Skip to content

Commit

Permalink
fix(misc): do not normalize project name and root when using as-provi…
Browse files Browse the repository at this point in the history
…ded format (#19651)
  • Loading branch information
leosvelperez authored Oct 17, 2023
1 parent 05e814f commit 81e8d12
Show file tree
Hide file tree
Showing 24 changed files with 397 additions and 387 deletions.
4 changes: 2 additions & 2 deletions e2e/angular-core/src/projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ describe('Angular Projects', () => {
it('should successfully generate apps and libs and work correctly', async () => {
const standaloneApp = uniq('standalone-app');
runCLI(
`generate @nx/angular:app ${standaloneApp} --directory=myDir/${standaloneApp} --standalone=true --project-name-and-root-format=as-provided --no-interactive`
`generate @nx/angular:app ${standaloneApp} --directory=my-dir/${standaloneApp} --standalone=true --project-name-and-root-format=as-provided --no-interactive`
);

const esbuildApp = uniq('esbuild-app');
runCLI(
`generate @nx/angular:app ${esbuildApp} --bundler=esbuild --directory=myDir/${esbuildApp} --project-name-and-root-format=as-provided --no-interactive`
`generate @nx/angular:app ${esbuildApp} --bundler=esbuild --directory=my-dir/${esbuildApp} --project-name-and-root-format=as-provided --no-interactive`
);

updateFile(
Expand Down
58 changes: 29 additions & 29 deletions packages/angular/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('app', () => {

it('should update tags + implicit dependencies', async () => {
// ACT
await generateApp(appTree, 'myApp', { tags: 'one,two,my-app' });
await generateApp(appTree, 'my-app', { tags: 'one,two,my-app' });

// ASSERT
const projects = devkit.getProjects(appTree);
Expand Down Expand Up @@ -193,14 +193,14 @@ describe('app', () => {

describe('nested', () => {
it('should create project configs', async () => {
await generateApp(appTree, 'myApp', { directory: 'myDir/myApp' });
await generateApp(appTree, 'my-app', { directory: 'my-dir/my-app' });
expect(readProjectConfiguration(appTree, 'my-app')).toMatchSnapshot();
expect(readProjectConfiguration(appTree, 'my-app-e2e')).toMatchSnapshot();
});

it('should update tags + implicit dependencies', async () => {
await generateApp(appTree, 'myApp', {
directory: 'myDir/myApp',
await generateApp(appTree, 'my-app', {
directory: 'my-dir/my-app',
tags: 'one,two,my-app',
});
const projects = devkit.getProjects(appTree);
Expand All @@ -225,7 +225,7 @@ describe('app', () => {

expect(lookupFn(content)).toEqual(expectedValue);
};
await generateApp(appTree, 'myApp', { directory: 'myDir/myApp' });
await generateApp(appTree, 'my-app', { directory: 'my-dir/my-app' });

const appModulePath = 'my-dir/my-app/src/app/app.module.ts';
expect(appTree.read(appModulePath, 'utf-8')).toContain('class AppModule');
Expand Down Expand Up @@ -267,7 +267,7 @@ describe('app', () => {

it('should extend from tsconfig.base.json', async () => {
// ACT
await generateApp(appTree, 'app', { directory: 'myDir/app' });
await generateApp(appTree, 'app', { directory: 'my-dir/app' });

// ASSERT
const appTsConfig = readJson(appTree, 'my-dir/app/tsconfig.json');
Expand All @@ -279,7 +279,7 @@ describe('app', () => {
appTree.rename('tsconfig.base.json', 'tsconfig.json');

// ACT
await generateApp(appTree, 'app', { directory: 'myDir/app' });
await generateApp(appTree, 'app', { directory: 'my-dir/app' });

// ASSERT
const appTsConfig = readJson(appTree, 'my-dir/app/tsconfig.json');
Expand All @@ -298,7 +298,7 @@ describe('app', () => {

it('should accept numbers in the path', async () => {
// ACT
await generateApp(appTree, 'myApp', {
await generateApp(appTree, 'my-app', {
directory: 'src/9-websites/my-app',
});

Expand All @@ -315,7 +315,7 @@ describe('app', () => {

expect(lookupFn(content)).toEqual(expectedValue);
};
await generateApp(appTree, 'myApp', { directory: 'myDir/myApp' });
await generateApp(appTree, 'my-app', { directory: 'my-dir/my-app' });

const appModulePath = 'my-dir/my-app/src/app/app.module.ts';
expect(appTree.read(appModulePath, 'utf-8')).toContain('class AppModule');
Expand Down Expand Up @@ -358,8 +358,8 @@ describe('app', () => {

describe('routing', () => {
it('should include RouterTestingModule', async () => {
await generateApp(appTree, 'myApp', {
directory: 'myDir/myApp',
await generateApp(appTree, 'my-app', {
directory: 'my-dir/my-app',
routing: true,
});
expect(
Expand All @@ -371,8 +371,8 @@ describe('app', () => {
});

it('should not modify tests when --skip-tests is set', async () => {
await generateApp(appTree, 'myApp', {
directory: 'myDir/myApp',
await generateApp(appTree, 'my-app', {
directory: 'my-dir/my-app',
routing: true,
skipTests: true,
});
Expand All @@ -384,15 +384,15 @@ describe('app', () => {

describe('template generation mode', () => {
it('should create Nx specific `app.component.html` template', async () => {
await generateApp(appTree, 'myApp', { directory: 'myDir/myApp' });
await generateApp(appTree, 'my-app', { directory: 'my-dir/my-app' });
expect(
appTree.read('my-dir/my-app/src/app/app.component.html', 'utf-8')
).toContain('<proj-nx-welcome></proj-nx-welcome>');
});

it("should update `template`'s property of AppComponent with Nx content", async () => {
await generateApp(appTree, 'myApp', {
directory: 'myDir/myApp',
await generateApp(appTree, 'my-app', {
directory: 'my-dir/my-app',
inlineTemplate: true,
});
expect(
Expand All @@ -401,15 +401,15 @@ describe('app', () => {
});

it('should create Nx specific `nx-welcome.component.ts` file', async () => {
await generateApp(appTree, 'myApp', { directory: 'myDir/myApp' });
await generateApp(appTree, 'my-app', { directory: 'my-dir/my-app' });
expect(
appTree.read('my-dir/my-app/src/app/nx-welcome.component.ts', 'utf-8')
).toContain('Hello there');
});

it('should update the AppComponent spec to target Nx content', async () => {
await generateApp(appTree, 'myApp', {
directory: 'myDir/myApp',
await generateApp(appTree, 'my-app', {
directory: 'my-dir/my-app',
inlineTemplate: true,
});
const testFileContent = appTree.read(
Expand All @@ -424,21 +424,21 @@ describe('app', () => {

describe('--style scss', () => {
it('should generate scss styles', async () => {
await generateApp(appTree, 'myApp', { style: 'scss' });
await generateApp(appTree, 'my-app', { style: 'scss' });
expect(appTree.exists('my-app/src/app/app.component.scss')).toEqual(true);
});
});

describe('--style sass', () => {
it('should generate sass styles', async () => {
await generateApp(appTree, 'myApp', { style: 'sass' });
await generateApp(appTree, 'my-app', { style: 'sass' });
expect(appTree.exists('my-app/src/app/app.component.sass')).toEqual(true);
});
});

describe('--style less', () => {
it('should generate less styles', async () => {
await generateApp(appTree, 'myApp', { style: 'less' });
await generateApp(appTree, 'my-app', { style: 'less' });
expect(appTree.exists('my-app/src/app/app.component.less')).toEqual(true);
});
});
Expand All @@ -458,7 +458,7 @@ describe('app', () => {
xit('should skip format when set to true', async () => {
const spy = jest.spyOn(devkit, 'formatFiles');

await generateApp(appTree, 'myApp', { skipFormat: true });
await generateApp(appTree, 'my-app', { skipFormat: true });

expect(spy).not.toHaveBeenCalled();
});
Expand All @@ -467,7 +467,7 @@ describe('app', () => {
describe('--linter', () => {
describe('eslint', () => {
it('should add lint target', async () => {
await generateApp(appTree, 'myApp', { linter: Linter.EsLint });
await generateApp(appTree, 'my-app', { linter: Linter.EsLint });
expect(readProjectConfiguration(appTree, 'my-app').targets.lint)
.toMatchInlineSnapshot(`
{
Expand Down Expand Up @@ -500,7 +500,7 @@ describe('app', () => {
});

it('should add valid eslint JSON configuration which extends from Nx presets', async () => {
await generateApp(appTree, 'myApp', { linter: Linter.EsLint });
await generateApp(appTree, 'my-app', { linter: Linter.EsLint });

const eslintConfig = readJson(appTree, 'my-app/.eslintrc.json');
expect(eslintConfig).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -556,7 +556,7 @@ describe('app', () => {

describe('none', () => {
it('should add no lint target', async () => {
await generateApp(appTree, 'myApp', { linter: Linter.None });
await generateApp(appTree, 'my-app', { linter: Linter.None });
expect(
readProjectConfiguration(appTree, 'my-app').targets.lint
).toBeUndefined();
Expand Down Expand Up @@ -594,7 +594,7 @@ describe('app', () => {

describe('none', () => {
it('should not generate test configuration', async () => {
await generateApp(appTree, 'myApp', {
await generateApp(appTree, 'my-app', {
unitTestRunner: UnitTestRunner.None,
});
expect(appTree.exists('my-app/src/test-setup.ts')).toBeFalsy();
Expand All @@ -620,7 +620,7 @@ describe('app', () => {
describe('--e2e-test-runner', () => {
describe('none', () => {
it('should not generate test configuration', async () => {
await generateApp(appTree, 'myApp', {
await generateApp(appTree, 'my-app', {
e2eTestRunner: E2eTestRunner.None,
});
expect(appTree.exists('my-app-e2e')).toBeFalsy();
Expand Down Expand Up @@ -1083,7 +1083,7 @@ describe('app', () => {

async function generateApp(
appTree: Tree,
name: string = 'myApp',
name: string = 'my-app',
options: Partial<Schema> = {}
) {
await generateTestApplication(appTree, {
Expand Down
16 changes: 8 additions & 8 deletions packages/angular/src/generators/host/host.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Host App Generator', () => {
// ACT

await generateTestHostApplication(tree, {
name: 'hostApp',
name: 'host-app',
remotes: ['remote1', 'remote2'],
typescriptConfiguration: false,
});
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('Host App Generator', () => {
// ACT

await generateTestHostApplication(tree, {
name: 'hostApp',
name: 'host-app',
remotes: ['remote1', 'remote2'],
typescriptConfiguration: true,
});
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('Host App Generator', () => {

// ACT
await generateTestHostApplication(tree, {
name: 'hostApp',
name: 'host-app',
remotes: ['remote1', 'remote2', 'remote3'],
typescriptConfiguration: false,
});
Expand All @@ -173,7 +173,7 @@ describe('Host App Generator', () => {

// ACT
await generateTestHostApplication(tree, {
name: 'hostApp',
name: 'host-app',
remotes: ['remote1', 'remote2', 'remote3'],
typescriptConfiguration: true,
});
Expand All @@ -197,8 +197,8 @@ describe('Host App Generator', () => {

// ACT
await generateTestHostApplication(tree, {
name: 'hostApp',
directory: 'foo/hostApp',
name: 'host-app',
directory: 'foo/host-app',
remotes: ['remote1', 'remote2', 'remote3'],
typescriptConfiguration: false,
});
Expand All @@ -222,8 +222,8 @@ describe('Host App Generator', () => {

// ACT
await generateTestHostApplication(tree, {
name: 'hostApp',
directory: 'foo/hostApp',
name: 'host-app',
directory: 'foo/host-app',
remotes: ['remote1', 'remote2', 'remote3'],
typescriptConfiguration: true,
});
Expand Down
Loading

0 comments on commit 81e8d12

Please sign in to comment.