From 60eb55584d82cc72d6d546e1a51198d3e4b91ad3 Mon Sep 17 00:00:00 2001 From: Noah Andrews Date: Mon, 8 May 2023 18:12:17 -0500 Subject: [PATCH] msiWrapped: Normalize target names before checking for NSIS target (#7529) --- .changeset/shiny-jars-fetch.md | 6 ++++ .../src/targets/MsiWrappedTarget.ts | 9 +++++- test/snapshots/windows/msiWrappedTest.js.snap | 29 +++++++++++++++++++ test/src/windows/msiWrappedTest.ts | 20 +++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .changeset/shiny-jars-fetch.md diff --git a/.changeset/shiny-jars-fetch.md b/.changeset/shiny-jars-fetch.md new file mode 100644 index 00000000000..8b1ba3817b9 --- /dev/null +++ b/.changeset/shiny-jars-fetch.md @@ -0,0 +1,6 @@ +--- +"app-builder-lib": patch +"electron-builder": patch +--- + +When using the msiWrapped target, allow the nsis target to be capitalized in the configuration file diff --git a/packages/app-builder-lib/src/targets/MsiWrappedTarget.ts b/packages/app-builder-lib/src/targets/MsiWrappedTarget.ts index 2da8365d4bd..e657f8dc005 100644 --- a/packages/app-builder-lib/src/targets/MsiWrappedTarget.ts +++ b/packages/app-builder-lib/src/targets/MsiWrappedTarget.ts @@ -38,7 +38,14 @@ export default class MsiWrappedTarget extends MsiTarget { const target = config.win.target const nsisTarget = "nsis" - if (!target.some((t: TargetConfiguration | string) => (typeof t === "string" && t === nsisTarget) || (t as TargetConfiguration).target === nsisTarget)) { + if ( + !target + .map((t: TargetConfiguration | string): string => { + const result: string = typeof t === "string" ? t : t.target + return result.toLowerCase().trim() + }) + .some(t => t === nsisTarget) + ) { throw new Error("No nsis target found! Please specify an nsis target") } } diff --git a/test/snapshots/windows/msiWrappedTest.js.snap b/test/snapshots/windows/msiWrappedTest.js.snap index 49b47ead29d..a663fa04959 100644 --- a/test/snapshots/windows/msiWrappedTest.js.snap +++ b/test/snapshots/windows/msiWrappedTest.js.snap @@ -1,5 +1,34 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`msiWrapped allows capitalized nsis target 1`] = ` +Object { + "win": Array [ + Object { + "arch": "x64", + "file": "Test MSI 1.1.0.msi", + "safeArtifactName": "Test-MSI-1.1.0.msi", + }, + Object { + "arch": "x64", + "file": "Test MSI Setup 1.1.0.exe", + "safeArtifactName": "Test-MSI-Setup-1.1.0.exe", + "updateInfo": Object { + "sha512": "@sha512", + "size": "@size", + }, + }, + Object { + "file": "Test MSI Setup 1.1.0.exe.blockmap", + "safeArtifactName": "Test-MSI-Setup-1.1.0.exe.blockmap", + "updateInfo": Object { + "sha512": "@sha512", + "size": "@size", + }, + }, + ], +} +`; + exports[`msiWrapped impersonate no if not provided 1`] = ` Object { "win": Array [ diff --git a/test/src/windows/msiWrappedTest.ts b/test/src/windows/msiWrappedTest.ts index 2280394ff4d..9f285a37886 100644 --- a/test/src/windows/msiWrappedTest.ts +++ b/test/src/windows/msiWrappedTest.ts @@ -33,6 +33,26 @@ test.ifAll.ifDevOrWinCi( ) ) +test.ifAll.ifDevOrWinCi( + "msiWrapped allows capitalized nsis target", + app( + { + targets: Platform.WINDOWS.createTarget(["msiWrapped", "NSIS"]), + config: { + appId: "build.electron.test.msi.oneClick.perMachine", + extraMetadata: { + // version: "1.0.0", + }, + productName: "Test MSI", + win: { + target: ["msiWrapped", "NSIS"], + }, + }, + }, + {} + ) +) + test.ifAll.ifDevOrWinCi( "msiWrapped includes packaged exe", app({