Skip to content

Commit

Permalink
split the identiityName and applicationid detect
Browse files Browse the repository at this point in the history
  • Loading branch information
ifurther committed May 15, 2024
1 parent 83aad7d commit b6f2499
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"type": "boolean"
},
"applicationId": {
"description": "The application id. Defaults to `identityName`.",
"description": "The application id. Defaults to `identityName`. This string contains alpha-numeric fields separated by periods. Each field must begin with an ASCII alphabetic character",
"type": "string"
},
"artifactName": {
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/options/AppXOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TargetSpecificOptions } from "../core"

export interface AppXOptions extends TargetSpecificOptions {
/**
* The application id. Defaults to `identityName`.
* The application id. Defaults to `identityName` This string contains alpha-numeric fields separated by periods. Each field must begin with an ASCII alphabetic character.
*/
readonly applicationId?: string

Expand Down
33 changes: 28 additions & 5 deletions packages/app-builder-lib/src/targets/AppxTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,17 @@ export default class AppXTarget extends Target {
case "applicationId": {
const result = options.applicationId || options.identityName || appInfo.name
const validCharactersRegex = /^[a-zA-Z0-9.-]+$/
if (result.length < 3 || result.length > 50) {
const message = `Appx Application.Id with a value between 3 and 50 characters in length`
const identitynumber = parseInt(result, 10)
if (!isNaN(identitynumber)) {
log.warn(`Remove the ${identitynumber}`)
result = result.replace(identitynumber,'')
}

if (result.length < 1 || result.length > 64) {
const message = `Appx Application.Id with a value between 1 and 64 characters in length`
throw new InvalidConfigurationError(message)
} else if (!validCharactersRegex.test(result)) {
const message = `AppX Application.Id cat be consists of alpha-numeric, period, and dash characters"`
const message = `AppX Application.Id cat be consists of alpha-numeric and period"`
throw new InvalidConfigurationError(message)
} else if (restrictedApplicationIdValues.includes(result.toUpperCase())) {
const message = `AppX Application.Id cannot be some values`
Expand All @@ -243,8 +249,25 @@ export default class AppXTarget extends Target {
return result
}

case "identityName":
return options.identityName || appInfo.name
case "identityName": {
const result = options.identityName || appInfo.name
const validCharactersRegex = /^[a-zA-Z0-9.-]+$/
if (result.length < 3 || result.length > 50) {
const message = `Appx identityName.Id with a value between 3 and 50 characters in length`
throw new InvalidConfigurationError(message)
} else if (!validCharactersRegex.test(result)) {
const message = `AppX identityName.Id cat be consists of alpha-numeric, period, and dash characters"`
throw new InvalidConfigurationError(message)
} else if (restrictedApplicationIdValues.includes(result.toUpperCase())) {
const message = `AppX identityName.Id cannot be some values`
throw new InvalidConfigurationError(message)
} else if (result == null && options.identityName == null) {
const message = `Please set appx.identityName or name`
throw new InvalidConfigurationError(message)
}

return result
}

case "executable":
return executable
Expand Down

0 comments on commit b6f2499

Please sign in to comment.