Skip to content

Commit

Permalink
fix(@schematics/angular): rename app.server.module.ts to `app.modul…
Browse files Browse the repository at this point in the history
…e.server.ts`

This fixes an issue were we generated files using inconsistent names example `app.server.module.ts` and `app.config.server.ts`.

(cherry picked from commit 603d24f)
  • Loading branch information
alan-agius4 committed Apr 25, 2023
1 parent eca366a commit 0d58f73
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('AppShell Builder', () => {
})
export class AppModule { }
`,
'src/app/app.server.module.ts': `
'src/app/app.module.server.ts': `
import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* found in the LICENSE file at https://angular.io/license
*/

export { AppServerModule } from './app/app.server.module';
export { AppServerModule } from './app/app.module.server';
12 changes: 6 additions & 6 deletions packages/schematics/angular/app-shell/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('App Shell Schematic', () => {

it('should add a universal app', async () => {
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
const filePath = '/projects/bar/src/app/app.server.module.ts';
const filePath = '/projects/bar/src/app/app.module.server.ts';
expect(tree.exists(filePath)).toEqual(true);
});

Expand Down Expand Up @@ -145,7 +145,7 @@ describe('App Shell Schematic', () => {

it('should add router imports to server module', async () => {
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
const filePath = '/projects/bar/src/app/app.server.module.ts';
const filePath = '/projects/bar/src/app/app.module.server.ts';
const content = tree.readContent(filePath);
expect(content).toMatch(/import { Routes, RouterModule } from '@angular\/router';/);
});
Expand All @@ -158,21 +158,21 @@ describe('App Shell Schematic', () => {
appTree.overwrite('angular.json', JSON.stringify(workspace, undefined, 2));

tree = await schematicRunner.runSchematic('app-shell', defaultOptions, tree);
const filePath = '/projects/bar/src/app/app.server.module.ts';
const filePath = '/projects/bar/src/app/app.module.server.ts';
const content = tree.readContent(filePath);
expect(content).toMatch(/import { Routes, RouterModule } from '@angular\/router';/);
});

it('should define a server route', async () => {
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
const filePath = '/projects/bar/src/app/app.server.module.ts';
const filePath = '/projects/bar/src/app/app.module.server.ts';
const content = tree.readContent(filePath);
expect(content).toMatch(/const routes: Routes = \[/);
});

it('should import RouterModule with forRoot', async () => {
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
const filePath = '/projects/bar/src/app/app.server.module.ts';
const filePath = '/projects/bar/src/app/app.module.server.ts';
const content = tree.readContent(filePath);
expect(content).toMatch(
/const routes: Routes = \[ { path: 'shell', component: AppShellComponent }\];/,
Expand All @@ -183,7 +183,7 @@ describe('App Shell Schematic', () => {
it('should create the shell component', async () => {
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
expect(tree.exists('/projects/bar/src/app/app-shell/app-shell.component.ts')).toBe(true);
const content = tree.readContent('/projects/bar/src/app/app.server.module.ts');
const content = tree.readContent('/projects/bar/src/app/app.module.server.ts');
expect(content).toMatch(/app-shell\.component/);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/schematics/angular/app-shell/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"rootModuleFileName": {
"type": "string",
"description": "The name of the root module file",
"default": "app.server.module.ts"
"default": "app.module.server.ts"
},
"rootModuleClassName": {
"type": "string",
Expand Down
6 changes: 3 additions & 3 deletions packages/schematics/angular/universal/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Universal Schematic', () => {

it('should create a root module file', async () => {
const tree = await schematicRunner.runSchematic('universal', defaultOptions, appTree);
const filePath = '/projects/bar/src/app/app.server.module.ts';
const filePath = '/projects/bar/src/app/app.module.server.ts';
expect(tree.exists(filePath)).toEqual(true);
});

Expand All @@ -76,7 +76,7 @@ describe('Universal Schematic', () => {
const filePath = '/projects/bar/src/main.server.ts';
expect(tree.exists(filePath)).toEqual(true);
const contents = tree.readContent(filePath);
expect(contents).toMatch(/export { AppServerModule } from '\.\/app\/app\.server\.module'/);
expect(contents).toMatch(/export { AppServerModule } from '\.\/app\/app\.module\.server'/);
});

it('should create a tsconfig file for the workspace project', async () => {
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('Universal Schematic', () => {
defaultStandaloneOptions,
appTree,
);
const filePath = '/projects/baz/src/app/app.server.module.ts';
const filePath = '/projects/baz/src/app/app.module.server.ts';
expect(tree.exists(filePath)).toEqual(false);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/schematics/angular/universal/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"type": "string",
"format": "path",
"description": "The name of the root NgModule file.",
"default": "app.server.module.ts"
"default": "app.module.server.ts"
},
"rootModuleClassName": {
"type": "string",
Expand Down

0 comments on commit 0d58f73

Please sign in to comment.