Skip to content

Replace regex with correct project name valdiation #18831

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 1 commit into from
Sep 23, 2020
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/angular/cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"projects": {
"type": "object",
"patternProperties": {
"^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$": {
"^(?:@[a-zA-Z0-9_-]+\/)?[a-zA-Z0-9_-]+$": {
"$ref": "#/definitions/project"
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/schematics/angular/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export default function (options: ApplicationOptions): Rule {
const isRootApp = options.projectRoot !== undefined;
const appDir = isRootApp
? normalize(options.projectRoot || '')
: join(normalize(newProjectRoot), options.name);
: join(normalize(newProjectRoot), strings.dasherize(options.name));
const sourceDir = `${appDir}/src/app`;

const e2eOptions: E2eOptions = {
Expand Down
16 changes: 16 additions & 0 deletions packages/schematics/angular/application/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,20 @@ describe('Application Schematic', () => {
expect(content).toContain('not IE 11');
expect(content).toContain('not IE 9-10');
});

it(`should create kebab-case project folder names with camelCase project name`, async () => {
const options: ApplicationOptions = { ...defaultOptions, name: 'myCool' };
const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree)
.toPromise();
const exists = tree.exists('/projects/my-cool/.browserslistrc');
expect(exists).toBeTrue();
});

it(`should create kebab-case project folder names with PascalCase project name`, async () => {
const options: ApplicationOptions = { ...defaultOptions, name: 'MyCool' };
const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree)
.toPromise();
const exists = tree.exists('/projects/my-cool/.browserslistrc');
expect(exists).toBeTrue();
});
});