Skip to content

Commit b8bffa9

Browse files
authored
Merge pull request #81 from EUCPilots/fixes
Proton apps
2 parents dcc0366 + 339197a commit b8bffa9

File tree

7 files changed

+265
-13
lines changed

7 files changed

+265
-13
lines changed

Apps/Get-ProtonAuthenticator.ps1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
function Get-ProtonAuthenticator {
2+
<#
3+
#>
4+
[OutputType([System.Management.Automation.PSObject])]
5+
[CmdletBinding(SupportsShouldProcess = $false)]
6+
param (
7+
[Parameter(Mandatory = $false, Position = 0)]
8+
[ValidateNotNull()]
9+
[System.Management.Automation.PSObject]
10+
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
11+
)
12+
13+
# Read the update source
14+
$params = @{
15+
Uri = $res.Get.Update.Uri
16+
}
17+
$Updates = Invoke-EvergreenRestMethod @params
18+
19+
# Convert the update JSON string
20+
if ($Updates -is [System.String]) {
21+
try {
22+
$Updates = $Updates | ConvertFrom-Json -ErrorAction "Continue"
23+
}
24+
catch {
25+
# Update feed may include duplicate keys in the JSON
26+
$Updates = $Updates -creplace $res.Get.Update.ReplaceString, "" | ConvertFrom-Json -ErrorAction "Stop"
27+
}
28+
}
29+
30+
# Simplify access to releases
31+
$Releases = $Updates.Releases
32+
33+
# Process each category
34+
foreach ($Category in ($Releases.CategoryName | Select-Object -Unique)) {
35+
Write-Verbose -Message "$($MyInvocation.MyCommand): Processing category: $Category"
36+
37+
# Sort for the latest version
38+
$LatestVersion = $Releases | Where-Object { $_.CategoryName -eq $Category } | `
39+
Sort-Object -Property @{ Expression = { [System.Version]$_.Version }; Descending = $true } -ErrorAction "SilentlyContinue" | `
40+
Select-Object -First 1
41+
Write-Verbose -Message "$($MyInvocation.MyCommand): Latest version in category '$Category' is $($LatestVersion.Version)"
42+
43+
# Construct the output; Return the custom object to the pipeline
44+
$PSObject = [PSCustomObject] @{
45+
Version = $LatestVersion.Version
46+
Date = ConvertTo-DateTime -DateTime $LatestVersion.ReleaseDate -Pattern $res.Get.Update.DatePattern
47+
Release = $LatestVersion.CategoryName
48+
Sha512 = $LatestVersion.File.Sha512CheckSum
49+
Type = Get-FileType -File $LatestVersion.File.Url
50+
URI = $LatestVersion.File.Url
51+
}
52+
Write-Output -InputObject $PSObject
53+
}
54+
}

Apps/Get-ProtonDrive.ps1

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,28 @@ function Get-ProtonDrive {
2727
}
2828
}
2929

30-
# Sort for the latest version
31-
$LatestVersion = $Updates.Releases | `
32-
Sort-Object -Property @{ Expression = { [System.Version]$_.Version }; Descending = $true } -ErrorAction "SilentlyContinue" | `
33-
Select-Object -First 1
30+
# Simplify access to releases
31+
$Releases = $Updates.Releases
3432

35-
# Construct the output; Return the custom object to the pipeline
36-
$PSObject = [PSCustomObject] @{
37-
Version = $LatestVersion.Version
38-
Date = ConvertTo-DateTime -DateTime $LatestVersion.ReleaseDate -Pattern $res.Get.Update.DatePattern
39-
Release = $LatestVersion.CategoryName
40-
Sha512 = $LatestVersion.File.Sha512CheckSum
41-
Type = Get-FileType -File $LatestVersion.File.Url
42-
URI = $LatestVersion.File.Url
33+
# Process each category
34+
foreach ($Category in ($Releases.CategoryName | Select-Object -Unique)) {
35+
Write-Verbose -Message "$($MyInvocation.MyCommand): Processing category: $Category"
36+
37+
# Sort for the latest version
38+
$LatestVersion = $Releases | Where-Object { $_.CategoryName -eq $Category } | `
39+
Sort-Object -Property @{ Expression = { [System.Version]$_.Version }; Descending = $true } -ErrorAction "SilentlyContinue" | `
40+
Select-Object -First 1
41+
Write-Verbose -Message "$($MyInvocation.MyCommand): Latest version in category '$Category' is $($LatestVersion.Version)"
42+
43+
# Construct the output; Return the custom object to the pipeline
44+
$PSObject = [PSCustomObject] @{
45+
Version = $LatestVersion.Version
46+
Date = ConvertTo-DateTime -DateTime $LatestVersion.ReleaseDate -Pattern $res.Get.Update.DatePattern
47+
Release = $LatestVersion.CategoryName
48+
Sha512 = $LatestVersion.File.Sha512CheckSum
49+
Type = Get-FileType -File $LatestVersion.File.Url
50+
URI = $LatestVersion.File.Url
51+
}
52+
Write-Output -InputObject $PSObject
4353
}
44-
Write-Output -InputObject $PSObject
4554
}

