From 60a51b14ff984166253d1f673f77317a48bf5b79 Mon Sep 17 00:00:00 2001 From: Further <55025025+ifurther@users.noreply.github.com> Date: Sat, 4 May 2024 18:31:42 +0800 Subject: [PATCH] feat(appx): Update identityName for windows 10 ref: https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-identity --- .../app-builder-lib/src/targets/AppxTarget.ts | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/app-builder-lib/src/targets/AppxTarget.ts b/packages/app-builder-lib/src/targets/AppxTarget.ts index 5a55a48864..9122e9096b 100644 --- a/packages/app-builder-lib/src/targets/AppxTarget.ts +++ b/packages/app-builder-lib/src/targets/AppxTarget.ts @@ -200,13 +200,29 @@ export default class AppXTarget extends Target { case "applicationId": { const result = options.applicationId || options.identityName || appInfo.name - if (!isNaN(parseInt(result[0], 10))) { - let message = `AppX Application.Id can’t start with numbers: "${result}"` - if (options.applicationId == null) { - message += `\nPlease set appx.applicationId (or correct appx.identityName or name)` - } + if (result.length < 3 || result.length > 50) { + let message = `Appx Application.Id with a value between 3 and 50 characters in length` throw new InvalidConfigurationError(message) } + const validCharactersRegex = /^[a-zA-Z0-9.-]+$/; + else if (!validCharactersRegex.test(result)) { + let message = `AppX Application.Id cat be consists of alpha-numeric, period, and dash characters"` + throw new InvalidConfigurationError(message) + } + const restrictedValues = [ + 'CON', 'PRN', 'AUX', 'NUL', + 'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9', + 'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9' + ]; + else if (restrictedValues.includes(result.toUpperCase())) { + let message = `AppX Application.Id cannot be some values` + throw new InvalidConfigurationError(message) + } + else if (options.applicationId == null) { + let message = `Please set appx.applicationId (or correct appx.identityName or name)` + throw new InvalidConfigurationError(message) + } + return result }