feat(windows): add installation method

resolves #3799
This commit is contained in:
Jan De Dobbeleer 2023-05-06 20:23:32 +02:00 committed by Jan De Dobbeleer
parent 0a5230c8ca
commit 4cae83ced1
8 changed files with 22 additions and 13 deletions

View file

@ -32,21 +32,21 @@ jobs:
"packageUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v${{ github.event.inputs.version }}/install-amd64.exe",
"languages":["en"],
"architectures":["X64"],
"installerParameters":"/VERYSILENT /CURRENTUSER",
"installerParameters":"/VERYSILENT /CURRENTUSER /INSTALLER=winstore",
"isSilentInstall":false
},
{
"packageUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v${{ github.event.inputs.version }}/install-arm64.exe",
"languages":["en"],
"architectures":["Arm64"],
"installerParameters":"/VERYSILENT /CURRENTUSER",
"installerParameters":"/VERYSILENT /CURRENTUSER /INSTALLER=winstore",
"isSilentInstall":false
},
{
"packageUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v${{ github.event.inputs.version }}/install-386.exe",
"languages":["en"],
"architectures":["X86"],
"installerParameters":"/VERYSILENT /CURRENTUSER",
"installerParameters":"/VERYSILENT /CURRENTUSER /INSTALLER=winstore",
"isSilentInstall":false
}
]

View file

@ -22,6 +22,7 @@ Source: "bin\themes\*"; DestDir: "{app}\themes"
[Registry]
Root: "HKA"; Subkey: "{code:GetEnvironmentKey}"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\bin"; Check: NeedsAddPathHKA(ExpandConstant('{app}\bin'))
Root: "HKA"; Subkey: "{code:GetEnvironmentKey}"; ValueType: string; ValueName: "POSH_THEMES_PATH"; ValueData: {app}\themes; Flags: preservestringtype
Root: "HKA"; Subkey: "{code:GetEnvironmentKey}"; ValueType: string; ValueName: "POSH_INSTALLER"; ValueData: {param:installer|manual}; Flags: preservestringtype
[Code]
function GetEnvironmentKey(Param: string): string;

View file

@ -19,7 +19,8 @@
"installer": {
"args": [
"/CURRENTUSER",
"/VERYSILENT"
"/VERYSILENT",
"/INSTALLER=scoop"
]
},
"checkver": {

View file

@ -15,36 +15,36 @@ Installers:
InstallerSha256: <HASH-AMD64>
Scope: machine
InstallerSwitches:
Custom: /ALLUSERS
Custom: /INSTALLER=winget
- Architecture: x64
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-amd64.exe
InstallerSha256: <HASH-AMD64>
Scope: user
InstallerSwitches:
Custom: /CURRENTUSER
Custom: /INSTALLER=winget
- Architecture: x86
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-386.exe
InstallerSha256: <HASH-386>
Scope: machine
InstallerSwitches:
Custom: /ALLUSERS
Custom: /INSTALLER=winget
- Architecture: x86
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-386.exe
InstallerSha256: <HASH-386>
Scope: user
InstallerSwitches:
Custom: /CURRENTUSER
Custom: /INSTALLER=winget
- Architecture: arm64
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-arm64.exe
InstallerSha256: <HASH-ARM64>
Scope: machine
InstallerSwitches:
Custom: /ALLUSERS
Custom: /INSTALLER=winget
- Architecture: arm64
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-arm64.exe
InstallerSha256: <HASH-ARM64>
Scope: user
InstallerSwitches:
Custom: /CURRENTUSER
Custom: /INSTALLER=winget
ManifestType: installer
ManifestVersion: 1.1.0
ManifestVersion: 1.4.0

View file

@ -26,6 +26,6 @@ Tags:
- "terminal"
- "oh-my-posh"
ManifestType: defaultLocale
ManifestVersion: 1.1.0
ManifestVersion: 1.4.0
ReleaseNotesUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/tag/v<VERSION>

View file

@ -2,4 +2,4 @@ PackageIdentifier: JanDeDobbeleer.OhMyPosh
PackageVersion: <VERSION>
DefaultLocale: en-US
ManifestType: version
ManifestVersion: 1.1.0
ManifestVersion: 1.4.0

View file

@ -58,6 +58,10 @@ func getLatestVersion(env platform.Environment) (string, error) {
//
// The upgrade check is only performed every other week.
func Notice(env platform.Environment) (string, bool) {
// never validate when we install using the Windows Store
if env.Getenv("POSH_INSTALLER") == "winstore" {
return "", false
}
// do not check when last validation was < 1 week ago
if _, OK := env.Cache().Get(CACHEKEY); OK {
return "", false

View file

@ -20,6 +20,7 @@ func TestCanUpgrade(t *testing.T) {
Error error
Cache bool
GOOS string
Installer string
}{
{Case: "Up to date", CurrentVersion: "3.0.0", LatestVersion: "v3.0.0"},
{Case: "Outdated Windows", Expected: true, CurrentVersion: "3.0.0", LatestVersion: "v3.0.1", GOOS: platform.WINDOWS},
@ -27,6 +28,7 @@ func TestCanUpgrade(t *testing.T) {
{Case: "Outdated Darwin", Expected: true, CurrentVersion: "3.0.0", LatestVersion: "v3.0.1", GOOS: platform.DARWIN},
{Case: "Cached", Cache: true},
{Case: "Error", Error: fmt.Errorf("error")},
{Case: "Windows Store", Installer: "winstore"},
}
for _, tc := range cases {
@ -39,6 +41,7 @@ func TestCanUpgrade(t *testing.T) {
cache.On("Set", mock2.Anything, mock2.Anything, mock2.Anything)
env.On("Cache").Return(cache)
env.On("GOOS").Return(tc.GOOS)
env.On("Getenv", "POSH_INSTALLER").Return(tc.Installer)
json := fmt.Sprintf(`{"tag_name":"%s"}`, tc.LatestVersion)
env.On("HTTPRequest", releaseURL).Return([]byte(json), tc.Error)