Apps/Get-ProtonMail.ps1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
function Get-ProtonMail {
2+
<#
3+
#>
4+
[OutputType([System.Management.Automation.PSObject])]
5+
[CmdletBinding(SupportsShouldProcess = $false)]
6+
param (
7+
[Parameter(Mandatory = $false, Position = 0)]
8+
[ValidateNotNull()]
9+
[System.Management.Automation.PSObject]
10+
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
11+
)
12+
13+
# Read the update source
14+
$params = @{
15+
Uri = $res.Get.Update.Uri
16+
}
17+
$Updates = Invoke-EvergreenRestMethod @params
18+
19+
# Convert the update JSON string
20+
if ($Updates -is [System.String]) {
21+
try {
22+
$Updates = $Updates | ConvertFrom-Json -ErrorAction "Continue"
23+
}
24+
catch {
25+
# Update feed may include duplicate keys in the JSON
26+
$Updates = $Updates -creplace $res.Get.Update.ReplaceString, "" | ConvertFrom-Json -ErrorAction "Stop"
27+
}
28+
}
29+
30+
# Simplify access to releases
31+
$Releases = $Updates.Releases
32+
33+
# Process each category
34+
foreach ($Category in ($Releases.CategoryName | Select-Object -Unique)) {
35+
Write-Verbose -Message "$($MyInvocation.MyCommand): Processing category: $Category"
36+
37+
# Sort for the latest version
38+
$LatestVersion = $Releases | Where-Object { $_.CategoryName -eq $Category } | `
39+
Sort-Object -Property @{ Expression = { [System.Version]$_.Version }; Descending = $true } -ErrorAction "SilentlyContinue" | `
40+
Select-Object -First 1
41+
Write-Verbose -Message "$($MyInvocation.MyCommand): Latest version in category '$Category' is $($LatestVersion.Version)"
42+
43+
# Construct the output; Return the custom object to the pipeline
44+
$PSObject = [PSCustomObject] @{
45+
Version = $LatestVersion.Version
46+
Date = ConvertTo-DateTime -DateTime $LatestVersion.ReleaseDate -Pattern $res.Get.Update.DatePattern
47+
Release = $LatestVersion.CategoryName
48+
Sha512 = $LatestVersion.File.Sha512CheckSum
49+
Type = Get-FileType -File $LatestVersion.File.Url
50+
URI = $LatestVersion.File.Url
51+
}
52+
Write-Output -InputObject $PSObject
53+
}
54+
}

