Exemple #1
0
 protected function movePersistentDirectories($sourceDir, $targetDir)
 {
     foreach ($this->persistentDirs as $dir) {
         $source = $sourceDir . self::DS . $dir;
         $target = $targetDir . self::DS . $dir;
         if (file_exists($source)) {
             $this->emptyDir($target);
             $this->fs->copyThenRemove($source, $target);
         }
     }
 }
 /**
  * Complete the setup task.
  *
  * @since 0.1.0
  *
  * @return void
  */
 public function complete()
 {
     $filesystem = new Filesystem();
     $templatesFolder = $this->getConfigKey('Folders', 'templates');
     $finder = new Finder();
     foreach ($finder->files()->in($templatesFolder) as $file) {
         $from = $file->getPathname();
         $to = $this->getTargetPath($from);
         $filesystem->ensureDirectoryExists(dirname($to));
         $filesystem->copyThenRemove($from, $to);
     }
 }
 /**
  * Install Rubedo Core sources
  *
  * @param string $actualRootDir Rubedo root dir for project
  * @param array  $removedFiles  List of old files to remove after installation
  */
 protected function installRubedoCoreSources($actualRootDir, $removedFiles)
 {
     if ($this->io->isVerbose()) {
         $this->io->write("Updating new code over existing installation.");
     }
     // Removing files / directories to ignore from installation from temporary dir
     $this->cleanTempDir();
     $this->fileSystem->copyThenRemove($this->rubedoRootDir, $actualRootDir);
     $this->rubedoRootDir = $actualRootDir;
     // Deleting files removed from the previous package release
     $this->deleteRemovedFiles($removedFiles);
 }
 /**
  * Renames the plugin file to {{package}}.php,
  * removes it, if the package is not of type wordpress-plugin
  */
 public function complete()
 {
     $fs = new Util\Filesystem();
     $base_dir = $this->getConfigKey('BaseDir');
     $type = $this->getConfigKey('Placeholders', 'type')['value'];
     $package = $this->getConfigKey('Placeholders', 'package_key')['value'];
     $plugin_file = "{$base_dir}/plugin.php";
     if ('wordpress-plugin' === $type) {
         $fs->copyThenRemove($plugin_file, "{$base_dir}/{$package}.php");
         return;
     }
     $this->io->write("Removing plugin file");
     $fs->remove($plugin_file);
 }
 /**
  * Renames the relevant license file to 'LICENSE' and removes
  * the one we don't use
  */
 public function complete()
 {
     $fs = new Util\Filesystem();
     $base_dir = $this->getConfigKey('BaseDir');
     $license = $this->getConfigKey('Placeholders', 'license')['value'];
     $license_files = ['MIT' => 'LICENSE.mit', 'GPL-2.0' => 'LICENSE.gpl2'];
     if (!isset($license_files[$license])) {
         throw new Exception\LogicException("No file found for license '{$license}'");
     }
     $license_file = "{$base_dir}/{$license_files[$license]}";
     $fs->copyThenRemove($license_file, "{$base_dir}/LICENSE");
     foreach ($license_files as $file) {
         $this->io->write(sprintf("Removing license file %s", basename($file)));
         $fs->remove($file);
     }
 }
 public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
 {
     $downloadPath = $this->getInstallPath($package);
     $fileSystem = new Filesystem();
     $actualLegacyDir = $this->innomaticLegacyDir;
     $this->innomaticLegacyDir = $this->generateTempDirName();
     if (!is_dir($downloadPath) || $fileSystem->isDirEmpty($downloadPath)) {
         if ($this->io->isVerbose()) {
             $this->io->write("Installing in temporary directory.");
         }
         parent::install($repo, $package);
         if ($this->io->isVerbose()) {
             $this->io->write("Copying to the Innomatic legacy directory.");
         }
         $fileSystem->copyThenRemove($this->innomaticLegacyDir . '/source/', $actualLegacyDir);
         $this->innomaticLegacyDir = $actualLegacyDir;
     }
 }
    /**
     * Same as install(): we need to insure there is no removal of actual eZ code.
     * updateCode is called by update()
     */
    public function updateCode( PackageInterface $initial, PackageInterface $target )
    {
        $actualLegacyDir = $this->ezpublishLegacyDir;
        $this->ezpublishLegacyDir = $this->generateTempDirName();
        if ( $this->io->isVerbose() )
        {
            $this->io->write( "Installing in temporary directory." );
        }

        $this->installCode( $target );

        $fileSystem = new Filesystem();
        if ( $this->io->isVerbose() )
        {
            $this->io->write( "Updating new code over existing installation." );
        }
        /// @todo the following function does not warn of any failures in copying stuff over. We should probably fix it...
        $fileSystem->copyThenRemove( $this->ezpublishLegacyDir, $actualLegacyDir );

        $this->ezpublishLegacyDir = $actualLegacyDir;
    }
 public function onPostUpdate(Event $event)
 {
     // Load global plugin configuration
     $globalCfg = $this->getGlobalConfig();
     if ($globalCfg) {
         $extra = self::get($globalCfg, 'extra', []);
         $myConfig = self::get($extra, self::EXTRA_KEY, []);
         if ($myConfig) {
             $this->info("Global configuration loaded");
         }
     } else {
         $myConfig = [];
     }
     // Merge project-specific configuration.
     // Ignore it if Composer is running in global mode.
     $package = $this->composer->getPackage();
     if ($package->getName() != '__root__') {
         $projCfg = self::get($package->getExtra(), self::EXTRA_KEY, []);
         $myConfig = array_merge_recursive($myConfig, $projCfg);
         $this->info("Project-specific configuration loaded");
     }
     // Setup
     $rules = array_unique(self::get($myConfig, self::RULES_KEY, []));
     $sharedDir = str_replace('~', getenv('HOME'), self::get($myConfig, self::SHARED_DIR_KEY, self::DEFAULT_SHARED_DIR));
     $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
     $rulesInfo = implode(', ', $rules);
     $this->info("Shared directory: <info>{$sharedDir}</info>");
     $this->info("Match packages: <info>{$rulesInfo}</info>");
     $fsUtil = new FilesystemUtil();
     $fs = new Filesystem();
     // Do useful work
     $count = 0;
     foreach ($packages as $package) {
         $srcDir = $this->getInstallPath($package);
         $packageName = $package->getName();
         if (self::globMatchAny($rules, $packageName) && !$fsUtil->isSymlinkedDirectory($srcDir)) {
             $destPath = "{$sharedDir}/{$packageName}";
             if (!file_exists($destPath)) {
                 $fsUtil->copyThenRemove($srcDir, $destPath);
                 $this->info("Moved <info>{$packageName}</info> to shared directory and symlinked to it");
             } else {
                 $fs->remove($srcDir);
                 $this->info("Symlinked to existing <info>{$packageName}</info> on shared directory");
             }
             $fs->symlink($destPath, $srcDir);
             ++$count;
         }
     }
     if (!$count) {
         $this->info("No packages matched");
     }
 }