Skip to content
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

Regex expression in 1.0.0-beta-24 disallows multiple dashes in project name #3680

Closed
ggoodfrd opened this issue Dec 21, 2016 · 5 comments
Closed

Comments

@ggoodfrd
Copy link

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Windows 7

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
angular-cli: 1.0.0-beta.24
node: 7.2.1
os: win32 x64

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
Issue detected on creation of a default project using ng new

The log given by the failure.

Normally this include a stack trace and some more information.
Project name "cli-beta-24-base" is not valid. New project names must start with a letter, and must contain only alphanumeric characters or dashes.

Mention any other details that might be useful.

After installing any new build of angular-cli I always create a default project in a sandbox folder. I use the new build as a base for diffing changes to previous versions and to the app I'm developing. Using beta.24 the regex expression disallows the naming convention I've been able to use without issue up through beta-22.

The project name I tried to use this time:
cli-beta-24-base

Please see line 40 of https://github.com/angular/angular-cli/blob/master/packages/angular-cli/commands/new.ts

The regex expression there shows:
/^[a-zA-Z][.0-9a-zA-Z](-[a-zA-Z][.0-9a-zA-Z])*$/

This appears to have been introduced as part of this fix:
#3478

From my experimentation, it appears that the dash in the capture group might be misplaced. The beta.24 regex only seems to allow one occurrence of the dash within the entire name. By moving the dash to the later character set listed in appears to correct the situation and allow multiple dashes within the project name.

An expression that appears to work properly:
/^[a-zA-Z][.0-9a-zA-Z]([a-zA-Z][-.0-9a-zA-Z])*$/

That's about it. It's a minor issue but perhaps this could be addressed in an upcoming build. Thanks for all of the great work!


Thanks! We'll be in touch soon.

@hansl
Copy link
Contributor

hansl commented Dec 21, 2016

You misunderstood my RegExp; it does not allow to have a substring that is just numbers. Which I think is fair.

Your project name contains -24-. That is not valid as an element selector in HTML, but we actually don't use the project name as the selector (we use app-root). We'll discuss internally if we want this to be fixed.

Your regex is wrong in many other ways, btw:

  • a.b- is not a valid project name nor should it be, but would pass your regex.
  • a-b is a valid project name but would fail your regex.

@ggoodfrd
Copy link
Author

This is my very first attempt at documenting an issue on a project like this...on a minor issue, so that I become familiar with the bug-reporting process and can contribute more effectively in the future. I appreciate the feedback. This is not a show-stopper by any means, just a "bump in the road" on a simple workflow I'd become used to.

I'm not a RegEx expert by any means and my attempt at the expression appeared to work in the testing tool I was using, but perhaps isn't a full representation of the naming convention the team is trying to uphold. At a minimum, perhaps a minor tweak of the error message would suffice for any other users that may attempt to use a similar naming convention to mine. Maybe state that only one dash is permitted instead of the plural inferred in the current message. Showing 2 or 3 examples of valid, slightly "complex" names in the error message may improve it as well.

"New project names must start with a letter, and must contain only alphanumeric characters or dashes."

@becke-ch-subscribe-s0v1
Copy link

Is there a good reason (technical limitation?) to have such a restriction on the project name?

@filipesilva
Copy link
Contributor

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants