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", "packageUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v${{ github.event.inputs.version }}/install-amd64.exe",
"languages":["en"], "languages":["en"],
"architectures":["X64"], "architectures":["X64"],
"installerParameters":"/VERYSILENT /CURRENTUSER", "installerParameters":"/VERYSILENT /CURRENTUSER /INSTALLER=winstore",
"isSilentInstall":false "isSilentInstall":false
}, },
{ {
"packageUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v${{ github.event.inputs.version }}/install-arm64.exe", "packageUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v${{ github.event.inputs.version }}/install-arm64.exe",
"languages":["en"], "languages":["en"],
"architectures":["Arm64"], "architectures":["Arm64"],
"installerParameters":"/VERYSILENT /CURRENTUSER", "installerParameters":"/VERYSILENT /CURRENTUSER /INSTALLER=winstore",
"isSilentInstall":false "isSilentInstall":false
}, },
{ {
"packageUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v${{ github.event.inputs.version }}/install-386.exe", "packageUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v${{ github.event.inputs.version }}/install-386.exe",
"languages":["en"], "languages":["en"],
"architectures":["X86"], "architectures":["X86"],
"installerParameters":"/VERYSILENT /CURRENTUSER", "installerParameters":"/VERYSILENT /CURRENTUSER /INSTALLER=winstore",
"isSilentInstall":false "isSilentInstall":false
} }
] ]

View file

@ -22,6 +22,7 @@ Source: "bin\themes\*"; DestDir: "{app}\themes"
[Registry] [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: 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_THEMES_PATH"; ValueData: {app}\themes; Flags: preservestringtype
Root: "HKA"; Subkey: "{code:GetEnvironmentKey}"; ValueType: string; ValueName: "POSH_INSTALLER"; ValueData: {param:installer|manual}; Flags: preservestringtype
[Code] [Code]
function GetEnvironmentKey(Param: string): string; function GetEnvironmentKey(Param: string): string;

View file

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

View file

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

View file

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

View file

@ -2,4 +2,4 @@ PackageIdentifier: JanDeDobbeleer.OhMyPosh
PackageVersion: <VERSION> PackageVersion: <VERSION>
DefaultLocale: en-US DefaultLocale: en-US
ManifestType: version 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. // The upgrade check is only performed every other week.
func Notice(env platform.Environment) (string, bool) { 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 // do not check when last validation was < 1 week ago
if _, OK := env.Cache().Get(CACHEKEY); OK { if _, OK := env.Cache().Get(CACHEKEY); OK {
return "", false return "", false

View file

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