Example #1
0
 /**
  */
 public function main()
 {
     if (empty($this->root)) {
         throw new \BuildException("You must specify the root folder, or the root folder does not exist.", $this->location);
     }
     $DS = DIRECTORY_SEPARATOR;
     foreach ($this->filesets as $fs) {
         $scanner = $fs->getDirectoryScanner($this->project);
         foreach ($scanner->getIncludedDirectories() as $included) {
             $dir = realpath(realpath($scanner->getBasedir()) . $DS . $included);
             $parts = explode($DS, substr($dir, strlen($this->root) + 1));
             $package = array_pop($parts);
             if (GemsString::startsWith($dir, '.') || GemsString::startsWith($package, '.')) {
                 continue;
             }
             $this->directory($dir, $package, $parts);
         }
     }
 }
 /**
  * @param string $dir
  * @param string $package
  * @param array  $parts
  *
  * @return array
  */
 private function getAll($dir, $package, array $parts)
 {
     $name = empty($parts) ? $package : sprintf("%s.%s", implode(".", $parts), $package);
     $lines = array('//***********************************************', '//* Do not edit. This file will be auto-updated *', '//***********************************************', '', sprintf('goog.provide("%s.All");', $name), sprintf('goog.require("%s");', $name), '');
     $this->eachDirectory($dir, function ($folder) use($name, &$lines) {
         $lines[] = sprintf('goog.require("%s.%s.All");', $name, $folder);
     });
     $lines = self::space($lines);
     $this->eachComponent($dir, function ($component) use($name, &$lines) {
         $lines[] = sprintf('goog.require("%s.%s");', $name, $component);
     });
     $lines = self::space($lines);
     $this->eachFile($dir, function ($file) use($name, &$lines) {
         if (GemsString::endsWith($file, ".js") && !GemsString::startsWith($file, "_") && !GemsString::endsWith($file, ".Test.js")) {
             $lines[] = sprintf('goog.require("%s.%s");', $name, substr($file, 0, -3));
         }
     });
     $lines = self::space($lines);
     return $lines;
 }
Example #3
0
 /**
  * @param string $dir
  *
  * @return array
  */
 private function getPackage($dir)
 {
     $DS = DIRECTORY_SEPARATOR;
     $lines = ['/** Import package wide styles here. **/', ''];
     self::eachFile($dir, function ($file) use($dir, $DS, &$lines) {
         if (!GemsString::endsWith($file, ".scss") || $file == '_All.scss' || $file == '_Package.scss') {
             return;
         }
         $lines[] = sprintf('@import "%s";', str_replace('.scss', '', $file));
     });
     return $lines;
 }
 /**
  * Ensures that a component folder contains all of it's required files.
  *
  * @param string $dir
  * @param string $package
  * @param array  $parts
  */
 protected function directory($dir, $package, array $parts)
 {
     if (GemsString::startsWith($package, $this->prefix) && $package != $this->parent) {
         $this->updateComponentFolder($dir, $package, $parts);
         return;
     }
     $this->updatePackageFolder($dir, $package, $parts);
 }