Esempio n. 1
0
 /**
  * @param Package|string $packageName
  * @return string
  */
 public static function getClassName($packageName)
 {
     if ($packageName instanceof Package) {
         return self::PACKAGE_CLASS_NAME_PREFIX . $packageName->getName(self::PACKAGE_PATH_SEPARATOR);
     }
     return self::PACKAGE_CLASS_NAME_PREFIX . str_replace(Package::PACKAGE_PATH_SEPARATOR, self::PACKAGE_PATH_SEPARATOR, $packageName);
 }
Esempio n. 2
0
 /**
  * @param Package $p
  * @param array $sourceFiles
  * @return string
  */
 private function generateSingleFileName(Package $p, array $sourceFiles)
 {
     $targetFile = $this->directory . DIRECTORY_SEPARATOR . $p->getName('_');
     $first = reset($sourceFiles);
     $targetFile .= '/' . $p->getName('_') . substr($first, strrpos($first, '.'));
     return $targetFile;
 }
Esempio n. 3
0
 /**
  * @param Package $p
  * @param array $commands
  */
 private function execute(Package $p, array $commands)
 {
     $targetDir = Config::instance()->directories()->CompiledResourcesDir . DIRECTORY_SEPARATOR . $p->getName('_');
     /** @var IGulpCommand $command */
     $command = Config::skeleton(IGulpCommand::class);
     $command->setAction('build');
     $command->setGulpPath(__DIR__ . '/../../../../../../js/GulpCompiler/');
     if (!file_exists($targetDir)) {
         mkdir($targetDir, 0777, true);
     }
     $command->setArg('--commands', $commands);
     $command->setArg('--targetDir', $targetDir);
     $command->execute(Config::skeleton(IShell::class));
 }
Esempio n. 4
0
 /**
  * Remove any files from the package directory.
  * @param Package $p
  */
 public function cleanDirectory(Package $p)
 {
     $targetDir = Config::instance()->directories()->CompiledResourcesDir;
     $packageDir = $targetDir . DIRECTORY_SEPARATOR . $p->getName('_');
     $allFiles = array_merge($p->Scripts->get(), $p->Styles->get(), $p->Views->get());
     foreach (glob($packageDir . '/*') as $path) {
         if (!is_file($path)) {
             continue;
         }
         if (in_array($path, $allFiles)) {
             continue;
         }
         unlink($path);
     }
 }
Esempio n. 5
0
 public function test_isValidPackageName_ValidValues()
 {
     $this->assertTrue(Package::isValidPackageName('a'));
     $this->assertTrue(Package::isValidPackageName('a/a'));
     $this->assertTrue(Package::isValidPackageName('a/a/a'));
     $this->assertTrue(Package::isValidPackageName('0'));
     $this->assertTrue(Package::isValidPackageName('abc/0123/def'));
 }
Esempio n. 6
0
 public function test_getPath_InvalidPartOfPath()
 {
     $p = new Package('package/name');
     $this->assertNull($p->getPath(-1));
     $this->assertNull($p->getPath(2));
 }
Esempio n. 7
0
 /**
  * @param Package $p
  * @return string
  */
 private function getPath(Package $p)
 {
     return $this->dir . DIRECTORY_SEPARATOR . $p->getName('_') . DIRECTORY_SEPARATOR . substr(md5($p->getName()), 0, 8) . '.view.js';
 }