Skip to content

Commit

Permalink
Merge branch 'develop' into issaclin32-rar
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven committed Jun 24, 2022
2 parents 3a8c877 + 9811a5f commit cfb2ef3
Show file tree
Hide file tree
Showing 29 changed files with 318 additions and 168 deletions.
28 changes: 25 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,36 @@

### Features

- **chore:** Add missing -a/--all param to all commands ([#5004](https://github.com/ScoopInstaller/Scoop/issues/5004))
- **scoop-status:** Check bucket status, improve output ([#5011](https://github.com/ScoopInstaller/Scoop/issues/5011))
- **scoop-info:** Show app installed/download size ([#4886](https://github.com/ScoopInstaller/Scoop/issues/4886))

### Bug Fixes

- **chore:** Update help documentation ([#5002](https://github.com/ScoopInstaller/Scoop/issues/5002))
- **decompress:** Handle splitted RAR archives ([#4994](https://github.com/ScoopInstaller/Scoop/issues/4994))
- **shortcuts:** Fix network drive shortcut creation ([#4410](https://github.com/ScoopInstaller/Scoop/issues/4410)), ([#5006](https://github.com/ScoopInstaller/Scoop/issues/5006))

### Code Refactoring

- **scoop-search:** Output PSObject, use API token ([#4997](https://github.com/ScoopInstaller/Scoop/issues/4997))

### Tests

- **typo:** Fix typo ('formated' -> 'formatted') ([#4217](https://github.com/ScoopInstaller/Scoop/issues/4217))

## [v0.2.2](https://github.com/ScoopInstaller/Scoop/compare/v0.2.1...v0.2.2) - 2022-06-21

### Features

- **core:** Add `Get-Encoding` function to fix missing webclient encoding ([#4956](https://github.com/ScoopInstaller/Scoop/issues/4956))
- **scoop-virustotal:** Migrate to virustotal api v3, improve flows, and ouput powershell objects ([#4983](https://github.com/ScoopInstaller/Scoop/pull/4983))
- **scoop-hold,scoop-unhold:** Support `-g`/`--global` flag ([#4991](https://github.com/ScoopInstaller/Scoop/issues/4991))
- **scoop-(un)hold:** Add `-g`/`--global` flag ([#4991](https://github.com/ScoopInstaller/Scoop/issues/4991))
- **scoop-update:** Support `scoop update scoop` ([#4992](https://github.com/ScoopInstaller/Scoop/issues/4992))
- **scoop-virustotal:** Migrate to VirusTotal API v3 ([#4983](https://github.com/ScoopInstaller/Scoop/issues/4983))

### Bug Fixes

- **manifest:** Fix bugs in 'Get-Manifest()' ([#4986](https://github.com/ScoopInstaller/Scoop/issues/4986))
- **decompress:** Handle splitted RAR archives ([#4994](https://github.com/ScoopInstaller/Scoop/pull/4994))

## [v0.2.1](https://github.com/ScoopInstaller/Scoop/compare/v0.2.0...v0.2.1) - 2022-06-10

Expand Down
2 changes: 1 addition & 1 deletion bin/scoop.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ switch ($subCommand) {
}
}
default {
"scoop: '$subCommand' isn't a scoop command. See 'scoop help'."
warn "scoop: '$subCommand' isn't a scoop command. See 'scoop help'."
exit 1
}
}
2 changes: 1 addition & 1 deletion lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ function Confirm-InstallationStatus {
$Global
)
$Installed = @()
$Apps | Select-Object -Unique | Where-Object { $_.Name -ne 'scoop' } | ForEach-Object {
$Apps | Select-Object -Unique | Where-Object { $_ -ne 'scoop' } | ForEach-Object {
$App, $null, $null = parse_app $_
if ($Global) {
if (Test-Path (appdir $App $true)) {
Expand Down
8 changes: 6 additions & 2 deletions lib/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ function manifest_path($app, $bucket) {
}

function parse_json($path) {
if(!(test-path $path)) { return $null }
Get-Content $path -raw -Encoding UTF8 | convertfrom-json -ea stop
if (!(Test-Path $path)) { return $null }
try {
Get-Content $path -Raw -Encoding UTF8 | ConvertFrom-Json -ErrorAction Stop
} catch {
warn "Error parsing manifest at $path."
}
}

function url_manifest($url) {
Expand Down
22 changes: 5 additions & 17 deletions lib/shortcuts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ function create_startmenu_shortcuts($manifest, $dir, $global, $arch) {
}

function shortcut_folder($global) {
$directory = [System.IO.Path]::Combine([Environment]::GetFolderPath('startmenu'), 'Programs', 'Scoop Apps')
if($global) {
$directory = [System.IO.Path]::Combine([Environment]::GetFolderPath('commonstartmenu'), 'Programs', 'Scoop Apps')
if ($global) {
$startmenu = 'CommonStartMenu'
} else {
$startmenu = 'StartMenu'
}
return $(ensure $directory)
return Convert-Path (ensure ([System.IO.Path]::Combine([Environment]::GetFolderPath($startmenu), 'Programs', 'Scoop Apps')))
}

function startmenu_shortcut([System.IO.FileInfo] $target, $shortcutName, $arguments, [System.IO.FileInfo]$icon, $global) {
Expand Down Expand Up @@ -67,18 +68,5 @@ function rm_startmenu_shortcuts($manifest, $global, $arch) {
if(Test-Path -Path $shortcut) {
Remove-Item $shortcut
}
# Before issue 1514 Startmenu shortcut removal
#
# Shortcuts that should have been installed globally would
# have been installed locally up until 27 June 2017.
#
# TODO: Remove this 'if' block and comment after
# 27 June 2018.
if($global) {
$shortcut = "$(shortcut_folder $false)\$name.lnk"
if(Test-Path -Path $shortcut) {
Remove-Item $shortcut
}
}
}
}
8 changes: 4 additions & 4 deletions libexec/scoop-alias.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ function add_alias($name, $command) {
# generate script
$shimdir = shimdir $false
$script =
@"
# Summary: $description
$command
"@
@(
"# Summary: $description",
"$command"
) -join "`r`n"
$script | Out-UTF8File "$shimdir\$alias_file.ps1"

# add alias to config
Expand Down
4 changes: 3 additions & 1 deletion libexec/scoop-cache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#
# To clear everything in your cache, use:
# scoop cache rm *
# You can also use the `-a/--all` switch in place of `*` here

param($cmd)

function cacheinfo($file) {
Expand All @@ -36,7 +38,7 @@ function cacheremove($app) {
'ERROR: <app(s)> missing'
my_usage
exit 1
} elseif ($app -eq '*') {
} elseif ($app -eq '*' -or $app -eq '-a' -or $app -eq '--all') {
$files = @(Get-ChildItem $cachedir)
} else {
$app = '(' + ($app -join '|') + ')'
Expand Down
11 changes: 7 additions & 4 deletions libexec/scoop-depends.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Usage: scoop depends <app>
# Summary: List dependencies for an app
# Summary: List dependencies for an app, in the order they'll be installed

. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\depends.ps1" # 'Get-Dependency'
Expand All @@ -17,9 +17,12 @@ try {
abort "ERROR: $_"
}

$deps = @(Get-Dependency $app $architecture) -ne $app
if($deps) {
$deps[($deps.length - 1)..0]
$deps = @()
Get-Dependency $app $architecture | ForEach-Object {
$dep = [ordered]@{}
$dep.Source, $dep.Name = $_ -split '/'
$deps += [PSCustomObject]$dep
}
$deps

exit 0
4 changes: 4 additions & 0 deletions libexec/scoop-download.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# Help: e.g. The usual way to download an app, without installing it (uses your local 'buckets'):
# scoop download git
#
# To download a different version of the app
# (note that this will auto-generate the manifest using current version):
# scoop download gh@2.7.0
#
# To download an app from a manifest at a URL:
# scoop download https://raw.githubusercontent.com/ScoopInstaller/Main/master/bucket/runat.json
#
Expand Down
29 changes: 15 additions & 14 deletions libexec/scoop-help.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,42 @@
param($cmd)

function print_help($cmd) {
$file = Get-Content (command_path $cmd) -raw
$file = Get-Content (command_path $cmd) -Raw

$usage = usage $file
$summary = summary $file
$help = scoop_help $file

if($usage) { "$usage`n" }
if($help) { $help }
if ($usage) { "$usage`n" }
if ($help) { $help }
}

function print_summaries {
$commands = @{}
$commands = @()

command_files | ForEach-Object {
$command = command_name $_
$summary = summary (Get-Content (command_path $command) -raw)
if(!($summary)) { $summary = '' }
$commands.add("$command ", $summary) # add padding
$command = [ordered]@{}
$command.Command = command_name $_
$command.Summary = summary (Get-Content (command_path $command.Command))
$commands += [PSCustomObject]$command
}

$commands.getenumerator() | Sort-Object name | Format-Table -hidetablehead -autosize -wrap
$commands
}

$commands = commands

if(!($cmd)) {
"Usage: scoop <command> [<args>]
Write-Host "Usage: scoop <command> [<args>]
Some useful commands are:"
Available commands are listed below.
Type 'scoop help <command>' to get more help for a specific command."
print_summaries
"Type 'scoop help <command>' to get help for a specific command."
} elseif($commands -contains $cmd) {
print_help $cmd
} else {
"scoop help: no such command '$cmd'"; exit 1
warn "scoop help: no such command '$cmd'"
exit 1
}

exit 0
79 changes: 79 additions & 0 deletions libexec/scoop-info.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,85 @@ if ($status.installed) {
$installed_output += if ($verbose) { versiondir $app $_ $global } else { "$_$(if ($global) { " *global*" })" }
}
$item.Installed = $installed_output -join "`n"

if ($verbose) {
# Show size of installation
$appsdir = appsdir $global

# Collect file list from each location
$appFiles = Get-ChildItem $appsdir -Filter $app
$currentFiles = Get-ChildItem $appFiles -Filter (Select-CurrentVersion $app $global)
$persistFiles = Get-ChildItem $persist_dir -ErrorAction Ignore # Will fail if app does not persist data
$cacheFiles = Get-ChildItem $cachedir -Filter "$app#*"

# Get the sum of each file list
$fileTotals = @()
foreach ($fileType in ($appFiles, $currentFiles, $persistFiles, $cacheFiles)) {
if ($null -ne $fileType) {
$fileSum = (Get-ChildItem $fileType -Recurse | Measure-Object -Property Length -Sum).Sum
$fileTotals += coalesce $fileSum 0
} else {
$fileTotals += 0
}
}

# Old versions = app total - current version size
$fileTotals += $fileTotals[0] - $fileTotals[1]

if ($fileTotals[2] + $fileTotals[3] + $fileTotals[4] -eq 0) {
# Simple app size output if no old versions, persisted data, cached downloads
$item.'Installed size' = filesize $fileTotals[1]
} else {
$fileSizes = [ordered] @{
'Current version: ' = $fileTotals[1]
'Old versions: ' = $fileTotals[4]
'Persisted data: ' = $fileTotals[2]
'Cached downloads: ' = $fileTotals[3]
'Total: ' = $fileTotals[0] + $fileTotals[2] + $fileTotals[3]
}

$fileSizeOutput = @()

# Don't output empty categories
$fileSizes.GetEnumerator() | ForEach-Object {
if ($_.Value -ne 0) {
$fileSizeOutput += $_.Key + (filesize $_.Value)
}
}

$item.'Installed size' = $fileSizeOutput -join "`n"
}
}
} else {
if ($verbose) {
# Get download size if app not installed
$totalPackage = 0
foreach ($url in @(url $manifest (default_architecture))) {
try {
if (Test-Path (fullpath (cache_path $app $manifest.version $url))) {
$cached = " (latest version is cached)"
} else {
$cached = $null
}

[int]$urlLength = (Invoke-WebRequest $url -Method Head).Headers.'Content-Length'[0]
$totalPackage += $urlLength
} catch [System.Management.Automation.RuntimeException] {
$totalPackage = 0
$packageError = "the server at $(([System.Uri]$url).Host) did not send a Content-Length header"
break
} catch {
$totalPackage = 0
$packageError = "the server at $(([System.Uri]$url).Host) is down"
break
}
}
if ($totalPackage -ne 0) {
$item.'Download size' = "$(filesize $totalPackage)$cached"
} else {
$item.'Download size' = "Unknown ($packageError)$cached"
}
}
}

$binaries = @(arch_specific 'bin' $manifest $install.architecture)
Expand Down
4 changes: 4 additions & 0 deletions libexec/scoop-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# Help: e.g. The usual way to install an app (uses your local 'buckets'):
# scoop install git
#
# To install a different version of the app
# (note that this will auto-generate the manifest using current version):
# scoop install gh@2.7.0
#
# To install an app from a manifest at a URL:
# scoop install https://raw.githubusercontent.com/ScoopInstaller/Main/master/bucket/runat.json
#
Expand Down
9 changes: 6 additions & 3 deletions libexec/scoop-reset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
# Help: Used to resolve conflicts in favor of a particular app. For example,
# if you've installed 'python' and 'python27', you can use 'scoop reset' to switch between
# using one or the other.
#
# You can use '*' in place of <app> or `-a`/`--all` switch to reset all apps.

. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Select-CurrentVersion' (indirectly)
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
. "$PSScriptRoot\..\lib\shortcuts.ps1"

$opt, $apps, $err = getopt $args
$opt, $apps, $err = getopt $args 'a' 'all'
if($err) { "scoop reset: $err"; exit 1 }
$all = $opt.a -or $opt.all

if(!$apps) { error '<app> missing'; my_usage; exit 1 }
if(!$apps -and !$all) { error '<app> missing'; my_usage; exit 1 }

if($apps -eq '*') {
if($apps -eq '*' -or $all) {
$local = installed_apps $false | ForEach-Object { ,@($_, $false) }
$global = installed_apps $true | ForEach-Object { ,@($_, $true) }
$apps = @($local) + @($global)
Expand Down
Loading

0 comments on commit cfb2ef3

Please sign in to comment.