Skip to content

Commit

Permalink
Merge pull request #617 from liudonghua123/app_name_update
Browse files Browse the repository at this point in the history
update name of app validation
  • Loading branch information
Tlntin committed Dec 11, 2023
2 parents 2bd8d92 + 42251e4 commit f2f0742
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bin/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function resolveAppName(name: string, platform: NodeJS.Platform): string {
function isValidName(name: string, platform: NodeJS.Platform): boolean {
const platformRegexMapping: PlatformMap = {
linux: /^[a-z0-9]+(-[a-z0-9]+)*$/,
default: /^[a-zA-Z0-9]+$/,
default: /^[a-zA-Z0-9]+([-a-zA-Z0-9])*$/,
};
const reg = platformRegexMapping[platform] || platformRegexMapping.default;
return !!name && reg.test(name);
Expand All @@ -38,7 +38,7 @@ export default async function handleOptions(

if (!isValidName(name, platform)) {
const LINUX_NAME_ERROR = `✕ name should only include lowercase letters, numbers, and dashes, and must contain at least one lowercase letter. Examples: com-123-xxx, 123pan, pan123, weread, we-read.`;
const DEFAULT_NAME_ERROR = `✕ Name should only include letters and numbers, and must contain at least one letter. Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead.`;
const DEFAULT_NAME_ERROR = `✕ Name should only include letters and numbers, and dashes (dashes must not at the begining), and must contain at least one letter. Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead, we-read.`;
const errorMsg = platform === 'linux' ? LINUX_NAME_ERROR : DEFAULT_NAME_ERROR;
logger.error(errorMsg);
if (isActions) {
Expand Down
4 changes: 2 additions & 2 deletions dist/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ function resolveAppName(name, platform) {
function isValidName(name, platform) {
const platformRegexMapping = {
linux: /^[a-z0-9]+(-[a-z0-9]+)*$/,
default: /^[a-zA-Z0-9]+$/,
default: /^[a-zA-Z0-9]+([-a-zA-Z0-9])*$/,
};
const reg = platformRegexMapping[platform] || platformRegexMapping.default;
return !!name && reg.test(name);
Expand All @@ -964,7 +964,7 @@ async function handleOptions(options, url) {
}
if (!isValidName(name, platform)) {
const LINUX_NAME_ERROR = `✕ name should only include lowercase letters, numbers, and dashes, and must contain at least one lowercase letter. Examples: com-123-xxx, 123pan, pan123, weread, we-read.`;
const DEFAULT_NAME_ERROR = `✕ Name should only include letters and numbers, and must contain at least one letter. Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead.`;
const DEFAULT_NAME_ERROR = `✕ Name should only include letters and numbers, and dashes (dashes must not at the begining), and must contain at least one letter. Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead, we-read.`;
const errorMsg = platform === 'linux' ? LINUX_NAME_ERROR : DEFAULT_NAME_ERROR;
logger.error(errorMsg);
if (isActions) {
Expand Down

0 comments on commit f2f0742

Please sign in to comment.