protected function __construct(CommandEvent $event)
 {
     $this->composerEvent = $event;
     $this->io = $this->composerEvent->getIO();
     $this->extras = $this->composerEvent->getComposer()->getPackage()->getExtra();
     $this->fs = new Filesystem();
 }
 /**
  * Called from composer
  *
  * @param CommandEvent $event
  * @return void
  */
 public static function postUpdateAndInstall(CommandEvent $event)
 {
     $scriptName = self::isWindowsOs() ? 'typo3cms.bat' : 'typo3cms';
     $success = self::safeCopy($scriptName, './');
     if (!$success) {
         $event->getIO()->write(sprintf(self::COPY_FAILED_MESSAGE_TITLE, $scriptName));
         $event->getIO()->write(sprintf(self::COPY_FAILED_MESSAGE, $scriptName));
     }
 }
 protected static function runCommand(CommandEvent $event, Tool $tool, $command)
 {
     if ($event->getIO()->isVerbose()) {
         $event->getIO()->write($command);
     }
     $process = new Process($command, getcwd(), null, null, $tool->getTimeout());
     $process->run(function ($type, $buffer) use($event) {
         if ($event->getIO()->isVerbose()) {
             $event->getIO()->write($buffer, false);
         }
     });
     return $process;
 }
Esempio n. 4
0
 /**
  * Executes a command
  *
  * @param CommandEvent $event      Event
  * @param string       $consoleDir Console dir
  * @param string       $cmd        Command
  * @param int          $timeout    Timeout
  *
  * @return void
  */
 protected static function executeCommand(CommandEvent $event, $consoleDir, $cmd, $timeout = 300)
 {
     $php = escapeshellarg(self::getPhp(false));
     $console = escapeshellarg($consoleDir . '/console');
     if ($event->getIO()->isDecorated()) {
         $console .= ' --ansi';
     }
     $process = new Process($php . ' ' . $console . ' ' . $cmd, null, null, null, $timeout);
     $process->run(function ($type, $buffer) use($event) {
         $event->getIO()->write($buffer, false);
     });
     if (!$process->isSuccessful()) {
         throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd)));
     }
 }
 protected static function executeCommand(CommandEvent $event, $consoleDir, $cmd, $timeout = 300)
 {
     $php = escapeshellarg(static::getPhp(false));
     $phpArgs = implode(' ', array_map('escapeshellarg', static::getPhpArguments()));
     $console = escapeshellarg($consoleDir . '/console');
     if ($event->getIO()->isDecorated()) {
         $console .= ' --ansi';
     }
     $process = new Process($php . ($phpArgs ? ' ' . $phpArgs : '') . ' ' . $console . ' ' . $cmd, null, null, null, $timeout);
     $process->run(function ($type, $buffer) use($event) {
         $event->getIO()->write($buffer, false);
     });
     if (!$process->isSuccessful()) {
         throw new \RuntimeException(sprintf("An error occurred when executing the \"%s\" command:\n\n%s\n\n%s.", escapeshellarg($cmd), $process->getOutput(), $process->getErrorOutput()));
     }
 }
Esempio n. 6
0
 public static function enableInstallMode(CommandEvent $event)
 {
     if (!file_exists(SystemUtil::getInstallDoneFilePath())) {
         SystemUtil::enableInstallMode();
     }
     $event->getIO()->write('CampaignChain: Enabled install mode.');
 }
