-
Notifications
You must be signed in to change notification settings - Fork 11.9k
refactor(@angular/cli): rename config file from angular-cli.json to .… #4681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,14 +16,14 @@ Since the data is static, we only need to keep it in a static store somewhere. | |
|
|
||
| One solution would be to keep the data in the `package.json`. Unfortunately, the metadata contains too much data and the `package.json` file would become unmanageable. | ||
|
|
||
| Instead of polluting the package file, a `angular-cli.json` file will be created that contains all the values. Access to that file will be allowed to the user if he knows the structure of the file (unknown keys will be kept but ignored), and it's easy to read and write. | ||
| Instead of polluting the package file, a `.angular-cli.json` file will be created that contains all the values. Access to that file will be allowed to the user if he knows the structure of the file (unknown keys will be kept but ignored), and it's easy to read and write. | ||
|
|
||
|
|
||
| ## Fallback | ||
|
|
||
| There should be two `angular-cli.json` files; one for the project and a general one. The general one should contain information that can be useful when scaffolding new apps, or informations about the user. | ||
| There should be two `.angular-cli.json` files; one for the project and a general one. The general one should contain information that can be useful when scaffolding new apps, or informations about the user. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| The project `angular-cli.json` goes into the project root. The global configuration should live at `$HOME/.angular-cli.json`. | ||
| The project `.angular-cli.json` goes into the project root. The global configuration should live at `$HOME/.angular-cli.json`. | ||
|
|
||
| ## Structure | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ The build artifacts will be stored in the `dist/` directory. | |
| environment file to be used with that build (`--environment=dev` or `--environment=prod`). | ||
| 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`: | ||
| The mapping used to determine which environment file is used can be found in `.angular-cli.json`: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be nice to show the schema or a link to it somewhere. |
||
|
|
||
| ```json | ||
| "environments": { | ||
|
|
@@ -46,7 +46,7 @@ ng build | |
|
|
||
| You can also add your own env files other than `dev` and `prod` by doing the following: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe say environment files instead of env files. |
||
| - create a `src/environments/environment.NAME.ts` | ||
| - add `{ "NAME": 'src/environments/environment.NAME.ts' }` to the `apps[0].environments` object in `angular-cli.json` | ||
| - add `{ "NAME": 'src/environments/environment.NAME.ts' }` to the `apps[0].environments` object in `.angular-cli.json` | ||
| - use them via the `--env=NAME` flag on the build/serve commands. | ||
|
|
||
| ### Base tag handling in index.html | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,8 @@ import * as chalk from 'chalk'; | |
| import * as fs from 'fs'; | ||
| import * as path from 'path'; | ||
|
|
||
| export const CLI_CONFIG_FILE_NAME = 'angular-cli.json'; | ||
| export const CLI_CONFIG_FILE_NAME = '.angular-cli.json'; | ||
| const CLI_CONFIG_FILE_NAME_ALT = 'angular-cli.json'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we show a warning if users are using the old one?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I spoke with @hansl about this, and we think we should silently fallback to the old file name. This means fewer changes are needed, but newly generated projects will generate with the new file name. |
||
|
|
||
|
|
||
| function _findUp(name: string, from: string) { | ||
|
|
@@ -38,8 +39,11 @@ export class CliConfig extends CliConfigBase<ConfigInterface> { | |
| // Find the configuration, either where specified, in the angular-cli project | ||
| // (if it's in node_modules) or from the current process. | ||
| return (projectPath && _findUp(CLI_CONFIG_FILE_NAME, projectPath)) | ||
| || (projectPath && _findUp(CLI_CONFIG_FILE_NAME_ALT, projectPath)) | ||
| || _findUp(CLI_CONFIG_FILE_NAME, process.cwd()) | ||
| || _findUp(CLI_CONFIG_FILE_NAME, __dirname); | ||
| || _findUp(CLI_CONFIG_FILE_NAME_ALT, process.cwd()) | ||
| || _findUp(CLI_CONFIG_FILE_NAME, __dirname) | ||
| || _findUp(CLI_CONFIG_FILE_NAME_ALT, __dirname); | ||
| } | ||
|
|
||
| static fromGlobal(): CliConfig { | ||
|
|
@@ -66,7 +70,7 @@ export class CliConfig extends CliConfigBase<ConfigInterface> { | |
| // If any of them returned true, output a deprecation warning. | ||
| if (aliases.some(x => !!x)) { | ||
| console.error(chalk.yellow(oneLine` | ||
| The "defaults.prefix" and "defaults.sourceDir" properties of angular-cli.json | ||
| The "defaults.prefix" and "defaults.sourceDir" properties of .angular-cli.json | ||
| are deprecated in favor of "apps[0].root" and "apps[0].prefix".\n | ||
| Please update in order to avoid errors in future versions of Angular CLI. | ||
| `)); | ||
|
|
@@ -94,7 +98,7 @@ export class CliConfig extends CliConfigBase<ConfigInterface> { | |
| // If any of them returned true, output a deprecation warning. | ||
| if (aliases.some(x => !!x)) { | ||
| console.error(chalk.yellow(oneLine` | ||
| The "defaults.prefix" and "defaults.sourceDir" properties of angular-cli.json | ||
| The "defaults.prefix" and "defaults.sourceDir" properties of .angular-cli.json | ||
| are deprecated in favor of "apps[0].root" and "apps[0].prefix".\n | ||
| Please update in order to avoid errors in future versions of Angular CLI. | ||
| `)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import {ng} from '../../utils/process'; | ||
| import {moveFile} from '../../utils/fs'; | ||
|
|
||
|
|
||
| export default function() { | ||
| return Promise.resolve() | ||
| .then(() => ng('build')) | ||
| .then(() => moveFile('.angular-cli.json', 'angular-cli.json')) | ||
| .then(() => ng('build')); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid
heandshe. be gender indifferent. Instead usewhohere.