Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scoop-shim): Add scoop shim to manipulate shims #4736

Merged
merged 20 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@

- **config:** Allow Scoop to ignore running processes during reset/uninstall/update ([#4713](https://github.com/ScoopInstaller/Scoop/issues/4713), [#4731](https://github.com/ScoopInstaller/Scoop/issues/4731))
- **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-bucket:** List more detailed information for buckets ([#4704](https://github.com/ScoopInstaller/Scoop/pull/4704))
- **scoop-list:** Allow list manipulation ([#4718](https://github.com/ScoopInstaller/Scoop/issues/4718))
- **scoop-list:** Show last-updated time [#4723](https://github.com/ScoopInstaller/Scoop/issues/4723))
- **scoop-cache:** Handle multiple apps and show detailed information ([#4738](https://github.com/ScoopInstaller/Scoop/pull/4738))
- **scoop-cat:** Use `bat` to pretty-print JSON ([#4742](https://github.com/ScoopInstaller/Scoop/pull/4742))
- **scoop-info:** Revamp details and show more information ([#4747](https://github.com/ScoopInstaller/Scoop/pull/4747))
- **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-info:** Revamp details and show more information ([#4747](https://github.com/ScoopInstaller/Scoop/issues/4747))
- **scoop-shim:** Add `scoop shim` to manipulate shims and move `scoop alter` to `scoop shim alter` [#4736](https://github.com/ScoopInstaller/Scoop/issues/4736))

### Bug Fixes

Expand Down
1 change: 0 additions & 1 deletion bin/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ Copy-Item "$dir\_tmp\*-master\*" $dir -Recurse -Force
Remove-Item "$dir\_tmp", $zipfile -Recurse -Force

ensure_robocopy_in_path
ensure_scoop_in_path

scoop config lastupdate ([System.DateTime]::Now.ToString('o'))
success 'Scoop was installed successfully!'
Expand Down
1 change: 0 additions & 1 deletion bin/refresh.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ $output | Where-Object { $_ -ne "" }
Write-Output 'creating shim...'
shim "$dest\bin\scoop.ps1" $false

ensure_scoop_in_path
success 'scoop was refreshed!'
13 changes: 4 additions & 9 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -594,18 +594,19 @@ function warn_on_overwrite($shim, $path) {
return
} else {
if (Test-Path -Path "$shim.$path_app" -PathType Leaf) {
Remove-Item -Path "$shim.$path_app" -Force
Remove-Item -Path "$shim.$path_app" -Force -ErrorAction SilentlyContinue
}
Rename-Item -Path $shim -NewName "$shim.$shim_app"
Rename-Item -Path $shim -NewName "$shim.$shim_app" -ErrorAction SilentlyContinue
}
$shimname = (fname $shim) -replace '\.shim$', '.exe'
$filename = (fname $path) -replace '\.shim$', '.exe'
warn "Overwriting shim ('$shimname' -> '$filename') installed from $shim_app"
warn "Overwriting shim ('$shimname' -> '$filename')$(if ($shim_app) { ' installed from ' + $shim_app })"
}

function shim($path, $global, $name, $arg) {
if (!(Test-Path $path)) { abort "Can't shim '$(fname $path)': couldn't find '$path'." }
$abs_shimdir = ensure (shimdir $global)
ensure_in_path $abs_shimdir $global
if (!$name) { $name = strip_ext (fname $path) }

$shim = "$abs_shimdir\$($name.tolower())"
Expand Down Expand Up @@ -855,12 +856,6 @@ function remove_from_path($dir, $global) {
if($was_in_path) { $env:PATH = $newpath }
}

function ensure_scoop_in_path($global) {
$abs_shimdir = ensure (shimdir $global)
# be aggressive (b-e-aggressive) and install scoop first in the path
ensure_in_path $abs_shimdir $global
}

function ensure_robocopy_in_path {
if(!(Test-CommandAvailable robocopy)) {
shim "C:\Windows\System32\Robocopy.exe" $false
Expand Down
1 change: 0 additions & 1 deletion lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru
create_shims $manifest $dir $global $architecture
create_startmenu_shortcuts $manifest $dir $global $architecture
install_psmodule $manifest $dir $global
if($global) { ensure_scoop_in_path $global } # can assume local scoop is in path
env_add_path $manifest $dir $global $architecture
env_set $manifest $dir $global $architecture

Expand Down
60 changes: 0 additions & 60 deletions libexec/scoop-alter.ps1

This file was deleted.

24 changes: 12 additions & 12 deletions libexec/scoop-list.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ param($query)

reset_aliases
$def_arch = default_architecture
if (-not (Get-FormatData ScoopAppsList)) {
Update-FormatData "$PSScriptRoot\..\supporting\formats\ScoopAppsList.Format.ps1xml"
if (-not (Get-FormatData ScoopApps)) {
Update-FormatData "$PSScriptRoot\..\supporting\formats\ScoopTypes.Format.ps1xml"
}

$local = installed_apps $false | ForEach-Object { @{ name = $_ } }
Expand All @@ -28,38 +28,38 @@ Write-Host "Installed apps$(if($query) { `" matching '$query'`"}):"
$apps | Where-Object { !$query -or ($_.name -match $query) } | ForEach-Object {
$app = $_.name
$global = $_.global
$item = @{ PSTypeName = 'ScoopAppsList' }
$item = @{}
$ver = Select-CurrentVersion -AppName $app -Global:$global
$item.Name = $app
$item.Version = $ver

$install_info_path = "$(versiondir $app $ver $global)\install.json"
$updated = (Get-Item (appdir $app $global)).LastWriteTime | Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
$updated = (Get-Item (appdir $app $global)).LastWriteTime
$install_info = $null
if(Test-Path $install_info_path) {
if (Test-Path $install_info_path) {
$install_info = parse_json $install_info_path
$updated = (Get-Item $install_info_path).LastWriteTime | Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
$updated = (Get-Item $install_info_path).LastWriteTime
}

$item.Source = if ($install_info.bucket) {
$install_info.bucket
} elseif ($install_info.url) {
if ($install_info.url -eq (usermanifest $app)) { "<auto-generated>" }
if ($install_info.url -eq (usermanifest $app)) { '<auto-generated>' }
else { $install_info.url }
}
$item.Updated = $updated

$info = @()
if($global) { $info += "Global install" }
if (failed $app $global) { $info += "Install failed" }
if ($install_info.hold) { $info += "Held package" }
if ($global) { $info += 'Global install' }
if (failed $app $global) { $info += 'Install failed' }
if ($install_info.hold) { $info += 'Held package' }
if ($install_info.architecture -and $def_arch -ne $install_info.architecture) {
$info += $install_info.architecture
}
$item.Info = $info -join ', '

$list += $item
$list += [PSCustomObject]$item
}

$list.ForEach({[PSCustomObject]$_})
$list | Add-Member -TypeName 'ScoopApps' -PassThru
rashil2000 marked this conversation as resolved.
Show resolved Hide resolved
exit 0
Loading