Esempio n. 7
0
    /**
     * Just dump welcome text on how to install eZ Platform.
     *
     * @param $event CommandEvent A instance
     */
    public static function installWelcomeText(CommandEvent $event)
    {
        $event->getIO()->write(<<<'EOT'

________________/\\\\\\\\\\\\\\\____________/\\\\\\\\\\\\\____/\\\\\\________________________________________/\\\\\_________________________________________________
 ________________\////////////\\\____________\/\\\/////////\\\_\////\\\______________________________________/\\\///__________________________________________________
  __________________________/\\\/_____________\/\\\_______\/\\\____\/\\\_______________________/\\\__________/\\\______________________________________________________
   _____/\\\\\\\\__________/\\\/_______________\/\\\\\\\\\\\\\/_____\/\\\_____/\\\\\\\\\_____/\\\\\\\\\\\__/\\\\\\\\\_______/\\\\\_____/\\/\\\\\\\_____/\\\\\__/\\\\\___
    ___/\\\/////\\\_______/\\\/_________________\/\\\/////////_______\/\\\____\////////\\\___\////\\\////__\////\\\//______/\\\///\\\__\/\\\/////\\\__/\\\///\\\\\///\\\_
     __/\\\\\\\\\\\______/\\\/___________________\/\\\________________\/\\\______/\\\\\\\\\\_____\/\\\_________\/\\\_______/\\\__\//\\\_\/\\\___\///__\/\\\_\//\\\__\/\\\_
      _\//\\///////_____/\\\/_____________________\/\\\________________\/\\\_____/\\\/////\\\_____\/\\\_/\\_____\/\\\______\//\\\__/\\\__\/\\\_________\/\\\__\/\\\__\/\\\_
       __\//\\\\\\\\\\__/\\\\\\\\\\\\\\\___________\/\\\______________/\\\\\\\\\_\//\\\\\\\\/\\____\//\\\\\______\/\\\_______\///\\\\\/___\/\\\_________\/\\\__\/\\\__\/\\\_
        ___\//////////__\///////////////____________\///______________\/////////___\////////\//______\/////_______\///__________\/////_____\///__________\///___\///___\///__


<fg=cyan>Welcome to eZ Platform!</fg=cyan>

<options=bold>You may now complete the eZ Platform installation with ezplatform:install command, example of use:</options=bold>
<comment>    $ php ezpublish/console ezplatform:install --env prod demo</comment>

<options=bold>After executing this, you can launch your browser* and get started.</options=bold>


* Assuming you have setup directory permissions and configured your web server (Apache/Nginx) correctly (see Install.md and doc/ folder in eZ Platform <root-directory>).
EOT
);
    }
Esempio n. 8
0
    /**
     * Just dump welcome text on how to install eZ Platform.
     *
     * @param $event CommandEvent A instance
     */
    public static function installWelcomeText(CommandEvent $event)
    {
        $event->getIO()->write(<<<'EOT'

________________/\\\\\\\\\\\\\\\____________/\\\\\\\\\\\\\____/\\\\\\________________________________________/\\\\\_________________________________________________
 ________________\////////////\\\____________\/\\\/////////\\\_\////\\\______________________________________/\\\///__________________________________________________
  __________________________/\\\/_____________\/\\\_______\/\\\____\/\\\_______________________/\\\__________/\\\______________________________________________________
   _____/\\\\\\\\__________/\\\/_______________\/\\\\\\\\\\\\\/_____\/\\\_____/\\\\\\\\\_____/\\\\\\\\\\\__/\\\\\\\\\_______/\\\\\_____/\\/\\\\\\\_____/\\\\\__/\\\\\___
    ___/\\\/////\\\_______/\\\/_________________\/\\\/////////_______\/\\\____\////////\\\___\////\\\////__\////\\\//______/\\\///\\\__\/\\\/////\\\__/\\\///\\\\\///\\\_
     __/\\\\\\\\\\\______/\\\/___________________\/\\\________________\/\\\______/\\\\\\\\\\_____\/\\\_________\/\\\_______/\\\__\//\\\_\/\\\___\///__\/\\\_\//\\\__\/\\\_
      _\//\\///////_____/\\\/_____________________\/\\\________________\/\\\_____/\\\/////\\\_____\/\\\_/\\_____\/\\\______\//\\\__/\\\__\/\\\_________\/\\\__\/\\\__\/\\\_
       __\//\\\\\\\\\\__/\\\\\\\\\\\\\\\___________\/\\\______________/\\\\\\\\\_\//\\\\\\\\/\\____\//\\\\\______\/\\\_______\///\\\\\/___\/\\\_________\/\\\__\/\\\__\/\\\_
        ___\//////////__\///////////////____________\///______________\/////////___\////////\//______\/////_______\///__________\/////_____\///__________\///___\///___\///__


<fg=cyan>Welcome to eZ Platform!</fg=cyan>

<options=bold>Please read the INSTALL.md file to complete the installation.</options>

<options=bold>Assuming that your database information were correctly entered, you may install a clean database by running the install command:</options>
<comment>    $ php app/console --env=prod ezplatform:install clean</comment>

EOT
);
    }
