65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?php if( !defined('__ROOT__') ) define('__ROOT__', dirname(dirname(__FILE__)) );
|
|
|
|
|
|
class Builder{
|
|
|
|
|
|
private static function src(){ return __ROOT__.'/src'; }
|
|
private $modules = null;
|
|
private $root = null;
|
|
|
|
|
|
|
|
/* BUILDS A BUILDER WITH SPECIFIC LOCATION AND CONFIG
|
|
*
|
|
* @pRoot<String> Path to project root
|
|
* @pModules<Array> Modules to load
|
|
*
|
|
*/
|
|
public function __construct($pRoot, $pModules){
|
|
/* [1] Stores the path
|
|
=========================================================*/
|
|
$this->root = $pRoot;
|
|
|
|
/* [2] Stores the modules
|
|
=========================================================*/
|
|
$this->modules = $pModules;
|
|
}
|
|
|
|
|
|
|
|
public function build(){
|
|
|
|
/* [1] Builds project's base file structure
|
|
=========================================================*/
|
|
/* (1) Copy from src/files */
|
|
shell_exec("cp -r ".__ROOT__."/src/files/* ".$this->root);
|
|
|
|
|
|
|
|
/* [2] Browse each module to load
|
|
=========================================================*/
|
|
foreach($this->modules as $module=>$version){
|
|
$path = "/$module/$version";
|
|
|
|
/* (1) Copy module folder if it exists */
|
|
if( file_exists(__ROOT__."/src/modules$path/") && is_dir(__ROOT__."/src/modules$path/") && count(scandir(__ROOT__."/src/modules$path/")) > 2 )
|
|
shell_exec("cp -r ".__ROOT__."/src/modules$path ".$this->root."/build/$module");
|
|
|
|
/* (2) Copy module config if it exists */
|
|
if( file_exists(__ROOT__."/src/config$path/") && is_dir(__ROOT__."/src/config$path/") && count(scandir(__ROOT__."/src/config$path/")) > 2 )
|
|
shell_exec("cp -r ".__ROOT__."/src/config$path/* ".$this->root."/config/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|