コード例 #1
0
 public function writeBuildProperties($installDir, $shopHost, $shopPath, $dbUser, $dbPassword, $dbName, $dbHost, $port = 3306)
 {
     $this->ioService->writeln("<info>Writing build.properties</info>");
     $shopPath = '/' . ltrim($shopPath, '/');
     $config = sprintf($this->buildPropertiesTemplate, $shopHost, $shopPath, $dbName, $dbHost, $dbUser, $dbPassword, $port);
     file_put_contents($installDir . '/build/build.properties', $config);
 }
コード例 #2
0
ファイル: Checkout.php プロジェクト: shobcheye/sw-cli-tools
 /**
  * @param string $repo
  * @param string $branch
  * @param string $destination
  */
 public function checkout($repo, $branch, $destination)
 {
     $this->ioService->writeln("<info>Checkout out {$repo} to {$destination}</info>");
     $repo = escapeshellarg($repo);
     $branch = escapeshellarg($branch);
     $destination = escapeshellarg($destination);
     $this->gitUtil->run("clone --progress -b {$branch} {$repo} {$destination}");
 }
コード例 #3
0
ファイル: Utilities.php プロジェクト: 0x4/sw-cli-tools
 /**
  * Ask for a valid shopware path until the user enters it
  *
  * @param  string $shopwarePath
  * @return string
  */
 public function getValidShopwarePath($shopwarePath = null)
 {
     if (!$shopwarePath) {
         $shopwarePath = realpath(getcwd());
     }
     if ($this->isShopwareInstallation($shopwarePath)) {
         return $shopwarePath;
     }
     return $this->ioService->askAndValidate("Path to your Shopware installation: ", array($this, 'validateShopwarePath'));
 }
コード例 #4
0
 /**
  * Download a release and unzip it
  *
  * @param string $release
  * @param string $installDir
  */
 public function downloadRelease($release, $installDir)
 {
     $this->ioService->writeln("<info>Downloading release</info>");
     $zipLocation = $this->downloadFromUpdateApi($release);
     if (!is_dir($installDir)) {
         mkdir($installDir);
     }
     $this->ioService->writeln("<info>Unzipping archive</info>");
     $this->processExecutor->execute("unzip -qq {$zipLocation} -d {$installDir}");
 }
コード例 #5
0
ファイル: Demodata.php プロジェクト: 0x4/sw-cli-tools
 /**
  * @param $installDir
  */
 private function runCliCommands($installDir)
 {
     $this->ioService->writeln("<info>Running license import</info>");
     $this->utilities->executeCommand("{$installDir}/bin/console sw:generate:attributes");
     $this->utilities->executeCommand("{$installDir}/bin/console sw:plugin:refresh");
     $this->utilities->executeCommand("{$installDir}/bin/console sw:plugin:install SwagLicense --activate");
     $licenseFile = @getenv('HOME') . '/licenses.txt';
     if (file_exists($licenseFile)) {
         $this->utilities->executeCommand("{$installDir}/bin/console swaglicense:import {$licenseFile}");
     }
 }
コード例 #6
0
ファイル: Install.php プロジェクト: shobcheye/sw-cli-tools
 /**
  * @param Plugin $plugin
  * @param string $shopwarePath
  * @param bool   $inputActivate
  * @param string $branch
  * @param bool   $useHttp
  */
 public function install(Plugin $plugin, $shopwarePath, $inputActivate = false, $branch = 'master', $useHttp = false)
 {
     $pluginName = $plugin->name;
     $this->checkout->checkout($plugin, $shopwarePath . '/engine/Shopware/Plugins/Local/', $branch, $useHttp);
     if ($inputActivate) {
         $this->ioService->writeln(exec($shopwarePath . '/bin/console sw:plugin:refresh'));
         $this->ioService->writeln(exec($shopwarePath . '/bin/console sw:plugin:install --activate ' . $pluginName));
     }
     $this->addPluginVcsMapping($plugin, $shopwarePath);
     return;
 }
