/**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if ($this->manifest->delete()) {
         $this->info('Manifest has been deleted. All collections will are now required to be rebuilt.');
     } else {
         $this->comment('Manifest does not exist or could not be deleted.');
     }
 }
 /**
  * Cleans a built collection and the manifest entries.
  *
  * @param  string  $collection
  * @return void
  */
 public function clean($collection)
 {
     $entry = $this->manifest->get($collection);
     // If the collection exists on the environment then we'll proceed with cleaning the filesystem
     // This removes any double-up production and development builds.
     if (isset($this->environment[$collection])) {
         $this->cleanFilesystem($this->environment[$collection], $entry);
     } else {
         $this->manifest->forget($collection);
     }
     // Cleaning the manifest is important as it will also remove unnecessary files from the
     // filesystem if a collection has been removed.
     $this->cleanManifestFiles($collection, $entry);
     $this->manifest->save();
 }
Exemple #3
0
 /**
  * Build a development collection.
  *
  * @param  \Basset\Collection  $collection
  * @param  string  $group
  * @return void
  * @throws \Basset\Exceptions\BuildNotRequiredException
  */
 public function buildAsDevelopment(Collection $collection, $group)
 {
     // Get the assets of the given group from the collection. The collection is also responsible
     // for handling any ordering of the assets so that we just need to build them.
     $assets = $collection->getAssetsWithoutRaw($group);
     $entry = $this->manifest->make($identifier = $collection->getIdentifier());
     // If the collection definition has changed when compared to the manifest entry or if the
     // collection is being forcefully rebuilt then we'll reset the development assets.
     if ($this->collectionDefinitionHasChanged($assets, $entry, $group) or $this->force) {
         $entry->resetDevelopmentAssets($group);
     } else {
         $assets = $assets->filter(function ($asset) use($entry) {
             return !$entry->hasDevelopmentAsset($asset) or $asset->getBuildPath() != $entry->getDevelopmentAsset($asset);
         });
     }
     if (!$assets->isEmpty()) {
         foreach ($assets as $asset) {
             $path = "{$this->buildPath}/{$identifier}/{$asset->getBuildPath()}";
             // If the build directory does not exist we'll attempt to recursively create it so we can
             // build the asset to the directory.
             !$this->files->exists($directory = dirname($path)) and $this->files->makeDirectory($directory, 0777, true);
             $this->files->put($path, $this->gzip($asset->build()));
             // Add the development asset to the manifest entry so that we can save the built asset
             // to the manifest.
             $entry->addDevelopmentAsset($asset);
         }
     } else {
         throw new BuildNotRequiredException();
     }
 }
Exemple #4
0
 /**
  * Tidy up the filesystem with the build cleaner.
  * 
  * @return void
  */
 protected function tidyUpFilesystem()
 {
     $collections = array_keys($this->environment->all()) + array_keys($this->manifest->all());
     foreach ($collections as $collection) {
         if ($this->input->getOption('verbose')) {
             $this->line('[' . $collection . '] Cleaning up files and manifest entries.');
         }
         $this->cleaner->clean($collection);
     }
     $this->input->getOption('verbose') and $this->line('');
     $this->info('The filesystem and manifest have been tidied up.');
 }