@@ -59,6 +59,7 @@ function load_cfg($file) {
5959}
6060
6161function 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
99102function 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
128131function 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 }
153156function warn ($msg ) { write-host " WARN $msg " -f darkyellow }
154157function info ($msg ) { write-host " INFO $msg " -f darkgray }
155158function 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" }
210213function versiondir ($app , $version , $global ) { " $ ( appdir $app $global ) \$version " }
211214
212215function 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) {
246249function 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
831834function 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) {
9991002function 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
10111014function 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
10981101function 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
11021105function handle_special_urls ($url )
@@ -1196,31 +1199,53 @@ function Out-UTF8File {
11961199# for all communication with api.github.com
11971200Optimize-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
12261251setup_proxy
0 commit comments