コード例 #7
0
ファイル: RunCliCommand.php プロジェクト: 0x4/sw-cli-tools
 /**
  * @param  string    $shopwarePath
  * @param  IoService $ioService
  * @return string
  */
 public function getValidShopwarePath($shopwarePath, IoService $ioService)
 {
     if (!$shopwarePath) {
         $shopwarePath = realpath(getcwd());
     }
     do {
         if ($this->container->get('utilities')->isShopwareInstallation($shopwarePath)) {
             return $shopwarePath;
         }
     } while (($shopwarePath = dirname($shopwarePath)) && $shopwarePath != '/');
     return $ioService->askAndValidate("Path to your Shopware installation: ", array($this->container->get('utilities'), 'validateShopwarePath'));
 }
コード例 #8
0
ファイル: Directory.php プロジェクト: pixolith/sw-cli-tools
 /**
  * @param InstallationRequest $request
  */
 public function installShopware(InstallationRequest $request)
 {
     $this->generateVcsMapping($request->installDir);
     $this->writeShopwareConfig($request->installDir, $request->databaseName);
     $this->setupDatabase($request);
     $this->lockInstaller($request->installDir);
     $this->ioService->writeln("<info>Running post release scripts</info>");
     $this->postInstall->fixPermissions($request->installDir);
     $this->postInstall->setupTheme($request->installDir);
     $this->postInstall->importCustomDeltas($request->databaseName);
     $this->postInstall->runCustomScripts($request->installDir);
     $this->demodata->runLicenseImport($request->installDir);
     $this->ioService->writeln("<info>Install completed</info>");
 }
コード例 #9
0
ファイル: Vcs.php プロジェクト: shobcheye/sw-cli-tools
 /**
  * Runs the steps needed to setup shopware
  *
  * @param $branch
  * @param string $installDir
  * @param $basePath
  * @param $database
  * @param null $httpUser
  * @param bool $noDemoData
  */
 public function installShopware($branch, $installDir, $basePath, $database, $httpUser = null, $noDemoData = false)
 {
     $this->checkoutRepos($branch, $installDir, $httpUser);
     $this->generateVcsMapping($installDir);
     $this->writeBuildProperties($installDir, $basePath, $database);
     $this->setupDatabase($installDir, $database);
     $this->demoData->runLicenseImport($installDir);
     if (!$noDemoData) {
         $this->demoData->setup($installDir);
     }
     $this->ioService->writeln("<info>Running post release scripts</info>");
     $this->postInstall->fixPermissions($installDir);
     $this->postInstall->importCustomDeltas($database);
     $this->postInstall->runCustomScripts($installDir);
     $this->postInstall->fixShopHost($database);
     $this->ioService->writeln("<info>Install completed</info>");
 }
コード例 #10
0
 public function createVcsMapping($installDir, $paths)
 {
     $this->ioService->writeln("<info>Generating VCS mapping</info>");
     $dir = $installDir . '/.idea';
     if (!is_dir($dir)) {
         mkdir($dir);
     }
     $mappings = array();
     foreach ($paths as $path) {
         if ($path == '/') {
             $path = '';
         }
         $mappings[] = sprintf($this->templateVcsMappingDirectory, $path);
     }
     $mappings = implode("\n", $mappings);
     file_put_contents($dir . '/vcs.xml', sprintf($this->templateVcsMapping, $mappings));
 }
コード例 #11
0
ファイル: Checkout.php プロジェクト: 0x4/sw-cli-tools
 /**
  * @param string $branch
  * @param string $cloneUrl
  * @param string $absPath
  * @param string $pluginName
  */
 private function installPlugin($branch, $cloneUrl, $absPath, $pluginName)
 {
     $this->gitUtil->run("clone  --progress {$cloneUrl} {$absPath}");
     if ($branch) {
         $this->gitUtil->run("-C {$absPath} checkout {$branch}");
     }
     $branch = $branch ?: 'master';
     $this->ioService->writeln("Successfully checked out '{$branch}' for '{$pluginName}'\n");
 }
コード例 #12
0
 /**
  * Initializes the main WriterInterface instance where the data will be written
  * Calls the create method
  * Flushes data at the end
  * Handles pre and pos query handling (truncating, enable/disable foreign keys)
  */
 public final function generateData()
 {
     $path = explode('\\', get_class($this));
     $writer = $this->writerManager->createWriter(strtolower(array_pop($path)), 'sql');
     $writer->write($this->prepareTables());
     $this->create($writer);
     $this->ioService->writeln("");
     $writer->write($this->enableKeys());
     $this->writerManager->flushAll();
     $this->writerManager->clear();
 }
