Update for cli

This commit is contained in:
Maxime 2022-06-17 17:04:15 +02:00
parent 3410b83336
commit 5b0e7f4c99
1 changed files with 8 additions and 16 deletions

View File

@ -5,14 +5,6 @@ function line($line) {
echo $line . PHP_EOL;
}
line(" xxxxxxx xxxxxxxx xxxxxxxx ");
line(" x x x x x ");
line(" x x x x x ");
line(" xwxxxxx xxxxxxxx x xxxx ");
line(" x x x x x x ");
line(" x x x x x x ");
line(" xxxxxxx x x xxxxxxx ");
function run($command) {
line("> $command");
exec($command, $output, $return);
@ -21,31 +13,31 @@ function run($command) {
return $return === 0;
}
$repository = 'git@git.bluesquare.io:bag/cli.git';
$repository = 'git@git.bluesquare.io:bluesquare/cli.git';
$home = $_SERVER['HOME'] ?? ($_SERVER['HOMEPATH'] ?? $_SERVER['HOMEDRIVE']);
$dir = __DIR__;
line("Répertoire utilisateur détecté : $home");
if (is_dir("$home/.bag")) {
line("Le dossier $home/.bag existe déjà.");
if (is_dir("$home/.bcli")) {
line("Le dossier $home/.bcli existe déjà.");
exit(1);
}
if (!run("cd $home && git clone $repository .bag"))
if (!run("cd $home && git clone $repository .bcli"))
exit(1);
if (!run("cd $home/.bag && composer install"))
if (!run("cd $home/.bcli && composer install"))
exit(1);
$source = file_exists("$home/.zshrc") ? "$home/.zshrc" : "$home/.bashrc";
$contents = file_exists($source) ? file_get_contents($source) : "";
if (strpos($contents, ".bag/bin") === false) {
if (strpos($contents, ".bcli/bin") === false) {
line("----------------------------------------------------");
line("----------------------------------------------------");
line("Pour pouvoir utiliser la commande `bag` :");
line("echo 'export PATH=\"$home/.bag/bin:\$PATH\"' >> $source");
line("Pour pouvoir utiliser la commande `bcli` :");
line("echo 'export PATH=\"$home/.bcli/bin:\$PATH\"' >> $source");
line("source $source");
line("----------------------------------------------------");
}