close
The Wayback Machine - https://web.archive.org/web/20201023165618/https://github.com/santoshyadavdev/angular-cli/commit/a5fa1ecd97ba1af0cb9903a61e9141a42da76982
Skip to content
Permalink
Browse files

fix(@schematics/angular): add appDir option

  • Loading branch information
santoshyadavdev committed Jun 3, 2020
1 parent fdfea58 commit a5fa1ecd97ba1af0cb9903a61e9141a42da76982
@@ -237,7 +237,8 @@ function addServerRoutes(options: AppShellOptions): Rule {
if (!clientServerOptions) {
throw new SchematicsException('Server target does not contain options.');
}
const modulePath = getServerModulePath(host, clientProject.sourceRoot || 'src', options.main as string);
const serverPath = clientProject.sourceRoot || 'src';
const modulePath = getServerModulePath(host, `${serverPath}/${options.appDir}` , options.main as string);
if (modulePath === null) {
throw new SchematicsException('Universal/server module not found.');
}
@@ -198,4 +198,16 @@ describe('App Shell Schematic', () => {
const content = tree.readContent('/projects/bar/src/app/app.server.module.ts');
expect(content).toMatch(/app\-shell\.component/);
});

it('should create the shell component with appDir option provided', async () => {
const defaultOptions: AppShellOptions = {
clientProject: 'bar',
appDir: 'app/server',
};
const tree = await schematicRunner.runSchematicAsync('appShell', defaultOptions, appTree)
.toPromise();
expect(tree.exists('/projects/bar/src/app/app-shell/app-shell.component.ts')).toBe(true);
const content = tree.readContent('/projects/bar/src/app/server/app.server.module.ts');
expect(content).toMatch(/app\-shell\.component/);
});
});
@@ -11,5 +11,5 @@ if (environment.production) {
enableProdMode();
}

export { <%= rootModuleClassName %> } from './app/<%= stripTsExtension(rootModuleFileName) %>';
export { <%= rootModuleClassName %> } from './<%= appDir %><%= '/' + stripTsExtension(rootModuleFileName) %>';
export { renderModule, renderModuleFactory } from '@angular/platform-server';
@@ -276,4 +276,15 @@ describe('Universal Schematic', () => {
{ path: './tsconfig.server.json' },
]);
});

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

0 comments on commit a5fa1ec

Please sign in to comment.
You can’t perform that action at this time.