コード例 #13
0
 /**
  * @param string $branch
  * @param string $cloneUrl
  * @param string $absPath
  * @param string $pluginName
  */
 private function installPlugin($branch, $cloneUrl, $absPath, $pluginName)
 {
     $this->gitUtil->run("clone  --progress {$cloneUrl} {$absPath}");
     if ($branch) {
         // the CWD change is a fix for older versions of GIT which do not support the -C flag
         $cwd = getcwd();
         $this->utilities->changeDir($absPath);
         $this->gitUtil->run("checkout {$branch}");
         $this->utilities->changeDir($cwd);
     }
     $branch = $branch ?: 'master';
     $this->ioService->writeln("Successfully checked out '{$branch}' for '{$pluginName}'\n");
 }
コード例 #14
0
 /**
  * Older releases needs to be installed directly via the s3 url
  *
  * @param  string $release
  * @return string
  */
 private function downloadFromUrl($release)
 {
     $url = $this->getDownloadUrl($release);
     $target = $this->getTempFile();
     $cacheFile = $this->getCacheFilePath($release);
     if (!file_exists($cacheFile)) {
         $this->ioService->writeln("<info>Downloading release {$release}</info>");
         $this->downloader->download($url, $target);
         copy($target, $cacheFile);
     } else {
         $this->ioService->writeln("<info>Reading cached release download for {$release}</info>");
     }
     return $cacheFile;
 }
コード例 #15
0
 /**
  * @param  string            $installDir
  * @throws \RuntimeException
  */
 private function importSnippetDeltas($installDir)
 {
     $this->ioService->writeln("<info>Importing snippet delta</info>");
     $installDataDir = $this->getInstallDataFolder($installDir);
     $snippetsFilePath = "{$installDataDir}/snippets.sql";
     if (!file_exists($installDataDir) || !file_exists($snippetsFilePath)) {
         $this->ioService->writeln("<error>Could not import snippet deltas. This is only ok for shopware versions < 4.2</error>");
         return;
     }
     $deltas = explode(";\n", file_get_contents($snippetsFilePath));
     foreach ($deltas as $delta) {
         $this->getConnection()->exec($delta);
     }
 }
コード例 #16
0
 /**
  * Ask the user to select one of the given plugins or enter one of $allowedAnswers
  * Will loop until a valid choice was made
  *
  * @param  Plugin[] $plugins
  * @param  string[] $allowedAnswers
  * @return string
  */
 public function selectPlugin($plugins, $allowedAnswers = array('all'))
 {
     while (true) {
         system('clear');
         $this->outputRenderer->show($plugins);
         $question = new Question($this->formatQuestion(count($plugins), $allowedAnswers));
         $response = $this->ioService->ask($question);
         if ($range = $this->getPluginRange($response)) {
             return array_filter(array_map(function ($number) use($plugins) {
                 return isset($plugins[$number - 1]) ? $plugins[$number - 1] : null;
             }, $range), function ($plugin) {
                 return $plugin;
             });
         } elseif (isset($plugins[$response - 1])) {
             return $plugins[$response - 1];
         } elseif (in_array($response, $allowedAnswers)) {
             return $response;
         } else {
             $question = new Question('<error>Invalid answer, hit enter to continue</error>');
             $this->ioService->ask($question);
         }
     }
 }
コード例 #17
0
 /**
  * Show the plugin list to the user, until "all" or "exit" was entered
  *
  * @param callable $callback
  * @param array    $params
  */
 public function operationLoop($callback, $params)
 {
     $plugins = $this->pluginProvider->getPlugins();
     while (true) {
         $response = $this->pluginSelector->selectPlugin($plugins, array('all', 'exit'));
         if ($response == 'exit') {
             return;
         }
         $this->ioService->cls();
         $responsePlugins = $this->getPluginsFromResponse($response, $plugins);
         foreach ($responsePlugins as $plugin) {
             $this->executeMethodCallback($plugin, $callback, $params);
         }
         $this->ioService->ask("\n<error>Done, hit enter to continue.</error>");
         $this->ioService->cls();
     }
 }
