From 7aa9bba8d3dd14c6f70eb207e34417ab1b2fe58f Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 2 Dec 2020 08:51:15 +0100 Subject: [PATCH 1/2] fix(@angular/cli): dasherize names option names when using JSON help This ensures that arguments listed in https://angular.io/cli help pages are all in kebab cases. This is a prerequisite to deprecate camel cased arguments. --- packages/angular/cli/models/command.ts | 5 ++++- tests/legacy-cli/e2e/tests/commands/help/help-json.ts | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/angular/cli/models/command.ts b/packages/angular/cli/models/command.ts index 60b490387c89..6e5eff538749 100644 --- a/packages/angular/cli/models/command.ts +++ b/packages/angular/cli/models/command.ts @@ -54,7 +54,10 @@ export abstract class Command } async printJsonHelp(_options: T & Arguments): Promise { - this.logger.info(JSON.stringify(this.description)); + const replacer = (key: string, value: string) => key === 'name' + ? strings.dasherize(value) + : value; + this.logger.info(JSON.stringify(this.description, replacer, 2)); return 0; } diff --git a/tests/legacy-cli/e2e/tests/commands/help/help-json.ts b/tests/legacy-cli/e2e/tests/commands/help/help-json.ts index af4f18872990..898adfbe5bc6 100644 --- a/tests/legacy-cli/e2e/tests/commands/help/help-json.ts +++ b/tests/legacy-cli/e2e/tests/commands/help/help-json.ts @@ -7,7 +7,11 @@ export default async function() { const { stdout } = await silentNg(commandName, '--help=json'); if (stdout.trim()) { - JSON.parse(stdout); + JSON.parse(stdout, (key, value) => { + if (key === 'name' && /[A-Z]/.test(value)) { + throw new Error(`Option named '${value}' is not kebab case.`); + } + }); } else { console.warn(`No JSON output for command [${commandName}].`); } From f4de90991167f97f13f9eef641a713ddf5bfbfbe Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 2 Dec 2020 10:42:56 +0100 Subject: [PATCH 2/2] docs: replace analytics table with kebabed cased arguments --- docs/design/analytics.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/design/analytics.md b/docs/design/analytics.md index abdc477910d1..1658f5d4b91a 100644 --- a/docs/design/analytics.md +++ b/docs/design/analytics.md @@ -48,16 +48,16 @@ Note: There's a limit of 20 custom dimensions. | 6 | `--collection` | `string` | | 7 | `Flag: --strict` | `boolean` | | 8 | `Ivy Enabled` | `boolean` | -| 9 | `Flag: --inlineStyle` | `boolean` | -| 10 | `Flag: --inlineTemplate` | `boolean` | -| 11 | `Flag: --viewEncapsulation` | `string` | -| 12 | `Flag: --skipTests` | `boolean` | +| 9 | `Flag: --inline-style` | `boolean` | +| 10 | `Flag: --inline-template` | `boolean` | +| 11 | `Flag: --view-encapsulation` | `string` | +| 12 | `Flag: --skip-tests` | `boolean` | | 13 | `Flag: --aot` | `boolean` | | 14 | `Flag: --minimal` | `boolean` | -| 15 | `Flag: --lintFix` | `boolean` | +| 15 | `Flag: --lint-fix` | `boolean` | | 16 | `Flag: --optimization` | `boolean` | | 17 | `Flag: --routing` | `boolean` | -| 18 | `Flag: --skipImport` | `boolean` | +| 18 | `Flag: --skip-import` | `boolean` | | 19 | `Flag: --export` | `boolean` | | 20 | `Build Errors (comma separated)` | `string` |