Esempio n. 9
0
 public static function deployAssets(CommandEvent $event)
 {
     $io = $event->getIO();
     if (!$io->askConfirmation('Would you like to update assets? (Y/n) ', true)) {
         return false;
     }
 }
Esempio n. 10
0
 public static function bootstrap(CommandEvent $event)
 {
     $webroot = $event->getIO()->askConfirmation('<info>Do you want your web directory to be a separate folder to root? [y/n] </info>', false);
     if ($webroot) {
         $webname = $event->getIO()->ask('<info>What do you want your public directory to be named? [default: public] </info>', 'public');
         $webname = trim($webname, '/');
         $assetDir = './' . $webname;
     } else {
         $webname = null;
         $assetDir = '.';
     }
     $generator = new BootstrapGenerator($webroot, $webname);
     $generator->create();
     $options = array_merge(self::getOptions($event), ['bolt-web-dir' => $assetDir]);
     self::installAssets($event, $options);
     $event->getIO()->write('<info>Your project has been setup</info>');
 }
Esempio n. 11
0
 protected static function executeCheck(CommandEvent $event, $appDir)
 {
     $phpFinder = new PhpExecutableFinder();
     $php = escapeshellarg($phpFinder->find());
     $check = escapeshellarg($appDir . '/check.php');
     $process = new Process($php . ' ' . $check);
     $process->run(function ($type, $buffer) use($event) {
         $event->getIO()->write($buffer, false);
     });
 }
Esempio n. 12
0
 public static function setPermissions(CommandEvent $event)
 {
     if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
         $event->getIO()->write('<info>No permissions setup is required on Windows.</info>');
         return;
     }
     $event->getIO()->write('Setting up permissions.');
     try {
         self::setPermissionsSetfacl($event);
         return;
     } catch (ProcessFailedException $setfaclException) {
         $event->getIO()->write(sprintf('<error>%s</error>', $setfaclException->getMessage()));
         $event->getIO()->write('<info>Trying chmod...</info>');
     }
     try {
         self::setPermissionsChmod($event);
         return;
     } catch (ProcessFailedException $chmodException) {
         $event->getIO()->write(sprintf('<error>%s</error>', $chmodException->getMessage()));
     }
 }
 public static function replaceViews(CommandEvent $event)
 {
     $event->getIO()->write('Copy ReCaptcha views to app/Resource/DS/ReCaptcha/views.');
     $directory = getcwd();
     self::$fileSystem = new Filesystem();
     $directory .= '/app/Resources';
     self::makeDirIfNOtExist($directory);
     $directory .= '/DS';
     self::makeDirIfNOtExist($directory);
     $directory .= '/ReCaptcha';
     self::makeDirIfNOtExist($directory);
     $directory .= '/views';
     self::makeDirIfNOtExist($directory);
     if (self::$fileSystem->exists($directory . '/form_div_layout.html.twig')) {
         if (!$event->getIO()->askConfirmation(sprintf('form_div_layout.html.twig already exist in %s. Would you like to rewrite this file? [y/N]  ', $directory), false)) {
             return;
         }
     }
     self::$fileSystem->copy(__DIR__ . '/../Resources/views/form_div_layout.html.twig', $directory . '/form_div_layout.html.twig', true);
     $event->getIO()->write('Files creation operation completed successfully.');
 }
Esempio n. 14
0
 /**
  * @static
  *
  * @param \Composer\Script\CommandEvent $event
  */
 public static function checkAndInstall($event)
 {
     $appDir = getcwd() . '/app';
     $resourcesPath = $appDir . '/Resources';
     if (is_dir($resourcesPath)) {
         $filesystem = new Filesystem();
         $jackrabbitDir = $resourcesPath . '/java/jackrabbit';
         $filesystem->ensureDirectoryExists($jackrabbitDir);
         if (!self::check($jackrabbitDir) && false !== ($file = self::download($event->getIO(), $jackrabbitDir))) {
             self::install($file, $appDir);
         }
     }
 }
