@angular/cli 14.0.0-next.8 → 14.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/lib/cli/index.js +1 -1
  2. package/lib/config/schema.json +18 -0
  3. package/lib/config/workspace-schema.d.ts +12 -0
  4. package/lib/init.js +1 -1
  5. package/package.json +16 -16
  6. package/src/analytics/analytics.d.ts +1 -1
  7. package/src/analytics/analytics.js +22 -20
  8. package/src/command-builder/architect-base-command-module.d.ts +1 -1
  9. package/src/command-builder/architect-base-command-module.js +7 -1
  10. package/src/command-builder/architect-command-module.d.ts +4 -0
  11. package/src/command-builder/architect-command-module.js +26 -6
  12. package/src/command-builder/command-module.d.ts +1 -0
  13. package/src/command-builder/command-module.js +7 -0
  14. package/src/command-builder/command-runner.js +41 -30
  15. package/src/command-builder/schematics-command-module.js +10 -7
  16. package/src/command-builder/utilities/command.d.ts +1 -1
  17. package/src/command-builder/utilities/normalize-options-middleware.d.ts +18 -0
  18. package/src/command-builder/utilities/normalize-options-middleware.js +59 -0
  19. package/src/command-builder/utilities/schematic-engine-host.d.ts +2 -2
  20. package/src/command-builder/utilities/schematic-engine-host.js +33 -18
  21. package/src/commands/analytics/settings/cli.js +2 -2
  22. package/src/commands/cache/settings/cli.d.ts +2 -2
  23. package/src/commands/cache/settings/cli.js +2 -2
  24. package/src/commands/cache/utilities.d.ts +1 -1
  25. package/src/commands/cache/utilities.js +7 -8
  26. package/src/commands/completion/cli.d.ts +16 -0
  27. package/src/commands/completion/cli.js +68 -0
  28. package/src/commands/completion/long-description.md +73 -0
  29. package/src/commands/config/cli.js +15 -14
  30. package/src/commands/doc/cli.js +2 -2
  31. package/src/commands/run/cli.d.ts +2 -0
  32. package/src/commands/run/cli.js +24 -0
  33. package/src/commands/update/cli.js +3 -2
  34. package/src/utilities/completion.d.ts +30 -0
  35. package/src/utilities/completion.js +282 -0
  36. package/src/utilities/config.d.ts +4 -3
  37. package/src/utilities/config.js +11 -5
  38. package/src/utilities/environment-options.d.ts +1 -0
  39. package/src/utilities/environment-options.js +8 -1
  40. package/src/utilities/json-file.js +1 -0
package/lib/cli/index.js CHANGED
@@ -73,7 +73,7 @@ async function default_1(options) {
73
73
  // Log nothing.
74
74
  }
75
75
  else {
76
- logger.fatal('An unexpected error occurred: ' + JSON.stringify(err));
76
+ logger.fatal(`An unexpected error occurred: ${'toString' in err ? err.toString() : JSON.stringify(err)}`);
77
77
  }
78
78
  return 1;
79
79
  }
@@ -812,6 +812,12 @@
812
812
  "alias": "t",
813
813
  "x-user-analytics": 10
814
814
  },
