Exemplo n.º 1
0
 /**
  * Initialise the home directory:
  * - if not present, create it copying the content from the home-dist directory
  * - if present check if the home directory is up to date with the latest DeploYii version
  */
 public static function initHomeDir()
 {
     if (!self::$_initialised) {
         $home = self::getHomeDir();
         if (!is_dir($home)) {
             FileHelper::copyDirectory(__DIR__ . '/../home-dist', $home);
             @unlink($home . '/README.md');
             VersionManager::updateHomeVersion();
         } else {
             $homeVersion = VersionManager::getHomeVersion();
             VersionManager::checkHomeVersion($homeVersion);
         }
     }
     self::$_initialised = true;
 }
Exemplo n.º 2
0
 /**
  * Load the required recipe and its requirements.
  * Note: recipes have to be loaded on init() declaring them as requirements
  *
  * This method will first look for built-in recipes and then for the user defined ones.
  * TODO: log warning message if the requested recipe is not found
  *
  * @param string $recipeName
  * @param bool   $globalRecipe whether to search inside the DeploYii home folder
  * @param bool   $userRecipe   whether to search inside the user build scripts folder
  *
  * @return bool|mixed
  */
 private function _loadRecipe($recipeName, $globalRecipe = false, $userRecipe = false)
 {
     $recipeScript = false;
     $recipeClass = ucfirst($recipeName) . 'Recipe';
     if ($globalRecipe && !$userRecipe) {
         $recipesDir = Yii::getAlias('@home/recipes');
     } elseif ($userRecipe) {
         $recipesDir = Yii::getAlias('@buildScripts/recipes');
     } else {
         $recipesDir = __DIR__ . '/recipes';
     }
     $recipeFile = $recipesDir . '/' . $recipeClass . '.php';
     if (file_exists($recipeFile)) {
         Log::logger()->addInfo('Loading recipe file: {file}', ['file' => $recipeFile]);
         /** @noinspection PhpIncludeInspection */
         $recipeScript = (require $recipeFile);
     } elseif (!$globalRecipe && !$userRecipe) {
         $recipeScript = $this->_loadRecipe($recipeName, true);
     } elseif (!$userRecipe) {
         $recipeScript = $this->_loadRecipe($recipeName, false, true);
     }
     $recipeVersion = isset($recipeScript['deployiiVersion']) ? $recipeScript['deployiiVersion'] : '0.3.0';
     VersionManager::checkRecipeVersion($recipeVersion, $recipeName);
     // Load requirements and initialise the extra parameters:
     if (!empty($recipeScript['require'])) {
         $this->_loadRequirements($recipeScript['require']);
     }
     $this->_recipes[$recipeName] = $recipeScript;
     return $recipeScript;
 }