Esempio n. 15
0
 public static function removeGitStuff(CommandEvent $event)
 {
     if ($event->getIO()->askConfirmation('Remove the GIT related stuff? [Y/n] ')) {
         $fs = new Filesystem();
         foreach (static::getPath() as $path) {
             $filename = $path . '/.gitkeep';
             if ($fs->exists($filename)) {
                 $fs->remove($filename);
             }
         }
         $fs->remove(static::getPath('root') . '/.git');
     }
 }
Esempio n. 16
0
 private static function spacingParametersYml(CommandEvent $event)
 {
     if (!file_exists($file = 'vendor/incenteev/composer-parameter-handler/Processor.php')) {
         return;
     }
     $content = file_get_contents($file);
     $matches = 0;
     $content = str_replace('Yaml::dump($actualValues, 99)', 'Yaml::dump($actualValues, 99, 2)', $content, $matches);
     if ($matches) {
         file_put_contents($file, $content, LOCK_EX);
         $event->getIO()->write('Updated spacing for incenteev parameters');
     }
 }
 public static function setPermissions(CommandEvent $event)
 {
     $event->getIO()->write('Setting up permissions.');
     try {
         self::setPermissionsSetfacl($event);
         return;
     } catch (ProcessFailedException $setfaclException) {
     }
     try {
         self::setPermissionsChmod($event);
         return;
     } catch (ProcessFailedException $chmodException) {
     }
     throw $setfaclException;
 }
 /**
  * Installs the shop bundle.
  *
  * @param CommandEvent $event CommandEvent instance
  * @throws \RuntimeException If an error occured
  */
 public static function installBundle(CommandEvent $event)
 {
     $event->getIO()->write('Installing the Aimeos shop bundle');
     $options = self::getOptions($event);
     if (!isset($options['symfony-app-dir']) || !is_dir($options['symfony-app-dir'])) {
         $msg = 'An error occurred because the "%1$s" option or the "%2$s" directory isn\'t available';
         throw new \RuntimeException(sprintf($msg, 'symfony-app-dir', $options['symfony-app-dir']));
     }
     if (!isset($options['symfony-web-dir']) || !is_dir($options['symfony-web-dir'])) {
         $msg = 'An error occurred because the "%1$s" option or the "%2$s" directory isn\'t available';
         throw new \RuntimeException(sprintf($msg, 'symfony-web-dir', $options['symfony-web-dir']));
     }
     self::updateConfigFile($options['symfony-app-dir'] . '/config/config.yml');
     self::updateRoutingFile($options['symfony-app-dir'] . '/config/routing.yml');
     self::createDirectory($options['symfony-web-dir'] . '/uploads');
 }
Esempio n. 19
0
 /**
  * Do install.
  *
  * @param CommandEvent $event The command event.
  *
  * @return  void
  */
 public static function install(CommandEvent $event)
 {
     $windPath = getcwd();
     $root = realpath($windPath . '/../..');
     $io = $event->getIO();
     // Create console file.
     $io->write('Writing console file to bin.');
     WindwalkerInstaller::createBinFile($root);
     // Config file
     $io->write('Prepare config file.');
     WindwalkerInstaller::copyConfigFile($root);
     // Bundles dir
     $bundlesDir = dirname($windPath) . '/windwalker-bundles';
     if (WindwalkerInstaller::createBundleDir($root)) {
         $io->write('Create bundle folder: ' . $bundlesDir);
     }
     // Complete
     $io->write('Install complete.');
 }
 /**
  * Do install.
  *
  * @param CommandEvent $event The command event.
  *
  * @return  void
  */
 public static function install(CommandEvent $event)
 {
     $windPath = getcwd();
     $root = realpath($windPath . '/../../..');
     $io = $event->getIO();
     $resourcesPath = $root . '/resources';
     if (!is_dir($resourcesPath)) {
         mkdir($resourcesPath, 0755, true);
         file_put_contents($resourcesPath . '/index.html', '<html></html>');
         $io->write('Create resources folder.');
     }
     $seederPath = $resourcesPath . '/seeders/DatabaseSeeder.php';
     if (!is_file($seederPath)) {
         mkdir(dirname($seederPath), 0755, true);
         copy($windPath . '/Resources/templates/DatabaseSeeder.php', $seederPath);
         $io->write('Create Seeder file.');
     }
     // Complete
     $io->write('Install complete.');
 }
