示例#1
0
 /**
  * @param string $targetPath
  * @param string $installPath
  * @param array $map
  * @param bool $isSymlink
  * @param bool $isRelative
  *
  * @throws IOException
  * @throws \InvalidArgumentException
  *
  * @api
  *
  * @quality:method [B]
  */
 public function publish($targetPath, $installPath, array $map, $isSymlink, $isRelative)
 {
     $targetPath = rtrim($targetPath, '/');
     $installPath = rtrim($installPath, '/');
     $this->filesystem->mkdir($targetPath, 0777);
     foreach ($map as $from => $to) {
         $targetDir = realpath($targetPath) . '/' . $to;
         $sourceDir = realpath($installPath) . '/' . $from;
         $this->filesystem->remove($targetDir);
         if ($isSymlink) {
             $this->io->write(sprintf('Trying to install AdminLTE %s assets as symbolic links.', $from));
             $originDir = $sourceDir;
             if ($isRelative) {
                 $originDir = $this->filesystem->makePathRelative($sourceDir, realpath($targetPath));
             }
             try {
                 $this->filesystem->symlink($originDir, $targetDir);
                 $this->io->write(sprintf('The AdminLTE %s assets were installed using symbolic links.', $from));
             } catch (IOException $e) {
                 $this->hardCopy($sourceDir, $targetDir);
                 $this->io->write(sprintf('It looks like your system doesn\'t support symbolic links,
                     so the AdminLTE %s assets were installed by copying them.', $from));
             }
         } else {
             $this->io->write(sprintf('Installing AdminLTE %s assets as <comment>hard copies</comment>.', $from));
             $this->hardCopy($sourceDir, $targetDir);
         }
     }
 }
示例#2
0
 private function symlinkPackageToVendor($packagePath, $vendorPath)
 {
     $relative = $this->fileSystem->makePathRelative(realpath($packagePath), realpath($vendorPath . '/../'));
     $this->fileSystem->rename($vendorPath, $vendorPath . '_linked', true);
     $this->fileSystem->symlink($relative, $vendorPath);
     $this->fileSystem->remove($vendorPath . '_linked');
 }
示例#3
0
 /**
  * Deploy build.
  *
  * @throws runtime_exception If deployment failed
  * @return $this
  */
 public function deploy_build()
 {
     if (!$this->fs->exists($this->build_dir)) {
         return $this;
     }
     $this->build_parents();
     $current_build = false;
     if ($this->fs->exists($this->production_link)) {
         if (is_link($this->production_link)) {
             $current_build = readlink($this->production_link);
         }
     }
     try {
         $new_build = $this->repo_dir . 'prod_' . time();
         $this->fs->rename($this->build_dir, $new_build);
         $this->fs->remove($this->production_link);
         $this->fs->symlink($new_build, $this->production_link);
     } catch (\Exception $e) {
         $this->fs->remove($this->production_link);
         if ($current_build) {
             $this->fs->symlink($current_build, $this->production_link);
         }
         throw new runtime_exception('PACKAGES_BUILD_DEPLOYMENT_FAILED');
     }
     if ($current_build) {
         $this->fs->remove($current_build);
     }
     return $this;
 }
 /**
  * Copy all assets from a given path to the publish path.
  *
  * @param string $name
  * @param string $source
  * @throws \RuntimeException
  * @return bool
  */
 public function publish($name, $source)
 {
     $destination = $this->publishPath . "/packages/{$name}";
     try {
         $this->files->symlink($source, $destination);
     } catch (\Exception $e) {
         throw new \RuntimeException("Unable to publish assets.");
     }
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function symlink(string $origin, string $target, bool $copyOnWindows = false)
 {
     try {
         $this->filesystem->symlink($origin, $target, $copyOnWindows);
     } catch (IOException $exception) {
         throw new FilesystemException($exception->getMessage(), $exception->getPath(), $exception);
     } catch (Exception $exception) {
         throw new FilesystemException($exception->getMessage(), null, $exception);
     }
 }
示例#6
0
 /**
  * Generates a symlink.
  *
  * The method will try to generate relative symlinks and fall back to generating
  * absolute symlinks if relative symlinks are not supported (see #208).
  *
  * @param string $source  The symlink name
  * @param string $target  The symlink target
  * @param string $rootDir The root directory
  */
 public static function symlink($source, $target, $rootDir)
 {
     static::validateSymlink($source, $target, $rootDir);
     $fs = new Filesystem();
     if ('\\' === DIRECTORY_SEPARATOR) {
         $fs->symlink($rootDir . '/' . $source, $rootDir . '/' . $target);
     } else {
         $fs->symlink(rtrim($fs->makePathRelative($source, dirname($target)), '/'), $rootDir . '/' . $target);
     }
 }
示例#7
0
 /**
  * @param $source
  * @param $target
  */
 protected function link($source, $target)
 {
     $targetDir = dirname($target);
     if (!$this->filesystem->exists($targetDir)) {
         $this->filesystem->mkdir($targetDir);
     }
     if ($this->filesystem->exists($target)) {
         $this->filesystem->remove($target);
     }
     $this->filesystem->symlink($source, $target);
 }
 /**
  * Forces image caching and returns path to cached image.
  *
  * @param string  $basePath Deprecated parameter
  * @param string  $path
  * @param string  $filter
  * @param boolean $force
  * @param string  $saveAs
  *
  * @return string|null
  *
  * @throws RuntimeException
  */
 public function cacheImage($basePath, $path, $filter, $force = false, $saveAs = null)
 {
     $path = '/' . ltrim($path, '/');
     $saveAs = $saveAs ? '/' . ltrim($saveAs, '/') : $path;
     // if cache path cannot be determined, return 404
     if (!($cachedPath = $this->cachePathResolver->getCachedPath($saveAs, $filter))) {
         return null;
     }
     // if the file has already been cached, just return path
     if (!$force && is_file($cachedPath)) {
         return $cachedPath;
     }
     if (!($sourcePath = $this->cachePathResolver->getRealPath($path, $filter))) {
         return null;
     }
     $this->ensureDirectoryExists($cachedPath);
     try {
         $image = $this->imagine->open($sourcePath);
     } catch (RuntimeException $e) {
         try {
             // Make sure source path is an image
             new ImageFile($sourcePath, false);
             // Do not pollute the space (don't copy anything; symlink is just fine)
             $this->filesystem->symlink($sourcePath, $cachedPath);
         } catch (RuntimeException $e) {
             return null;
         } catch (IOException $e) {
             // In case we were not able to create symlink we should return source path.
             // This means we'll be back here, but at least we'll not be polluting space with useless copies.
             return $sourcePath;
         }
         return $cachedPath;
     }
     $options = ['quality' => $this->filterManager->getOption($filter, 'quality', $this->defaultQuality), 'format' => $this->filterManager->getOption($filter, 'format', null)];
     // Important! optipng filter returns an instance of ImageAssetWrapper.
     /** @var ImageInterface|ImageAssetWrapper $image */
     $image = $this->filterManager->getFilter($filter)->apply($image);
     /** @var resource $context */
     if ($context = $this->findStreamContext($cachedPath, $filter)) {
         $tmpPath = tempnam(sys_get_temp_dir(), 'avalanche-cache-manager-proxy-');
         $image->save($tmpPath, $options);
         copy($tmpPath, $cachedPath, $context);
         unlink($tmpPath);
     } else {
         $image->save($cachedPath, $options);
     }
     $this->ensureFilePermissions($cachedPath);
     return $cachedPath;
 }
示例#9
0
 /**
  * {@inheritdoc}
  */
 public function download(PackageInterface $package, $path)
 {
     $url = $package->getDistUrl();
     $realUrl = realpath($url);
     if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
         throw new \RuntimeException(sprintf('Source path "%s" is not found for package %s', $url, $package->getName()));
     }
     if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
         throw new \RuntimeException(sprintf('Package %s cannot install to "%s" inside its source at "%s"', $package->getName(), realpath($path), $realUrl));
     }
     $fileSystem = new Filesystem();
     $this->filesystem->removeDirectory($path);
     $this->io->writeError(sprintf('  - Installing <info>%s</info> (<comment>%s</comment>)', $package->getName(), $package->getFullPrettyVersion()));
     try {
         if (Platform::isWindows()) {
             // Implement symlinks as NTFS junctions on Windows
             $this->filesystem->junction($realUrl, $path);
             $this->io->writeError(sprintf('    Junctioned from %s', $url));
         } else {
             $shortestPath = $this->filesystem->findShortestPath($path, $realUrl);
             $fileSystem->symlink($shortestPath, $path);
             $this->io->writeError(sprintf('    Symlinked from %s', $url));
         }
     } catch (IOException $e) {
         $fileSystem->mirror($realUrl, $path);
         $this->io->writeError(sprintf('    Mirrored from %s', $url));
     }
     $this->io->writeError('');
 }
 /**
  * Dumps all translation files.
  *
  * @param string  $targetDir Target directory.
  * @param boolean $symlink   True if generate symlink
  *
  * @return null
  */
 public function dump($targetDir = 'web', $symlink = false, $directory = null)
 {
     $route = $this->router->getRouteCollection()->get('bazinga_exposetranslation_js');
     $directory = null === $directory ? $this->kernel->getRootDir() . '/../' : $directory;
     $requirements = $route->getRequirements();
     $formats = explode('|', $requirements['_format']);
     $routeDefaults = $route->getDefaults();
     $defaultFormat = $routeDefaults['_format'];
     $parts = array_filter(explode('/', $route->getPattern()));
     $this->filesystem->remove($directory . $targetDir . "/" . current($parts));
     foreach ($this->getTranslationMessages() as $locale => $domains) {
         foreach ($domains as $domain => $messageList) {
             foreach ($formats as $format) {
                 $content = $this->engine->render('BazingaExposeTranslationBundle::exposeTranslation.' . $format . '.twig', array('messages' => array($domain => $messageList), 'locale' => $locale, 'defaultDomains' => $domain));
                 $path[$format] = $directory . $targetDir . strtr($route->getPattern(), array('{domain_name}' => $domain, '{_locale}' => $locale, '{_format}' => $format));
                 $this->filesystem->mkdir(dirname($path[$format]), 0777);
                 if (file_exists($path[$format])) {
                     $this->filesystem->remove($path[$format]);
                 }
                 file_put_contents($path[$format], $content);
             }
             $targetFile = $directory . $targetDir;
             $targetFile .= strtr($route->getPattern(), array('{domain_name}' => $domain, '{_locale}' => $locale, '.{_format}' => ''));
             if (true === $symlink) {
                 $this->filesystem->symlink($path[$defaultFormat], $targetFile);
             } else {
                 $this->filesystem->copy($path[$defaultFormat], $targetFile);
             }
         }
     }
 }
示例#11
0
 /**
  * Installs the assets under the web root directory.
  *
  * @param CommandEvent $event A CommandEvent instance
  */
 public static function installAssets(CommandEvent $event)
 {
     $webDir = static::$options['pulsar-web-dir'];
     $fs = new Filesystem();
     // $fs->mirror(sprintf('%s/../Resources/public', __DIR__), sprintf('%s/pulsar', $webDir));
     $fs->symlink(sprintf('%s/../Resources/public', __DIR__), sprintf('%s/pulsar', $webDir), true);
 }
示例#12
0
 /**
  * Links Drupal core, modules, themes and assets into Drupal root.
  *
  * @param Event $event
  */
 public static function prepareDrupalRoot(Event $event)
 {
     $options = self::getOptions($event);
     $composer = $event->getComposer();
     $filesystem = new Filesystem();
     $originDir = realpath($composer->getConfig()->get('vendor-dir') . '/drupal/drupal');
     $targetDir = realpath($options['drupal-root']);
     if (is_dir($originDir)) {
         if ($options['drupal-install']['relative']) {
             $originDir = rtrim($filesystem->makePathRelative($originDir, $targetDir), '/');
         }
         $directories = array('includes', 'misc', 'modules', 'themes');
         foreach ($directories as $directory) {
             $filesystem->remove($targetDir . '/' . $directory);
             if ($options['drupal-install']['symlink']) {
                 $event->getIO()->write(sprintf('Creating symlink for Drupal\'s \'%s\' directory', $directory));
                 $filesystem->symlink($originDir . '/' . $directory, $targetDir . '/' . $directory);
             } else {
                 $event->getIO()->write(sprintf('Copying Drupal\'s \'%s\' directory to web root', $directory));
                 $filesystem->mkdir($targetDir . '/' . $directory, 0777);
                 // We use a custom iterator to ignore VCS files
                 $filesystem->mirror($originDir . '/' . $directory, $targetDir . '/' . $directory, Finder::create()->ignoreDotFiles(false)->in($originDir));
             }
         }
     }
 }
示例#13
0
 /**
  * Installs Drupal under the web root directory.
  *
  * @param $event CommandEvent A instance
  */
 public static function installDrupal(CommandEvent $event)
 {
     $options = self::getOptions($event);
     $webDir = $options['symfony-web-dir'];
     $composer = $event->getComposer();
     $filesystem = new Filesystem();
     $packages = $composer->getPackage()->getRequires();
     $drupal_root = $composer->getConfig()->get('vendor-dir') . DIRECTORY_SEPARATOR . $packages['drupal/drupal']->getTarget();
     $directories = array('includes', 'misc', 'modules', 'themes');
     foreach ($directories as $directory) {
         $originDir = '../' . $drupal_root . '/' . $directory;
         $targetDir = $webDir . '/' . $directory;
         echo sprintf('Creating symlink for Drupal\'s \'%s\' directory', $directory) . PHP_EOL;
         $filesystem->symlink($originDir, $targetDir);
     }
     $directory = 'sites';
     $targetDir = $webDir . '/' . $directory . '/';
     // Check for sites/default because sites/all may exist if composer installs
     // modules or themes.
     if (!$filesystem->exists($targetDir . '/default')) {
         $originDir = $drupal_root . '/' . $directory;
         echo sprintf('Creating new sites directory', $directory) . PHP_EOL;
         $filesystem->mirror($originDir, $targetDir, null, array('override' => true));
     }
 }
示例#14
0
 /**
  * @inheritdoc
  */
 public function postActivation(ConnectionInterface $con = null)
 {
     $fileSystem = new Filesystem();
     //Check for environment
     if ($env = $this->getContainer()->getParameter('kernel.environment')) {
         //Check for backward compatibility
         if ($env !== "prod" && $env !== "dev") {
             //Remove separtion between dev and prod in particular environment
             $env = str_replace('_dev', '', $env);
             $this->webMediaEnvPath = $this->webMediaPath . DS . $env;
         }
     }
     // Create symbolic links or hard copy in the web directory
     // (according to \Thelia\Action\Document::CONFIG_DELIVERY_MODE),
     // to make the TinyMCE code available.
     if (false === $fileSystem->exists($this->webJsPath)) {
         if (ConfigQuery::read(Document::CONFIG_DELIVERY_MODE) === 'symlink') {
             $fileSystem->symlink($this->jsPath, $this->webJsPath);
         } else {
             $fileSystem->mirror($this->jsPath, $this->webJsPath);
         }
     }
     // Create the media directory in the web root , if required
     if (null !== $this->webMediaEnvPath) {
         if (false === $fileSystem->exists($this->webMediaEnvPath)) {
             $fileSystem->mkdir($this->webMediaEnvPath . DS . 'upload');
             $fileSystem->mkdir($this->webMediaEnvPath . DS . 'thumbs');
         }
     } else {
         if (false === $fileSystem->exists($this->webMediaPath)) {
             $fileSystem->mkdir($this->webMediaPath . DS . 'upload');
             $fileSystem->mkdir($this->webMediaPath . DS . 'thumbs');
         }
     }
 }
 /**
  * @param $origin
  * @param $target
  */
 private function doSymlinkAsset($origin, $target)
 {
     $this->filesystem->symlink($origin, $target);
     if (!file_exists($target)) {
         throw new IOException('Symbolic link is broken');
     }
 }
 /**
  * @param $dir
  * @param  InputInterface  $input
  * @param  OutputInterface $output
  * @return bool
  */
 private function installPluginAssets($dir, InputInterface $input, OutputInterface $output)
 {
     // Create the specific assets directory otherwise symlink will fail.
     $assetsDir = $dir . '/assets/plugins/';
     $this->filesystem->mkdir($assetsDir, 0777);
     $plugins = $this->getContainer()->get('simplr.pluginmanager')->getActivePlugins();
     if (!empty($plugins)) {
         foreach ($plugins as $name => $configuration) {
             $activePluginPath = $this->getContainer()->get('simplr.pluginmanager')->getPathToPlugin($name);
             if (is_dir($originDir = $activePluginPath . '/Resources/public')) {
                 $targetDir = $assetsDir . strtolower($name);
                 $output->writeln(sprintf("Installing assets for plugin <comment>%s</comment> into <comment>%s</comment>", $name, $targetDir));
                 $this->filesystem->remove($targetDir);
                 if ($input->getOption('symlink')) {
                     if ($input->getOption('relative')) {
                         $relativeOriginDir = $this->filesystem->makePathRelative($originDir, realpath($assetsDir));
                     } else {
                         $relativeOriginDir = $originDir;
                     }
                     $this->filesystem->symlink($relativeOriginDir, $targetDir);
                 } else {
                     $this->filesystem->mkdir($targetDir, 0777);
                     // We use a custom iterator to ignore VCS files
                     $this->filesystem->mirror($originDir, $targetDir, Finder::create()->in($originDir));
                 }
             }
         }
     } else {
         $output->writeln('Installing assets for plugins... no plugins found!');
     }
     return true;
 }
 protected static function symlink($origin, $target)
 {
     $filesystem = new Filesystem();
     try {
         $filesystem->symlink($origin, $target);
     } catch (\Exception $e) {
     }
 }
 /**
  * Symlink given path to latest in file system
  *
  * @param string $path
  * @author Daniel Wendlandt
  */
 public function symlinkLatestBackup($path)
 {
     $latestPath = dirname($path) . DIRECTORY_SEPARATOR . self::SYMLINK_LATEST;
     if ($this->filesytsem->exists($latestPath)) {
         $this->filesytsem->remove($latestPath);
     }
     $this->filesytsem->symlink($path, $latestPath);
 }
示例#19
0
 /**
  * {@inheritdoc}
  */
 public function symlink($origin_dir, $target_dir, $copy_on_windows = false)
 {
     try {
         $this->symfony_filesystem->symlink($origin_dir, $target_dir, $copy_on_windows);
     } catch (\Symfony\Component\Filesystem\Exception\IOException $e) {
         throw new filesystem_exception('CANNOT_CREATE_SYMLINK', $origin_dir, array(), $e);
     }
 }
 /**
  *
  */
 public function save()
 {
     $fs = new Filesystem();
     $fs->dumpFile(Platform::sharedDir() . '/settings.local.php', $this->string);
     // Relink if missing.
     if (!$fs->exists(Platform::webDir() . '/sites/default/settings.local.php')) {
         $fs->symlink('../../../shared/settings.local.php', Platform::webDir() . '/sites/default/settings.local.php');
     }
 }
 /**
  * {@inheritdoc}
  */
 public function download(PackageInterface $package, $path)
 {
     $url = $package->getDistUrl();
     $realUrl = realpath($url);
     if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
         throw new \RuntimeException(sprintf('Source path "%s" is not found for package %s', $url, $package->getName()));
     }
     if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
         throw new \RuntimeException(sprintf('Package %s cannot install to "%s" inside its source at "%s"', $package->getName(), realpath($path), $realUrl));
     }
     // Get the transport options with default values
     $transportOptions = $package->getTransportOptions() + array('symlink' => null);
     // When symlink transport option is null, both symlink and mirror are allowed
     $currentStrategy = self::STRATEGY_SYMLINK;
     $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR);
     if (true === $transportOptions['symlink']) {
         $currentStrategy = self::STRATEGY_SYMLINK;
         $allowedStrategies = array(self::STRATEGY_SYMLINK);
     } elseif (false === $transportOptions['symlink']) {
         $currentStrategy = self::STRATEGY_MIRROR;
         $allowedStrategies = array(self::STRATEGY_MIRROR);
     }
     $fileSystem = new Filesystem();
     $this->filesystem->removeDirectory($path);
     $this->io->writeError(sprintf('  - Installing <info>%s</info> (<comment>%s</comment>)', $package->getName(), $package->getFullPrettyVersion()));
     if (self::STRATEGY_SYMLINK == $currentStrategy) {
         try {
             if (Platform::isWindows()) {
                 // Implement symlinks as NTFS junctions on Windows
                 $this->filesystem->junction($realUrl, $path);
                 $this->io->writeError(sprintf('    Junctioned from %s', $url));
             } else {
                 $absolutePath = $path;
                 if (!$this->filesystem->isAbsolutePath($absolutePath)) {
                     $absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path;
                 }
                 $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
                 $path = rtrim($path, "/");
                 $fileSystem->symlink($shortestPath, $path);
                 $this->io->writeError(sprintf('    Symlinked from %s', $url));
             }
         } catch (IOException $e) {
             if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) {
                 $this->io->writeError('    <error>Symlink failed, fallback to use mirroring!</error>');
                 $currentStrategy = self::STRATEGY_MIRROR;
             } else {
                 throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
             }
         }
     }
     // Fallback if symlink failed or if symlink is not allowed for the package
     if (self::STRATEGY_MIRROR == $currentStrategy) {
         $fileSystem->mirror($realUrl, $path);
         $this->io->writeError(sprintf('    Mirrored from %s', $url));
     }
     $this->io->writeError('');
 }
 /**
  * Creates symbolic link.
  *
  * @param string $originDir
  * @param string $targetDir
  * @param bool   $relative
  *
  * @throws IOException If link can not be created.
  */
 private function symlink($originDir, $targetDir, $relative = false)
 {
     if ($relative) {
         $originDir = $this->filesystem->makePathRelative($originDir, realpath(dirname($targetDir)));
     }
     $this->filesystem->symlink($originDir, $targetDir);
     if (!file_exists($targetDir)) {
         throw new IOException(sprintf('Symbolic link "%s" was created but appears to be broken.', $targetDir), 0, null, $targetDir);
     }
 }
