From 1008b93836c82e597c1cf76cc4136b46a2444a22 Mon Sep 17 00:00:00 2001 From: Mike Brocchi Date: Sat, 1 Oct 2016 01:27:46 -0400 Subject: [PATCH] feature(config): config inline template & style in angular-cli.json Fixes #2447 --- package.json | 2 +- packages/angular-cli/addon/index.js | 3 ++- packages/angular-cli/blueprints/component/index.js | 12 ++++++++++-- packages/angular-cli/lib/config/schema.d.ts | 4 ++++ packages/angular-cli/lib/config/schema.json | 13 +++++++++++++ .../angular-cli/models/json-schema/schema-tree.ts | 2 +- 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4fea554a5c1c..8a11064fddad 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test:cli": "node tests/runner", "test:inspect": "node --inspect --debug-brk tests/runner", "test:packages": "node scripts/run-packages-spec.js", - "build-config-interface": "dtsgen lib/config/schema.json --out lib/config/schema.d.ts", + "build-config-interface": "dtsgen packages/angular-cli/lib/config/schema.json --out packages/angular-cli/lib/config/schema.d.ts", "eslint": "eslint .", "tslint": "tslint \"**/*.ts\" -c tslint.json -e \"**/blueprints/*/files/**/*.ts\" -e \"node_modules/**\" -e \"tmp/**\" -e \"dist/**\"", "lint": "npm-run-all -c eslint tslint" diff --git a/packages/angular-cli/addon/index.js b/packages/angular-cli/addon/index.js index 13056bc09538..3a2d7abb1850 100644 --- a/packages/angular-cli/addon/index.js +++ b/packages/angular-cli/addon/index.js @@ -8,7 +8,8 @@ module.exports = { name: 'ng2', config: function () { - this.project.ngConfig = this.project.ngConfig || config.CliConfig.fromProject().config; + this.project.ngConfigObj = this.project.ngConfigObj || config.CliConfig.fromProject(); + this.project.ngConfig = this.project.ngConfig || this.project.ngConfigObj.config; }, blueprintsPath: function () { diff --git a/packages/angular-cli/blueprints/component/index.js b/packages/angular-cli/blueprints/component/index.js index e037aa260839..39243e1eb508 100644 --- a/packages/angular-cli/blueprints/component/index.js +++ b/packages/angular-cli/blueprints/component/index.js @@ -13,8 +13,8 @@ module.exports = { availableOptions: [ { name: 'flat', type: Boolean, default: false }, - { name: 'inline-template', type: Boolean, default: false, aliases: ['it'] }, - { name: 'inline-style', type: Boolean, default: false, aliases: ['is'] }, + { name: 'inline-template', type: Boolean, aliases: ['it'] }, + { name: 'inline-style', type: Boolean, aliases: ['is'] }, { name: 'prefix', type: Boolean, default: true }, { name: 'spec', type: Boolean, default: true } ], @@ -56,6 +56,14 @@ module.exports = { this.styleExt = this.project.ngConfig.defaults.styleExt; } + options.inlineStyle = options.inlineStyle !== undefined ? + options.inlineStyle : + this.project.ngConfigObj.get('defaults.inline.style'); + + options.inlineTemplate = options.inlineTemplate !== undefined ? + options.inlineTemplate : + this.project.ngConfigObj.get('defaults.inline.template'); + return { dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''), flat: options.flat, diff --git a/packages/angular-cli/lib/config/schema.d.ts b/packages/angular-cli/lib/config/schema.d.ts index bb47f47212a8..2c09a9471ca3 100644 --- a/packages/angular-cli/lib/config/schema.d.ts +++ b/packages/angular-cli/lib/config/schema.d.ts @@ -60,5 +60,9 @@ export interface CliConfig { styleExt?: string; prefixInterfaces?: boolean; poll?: number; + inline?: { + style?: boolean; + template?: boolean; + }; }; } diff --git a/packages/angular-cli/lib/config/schema.json b/packages/angular-cli/lib/config/schema.json index 5077846501e6..8abcc7870466 100644 --- a/packages/angular-cli/lib/config/schema.json +++ b/packages/angular-cli/lib/config/schema.json @@ -138,6 +138,19 @@ }, "poll": { "type": "number" + }, + "inline": { + "type": "object", + "properties": { + "style": { + "type": "boolean", + "default": false + }, + "template": { + "type": "boolean", + "default": false + } + } } }, "additionalProperties": false diff --git a/packages/angular-cli/models/json-schema/schema-tree.ts b/packages/angular-cli/models/json-schema/schema-tree.ts index 68a46dee9394..51c46b7f013b 100644 --- a/packages/angular-cli/models/json-schema/schema-tree.ts +++ b/packages/angular-cli/models/json-schema/schema-tree.ts @@ -281,7 +281,7 @@ export abstract class LeafSchemaTreeNode extends SchemaTreeNode { constructor(metaData: TreeNodeConstructorArgument) { super(metaData); - this._defined = metaData.value !== undefined; + this._defined = !(metaData.value === undefined || metaData.value === null); if ('default' in metaData.schema) { this._default = metaData.schema['default']; }