-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.ps1
More file actions
73 lines (58 loc) · 2.83 KB
/
update.ps1
File metadata and controls
73 lines (58 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Import-Module au
$currentPath = (Split-Path $MyInvocation.MyCommand.Definition)
$toolsPath = Join-Path -Path $currentPath -ChildPath 'tools'
function global:au_BeforeUpdate ($Package) {
Get-RemoteFiles -Purge -NoSuffix -Algorithm sha256
if (!(Test-Path -Path "$env:PROGRAMFILES\Mozilla Firefox\firefox.exe")) {
choco install firefox -y
}
$seleniumModuleName = 'Selenium'
if (!(Get-Module -ListAvailable -Name $seleniumModuleName)) {
Install-Module -Name $seleniumModuleName
}
Import-Module $seleniumModuleName
$startUrl = "https://web.archive.org/save/$($Latest.Url32)"
Write-Output "Starting Selenium at $startUrl"
$seleniumDriver = Start-SeFirefox -StartURL $startUrl -Headless
$Latest.ArchivedURL = $seleniumDriver.Url
$seleniumDriver.Dispose()
Copy-Item -Path "$toolsPath\VERIFICATION.txt.template" -Destination "$toolsPath\VERIFICATION.txt" -Force
Set-DescriptionFromReadme -Package $Package -ReadmePath ".\DESCRIPTION.md"
}
function global:au_AfterUpdate ($Package) {
}
function global:au_SearchReplace {
@{
'build.ps1' = @{
'(^\s*Url32\s*=\s*)(''.*'')' = "`$1'$($Latest.ArchivedURL)'"
}
"$($Latest.PackageName).nuspec" = @{
"<packageSourceUrl>[^<]*</packageSourceUrl>" = "<packageSourceUrl>https://github.com/brogers5/chocolatey-package-$($Latest.PackageName)/tree/v$($Latest.Version)</packageSourceUrl>"
"<copyright>[^<]*</copyright>" = "<copyright>Copyright (C) David L. A. Anson 2010-$(Get-Date -Format yyyy)</copyright>"
}
'tools\VERIFICATION.txt' = @{
'%snapshotUrl%' = "$($Latest.ArchivedURL)"
'%checksumType%' = "$($Latest.ChecksumType32.ToUpper())"
'%checksumValue%' = "$($Latest.Checksum32)"
}
}
}
function global:au_GetLatest {
#Use filename with .zip extension to prevent issues with Expand-Archive in Windows PowerShell
$tempArchive = "$(New-TemporaryFile).zip"
$downloadUri = 'https://dlaa.me/Samples/Insomnia/Insomnia.zip'
$userAgent = 'Update checker of Chocolatey Community Package ''insomnia'''
Invoke-WebRequest -Uri $downloadUri -UserAgent $userAgent -OutFile $tempArchive -UseBasicParsing
$tempDirectory = Join-Path -Path $env:TEMP -ChildPath $(New-Guid)
Expand-Archive -Path $tempArchive -DestinationPath $tempDirectory -Force
$64BitBinaryPath = Join-Path -Path $tempDirectory -ChildPath '64-bit' | Join-Path -ChildPath 'Insomnia.exe'
$64BitBinary = Get-Item -Path $64BitBinaryPath
$softwareVersion = $64BitBinary.VersionInfo.ProductVersion
Remove-Item -Path $tempDirectory -Recurse -Force
Remove-Item -Path $tempArchive -Force
return @{
Url32 = $downloadUri
Version = $softwareVersion
}
}
Update-Package -ChecksumFor None -NoReadme