Esempio n. 21
0
 protected static function executeCommand(CommandEvent $event, $cmd, $timeout = 300)
 {
     $extra = $event->getComposer()->getPackage()->getExtra();
     $binDir = $extra['sb-bin-dir'];
     if (!is_dir($binDir)) {
         echo 'The sb-bin-dir (' . $binDir . ') specified in composer.json was not found in ' . getcwd() . ', can not clear the cache.' . PHP_EOL;
         return;
     }
     $php = escapeshellarg(self::getPhp());
     $console = escapeshellarg($binDir . '/sb');
     if ($event->getIO()->isDecorated()) {
         $console .= ' --ansi';
     }
     $process = new Process($php . ' ' . $console . ' ' . $cmd, null, null, null, $timeout);
     $process->run(function ($type, $buffer) {
         echo $buffer;
     });
     if (!$process->isSuccessful()) {
         throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd)));
     }
 }
 private static function installBootstrap(CommandEvent $event)
 {
     $event->getIO()->write('<info>Generating bootstrap assets</info>');
     $configOptions = self::getConfigOptions($event);
     $vendorDir = $configOptions['vendor-dir'];
     if (!is_dir($vendorDir)) {
         echo "The vendor-dir ({$vendorDir}) specified in composer.json was not found in " . getcwd() . ", can not build bootstrap file.\n";
         return;
     }
     $extraOptions = self::getExtraOptions($event);
     $webDir = $extraOptions['nette-web-dir'];
     if (!is_dir($webDir)) {
         echo "The nette-web-dir ({$webDir}) specified in composer.json was not found in " . getcwd() . ", can not build bootstrap file.\n";
         return;
     }
     $bootstrapDir = $vendorDir . "/twitter/bootstrap";
     self::createDirectory("{$webDir}/css/bootstrap3");
     self::createDirectory("{$webDir}/js/bootstrap3");
     self::createDirectory("{$webDir}/images");
     /*require  $vendorDir . '/leafo/lessphp/lessc.inc.php';
       $lessc = new \lessc();
       $css = $lessc->compileFile("$bootstrapDir/less/bootstrap.less");
       file_put_contents("$webDir/css/bootstrap/bootstrap.css", $css);*/
     $cssSrc = "{$bootstrapDir}/dist/css/bootstrap.min.css";
     $cssDst = "{$webDir}/css/bootstrap3/bootstrap.min.css";
     copy($cssSrc, $cssDst);
     foreach (glob("{$bootstrapDir}/less/*.less") as $src) {
         $dst = "{$webDir}/css/bootstrap3/" . basename($src);
         copy($src, $dst);
     }
     foreach (glob("{$bootstrapDir}/js/bootstrap*.js") as $src) {
         $dst = "{$webDir}/js/bootstrap3/" . basename($src);
         copy($src, $dst);
     }
     foreach (glob("{$bootstrapDir}/assets/ico/*.png") as $src) {
         $dst = "{$webDir}/images/" . basename($src);
         copy($src, $dst);
     }
 }
Esempio n. 23
0
 protected function executeCommand($consoleDir, $cmd, $output = true, $timeout = 300)
 {
     $event = $this->event;
     $php = escapeshellarg(static::getPhp(false));
     $phpArgs = implode(' ', array_map('escapeshellarg', static::getPhpArguments()));
     $console = escapeshellarg($consoleDir . '/console');
     if ($this->event->getIO()->isDecorated()) {
         $console .= ' --ansi';
     }
     $process = new Process($php . ($phpArgs ? ' ' . $phpArgs : '') . ' ' . $console . ' ' . $cmd, null, null, null, $timeout);
     if ($output) {
         $process->run(function ($type, $buffer) use($event) {
             $event->getIO()->write($buffer, false);
         });
     } else {
         $process->run();
     }
     if (!$process->isSuccessful()) {
         throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd)));
     }
     return $process;
 }
Esempio n. 24
0
 public static function deleteCache(CommandEvent $event)
 {
     $options = array_merge(array('symfony-app-dir' => 'app'), $event->getComposer()->getPackage()->getExtra());
     $cacheDir = $options['symfony-app-dir'] . '/cache';
     $event->getIO()->write('Clearing the cache...');
     static::removeContentFrom($cacheDir);
 }
