Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit b94ccc5

Browse files
Broccohansl
authored andcommitted
fix(@schematics/angular): Update app schematic app component's template
1 parent 0470a36 commit b94ccc5

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!--The whole content below can be removed with the new code.-->
2+
<div style="text-align:center">
3+
<h1>
4+
Welcome to {{title}}!!
5+
</h1>
6+
<img width="300" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOS4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZpZXdCb3g9IjAgMCAyNTAgMjUwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNTAgMjUwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDojREQwMDMxO30NCgkuc3Qxe2ZpbGw6I0MzMDAyRjt9DQoJLnN0MntmaWxsOiNGRkZGRkY7fQ0KPC9zdHlsZT4NCjxnPg0KCTxwb2x5Z29uIGNsYXNzPSJzdDAiIHBvaW50cz0iMTI1LDMwIDEyNSwzMCAxMjUsMzAgMzEuOSw2My4yIDQ2LjEsMTg2LjMgMTI1LDIzMCAxMjUsMjMwIDEyNSwyMzAgMjAzLjksMTg2LjMgMjE4LjEsNjMuMiAJIi8+DQoJPHBvbHlnb24gY2xhc3M9InN0MSIgcG9pbnRzPSIxMjUsMzAgMTI1LDUyLjIgMTI1LDUyLjEgMTI1LDE1My40IDEyNSwxNTMuNCAxMjUsMjMwIDEyNSwyMzAgMjAzLjksMTg2LjMgMjE4LjEsNjMuMiAxMjUsMzAgCSIvPg0KCTxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik0xMjUsNTIuMUw2Ni44LDE4Mi42aDBoMjEuN2gwbDExLjctMjkuMmg0OS40bDExLjcsMjkuMmgwaDIxLjdoMEwxMjUsNTIuMUwxMjUsNTIuMUwxMjUsNTIuMUwxMjUsNTIuMQ0KCQlMMTI1LDUyLjF6IE0xNDIsMTM1LjRIMTA4bDE3LTQwLjlMMTQyLDEzNS40eiIvPg0KPC9nPg0KPC9zdmc+DQo=" />
7+
</div>
8+
<h2>Here are some links to help you start: </h2>
9+
<ul>
10+
<li>
11+
<h2><a target="_blank" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
12+
</li>
13+
<li>
14+
<h2><a target="_blank" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></h2>
15+
</li>
16+
<li>
17+
<h2><a target="_blank" href="http://angularjs.blogspot.ca/">Angular blog</a></h2>
18+
</li>
19+
</ul>
20+
<% if (routing) { %>
21+
<router-outlet></router-outlet><% } %>

packages/schematics/angular/angular-app/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// TODO: replace `options: any` with an actual type generated from the schema.
99
// tslint:disable:no-any
1010
import {
11+
MergeStrategy,
1112
Rule,
1213
Tree,
1314
apply,
@@ -76,5 +77,10 @@ export default function (options: any): Rule {
7677
flat: true,
7778
}),
7879
addBootstrapToNgModule(options.directory),
80+
mergeWith(
81+
apply(url('./helper-files'), [
82+
template({ utils: stringUtils, ...options }),
83+
move(options.directory + '/' + options.sourceDir + '/app'),
84+
]), MergeStrategy.Overwrite),
7985
]);
8086
};

packages/schematics/angular/component/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import * as stringUtils from '../strings';
2727

2828
import 'rxjs/add/operator/merge';
2929
import * as ts from 'typescript';
30-
import {buildRelativePath, findModule} from '../utility/find-module';
30+
import { buildRelativePath, findModule } from '../utility/find-module';
3131

3232

3333
function addDeclarationToNgModule(options: any): Rule {
@@ -36,7 +36,15 @@ function addDeclarationToNgModule(options: any): Rule {
3636
return host;
3737
}
3838

39-
const modulePath = findModule(host, options.sourceDir + '/' + options.path);
39+
let modulePath;
40+
if (options.module) {
41+
if (!host.exists(options.module)) {
42+
throw new Error(`Module specified (${options.module}) does not exist.`);
43+
}
44+
modulePath = options.module;
45+
} else {
46+
modulePath = findModule(host, options.sourceDir + '/' + options.path);
47+
}
4048

4149
const sourceText = host.read(modulePath) !.toString('utf-8');
4250
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);

packages/schematics/angular/component/schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@
6868
},
6969
"selector": {
7070
"type": "string"
71+
},
72+
"module": {
73+
"type": "string",
74+
"description": "Allows specification of the declaring module.",
75+
"alias": "m",
76+
"subtype": "filepath"
7177
}
7278
},
7379
"required": [

0 commit comments

Comments
 (0)