-
-
Notifications
You must be signed in to change notification settings - Fork 610
feat(msix): add maker-msix #3978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| ## maker-msix | ||
|
|
||
| > [!IMPORTANT] | ||
| > This module is _experimental_ and is subject to breaking changes between releases. | ||
| > See GitHub Releases change notes for migration instructions. | ||
|
|
||
| `@electron-forge/maker-msix` builds `.msix` packages, which can be distributed directly or via the Windows Store. | ||
|
|
||
| You can only build the MSIX target on Windows machines with the Windows 10 SDK installed. | ||
|
|
||
| Configuration options are documented in [`MakerMSIXConfig`](https://js.electronforge.io/interfaces/_electron_forge_maker_msix.MakerMSIXConfig.html). | ||
|
|
||
| maker-msix utilizes @electron/windows-sign via the `windowsSignOptions` property. See the [windows-sign documentation](https://github.com/electron/windows-sign/blob/main/README.md) for details. | ||
|
|
||
| ```javascript | ||
| { | ||
| name: '@electron-forge/maker-msix', | ||
| config: { | ||
| manifestVariables: { | ||
| publisher: 'Electron Dev' | ||
| }, | ||
| windowsSignOptions: { | ||
| certificatePassword: '12345' | ||
| } | ||
| } | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| { | ||
| "name": "@electron-forge/maker-msix", | ||
| "version": "7.8.3", | ||
| "description": "MSIX maker for Electron Forge", | ||
| "repository": "https://github.com/electron/forge", | ||
| "author": "Jan Hannemann", | ||
| "license": "MIT", | ||
| "main": "dist/MakerMSIX.js", | ||
| "typings": "dist/MakerMSIX.d.ts", | ||
| "devDependencies": { | ||
| "vitest": "^3.1.3" | ||
| }, | ||
| "engines": { | ||
| "node": ">= 16.4.0" | ||
| }, | ||
| "dependencies": { | ||
| "@electron-forge/core-utils": "7.9.0", | ||
| "@electron-forge/maker-base": "7.9.0", | ||
| "@electron-forge/shared-types": "7.9.0", | ||
| "cross-spawn": "^7.0.3", | ||
| "electron-windows-msix": "^2.0.4", | ||
| "fs-extra": "^10.0.0", | ||
| "parse-author": "^2.0.0" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "files": [ | ||
| "dist", | ||
| "src" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { toMsixArch } from '../../src/util/arch'; | ||
|
|
||
| describe('toMsixArch', () => { | ||
| [ | ||
| { | ||
| arch: 'x64', | ||
| expectedMsixArch: 'x64', | ||
| }, | ||
| { | ||
| arch: 'arm64', | ||
| expectedMsixArch: 'arm64', | ||
| }, | ||
| { | ||
| arch: 'ia32', | ||
| expectedMsixArch: 'x86', | ||
| }, | ||
| ].forEach((test) => { | ||
| it(`${test.arch} converts to ${test.expectedMsixArch}`, () => { | ||
| expect(toMsixArch(test.arch)).toBe(test.expectedMsixArch); | ||
| }); | ||
| }); | ||
|
|
||
| it(`throw for arch values without a match`, () => { | ||
| expect(() => toMsixArch('armv7l')).toThrowError( | ||
| 'Invalid architecture: armv7l. Must be one of x64, arm64 or ia32', | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { PackagingOptions } from 'electron-windows-msix'; | ||
|
|
||
| /** | ||
| * The configuration object for the MSIX maker. | ||
| * The `outputDir` and `appDir` parameters are preconfigured by Forge so that the | ||
| * Maker uses the package output and can be then used to publish the app. | ||
| * | ||
| * @see https://github.com/bitdisaster/electron-windows-msix/blob/master/src/types.ts | ||
| */ | ||
| export type MakerMsixConfig = Omit<PackagingOptions, 'outputDir' | 'appDir'>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { getNameFromAuthor } from '@electron-forge/core-utils'; | ||
| import { MakerBase, MakerOptions } from '@electron-forge/maker-base'; | ||
| import { ForgePlatform } from '@electron-forge/shared-types'; | ||
| import { packageMSIX } from 'electron-windows-msix'; | ||
|
|
||
| import { MakerMsixConfig } from './Config'; | ||
| import { toMsixArch } from './util/arch'; | ||
|
|
||
| /** | ||
| * Creates an MSIX package for your Electron app. | ||
| * @experimental | ||
| */ | ||
| export default class MakerMsix extends MakerBase<MakerMsixConfig> { | ||
| name = 'msix'; | ||
| defaultPlatforms: ForgePlatform[] = ['win32']; | ||
|
|
||
| isSupportedOnCurrentPlatform(): boolean { | ||
| return process.platform === 'win32'; | ||
| } | ||
|
|
||
| async make({ | ||
| dir, | ||
| makeDir, | ||
| targetArch, | ||
| packageJSON, | ||
| appName, | ||
| }: MakerOptions): Promise<string[]> { | ||
| const configManifestVariables = this.config.manifestVariables; | ||
| const packageOptions = this.config; | ||
| delete packageOptions.manifestVariables; | ||
|
|
||
| const result = await packageMSIX({ | ||
| manifestVariables: { | ||
| packageDescription: packageJSON.description, | ||
| appExecutable: `${appName}.exe`, | ||
| packageVersion: packageJSON.version, | ||
| publisher: getNameFromAuthor(packageJSON.author), | ||
| packageIdentity: appName, | ||
| targetArch: toMsixArch(targetArch), | ||
| ...configManifestVariables, | ||
| }, | ||
| ...packageOptions, | ||
| appDir: dir, | ||
| outputDir: makeDir, | ||
| }); | ||
|
|
||
| return [result.msixPackage]; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| type MsixArch = 'x64' | 'arm64' | 'x86' | 'arm' | '*'; | ||
|
|
||
| /** | ||
| * Converts a Node.JS architecture to the corresponding MSIX architecture. | ||
| * Valid Node.js values are x64, arm64, and ia32. | ||
| */ | ||
| export function toMsixArch(arch: string): MsixArch { | ||
bitdisaster marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const validArchitectures = ['x64', 'arm64']; | ||
|
|
||
| if (arch === 'ia32') { | ||
| return 'x86'; | ||
| } | ||
|
|
||
| if (validArchitectures.includes(arch)) { | ||
| return arch as MsixArch; | ||
| } | ||
|
|
||
| throw new Error( | ||
| `Invalid architecture: ${arch}. Must be one of ${validArchitectures.join(', ')} or ia32`, | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.