Esempio n. 25
0
 /**
  * Just dump help text on how to dump assets
  *
  * Typically to use this instead on composer update as dump command uses prod environment where cache is not cleared,
  * causing it to sometimes crash when cache needs to be cleared.
  *
  * @param $event CommandEvent A instance
  */
 public static function dumpAssetsHelpText(CommandEvent $event)
 {
     $event->getIO()->write('<info>To dump eZ Publish production assets, execute the following:</info>');
     $event->getIO()->write('    php ezpublish/console assetic:dump --env=prod web');
     $event->getIO()->write('');
 }
Esempio n. 26
0
 /**
  * Updates the Puli repository after Composer installations/updates.
  *
  * @param CommandEvent $event The Composer event.
  */
 public function postInstall(CommandEvent $event)
 {
     // Plugin has been uninstalled
     if (!file_exists(__FILE__)) {
         return;
     }
     if (!$this->initialized) {
         $this->initialize($event->getComposer(), $event->getIO());
     }
     // This method is called twice. Run it only once.
     if (!$this->runPostInstall) {
         return;
     }
     $this->runPostInstall = false;
     $io = $event->getIO();
     $io->write('<info>Looking for updated Puli packages</info>');
     $rootPackage = $event->getComposer()->getPackage();
     $composerPackages = $this->loadComposerPackages($event->getComposer());
     $prodPackageNames = $this->filterProdPackageNames($composerPackages, $rootPackage);
     $env = $event->isDevMode() ? PuliPackage::ENV_DEV : PuliPackage::ENV_PROD;
     try {
         $puliPackages = $this->loadPuliPackages();
     } catch (PuliRunnerException $e) {
         $this->printWarning($io, 'Could not load Puli packages', $e);
         return;
     }
     // Don't remove non-existing packages in production environment
     // Removed packages could be dev dependencies (i.e. "require-dev"
     // of the root package or "require" of another dev dependency), and
     // we can't find out whether they are since Composer doesn't load them
     if (PuliPackage::ENV_PROD !== $env) {
         $this->removeRemovedPackages($composerPackages, $puliPackages, $io);
     }
     $this->installNewPackages($composerPackages, $prodPackageNames, $puliPackages, $io, $event->getComposer());
     // Don't print warnings for non-existing packages in production
     if (PuliPackage::ENV_PROD !== $env) {
         $this->checkForNotFoundErrors($puliPackages, $io);
     }
     $this->checkForNotLoadableErrors($puliPackages, $io);
     $this->adoptComposerName($puliPackages, $io, $event->getComposer());
     $this->buildPuli($io);
 }
 /**
  * Method which executes npm commands.
  *
  * @param string       $command
  * @param CommandEvent $event
  * @param bool|true    $showOutput
  * @param int          $timeout
  */
 private static function executeNpmCommand($command, CommandEvent $event, $showOutput = true, $timeout = 500)
 {
     $npm = (new ExecutableFinder())->find('npm');
     $handler = function ($type, $buffer) use($event) {
         $event->getIO()->write($buffer, false);
     };
     $process = new Process(sprintf('%s %s', $npm, $command), null, null, null, $timeout);
     if (!$showOutput) {
         $handler = function () {
         };
     }
     $process->run($handler);
 }