コード例 #18
0
 /**
  * Print a little legend with the repository color keys
  *
  * @param DisplayPlugin[] $plugins
  */
 private function printLegend($plugins)
 {
     if (!$this->config['general']['enableRepositoryColors']) {
         return;
     }
     $repos = array();
     foreach ($plugins as $plugin) {
         $repos[$plugin->repoType . '(' . $plugin->repository . ')'] = $this->getColorForPlugin($plugin);
     }
     $output = array();
     foreach ($repos as $name => $color) {
         $color = $color ?: 'white';
         $output[] = "<fg={$color}>{$name}</fg={$color}>";
     }
     $this->ioService->writeln('Legend:');
     $this->ioService->writeln(implode(', ', $output) . "\n");
 }
コード例 #19
0
ファイル: Release.php プロジェクト: shopwarelabs/sw-cli-tools
 /**
  * @param InstallationRequest $request
  */
 public function installShopware(InstallationRequest $request)
 {
     $this->releaseDownloader->downloadRelease($request->getRelease(), $request->getInstallDir());
     if ($request->getRelease() === 'latest' || version_compare($request->getRelease(), '5.1.2', '>=')) {
         $this->createDatabase($request);
         $this->createShopwareConfig($request);
         $this->runInstaller($request);
     } else {
         $this->generateVcsMapping($request->getAbsoluteInstallDir());
         $this->createShopwareConfig($request);
         $this->setupDatabase($request);
         $this->lockInstaller($request->getAbsoluteInstallDir());
     }
     $this->ioService->writeln("<info>Running post release scripts</info>");
     $this->postInstall->fixPermissions($request->getAbsoluteInstallDir());
     $this->postInstall->setupTheme($request->getAbsoluteInstallDir());
     $this->postInstall->importCustomDeltas($request->getDbName());
     $this->postInstall->runCustomScripts($request->getAbsoluteInstallDir());
     $this->demodata->runLicenseImport($request->getAbsoluteInstallDir());
     $this->ioService->writeln("<info>Install completed</info>");
 }
コード例 #20
0
 /**
  * @param InputInterface $input
  * @param IoService $ioService
  */
 private function askDatabasePassword(InputInterface $input, IoService $ioService)
 {
     $databasePassword = $input->getOption('db-password');
     if (!$databasePassword) {
         $databasePassword = $ioService->ask("Please provide the database password: ");
         $input->setOption('db-password', trim($databasePassword));
     }
 }
コード例 #21
0
 /**
  * @param InputInterface $input
  * @param IoService      $ioService
  *
  * @return string
  */
 private function askBranch(InputInterface $input, IoService $ioService)
 {
     $branch = $input->getOption('branch');
     if (!$branch) {
         $branch = $ioService->ask('Please provide the branch you want to install <master>: ');
         $branch = trim($branch) ? $branch : 'master';
         $input->setOption('branch', $branch);
         return $branch;
     }
     return $branch;
 }
コード例 #22
0
 /**
  * @param InputInterface $input
  * @param IoService      $ioService
  * @param string         $suggestion
  */
 protected function askBasePath(InputInterface $input, IoService $ioService, $suggestion)
 {
     $basePath = $input->getOption('basePath');
     if (!$basePath) {
         $basePath = $ioService->ask("Please provide the basepath you want to use <{$suggestion}>: ");
         $input->setOption('basePath', trim($basePath) ? $basePath : $suggestion);
     }
 }
コード例 #23
0
 /**
  * @param InputInterface $input
  * @param IoService      $ioService
  *
  * @return string
  */
 private function askBranch(InputInterface $input, IoService $ioService)
 {
     $branch = $input->getOption('branch');
     if (!$branch) {
         $branchSuggestion = self::MAIN_BRANCH;
         $branch = $ioService->ask("Please provide the branch you want to install <{$branchSuggestion}>: ");
         $branch = trim($branch) ? $branch : self::MAIN_BRANCH;
         $input->setOption('branch', $branch);
         return $branch;
     }
     return $branch;
 }