Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 /**
  * resolveProjects
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 protected function resolveProjects()
 {
     if (!$this->projects->isEmpty()) {
         return;
     }
     /**
      * @var \Docit\Core\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)]);
     }
 }
Exemplo n.º 4
0
 public function getBranchesToSync()
 {
     $allowedBranches = $this->setting('sync.sync.branches');
     if (count($allowedBranches) === 0) {
         return [];
     }
     $branchesToSync = [];
     $branches = $this->github->repositories()->branches($this->setting('owner'), $this->setting('repository'));
     foreach ($branches as $branch) {
         $branchName = $branch['name'];
         if (!in_array('*', $allowedBranches, true) and !in_array($branchName, $allowedBranches, true)) {
             continue;
         }
         $sha = $branch['commit']['sha'];
         $cacheKey = md5($this->project->getName() . $branchName);
         $branch = $this->cache->get($cacheKey, false);
         $destinationPath = Path::join($this->project->getPath(), $branchName);
         if ($branch !== $sha or $branch === false or !$this->files->exists($destinationPath)) {
             $branchesToSync[] = $branchName;
         }
     }
     return $branchesToSync;
 }
Exemplo n.º 5
0
 /**
  * Returns the menu for this project
  *
  * @return \Docit\Core\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('docit::menus/project-sidebar');
     $this->runHook('project:documents-menu', [$this, $menu]);
     return $menu;
 }