protected function createDirGenTest($baseDir, $dir)
 {
     $this->fs->shouldReceive('exists')->once()->with(m::mustBe(Path::join($baseDir, $dir)))->andReturn(false);
     $this->fs->shouldReceive('makeDirectory')->once()->with(m::mustBe(Path::join($baseDir, $dir)), m::mustBe(0755), m::mustBe(true))->andReturn(true);
     $generator = $this->generator->generateDirectoryStructure($baseDir, [$dir]);
     $this->assertInstanceOf(StubGenerator::class, $generator);
 }
 protected static function generateIfRequired()
 {
     $fs = new Filesystem();
     if (!isset(static::$values) || !isset(static::$records)) {
         static::$values = json_decode($fs->get(Path::join(__DIR__, 'data/values.json')), true)[0];
         static::$records = json_decode($fs->get(Path::join(__DIR__, 'data/records.json')), true);
     }
 }
Beispiel #3
0
 public function handle()
 {
     $name = $this->ask('Directory name');
     $displayName = $this->ask('Display name');
     $name = Str::slugify($name);
     $destPath = Path::join(config('codex.root_dir'), $name);
     $fs = $this->getLaravel()->make('fs');
     if ($fs->exists($destPath)) {
         return $this->error("Could not create {$name}. Already exists");
     }
     $this->getLaravel()->make(ProjectGenerator::class)->setDestPath($destPath)->generateProject($name, $displayName);
     $this->comment('All done sire!');
 }
 protected function remove($name)
 {
     $tmpDir = storage_path('blade-extensions');
     $path = Path::join($tmpDir, $name);
     $this->files->delete($path);
     return $this;
 }
Beispiel #5
0
 /**
  * Returns the menu for this project
  *
  * @return \Codex\Codex\Menus\Menu
  */
 public function getDocumentsMenu()
 {
     $yaml = $this->files->get(Path::join($this->path, $this->ref, 'menu.yml'));
     $array = Yaml::parse($yaml);
     $this->factory->getMenus()->forget('project_sidebar_menu');
     $menu = $this->resolveDocumentsMenu($array['menu']);
     $menu->setView('codex::menus/project-sidebar');
     $this->runHook('project:documents-menu', [$this, $menu]);
     return $menu;
 }
Beispiel #6
0
 /**
  * resolveProjects
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 protected function resolveProjects()
 {
     if (!$this->projects->isEmpty()) {
         return;
     }
     /**
      * @var \Codex\Codex\Menus\Node $projectsMenu
      */
     $projectsMenu = $this->menus->add('projects_menu');
     $finder = new Finder();
     $projects = $finder->in($this->rootDir)->files()->name('config.php')->depth('<= 1')->followLinks();
     foreach ($projects as $projectDir) {
         /** @var \SplFileInfo $projectDir */
         $name = Path::getDirectoryName($projectDir->getPath());
         $config = $this->container->make('fs')->getRequire($projectDir->getRealPath());
         $config = array_replace_recursive($this->config('default_project_config'), $config);
         $project = $this->container->make(Project::class, ['factory' => $this, 'name' => $name, 'config' => $config]);
         $this->runHook('project:make', [$this, $project]);
         $this->projects->put($name, $project);
         $projectsMenu->add($name, $name, 'root', [], ['href' => $this->url($project)]);
     }
 }
Beispiel #7
0
 /**
  * generateDirectoryStructure
  *
  * @param       $destDir
  * @param array $dirs
  * @return $this
  */
 public function generateDirectoryStructure($destDir, array $dirs = [])
 {
     foreach ($dirs as $dirPath) {
         $dirPath = Path::join($destDir, $dirPath);
         if (!$this->files->exists($dirPath)) {
             $this->files->makeDirectory($dirPath, 0755, true);
         }
     }
     return $this;
 }
Beispiel #8
0
 /**
  * @inheritDoc
  */
 public function __construct(BladeCompiler $compiler, Filesystem $files)
 {
     parent::__construct($compiler, $files);
     $this->stubPath = Path::join(__DIR__, '..', 'resources', 'stubs');
 }
 /**
  * getFilePath
  *
  * @param        $relativePath
  * @param null   $fileName
  * @param string $ext
  * @return string
  */
 public function getPath($relativePath, $fileName = null, $ext = '.php')
 {
     $path = Path::join($this->dir, $relativePath);
     return is_null($fileName) ? $path : Path::join($path, $fileName . $ext);
 }
Beispiel #10
0
 /**
  * @dataProvider provideIsBasePathTests
  */
 public function testIsBasePath($path, $ofPath, $result)
 {
     $this->assertSame($result, Path::isBasePath($path, $ofPath));
 }