示例#23
0
 /**
  * @param Filesystem $filesystem
  * @param $path
  * @param $fileName
  * @param array|null $options
  */
 public function save(Filesystem $filesystem, $path, $fileName, array $options = null)
 {
     $origin = "{$path}/{$fileName}";
     $snapshotFileName = SnapshotManager::createNameForSnapshot();
     $target = "{$path}/{$snapshotFileName}";
     $freshFileName = SnapshotManager::FRESH_FILE;
     $freshFilePath = "{$path}/{$freshFileName}";
     $filesystem->rename($origin, $target);
     $filesystem->symlink($target, $freshFilePath);
 }
示例#24
0
 /**
  * {@inheritdoc}
  */
 public function download(PackageInterface $package, $path)
 {
     $fileSystem = new Filesystem();
     $this->filesystem->removeDirectory($path);
     $this->io->writeError(sprintf('  - Installing <info>%s</info> (<comment>%s</comment>) from %s', $package->getName(), $package->getFullPrettyVersion(), $package->getDistUrl()));
     try {
         $fileSystem->symlink($package->getDistUrl(), $path);
     } catch (IOException $e) {
         $fileSystem->mirror($package->getDistUrl(), $path);
     }
 }
示例#25
0
 private function trySymlink($origin, $target)
 {
     try {
         $this->filesystem->symlink($origin, $target);
         if (file_exists($target)) {
             return true;
         }
     } catch (IOException $e) {
     }
     return false;
 }
