From 7d611fc474e4c7ddb3a5549763e98359991deb6c Mon Sep 17 00:00:00 2001 From: vsavkin Date: Wed, 6 Dec 2017 17:37:34 -0500 Subject: [PATCH] fix(schematics): nested apps generation --- e2e/schematics/application.test.ts | 6 +-- .../app.component.html__tmpl__ | 18 --------- .../schematics/src/collection/app/index.ts | 37 ++++++++++++++----- 3 files changed, 31 insertions(+), 30 deletions(-) delete mode 100644 packages/schematics/src/collection/app/component-files/app.component.html__tmpl__ diff --git a/e2e/schematics/application.test.ts b/e2e/schematics/application.test.ts index 4d331bd8f2846..3929c40caa756 100644 --- a/e2e/schematics/application.test.ts +++ b/e2e/schematics/application.test.ts @@ -25,7 +25,7 @@ describe('Nrwl Workspace', () => { ` ); - runCLI('build --aot'); + runCLI('build --aot -a=my-dir/my-app'); expect(runCLI('test --single-run')).toContain('Executed 2 of 2 SUCCESS'); }, 1000000 @@ -38,7 +38,7 @@ describe('Nrwl Workspace', () => { newApp('myApp --directory=myDir --routing'); newLib('myLib --directory=myDir --routing --lazy --parentModule=apps/my-dir/my-app/src/app/app.module.ts'); - runCLI('build --aot'); + runCLI('build --aot -a=my-dir/my-app'); expect(runCLI('test --single-run')).toContain('Executed 2 of 2 SUCCESS'); }, 1000000 @@ -51,7 +51,7 @@ describe('Nrwl Workspace', () => { newApp('myApp --directory=myDir --routing'); newLib('myLib --directory=myDir --routing --parentModule=apps/my-dir/my-app/src/app/app.module.ts'); - runCLI('build --aot'); + runCLI('build --aot -a=my-dir/my-app'); expect(runCLI('test --single-run')).toContain('Executed 2 of 2 SUCCESS'); }, 1000000 diff --git a/packages/schematics/src/collection/app/component-files/app.component.html__tmpl__ b/packages/schematics/src/collection/app/component-files/app.component.html__tmpl__ deleted file mode 100644 index a828010fd628e..0000000000000 --- a/packages/schematics/src/collection/app/component-files/app.component.html__tmpl__ +++ /dev/null @@ -1,18 +0,0 @@ -
-

- Welcome to an Angular CLI app built with Nrwl Nx! -

- -
- -

Nx

- -An open source toolkit for enterprise Angular applications. - -Nx is designed to help you create and build enterprise grade Angular applications. It provides an opinionated approach to application project structure and patterns. - -

Quick Start & Documentation

- -Watch a 5-minute video on how to get started with Nx.<% if (routing) { %> - -<% } %> diff --git a/packages/schematics/src/collection/app/index.ts b/packages/schematics/src/collection/app/index.ts index d4b382a908b19..f7bbfa047f39d 100644 --- a/packages/schematics/src/collection/app/index.ts +++ b/packages/schematics/src/collection/app/index.ts @@ -114,6 +114,33 @@ function addRouterRootConfiguration(path: string): Rule { }; } +const staticComponentContent = ` +
+

+ Welcome to an Angular CLI app built with Nrwl Nx! +

+ +
+ +

Nx

+ +An open source toolkit for enterprise Angular applications. + +Nx is designed to help you create and build enterprise grade Angular applications. It provides an opinionated approach to application project structure and patterns. + +

Quick Start & Documentation

+ +Watch a 5-minute video on how to get started with Nx.`; + +function updateComponentTemplate(options: NormalizedSchema): Rule { + return (host: Tree) => { + const content = options.routing + ? `${staticComponentContent}\n` + : staticComponentContent; + host.overwrite(`${options.fullPath}/app/app.component.html`, content); + }; +} + export default function(schema: Schema): Rule { const options = normalizeOptions(schema); @@ -144,15 +171,7 @@ export default function(schema: Schema): Rule { viewEncapsulation: options.viewEncapsulation, changeDetection: options.changeDetection }), - - mergeWith( - apply(url('./component-files'), [ - options.inlineTemplate ? filter(path => !path.endsWith('.html')) : noop(), - template({ ...options, tmpl: '' }), - move(`${options.fullPath}/app`) - ]), - MergeStrategy.Overwrite - ), + updateComponentTemplate(options), addBootstrap(options.fullPath), addNxModule(options.fullPath), addAppToAngularCliJson(options),