Skip to content

Commit 8d1c526

Browse files
committed
New Update script
1 parent d850d1c commit 8d1c526

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

Cli/Main.php

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,47 @@ function cmdInstall($v, $arg)
104104
*
105105
* @return string Display user data
106106
*/
107+
107108
function cmdUpdate($v, $arg)
108109
{
109-
$devbr = _APP.'Composer/devbr/';
110-
$dir = scandir($devbr);
111-
$o = '';
110+
$composer_psr4 = dirname(dirname(dirname(__DIR__))).'/composer/autoload_psr4.php';
111+
if (!file_exists($composer_psr4)) {
112+
ret("I can't find Composer data!");
113+
}
114+
115+
$composer = require_once $composer_psr4;
116+
if (!isset($composer['Config\\'][0])) {
117+
ret("I can't find Composer data!");
118+
}
119+
120+
$configDir = $composer['Config\\'][0];
112121

113-
foreach ($dir as $k) {
114-
if ($k == '.' || $k == '..') {
122+
$dir = scandir($vendorDir.'/devbr');
123+
foreach ($dir as $d) {
124+
if ($d == '.' || $d == '..') {
115125
continue;
116126
}
117-
if (is_file($devbr.$k.'/install.php')) {
118-
$o .= include $devbr.$k.'/install.php';
127+
128+
$key = 'Devbr/'.ucfirst($d);
129+
130+
if (is_dir("$vendorDir/".strtolower($key)."/Config/")) {
131+
echo "\n - Running: $key";
132+
133+
if (is_dir("$configDir/$key")) {
134+
echo "\n - Configuration already exists - ignored.\n";
135+
continue;
136+
}
137+
138+
//Coping all files (and directorys) in /Config
139+
$copy = static::copyDirectoryContents("$vendorDir/".strtolower($key)."/Config", "$configDir/$key");
140+
141+
//Return to application installer
142+
echo "\n - ".($copy === true ? "$key instaled!" : $copy)."\n";
119143
}
120144
}
121-
return $o;
122145
}
123146

147+
124148
// Checa um diretório e cria se não existe - retorna false se não conseguir ou não existir
125149
/**
126150
* Check or create a directory

0 commit comments

Comments
 (0)