|
| 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 | +} |
0 commit comments