Skip to content

Commit

Permalink
feat(manifest): Present pre_download property (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 authored Dec 5, 2020
1 parent 059c441 commit 733b922
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### 0.55-pre5

- **manifests**: Present `pre_download` property
- **scoop-install**: Fix installlation of different/older versions
- **scoop-info**: Respect NO_JUNCTION config
- Add changelog to repository
Expand Down
4 changes: 3 additions & 1 deletion lib/Update.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'core', 'Git', 'Helpers', 'buckets', 'install' | ForEach-Object {
'core', 'Git', 'Helpers', 'buckets', 'install', 'manifest' | ForEach-Object {
. (Join-Path $PSScriptRoot "$_.ps1")
}

Expand Down Expand Up @@ -255,6 +255,8 @@ function Update-App {
# Remove and replace whole region after proper implementation
Write-UserMessage -Message 'Downloading new version' -Output

Invoke-ManifestScript -Manifest $manifest -ScriptName 'pre_download' -Architecture $architecture

if (Test-Aria2Enabled) {
dl_with_cache_aria2 $App $version $manifest $architecture $SCOOP_CACHE_DIRECTORY $manifest.cookie $true (!$SkipHashCHeck)
} else {
Expand Down
4 changes: 3 additions & 1 deletion lib/install.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'Helpers', 'autoupdate', 'buckets', 'decompress' | ForEach-Object {
'Helpers', 'autoupdate', 'buckets', 'decompress', 'manifest' | ForEach-Object {
. (Join-Path $PSScriptRoot "$_.ps1")
}

Expand Down Expand Up @@ -64,6 +64,8 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru
$original_dir = $dir # Keep reference to real (not linked) directory
$persist_dir = persistdir $app $global

Invoke-ManifestScript -Manifest $manifest -ScriptName 'pre_download' -Architecture $architecture

$fname = dl_urls $app $version $manifest $bucket $architecture $dir $use_cache $check_hash
pre_install $manifest $architecture
run_installer $fname $manifest $architecture $dir $global
Expand Down
31 changes: 31 additions & 0 deletions lib/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,37 @@ function supports_architecture($manifest, $architecture) {
return -not [String]::IsNullOrEmpty((arch_specific 'url' $manifest $architecture))
}

function Invoke-ManifestScript {
<#
.SYNOPSIS
Execute script properties defined in manifest.
.PARAMETER Manifest
Specifies the manifest object.
.PARAMETER ScriptName
Specifies the property name.
.PARAMETER Architecture
Specifies the architecture.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[Alias('InputObject')]
$Manifest,
[Parameter(Mandatory)]
[String] $ScriptName,
[String] $Architecture
)

process {
$script = arch_specific $ScriptName $Manifest $Architecture
if ($script) {
$print = $ScriptName -replace '_', '-'
Write-UserMessage -Message "Running $print script..." -Output:$false
Invoke-Expression (@($script) -join "`r`n")
}
}
}

function generate_user_manifest($app, $bucket, $version) {
$null, $manifest, $bucket, $null = Find-Manifest $app $bucket

Expand Down
10 changes: 9 additions & 1 deletion schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@
"type": "object",
"additionalProperties": false,
"properties": {
"pre_download": {
"description": "Specify PowerShell commands to be executed before download process is executed.",
"$ref": "#/definitions/stringOrArrayOfStrings"
},
"url": {
"description": "Specify URLs of files, which needs to be downloaded to install application.",
"$ref": "#/definitions/uriOrArrayOfUris"
Expand All @@ -151,7 +155,7 @@
"$ref": "#/definitions/stringOrArrayOfStrings"
},
"pre_install": {
"description": "PowerShell commands to be executed before 'installer' is invoked.",
"description": "Specify PowerShell commands to be executed before 'installer' is invoked.",
"$ref": "#/definitions/stringOrArrayOfStrings"
},
"installer": {
Expand Down Expand Up @@ -524,6 +528,10 @@
}
}
},
"pre_download": {
"description": "Specify PowerShell commands to be executed before download process is executed.",
"$ref": "#/definitions/stringOrArrayOfStrings"
},
"cookie": {
"description": "Specify the cookies required to download applicaiton.",
"type": "object"
Expand Down

0 comments on commit 733b922

Please sign in to comment.