/**
  * Restore previously backed up paths.
  *
  * @see PathPreserver::backupSubpaths()
  */
 public function rollback()
 {
     if (empty($this->backups)) {
         return;
     }
     foreach ($this->backups as $original => $backup_location) {
         // Remove any code that was placed by the package at the place of
         // the original path.
         if (static::file_exists($original)) {
             if (is_dir($original)) {
                 $this->filesystem->emptyDirectory($original, false);
                 $this->filesystem->removeDirectory($original);
             } else {
                 $this->filesystem->remove($original);
             }
             $this->io->write(sprintf('<comment>Files of installed package were overwritten with preserved path %s!</comment>', $original), true);
         }
         $folder = dirname($original);
         $this->filesystem->ensureDirectoryExists($folder);
         // Make sure we can write the file to the folder.
         $this->makePathWritable($folder);
         $this->filesystem->rename($backup_location, $original);
         if ($this->filesystem->isDirEmpty(dirname($backup_location))) {
             $this->filesystem->removeDirectory(dirname($backup_location));
         }
     }
     // Restore all path permissions, that where set for the sake of moving
     // things around.
     $this->restorePathPermissions();
     // With a clean array, we can start over.
     $this->backups = array();
 }
示例#2
0
 public static function clean(Event $event)
 {
     $themes = __DIR__ . '/../../../../themes/';
     $vendors = __DIR__ . '/../../../../vendor/';
     $fs = new FileSystem();
     $fs->ensureDirectoryExists($themes);
     self::addIndexFile($themes);
     self::addIndexFile($vendors);
     self::removeStandard($vendors);
     $fs->remove($vendors . 'adodb/adodb/cute_icons_for_site');
     $fs->remove($vendors . 'aFarkas/html5shiv/build');
     $fs->remove($vendors . 'bombayworks/zendframework1/library/Zend/Service/WindowsAzure/CommandLine/Scaffolders');
     $fs->remove($vendors . 'ckeditor/samples');
     $fs->remove($vendors . 'codemirror/codemirror/mode/tiki');
     self::removeMultiple($vendors . 'cwspear/bootstrap-hover-dropdown', ['bootstrap-hover-dropdown.min.js', 'demo.html']);
     $fs->remove($vendors . 'jcapture-applet/jcapture-applet/src');
     $fs->remove($vendors . 'jquery/jquery-s5/lib/dompdf/www');
     self::removeMultiple($vendors . 'jquery/jquery-sheet', ['jquery-1.10.2.min.js', 'jquery-ui', 'parser.php', 'parser/formula/formula.php']);
     self::removeMultiple($vendors . 'jquery/jquery-timepicker-addon', ['lib', 'src', 'jquery-ui-timepicker-addon.json', 'jquery-ui-timepicker-addon.min.css', 'jquery-ui-timepicker-addon.min.js']);
     self::removeMultiple($vendors . 'jquery/jquery-ui', ['development-bundle', 'external']);
     self::removeMultiple($vendors . 'jquery/jtrack', ['js/jquery.json-2.2.min.js', 'js/jquery-1.4.2.min.js']);
     self::removeMultiple($vendors . 'jquery/md5', ['css', 'js/demo.js', 'js/md5.min.js', 'test']);
     $fs->remove($vendors . 'jquery/minicart/src');
     self::removeMultiple($vendors . 'jquery/plugins/anythingslider', ['demos.html', 'anythingslider.jquery.json', 'expand.html', 'simple.html', 'video.html']);
     $fs->remove($vendors . 'jquery/plugins/brosho/__MACOSX');
     self::removeMultiple($vendors . 'jquery/plugins/chosen', ['docsupport', 'chosen.css', 'chosen.jquery.min.js', 'chosen.min.css', 'chosen.proto.js', 'chosen.proto.min.js', 'chosen-sprite.png', '*****@*****.**', 'index.proto.html', 'options.html']);
     $fs->remove($vendors . 'jquery/plugins/colorbox/content');
     self::removeMultiple($vendors . 'jquery/plugins/galleriffic', ['js/jquery-1.3.2.js', 'js/jquery.history.js', 'js/jush.js', 'example-1.html', 'example-2.html', 'example-3.html', 'example-4.html', 'example-5.html']);
     $fs->remove($vendors . 'jquery/plugins/infinitecarousel/jquery.infinitecarousel3.min.js');
     self::removeMultiple($vendors . 'jquery/plugins/jquery-validation', ['lib', 'src', 'dist/additional-methods.js', 'dist/additional-methods.min.js', 'dist/jquery.validate.min.js']);
     self::removeMultiple($vendors . 'jquery/plugins/jquery-json', ['dist', 'libs', '.jscsrc', '.jshintignore', '.jshintrc', '.travis.yml', 'HISTORY.md']);
     $fs->remove($vendors . 'jquery/plugins/reflection-jquery/src');
     self::removeMultiple($vendors . 'jquery/plugins/superfish', ['src', 'superfish.jquery.json', 'dist/js/jquery.js', 'dist/js/superfish.min.js']);
     self::removeMultiple($vendors . 'jquery/plugins/tablesorter', ['addons', 'beta-testing', 'css', 'docs', 'dist', 'testing', '.gitattributes', '.gitignore', '.jscsrc', 'bower.json', 'changelog.txt', 'CONTRIBUTING.md', 'example.json', 'Gruntfile.js', 'index.html', 'package.json', 'tablesorter.jquery.json', 'test.html', 'js/extras', 'js/jquery.tablesorter.js', 'js/jquery.tablesorter.widgets.js', 'js/parsers/parser-date.js', 'js/parsers/parser-date-extract.js', 'js/parsers/parser-date-iso8601.js', 'js/parsers/parser-date-month.js', 'js/parsers/parser-date-range.js', 'js/parsers/parser-date-two-digit-year.js', 'js/parsers/parser-date-weekday.js', 'js/parsers/parser-duration.js', 'js/parsers/parser-feet-inch-fraction.js', 'js/parsers/parser-file-type.js', 'js/parsers/parser-globalize.js', 'js/parsers/parser-ignore-articles.js', 'js/parsers/parser-image.js', 'js/parsers/parser-metric.js', 'js/parsers/parser-named-numbers.js', 'js/parsers/parser-network.js', 'js/parsers/parser-roman.js', 'js/widgets/widget-alignChar.js', 'js/widgets/widget-build-table.js', 'js/widgets/widget-chart.js', 'js/widgets/widget-cssStickyHeaders.js', 'js/widgets/widget-columns.js', 'js/widgets/widget-editable.js', 'js/widgets/widget-filter.js', 'js/widgets/widget-filter-formatter-html5.js', 'js/widgets/widget-filter-formatter-select2.js', 'js/widgets/widget-filter-type-insideRange.js', 'js/widgets/widget-formatter.js', 'js/widgets/widget-headerTitles.js', 'js/widgets/widget-output.js', 'js/widgets/widget-print.js', 'js/widgets/widget-reflow.js', 'js/widgets/widget-repeatheaders.js', 'js/widgets/widget-resizable.js', 'js/widgets/widget-saveSort.js', 'js/widgets/widget-scroller.js', 'js/widgets/widget-sort2Hash.js', 'js/widgets/widget-sortTbodies.js', 'js/widgets/widget-staticRow.js', 'js/widgets/widget-stickyHeaders.js', 'js/widgets/widget-storage.js', 'js/widgets/widget-uitheme.js']);
     self::removeMultiple($vendors . 'jquery/plugins/treetable', ['javascripts/test', 'stylesheets/jquery.treetable.theme.default.css', 'stylesheets/screen.css', 'treetable.jquery.json']);
     self::removeMultiple($vendors . 'jquery/plugins/zoom', ['jquery.zoom.min.js', 'zoom.jquery.json', 'demo.html', 'daisy.jpg', 'roxy.jpg']);
     self::removeMultiple($vendors . 'mediumjs/mediumjs', ['src', 'medium.min.js']);
     $fs->remove($vendors . 'phpcas/phpcas/CAS-1.3.2/docs');
     $fs->remove($vendors . 'phpseclib/phpseclib/tests');
     self::removeMultiple($vendors . 'player', ['flv/base', 'flv/classes', 'flv/html5', 'flv/mtasc', 'flv/template_js', 'flv/template_maxi', 'flv/template_mini', 'flv/template_multi', 'mp3/classes', 'mp3/mtasc', 'mp3/template_js', 'mp3/template_maxi', 'mp3/template_mini', 'mp3/template_multi']);
     self::removeMultiple($vendors . 'rangy/rangy', ['uncompressed/rangy-highlighter.js', 'uncompressed/rangy-serializer.js', 'uncompressed/rangy-textrange.js', 'rangy-core.js', 'rangy-cssclassapplier.js', 'rangy-highlighter.js', 'rangy-selectionsaverestore.js', 'rangy-serializer.js', 'rangy-textrange.js']);
     $fs->remove($vendors . 'smarty/smarty/distribution/demo');
     $fs->remove($vendors . 'twitter/bootstrap/docs');
     $fs->remove($vendors . 'zetacomponents/base/design');
     $fs->remove($vendors . 'zetacomponents/webdav/design');
     // These are removed to avoid composer warnings caused by classes declared in multiple locations
     $fs->remove($vendors . 'adodb/adodb/datadict/datadict');
     $fs->remove($vendors . 'adodb/adodb/session/session');
     $fs->remove($vendors . 'adodb/adodb/perf/perf');
     $fs->remove($vendors . 'adodb/adodb/drivers/drivers');
     $fs->remove($vendors . 'adodb/adodb/adodb-active-recordx.inc.php');
     $fs->remove($vendors . 'adodb/adodb/drivers/adodb-informix.inc.php');
     $fs->remove($vendors . 'adodb/adodb/perf/perf-informix.inc.php');
     $fs->remove($vendors . 'adodb/adodb/datadict/datadict-informix.inc.php');
     // html5shiv uses a component installer that doesn't seem to be optional, so delete the spare copy we end up with.
     $fs->remove($vendors . '../components');
     // and cwspear/bootstrap-hover-dropdown includes bootstrap and jquery without asking
     $fs->remove($vendors . 'components');
 }
