perf(scoop): Load libs only once (#4839)

This commit is contained in:
Hsiao-nan Cheung
2022-04-21 21:34:26 +08:00
committed by GitHub
parent 7ee74a0638
commit 6296822f1f
42 changed files with 146 additions and 187 deletions

View File

@@ -15,6 +15,10 @@
- **scoop-download:** Add failure check ([#4822](https://github.com/ScoopInstaller/Scoop/pull/4822))
- **install:** Fix issue with installation inside containers ([#4837](https://github.com/ScoopInstaller/Scoop/pull/4837))
### Performance Improvements
- **scoop:** Load libs only once ([#4839](https://github.com/ScoopInstaller/Scoop/issues/4839))
### Code Refactoring
- **bucket:** Move 'Find-Manifest' and 'list_buckets' to 'buckets' ([#4814](https://github.com/ScoopInstaller/Scoop/issues/4814))

View File

@@ -69,9 +69,9 @@ param(
)
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\autoupdate.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\autoupdate.ps1"
. "$PSScriptRoot\..\lib\json.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\install.ps1" # needed for hash generation
@@ -105,7 +105,7 @@ Get-Event | ForEach-Object {
$Queue | ForEach-Object {
$name, $json = $_
$substitutions = Get-VersionSubstitution $json.version
$substitutions = Get-VersionSubstitution $json.version # 'autoupdate.ps1'
$wc = New-Object Net.Webclient
if ($json.checkver.useragent) {
@@ -337,7 +337,7 @@ while ($in_progress -gt 0) {
Write-Host 'Forcing autoupdate!' -ForegroundColor DarkMagenta
}
try {
Invoke-AutoUpdate $App $Dir $json $ver $matchesHashtable
Invoke-AutoUpdate $App $Dir $json $ver $matchesHashtable # 'autoupdate.ps1'
} catch {
if ($ThrowError) {
throw $_

View File

@@ -1,32 +1,56 @@
#Requires -Version 5
param($cmd)
param($SubCommand)
Set-StrictMode -off
Set-StrictMode -Off
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\commands.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
# for aliases where there's a local function, re-alias so the function takes precedence
$aliases = Get-Alias | Where-Object { $_.Options -notmatch 'ReadOnly|AllScope' } | ForEach-Object { $_.Name }
Get-ChildItem Function: | Where-Object -Property Name -In -Value $aliases | ForEach-Object {
Set-Alias -Name $_.Name -Value Local:$($_.Name) -Scope Script
}
$commands = commands
if ('--version' -contains $cmd -or (!$cmd -and '-v' -contains $args)) {
Write-Host "Current Scoop version:"
Invoke-Expression "git -C '$(versiondir 'scoop' 'current')' --no-pager log --oneline HEAD -n 1"
Write-Host ""
switch ($SubCommand) {
({ $SubCommand -in @($null, '--help', '/?') }) {
if (!$SubCommand -and $Args -eq '-v') {
$SubCommand = '--version'
} else {
exec 'help'
}
}
({ $SubCommand -eq '--version' }) {
Write-Host 'Current Scoop version:'
if ((Test-CommandAvailable git) -and (Test-Path "$PSScriptRoot\..\.git") -and (get_config SCOOP_BRANCH 'master') -ne 'master') {
Invoke-Expression "git -C '$PSScriptRoot\..' --no-pager log --oneline HEAD -n 1"
} else {
$version = Select-String -Pattern '^## \[(v[\d.]+)\].*?([\d-]+)$' -Path "$PSScriptRoot\..\CHANGELOG.md"
Write-Host $version.Matches.Groups[1].Value -ForegroundColor Cyan -NoNewline
Write-Host " - Released at $($version.Matches.Groups[2].Value)"
}
Write-Host ''
Get-LocalBucket | ForEach-Object {
$bucketLoc = Find-BucketDirectory $_ -Root
if(Test-Path (Join-Path $bucketLoc '.git')) {
if ((Test-Path (Join-Path $bucketLoc '.git')) -and (Test-CommandAvailable git)) {
Write-Host "'$_' bucket:"
Invoke-Expression "git -C '$bucketLoc' --no-pager log --oneline HEAD -n 1"
Write-Host ""
Write-Host ''
}
}
}
elseif (@($null, '--help', '/?') -contains $cmd -or $args[0] -contains '-h') { exec 'help' $args }
elseif ($commands -contains $cmd) { exec $cmd $args }
else { "scoop: '$cmd' isn't a scoop command. See 'scoop help'."; exit 1 }
({ $SubCommand -in (commands) }) {
if ($Args -in @('-h', '--help', '/?')) {
exec 'help' @($SubCommand)
} else {
exec $SubCommand $Args
}
}
default {
"scoop: '$SubCommand' isn't a scoop command. See 'scoop help'."
exit 1
}
}

View File

@@ -1,10 +1,4 @@
<#
TODO
- clean up
#>
. "$PSScriptRoot\core.ps1"
. "$PSScriptRoot\json.ps1"
# Must included with 'json.ps1'
function find_hash_in_rdf([String] $url, [String] $basename) {
$data = $null
try {

View File

@@ -1,5 +1,3 @@
. "$PSScriptRoot\core.ps1"
$bucketsdir = "$scoopdir\buckets"
function Find-BucketDirectory {

View File

@@ -918,7 +918,7 @@ function show_app($app, $bucket, $version) {
function last_scoop_update() {
# PowerShell 6 returns an DateTime Object
$last_update = (scoop config lastupdate)
$last_update = (get_config lastupdate)
if ($null -ne $last_update -and $last_update.GetType() -eq [System.String]) {
try {
@@ -934,7 +934,7 @@ function is_scoop_outdated() {
$last_update = $(last_scoop_update)
$now = [System.DateTime]::Now
if($null -eq $last_update) {
scoop config lastupdate $now.ToString('o')
set_config lastupdate $now.ToString('o')
# enforce an update for the first time
return $true
}

View File

@@ -3,8 +3,6 @@ Diagnostic tests.
Return $true if the test passed, otherwise $false.
Use 'warn' to highlight the issue, and follow up with the recommended actions to rectify.
#>
. "$PSScriptRoot\buckets.ps1"
function check_windows_defender($global) {
$defender = Get-Service -Name WinDefend -ErrorAction SilentlyContinue
if (Test-CommandAvailable Get-MpPreference) {
@@ -55,4 +53,3 @@ function check_long_paths {
return $true
}

View File

@@ -1,7 +1,3 @@
. "$PSScriptRoot\core.ps1"
. "$PSScriptRoot\autoupdate.ps1"
. "$PSScriptRoot\buckets.ps1"
function nightly_version($date, $quiet = $false) {
$date_str = $date.tostring("yyyyMMdd")
if (!$quiet) {

View File

@@ -1,6 +1,3 @@
. "$PSScriptRoot\core.ps1"
. "$PSScriptRoot\autoupdate.ps1"
function manifest_path($app, $bucket) {
fullpath "$(Find-BucketDirectory $bucket)\$(sanitary_path $app).json"
}
@@ -88,7 +85,7 @@ function supports_architecture($manifest, $architecture) {
return -not [String]::IsNullOrEmpty((arch_specific 'url' $manifest $architecture))
}
function generate_user_manifest($app, $bucket, $version) {
function generate_user_manifest($app, $bucket, $version) { # 'autoupdate.ps1' 'buckets.ps1' 'manifest.ps1'
$null, $manifest, $bucket, $null = Find-Manifest $app $bucket
if ("$($manifest.version)" -eq "$version") {
return manifest_path $app $bucket

View File

@@ -1,4 +1,3 @@
# versions
function Get-LatestVersion {
<#
.SYNOPSIS
@@ -29,7 +28,7 @@ function Get-LatestVersion {
}
}
function Select-CurrentVersion {
function Select-CurrentVersion { # 'manifest.ps1'
<#
.SYNOPSIS
Select current version of installed app, from 'current\manifest.json' or modified time of version directory

View File

@@ -23,9 +23,7 @@ param(
[Switch]$verbose = $false
)
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\install.ps1" # shim related
$script:config_alias = 'alias'

View File

@@ -19,10 +19,6 @@
# scoop bucket known
param($cmd, $name, $repo)
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
$usage_add = 'usage: scoop bucket add <name> [<repo>]'
$usage_rm = 'usage: scoop bucket rm <name>'

View File

@@ -12,8 +12,6 @@
# scoop cache rm *
param($cmd)
. "$PSScriptRoot\..\lib\help.ps1"
function cacheinfo($file) {
$app, $version, $url = $file.Name -split '#'
New-Object PSObject -Property @{ Name = $app; Version = $version; Length = $file.Length; URL = $url }

View File

@@ -3,9 +3,8 @@
param($app)
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\json.ps1" # 'ConvertToPrettyJson'
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Find-Manifest' (indirectly)
if (!$app) { error '<app> missing'; my_usage; exit 1 }

View File

@@ -3,7 +3,6 @@
# Help: Performs a series of diagnostic tests to try to identify things that may
# cause problems with Scoop.
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\diagnostic.ps1"
$issues = 0

View File

@@ -9,13 +9,10 @@
# -g, --global Cleanup a globally installed app
# -k, --cache Remove outdated download cache
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Select-CurrentVersion' (indirectly)
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
. "$PSScriptRoot\..\lib\install.ps1" # persist related
$opt, $apps, $err = getopt $args 'gk' 'global', 'cache'
if ($err) { "scoop cleanup: $err"; exit 1 }

View File

@@ -132,9 +132,6 @@
param($name, $value)
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
if (!$name) {
$scoopConfig
} elseif ($name -like '--help') {

View File

@@ -1,13 +1,9 @@
# Usage: scoop depends <app>
# Summary: List dependencies for an app
. "$PSScriptRoot\..\lib\depends.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\decompress.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\depends.ps1" # 'Get-Dependency'
. "$PSScriptRoot\..\lib\manifest.ps1" # 'default_architecture'
$opt, $apps, $err = getopt $args 'a:' 'arch='
$app = $apps[0]

View File

@@ -15,10 +15,11 @@
# -u, --no-update-scoop Don't update Scoop before downloading if it's outdated
# -a, --arch <32bit|64bit> Use the specified architecture, if the app supports it
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\json.ps1" # 'autoupdate.ps1' (indirectly)
. "$PSScriptRoot\..\lib\autoupdate.ps1" # 'generate_user_manifest' (indirectly)
. "$PSScriptRoot\..\lib\manifest.ps1" # 'default_architecture' 'generate_user_manifest' 'Find-Manifest' (indirectly)
. "$PSScriptRoot\..\lib\install.ps1"
$opt, $apps, $err = getopt $args 'fhua:' 'force', 'no-hash-check', 'no-update-scoop', 'arch='
if ($err) { error "scoop download: $err"; exit 1 }

View File

@@ -2,10 +2,8 @@
# Summary: Exports (an importable) list of installed apps
# Help: Lists all installed apps.
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
. "$PSScriptRoot\..\lib\manifest.ps1" # 'default_architecture' 'Select-CurrentVersion' (indirectly)
$def_arch = default_architecture

View File

@@ -2,10 +2,6 @@
# Summary: Show help for a command
param($cmd)
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\commands.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
function print_help($cmd) {
$file = Get-Content (command_path $cmd) -raw

View File

@@ -1,9 +1,8 @@
# Usage: scoop hold <apps>
# Summary: Hold an app to disable updates
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'install_info' 'Select-CurrentVersion' (indirectly)
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
$apps = $args

View File

@@ -2,10 +2,7 @@
# Summary: Opens the app homepage
param($app)
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Find-Manifest' (indirectly)
if ($app) {
$null, $manifest, $bucket, $null = Find-Manifest $app

View File

@@ -3,11 +3,9 @@
# Options:
# -v, --verbose Show full paths and URLs
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Find-Manifest' (indirectly)
. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-InstalledVersion'
$opt, $app, $err = getopt $args 'v' 'verbose'
if ($err) { error "scoop info: $err"; exit 1 }

View File

@@ -17,16 +17,15 @@
# -s, --skip Skip hash validation (use with caution!)
# -a, --arch <32bit|64bit> Use the specified architecture, if the app supports it
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\decompress.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\json.ps1" # 'autoupdate.ps1' (indirectly)
. "$PSScriptRoot\..\lib\autoupdate.ps1" # 'generate_user_manifest' (indirectly)
. "$PSScriptRoot\..\lib\manifest.ps1" # 'default_architecture' 'generate_user_manifest' 'Select-CurrentVersion' (indirectly)
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\decompress.ps1"
. "$PSScriptRoot\..\lib\shortcuts.ps1"
. "$PSScriptRoot\..\lib\psmodules.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\depends.ps1"
$opt, $apps, $err = getopt $args 'gikusa:' 'global', 'independent', 'no-cache', 'no-update-scoop', 'skip', 'arch='

View File

@@ -3,10 +3,8 @@
# Help: Lists all installed apps, or the apps matching the supplied query.
param($query)
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
. "$PSScriptRoot\..\lib\manifest.ps1" # 'parse_json' 'Select-CurrentVersion' (indirectly)
$def_arch = default_architecture
if (-not (Get-FormatData ScoopApps)) {

View File

@@ -2,15 +2,13 @@
# Summary: Returns the path to the specified app
param($app)
. "$PSScriptRoot\..\lib\versions.ps1" # 'currentdir' (indirectly)
if (!$app) {
. "$PSScriptRoot\..\lib\help.ps1"
my_usage
exit 1
}
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
$app_path = currentdir $app $false
if (!(Test-Path $app_path)) {
$app_path = currentdir $app $true

View File

@@ -4,12 +4,10 @@
# if you've installed 'python' and 'python27', you can use 'scoop reset' to switch between
# using one or the other.
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Select-CurrentVersion' (indirectly)
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
. "$PSScriptRoot\..\lib\shortcuts.ps1"
$opt, $apps, $err = getopt $args

View File

@@ -5,10 +5,9 @@
# If used with [query], shows app names that match the query.
# Without [query], shows all the available apps.
param($query)
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'manifest'
. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-LatestVersion'
function bin_match($manifest, $query) {
if(!$manifest.bin) { return $false }

View File

@@ -29,7 +29,6 @@
param($SubCommand, $ShimName, [Switch]$global)
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\install.ps1" # for rm_shim
if ($SubCommand -notin @('add', 'rm', 'list', 'info', 'alter')) {

View File

@@ -1,11 +1,8 @@
# Usage: scoop status
# Summary: Show status and check for new app versions
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\depends.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'manifest' 'parse_json' "install_info"
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
# check if scoop needs updating
$currentdir = fullpath $(versiondir 'scoop' 'current')
@@ -13,17 +10,15 @@ $needs_update = $false
if (Test-Path "$currentdir\.git") {
git_cmd -C "`"$currentdir`"" fetch -q origin
$commits = $(git -C $currentdir log "HEAD..origin/$(scoop config SCOOP_BRANCH)" --oneline)
$commits = $(git -C $currentdir log "HEAD..origin/$(get_config SCOOP_BRANCH)" --oneline)
if ($commits) { $needs_update = $true }
}
else {
} else {
$needs_update = $true
}
if ($needs_update) {
warn "Scoop is out of date. Run 'scoop update' to get the latest changes."
}
else { success "Scoop is up to date."}
} else { success 'Scoop is up to date.' }
$failed = @()
$outdated = @()
@@ -36,7 +31,7 @@ $true, $false | ForEach-Object { # local and global apps
$dir = appsdir $global
if (!(Test-Path $dir)) { return }
Get-ChildItem $dir | Where-Object name -ne 'scoop' | ForEach-Object {
Get-ChildItem $dir | Where-Object name -NE 'scoop' | ForEach-Object {
$app = $_.name
$status = app_status $app $global
if ($status.failed) {
@@ -96,7 +91,7 @@ if($missing_deps) {
}
if (!$old -and !$removed -and !$failed -and !$missing_deps -and !$needs_update) {
success "Everything is ok!"
success 'Everything is ok!'
}
exit 0

View File

@@ -1,9 +1,8 @@
# Usage: scoop unhold <app>
# Summary: Unhold an app to enable updates
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'install_info' 'Select-CurrentVersion' (indirectly)
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
$apps = $args

View File

@@ -6,14 +6,12 @@
# -g, --global Uninstall a globally installed app
# -p, --purge Remove all persistent data
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Select-CurrentVersion' (indirectly)
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\shortcuts.ps1"
. "$PSScriptRoot\..\lib\psmodules.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
# options
$opt, $apps, $err = getopt $args 'gp' 'global', 'purge'

View File

@@ -14,14 +14,12 @@
# -q, --quiet Hide extraneous messages
# -a, --all Update all apps (alternative to '*')
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\shortcuts.ps1"
. "$PSScriptRoot\..\lib\psmodules.ps1"
. "$PSScriptRoot\..\lib\decompress.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\depends.ps1"
. "$PSScriptRoot\..\lib\install.ps1"

View File

@@ -34,15 +34,11 @@
# -n, --no-depends By default, all dependencies are checked too. This flag avoids it.
# -u, --no-update-scoop Don't update Scoop before checking if it's outdated
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\json.ps1"
. "$PSScriptRoot\..\lib\decompress.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\depends.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Find-Manifest' (indirectly)
. "$PSScriptRoot\..\lib\json.ps1" # 'json_path'
. "$PSScriptRoot\..\lib\install.ps1" # 'hash_for_url'
. "$PSScriptRoot\..\lib\depends.ps1" # 'Get-Dependency'
$opt, $apps, $err = getopt $args 'a:snu' @('arch=', 'scan', 'no-depends', 'no-update-scoop')
if ($err) { "scoop virustotal: $err"; exit 1 }
@@ -51,7 +47,7 @@ $architecture = ensure_architecture ($opt.a + $opt.arch)
if (is_scoop_outdated) {
if ($opt.u -or $opt.'no-update-scoop') {
warn "Scoop is out of date."
warn 'Scoop is out of date.'
} else {
scoop update
}
@@ -97,12 +93,12 @@ Function Get-VirusTotalResult($hash, $app) {
$unsafe = [int]$malicious + [int]$suspicious
$see_url = "see https://www.virustotal.com/#/file/$hash/detection"
switch ($unsafe) {
0 { if ($undetected -eq 0) { $fg = "Yellow" } else { $fg = "DarkGreen" } }
1 { $fg = "DarkYellow" }
2 { $fg = "Yellow" }
default { $fg = "Red" }
0 { if ($undetected -eq 0) { $fg = 'Yellow' } else { $fg = 'DarkGreen' } }
1 { $fg = 'DarkYellow' }
2 { $fg = 'Yellow' }
default { $fg = 'Red' }
}
write-host -f $fg "$app`: $unsafe/$undetected, $see_url"
Write-Host -f $fg "$app`: $unsafe/$undetected, $see_url"
if ($unsafe -gt 0) {
return $_ERR_UNSAFE
}
@@ -137,9 +133,8 @@ Function Submit-RedirectedUrl {
$request.AllowAutoRedirect = $false
$response = $request.GetResponse()
if (([int]$response.StatusCode -ge 300) -and ([int]$response.StatusCode -lt 400)) {
$redir = $response.GetResponseHeader("Location")
}
else {
$redir = $response.GetResponseHeader('Location')
} else {
$redir = $URL
}
$response.Close()
@@ -157,7 +152,7 @@ Function Submit-RedirectedUrl {
# exceeded, without risking an infinite loop (as stack
# overflow) if the submission keeps failing.
Function Submit-ToVirusTotal ($url, $app, $do_scan, $retrying = $False) {
$api_key = get_config("virustotal_api_key")
$api_key = get_config virustotal_api_key
if ($do_scan -and !$api_key -and !$warned_no_api_key) {
$warned_no_api_key = $true
info "Submitting unknown apps needs a VirusTotal API key. " +

View File

@@ -2,8 +2,6 @@
# Summary: Locate a shim/executable (similar to 'which' on Linux)
# Help: Locate the path to a shim/executable that was installed with Scoop (similar to 'which' on Linux)
param($command)
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
if (!$command) {
'ERROR: <command> missing'

View File

@@ -1,3 +1,6 @@
. "$PSScriptRoot\Scoop-TestLib.ps1"
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\help.ps1"
. "$PSScriptRoot\..\libexec\scoop-alias.ps1" | Out-Null
Describe 'add_alias' -Tag 'Scoop' {

View File

@@ -1,3 +1,4 @@
. "$PSScriptRoot\Scoop-TestLib.ps1"
. "$PSScriptRoot\..\lib\core.ps1"
Describe 'config' -Tag 'Scoop' {

View File

@@ -1,7 +1,7 @@
. "$PSScriptRoot\Scoop-TestLib.ps1"
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\unix.ps1"
. "$PSScriptRoot\Scoop-TestLib.ps1"
$repo_dir = (Get-Item $MyInvocation.MyCommand.Path).directory.parent.FullName
$isUnix = is_unix

View File

@@ -1,9 +1,10 @@
. "$PSScriptRoot\Scoop-TestLib.ps1"
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\decompress.ps1"
. "$PSScriptRoot\..\lib\unix.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\versions.ps1"
. "$PSScriptRoot\..\lib\unix.ps1"
$isUnix = is_unix

View File

@@ -1,5 +1,7 @@
. "$PSScriptRoot\Scoop-TestLib.ps1"
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\depends.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"

View File

@@ -1,8 +1,8 @@
. "$PSScriptRoot\Scoop-TestLib.ps1"
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\unix.ps1"
. "$PSScriptRoot\Scoop-TestLib.ps1"
$isUnix = is_unix