Skip to content

Commit a77319b

Browse files
authored
Merge branch 'main' into gxu-yarn-upgrade
2 parents 1163b74 + 5ca3bdd commit a77319b

File tree

18 files changed

+187
-66
lines changed

18 files changed

+187
-66
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"electron-installer-dmg": "^5.0.1",
130130
"electron-installer-redhat": "^3.2.0",
131131
"electron-installer-snap": "^5.2.0",
132+
"electron-windows-msix": "^2.0.4",
132133
"electron-windows-store": "^2.1.0",
133134
"electron-winstaller": "^5.3.0",
134135
"electron-wix-msi": "^5.1.3"

packages/api/core/spec/slow/api.slow.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ describe.each([
467467
'@electron-forge/maker-deb',
468468
'@electron-forge/maker-dmg',
469469
'@electron-forge/maker-flatpak',
470+
'@electron-forge/maker-msix',
470471
'@electron-forge/maker-rpm',
471472
'@electron-forge/maker-snap',
472473
'@electron-forge/maker-squirrel',

packages/maker/appx/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"node": ">= 16.4.0"
1515
},
1616
"dependencies": {
17+
"@electron-forge/core-utils": "7.9.0",
1718
"@electron-forge/maker-base": "7.9.0",
1819
"@electron-forge/shared-types": "7.9.0",
1920
"cross-spawn": "^7.0.3",

packages/maker/appx/src/MakerAppX.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'node:path';
22

3+
import { getNameFromAuthor } from '@electron-forge/core-utils';
34
import { MakerBase, MakerOptions } from '@electron-forge/maker-base';
45
import { ForgePlatform } from '@electron-forge/shared-types';
56
import resolveCommand from 'cross-spawn/lib/util/resolveCommand';
@@ -11,7 +12,6 @@ import {
1112
import fs from 'fs-extra';
1213

1314
import { MakerAppXConfig } from './Config';
14-
import getNameFromAuthor from './util/author-name';
1515

1616
// NB: This is not a typo, we require AppXs to be built on 64-bit
1717
// but if we're running in a 32-bit node.js process, we're going to

packages/maker/msix/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## maker-msix
2+
3+
> [!IMPORTANT]
4+
> This module is _experimental_ and is subject to breaking changes between releases.
5+
> See GitHub Releases change notes for migration instructions.
6+
7+
`@electron-forge/maker-msix` builds `.msix` packages, which can be distributed directly or via the Windows Store.
8+
9+
You can only build the MSIX target on Windows machines with the Windows 10 SDK installed.
10+
11+
Configuration options are documented in [`MakerMSIXConfig`](https://js.electronforge.io/interfaces/_electron_forge_maker_msix.MakerMSIXConfig.html).
12+
13+
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.
14+
15+
```javascript
16+
{
17+
name: '@electron-forge/maker-msix',
18+
config: {
19+
manifestVariables: {
20+
publisher: 'Electron Dev'
21+
},
22+
windowsSignOptions: {
23+
certificatePassword: '12345'
24+
}
25+
}
26+
}
27+
```

packages/maker/msix/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@electron-forge/maker-msix",
3+
"version": "7.8.3",
4+
"description": "MSIX maker for Electron Forge",
5+
"repository": "https://github.com/electron/forge",
6+
"author": "Jan Hannemann",
7+
"license": "MIT",
8+
"main": "dist/MakerMSIX.js",
9+
"typings": "dist/MakerMSIX.d.ts",
10+
"devDependencies": {
11+
"vitest": "^3.1.3"
12+
},
13+
"engines": {
14+
"node": ">= 16.4.0"
15+
},
16+
"dependencies": {
17+
"@electron-forge/core-utils": "7.9.0",
18+
"@electron-forge/maker-base": "7.9.0",
19+
"@electron-forge/shared-types": "7.9.0",
20+
"cross-spawn": "^7.0.3",
21+
"electron-windows-msix": "^2.0.4",
22+
"fs-extra": "^10.0.0",
23+
"parse-author": "^2.0.0"
24+
},
25+
"publishConfig": {
26+
"access": "public"
27+
},
28+
"files": [
29+
"dist",
30+
"src"
31+
]
32+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { describe, expect, it } from 'vitest';
2+
3+
import { toMsixArch } from '../../src/util/arch';
4+
5+
describe('toMsixArch', () => {
6+
[
7+
{
8+
arch: 'x64',
9+
expectedMsixArch: 'x64',
10+
},
11+
{
12+
arch: 'arm64',
13+
expectedMsixArch: 'arm64',
14+
},
15+
{
16+
arch: 'ia32',
17+
expectedMsixArch: 'x86',
18+
},
19+
].forEach((test) => {
20+
it(`${test.arch} converts to ${test.expectedMsixArch}`, () => {
21+
expect(toMsixArch(test.arch)).toBe(test.expectedMsixArch);
22+
});
23+
});
24+
25+
it(`throw for arch values without a match`, () => {
26+
expect(() => toMsixArch('armv7l')).toThrowError(
27+
'Invalid architecture: armv7l. Must be one of x64, arm64 or ia32',
28+
);
29+
});
30+
});

packages/maker/msix/src/Config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { PackagingOptions } from 'electron-windows-msix';
2+
3+
/**
4+
* The configuration object for the MSIX maker.
5+
* The `outputDir` and `appDir` parameters are preconfigured by Forge so that the
6+
* Maker uses the package output and can be then used to publish the app.
7+
*
8+
* @see https://github.com/bitdisaster/electron-windows-msix/blob/master/src/types.ts
9+
*/
10+
export type MakerMsixConfig = Omit<PackagingOptions, 'outputDir' | 'appDir'>;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { getNameFromAuthor } from '@electron-forge/core-utils';
2+
import { MakerBase, MakerOptions } from '@electron-forge/maker-base';
3+
import { ForgePlatform } from '@electron-forge/shared-types';
4+
import { packageMSIX } from 'electron-windows-msix';
5+
6+
import { MakerMsixConfig } from './Config';
7+
import { toMsixArch } from './util/arch';
8+
9+
/**
10+
* Creates an MSIX package for your Electron app.
11+
* @experimental
12+
*/
13+
export default class MakerMsix extends MakerBase<MakerMsixConfig> {
14+
name = 'msix';
15+
defaultPlatforms: ForgePlatform[] = ['win32'];
16+
17+
isSupportedOnCurrentPlatform(): boolean {
18+
return process.platform === 'win32';
19+
}
20+
21+
async make({
22+
dir,
23+
makeDir,
24+
targetArch,
25+
packageJSON,
26+
appName,
27+
}: MakerOptions): Promise<string[]> {
28+
const configManifestVariables = this.config.manifestVariables;
29+
const packageOptions = this.config;
30+
delete packageOptions.manifestVariables;
31+
32+
const result = await packageMSIX({
33+
manifestVariables: {
34+
packageDescription: packageJSON.description,
35+
appExecutable: `${appName}.exe`,
36+
packageVersion: packageJSON.version,
37+
publisher: getNameFromAuthor(packageJSON.author),
38+
packageIdentity: appName,
39+
targetArch: toMsixArch(targetArch),
40+
...configManifestVariables,
41+
},
42+
...packageOptions,
43+
appDir: dir,
44+
outputDir: makeDir,
45+
});
46+
47+
return [result.msixPackage];
48+
}
49+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
type MsixArch = 'x64' | 'arm64' | 'x86' | 'arm' | '*';
2+
3+
/**
4+
* Converts a Node.JS architecture to the corresponding MSIX architecture.
5+
* Valid Node.js values are x64, arm64, and ia32.
6+
*/
7+
export function toMsixArch(arch: string): MsixArch {
8+
const validArchitectures = ['x64', 'arm64'];
9+
10+
if (arch === 'ia32') {
11+
return 'x86';
12+
}
13+
14+
if (validArchitectures.includes(arch)) {
15+
return arch as MsixArch;
16+
}
17+
18+
throw new Error(
19+
`Invalid architecture: ${arch}. Must be one of ${validArchitectures.join(', ')} or ia32`,
20+
);
21+
}

0 commit comments

Comments
 (0)