Skip to content

Commit ed6aeea

Browse files
Jefioziemgechev
authored andcommitted
fix(@angular/cli): replace regex with correct project name validation
Closes #17579
1 parent 4b0e4bf commit ed6aeea

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

packages/angular/cli/lib/config/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"projects": {
2828
"type": "object",
2929
"patternProperties": {
30-
"^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$": {
30+
"^(?:@[a-zA-Z0-9_-]+\/)?[a-zA-Z0-9_-]+$": {
3131
"$ref": "#/definitions/project"
3232
}
3333
},

packages/schematics/angular/application/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ export default function (options: ApplicationOptions): Rule {
301301
const isRootApp = options.projectRoot !== undefined;
302302
const appDir = isRootApp
303303
? normalize(options.projectRoot || '')
304-
: join(normalize(newProjectRoot), options.name);
304+
: join(normalize(newProjectRoot), strings.dasherize(options.name));
305305
const sourceDir = `${appDir}/src/app`;
306306

307307
const e2eOptions: E2eOptions = {

packages/schematics/angular/application/index_spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,20 @@ describe('Application Schematic', () => {
451451
expect(content).toContain('not IE 11');
452452
expect(content).toContain('not IE 9-10');
453453
});
454+
455+
it(`should create kebab-case project folder names with camelCase project name`, async () => {
456+
const options: ApplicationOptions = { ...defaultOptions, name: 'myCool' };
457+
const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree)
458+
.toPromise();
459+
const exists = tree.exists('/projects/my-cool/.browserslistrc');
460+
expect(exists).toBeTrue();
461+
});
462+
463+
it(`should create kebab-case project folder names with PascalCase project name`, async () => {
464+
const options: ApplicationOptions = { ...defaultOptions, name: 'MyCool' };
465+
const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree)
466+
.toPromise();
467+
const exists = tree.exists('/projects/my-cool/.browserslistrc');
468+
expect(exists).toBeTrue();
469+
});
454470
});

0 commit comments

Comments
 (0)