This repository has been archived by the owner on Oct 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
109 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,24 +5,29 @@ | |
# | ||
# Options: | ||
# -g, --global Install the package globally. | ||
# -f, --force Force installation of package. | ||
|
||
. "$psscriptroot/../lib/core.ps1" | ||
. "$psscriptroot/../lib/unix.ps1" | ||
. "$psscriptroot/../lib/shim.ps1" | ||
. "$psscriptroot/../lib/path.ps1" | ||
. "$psscriptroot/../lib/args.ps1" | ||
. "$psscriptroot/../lib/filesys.ps1" | ||
|
||
$E = [char]27 | ||
$error_msg = "$E[1m$E[38;2;255;10;010merr!$E[0m" | ||
$done_msg = "$E[1m$E[38;2;100;255;80mdone$E[0m" | ||
$ok_msg = "$E[1m$E[38;2;100;255;80mok$E[0m" | ||
$unknown_msg = "$E[1m$E[38;2;250;250;0m???$E[0m" | ||
$warn_msg = "$E[1m$E[38;2;250;250;0mwarn$E[0m" | ||
$info_msg = "$E[1m$E[38;2;120;120;255minfo$E[0m" | ||
|
||
$opt, $packages, $errors = getopt $args 'g' 'global' | ||
$opt, $packages, $errors = getopt $args 'gf' 'global','force' | ||
$global = $opt.global -or $opt.g | ||
$force = $opt.force -or $opt.f | ||
|
||
if ($errors) { | ||
printf "$error_msg argument error: $err`n" | ||
printf "$error_msg argument error: $errors`n" | ||
exit 1 | ||
} | ||
|
||
|
@@ -41,26 +46,114 @@ foreach ($_pkg in $packages) { | |
$manifest = $manifest_json | convertfrom-json | ||
$package = $manifest.name | ||
$vendor = $manifest.vendor | ||
$g_url = $manifest.git_url | ||
$f_url = $manifest.file_url | ||
$platform = $manifest.platform | ||
$done_msg | ||
|
||
|
||
printf "$info_msg checking repository '$package' from '$vendor'... " | ||
git ls-remote "[email protected]:$vendor/$package" -q 2> $null | ||
if (!$?) { | ||
$error_msg | ||
printf "$error_msg repository does not appear to exist. aborting.`n" | ||
continue | ||
if ($platform) { | ||
printf "$info_msg checking platform compatibility... " | ||
if ($platform -eq "win32") { | ||
if ($IsWindows) { | ||
$ok_msg | ||
} | ||
else { | ||
if ($force) { | ||
"" | ||
printf "$warn_msg platform 'win32' does not match current platform, forcing install anyway.`n" | ||
} | ||
else { | ||
$error_msg | ||
printf "$error_msg platform 'win32' does not match current platform, skipping.`n" | ||
continue | ||
} | ||
} | ||
} | ||
elseif ($platform -eq "linux") { | ||
if ($IsLinux) { | ||
$ok_msg | ||
} | ||
else { | ||
if ($force) { | ||
"" | ||
printf "$warn_msg platform 'linux' does not match current platform, forcing install anyway." | ||
} | ||
else { | ||
$error_msg | ||
printf "$error_msg platform 'linux' does not match current platform, skipping." | ||
continue | ||
} | ||
} | ||
} | ||
elseif ($platform -eq "darwin") { | ||
if ($IsMacOS) { | ||
$ok_msg | ||
} | ||
else { | ||
if ($force) { | ||
"" | ||
printf "$warn_msg platform 'darwin' does not match current platform, forcing install anyway." | ||
} | ||
else { | ||
$error_msg | ||
printf "$error_msg platform 'darwin' does not match current platform, skipping." | ||
continue | ||
} | ||
} | ||
} | ||
else { | ||
$unknown_msg | ||
} | ||
} | ||
else { | ||
|
||
if ($g_url) { | ||
printf "$info_msg checking repository $g_url... " | ||
git ls-remote "$g_url" -q 2> $null | ||
if (!$?) { | ||
$error_msg | ||
printf "$error_msg repository does not appear to exist. skipping.`n" | ||
continue | ||
} | ||
else { | ||
$done_msg | ||
} | ||
|
||
printf "$info_msg cloning package '${package}'... " | ||
if (test-path "$(get_tmp)/${vendor}-${package}") { | ||
remove-item -r -fo "$(get_tmp)/${vendor}-${package}" | ||
} | ||
git clone -q "$g_url" "$(get_tmp)/${vendor}-${package}" > $null | ||
$done_msg | ||
} | ||
} elseif ($f_url) { | ||
if (test-path "$(get_tmp)/${vendor}-${package}") { | ||
remove-item -r -fo "$(get_tmp)/${vendor}-${package}" | ||
} | ||
mkdir -p "$(get_tmp)/${vendor}-${package}" > $null | ||
|
||
printf "$info_msg cloning package '${package}'... " | ||
if (test-path "$(get_tmp)/${vendor}-${package}") { | ||
remove-item -r -fo "$(get_tmp)/${vendor}-${package}" | ||
foreach ($url in $f_url) { | ||
printf "$info_msg downloading file from $f_url... " | ||
curl -sSL "$url" > "$(get_tmp)/${vendor}-${package}/$(url_fname $url)" | ||
$done_msg | ||
} | ||
} else { | ||
printf "$info_msg checking repository '$package' from '$vendor'... " | ||
git ls-remote "[email protected]:$vendor/$package" -q 2> $null | ||
if (!$?) { | ||
$error_msg | ||
printf "$error_msg repository does not appear to exist. skipping.`n" | ||
continue | ||
} | ||
else { | ||
$done_msg | ||
} | ||
|
||
printf "$info_msg cloning package '${package}'... " | ||
if (test-path "$(get_tmp)/${vendor}-${package}") { | ||
remove-item -r -fo "$(get_tmp)/${vendor}-${package}" | ||
} | ||
git clone -q "https://github.com/$vendor/$package" "$(get_tmp)/${vendor}-${package}" > $null | ||
$done_msg | ||
} | ||
git clone -q "https://github.com/$vendor/$package" "$(get_tmp)/${vendor}-${package}" > $null | ||
$done_msg | ||
|
||
if ($manifest.global -eq "true" -and $global -eq $false) { | ||
$install_global = $true | ||
|
This file was deleted.
Oops, something went wrong.