Exemple #1
0
 public static function scan_modules($dirs = array("lib", "resources"), $target = "resources/bundle.json")
 {
     self::$webmodules = array("_" => array(), "bundles" => array());
     foreach ($dirs as $dir) {
         self::$webmodules = self::scan_modules_dir(self::$PROJECT_ROOT_DIR . $dir, self::$webmodules);
     }
     FileUtil::build_mkdir(self::$RESOURCE_DIST_DIR);
     FileUtil::build_write(self::$RESOURCE_DIST_DIR . "/" . $target, json_encode(self::$webmodules, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
     FileUtil::build_export_object(self::$RESOURCE_DIST_DIR . "/" . $target . ".php", self::$webmodules);
     return self::$webmodules;
 }
Exemple #2
0
 public static function deploy($configName)
 {
     $config = parse_ini_file("config/project.properties", true);
     $prog_dir = realpath(dirname(__FILE__)) . "/";
     if (empty($configName)) {
         $configName = "production";
     }
     if (!isset($config[$configName])) {
         Console::error("Config Does not exists in your config/project.properties");
         return false;
     }
     Console::block("Dplooying on Server with config : " . $configName);
     $password;
     if (isset($config[$configName]["pass"])) {
         $password = $config[$configName]["pass"];
     } else {
         if ($password == null) {
             Console::println("Enter Password");
             $stdin = fopen('php://stdin', 'r');
             $password = trim(fgets($stdin));
             fclose($stdin);
         }
     }
     $serverConfig = array_merge_recursive($config[$configName], array("clean_directories" => array(), "ignore_files" => array('lib/*', "lib/", "lib"), "upload_untracked" => array('lib/composer', 'lib/autoload.php', 'build')));
     $serverConfig["pass"] = $password;
     Console::line();
     print_r($serverConfig);
     Console::line();
     // Empty build folder
     FileUtil::build_mkdir("deploy");
     // Write Config File for main project
     self::upload($prog_dir, $serverConfig, "build/deploy/deploy.ini");
     // No need o delete lib and buld in library cud be harmful
     unset($serverConfig["clean_directories"]);
     unset($serverConfig["ignore_files"]);
     unset($serverConfig["upload_untracked"]);
     // Upload Libraries..
     chdir("lib");
     $vendors = array_filter(glob('*'), 'is_dir');
     Console::line();
     Console::println("Libraries to upload:");
     print_r($vendors);
     Console::line();
     try {
         $host_path = $serverConfig['path'];
         foreach ($vendors as $vendor) {
             chdir($vendor);
             Console::println("Directory: " . $vendor);
             $libs = array_filter(glob('*'), 'is_dir');
             Console::println("Directorirs: " . implode(",", $libs));
             foreach ($libs as $lib) {
                 if (!($vendor == "rudrax" && $lib == "application")) {
                     Console::line();
                     chdir($lib);
                     Console::println("Package: " . $vendor . "/" . $lib);
                     $lib_ini_file = "../../../build/deploy/" . $vendor . "-" . $lib . ".ini";
                     $serverConfig['path'] = $host_path . "lib/" . $vendor . "/" . $lib;
                     $serverConfig['pass'] = $password;
                     self::mkdir($serverConfig);
                     self::upload($prog_dir, $serverConfig, $lib_ini_file);
                     // $this->write_ini_file ( $config, $lib_ini_file, true );
                     // Console::println ( "Executing: " . "php " . $prog_dir . "git-deploy " . $lib_ini_file );
                     // passthru ( "php " . $prog_dir . "/git-deploy " . $lib_ini_file );
                     // unlink ( $lib_ini_file );
                     chdir("..");
                 }
             }
             chdir("..");
         }
         //$this->delete_dir ( "build" );
     } catch (Exception $e) {
         Console::println("Error: Some error in libraries uploaded");
     }
 }