Skip to content

Commit a091fda

Browse files
authored
Merge branch 'develop' into fix-schema
2 parents 810de6a + 08ecdd1 commit a091fda

19 files changed

Lines changed: 118 additions & 71 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
- **scoop-update:** Stash uncommitted changes before update ([#5091](https://github.com/ScoopInstaller/Scoop/issues/5091))
88
- **install:** Show the running process ([#5102](https://github.com/ScoopInstaller/Scoop/issues/5102))
99

10+
### Bug Fixes
11+
12+
- **config:** Change config option to snake_case in file and SCREAMING_CASE in code ([#5116](https://github.com/ScoopInstaller/Scoop/issues/5116))
13+
1014
### Builds
1115

1216
- **schema**: Set manifest schema to be stricter ([#5093](https://github.com/ScoopInstaller/Scoop/issues/5093))

bin/install.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Remove-Item "$dir\_tmp", $zipfile -Recurse -Force
7070

7171
ensure_robocopy_in_path
7272

73-
set_config lastUpdate ([System.DateTime]::Now.ToString('o')) | Out-Null
73+
set_config LAST_UPDATE ([System.DateTime]::Now.ToString('o')) | Out-Null
7474
success 'Scoop was installed successfully!'
7575

7676
Write-Output "Type 'scoop help' for instructions."

lib/core.ps1

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ function load_cfg($file) {
5959
}
6060

6161
function get_config($name, $default) {
62+
$name = $name.ToLowerInvariant()
6263
if($null -eq $scoopConfig.$name -and $null -ne $default) {
6364
return $default
6465
}
@@ -72,6 +73,8 @@ function set_config {
7273
$value
7374
)
7475

76+
$name = $name.ToLowerInvariant()
77+
7578
if ($null -eq $scoopConfig -or $scoopConfig.Count -eq 0) {
7679
ensure (Split-Path -Path $configFile) | Out-Null
7780
$scoopConfig = New-Object -TypeName PSObject
@@ -98,7 +101,7 @@ function set_config {
98101

99102
function setup_proxy() {
100103
# note: '@' and ':' in password must be escaped, e.g. 'p@ssword' -> p\@ssword'
101-
$proxy = get_config 'proxy'
104+
$proxy = get_config PROXY
102105
if(!$proxy) {
103106
return
104107
}
@@ -126,7 +129,7 @@ function setup_proxy() {
126129
}
127130

128131
function git_cmd {
129-
$proxy = get_config 'proxy'
132+
$proxy = get_config PROXY
130133
$cmd = "git $($args | ForEach-Object { "$_ " })"
131134
if ($proxy -and $proxy -ne 'none') {
132135
$cmd = "SET HTTPS_PROXY=$proxy&&SET HTTP_PROXY=$proxy&&$cmd"
@@ -153,7 +156,7 @@ function error($msg) { write-host "ERROR $msg" -f darkred }
153156
function warn($msg) { write-host "WARN $msg" -f darkyellow }
154157
function info($msg) { write-host "INFO $msg" -f darkgray }
155158
function debug($obj) {
156-
if((get_config 'debug' $false) -ine 'true' -and $env:SCOOP_DEBUG -ine 'true') {
159+
if ((get_config DEBUG $false) -ine 'true' -and $env:SCOOP_DEBUG -ine 'true') {
157160
return
158161
}
159162

@@ -210,7 +213,7 @@ function appdir($app, $global) { "$(appsdir $global)\$app" }
210213
function versiondir($app, $version, $global) { "$(appdir $app $global)\$version" }
211214

212215
function currentdir($app, $global) {
213-
if (get_config NO_JUNCTIONS) {
216+
if (get_config NO_JUNCTION) {
214217
$version = Select-CurrentVersion -App $app -Global:$global
215218
} else {
216219
$version = 'current'
@@ -246,7 +249,7 @@ function installed_apps($global) {
246249
function failed($app, $global) {
247250
$app = ($app -split '/|\\')[-1]
248251
$appPath = appdir $app $global
249-
$hasCurrent = (get_config NO_JUNCTIONS) -or (Test-Path "$appPath\current")
252+
$hasCurrent = (get_config NO_JUNCTION) -or (Test-Path "$appPath\current")
250253
return (Test-Path $appPath) -and !($hasCurrent -and (installed $app $global))
251254
}
252255

@@ -394,7 +397,7 @@ function app_status($app, $global) {
394397

395398
$status.outdated = $false
396399
if ($status.version -and $status.latest_version) {
397-
if (get_config 'force_update' $false) {
400+
if (get_config FORCE_UPDATE $false) {
398401
$status.outdated = ((Compare-Version -ReferenceVersion $status.version -DifferenceVersion $status.latest_version) -ne 0)
399402
} else {
400403
$status.outdated = ((Compare-Version -ReferenceVersion $status.version -DifferenceVersion $status.latest_version) -gt 0)
@@ -830,7 +833,7 @@ function shim($path, $global, $name, $arg) {
830833

831834
function get_shim_path() {
832835
$shim_path = "$(versiondir 'scoop' 'current')\supporting\shims\kiennq\shim.exe"
833-
$shim_version = get_config 'shim' 'default'
836+
$shim_version = get_config SHIM 'default'
834837
switch ($shim_version) {
835838
'71' { $shim_path = "$(versiondir 'scoop' 'current')\supporting\shims\71\shim.exe"; Break }
836839
'scoopcs' { $shim_path = "$(versiondir 'scoop' 'current')\supporting\shimexe\bin\shim.exe"; Break }
@@ -999,17 +1002,17 @@ function show_app($app, $bucket, $version) {
9991002
function is_scoop_outdated() {
10001003
$now = [System.DateTime]::Now
10011004
try {
1002-
$expireHour = (New-TimeSpan (get_config lastUpdate) $now).TotalHours
1005+
$expireHour = (New-TimeSpan (get_config LAST_UPDATE) $now).TotalHours
10031006
return ($expireHour -ge 3)
10041007
} catch {
10051008
# If not System.DateTime
1006-
set_config lastUpdate ($now.ToString('o')) | Out-Null
1009+
set_config LAST_UPDATE ($now.ToString('o')) | Out-Null
10071010
return $true
10081011
}
10091012
}
10101013

10111014
function Test-ScoopCoreOnHold() {
1012-
$hold_update_until = get_config hold_update_until
1015+
$hold_update_until = get_config HOLD_UPDATE_UNTIL
10131016
if ($null -eq $hold_update_until) {
10141017
return $false
10151018
}
@@ -1027,7 +1030,7 @@ function Test-ScoopCoreOnHold() {
10271030
error 'If you want to disable self-update of Scoop Core for a moment,'
10281031
error "use 'scoop hold scoop' or 'scoop config hold_update_until <YYYY-MM-DD>/<YYYY/MM/DD>'."
10291032
}
1030-
set_config hold_update_until $null | Out-Null
1033+
set_config HOLD_UPDATE_UNTIL $null | Out-Null
10311034
return $false
10321035
}
10331036

@@ -1096,7 +1099,7 @@ function get_hash([String] $multihash) {
10961099
}
10971100

10981101
function Get-GitHubToken {
1099-
return $env:SCOOP_GH_TOKEN, (get_config 'gh_token') | Where-Object -Property Length -Value 0 -GT | Select-Object -First 1
1102+
return $env:SCOOP_GH_TOKEN, (get_config GH_TOKEN) | Where-Object -Property Length -Value 0 -GT | Select-Object -First 1
11001103
}
11011104

11021105
function handle_special_urls($url)
@@ -1196,31 +1199,53 @@ function Out-UTF8File {
11961199
# for all communication with api.github.com
11971200
Optimize-SecurityProtocol
11981201

1199-
# Scoop config file migration
1202+
# Load Scoop config
12001203
$configHome = $env:XDG_CONFIG_HOME, "$env:USERPROFILE\.config" | Select-Object -First 1
12011204
$configFile = "$configHome\scoop\config.json"
1202-
if ((Test-Path "$env:USERPROFILE\.scoop") -and !(Test-Path $configFile)) {
1203-
New-Item -ItemType Directory (Split-Path -Path $configFile) -ErrorAction Ignore | Out-Null
1204-
Move-Item "$env:USERPROFILE\.scoop" $configFile
1205-
write-host "WARN Scoop configuration has been migrated from '~/.scoop'" -f darkyellow
1206-
write-host "WARN to '$configFile'" -f darkyellow
1207-
}
1208-
1209-
# Load Scoop config
12101205
$scoopConfig = load_cfg $configFile
12111206

1207+
# NOTE Scoop config file migration. Remove this after 2023/6/30
1208+
if ($scoopConfig) {
1209+
$newConfigNames = @{
1210+
'lastUpdate' = 'last_update'
1211+
'SCOOP_REPO' = 'scoop_repo'
1212+
'SCOOP_BRANCH' = 'scoop_branch'
1213+
'7ZIPEXTRACT_USE_EXTERNAL' = 'use_external_7zip'
1214+
'MSIEXTRACT_USE_LESSMSI' = 'use_lessmsi'
1215+
'NO_JUNCTIONS' = 'no_junction'
1216+
'manifest_review' = 'show_manifest'
1217+
'rootPath' = 'root_path'
1218+
'globalPath' = 'global_path'
1219+
'cachePath' = 'cache_path'
1220+
}
1221+
$newConfigNames.GetEnumerator() | ForEach-Object {
1222+
if ($null -ne $scoopConfig.$($_.Key)) {
1223+
$value = $scoopConfig.$($_.Key)
1224+
$scoopConfig.PSObject.Properties.Remove($_.Key)
1225+
$scoopConfig | Add-Member -MemberType NoteProperty -Name $_.Value -Value $value
1226+
if ($_.Key -eq 'lastUpdate') {
1227+
$scoopConfigChg = $true
1228+
}
1229+
}
1230+
}
1231+
if ($scoopConfigChg) { # Only save config file if there was a change
1232+
ConvertTo-Json $scoopConfig | Out-UTF8File -FilePath $configFile
1233+
}
1234+
}
1235+
# END NOTE
1236+
12121237
# Scoop root directory
1213-
$scoopdir = $env:SCOOP, (get_config 'rootPath'), "$env:USERPROFILE\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
1238+
$scoopdir = $env:SCOOP, (get_config ROOT_PATH), "$env:USERPROFILE\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
12141239

12151240
# Scoop global apps directory
1216-
$globaldir = $env:SCOOP_GLOBAL, (get_config 'globalPath'), "$env:ProgramData\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -first 1
1241+
$globaldir = $env:SCOOP_GLOBAL, (get_config GLOBAL_PATH), "$env:ProgramData\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
12171242

12181243
# Scoop cache directory
12191244
# Note: Setting the SCOOP_CACHE environment variable to use a shared directory
12201245
# is experimental and untested. There may be concurrency issues when
12211246
# multiple users write and access cached files at the same time.
12221247
# Use at your own risk.
1223-
$cachedir = $env:SCOOP_CACHE, (get_config 'cachePath'), "$scoopdir\cache" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -first 1
1248+
$cachedir = $env:SCOOP_CACHE, (get_config CACHE_PATH), "$scoopdir\cache" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
12241249

12251250
# Setup proxy globally
12261251
setup_proxy

lib/decompress.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ function Expand-7zipArchive {
1818
[Switch]
1919
$Removal
2020
)
21-
if ((get_config 7ZIPEXTRACT_USE_EXTERNAL)) {
21+
if ((get_config USE_EXTERNAL_7ZIP)) {
2222
try {
2323
$7zPath = (Get-Command '7z' -CommandType Application -ErrorAction Stop | Select-Object -First 1).Source
2424
} catch [System.Management.Automation.CommandNotFoundException] {
25-
abort "`nCannot find external 7-Zip (7z.exe) while '7ZIPEXTRACT_USE_EXTERNAL' is 'true'!`nRun 'scoop config 7ZIPEXTRACT_USE_EXTERNAL false' or install 7-Zip manually and try again."
25+
abort "`nCannot find external 7-Zip (7z.exe) while 'use_external_7zip' is 'true'!`nRun 'scoop config use_external_7zip false' or install 7-Zip manually and try again."
2626
}
2727
} else {
2828
$7zPath = Get-HelperPath -Helper 7zip
@@ -146,7 +146,7 @@ function Expand-MsiArchive {
146146
$OriDestinationPath = $DestinationPath
147147
$DestinationPath = "$DestinationPath\_tmp"
148148
}
149-
if ((get_config MSIEXTRACT_USE_LESSMSI)) {
149+
if ((get_config USE_LESSMSI)) {
150150
$MsiPath = Get-HelperPath -Helper Lessmsi
151151
$ArgList = @('x', $Path, "$DestinationPath\")
152152
} else {

lib/depends.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ function Get-InstallationHelper {
106106
$installer = arch_specific 'installer' $Manifest $Architecture
107107
$post_install = arch_specific 'post_install' $Manifest $Architecture
108108
$script = $pre_install + $installer.script + $post_install
109-
if (((Test-7zipRequirement -Uri $url) -or ($script -like '*Expand-7zipArchive *')) -and !(get_config 7ZIPEXTRACT_USE_EXTERNAL)) {
109+
if (((Test-7zipRequirement -Uri $url) -or ($script -like '*Expand-7zipArchive *')) -and !(get_config USE_EXTERNAL_7ZIP)) {
110110
$helper += '7zip'
111111
}
112-
if (((Test-LessmsiRequirement -Uri $url) -or ($script -like '*Expand-MsiArchive *')) -and (get_config MSIEXTRACT_USE_LESSMSI)) {
112+
if (((Test-LessmsiRequirement -Uri $url) -or ($script -like '*Expand-MsiArchive *')) -and (get_config USE_LESSMSI)) {
113113
$helper += 'lessmsi'
114114
}
115115
if ($Manifest.innosetup -or ($script -like '*Expand-InnoArchive *')) {

lib/install.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru
3030
return
3131
}
3232

33-
if ((get_config 'manifest_review' $false) -and ($MyInvocation.ScriptName -notlike '*scoop-update*')) {
33+
if ((get_config SHOW_MANIFEST $false) -and ($MyInvocation.ScriptName -notlike '*scoop-update*')) {
3434
Write-Host "Manifest: $app.json"
35-
$style = get_config cat_style
35+
$style = get_config CAT_STYLE
3636
if ($style) {
3737
$manifest | ConvertToPrettyJson | bat --no-paging --style $style --language json
3838
} else {
@@ -214,7 +214,7 @@ function dl_with_cache_aria2($app, $version, $manifest, $architecture, $dir, $co
214214
$options += "--header='Cookie: $(cookie_header $cookies)'"
215215
}
216216

217-
$proxy = get_config 'proxy'
217+
$proxy = get_config PROXY
218218
if ($proxy -ne 'none') {
219219
if ([Net.Webrequest]::DefaultWebProxy.Address) {
220220
$options += "--all-proxy='$([Net.Webrequest]::DefaultWebProxy.Address.Authority)'"
@@ -371,7 +371,7 @@ function dl($url, $to, $cookies, $progress) {
371371
$wreq.Headers.Add('Cookie', (cookie_header $cookies))
372372
}
373373

374-
get_config 'private_hosts' | Where-Object { $_ -ne $null -and $url -match $_.match } | ForEach-Object {
374+
get_config PRIVATE_HOSTS | Where-Object { $_ -ne $null -and $url -match $_.match } | ForEach-Object {
375375
(ConvertFrom-StringData -StringData $_.Headers).GetEnumerator() | ForEach-Object {
376376
$wreq.Headers[$_.Key] = $_.Value
377377
}
@@ -588,7 +588,7 @@ function dl_urls($app, $version, $manifest, $bucket, $architecture, $dir, $use_c
588588
$extract_fn = 'Expand-InnoArchive'
589589
} elseif($fname -match '\.zip$') {
590590
# Use 7zip when available (more fast)
591-
if (((get_config 7ZIPEXTRACT_USE_EXTERNAL) -and (Test-CommandAvailable 7z)) -or (Test-HelperInstalled -Helper 7zip)) {
591+
if (((get_config USE_EXTERNAL_7ZIP) -and (Test-CommandAvailable 7z)) -or (Test-HelperInstalled -Helper 7zip)) {
592592
$extract_fn = 'Expand-7zipArchive'
593593
} else {
594594
$extract_fn = 'Expand-ZipArchive'
@@ -909,7 +909,7 @@ function rm_shims($app, $manifest, $global, $arch) {
909909
# Returns the 'current' junction directory if in use, otherwise
910910
# the version directory.
911911
function link_current($versiondir) {
912-
if (get_config NO_JUNCTIONS) { return $versiondir.ToString() }
912+
if (get_config NO_JUNCTION) { return $versiondir.ToString() }
913913

914914
$currentdir = "$(Split-Path $versiondir)\current"
915915

@@ -936,7 +936,7 @@ function link_current($versiondir) {
936936
# Returns the 'current' junction directory (if it exists),
937937
# otherwise the normal version directory.
938938
function unlink_current($versiondir) {
939-
if (get_config NO_JUNCTIONS) { return $versiondir.ToString() }
939+
if (get_config NO_JUNCTION) { return $versiondir.ToString() }
940940
$currentdir = "$(Split-Path $versiondir)\current"
941941

942942
if (Test-Path $currentdir) {
@@ -1234,7 +1234,7 @@ function test_running_process($app, $global) {
12341234
$running_processes = Get-Process | Where-Object { $_.Path -like "$processdir\*" } | Out-String
12351235

12361236
if ($running_processes) {
1237-
if (get_config 'ignore_running_processes') {
1237+
if (get_config IGNORE_RUNNING_PROCESSES) {
12381238
warn "The following instances of `"$app`" are still running. Scoop is configured to ignore this condition."
12391239
Write-Host $running_processes
12401240
return $false

lib/manifest.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function install_info($app, $version, $global) {
103103
}
104104

105105
function default_architecture {
106-
$arch = get_config 'default_architecture'
106+
$arch = get_config DEFAULT_ARCHITECTURE
107107
$system = if ([Environment]::Is64BitOperatingSystem) { '64bit' } else { '32bit' }
108108
if ($null -eq $arch) {
109109
$arch = $system

lib/unix.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ if(!(is_unix)) {
1010
}
1111

1212
# core.ps1
13-
$scoopdir = $env:SCOOP, (get_config 'rootPath'), (Join-Path $env:HOME "scoop") | Select-Object -first 1
14-
$globaldir = $env:SCOOP_GLOBAL, (get_config 'globalPath'), "/usr/local/scoop" | Select-Object -first 1
15-
$cachedir = $env:SCOOP_CACHE, (get_config 'cachePath'), (Join-Path $scoopdir "cache") | Select-Object -first 1
13+
$scoopdir = $env:SCOOP, (get_config ROOT_PATH), (Join-Path $env:HOME 'scoop') | Select-Object -First 1
14+
$globaldir = $env:SCOOP_GLOBAL, (get_config 'GLOBAL_PATH'), '/usr/local/scoop' | Select-Object -First 1
15+
$cachedir = $env:SCOOP_CACHE, (get_config 'CACHE_PATH'), (Join-Path $scoopdir 'cache') | Select-Object -First 1
1616

1717
# core.ps1
1818
function ensure($dir) {

lib/versions.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function Select-CurrentVersion { # 'manifest.ps1'
5050
)
5151
process {
5252
$currentPath = "$(appdir $AppName $Global)\current"
53-
if (!(get_config NO_JUNCTIONS)) {
53+
if (!(get_config NO_JUNCTION)) {
5454
$currentVersion = (parse_json "$currentPath\manifest.json").version
5555
if ($currentVersion -eq 'nightly') {
5656
$currentVersion = (Get-Item $currentPath).Target | Split-Path -Leaf

libexec/scoop-cat.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (!$app) { error '<app> missing'; my_usage; exit 1 }
1111
$null, $manifest, $bucket, $url = Get-Manifest $app
1212

1313
if ($manifest) {
14-
$style = get_config cat_style
14+
$style = get_config CAT_STYLE
1515
if ($style) {
1616
$manifest | ConvertToPrettyJson | bat --no-paging --style $style --language json
1717
} else {

0 commit comments

Comments
 (0)