示例#26
0
 public function testSymlinkIsNotOverwrittenIfAlreadyCreated()
 {
     $this->markAsSkippeIfSymlinkIsMissing();
     $file = $this->workspace . DIRECTORY_SEPARATOR . 'file';
     $link = $this->workspace . DIRECTORY_SEPARATOR . 'link';
     touch($file);
     symlink($file, $link);
     $this->filesystem->symlink($file, $link);
     $this->assertTrue(is_link($link));
     $this->assertEquals($file, readlink($link));
 }
示例#27
0
 public function configure()
 {
     $fs = new Filesystem();
     $fs->copy(CLI_ROOT . '/resources/stacks/wordpress/wp-config.php', Platform::webDir() . '/wp-config.php', true);
     $fs->remove(Platform::webDir() . '/wp-confg-sample.php');
     $fs->dumpFile(Platform::sharedDir() . '/wp-config.local.php', $this->string);
     // Relink if missing.
     if (!$fs->exists(Platform::webDir() . '/wp-config.local.php')) {
         $fs->symlink('../shared/wp-config.local.php', Platform::webDir() . '/wp-config  .local.php');
     }
 }
示例#28
0
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fs = new Filesystem();
     $addon_id = $input->getArgument('name');
     $abs_cart_path = rtrim(realpath($input->getArgument('cart-directory')), '\\/') . '/';
     $this->validateCartPath($abs_cart_path, $input, $output);
     $abs_addon_path = rtrim(realpath($input->getArgument('addon-directory')), '\\/') . '/';
     chdir($abs_addon_path);
     $addon = new Addon($addon_id, $abs_addon_path);
     $addon_files_glob_masks = $addon->getFilesGlobMasks();
     $addon_files_glob_masks = array_filter($addon_files_glob_masks, function ($glob_mask) {
         // Always ignore "design/themes/" masks because there shouldn't
         // be such directory in add-on files directory
         if (mb_strpos($glob_mask, 'design/themes/') === 0) {
             return false;
         }
         return true;
     });
     $glob_matches = $addon->matchFilesAgainstGlobMasks($addon_files_glob_masks, $abs_addon_path);
     $output->writeln(sprintf('<fg=magenta;options=bold>Creating symlinks at the "%s" directory:</>', $abs_cart_path));
     foreach ($glob_matches as $rel_filepath) {
         $abs_addon_filepath = $abs_addon_path . $rel_filepath;
         // Add-on templates at the "var/themes_repository/" directory will be
         // symlinked to the "design/themes/" directory.
         if ($input->getOption('templates-to-design') && mb_strpos($rel_filepath, 'var/themes_repository/') === 0) {
             $abs_cart_filepath = $abs_cart_path . 'design/themes/' . mb_substr($rel_filepath, mb_strlen('var/themes_repository/'));
         } else {
             $abs_cart_filepath = $abs_cart_path . $rel_filepath;
         }
         // Delete existing files and links located at cart directory
         clearstatcache(true, $abs_cart_filepath);
         if (file_exists($abs_cart_filepath)) {
             $is_link = is_link($abs_cart_filepath);
             $is_file = $is_link ? is_file(readlink($abs_cart_filepath)) : is_file($abs_cart_filepath);
             $is_dir = $is_link ? is_dir(readlink($abs_cart_filepath)) : is_dir($abs_cart_filepath);
             // Confirm overwriting of the found conflicting file or directory on the same path.
             // We only ask confirmation for files which are not symbolic links, because we assume
             // that symbolic links were created by this command earlier and can be overwritten without
             // the loss of any data.
             if (!$is_link && ($is_file || $is_dir)) {
                 $helper = $this->getHelper('question');
                 $question = new ConfirmationQuestion(sprintf('<question>%s "%s" already exists. Overwrite? [y/N]:</question> ', $is_dir ? 'Directory' : 'File', $abs_cart_filepath), false);
                 if (!$helper->ask($input, $output, $question)) {
                     continue;
                 }
             }
             $fs->remove($abs_cart_filepath);
         }
         $symlink_target_filepath = $input->getOption('relative') ? $fs->makePathRelative(dirname($abs_addon_filepath), dirname($abs_cart_filepath)) . basename($abs_cart_filepath) : $abs_addon_filepath;
         $fs->symlink($symlink_target_filepath, $abs_cart_filepath);
         $output->writeln(sprintf('Creating symlink for %s... <info>OK</info>', $rel_filepath));
     }
 }
