Skip to content

Commit 65997fc

Browse files
committed
Init Scoop bucket
0 parents  commit 65997fc

17 files changed

+502
-0
lines changed

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# retain windows line-endings in case checked out on mac or linux
2+
* text eol=crlf
3+
.git/hooks/* text eol=lf

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @silver886
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Hash check fail
3+
about: Installation failed due to hash check.
4+
title: '%%manifest%%@%%version%%: Hash check failed'
5+
---
6+
7+
<!-- Replace title placeholders with proper information -->
8+
<!-- Copy terminal output and paste it into code fence block -->
9+
10+
```powershell
11+
12+
```
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: New manifest request
3+
about: Request new manifest to be added into this bucket.
4+
title: '[Request] Add %%applicationName%%'
5+
labels: request, help wanted
6+
---
7+
8+
<!-- Adjust prefilled title with correct name of application -->
9+
<!-- Please provide following information: -->
10+
- **URL to application**: <>
11+
- **Latest version**:
12+
- **Graphical interface**: Yes/No
13+
- **Portable version**: Yes/No <!-- if Yes please specify if portable mode needs to be enabled and list files/folders needed to be handled on update -->
14+
15+
<!-- Is there anything else contributors need to know? -->
16+
<!-- Files, folders to persist across updates -->
17+
<!-- Installation requirements -->
18+
<!-- ... -->

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/checkver*

LICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org/>

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Scoop Bucket - silver886
2+
3+
`scoop bucket add silver886 'https://github.com/silver886/scoop-silver886.git'`

bin/Helpers.ps1

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$ROOT_DIRECTORY = Resolve-Path "$PSScriptRoot\.."
2+
$BUCKET_DIRECTORY = Resolve-Path "$ROOT_DIRECTORY\bucket"
3+
4+
function Get-RecursiveFolder {
5+
$folders = @($ROOT_DIRECTORY)
6+
$folders += Get-ChildItem $ROOT_DIRECTORY -Directory | Where-Object { $_ -inotmatch '.vscode|bin' }
7+
8+
return Resolve-Path $folders
9+
}

bin/auto-pr.ps1

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<#
2+
.SYNOPSIS
3+
Updates manifests and pushes them or creates pull-requests.
4+
.DESCRIPTION
5+
Updates manifests and pushes them to directly the master branch or creates pull-requests for upstream.
6+
.PARAMETER Manifest
7+
Specify manifest to be updated.
8+
.PARAMETER Dir
9+
Specify directory with manifests.
10+
.PARAMETER Upstream
11+
Specify upstream repository with target branch.
12+
.PARAMETER Push
13+
Specify if updates should be directly pushed to 'origin master'.
14+
.PARAMETER Request
15+
Specify if pull-requests should be created on 'upstream master' for each manifest.
16+
.PARAMETER SpecialSnowflakes
17+
Specify list of manifests, which should be force updated.
18+
#>
19+
param(
20+
[Alias('App', 'Name')]
21+
[String] $Manifest = '*',
22+
[ValidateScript( { if ( Test-Path $_ -Type Container) { $true } else { $false } })]
23+
[String] $Dir = "$PSScriptRoot\..\bucket",
24+
[ValidatePattern('^(.+)\/(.+):(.+)$')]
25+
[String] $Upstream = $((git config --get remote.origin.url) -replace '^.+[:/](?<user>.*)\/(?<repo>.*)(\.git)?$', '${user}/${repo}:master'),
26+
[Switch] $Push,
27+
[Switch] $Request,
28+
[string[]] $SpecialSnowflakes
29+
)
30+
31+
begin {
32+
if (-not $env:SCOOP_HOME) {
33+
if (-not (Get-Command 'scoop' -ErrorAction SilentlyContinue)) { throw 'Scoop installation or SCOOP_HOME environment is required' }
34+
$env:SCOOP_HOME = scoop prefix scoop | Resolve-Path
35+
}
36+
$Params = @{
37+
App = $Manifest
38+
Dir = Resolve-Path $Dir
39+
Upstream = $Upstream
40+
Push = $Push
41+
Request = $Request
42+
SpecialSnowflakes = $SpecialSnowflakes
43+
SkipUpdated = $true
44+
}
45+
}
46+
47+
process { & "$env:SCOOP_HOME\bin\auto-pr.ps1" @Params }
48+
49+
end { Write-Host 'DONE' -ForegroundColor Yellow }

bin/checkAndPush.ps1

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<#
2+
.SYNOPSIS
3+
Update manifest, commit and push.
4+
.DESCRIPTION
5+
Use as vscode task:
6+
1. Open manifest in editor
7+
1. Press CTRL+SHIFT+B or CTRL+F9 (IntelliJ)
8+
1. Be surprised
9+
.PARAMETER Manifest
10+
Full Path to manifest. (vscode ${file})
11+
.PARAMETER Force
12+
Force parameter will be passed to checkver.
13+
.PARAMETER Hashes
14+
checkhashes.ps1 script will be executed instead of checkver.ps1
15+
#>
16+
param(
17+
[Alias('App')]
18+
[String[]] $Manifest,
19+
[Alias('ForceUpdate')]
20+
[Switch] $Force,
21+
[Switch] $Hashes
22+
)
23+
24+
begin {
25+
. "$PSScriptRoot\Helpers.ps1"
26+
27+
if ($Force) { $arg = '-ForceUpdate' } else { $arg = '-Update' }
28+
}
29+
30+
process {
31+
foreach ($man in $Manifest) {
32+
# TODO: Yaml
33+
# if (-not ($man.EndsWith('.yml'))) {
34+
# $man += '.yml'
35+
# }
36+
if (-not ($man.EndsWith('.json'))) {
37+
$man += '.json'
38+
}
39+
$man = Resolve-Path $man
40+
$folder = Split-Path $man -Parent
41+
$file = Split-Path $man -Leaf
42+
$noExt = ($file -split '\.')[0]
43+
$cmd = 'checkver'
44+
45+
if ($Force) { scoop cache rm $noExt }
46+
if ($Hashes) { $cmd = 'checkhashes' }
47+
48+
Invoke-Expression -Command "$PSScriptRoot\$cmd.ps1 '$noExt' '$folder' $arg"
49+
50+
$updated = @(git status -s)
51+
52+
if (($updated -match "$noExt").Count -gt 0) {
53+
# TODO: Yaml
54+
# $manifest = Get-Content $man -Raw -Encoding UTF8 | ConvertFrom-Yaml -Ordered
55+
[psobject] $manifest = Get-Content $man -Raw -Encoding UTF8 | ConvertFrom-Json
56+
$message = "$noExt`: Bumped to $($manifest.version)"
57+
58+
if ($Hashes) { $message = "${noExt}: Fixed hashes" }
59+
60+
Write-Host 'Commiting' -ForegroundColor Green
61+
git commit --message $message --only "*$file"
62+
$exit = $LASTEXITCODE
63+
64+
if ($exit -gt 0) {
65+
Write-Host 'Pre-commit hook failed.' -ForegroundColor Red
66+
exit $exit
67+
}
68+
69+
Write-Host 'Pushing' -ForegroundColor Green
70+
git push
71+
72+
Write-Host 'DONE' -ForegroundColor Yellow
73+
} else {
74+
Write-Host 'No Changes' -ForegroundColor Yellow
75+
}
76+
}
77+
}

bin/checkhashes.ps1

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<#
2+
.SYNOPSIS
3+
Check hashes of all URLs inside manifest.
4+
.DESCRIPTION
5+
Check hashes of all URLs inside manifest.
6+
Script will download every URL and then calculate hash of them.
7+
.PARAMETER Manifest
8+
Specify the name of manifest to be checked.
9+
Placeholders are supported.
10+
.PARAMETER Dir
11+
Specify the directory with manifests.
12+
Default to bucket folder.
13+
.PARAMETER Rest
14+
-u - Update hashes if there are mismatched ones.
15+
-f - Update hashes always (even without mismatch).
16+
-k - Use cache.
17+
.EXAMPLE
18+
PS BUCKETDIR> .\bin\checkhashes.ps1
19+
Check URLs of all manifests.
20+
.EXAMPLE
21+
PS BUCKETDIR> .\bin\checkhashes.ps1 MAN
22+
Check URLs of manifests MAN.json inside bucket root.
23+
.EXAMPLE
24+
PS BUCKETDIR> .\bin\checkhashes.ps1 MAN TODO
25+
Check URLs of manifests MAN.json inside folder ./BUCKETROOT/TODO.
26+
.EXAMPLE
27+
PS BUCKETDIR> .\bin\checkhashes.ps1 MAN -u
28+
Check URLs of manifests MAN and update if there are some mismatches.
29+
.EXAMPLE
30+
PS BUCKETDIR> .\bin\checkhashes.ps1 MAN -f
31+
Check URLs of manifests MAN and update even if every hash is correct.
32+
.EXAMPLE
33+
PS BUCKETDIR> .\bin\checkhashes.ps1 MAN -k
34+
Check URLs of manifests MAN and keep it's downloaded files.
35+
#>
36+
param(
37+
[Parameter(ValueFromPipeline = $true)]
38+
[Alias('App', 'Name')]
39+
[String[]] $Manifest = '*',
40+
[ValidateScript( { if ( Test-Path $_ -Type Container) { $true } else { $false } })]
41+
[String] $Dir = "$PSScriptRoot\..\bucket",
42+
[Switch] $Recurse,
43+
[Parameter(ValueFromRemainingArguments)]
44+
[String[]] $Rest
45+
)
46+
47+
48+
begin {
49+
. "$PSScriptRoot\Helpers.ps1"
50+
51+
if (-not $env:SCOOP_HOME) {
52+
if (-not (Get-Command 'scoop' -ErrorAction SilentlyContinue)) { throw 'Scoop installation or SCOOP_HOME environment is required' }
53+
$env:SCOOP_HOME = scoop prefix scoop | Resolve-Path
54+
}
55+
$Dir = Resolve-Path $Dir
56+
$Script = "$env:SCOOP_HOME\bin\checkhashes.ps1"
57+
$Rest = ($Rest | Select-Object -Unique) -join ' '
58+
}
59+
60+
process {
61+
if ($Recurse) {
62+
Get-RecursiveFolder | ForEach-Object { Invoke-Expression -Command "$Script -Dir ""$_"" $Rest" }
63+
} else {
64+
foreach ($man in $Manifest) { Invoke-Expression -Command "$Script -App ""$man"" -Dir ""$Dir"" $Rest" }
65+
}
66+
}
67+
68+
end { Write-Host 'DONE' -ForegroundColor Yellow }

bin/checkurls.ps1

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<#
2+
.SYNOPSIS
3+
Check if all urls inside manifest are valid.
4+
.PARAMETER Manifest
5+
Manifest to check.
6+
Wildcard * is supported.
7+
.PARAMETER Dir
8+
Location where to search manifests.
9+
Default to bucket folder.
10+
.PARAMETER Timeout
11+
How many seconds to wait until mark URL as invalid.
12+
.PARAMETER Rest
13+
-s - Skip manifests will all URLs valid.
14+
.EXAMPLE
15+
PS BUCKETROOT > .\bin\checkurls
16+
Check urls for all manifests in root of bucket.
17+
.EXAMPLE
18+
PS BUCKETROOT > .\bin\checkurls cosi
19+
Check urls for cosi.json manifest in root of bucket.
20+
.EXAMPLE
21+
PS BUCKETROOT > .\bin\checkurls cosi TODO
22+
Check urls for cosi.json manifest in TODO directory.
23+
.EXAMPLE
24+
PS BUCKETROOT > .\bin\checkurls cosi TODO 25
25+
Check urls for cosi.json manifest in TODO directory with 25 timeout.
26+
.EXAMPLE
27+
PS BUCKETROOT > .\bin\checkurls -dir TODO
28+
Check urls for all manifests in TODO directory.
29+
#>
30+
param(
31+
[Parameter(ValueFromPipeline = $true)]
32+
[Alias('App')]
33+
[String[]] $Manifest = '*',
34+
[ValidateScript( { if ( Test-Path $_ -Type Container) { $true } else { $false } })]
35+
[String] $Dir = "$PSScriptRoot\..\bucket",
36+
[Int] $Timeout = 5,
37+
[Switch] $Recurse,
38+
[Parameter(ValueFromRemainingArguments = $true)]
39+
[String[]] $Rest = @()
40+
)
41+
42+
begin {
43+
if (-not $env:SCOOP_HOME) { $env:SCOOP_HOME = Resolve-Path (scoop prefix scoop) }
44+
$Dir = Resolve-Path $Dir
45+
$Script = "$env:SCOOP_HOME\bin\checkurls.ps1"
46+
$Rest = ($Rest | Select-Object -Unique) -join ' '
47+
}
48+
49+
process {
50+
if ($Recurse) {
51+
Get-RecursiveFolder | ForEach-Object { Invoke-Expression -Command "$Script -Dir ""$_"" -Timeout $Timeout $Rest" }
52+
} else {
53+
foreach ($man in $Manifest) { Invoke-Expression -Command "$Script -App ""$man"" -Dir ""$Dir"" -Timeout $Timeout $Rest" }
54+
}
55+
}

0 commit comments

Comments
 (0)