Multiple fixes

* Implemented ScriptRunner with environment expansion and cleaner
  code.
* Added ApiClient plugin (com.noccy.apiclient)
* Renamed CHANGELOG.md to VERSIONS.md
* Shuffled buildtools
* Added first unittests
This commit is contained in:
2021-12-11 01:44:01 +01:00
parent 8c6f7c1e93
commit 8cc1eac7a4
33 changed files with 1976 additions and 891 deletions

View File

@ -1,5 +1,10 @@
<?php
if (!(file_exists(getcwd()."/plugins") && file_exists(getcwd()."/spark.phar"))) {
fwrite(STDERR, "Not running from installer directory! Already installed?\n");
exit(1);
}
function askConfirm(string $prompt, bool $default) {
$pstr = sprintf("%s [%s]? ", $prompt, $default?"Y/n":"y/N");
@ -26,7 +31,13 @@ function askString(string $prompt, ?string $default=null) {
}
printf("\n%s\n\e[1mSpark\e[0m Installer\n%s\n\n", str_repeat("\u{2500}",40), str_repeat("\u{2500}", 40));
echo " ___ _ \n";
echo "/ __|_ __ __ _ _ _| |__\n";
echo "\\__ \\ '_ \\/ _` | '_| / /\n";
echo "|___/ .__/\\__,_|_| |_\\_\\\n";
echo " |_| \n";
printf("\n%s\n \u{26a1} \e[1mSpark\e[0m Installer\n%s\n\n", str_repeat("\u{2500}",40), str_repeat("\u{2500}", 40));
$destination = askString("Installation directory", getenv("HOME")."/opt/spark");
$binaries = askString("Path for executables", getenv("HOME")."/bin");
@ -57,14 +68,17 @@ passthru("cp -R plugins/* ".escapeshellarg($destination."/plugins/"));
if ($doPlugins) {
$file = sprintf("export SPARK_PLUGINS=\"%s/plugins\"\n", $destination);
file_put_contents(getenv("HOME")."/.profile_spark", $file);
file_put_contents(getenv("HOME")."/.bashrc_spark", $file);
printf("Updated \e[3m.bashrc_spark\e[0m.\n");
$file = file_get_contents(getenv("HOME")."/.profile");
$file .= "\nsource ~/.profile_spark\n";
file_put_contents(getenv("HOME")."/.profile.new", $file);
rename(getenv("HOME")."/.profile", getenv("HOME")."/.profile.bak");
rename(getenv("HOME")."/.profile.new", getenv("HOME")."/.profile");
printf("Updated \e[3m.profile\e[0m.\n");
$file = file_get_contents(getenv("HOME")."/.bashrc");
if (!str_contains($file, ".bashrc_spark")) {
$file .= "\nsource ~/.bashrc_spark\n";
file_put_contents(getenv("HOME")."/.bashrc.new", $file);
rename(getenv("HOME")."/.bashrc", getenv("HOME")."/.bashrc.bak");
rename(getenv("HOME")."/.bashrc.new", getenv("HOME")."/.bashrc");
printf("Updated \e[3m.bashrc\e[0m.\n");
}
}
if ($doAliases) {
$file = file_get_contents(getenv("HOME")."/.bash_aliases") . "\n";