示例#29
0
 /**
  *
  */
 public function configure()
 {
     $fs = new Filesystem();
     if (!file_exists(Platform::webDir() . '/sites/default/settings.php')) {
         $fs->copy(CLI_ROOT . '/resources/stacks/drupal/drupal7.settings.php', Platform::webDir() . '/sites/default/settings.php', true);
     }
     $fs->dumpFile(Platform::sharedDir() . '/settings.local.php', $this->string);
     // Relink if missing.
     if (!$fs->exists(Platform::webDir() . '/sites/default/settings.local.php')) {
         $fs->symlink('../../../shared/settings.local.php', Platform::webDir() . '/sites/default/settings.local.php');
     }
 }
示例#30
0
 public function testSymlinkCreatesTargetDirectoryIfItDoesNotExist()
 {
     $this->markAsSkippedIfSymlinkIsMissing();
     $file = $this->workspace . DIRECTORY_SEPARATOR . 'file';
     $link1 = $this->workspace . DIRECTORY_SEPARATOR . 'dir' . DIRECTORY_SEPARATOR . 'link';
     $link2 = $this->workspace . DIRECTORY_SEPARATOR . 'dir' . DIRECTORY_SEPARATOR . 'subdir' . DIRECTORY_SEPARATOR . 'link';
     $this->filesystem->symlink($file, $link1);
     $this->filesystem->symlink($file, $link2);
     $this->assertTrue(is_link($link1));
     $this->assertEquals($file, readlink($link1));
     $this->assertTrue(is_link($link2));
     $this->assertEquals($file, readlink($link2));
 }