From cc8a53e3afb05ad4547baf60c2e6138e26e6d226 Mon Sep 17 00:00:00 2001 From: Juan Sanchez Garcia Date: Thu, 5 Jan 2017 16:20:44 -0800 Subject: [PATCH 1/4] refactor(build): replace `source` in environments with `environmentDefault` entry Replace source in environments with separate environmentDefault entry and updated docs to reflect this change BREAKING CHANGE: angular-cli.json has changed. A new environmentDefault entry replaces the previous source entry inside environments. To migrate the code follow the example below: Before: "environments": { "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } After: "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } Closes #3857 --- README.md | 2 +- docs/documentation/overview.md | 2 +- packages/angular-cli/lib/config/schema.d.ts | 16 +++++++++++++--- packages/angular-cli/lib/config/schema.json | 5 +++++ .../angular-cli/models/webpack-build-common.ts | 6 +++--- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f387c805f9be..afda0db8c8be 100644 --- a/README.md +++ b/README.md @@ -137,8 +137,8 @@ By default, the development build target and environment are used. The mapping used to determine which environment file is used can be found in `angular-cli.json`: ```json +"environmentSource": "environments/environment.ts", "environments": { - "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } diff --git a/docs/documentation/overview.md b/docs/documentation/overview.md index 6286a25678a8..3f7a0cffc570 100644 --- a/docs/documentation/overview.md +++ b/docs/documentation/overview.md @@ -27,8 +27,8 @@ By default, the development build target and environment are used. The mapping used to determine which environment file is used can be found in `angular-cli.json`: ```json +"environmentSource": "environments/environment.ts", "environments": { - "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } diff --git a/packages/angular-cli/lib/config/schema.d.ts b/packages/angular-cli/lib/config/schema.d.ts index d323223b5f36..48078bb76add 100644 --- a/packages/angular-cli/lib/config/schema.d.ts +++ b/packages/angular-cli/lib/config/schema.d.ts @@ -12,7 +12,7 @@ export interface CliConfig { apps?: { root?: string; outDir?: string; - assets?: string; + assets?: string | string[]; deployUrl?: string; index?: string; main?: string; @@ -23,11 +23,21 @@ export interface CliConfig { /** * Global styles to be included in the build. */ - styles?: string[]; + styles?: (string | { + [name: string]: any; + input?: string; + })[]; /** * Global scripts to be included in the build. */ - scripts?: string[]; + scripts?: (string | { + [name: string]: any; + input?: string; + })[]; + /** + * Source file for environment config. + */ + environmentSource?: string; /** * Name and corresponding file for environment config. */ diff --git a/packages/angular-cli/lib/config/schema.json b/packages/angular-cli/lib/config/schema.json index 3a2a1f02fcc9..7db10ee72800 100644 --- a/packages/angular-cli/lib/config/schema.json +++ b/packages/angular-cli/lib/config/schema.json @@ -110,6 +110,11 @@ }, "additionalProperties": false }, + "environmentSource": { + "description": "Source file for environment config.", + "type": "string", + "additionalProperties": true + }, "environments": { "description": "Name and corresponding file for environment config.", "type": "object", diff --git a/packages/angular-cli/models/webpack-build-common.ts b/packages/angular-cli/models/webpack-build-common.ts index 6130f887fbc0..49e94af24f25 100644 --- a/packages/angular-cli/models/webpack-build-common.ts +++ b/packages/angular-cli/models/webpack-build-common.ts @@ -102,8 +102,8 @@ export function getWebpackCommonConfig( // process environment file replacement if (appConfig.environments) { - if (!('source' in appConfig.environments)) { - throw new SilentError(`Environment configuration does not contain "source" entry.`); + if (!appConfig.environmentSource) { + throw new SilentError(`Environment configuration does not contain "environmentSource" entry.`); } if (!(environment in appConfig.environments)) { throw new SilentError(`Environment "${environment}" does not exist.`); @@ -113,7 +113,7 @@ export function getWebpackCommonConfig( // This plugin is responsible for swapping the environment files. // Since it takes a RegExp as first parameter, we need to escape the path. // See https://webpack.github.io/docs/list-of-plugins.html#normalmodulereplacementplugin - new RegExp(path.resolve(appRoot, appConfig.environments['source']) + new RegExp(path.resolve(appRoot, appConfig['environmentSource']) .replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')), path.resolve(appRoot, appConfig.environments[environment]) )); From 15400458271d05de6deb6bd685845c11b233552b Mon Sep 17 00:00:00 2001 From: Juan Sanchez Garcia Date: Thu, 5 Jan 2017 16:20:44 -0800 Subject: [PATCH 2/4] refactor(build): replace `source` in environments with `environmentDefault` entry Replace source in environments with separate environmentDefault entry and updated docs to reflect this change BREAKING CHANGE: angular-cli.json has changed. A new environmentDefault entry replaces the previous source entry inside environments. To migrate the code follow the example below: Before: "environments": { "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } After: "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } Closes #3857 --- README.md | 2 +- docs/documentation/overview.md | 2 +- .../blueprints/ng2/files/angular-cli.json | 2 +- packages/angular-cli/lib/config/schema.d.ts | 16 +++++++++++++--- packages/angular-cli/lib/config/schema.json | 5 +++++ .../angular-cli/models/webpack-build-common.ts | 6 +++--- .../angular-cli/models/webpack-build-test.js | 2 +- 7 files changed, 25 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f387c805f9be..afda0db8c8be 100644 --- a/README.md +++ b/README.md @@ -137,8 +137,8 @@ By default, the development build target and environment are used. The mapping used to determine which environment file is used can be found in `angular-cli.json`: ```json +"environmentSource": "environments/environment.ts", "environments": { - "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } diff --git a/docs/documentation/overview.md b/docs/documentation/overview.md index 6286a25678a8..3f7a0cffc570 100644 --- a/docs/documentation/overview.md +++ b/docs/documentation/overview.md @@ -27,8 +27,8 @@ By default, the development build target and environment are used. The mapping used to determine which environment file is used can be found in `angular-cli.json`: ```json +"environmentSource": "environments/environment.ts", "environments": { - "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } diff --git a/packages/angular-cli/blueprints/ng2/files/angular-cli.json b/packages/angular-cli/blueprints/ng2/files/angular-cli.json index 4fd88b98c1cf..9f5e8fc6e156 100644 --- a/packages/angular-cli/blueprints/ng2/files/angular-cli.json +++ b/packages/angular-cli/blueprints/ng2/files/angular-cli.json @@ -21,8 +21,8 @@ "styles.<%= styleExt %>" ], "scripts": [], + "environmentSource": "environments/environment.ts", "environments": { - "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } diff --git a/packages/angular-cli/lib/config/schema.d.ts b/packages/angular-cli/lib/config/schema.d.ts index d323223b5f36..48078bb76add 100644 --- a/packages/angular-cli/lib/config/schema.d.ts +++ b/packages/angular-cli/lib/config/schema.d.ts @@ -12,7 +12,7 @@ export interface CliConfig { apps?: { root?: string; outDir?: string; - assets?: string; + assets?: string | string[]; deployUrl?: string; index?: string; main?: string; @@ -23,11 +23,21 @@ export interface CliConfig { /** * Global styles to be included in the build. */ - styles?: string[]; + styles?: (string | { + [name: string]: any; + input?: string; + })[]; /** * Global scripts to be included in the build. */ - scripts?: string[]; + scripts?: (string | { + [name: string]: any; + input?: string; + })[]; + /** + * Source file for environment config. + */ + environmentSource?: string; /** * Name and corresponding file for environment config. */ diff --git a/packages/angular-cli/lib/config/schema.json b/packages/angular-cli/lib/config/schema.json index 3a2a1f02fcc9..7db10ee72800 100644 --- a/packages/angular-cli/lib/config/schema.json +++ b/packages/angular-cli/lib/config/schema.json @@ -110,6 +110,11 @@ }, "additionalProperties": false }, + "environmentSource": { + "description": "Source file for environment config.", + "type": "string", + "additionalProperties": true + }, "environments": { "description": "Name and corresponding file for environment config.", "type": "object", diff --git a/packages/angular-cli/models/webpack-build-common.ts b/packages/angular-cli/models/webpack-build-common.ts index 6130f887fbc0..49e94af24f25 100644 --- a/packages/angular-cli/models/webpack-build-common.ts +++ b/packages/angular-cli/models/webpack-build-common.ts @@ -102,8 +102,8 @@ export function getWebpackCommonConfig( // process environment file replacement if (appConfig.environments) { - if (!('source' in appConfig.environments)) { - throw new SilentError(`Environment configuration does not contain "source" entry.`); + if (!appConfig.environmentSource) { + throw new SilentError(`Environment configuration does not contain "environmentSource" entry.`); } if (!(environment in appConfig.environments)) { throw new SilentError(`Environment "${environment}" does not exist.`); @@ -113,7 +113,7 @@ export function getWebpackCommonConfig( // This plugin is responsible for swapping the environment files. // Since it takes a RegExp as first parameter, we need to escape the path. // See https://webpack.github.io/docs/list-of-plugins.html#normalmodulereplacementplugin - new RegExp(path.resolve(appRoot, appConfig.environments['source']) + new RegExp(path.resolve(appRoot, appConfig['environmentSource']) .replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')), path.resolve(appRoot, appConfig.environments[environment]) )); diff --git a/packages/angular-cli/models/webpack-build-test.js b/packages/angular-cli/models/webpack-build-test.js index a1b1dbe98ecd..2b64382024ba 100644 --- a/packages/angular-cli/models/webpack-build-test.js +++ b/packages/angular-cli/models/webpack-build-test.js @@ -128,7 +128,7 @@ const getWebpackTestConfig = function (projectRoot, environment, appConfig, test // This plugin is responsible for swapping the environment files. // Since it takes a RegExp as first parameter, we need to escape the path. // See https://webpack.github.io/docs/list-of-plugins.html#normalmodulereplacementplugin - new RegExp(path.resolve(appRoot, appConfig.environments['source']) + new RegExp(path.resolve(appRoot, appConfig.['environmentSource']) .replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')), path.resolve(appRoot, appConfig.environments[environment]) ), From 6dc8ef6590a319861265a94f63af06351bd01707 Mon Sep 17 00:00:00 2001 From: Juan Sanchez Garcia Date: Thu, 5 Jan 2017 16:31:22 -0800 Subject: [PATCH 3/4] refactor(build): replace `source` in environments with `environmentDefault` entry Replace source in environments with separate environmentDefault entry and updated docs to reflect this change BREAKING CHANGE: angular-cli.json has changed. A new environmentDefault entry replaces the previous source entry inside environments. To migrate the code follow the example below: Before: "environments": { "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } After: "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } Closes #3857 --- packages/angular-cli/blueprints/ng2/files/angular-cli.json | 2 +- packages/angular-cli/models/webpack-build-test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/angular-cli/blueprints/ng2/files/angular-cli.json b/packages/angular-cli/blueprints/ng2/files/angular-cli.json index 4fd88b98c1cf..9f5e8fc6e156 100644 --- a/packages/angular-cli/blueprints/ng2/files/angular-cli.json +++ b/packages/angular-cli/blueprints/ng2/files/angular-cli.json @@ -21,8 +21,8 @@ "styles.<%= styleExt %>" ], "scripts": [], + "environmentSource": "environments/environment.ts", "environments": { - "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } diff --git a/packages/angular-cli/models/webpack-build-test.js b/packages/angular-cli/models/webpack-build-test.js index a1b1dbe98ecd..a16891027d61 100644 --- a/packages/angular-cli/models/webpack-build-test.js +++ b/packages/angular-cli/models/webpack-build-test.js @@ -128,7 +128,7 @@ const getWebpackTestConfig = function (projectRoot, environment, appConfig, test // This plugin is responsible for swapping the environment files. // Since it takes a RegExp as first parameter, we need to escape the path. // See https://webpack.github.io/docs/list-of-plugins.html#normalmodulereplacementplugin - new RegExp(path.resolve(appRoot, appConfig.environments['source']) + new RegExp(path.resolve(appRoot, appConfig['environmentSource']) .replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')), path.resolve(appRoot, appConfig.environments[environment]) ), From 65a35c345c046921047deb81957ddcfae037294d Mon Sep 17 00:00:00 2001 From: Juan Sanchez Garcia Date: Thu, 5 Jan 2017 16:42:59 -0800 Subject: [PATCH 4/4] refactor(build): replace `source` in environments with `environmentDefault` entry Replace source in environments with separate environmentDefault entry and updated docs to reflect this change BREAKING CHANGE: angular-cli.json has changed. A new environmentDefault entry replaces the previous source entry inside environments. To migrate the code follow the example below: Before: "environments": { "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } After: "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } Closes #3857 --- packages/angular-cli/models/webpack-build-common.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/angular-cli/models/webpack-build-common.ts b/packages/angular-cli/models/webpack-build-common.ts index 49e94af24f25..9771fbb77213 100644 --- a/packages/angular-cli/models/webpack-build-common.ts +++ b/packages/angular-cli/models/webpack-build-common.ts @@ -103,7 +103,8 @@ export function getWebpackCommonConfig( // process environment file replacement if (appConfig.environments) { if (!appConfig.environmentSource) { - throw new SilentError(`Environment configuration does not contain "environmentSource" entry.`); + throw new SilentError(`Environment configuration + does not contain "environmentSource" entry.`); } if (!(environment in appConfig.environments)) { throw new SilentError(`Environment "${environment}" does not exist.`);