Skip to content

fix!: keep project name validation rules in sync between UI and CLI #6443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@vue/cli-ui/apollo-server/connectors/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ async function create (input, context) {
creator.context = targetDir

const inCurrent = input.folder === '.'
const name = creator.name = (inCurrent ? path.relative('../', process.cwd()) : input.folder).toLowerCase()
const name = creator.name = (inCurrent ? path.relative('../', process.cwd()) : input.folder)

// Answers
const answers = prompts.getAnswers()
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"stylus": "^0.54.5",
"stylus-loader": "^5.0.0",
"subscriptions-transport-ws": "^0.9.18",
"validate-npm-package-name": "^3.0.0",
"vue": "^2.6.12",
"vue-apollo": "^3.0.7",
"vue-cli-plugin-apollo": "^0.22.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
class="vue-ui-text danger banner"
>
<VueIcon icon="error" class="big"/>
<span>{{ $t('org.vue.views.project-create.tabs.details.form.folder.folder-name-invalid') }}</span>
<span>
{{ $t('org.vue.views.project-create.tabs.details.form.folder.folder-name-invalid') }}:
{{ folderNameValidationMessage }}
</span>
</div>

<ApolloQuery
Expand Down Expand Up @@ -463,7 +466,7 @@

<script>
import Prompts from '@/mixins/Prompts'
import { isValidName } from '@/util/folders'
import validateNpmPackageName from 'validate-npm-package-name'
import debounce from 'lodash.debounce'

import CWD from '@/graphql/cwd/cwd.gql'
Expand Down Expand Up @@ -534,8 +537,21 @@ export default {
},

computed: {
folderNameValidationResult () {
return validateNpmPackageName(this.formData.folder)
},

folderNameValid () {
return isValidName(this.formData.folder)
return this.folderNameValidationResult.validForNewPackages
},

folderNameValidationMessage () {
const messages = [
...(this.folderNameValidationResult.errors || []),
...(this.folderNameValidationResult.warnings || [])
]

return messages[0]
},

detailsValid () {
Expand Down