From 481e3b5e74640efd0f4aea35ad12bac9295af8e9 Mon Sep 17 00:00:00 2001 From: Mike Maietta Date: Wed, 18 Sep 2024 17:06:55 -0700 Subject: [PATCH 1/2] fix: force using `applicationId` if provided before falling back to identityName or app name --- .changeset/orange-radios-tie.md | 5 +++++ packages/app-builder-lib/src/targets/AppxTarget.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/orange-radios-tie.md diff --git a/.changeset/orange-radios-tie.md b/.changeset/orange-radios-tie.md new file mode 100644 index 00000000000..d1f6eace120 --- /dev/null +++ b/.changeset/orange-radios-tie.md @@ -0,0 +1,5 @@ +--- +"app-builder-lib": patch +--- + +fix: force using `applicationId` if provided before falling back to identityName or app name diff --git a/packages/app-builder-lib/src/targets/AppxTarget.ts b/packages/app-builder-lib/src/targets/AppxTarget.ts index f4c19f23523..2ffee2b7e4e 100644 --- a/packages/app-builder-lib/src/targets/AppxTarget.ts +++ b/packages/app-builder-lib/src/targets/AppxTarget.ts @@ -228,7 +228,9 @@ export default class AppXTarget extends Target { const validCharactersRegex = /^([A-Za-z][A-Za-z0-9]*)(\.[A-Za-z][A-Za-z0-9]*)*$/ const identitynumber = parseInt(options.identityName as string, 10) || NaN let result: string - if (!isNaN(identitynumber) && options.identityName !== null && options.identityName !== undefined) { + if (options.applicationId) { + result = options.applicationId + } else if (!isNaN(identitynumber) && options.identityName !== null && options.identityName !== undefined) { if (options.identityName[0] === "0") { log.warn(`Remove the 0${identitynumber}`) result = options.identityName.replace("0" + identitynumber.toString(), "") @@ -237,7 +239,7 @@ export default class AppXTarget extends Target { result = options.identityName.replace(identitynumber.toString(), "") } } else { - result = options.applicationId || options.identityName || appInfo.name + result = options.identityName || appInfo.name } if (result.length < 1 || result.length > 64) { From ca5488ee1b4c5e31586357d3208452ac4e02265c Mon Sep 17 00:00:00 2001 From: Mike Maietta Date: Wed, 18 Sep 2024 17:25:41 -0700 Subject: [PATCH 2/2] extract common configuration options to its own interface for better readability on the docs site --- packages/app-builder-lib/scheme.json | 1 - packages/app-builder-lib/src/configuration.ts | 77 ++++++++++--------- packages/app-builder-lib/src/index.ts | 1 + pages/configuration.md | 4 +- 4 files changed, 42 insertions(+), 41 deletions(-) diff --git a/packages/app-builder-lib/scheme.json b/packages/app-builder-lib/scheme.json index 4d329846ddd..4663f0e21f5 100644 --- a/packages/app-builder-lib/scheme.json +++ b/packages/app-builder-lib/scheme.json @@ -6596,7 +6596,6 @@ "type": "object" } }, - "description": "Configuration Options", "properties": { "afterAllArtifactBuild": { "anyOf": [ diff --git a/packages/app-builder-lib/src/configuration.ts b/packages/app-builder-lib/src/configuration.ts index 737ff8d3bee..5d1dfa61f54 100644 --- a/packages/app-builder-lib/src/configuration.ts +++ b/packages/app-builder-lib/src/configuration.ts @@ -21,7 +21,7 @@ import { NsisOptions, NsisWebOptions, PortableOptions } from "./targets/nsis/nsi /** * Configuration Options */ -export interface Configuration extends PlatformSpecificBuildOptions, Hooks { +export interface CommonConfiguration { /** * The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as * [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set. @@ -107,12 +107,6 @@ export interface Configuration extends PlatformSpecificBuildOptions, Hooks { readonly p5p?: LinuxTargetSpecificOptions | null readonly apk?: LinuxTargetSpecificOptions | null - /** - * Whether to include *all* of the submodules node_modules directories - * @default false - */ - includeSubNodeModules?: boolean - /** * Whether to build the application native dependencies from source. * @default false @@ -157,6 +151,44 @@ export interface Configuration extends PlatformSpecificBuildOptions, Hooks { */ readonly downloadAlternateFFmpeg?: boolean + /** + * Inject properties to `package.json`. + */ + readonly extraMetadata?: any + + /** + * Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct). + * @default false + */ + readonly forceCodeSigning?: boolean + + /** + * Whether to include PDB files. + * @default false + */ + readonly includePdb?: boolean + + /** + * Whether to remove `scripts` field from `package.json` files. + * + * @default true + */ + readonly removePackageScripts?: boolean + + /** + * Whether to remove `keywords` field from `package.json` files. + * + * @default true + */ + readonly removePackageKeywords?: boolean +} +export interface Configuration extends CommonConfiguration, PlatformSpecificBuildOptions, Hooks { + /** + * Whether to include *all* of the submodules node_modules directories + * @default false + */ + includeSubNodeModules?: boolean + /** * Whether to use [electron-compile](http://github.com/electron/electron-compile) to compile app. Defaults to `true` if `electron-compile` in the dependencies. And `false` if in the `devDependencies` or doesn't specified. */ @@ -191,17 +223,6 @@ export interface Configuration extends PlatformSpecificBuildOptions, Hooks { */ extends?: Array | string | null - /** - * Inject properties to `package.json`. - */ - readonly extraMetadata?: any - - /** - * Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct). - * @default false - */ - readonly forceCodeSigning?: boolean - /** * *libui-based frameworks only* The version of NodeJS you are packaging for. * You can set it to `current` to set the Node.js version that you use to run. @@ -218,26 +239,6 @@ export interface Configuration extends PlatformSpecificBuildOptions, Hooks { */ readonly framework?: string | null - /** - * Whether to include PDB files. - * @default false - */ - readonly includePdb?: boolean - - /** - * Whether to remove `scripts` field from `package.json` files. - * - * @default true - */ - readonly removePackageScripts?: boolean - - /** - * Whether to remove `keywords` field from `package.json` files. - * - * @default true - */ - readonly removePackageKeywords?: boolean - /** * Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation) * @default false diff --git a/packages/app-builder-lib/src/index.ts b/packages/app-builder-lib/src/index.ts index 8cb973f5225..50d452da39c 100644 --- a/packages/app-builder-lib/src/index.ts +++ b/packages/app-builder-lib/src/index.ts @@ -22,6 +22,7 @@ export { } from "./core" export { getArchSuffix, Arch, archFromString } from "builder-util" export { + CommonConfiguration, Configuration, AfterPackContext, MetadataDirectories, diff --git a/pages/configuration.md b/pages/configuration.md index 8a91a781e8f..f25f88ef54d 100644 --- a/pages/configuration.md +++ b/pages/configuration.md @@ -34,9 +34,9 @@ Env file `electron-builder.env` in the current dir ([example](https://github.com * Name of optional property is normal, **required** is bold. * Type is specified after property name: `Array | String`. Union like this means that you can specify or string (`**/*`), or array of strings (`["**/*", "!foo.js"]`). -### Configuration +### Common Configuration -{!./app-builder-lib.Interface.Configuration.md!} +{!./app-builder-lib.Interface.CommonConfiguration.md!} ---