Validate site name on init command #264
Merged
+9
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- Summary
When creating a new site using the web UI, the site name is subject to a validation rule that allows only alphanumeric characters and hyphens. The same doesn't happen when using the
netlify init
command in the CLI. This PR addresses that by introducing a validation rule with the same regular expression used in the web flow.I've also added a few cosmetic changes to some user-facing messages in the
init
command, to make words like Netlify and GitHub capitalized in a consistent manner. I'm more than happy to make this a different PR (or discard it altogether), if you prefer.- Test plan
I started writing an integration test, but then I saw that there is a big change to the testing architecture underway in #254. I didn't want to create possible merge conflicts, so I've refrained from committing the tests for now. Happy to revisit.
The change makes use of inquirer's validate method, which displays an error when the user tries to input an invalid value.
The error message is consistent with the instructions shown in the web UI.
- Description for the changelog
Validates site name on init command. Closes #211.
- A picture of a cute animal (not mandatory but encouraged)