Exemple #1
1
 /**
  * {@inheritDoc}
  */
 public function initialize()
 {
     if (Filesystem::isLocalPath($this->url)) {
         $this->repoDir = $this->url;
     } else {
         $cacheDir = $this->config->get('cache-vcs-dir');
         $this->repoDir = $cacheDir . '/' . preg_replace('{[^a-z0-9]}i', '-', $this->url) . '/';
         $fs = new Filesystem();
         $fs->ensureDirectoryExists($cacheDir);
         if (!is_writable(dirname($this->repoDir))) {
             throw new \RuntimeException('Can not clone ' . $this->url . ' to access package information. The "' . $cacheDir . '" directory is not writable by the current user.');
         }
         // update the repo if it is a valid hg repository
         if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
             if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
                 $this->io->write('<error>Failed to update ' . $this->url . ', package information from this repository may be outdated (' . $this->process->getErrorOutput() . ')</error>');
             }
         } else {
             // clean up directory and do a fresh clone into it
             $fs->removeDirectory($this->repoDir);
             if (0 !== $this->process->execute(sprintf('hg clone --noupdate %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoDir)), $output, $cacheDir)) {
                 $output = $this->process->getErrorOutput();
                 if (0 !== $this->process->execute('hg --version', $ignoredOutput)) {
                     throw new \RuntimeException('Failed to clone ' . $this->url . ', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
                 }
                 throw new \RuntimeException('Failed to clone ' . $this->url . ', could not read packages from it' . "\n\n" . $output);
             }
         }
     }
     $this->getTags();
     $this->getBranches();
 }
 /**
  * Makes sure the given directory exists and has no content.
  *
  * @param string $directory
  */
 protected function ensureDirectoryExistsAndClear($directory)
 {
     if (is_dir($directory)) {
         $this->fs->removeDirectory($directory);
     }
     mkdir($directory, 0777, true);
 }
 protected function tearDown()
 {
     if (is_dir($this->workingDir)) {
         $this->fs->removeDirectory($this->workingDir);
     }
     // reset the static version cache
     $refl = new \ReflectionProperty('Composer\\Util\\Git', 'version');
     $refl->setAccessible(true);
     $refl->setValue(null, null);
 }
 /**
  * Remove asset directories if the package is of type
  * project or library
  */
 public function complete()
 {
     $type = $this->getConfigKey('Placeholders', 'type')['value'];
     $wp_types = ['wordpress-theme', 'wordpress-plugin'];
     if (in_array($type, $wp_types)) {
         return;
     }
     $base_dir = $this->getConfigKey('BaseDir');
     $fs = new Util\Filesystem();
     $this->io->write("Removing assets directories");
     $fs->removeDirectory("{$base_dir}/assets");
     $fs->removeDirectory("{$base_dir}/w-org-assets");
 }
Exemple #5
0
 public static function postCreateProject(Event $event)
 {
     $config = $event->getComposer()->getConfig();
     $rootPath = dirname($config->get('vendor-dir'));
     // cleanup
     @unlink($rootPath . '/.travis.yml');
     rename($rootPath . '/plugins_example', $rootPath . '/plugins');
     rename($rootPath . '/website_example', $rootPath . '/website');
     $filesystem = new Filesystem();
     $filesystem->removeDirectory($rootPath . '/update');
     $filesystem->removeDirectory($rootPath . '/build');
     $filesystem->removeDirectory($rootPath . '/tests');
     $filesystem->removeDirectory($rootPath . '/.svn');
     $filesystem->removeDirectory($rootPath . '/.git');
 }
 public function tearDown()
 {
     if (is_dir($this->tmpdir)) {
         $fs = new Filesystem();
         $fs->removeDirectory($this->tmpdir);
     }
 }
 /**
  * Duplicates search packages.
  *
  * @param string $path
  * @param array $vars
  */
 protected function checkDuplicates($path, array $vars = array())
 {
     $packageType = substr($vars['type'], strlen('bitrix') + 1);
     $localDir = explode('/', $vars['bitrix_dir']);
     array_pop($localDir);
     $localDir[] = 'local';
     $localDir = implode('/', $localDir);
     $oldPath = str_replace(array('{$bitrix_dir}', '{$name}'), array($localDir, $vars['name']), $this->locations[$packageType]);
     if (in_array($oldPath, static::$checkedDuplicates)) {
         return;
     }
     if ($oldPath !== $path && file_exists($oldPath) && $this->io && $this->io->isInteractive()) {
         $this->io->writeError('    <error>Duplication of packages:</error>');
         $this->io->writeError('    <info>Package ' . $oldPath . ' will be called instead package ' . $path . '</info>');
         while (true) {
             switch ($this->io->ask('    <info>Delete ' . $oldPath . ' [y,n,?]?</info> ', '?')) {
                 case 'y':
                     $fs = new Filesystem();
                     $fs->removeDirectory($oldPath);
                     break 2;
                 case 'n':
                     break 2;
                 case '?':
                 default:
                     $this->io->writeError(array('    y - delete package ' . $oldPath . ' and to continue with the installation', '    n - don\'t delete and to continue with the installation'));
                     $this->io->writeError('    ? - print help');
                     break;
             }
         }
     }
     static::$checkedDuplicates[] = $oldPath;
 }
 /**
  * Duplicates search packages
  *
  * @param string $templatePath
  * @param array $vars
  */
 protected function checkDuplicates($templatePath, array $vars = array())
 {
     /**
      * Incorrect paths for backward compatibility
      */
     $oldLocations = array('module' => 'local/modules/{$name}/', 'component' => 'local/components/{$name}/', 'theme' => 'local/templates/{$name}/');
     $packageType = substr($vars['type'], strlen('bitrix') + 1);
     $oldLocation = str_replace('{$name}', $vars['name'], $oldLocations[$packageType]);
     if (in_array($oldLocation, static::$checkedDuplicates)) {
         return;
     }
     if ($oldLocation !== $templatePath && file_exists($oldLocation) && $this->io && $this->io->isInteractive()) {
         $this->io->writeError('    <error>Duplication of packages:</error>');
         $this->io->writeError('    <info>Package ' . $oldLocation . ' will be called instead package ' . $templatePath . '</info>');
         while (true) {
             switch ($this->io->ask('    <info>Delete ' . $oldLocation . ' [y,n,?]?</info> ', '?')) {
                 case 'y':
                     $fs = new Filesystem();
                     $fs->removeDirectory($oldLocation);
                     break 2;
                 case 'n':
                     break 2;
                 case '?':
                 default:
                     $this->io->writeError(['    y - delete package ' . $oldLocation . ' and to continue with the installation', '    n - don\'t delete and to continue with the installation']);
                     $this->io->writeError('    ? - print help');
                     break;
             }
         }
     }
     static::$checkedDuplicates[] = $oldLocation;
 }
Exemple #9
0
 /**
  * Builds the archives of the repository.
  *
  * @param array $packages List of packages to dump
  */
 public function dump(array $packages)
 {
     $helper = new ArchiveBuilderHelper($this->output, $this->config['archive']);
     $directory = $helper->getDirectory($this->outputDir);
     $this->output->writeln(sprintf("<info>Creating local downloads in '%s'</info>", $directory));
     $format = isset($this->config['archive']['format']) ? $this->config['archive']['format'] : 'zip';
     $endpoint = isset($this->config['archive']['prefix-url']) ? $this->config['archive']['prefix-url'] : $this->config['homepage'];
     $includeArchiveChecksum = isset($this->config['archive']['checksum']) ? (bool) $this->config['archive']['checksum'] : true;
     $composerConfig = Factory::createConfig();
     $factory = new Factory();
     $io = new ConsoleIO($this->input, $this->output, $this->helperSet);
     $io->loadConfiguration($composerConfig);
     /* @var \Composer\Downloader\DownloadManager $downloadManager */
     $downloadManager = $factory->createDownloadManager($io, $composerConfig);
     /* @var \Composer\Package\Archiver\ArchiveManager $archiveManager */
     $archiveManager = $factory->createArchiveManager($composerConfig, $downloadManager);
     $archiveManager->setOverwriteFiles(false);
     shuffle($packages);
     /* @var \Composer\Package\CompletePackage $package */
     foreach ($packages as $package) {
         if ($helper->isSkippable($package)) {
             continue;
         }
         $this->output->writeln(sprintf("<info>Dumping '%s'.</info>", $package->getName()));
         try {
             if ('pear-library' === $package->getType()) {
                 // PEAR packages are archives already
                 $filesystem = new Filesystem();
                 $packageName = $archiveManager->getPackageFilename($package);
                 $path = realpath($directory) . '/' . $packageName . '.' . pathinfo($package->getDistUrl(), PATHINFO_EXTENSION);
                 if (!file_exists($path)) {
                     $downloadDir = sys_get_temp_dir() . '/composer_archiver/' . $packageName;
                     $filesystem->ensureDirectoryExists($downloadDir);
                     $downloadManager->download($package, $downloadDir, false);
                     $filesystem->ensureDirectoryExists($directory);
                     $filesystem->rename($downloadDir . '/' . pathinfo($package->getDistUrl(), PATHINFO_BASENAME), $path);
                     $filesystem->removeDirectory($downloadDir);
                 }
                 // Set archive format to `file` to tell composer to download it as is
                 $archiveFormat = 'file';
             } else {
                 $path = $archiveManager->archive($package, $format, $directory);
                 $archiveFormat = $format;
             }
             $archive = basename($path);
             $distUrl = sprintf('%s/%s/%s', $endpoint, $this->config['archive']['directory'], $archive);
             $package->setDistType($archiveFormat);
             $package->setDistUrl($distUrl);
             if ($includeArchiveChecksum) {
                 $package->setDistSha1Checksum(hash_file('sha1', $path));
             }
             $package->setDistReference($package->getSourceReference());
         } catch (\Exception $exception) {
             if (!$this->skipErrors) {
                 throw $exception;
             }
             $this->output->writeln(sprintf("<error>Skipping Exception '%s'.</error>", $exception->getMessage()));
         }
     }
 }
 /**
  * @dataProvider getTestFiles
  */
 public function testIntegration(\SplFileInfo $testFile)
 {
     $testData = $this->parseTestFile($testFile);
     $cmd = 'php ' . __DIR__ . '/../../../bin/composer --no-ansi ' . $testData['RUN'];
     $proc = new Process($cmd);
     $exitcode = $proc->run();
     if (isset($testData['EXPECT'])) {
         $this->assertEquals($testData['EXPECT'], $this->cleanOutput($proc->getOutput()), 'Error Output: ' . $proc->getErrorOutput());
     }
     if (isset($testData['EXPECT-REGEX'])) {
         $this->assertRegExp($testData['EXPECT-REGEX'], $this->cleanOutput($proc->getOutput()), 'Error Output: ' . $proc->getErrorOutput());
     }
     if (isset($testData['EXPECT-ERROR'])) {
         $this->assertEquals($testData['EXPECT-ERROR'], $this->cleanOutput($proc->getErrorOutput()));
     }
     if (isset($testData['EXPECT-ERROR-REGEX'])) {
         $this->assertRegExp($testData['EXPECT-ERROR-REGEX'], $this->cleanOutput($proc->getErrorOutput()));
     }
     if (isset($testData['EXPECT-EXIT-CODE'])) {
         $this->assertSame($testData['EXPECT-EXIT-CODE'], $exitcode);
     }
     // Clean up.
     $fs = new Filesystem();
     if (isset($testData['test_dir']) && is_dir($testData['test_dir'])) {
         $fs->removeDirectory($testData['test_dir']);
     }
 }
Exemple #11
0
 /**
  * {@inheritDoc}
  */
 public function initialize()
 {
     if (static::isLocalUrl($this->url)) {
         $this->repoDir = str_replace('file://', '', $this->url);
     } else {
         $this->repoDir = $this->config->get('home') . '/cache.git/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
         // update the repo if it is a valid git repository
         if (is_dir($this->repoDir) && 0 === $this->process->execute('git remote', $output, $this->repoDir)) {
             if (0 !== $this->process->execute('git remote update --prune origin', $output, $this->repoDir)) {
                 $this->io->write('<error>Failed to update ' . $this->url . ', package information from this repository may be outdated (' . $this->process->getErrorOutput() . ')</error>');
             }
         } else {
             // clean up directory and do a fresh clone into it
             $fs = new Filesystem();
             $fs->removeDirectory($this->repoDir);
             // added in git 1.7.1, prevents prompting the user
             putenv('GIT_ASKPASS=echo');
             $command = sprintf('git clone --mirror %s %s', escapeshellarg($this->url), escapeshellarg($this->repoDir));
             if (0 !== $this->process->execute($command, $output)) {
                 $output = $this->process->getErrorOutput();
                 if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
                     throw new \RuntimeException('Failed to clone ' . $this->url . ', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
                 }
                 throw new \RuntimeException('Failed to clone ' . $this->url . ', could not read packages from it' . "\n\n" . $output);
             }
         }
     }
     $this->getTags();
     $this->getBranches();
 }
Exemple #12
0
 /**
  * {@inheritDoc}
  */
 public function initialize()
 {
     if (static::isLocalUrl($this->url)) {
         $this->repoDir = str_replace('file://', '', $this->url);
     } else {
         $this->repoDir = sys_get_temp_dir() . '/composer-' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
         // update the repo if it is a valid git repository
         if (is_dir($this->repoDir) && 0 === $this->process->execute('git remote', $output, $this->repoDir)) {
             $this->process->execute('git remote update --prune origin', $output, $this->repoDir);
         } else {
             // clean up directory and do a fresh clone into it
             $fs = new Filesystem();
             $fs->removeDirectory($this->repoDir);
             $command = sprintf('git clone --mirror %s %s', escapeshellarg($this->url), escapeshellarg($this->repoDir));
             if (0 !== $this->process->execute($command, $output)) {
                 $output = $this->process->getErrorOutput();
                 if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
                     throw new \RuntimeException('Failed to clone ' . $this->url . ', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
                 }
                 throw new \RuntimeException('Failed to clone ' . $this->url . ', could not read packages from it' . "\n\n" . $output);
             }
         }
     }
     $this->getTags();
     $this->getBranches();
 }
 public function testBuildPhar()
 {
     if (defined('HHVM_VERSION')) {
         $this->markTestSkipped('Building the phar does not work on HHVM.');
     }
     $target = dirname(self::$pharPath);
     $fs = new Filesystem();
     $fs->removeDirectory($target);
     $fs->ensureDirectoryExists($target);
     chdir($target);
     $it = new \RecursiveDirectoryIterator(__DIR__ . '/../../../', \RecursiveDirectoryIterator::SKIP_DOTS);
     $ri = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($ri as $file) {
         $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
         if ($file->isDir()) {
             $fs->ensureDirectoryExists($targetPath);
         } else {
             copy($file->getPathname(), $targetPath);
         }
     }
     $proc = new Process('php ' . escapeshellarg('./bin/compile'), $target);
     $exitcode = $proc->run();
     if ($exitcode !== 0 || trim($proc->getOutput())) {
         $this->fail($proc->getOutput());
     }
     $this->assertTrue(file_exists(self::$pharPath));
 }
 protected function tearDown()
 {
     if (is_dir($this->workingDir)) {
         $fs = new Filesystem();
         $fs->removeDirectory($this->workingDir);
     }
 }
 /**
  * Installs PEAR source files according to package.xml definitions and removes extracted files
  *
  * @param  string                    $target target install location. all source installation would be performed relative to target path.
  * @param  array                     $roles  types of files to install. default role for PEAR source files are 'php'.
  * @param  array                     $vars   used for replacement tasks
  * @throws \RuntimeException
  * @throws \UnexpectedValueException
  *
  */
 public function extractTo($target, array $roles = array('php' => '/', 'script' => '/bin'), $vars = array())
 {
     $extractionPath = $target . '/tarball';
     try {
         $archive = new \PharData($this->file);
         $archive->extractTo($extractionPath, null, true);
         if (!is_file($this->combine($extractionPath, '/package.xml'))) {
             throw new \RuntimeException('Invalid PEAR package. It must contain package.xml file.');
         }
         $fileCopyActions = $this->buildCopyActions($extractionPath, $roles, $vars);
         $this->copyFiles($fileCopyActions, $extractionPath, $target, $roles, $vars);
         $this->filesystem->removeDirectory($extractionPath);
     } catch (\Exception $exception) {
         throw new \UnexpectedValueException(sprintf('Failed to extract PEAR package %s to %s. Reason: %s', $this->file, $target, $exception->getMessage()), 0, $exception);
     }
 }
 /**
  * Runs the project configurator.
  *
  * @return void
  */
 public function run()
 {
     $namespace = $this->ask('Namespace', function ($namespace) {
         return $this->validateNamespace($namespace);
     }, 'App');
     $packageName = $this->ask('Package name', function ($packageName) {
         return $this->validatePackageName($packageName);
     }, $this->suggestPackageName($namespace));
     $license = $this->ask('License', function ($license) {
         return trim($license);
     }, 'proprietary');
     $description = $this->ask('Description', function ($description) {
         return trim($description);
     }, '');
     $file = new JsonFile('./composer.json');
     $config = $file->read();
     $config['name'] = $packageName;
     $config['license'] = $license;
     $config['description'] = $description;
     $config['autoload']['psr-4'] = [$namespace . '\\' => 'src/'];
     $config['autoload-dev']['psr-4'] = [$namespace . '\\Tests\\' => 'tests/'];
     unset($config['scripts']['post-root-package-install']);
     $config['extra']['branch-alias']['dev-master'] = '1.0-dev';
     $file->write($config);
     $this->composer->setPackage(Factory::create($this->io, null, true)->getPackage());
     // reload root package
     $filesystem = new Filesystem();
     $filesystem->removeDirectory('./app/Distribution');
 }
Exemple #17
0
 protected function ensureDirectoryExistsAndClear($directory)
 {
     $fs = new Filesystem();
     if (is_dir($directory)) {
         $fs->removeDirectory($directory);
     }
     mkdir($directory, 0777, true);
 }
 /**
  * {@inheritDoc}
  */
 public function remove(PackageInterface $package, $path)
 {
     $this->io->writeError("  - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getPrettyVersion() . "</comment>)");
     $this->cleanChanges($package, $path, false);
     if (!$this->filesystem->removeDirectory($path)) {
         throw new \RuntimeException('Could not completely delete ' . $path . ', aborting.');
     }
 }
Exemple #19
0
 public function tearDown()
 {
     chdir($this->prevCwd);
     if (is_dir($this->tempComposerHome)) {
         $fs = new Filesystem();
         $fs->removeDirectory($this->tempComposerHome);
     }
 }
 /**
  * Complete the setup task.
  *
  * @since 0.1.0
  *
  * @return void
  */
 public function complete()
 {
     $templatesFolder = $this->getConfigKey('Folders', 'vcs');
     try {
         $filesystem = new Filesystem();
         $filesystem->removeDirectory($templatesFolder);
     } catch (Exception $exception) {
         $this->io->writeError(sprintf('Could not remove VCS folder "%1$s". Reason: %2$s', $templatesFolder, $exception->getMessage()));
     }
 }
 protected function tearDown()
 {
     chdir($this->origDir);
     if (is_dir($this->workingDir)) {
         $this->fs->removeDirectory($this->workingDir);
     }
     if (is_dir($this->vendorDir)) {
         $this->fs->removeDirectory($this->vendorDir);
     }
 }
 public function tearDown()
 {
     $filesystem = new Filesystem();
     $filesystem->removeDirectory($this->tmp);
     chdir($this->cwd);
     umask($this->umask);
     unset($this->umask);
     unset($this->tmp);
     unset($this->cwd);
 }
Exemple #23
0
 /**
  * {@inheritDoc}
  */
 public function initialize()
 {
     if (static::isLocalUrl($this->url)) {
         $this->repoDir = str_replace('file://', '', $this->url);
     } else {
         $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
         $util = new GitUtil();
         $util->cleanEnv();
         $fs = new Filesystem();
         $fs->ensureDirectoryExists(dirname($this->repoDir));
         if (!is_writable(dirname($this->repoDir))) {
             throw new \RuntimeException('Can not clone ' . $this->url . ' to access package information. The "' . dirname($this->repoDir) . '" directory is not writable by the current user.');
         }
         if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
             throw new \InvalidArgumentException('The source URL ' . $this->url . ' is invalid, ssh URLs should have a port number after ":".' . "\n" . 'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.');
         }
         // update the repo if it is a valid git repository
         if (is_dir($this->repoDir) && 0 === $this->process->execute('git remote', $output, $this->repoDir)) {
             if (0 !== $this->process->execute('git remote update --prune origin', $output, $this->repoDir)) {
                 $this->io->write('<error>Failed to update ' . $this->url . ', package information from this repository may be outdated (' . $this->process->getErrorOutput() . ')</error>');
             }
         } else {
             // clean up directory and do a fresh clone into it
             $fs->removeDirectory($this->repoDir);
             $command = sprintf('git clone --mirror %s %s', escapeshellarg($this->url), escapeshellarg($this->repoDir));
             if (0 !== $this->process->execute($command, $output)) {
                 $output = $this->process->getErrorOutput();
                 if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
                     throw new \RuntimeException('Failed to clone ' . $this->url . ', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
                 }
                 if ($this->io->isInteractive() && preg_match('{(https?://)([^/]+)(.*)$}i', $this->url, $match) && strpos($output, 'fatal: Authentication failed') !== false) {
                     if ($this->io->hasAuthentication($match[2])) {
                         $auth = $this->io->getAuthentication($match[2]);
                     } else {
                         $this->io->write($this->url . ' requires Authentication');
                         $auth = array('username' => $this->io->ask('Username: '******'password' => $this->io->askAndHideAnswer('Password: '******'username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
                     $command = sprintf('git clone --mirror %s %s', escapeshellarg($url), escapeshellarg($this->repoDir));
                     if (0 === $this->process->execute($command, $output)) {
                         $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
                     } else {
                         $output = $this->process->getErrorOutput();
                         throw new \RuntimeException('Failed to clone ' . $this->url . ', could not read packages from it' . "\n\n" . $output);
                     }
                 } else {
                     throw new \RuntimeException('Failed to clone ' . $this->url . ', could not read packages from it' . "\n\n" . $output);
                 }
             }
         }
     }
     $this->getTags();
     $this->getBranches();
     $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url));
 }
Exemple #24
0
 private function removeDirectory($path)
 {
     $retries = 5;
     do {
         if (!$this->cfs->removeDirectory($path)) {
             usleep(200);
         }
         clearstatcache();
     } while (is_dir($path) && $retries--);
     return !is_dir($path);
 }
 protected function tearDown()
 {
     if (!empty(self::$workingDirectory)) {
         $filesystem = new Filesystem();
         foreach (self::$workingDirectory as $workingDirectory) {
             $filesystem->removeDirectory($workingDirectory);
         }
         self::$workingDirectory = [];
     }
     parent::tearDown();
 }
 public function testBuildPhar()
 {
     $fs = new Filesystem();
     $fs->removeDirectory(dirname(self::$pharPath));
     $fs->ensureDirectoryExists(dirname(self::$pharPath));
     chdir(dirname(self::$pharPath));
     $proc = new Process('php ' . escapeshellarg(__DIR__ . '/../../../bin/compile'));
     $exitcode = $proc->run();
     $this->assertSame(0, $exitcode);
     $this->assertTrue(file_exists(self::$pharPath));
 }
Exemple #27
0
 /**
  * Clean the internal cache of Contao after updates has been installed.
  *
  * @param IOInterface $inputOutput The input output interface to use.
  *
  * @param string      $root        The contao installation root.
  *
  * @return void
  *
  * @throws \RuntimeException When the root path is a windows drive root.
  *
  * @throws RuntimeException When an OS error occurred while deleting.
  */
 public static function cleanCache(IOInterface $inputOutput, $root)
 {
     // clean cache
     $filesystem = new Filesystem();
     foreach (array('config', 'dca', 'language', 'sql') as $dir) {
         $cache = $root . '/system/cache/' . $dir;
         if (is_dir($cache)) {
             $inputOutput->write(sprintf('<info>Clean contao internal %s cache</info>', $dir));
             $filesystem->removeDirectory($cache);
         }
     }
 }
 /**
  * UnInstall the extension given the list of install files
  *
  * @param array $files
  */
 public function unInstall(array $files)
 {
     foreach ($files as $file) {
         $file = $this->rootDir . $file;
         /*
         because of different reasons the file can be already gone.
         example:
         - file got deployed by multiple modules(should only happen with copy force)
         - user did things
         
         when the file is a symlink, but the target is already gone, file_exists returns false
         */
         if (file_exists($file) xor is_link($file)) {
             $this->fileSystem->unlink($file);
             $parentDir = dirname($file);
             while ($this->fileSystem->isDirEmpty($parentDir) && $parentDir !== $this->rootDir) {
                 $this->fileSystem->removeDirectory($parentDir);
                 $parentDir = dirname($parentDir);
             }
         }
     }
 }
 public function testInstallerCreationShouldNotCreateBinDirectory()
 {
     /* @var RootPackageInterface $rootPackage */
     $rootPackage = $this->createRootPackageMock();
     /* @var IOInterface $io */
     $io = $this->io;
     /* @var AssetTypeInterface $type */
     $type = $this->type;
     $this->fs->removeDirectory($this->binDir);
     $this->composer->setPackage($rootPackage);
     new BowerInstaller($io, $this->composer, $type);
     $this->assertFileNotExists($this->binDir);
 }
 protected function tearDown()
 {
     $this->downloader = null;
     $this->package = null;
     $this->repository = null;
     $this->io = null;
     $this->config = null;
     $this->repoConfig = null;
     if (is_dir($this->testPath)) {
         $fs = new Filesystem();
         $fs->removeDirectory($this->testPath);
     }
 }