815
+ "standalone": {
816
+ "description": "Whether the generated component is standalone.",
817
+ "type": "boolean",
818
+ "default": false,
819
+ "x-user-analytics": 15
820
+ },
815
821
  "viewEncapsulation": {
816
822
  "description": "The view encapsulation strategy to use in the new component.",
817
823
  "enum": [
@@ -964,6 +970,12 @@
964
970
  "format": "html-selector",
965
971
  "description": "The HTML selector to use for this directive."
966
972
  },
973
+ "standalone": {
974
+ "description": "Whether the generated directive is standalone.",
975
+ "type": "boolean",
976
+ "default": false,
977
+ "x-user-analytics": 15
978
+ },
967
979
  "flat": {
968
980
  "type": "boolean",
969
981
  "description": "When true (the default), creates the new files at the top level of the current project.",
@@ -1251,6 +1263,12 @@
1251
1263
  "description": "Do not import this pipe into the owning NgModule.",
1252
1264
  "x-user-analytics": 18
1253
1265
  },
1266
+ "standalone": {
1267
+ "description": "Whether the generated pipe is standalone.",
1268
+ "type": "boolean",
1269
+ "default": false,
1270
+ "x-user-analytics": 15
1271
+ },
1254
1272
  "module": {
1255
1273
  "type": "string",
1256
1274
  "description": "The declaring NgModule.",
@@ -292,6 +292,10 @@ export interface AngularComponentOptionsSchema {
292
292
  * Do not create "spec.ts" test files for the new component.
293
293
  */
294
294
  skipTests?: boolean;
295
+ /**
296
+ * Whether the generated component is standalone.
297
+ */
298
+ standalone?: boolean;
295
299
  /**
296
300
  * The file extension or preprocessor to use for style files, or 'none' to skip generating
297
301
  * the style file.
@@ -369,6 +373,10 @@ export interface AngularDirectiveOptionsSchema {
369
373
  * Do not create "spec.ts" test files for the new class.
370
374
  */
371
375
  skipTests?: boolean;
376
+ /**
377
+ * Whether the generated directive is standalone.
378
+ */
379
+ standalone?: boolean;
372
380
  }
373
381
  /**
374
382
  * Generates a new, generic enum definition for the given or default project.
@@ -640,6 +648,10 @@ export interface AngularPipeOptionsSchema {
640
648
  * Do not create "spec.ts" test files for the new pipe.
641
649
  */
642
650
  skipTests?: boolean;
651
+ /**
652
+ * Whether the generated pipe is standalone.
653
+ */
654
+ standalone?: boolean;
643
655
  }
644
656
  /**
645
657
  * Generates a new, generic resolver definition in the given or default project.
package/lib/init.js CHANGED
@@ -120,7 +120,7 @@ const version_1 = require("../src/utilities/version");
120
120
  });
121
121
  })
122
122
  .then((exitCode) => {
123
- process.exit(exitCode);
123
+ process.exitCode = exitCode;
124
124
  })
125
125
  .catch((err) => {
126
126
  // eslint-disable-next-line no-console
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/cli",
3
- "version": "14.0.0-next.8",
3
+ "version": "14.0.0-rc.1",
4
4
  "description": "CLI tool for Angular",
5
5
  "main": "lib/cli/index.js",
6
6
  "bin": {
@@ -25,36 +25,36 @@
25
25
  },
26
26
  "homepage": "https://github.com/angular/angular-cli",
27
27
  "dependencies": {
28
- "@angular-devkit/architect": "0.1400.0-next.8",
29
- "@angular-devkit/core": "14.0.0-next.8",
30
- "@angular-devkit/schematics": "14.0.0-next.8",
31
- "@schematics/angular": "14.0.0-next.8",
28
+ "@angular-devkit/architect": "0.1400.0-rc.1",
29
+ "@angular-devkit/core": "14.0.0-rc.1",
30
+ "@angular-devkit/schematics": "14.0.0-rc.1",
31
+ "@schematics/angular": "14.0.0-rc.1",
32
32
  "@yarnpkg/lockfile": "1.1.0",
33
33
  "ansi-colors": "4.1.1",
34
34
  "debug": "4.3.4",
35
- "ini": "2.0.0",
36
- "inquirer": "8.2.2",
35
+ "ini": "3.0.0",
36
+ "inquirer": "8.2.4",
37
37
  "jsonc-parser": "3.0.0",
38
38
  "npm-package-arg": "9.0.2",
39
39
  "npm-pick-manifest": "7.0.1",
40
40
  "open": "8.4.0",
41
41
  "ora": "5.4.1",
42
- "pacote": "13.1.0",
42
+ "pacote": "13.3.0",
43
43
  "resolve": "1.22.0",
44
- "semver": "7.3.5",
44
+ "semver": "7.3.7",
45
45
  "symbol-observable": "4.0.0",
46
46
  "uuid": "8.3.2",
47
- "yargs": "17.4.0"
47
+ "yargs": "17.4.1"
48
48
  },
49
49
  "ng-update": {
50
50
  "migrations": "@schematics/angular/migrations/migration-collection.json",
51
51
  "packageGroup": {
52
- "@angular/cli": "14.0.0-next.8",
53
- "@angular-devkit/architect": "0.1400.0-next.8",
54
- "@angular-devkit/build-angular": "14.0.0-next.8",
55
- "@angular-devkit/build-webpack": "0.1400.0-next.8",
56
- "@angular-devkit/core": "14.0.0-next.8",
57
- "@angular-devkit/schematics": "14.0.0-next.8"
52
+ "@angular/cli": "14.0.0-rc.1",
53
+ "@angular-devkit/architect": "0.1400.0-rc.1",
54
+ "@angular-devkit/build-angular": "14.0.0-rc.1",
55
+ "@angular-devkit/build-webpack": "0.1400.0-rc.1",
56
+ "@angular-devkit/core": "14.0.0-rc.1",
57
+ "@angular-devkit/schematics": "14.0.0-rc.1"
58
58
  }
59
59
  },
60
60
  "engines": {
@@ -22,7 +22,7 @@ export declare function isPackageNameSafeForAnalytics(name: string): boolean;
22
22
  * @param global Which config to use. "global" for user-level, and "local" for project-level.
23
23
  * @param value Either a user ID, true to generate a new User ID, or false to disable analytics.
24
24
  */
25
- export declare function setAnalyticsConfig(global: boolean, value: string | boolean): void;
25
+ export declare function setAnalyticsConfig(global: boolean, value: string | boolean): Promise<void>;
26
26
  /**
27
27
  * Prompt the user for usage gathering permission.
28
28
  * @param force Whether to ask regardless of whether or not the user is using an interactive shell.
@@ -87,22 +87,21 @@ exports.isPackageNameSafeForAnalytics = isPackageNameSafeForAnalytics;
87
87
  * @param global Which config to use. "global" for user-level, and "local" for project-level.
88
88
  * @param value Either a user ID, true to generate a new User ID, or false to disable analytics.
89
89
  */
90
- function setAnalyticsConfig(global, value) {
90
+ async function setAnalyticsConfig(global, value) {
91
+ var _a;
92
+ var _b;
91
93
  const level = global ? 'global' : 'local';
92
94
  analyticsDebug('setting %s level analytics to: %s', level, value);
93
- const [config, configPath] = (0, config_1.getWorkspaceRaw)(level);
94
- if (!config || !configPath) {
95
+ const workspace = await (0, config_1.getWorkspace)(level);
96
+ if (!workspace) {
95
97
  throw new Error(`Could not find ${level} workspace.`);
96
98
  }
97
- const cli = config.get(['cli']);
98
- if (cli !== undefined && !core_1.json.isJsonObject(cli)) {
99
- throw new Error(`Invalid config found at ${configPath}. CLI should be an object.`);
100
- }
101
- if (value === true) {
102
- value = (0, uuid_1.v4)();
99
+ const cli = ((_a = (_b = workspace.extensions)['cli']) !== null && _a !== void 0 ? _a : (_b['cli'] = {}));
100
+ if (!workspace || !core_1.json.isJsonObject(cli)) {
101
+ throw new Error(`Invalid config found at ${workspace.filePath}. CLI should be an object.`);
103
102
  }
104
- config.modify(['cli', 'analytics'], value);
105
- config.save();
103
+ cli.analytics = value === true ? (0, uuid_1.v4)() : value;
104
+ await workspace.save();
106
105
  analyticsDebug('done');
107
106
  }
108
107
  exports.setAnalyticsConfig = setAnalyticsConfig;
@@ -114,8 +113,8 @@ exports.setAnalyticsConfig = setAnalyticsConfig;
114
113
  async function promptAnalytics(global, force = false) {
115
114
  analyticsDebug('prompting user');
116
115
  const level = global ? 'global' : 'local';
117
- const [config, configPath] = (0, config_1.getWorkspaceRaw)(level);
118
- if (!config || !configPath) {
116
+ const workspace = await (0, config_1.getWorkspace)(level);
117
+ if (!workspace) {
119
118
  throw new Error(`Could not find a ${level} workspace. Are you in a project?`);
120
119
  }
121
120
  if (force || (0, tty_1.isTTY)()) {
@@ -133,7 +132,7 @@ async function promptAnalytics(global, force = false) {
133
132
  default: false,
134
133
  },
135
134
  ]);
136
- setAnalyticsConfig(global, answers.analytics);
135
+ await setAnalyticsConfig(global, answers.analytics);
137
136
  if (answers.analytics) {
138
137
  console.log('');
139
138
  console.log(core_1.tags.stripIndent `
@@ -169,6 +168,7 @@ exports.promptAnalytics = promptAnalytics;
169
168
  * - `undefined` when not configured.
170
169
  */
171
170
  async function getAnalytics(level) {
171
+ var _a;
172
172
  analyticsDebug('getAnalytics');
173
173
  if (environment_options_1.analyticsDisabled) {
174
174
  analyticsDebug('NG_CLI_ANALYTICS is false');
@@ -176,7 +176,7 @@ async function getAnalytics(level) {
176
176
  }
177
177
  try {
178
178
  const workspace = await (0, config_1.getWorkspace)(level);
179
- const analyticsConfig = workspace === null || workspace === void 0 ? void 0 : workspace.getCli()['analytics'];
179
+ const analyticsConfig = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.getCli()) === null || _a === void 0 ? void 0 : _a['analytics'];
180
180
  analyticsDebug('Workspace Analytics config found: %j', analyticsConfig);
181
181
  if (analyticsConfig === false) {
182
182
  return new core_1.analytics.NoopAnalytics();
@@ -210,6 +210,7 @@ exports.getAnalytics = getAnalytics;
210
210
  * or undefined if no sharing.
211
211
  */
212
212
  async function getSharedAnalytics() {
213
+ var _a;
213
214
  analyticsDebug('getSharedAnalytics');
214
215
  if (environment_options_1.analyticsShareDisabled) {
215
216
  analyticsDebug('NG_CLI_ANALYTICS is false');
@@ -218,7 +219,7 @@ async function getSharedAnalytics() {
218
219
  // If anything happens we just keep the NOOP analytics.
219
220
  try {
220
221
  const globalWorkspace = await (0, config_1.getWorkspace)('global');
221
- const analyticsConfig = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.getCli()['analyticsSharing'];
222
+ const analyticsConfig = (_a = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.getCli()) === null || _a === void 0 ? void 0 : _a['analyticsSharing'];
222
223
  if (!analyticsConfig || !analyticsConfig.tracking || !analyticsConfig.uuid) {
223
224
  return undefined;
224
225
  }
@@ -288,10 +289,11 @@ function analyticsConfigValueToHumanFormat(value) {
288
289
  }
289
290
  }
290
291
  async function getAnalyticsInfoString() {
291
- const [globalWorkspace] = (0, config_1.getWorkspaceRaw)('global');
292
- const [localWorkspace] = (0, config_1.getWorkspaceRaw)('local');
293
- const globalSetting = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.get(['cli', 'analytics']);
294
- const localSetting = localWorkspace === null || localWorkspace === void 0 ? void 0 : localWorkspace.get(['cli', 'analytics']);
292
+ var _a, _b;
293
+ const globalWorkspace = await (0, config_1.getWorkspace)('global');
294
+ const localWorkspace = await (0, config_1.getWorkspace)('local');
295
+ const globalSetting = (_a = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.getCli()) === null || _a === void 0 ? void 0 : _a['analytics'];
296
+ const localSetting = (_b = localWorkspace === null || localWorkspace === void 0 ? void 0 : localWorkspace.getCli()) === null || _b === void 0 ? void 0 : _b['analytics'];
295
297
  const analyticsInstance = await createAnalytics(!!localWorkspace /** workspace */, true /** skipPrompt */);
296
298
  return (core_1.tags.stripIndents `
297
299
  Global setting: ${analyticsConfigValueToHumanFormat(globalSetting)}
@@ -13,7 +13,7 @@ export interface MissingTargetChoice {
13
13
  name: string;
14
14
  value: string;
15
15
  }
16
- export declare abstract class ArchitectBaseCommandModule<T> extends CommandModule<T> implements CommandModuleImplementation<T> {
16
+ export declare abstract class ArchitectBaseCommandModule<T extends object> extends CommandModule<T> implements CommandModuleImplementation<T> {
17
17
  static scope: CommandScope;
18
18
  protected shouldReportAnalytics: boolean;
19
19
  protected readonly missingTargetChoices: MissingTargetChoice[] | undefined;
@@ -68,7 +68,13 @@ class ArchitectBaseCommandModule extends command_module_1.CommandModule {
68
68
  }
69
69
  async getArchitectTargetOptions(target) {
70
70
  const architectHost = this.getArchitectHost();
71
- const builderConf = await architectHost.getBuilderNameForTarget(target);
71
+ let builderConf;
72
+ try {
73
+ builderConf = await architectHost.getBuilderNameForTarget(target);
74
+ }
75
+ catch {
76
+ return [];
77
+ }
72
78
  let builderDesc;
73
79
  try {
74
80
  builderDesc = await architectHost.resolveBuilder(builderConf);
@@ -18,4 +18,8 @@ export declare abstract class ArchitectCommandModule extends ArchitectBaseComman
18
18
  run(options: Options<ArchitectCommandArgs> & OtherOptions): Promise<number | void>;
19
19
  private getArchitectProject;
20
20
  private getProjectNamesByTarget;
21
+ /** @returns a sorted list of project names to be used for auto completion. */
22
+ private getProjectChoices;
23
+ /** @returns a sorted list of configuration names to be used for auto completion. */
24
+ private getConfigurationChoices;
21
25
  }
@@ -17,13 +17,16 @@ exports.ArchitectCommandModule = void 0;
17
17
  const config_1 = require("../utilities/config");
18
18
  const memoize_1 = require("../utilities/memoize");
19
19
  const architect_base_command_module_1 = require("./architect-base-command-module");
20
- const command_module_1 = require("./command-module");
21
20
  class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBaseCommandModule {
22
21
  async builder(argv) {
22
+ const project = this.getArchitectProject();
23
+ const { jsonHelp, getYargsCompletions, help } = this.context.args.options;
23
24
  const localYargs = argv
24
25
  .positional('project', {
25
26
  describe: 'The name of the project to build. Can be an application or a library.',
26
27
  type: 'string',
28
+ // Hide choices from JSON help so that we don't display them in AIO.
29
+ choices: jsonHelp ? undefined : this.getProjectChoices(),
27
30
  })
28
31
  .option('configuration', {
29
32
  describe: `One or more named builder configurations as a comma-separated ` +
@@ -32,9 +35,13 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
32
35
  `For more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.`,
33
36
  alias: 'c',
34
37
  type: 'string',
38
+ // Show only in when using --help and auto completion because otherwise comma seperated configuration values will be invalid.
39
+ // Also, hide choices from JSON help so that we don't display them in AIO.
40
+ choices: (getYargsCompletions || help) && !jsonHelp && project
41
+ ? this.getConfigurationChoices(project)
42
+ : undefined,
35
43
  })
36
44
  .strict();
37
- const project = this.getArchitectProject();
38
45
  if (!project) {
39
46
  return localYargs;
40
47
  }
@@ -72,10 +79,7 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
72
79
  }
73
80
  const [, projectName] = this.context.args.positional;
74
81
  if (projectName) {
75
- if (!workspace.projects.has(projectName)) {
76
- throw new command_module_1.CommandModuleError(`Project '${projectName}' does not exist.`);
77
- }
78
- return projectName;
82
+ return workspace.projects.has(projectName) ? projectName : undefined;
79
83
  }
80
84
  const target = this.getArchitectTarget();
81
85
  const projectFromTarget = this.getProjectNamesByTarget(target);
@@ -107,6 +111,22 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
107
111
  }
108
112
  return undefined;
109
113
  }
114
+ /** @returns a sorted list of project names to be used for auto completion. */
115
+ getProjectChoices() {
116
+ const { workspace } = this.context;
117
+ return workspace ? [...workspace.projects.keys()].sort() : undefined;
118
+ }
119
+ /** @returns a sorted list of configuration names to be used for auto completion. */
120
+ getConfigurationChoices(project) {
121
+ var _a, _b;
122
+ const projectDefinition = (_a = this.context.workspace) === null || _a === void 0 ? void 0 : _a.projects.get(project);
123
+ if (!projectDefinition) {
124
+ return undefined;
125
+ }
126
+ const target = this.getArchitectTarget();
127
+ const configurations = (_b = projectDefinition.targets.get(target)) === null || _b === void 0 ? void 0 : _b.configurations;
128
+ return configurations ? Object.keys(configurations).sort() : undefined;
129
+ }
110
130
  }
111
131
  __decorate([
112
132
  memoize_1.memoize
@@ -34,6 +34,7 @@ export interface CommandContext {
34
34
  options: {
35
35
  help: boolean;
36
36
  jsonHelp: boolean;
37
+ getYargsCompletions: boolean;
37
38
  } & Record<string, unknown>;
38
39
  };
39
40
  }
@@ -42,6 +42,7 @@ const fs_1 = require("fs");
42
42
  const path = __importStar(require("path"));
43
43
  const helpers_1 = require("yargs/helpers");
44
44
  const analytics_1 = require("../analytics/analytics");
45
+ const completion_1 = require("../utilities/completion");
45
46
  const memoize_1 = require("../utilities/memoize");
46
47
  var CommandScope;
47
48
  (function (CommandScope) {
@@ -89,6 +90,12 @@ class CommandModule {
89
90
  for (const [key, value] of Object.entries(options)) {
90
91
  camelCasedOptions[helpers_1.Parser.camelCase(key)] = value;
91
92
  }
93
+ // Set up autocompletion if appropriate.
94
+ const autocompletionExitCode = await (0, completion_1.considerSettingUpAutocompletion)(this.commandName, this.context.logger);
95
+ if (autocompletionExitCode !== undefined) {
96
+ process.exitCode = autocompletionExitCode;
97
+ return;
98
+ }
92
99
  // Gather and report analytics.
93
100
  const analytics = await this.getAnalytics();
94
101
  if (this.shouldReportAnalytics) {
@@ -17,50 +17,58 @@ const cli_1 = require("../commands/add/cli");
17
17
  const cli_2 = require("../commands/analytics/cli");
18
18
  const cli_3 = require("../commands/build/cli");
19
19
  const cli_4 = require("../commands/cache/cli");
20
- const cli_5 = require("../commands/config/cli");
21
- const cli_6 = require("../commands/deploy/cli");
22
- const cli_7 = require("../commands/doc/cli");
23
- const cli_8 = require("../commands/e2e/cli");
24
- const cli_9 = require("../commands/extract-i18n/cli");
25
- const cli_10 = require("../commands/generate/cli");
26
- const cli_11 = require("../commands/lint/cli");
27
- const cli_12 = require("../commands/make-this-awesome/cli");
28
- const cli_13 = require("../commands/new/cli");
29
- const cli_14 = require("../commands/run/cli");
30
- const cli_15 = require("../commands/serve/cli");
31
- const cli_16 = require("../commands/test/cli");
32
- const cli_17 = require("../commands/update/cli");
33
- const cli_18 = require("../commands/version/cli");
20
+ const cli_5 = require("../commands/completion/cli");
21
+ const cli_6 = require("../commands/config/cli");
22
+ const cli_7 = require("../commands/deploy/cli");
23
+ const cli_8 = require("../commands/doc/cli");
24
+ const cli_9 = require("../commands/e2e/cli");
25
+ const cli_10 = require("../commands/extract-i18n/cli");
26
+ const cli_11 = require("../commands/generate/cli");
27
+ const cli_12 = require("../commands/lint/cli");
28
+ const cli_13 = require("../commands/make-this-awesome/cli");
29
+ const cli_14 = require("../commands/new/cli");
30
+ const cli_15 = require("../commands/run/cli");
31
+ const cli_16 = require("../commands/serve/cli");
32
+ const cli_17 = require("../commands/test/cli");
33
+ const cli_18 = require("../commands/update/cli");
34
+ const cli_19 = require("../commands/version/cli");
34
35
  const color_1 = require("../utilities/color");
35
36
  const config_1 = require("../utilities/config");
36
37
  const package_manager_1 = require("../utilities/package-manager");
37
38
  const command_module_1 = require("./command-module");
38
39
  const command_1 = require("./utilities/command");
39
40
  const json_help_1 = require("./utilities/json-help");
41
+ const normalize_options_middleware_1 = require("./utilities/normalize-options-middleware");
40
42
  const COMMANDS = [
41
- cli_18.VersionCommandModule,
42
- cli_7.DocCommandModule,
43
- cli_12.AwesomeCommandModule,
44
- cli_5.ConfigCommandModule,
43
+ cli_19.VersionCommandModule,
44
+ cli_8.DocCommandModule,
45
+ cli_13.AwesomeCommandModule,
46
+ cli_6.ConfigCommandModule,
45
47
  cli_2.AnalyticsCommandModule,
46
48
  cli_1.AddCommandModule,
47
- cli_10.GenerateCommandModule,
49
+ cli_11.GenerateCommandModule,
48
50
  cli_3.BuildCommandModule,
49
- cli_8.E2eCommandModule,
50
- cli_16.TestCommandModule,
51
- cli_15.ServeCommandModule,
52
- cli_9.ExtractI18nCommandModule,
53
- cli_6.DeployCommandModule,
54
- cli_11.LintCommandModule,
55
- cli_13.NewCommandModule,
56
- cli_17.UpdateCommandModule,
57
- cli_14.RunCommandModule,
51
+ cli_9.E2eCommandModule,
52
+ cli_17.TestCommandModule,
53
+ cli_16.ServeCommandModule,
54
+ cli_10.ExtractI18nCommandModule,
55
+ cli_7.DeployCommandModule,
56
+ cli_12.LintCommandModule,
57
+ cli_14.NewCommandModule,
58
+ cli_18.UpdateCommandModule,
59
+ cli_15.RunCommandModule,
58
60
  cli_4.CacheCommandModule,
61
+ cli_5.CompletionCommandModule,
59
62
  ].sort(); // Will be sorted by class name.
60
63
  const yargsParser = helpers_1.Parser;
61
64
  async function runCommand(args, logger) {
62
65
  var _a, _b;
63
- const { $0, _: positional, help = false, jsonHelp = false, ...rest } = yargsParser(args, { boolean: ['help', 'json-help'], alias: { 'collection': 'c' } });
66
+ const { $0, _, help = false, jsonHelp = false, getYargsCompletions = false, ...rest } = yargsParser(args, {
67
+ boolean: ['help', 'json-help', 'get-yargs-completions'],
68
+ alias: { 'collection': 'c' },
69
+ });
70
+ // When `getYargsCompletions` is true the scriptName 'ng' at index 0 is not removed.
71
+ const positional = getYargsCompletions ? _.slice(1) : _;
64
72
  let workspace;
65
73
  let globalConfiguration;
66
74
  try {
@@ -86,6 +94,7 @@ async function runCommand(args, logger) {
86
94
  options: {
87
95
  help,
88
96
  jsonHelp,
97
+ getYargsCompletions,
89
98
  ...rest,
90
99
  },
91
100
  },
@@ -103,7 +112,8 @@ async function runCommand(args, logger) {
103
112
  }
104
113
  if (jsonHelp) {
105
114
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
- localYargs.getInternalMethods().getUsageInstance().help = () => (0, json_help_1.jsonHelpUsage)();
115
+ const usageInstance = localYargs.getInternalMethods().getUsageInstance();
116
+ usageInstance.help = () => (0, json_help_1.jsonHelpUsage)();
107
117
  }
108
118
  await localYargs
109
119
  .scriptName('ng')
@@ -135,6 +145,7 @@ async function runCommand(args, logger) {
135
145
  })
136
146
  .demandCommand(1, command_1.demandCommandFailureMessage)
137
147
  .recommendCommands()
148
+ .middleware(normalize_options_middleware_1.normalizeOptionsMiddleware)
138
149
  .version(false)
139
150
  .showHelpOnFail(false)
140
151
  .strict()
@@ -40,6 +40,7 @@ exports.SchematicsCommandModule = exports.DEFAULT_SCHEMATICS_COLLECTION = void 0
40
40
  const core_1 = require("@angular-devkit/core");
41
41
  const schematics_1 = require("@angular-devkit/schematics");
42
42
  const tools_1 = require("@angular-devkit/schematics/tools");
43
+ const path_1 = require("path");
43
44
  const config_1 = require("../utilities/config");
44
45
  const memoize_1 = require("../utilities/memoize");
45
46
  const tty_1 = require("../utilities/tty");
@@ -109,9 +110,7 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
109
110
  optionTransforms: [
110
111
  // Add configuration file defaults
111
112
  async (schematic, current) => {
112
- const projectName = typeof current.project === 'string'
113
- ? current.project
114
- : this.getProjectName();
113
+ const projectName = typeof (current === null || current === void 0 ? void 0 : current.project) === 'string' ? current.project : this.getProjectName();
115
114
  return {
116
115
  ...(await (0, config_1.getSchematicDefaults)(schematic.collection.name, schematic.name, projectName)),
117
116
  ...current,
@@ -211,16 +210,20 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
211
210
  }
212
211
  async getSchematicCollections() {
213
212
  var _a;
213
+ // Resolve relative collections from the location of `angular.json`
214
+ const resolveRelativeCollection = (collectionName) => collectionName.charAt(0) === '.'
215
+ ? (0, path_1.resolve)(this.context.root, collectionName)
216
+ : collectionName;
214
217
  const getSchematicCollections = (configSection) => {
215
218
  if (!configSection) {
216
219
  return undefined;
217
220
  }
218
221
  const { schematicCollections, defaultCollection } = configSection;
219
222
  if (Array.isArray(schematicCollections)) {
220
- return new Set(schematicCollections);
223
+ return new Set(schematicCollections.map((c) => resolveRelativeCollection(c)));
221
224
  }
222
225
  else if (typeof defaultCollection === 'string') {
223
- return new Set([defaultCollection]);
226
+ return new Set([resolveRelativeCollection(defaultCollection)]);
224
227
  }
225
228
  return undefined;
226
229
  };
@@ -277,11 +280,11 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
277
280
  if (err instanceof schematics_1.UnsuccessfulWorkflowExecution) {
278
281
  // "See above" because we already printed the error.
279
282
  logger.fatal('The Schematic workflow failed. See above.');
280
- return 1;
281
283
  }
282
284
  else {
283
- throw err;
285
+ logger.fatal(err.message);
284
286
  }
287
+ return 1;
285
288
  }
286
289
  finally {
287
290
  unsubscribe();
@@ -8,6 +8,6 @@
8
8
  import { Argv } from 'yargs';
9
9
  import { CommandContext, CommandModule, CommandModuleImplementation } from '../command-module';
10
10
  export declare const demandCommandFailureMessage = "You need to specify a command before moving on. Use '--help' to view the available commands.";
11
- export declare function addCommandModuleToYargs<T, U extends Partial<CommandModuleImplementation> & {
11
+ export declare function addCommandModuleToYargs<T extends object, U extends Partial<CommandModuleImplementation> & {
12
12
  new (context: CommandContext): Partial<CommandModuleImplementation> & CommandModule;
13
13
  }>(localYargs: Argv<T>, commandModule: U, context: CommandContext): Argv<T>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import * as yargs from 'yargs';
9
+ /**
10
+ * A Yargs middleware that normalizes non Array options when the argument has been provided multiple times.
11
+ *
12
+ * By default, when an option is non array and it is provided multiple times in the command line, yargs
13
+ * will not override it's value but instead it will be changed to an array unless `duplicate-arguments-array` is disabled.
14
+ * But this option also have an effect on real array options which isn't desired.
15
+ *
16
+ * See: https://github.com/yargs/yargs-parser/pull/163#issuecomment-516566614
17
+ */
18
+ export declare function normalizeOptionsMiddleware(args: yargs.Arguments): void;