/**
  * Search the plugin provider by $name and operate on the matching plugin. If multiple plugins are found
  * the users is asked for a selection. If no plugin was found, a corresponding message is printed
  *
  * @param string[] $names
  * @param callable $callback
  * @param array    $params
  */
 public function searchAndOperate($names, $callback, $params)
 {
     foreach ($names as $name) {
         $plugins = $this->pluginProvider->getPluginByName($name);
         $count = count($plugins);
         if ($count == 0) {
             $plugins = $this->pluginProvider->getPluginsByRepositoryName($name);
             $count = count($plugins);
         }
         if ($count == 0) {
             $this->ioService->writeln("\n<error>Could not find a plugin named '{$name}'</error>");
             return;
         }
         $this->ioService->writeln("\nWill now process '<comment>{$name}</comment>'");
         if ($count == 1) {
             $this->executeMethodCallback($plugins[0], $callback, $params);
             return;
         }
         $response = $this->pluginSelector->selectPlugin($plugins, array('all'));
         $plugins = $this->getPluginsFromResponse($response, $plugins);
         foreach ($plugins as $plugin) {
             $this->executeMethodCallback($plugin, $callback, $params);
         }
     }
 }
 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);
 }
Exemple #3
0
 /**
  * @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}");
 }
 /**
  * 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}");
 }
Exemple #5
0
 /**
  * @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;
 }
Exemple #6
0
 /**
  * @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}");
     }
 }
Exemple #7
0
 /**
  * @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>");
 }
 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));
 }
Exemple #9
0
 /**
  * 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>");
 }
Exemple #10
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) {
         $this->gitUtil->run("-C {$absPath} checkout {$branch}");
     }
     $branch = $branch ?: 'master';
     $this->ioService->writeln("Successfully checked out '{$branch}' for '{$pluginName}'\n");
 }
 /**
  * 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();
 }
 /**
  * @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");
 }
 /**
  * @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);
     }
 }
 /**
  * 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;
 }
 /**
  * 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");
 }
Exemple #16
0
 /**
  * @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>");
 }