Skip to content

Commit

Permalink
fix(schematics): nested apps generation
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Dec 6, 2017
1 parent 013a828 commit 5a0a19a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
8 changes: 4 additions & 4 deletions e2e/schematics/application.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { newApp, newLib, newProject, runCLI, updateFile } from '../utils';

describe('Nrwl Workspace', () => {
it(
fit(
'should work',
() => {
newProject();
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

This file was deleted.

37 changes: 28 additions & 9 deletions packages/schematics/src/collection/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,33 @@ function addRouterRootConfiguration(path: string): Rule {
};
}

const staticComponentContent = `
<div style="text-align:center">
<h1>
Welcome to an Angular CLI app built with Nrwl Nx!
</h1>
<img width="300" src="assets/nx-logo.png">
</div>
<h2>Nx</h2>
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.
<h2>Quick Start & Documentation</h2>
<a href="https://nrwl.io/nx">Watch a 5-minute video on how to get started with Nx.</a>`;

function updateComponentTemplate(options: NormalizedSchema): Rule {
return (host: Tree) => {
const content = options.routing
? `${staticComponentContent}\n<router-outlet></router-outlet>`
: staticComponentContent;
host.overwrite(`${options.fullPath}/app/app.component.html`, content);
};
}

export default function(schema: Schema): Rule {
const options = normalizeOptions(schema);

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 5a0a19a

Please sign in to comment.