feat(frontend): generate NxModule only when generating NgRx
This commit is contained in:
parent
ddf7afb219
commit
36b8ff9c94
@ -236,17 +236,6 @@ describe('app', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should import NgModule', async () => {
|
|
||||||
const tree = await runSchematic(
|
|
||||||
'app',
|
|
||||||
{ name: 'myApp', directory: 'myDir' },
|
|
||||||
appTree
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
getFileContent(tree, 'apps/my-dir/my-app/src/app/app.module.ts')
|
|
||||||
).toContain('NxModule.forRoot()');
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('routing', () => {
|
describe('routing', () => {
|
||||||
it('should include RouterTestingModule', async () => {
|
it('should include RouterTestingModule', async () => {
|
||||||
const tree = await runSchematic(
|
const tree = await runSchematic(
|
||||||
|
|||||||
@ -44,24 +44,6 @@ interface NormalizedSchema extends Schema {
|
|||||||
parsedTags: string[];
|
parsedTags: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNxModule(options: NormalizedSchema): Rule {
|
|
||||||
return (host: Tree) => {
|
|
||||||
const modulePath = `${options.appProjectRoot}/src/app/app.module.ts`;
|
|
||||||
const moduleSource = host.read(modulePath)!.toString('utf-8');
|
|
||||||
const sourceFile = ts.createSourceFile(
|
|
||||||
modulePath,
|
|
||||||
moduleSource,
|
|
||||||
ts.ScriptTarget.Latest,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
insert(host, modulePath, [
|
|
||||||
insertImport(sourceFile, modulePath, 'NxModule', '@nrwl/nx'),
|
|
||||||
...addImportToModule(sourceFile, modulePath, 'NxModule.forRoot()')
|
|
||||||
]);
|
|
||||||
return host;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function addRouterRootConfiguration(options: NormalizedSchema): Rule {
|
function addRouterRootConfiguration(options: NormalizedSchema): Rule {
|
||||||
return (host: Tree) => {
|
return (host: Tree) => {
|
||||||
const modulePath = `${options.appProjectRoot}/src/app/app.module.ts`;
|
const modulePath = `${options.appProjectRoot}/src/app/app.module.ts`;
|
||||||
@ -379,7 +361,6 @@ export default function(schema: Schema): Rule {
|
|||||||
updateProject(options),
|
updateProject(options),
|
||||||
|
|
||||||
updateComponentTemplate(options),
|
updateComponentTemplate(options),
|
||||||
addNxModule(options),
|
|
||||||
options.routing ? addRouterRootConfiguration(options) : noop(),
|
options.routing ? addRouterRootConfiguration(options) : noop(),
|
||||||
options.unitTestRunner === 'jest'
|
options.unitTestRunner === 'jest'
|
||||||
? schematic('jest-project', {
|
? schematic('jest-project', {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user