You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.5 KiB
53 lines
1.5 KiB
#!/usr/bin/env php |
|
<?php |
|
|
|
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); |
|
foreach ($output as $line) |
|
line($line); |
|
return $return === 0; |
|
} |
|
|
|
$repository = 'git@git.bluesquare.io:bag/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à."); |
|
exit(1); |
|
} |
|
|
|
if (!run("cd $home && git clone $repository .bag")) |
|
exit(1); |
|
|
|
if (!run("cd $home/.bag && 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) { |
|
line("----------------------------------------------------"); |
|
line("----------------------------------------------------"); |
|
line("Pour pouvoir utiliser la commande `bag` :"); |
|
line("echo 'export PATH=\"$home/.bag/bin:\$PATH\"' >> $source"); |
|
line("source $source"); |
|
line("----------------------------------------------------"); |
|
} |
|
|
|
exit(0);
|
|
|