fix(new-design): Changed design name acceptable characters
This commit is contained in:
parent
9542b192f7
commit
c61de2da13
2 changed files with 8 additions and 6 deletions
|
@ -49,8 +49,9 @@ export const checkNodeVersion = () => {
|
|||
|
||||
// Helper method to validate the design name
|
||||
const validateDesignName = (name) => {
|
||||
if (/^([a-z]+)$/.test(name)) return true
|
||||
else return ' 🙈 Please use only [a-z], no spaces, no capitals, no nothing 🤷'
|
||||
if (/^([a-z0-9][a-z0-9_\-]*)$/.test(name)) return true
|
||||
else
|
||||
return ' 🙈 Please use only lowercase letters, digits, underscores, and hyphens. Names must start with a lowercase letter or digit. 🤷'
|
||||
}
|
||||
|
||||
// Gets user input to figure out what to do
|
||||
|
@ -106,7 +107,7 @@ export const getChoices = async () => {
|
|||
await prompts({
|
||||
type: 'text',
|
||||
name: 'name',
|
||||
message: 'What name would you like the design to have? 🏷️ ([a-z] only)',
|
||||
message: 'What name would you like the design to have? 🏷️ ([a-z0-9_-] only)',
|
||||
validate: validateDesignName,
|
||||
})
|
||||
).name
|
||||
|
|
|
@ -85,7 +85,7 @@ async function addDesign() {
|
|||
const { name } = await prompts({
|
||||
type: 'text',
|
||||
name: 'name',
|
||||
message: 'What name would you like the design to have? ([a-z] only)',
|
||||
message: 'What name would you like the design to have? ([a-z0-9_-] only)',
|
||||
validate: validateDesignName,
|
||||
})
|
||||
|
||||
|
@ -223,8 +223,9 @@ function validateDesignName(name) {
|
|||
)
|
||||
return `Sorry but ${name} is already taken so you'll need to pick something else`
|
||||
|
||||
if (/^([a-z]+)$/.test(name)) return true
|
||||
else return ' 🙈 Please use only [a-z], no spaces, no capitals, no nothing 🤷'
|
||||
if (/^([a-z0-9][a-z0-9_\-]*)$/.test(name)) return true
|
||||
else
|
||||
return ' 🙈 Please use only lowercase letters, digits, underscores, and hyphens. Names must start with a lowercase letter or digit. 🤷'
|
||||
}
|
||||
|
||||
function validatePluginName(name) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue