Skip to content

Commit b1f95a8

Browse files
committed
feature(config): config inline template & style in angular-cli.json
Fixes angular#2447
1 parent 96d0659 commit b1f95a8

File tree

6 files changed

+32
-6
lines changed

6 files changed

+32
-6
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"test:cli": "node tests/runner",
2121
"test:inspect": "node --inspect --debug-brk tests/runner",
2222
"test:packages": "node scripts/run-packages-spec.js",
23-
"build-config-interface": "dtsgen lib/config/schema.json --out lib/config/schema.d.ts",
23+
"build-config-interface": "dtsgen packages/angular-cli/lib/config/schema.json --out packages/angular-cli/lib/config/schema.d.ts",
2424
"eslint": "eslint .",
2525
"tslint": "tslint \"**/*.ts\" -c tslint.json -e \"**/blueprints/*/files/**/*.ts\" -e \"node_modules/**\" -e \"tmp/**\" -e \"dist/**\"",
2626
"lint": "npm-run-all -c eslint tslint"

packages/angular-cli/addon/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ module.exports = {
88
name: 'ng2',
99

1010
config: function () {
11-
this.project.ngConfig = this.project.ngConfig || config.CliConfig.fromProject().config;
11+
this.project.ngConfigObj = this.project.ngConfigObj || config.CliConfig.fromProject();
12+
this.project.ngConfig = this.project.ngConfig || this.project.ngConfigObj.config;
1213
},
1314

1415
blueprintsPath: function () {

packages/angular-cli/blueprints/component/index.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ module.exports = {
1313

1414
availableOptions: [
1515
{ name: 'flat', type: Boolean, default: false },
16-
{ name: 'inline-template', type: Boolean, default: false, aliases: ['it'] },
17-
{ name: 'inline-style', type: Boolean, default: false, aliases: ['is'] },
16+
{ name: 'inline-template', type: Boolean, aliases: ['it'] },
17+
{ name: 'inline-style', type: Boolean, aliases: ['is'] },
1818
{ name: 'prefix', type: Boolean, default: true },
1919
{ name: 'spec', type: Boolean, default: true }
2020
],
@@ -56,6 +56,14 @@ module.exports = {
5656
this.styleExt = this.project.ngConfig.defaults.styleExt;
5757
}
5858

59+
options.inlineStyle = options.inlineStyle !== undefined ?
60+
options.inlineStyle :
61+
this.project.ngConfigObj.get('defaults.inline.style');
62+
63+
options.inlineTemplate = options.inlineTemplate !== undefined ?
64+
options.inlineTemplate :
65+
this.project.ngConfigObj.get('defaults.inline.template');
66+
5967
return {
6068
dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''),
6169
flat: options.flat,
@@ -71,7 +79,7 @@ module.exports = {
7179

7280
files: function() {
7381
var fileList = getFiles.call(this);
74-
82+
7583
if (this.options && this.options.inlineTemplate) {
7684
fileList = fileList.filter(p => p.indexOf('.html') < 0);
7785
}

packages/angular-cli/lib/config/schema.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,9 @@ export interface CliConfig {
6060
styleExt?: string;
6161
prefixInterfaces?: boolean;
6262
poll?: number;
63+
inline?: {
64+
style?: boolean;
65+
template?: boolean;
66+
};
6367
};
6468
}

packages/angular-cli/lib/config/schema.json

+13
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,19 @@
138138
},
139139
"poll": {
140140
"type": "number"
141+
},
142+
"inline": {
143+
"type": "object",
144+
"properties": {
145+
"style": {
146+
"type": "boolean",
147+
"default": false
148+
},
149+
"template": {
150+
"type": "boolean",
151+
"default": false
152+
}
153+
}
141154
}
142155
},
143156
"additionalProperties": false

packages/angular-cli/models/json-schema/schema-tree.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export abstract class LeafSchemaTreeNode<T> extends SchemaTreeNode<T> {
281281

282282
constructor(metaData: TreeNodeConstructorArgument<T>) {
283283
super(metaData);
284-
this._defined = metaData.value !== undefined;
284+
this._defined = !(metaData.value === undefined || metaData.value === null);
285285
if ('default' in metaData.schema) {
286286
this._default = metaData.schema['default'];
287287
}

0 commit comments

Comments
 (0)