Skip to content

Commit

Permalink
Merge branch 'develop' into feat-scoop-shim
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven committed Feb 21, 2022
2 parents 3e5381d + b95ccbe commit 00de264
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 66 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- **scoop-alter:** Add `scoop alter` command to switch shim's target ([#4727](https://github.com/ScoopInstaller/Scoop/issues/4727))
- **scoop-bucket:** List more detailed information for buckets ([#4704](https://github.com/ScoopInstaller/Scoop/issues/4704))
- **scoop-cache:** Handle multiple apps and show detailed information ([#4738](https://github.com/ScoopInstaller/Scoop/issues/4738))
- **scoop-cat:** Use `bat` to pretty-print JSON ([#4742](https://github.com/ScoopInstaller/Scoop/issues/4742))
- **scoop-download:** Add `scoop download` command ([#4621](https://github.com/ScoopInstaller/Scoop/issues/4621))
- **scoop-(install|virustotal):** Allow skipping update check ([#4634](https://github.com/ScoopInstaller/Scoop/issues/4634))
- **scoop-list:** Allow list manipulation ([#4718](https://github.com/ScoopInstaller/Scoop/issues/4718))
Expand Down Expand Up @@ -42,6 +43,8 @@
- **rmdir:** Use 'Remove-Item' instead of 'rmdir' ([#4691](https://github.com/ScoopInstaller/Scoop/issues/4691))
- **COMSPEC:** Deprecate use of subshell cmd.exe ([#4692](https://github.com/ScoopInstaller/Scoop/issues/4692))
- **git:** Use 'git -C' to specify the work directory instead of 'Push-Location'/'Pop-Location' ([#4697](https://github.com/ScoopInstaller/Scoop/issues/4697))
- **scoop-info:** Use List View for output ([#4741](https://github.com/ScoopInstaller/Scoop/issues/4741))
- **scoop-config:** Use underscores everywhere ([#4745](https://github.com/ScoopInstaller/Scoop/issues/4745))

### Builds

Expand Down
10 changes: 5 additions & 5 deletions bin/scoop.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#requires -v 3
#Requires -Version 5
param($cmd)

set-strictmode -off
Set-StrictMode -off

. "$psscriptroot\..\lib\core.ps1"
. "$psscriptroot\..\lib\buckets.ps1"
. (relpath '..\lib\commands')
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\commands.ps1"

reset_aliases

Expand Down
2 changes: 1 addition & 1 deletion lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ function app_status($app, $global) {

$status.outdated = $false
if ($status.version -and $status.latest_version) {
if (get_config 'force-update' $false) {
if (get_config 'force_update' $false) {
$status.outdated = ((Compare-Version -ReferenceVersion $status.version -DifferenceVersion $status.latest_version) -ne 0)
} else {
$status.outdated = ((Compare-Version -ReferenceVersion $status.version -DifferenceVersion $status.latest_version) -gt 0)
Expand Down
15 changes: 10 additions & 5 deletions lib/install.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
. "$psscriptroot/autoupdate.ps1"
. "$psscriptroot/buckets.ps1"
. "$PSScriptRoot/autoupdate.ps1"
. "$PSScriptRoot/buckets.ps1"

function nightly_version($date, $quiet = $false) {
$date_str = $date.tostring("yyyyMMdd")
Expand Down Expand Up @@ -34,9 +34,14 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru
return
}

if ((get_config 'manifest-review' $false) -and ($MyInvocation.ScriptName -notlike '*scoop-update*')) {
Write-Output "Manifest: $app.json"
Write-Output $manifest | ConvertToPrettyJson
if ((get_config 'manifest_review' $false) -and ($MyInvocation.ScriptName -notlike '*scoop-update*')) {
Write-Host "Manifest: $app.json"
$style = get_config cat_style
if ($style) {
$manifest | ConvertToPrettyJson | bat --no-paging --style $style --language json
} else {
$manifest | ConvertToPrettyJson
}
$answer = Read-Host -Prompt "Continue installation? [Y/n]"
if (($answer -eq 'n') -or ($answer -eq 'N')) {
return
Expand Down
2 changes: 1 addition & 1 deletion lib/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function install_info($app, $version, $global) {
}

function default_architecture {
$arch = get_config 'default-architecture'
$arch = get_config 'default_architecture'
$system = if ([Environment]::Is64BitOperatingSystem) { '64bit' } else { '32bit' }
if ($null -eq $arch) {
$arch = $system
Expand Down
15 changes: 10 additions & 5 deletions libexec/scoop-cat.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Usage: scoop cat <app>
# Summary: Show content of specified manifest.
# Summary: Show content of specified manifest. If available, `bat` will be used to pretty-print the JSON.

param($app)

. "$psscriptroot\..\lib\manifest.ps1"
. "$psscriptroot\..\lib\install.ps1"
. "$psscriptroot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\help.ps1"

reset_aliases

Expand All @@ -15,7 +15,12 @@ $app, $bucket, $null = parse_app $app
$app, $manifest, $bucket, $url = Find-Manifest $app $bucket

if ($manifest) {
$manifest | ConvertToPrettyJson | Write-Host
$style = get_config cat_style
if ($style) {
$manifest | ConvertToPrettyJson | bat --no-paging --style $style --language json
} else {
$manifest | ConvertToPrettyJson
}
} else {
abort "Couldn't find manifest for '$app'$(if($url) { " at the URL $url" })."
}
Expand Down
10 changes: 8 additions & 2 deletions libexec/scoop-config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
# * An empty or unset value for proxy is equivalent to 'default' (with no username or password)
# * To bypass the system proxy and connect directly, use 'none' (with no username or password)
#
# default-architecture: 64bit|32bit
# default_architecture: 64bit|32bit
# Allow to configure preferred architecture for application installation.
# If not specified, architecture is determined be system.
#
# debug: $true|$false
# Additional and detailed output will be shown.
#
# force-update: $true|$false
# force_update: $true|$false
# Force apps updating to bucket's version.
#
# show_update_log: $true|$false
Expand Down Expand Up @@ -81,6 +81,12 @@
# API key used for uploading/scanning files using virustotal.
# See: 'https://support.virustotal.com/hc/en-us/articles/115002088769-Please-give-me-an-API-key'
#
# cat_style:
# When set to a non-empty string, Scoop will use 'bat' to display the manifest for
# the `scoop cat` command and while doing manifest review. This requires 'bat' to be
# installed (run `scoop install bat` to install it), otherwise errors will be thrown.
# The accepted values are the same as ones passed to the --style flag of 'bat'.
#
# ignore_running_processes: $true|$false
# When set to $false (default), Scoop would stop its procedure immediately if it detects
# any target app process is running. Procedure here refers to reset/uninstall/update.
Expand Down
89 changes: 42 additions & 47 deletions libexec/scoop-info.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
# Summary: Display information about an app
param($app)

. "$psscriptroot\..\lib\buckets.ps1"
. "$psscriptroot\..\lib\core.ps1"
. "$psscriptroot\..\lib\depends.ps1"
. "$psscriptroot\..\lib\help.ps1"
. "$psscriptroot\..\lib\install.ps1"
. "$psscriptroot\..\lib\manifest.ps1"
. "$psscriptroot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\depends.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"

reset_aliases

if(!$app) { my_usage; exit 1 }
if (!$app) { my_usage; exit 1 }

if ($app -match '^(ht|f)tps?://|\\\\') {
# check if $app is a URL or UNC path
Expand Down Expand Up @@ -45,24 +43,24 @@ $dir = currentdir $app $global
$original_dir = versiondir $app $manifest.version $global
$persist_dir = persistdir $app $global

if($status.installed) {
if ($status.installed) {
$manifest_file = manifest_path $app $install.bucket
if ($install.url) {
$manifest_file = $install.url
}
if($status.version -eq $manifest.version) {
if ($status.version -eq $manifest.version) {
$version_output = $status.version
} else {
$version_output = "$($status.version) (Update to $($manifest.version) available)"
}
}

Write-Output "Name: $app"
$item = [ordered]@{ Name = $app }
if ($manifest.description) {
Write-Output "Description: $($manifest.description)"
$item.Description = $manifest.description
}
Write-Output "Version: $version_output"
Write-Output "Website: $($manifest.homepage)"
$item.Version = $version_output
$item.Website = $manifest.homepage
# Show license
if ($manifest.license) {
$license = $manifest.license
Expand All @@ -76,66 +74,63 @@ if ($manifest.license) {
} else {
$license = "$($manifest.license) (https://spdx.org/licenses/$($manifest.license).html)"
}
Write-Output "License: $license"
$item.License = $license
}

# Manifest file
Write-Output "Manifest:`n $manifest_file"
$item.Manifest = $manifest_file

if($status.installed) {
if ($status.installed) {
# Show installed versions
Write-Output "Installed:"
$versions = Get-InstalledVersion -AppName $app -Global:$global
$versions | ForEach-Object {
$dir = versiondir $app $_ $global
if($global) { $dir += " *global*" }
Write-Output " $dir"
$installed_output = @()
Get-InstalledVersion -AppName $app -Global:$global | ForEach-Object {
$installed_output += versiondir $app $_ $global
}
} else {
Write-Output "Installed: No"
$item.Installed = $installed_output -join "`n"
}

$binaries = @(arch_specific 'bin' $manifest $install.architecture)
if($binaries) {
$binary_output = "Binaries:`n "
if ($binaries) {
$binary_output = @()
$binaries | ForEach-Object {
if($_ -is [System.Array]) {
$binary_output += " $($_[1]).exe"
if ($_ -is [System.Array]) {
$binary_output += "$($_[1]).exe"
} else {
$binary_output += " $_"
$binary_output += $_
}
}
Write-Output $binary_output
$item.Binaries = $binary_output -join " | "
}
$env_set = (arch_specific 'env_set' $manifest $install.architecture)
$env_add_path = (arch_specific 'env_add_path' $manifest $install.architecture)
if($env_set -or $env_add_path) {
if($status.installed) {
Write-Output "Environment:"
} else {
Write-Output "Environment: (simulated)"
}
}
if($env_set) {
if ($env_set) {
$env_vars = @()
$env_set | Get-Member -member noteproperty | ForEach-Object {
$value = env $_.name $global
if(!$value) {
if (!$value) {
$value = format $env_set.$($_.name) @{ "dir" = $dir }
}
Write-Output " $($_.name)=$value"
$env_vars += "$($_.name) = $value"
}
$item.'Environment Variables' = $env_vars -join "`n"
}
if($env_add_path) {
if ($env_add_path) {
$env_path = @()
$env_add_path | Where-Object { $_ } | ForEach-Object {
if($_ -eq '.') {
Write-Output " PATH=%PATH%;$dir"
if ($_ -eq '.') {
$env_path += $dir
} else {
Write-Output " PATH=%PATH%;$dir\$_"
$env_path += "$dir\$_"
}
}
$item.'Path Added' = $env_path -join "`n"
}

if ($manifest.notes) {
# Show notes
$item.Notes = (substitute $manifest.notes @{ '$dir' = $dir; '$original_dir' = $original_dir; '$persist_dir' = $persist_dir}) -join "`n"
}

# Show notes
show_notes $manifest $dir $original_dir $persist_dir
[PSCustomObject]$item

exit 0

0 comments on commit 00de264

Please sign in to comment.