Apps/Get-ProtonPass.ps1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
function Get-ProtonPass {
2+
<#
3+
#>
4+
[OutputType([System.Management.Automation.PSObject])]
5+
[CmdletBinding(SupportsShouldProcess = $false)]
6+
param (
7+
[Parameter(Mandatory = $false, Position = 0)]
8+
[ValidateNotNull()]
9+
[System.Management.Automation.PSObject]
10+
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
11+
)
12+
13+
# Read the update source
14+
$params = @{
15+
Uri = $res.Get.Update.Uri
16+
}
17+
$Updates = Invoke-EvergreenRestMethod @params
18+
19+
# Convert the update JSON string
20+
if ($Updates -is [System.String]) {
21+
try {
22+
$Updates = $Updates | ConvertFrom-Json -ErrorAction "Continue"
23+
}
24+
catch {
25+
# Update feed may include duplicate keys in the JSON
26+
$Updates = $Updates -creplace $res.Get.Update.ReplaceString, "" | ConvertFrom-Json -ErrorAction "Stop"
27+
}
28+
}
29+
30+
# Simplify access to releases
31+
$Releases = $Updates.Releases
32+
33+
# Process each category
34+
foreach ($Category in ($Releases.CategoryName | Select-Object -Unique)) {
35+
Write-Verbose -Message "$($MyInvocation.MyCommand): Processing category: $Category"
36+
37+
# Sort for the latest version
38+
$LatestVersion = $Releases | Where-Object { $_.CategoryName -eq $Category } | `
39+
Sort-Object -Property @{ Expression = { [System.Version]$_.Version }; Descending = $true } -ErrorAction "SilentlyContinue" | `
40+
Select-Object -First 1
41+
Write-Verbose -Message "$($MyInvocation.MyCommand): Latest version in category '$Category' is $($LatestVersion.Version)"
42+
43+
# Construct the output; Return the custom object to the pipeline
44+
$PSObject = [PSCustomObject] @{
45+
Version = $LatestVersion.Version
46+
Date = ConvertTo-DateTime -DateTime $LatestVersion.ReleaseDate -Pattern $res.Get.Update.DatePattern
47+
Release = $LatestVersion.CategoryName
48+
Sha512 = $LatestVersion.File.Sha512CheckSum
49+
Type = Get-FileType -File $LatestVersion.File.Url
50+
URI = $LatestVersion.File.Url
51+
}
52+
Write-Output -InputObject $PSObject
53+
}
54+
}

Manifests/ProtonAuthenticator.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"Name": "Proton Authenticator",
3+
"Source": "https://proton.me/authenticator/",
4+
"Get": {
5+
"Update": {
6+
"Uri": "https://proton.me/download/authenticator/windows/version.json",
7+
"DatePattern": "yyyy-MM-dd",
8+
"ReplaceString": "(\\s+\\\"Sha512Checksum\\\":\\s+\\\".*\\\"\\,)",
9+
"CategoryName": [
10+
"EarlyAccess",
11+
"Stable",
12+
"Aplha"
13+
]
14+
}
15+
},
16+
"Install": {
17+
"Setup": "",
18+
"Physical": {
19+
"Arguments": "",
20+
"PostInstall": []
21+
},
22+
"Virtual": {
23+
"Arguments": "",
24+
"PostInstall": []
25+
}
26+
}
27+
}

Manifests/ProtonMail.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"Name": "Proton Mail",
3+
"Source": "https://proton.me/mail/",
4+
"Get": {
5+
"Update": {
6+
"Uri": "https://proton.me/download/mail/windows/version.json",
7+
"DatePattern": "yyyy-MM-dd",
8+
"ReplaceString": "(\\s+\\\"Sha512Checksum\\\":\\s+\\\".*\\\"\\,)",
9+
"CategoryName": [
10+
"EarlyAccess",
11+
"Stable",
12+
"Aplha"
13+
]
14+
}
15+
},
16+
"Install": {
17+
"Setup": "",
18+
"Physical": {
19+
"Arguments": "",
20+
"PostInstall": []
21+
},
22+
"Virtual": {
23+
"Arguments": "",
24+
"PostInstall": []
25+
}
26+
}
27+
}

Manifests/ProtonPass.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"Name": "Proton Pass",
3+
"Source": "https://proton.me/pass/",
4+
"Get": {
5+
"Update": {
6+
"Uri": "https://proton.me/download/pass/windows/version.json",
7+
"DatePattern": "yyyy-MM-dd",
8+
"ReplaceString": "(\\s+\\\"Sha512Checksum\\\":\\s+\\\".*\\\"\\,)",
9+
"CategoryName": [
10+
"EarlyAccess",
11+
"Stable",
12+
"Aplha"
13+
]
14+
}
15+
},
16+
"Install": {
17+
"Setup": "",
18+
"Physical": {
19+
"Arguments": "",
20+
"PostInstall": []
21+
},
22+
"Virtual": {
23+
"Arguments": "",
24+
"PostInstall": []
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)