Esempio n. 28
0
    protected static function updateDirectoryStructure(CommandEvent $event, $rootDir, $appDir, $binDir, $varDir, $webDir)
    {
        $event->getIO()->write('Updating Symfony directory structure...');
        $fs = new Filesystem();
        $fs->mkdir(array($binDir, $varDir));
        foreach (array($appDir . '/console' => $binDir . '/console', $appDir . '/phpunit.xml.dist' => $rootDir . '/phpunit.xml.dist') as $source => $target) {
            $fs->rename($source, $target, true);
        }
        foreach (array('/logs', '/cache') as $dir) {
            $fs->rename($appDir . $dir, $varDir . $dir);
        }
        $gitignore = <<<EOF
/web/bundles/
/app/config/parameters.yml
/var/bootstrap.php.cache
/var/SymfonyRequirements.php
/var/cache/*
/var/logs/*
!var/cache/.gitkeep
!var/logs/.gitkeep
/build/
/vendor/
/bin/*
!bin/console
!bin/symfony_requirements
/composer.phar
EOF;
        $phpunitKernelBefore = <<<EOF
    <!--
    <php>
        <server name="KERNEL_DIR" value="/path/to/your/app/" />
    </php>
    -->
EOF;
        $phpunitKernelAfter = <<<EOF
    <php>
        <server name="KERNEL_DIR" value="{$appDir}/" />
    </php>
EOF;
        $phpunit = str_replace(array('<directory>../src', '"bootstrap.php.cache"', $phpunitKernelBefore), array('<directory>src', '"' . $varDir . '/bootstrap.php.cache"', $phpunitKernelAfter), file_get_contents($rootDir . '/phpunit.xml.dist'));
        $composer = str_replace("\"symfony-app-dir\": \"app\",", "\"symfony-app-dir\": \"app\",\n        \"symfony-bin-dir\": \"bin\",\n        \"symfony-var-dir\": \"var\",", file_get_contents($rootDir . '/composer.json'));
        $fs->dumpFile($webDir . '/app.php', str_replace($appDir . '/bootstrap.php.cache', $varDir . '/bootstrap.php.cache', file_get_contents($webDir . '/app.php')));
        $fs->dumpFile($webDir . '/app_dev.php', str_replace($appDir . '/bootstrap.php.cache', $varDir . '/bootstrap.php.cache', file_get_contents($webDir . '/app_dev.php')));
        $fs->dumpFile($binDir . '/console', str_replace(array(".'/bootstrap.php.cache'", ".'/AppKernel.php'"), array(".'/" . $fs->makePathRelative($varDir, $binDir) . "bootstrap.php.cache'", ".'/" . $fs->makePathRelative($appDir, $binDir) . "AppKernel.php'"), file_get_contents($binDir . '/console')));
        $fs->dumpFile($rootDir . '/phpunit.xml.dist', $phpunit);
        $fs->dumpFile($rootDir . '/composer.json', $composer);
        $fs->dumpFile($rootDir . '/.gitignore', $gitignore);
        $fs->chmod($binDir . '/console', 0755);
    }
Esempio n. 29
0
 protected static function hasDirectory(CommandEvent $event, $configName, $path, $actionName)
 {
     if (!is_dir($path)) {
         $event->getIO()->write(sprintf('The %s (%s) specified in composer.json was not found in %s, can not %s.', $configName, $path, getcwd(), $actionName));
         return false;
     }
     return true;
 }
Esempio n. 30
0
 /**
  * Handle the dependency version.
  *
  * @param CommandEvent $event
  * @param string       $dependency
  * @param string       $content
  */
 private static function handleDependencyVersion(CommandEvent $event, $dependency, $content)
 {
     $versions = self::getAvailableDependencyVersions($content, $dependency . '_version');
     $defaultVersion = self::getDefaultVersion($content, $dependency);
     preg_match('/#' . $dependency . '_version.*\\r?\\n/', $content, $versionMatches);
     $versionValidator = function ($value) use($versions) {
         if (!in_array($value, $versions)) {
             throw new \InvalidArgumentException('This version is not valid');
         }
         return $value;
     };
     $chosenVersion = $event->getIO()->askAndValidate('<info>' . $dependency . ' version (' . implode(', ', $versions) . ')</info> [<comment>' . $defaultVersion . '</comment>] : ', $versionValidator, 5, $defaultVersion);
     if ('php' === $dependency or 'nodejs' === $dependency) {
         if ('php' === $dependency) {
             $boxVersion = '7.0' === $chosenVersion ? '3.0.0' : '2.0.0';
             self::replaceValueInFile('Vagrantfile', '/(box_version\\s+=>\\s+)\'.+(\',)/', '$1\'~> ' . $boxVersion . '$2');
         }
         self::replaceValueInFile(self::ANSIBLE_FILE, '/(' . $dependency . '_version:.+)\'.+(\').+(\\S)/', '$1 \'' . $chosenVersion . '$2');
     } else {
         self::replaceValueInFile(self::ANSIBLE_FILE, '/#(' . $dependency . '_version:.+)\'.+(\').+(\\S)/', '$1 \'' . $chosenVersion . '$2');
     }
 }