Skip to content

Commit c5907c3

Browse files
committed
first step
1 parent e0c682d commit c5907c3

7 files changed

Lines changed: 29 additions & 3 deletions

File tree

lib/core.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,19 @@ function applist($apps, $global) {
11401140

11411141
function parse_app([string]$app) {
11421142
if ($app -match '^(?:(?<bucket>[a-zA-Z0-9-_.]+)/)?(?<app>.*\.json|[a-zA-Z0-9-_.]+)(?:@(?<version>.*))?$') {
1143-
return $Matches['app'], $Matches['bucket'], $Matches['version']
1143+
$app = $Matches['app']
1144+
$bucket = $Matches['bucket']
1145+
$version = $Matches['version']
1146+
if (installed $app) {
1147+
$global = installed $app $true
1148+
$ver = Select-CurrentVersion -AppName $app -Global:$global
1149+
$install_info_path = "$(versiondir $app $ver $global)\install.json"
1150+
if (Test-Path $install_info_path) {
1151+
$install_info = parse_json $install_info_path
1152+
$bucket = $install_info.bucket
1153+
}
1154+
}
1155+
return $app, $bucket, $version
11441156
} else {
11451157
return $app, $null, $null
11461158
}

lib/manifest.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ function Get-Manifest($app) {
5353
}
5454
}
5555
if (!$manifest) {
56+
if (installed $app) {
57+
$global = installed $app $true
58+
$ver = Select-CurrentVersion -AppName $app -Global:$global
59+
$install_info_path = "$(versiondir $app $ver $global)\install.json"
60+
if (Test-Path $install_info_path) {
61+
$install_info = parse_json $install_info_path
62+
$url = $install_info.url
63+
}
64+
$manifest = if (Test-Path $url) { parse_json $url } else { installed_manifest $app $ver $global }
65+
}
5666
# couldn't find app in buckets: check if it's a local path
5767
if (Test-Path $app) {
5868
$url = Convert-Path $app

libexec/scoop-cat.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
param($app)
88

99
. "$PSScriptRoot\..\lib\json.ps1" # 'ConvertToPrettyJson'
10+
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
1011
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest'
1112

1213
if (!$app) { error '<app> missing'; my_usage; exit 1 }

libexec/scoop-download.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
. "$PSScriptRoot\..\lib\getopt.ps1"
2323
. "$PSScriptRoot\..\lib\json.ps1" # 'autoupdate.ps1' (indirectly)
2424
. "$PSScriptRoot\..\lib\autoupdate.ps1" # 'generate_user_manifest' (indirectly)
25+
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
2526
. "$PSScriptRoot\..\lib\manifest.ps1" # 'generate_user_manifest' 'Get-Manifest'
2627
. "$PSScriptRoot\..\lib\download.ps1"
2728
if (get_config USE_SQLITE_CACHE) {

libexec/scoop-home.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Summary: Opens the app homepage
33
param($app)
44

5+
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
56
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest'
67

78
if ($app) {

libexec/scoop-info.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
. "$PSScriptRoot\..\lib\getopt.ps1"
77
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest'
8-
. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-InstalledVersion'
8+
. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-InstalledVersion', 'Select-CurrentVersion'
99
. "$PSScriptRoot\..\lib\download.ps1" # 'Get-RemoteFileSize'
1010

1111
$opt, $app, $err = getopt $args 'v' 'verbose'
@@ -23,7 +23,7 @@ if (!$manifest) {
2323
$global = installed $app $true
2424
$status = app_status $app $global
2525
$install = install_info $app $status.version $global
26-
$status.installed = $bucket -and $install.bucket -eq $bucket
26+
$status.installed = installed $app
2727
$version_output = $manifest.version
2828
$manifest_file = if ($bucket) {
2929
manifest_path $app $bucket

libexec/scoop-virustotal.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# -p, --passthru Return reports as objects
3030

3131
. "$PSScriptRoot\..\lib\getopt.ps1"
32+
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
3233
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest'
3334
. "$PSScriptRoot\..\lib\json.ps1" # 'json_path'
3435
. "$PSScriptRoot\..\lib\download.ps1" # 'hash_for_url'

0 commit comments

Comments
 (0)