Skip to content

Commit

Permalink
feat: relaxation of restrictions on project names(#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pengfei committed Jan 14, 2025
1 parent afdca85 commit 86070d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/create-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ async function init() {

let result = {};
const authorInfo = await getUser();
const transferName = toValidPackageName(defaultProjectName);
const transferName = defaultProjectName.replace('.', '-');

try {
result = await prompts(
Expand All @@ -262,7 +262,7 @@ async function init() {
projectName = state.value.trim() || transferName;
},
validate: (value) =>
isValidName(value) ? true : 'Please enter a valid project name, only a~z, A~Z, 0~9, - and _ are allowed.',
isValidName(value) ? true : 'Please enter a valid project name, the "." is not allowed.',
},
{
type: () => (!fs.existsSync(targetDir) || isEmpty(targetDir) ? null : 'confirm'),
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function copy(src, dest) {
}

export function isValidName(name) {
return /^[a-zA-Z0-9][-a-zA-Z0-9_]{2,128}$/.test(name);
return !name.includes('.');
}

export function isValidPackageName(projectName) {
Expand Down

0 comments on commit 86070d8

Please sign in to comment.