示例#3
0
 private function finalizePackage($package)
 {
     $fs = new FileSystem();
     $base = $this->getPackageBasePath($package);
     $fs->ensureDirectoryExists("{$base}/css");
     $compiler = new \lessc();
     $compiler->compileFile("{$base}/less/tiki.less", "{$base}/css/{$base}.css");
     // Clean-up undesired files
     $fs->remove("{$base}/dist");
     $fs->remove("{$base}/docs");
     $fs->remove("{$base}/grunt");
     $fs->remove("{$base}/js");
     $fs->remove("{$base}/test-infra");
 }
 protected function beforeDrupalSaveCustom(PackageEvent $event, IOInterface $io)
 {
     // Change permissions for a better outcome when deleting existing sites,
     // since Drupal changes the permissions on these directories.
     $sitesDir = $this->drupalRoot . '/sites';
     if (!is_dir($sitesDir)) {
         $io->write("<error>Missing {$sitesDir->tmpdir}</error>");
         return;
     }
     $scanFiles = scandir($sitesDir);
     foreach ($scanFiles as $partialPath) {
         if ($partialPath != '.' && $partialPath != '..') {
             $filePath = "{$sitesDir}/{$partialPath}";
             if (is_dir($filePath)) {
                 @chmod($filePath, 0755);
                 @chmod("{$filePath}/settings.php", 0644);
             }
         }
     }
     $file = new FileSystem();
     foreach ($this->drupalCustom as $path) {
         if (!file_exists($path)) {
             continue;
         }
         if (!isset($this->tmpdir)) {
             $this->tmpdir = uniqid('/tmp/dci') . '.bak';
             if ($io->isVerbose()) {
                 $io->write("<info>Ensure {$this->tmpdir}</info>");
             }
             $file->ensureDirectoryExists($this->tmpdir);
         }
         $basename = basename($path);
         $tmpfile = $this->tmpdir . '/' . $basename;
         if (file_exists($tmpfile)) {
             $tmpfile = $this->tmpdir . '/' . md5($path);
             if ($io->isVerbose()) {
                 $io->write("<info>Ensure {$tmpfile}</info>");
             }
             $file->ensureDirectoryExists($tmpfile);
             $tmpfile .= '/' . $basename;
         }
         $io->write("<info>Save {$path} to {$tmpfile}</info>");
         $file->rename($path, $tmpfile);
         $this->tmp[$path] = $tmpfile;
     }
 }