|
1 | 1 | <?php |
2 | | -if (php_sapi_name() !== 'cli') { |
3 | | - exit('It\'s no cli!'); |
| 2 | + |
| 3 | +if (php_sapi_name() !== 'cli' || !defined('_CONFIG')) { |
| 4 | + exit("\n\tI can not run out of system!\n"); |
4 | 5 | } |
5 | 6 |
|
6 | | -//Configurations - you can change... |
7 | | -$name = 'Router'; |
8 | | -$file = 'Router.php'; |
9 | | -$configPath = defined('_CONFIG') ? _CONFIG.'Router/' : dirname(dirname(dirname(__DIR__))).'/Config/Router/'; |
| 7 | +$thisConfig = __DIR__.'/Config/'; |
10 | 8 |
|
11 | | -//Checkin |
12 | | -if (is_file($configPath.$file)) { |
13 | | - return "\n--- $name configuration file already exists!"; |
14 | | -} |
15 | | -if (!is_dir($configPath)) { |
16 | | - @mkdir($configPath, 0777, true); |
17 | | - @chmod($configPath, 0777); |
18 | | - if (!is_writable($configPath)) { |
19 | | - return "\n\n--- Configuration file for $name not instaled!\n\n"; |
20 | | - } |
| 9 | +if (!is_dir($thisConfig)) { |
| 10 | + return; |
21 | 11 | } |
22 | 12 |
|
23 | | -//Copiando o arquivo de configuração para o CONFIG da aplicação |
24 | | -//copy(__DIR__.'/Config/Router/Router.php', $configPath.$file); |
25 | | -copy(__DIR__.'/Config/Router', $configPath); |
| 13 | +$namespace = @json_decode(file_get_contents(__DIR__.'/composer.json'))->name; |
| 14 | +/* OPTIONAL |
| 15 | + * load composer.json and get the "name" of pack |
| 16 | + * $appConfig = _CONFIG.$namespace; |
| 17 | + */ |
| 18 | + |
| 19 | +$appConfig = _CONFIG; |
| 20 | + |
| 21 | +//Coping all files (and directorys) in /Config |
| 22 | +$copy = \Lib\Cli\Main::copyDirectoryContents($thisConfig, $appConfig); |
26 | 23 |
|
27 | 24 | //Return to application installer |
28 | | -return "\n--- $name instaled!"; |
| 25 | +return "\n---".($copy === true ? " $namespace instaled!" : $copy); |
0 commit comments