@angular/cli 14.0.0-next.2 → 14.0.0-next.5

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 (211) hide show
  1. package/bin/ng.js +3 -5
  2. package/bin/postinstall/analytics-prompt.js +1 -1
  3. package/lib/cli/index.d.ts +1 -1
  4. package/lib/cli/index.js +16 -18
  5. package/lib/config/schema.json +4 -8
  6. package/lib/init.js +3 -3
  7. package/models/command.d.ts +14 -19
  8. package/models/command.js +13 -106
  9. package/models/interface.d.ts +3 -180
  10. package/models/interface.js +0 -22
  11. package/models/schematic-command.d.ts +6 -18
  12. package/models/schematic-command.js +16 -123
  13. package/package.json +16 -15
  14. package/{models → src/analytics}/analytics-collector.d.ts +0 -0
  15. package/{models → src/analytics}/analytics-collector.js +1 -1
  16. package/{models → src/analytics}/analytics.d.ts +2 -0
  17. package/{models → src/analytics}/analytics.js +33 -2
  18. package/src/command-builder/architect-base-command-module.d.ts +23 -0
  19. package/src/command-builder/architect-base-command-module.js +105 -0
  20. package/src/command-builder/architect-command-module.d.ts +22 -0
  21. package/src/command-builder/architect-command-module.js +110 -0
  22. package/src/command-builder/command-module.d.ts +85 -0
  23. package/src/command-builder/command-module.js +185 -0
  24. package/src/command-builder/command-runner.d.ts +10 -0
  25. package/src/command-builder/command-runner.js +146 -0
  26. package/src/command-builder/schematics-command-module.d.ts +31 -0
  27. package/src/command-builder/schematics-command-module.js +117 -0
  28. package/src/command-builder/utilities/json-help.d.ts +34 -0
  29. package/src/command-builder/utilities/json-help.js +90 -0
  30. package/src/command-builder/utilities/json-schema.d.ts +40 -0
  31. package/{utilities → src/command-builder/utilities}/json-schema.js +20 -121
  32. package/src/commands/add/add-impl.d.ts +22 -0
  33. package/{commands → src/commands/add}/add-impl.js +24 -32
  34. package/src/commands/add/cli.d.ts +23 -0
  35. package/src/commands/add/cli.js +48 -0
  36. package/{commands/add.md → src/commands/add/long-description.md} +0 -0
  37. package/src/commands/analytics/cli.d.ts +21 -0
  38. package/src/commands/analytics/cli.js +70 -0
  39. package/src/commands/analytics/long-description.md +10 -0
  40. package/src/commands/build/cli.d.ts +16 -0
  41. package/src/commands/build/cli.js +23 -0
  42. package/{commands/build-long.md → src/commands/build/long-description.md} +0 -0
  43. package/src/commands/config/cli.d.ts +21 -0
  44. package/src/commands/config/cli.js +46 -0
  45. package/{commands → src/commands/config}/config-impl.d.ts +7 -5
  46. package/{commands → src/commands/config}/config-impl.js +3 -7
  47. package/{commands/config-long.md → src/commands/config/long-description.md} +2 -2
  48. package/src/commands/deploy/cli.d.ts +16 -0
  49. package/src/commands/deploy/cli.js +35 -0
  50. package/{commands/deploy-long.md → src/commands/deploy/long-description.md} +0 -0
  51. package/src/commands/doc/cli.d.ts +23 -0
  52. package/{commands/doc-impl.js → src/commands/doc/cli.js} +36 -11
  53. package/src/commands/e2e/cli.d.ts +17 -0
  54. package/src/commands/e2e/cli.js +34 -0
  55. package/src/commands/extract-i18n/cli.d.ts +15 -0
  56. package/src/commands/extract-i18n/cli.js +20 -0
  57. package/src/commands/generate/cli.d.ts +27 -0
  58. package/src/commands/generate/cli.js +98 -0
  59. package/src/commands/generate/generate-impl.d.ts +19 -0
  60. package/src/commands/generate/generate-impl.js +49 -0
  61. package/src/commands/lint/cli.d.ts +16 -0
  62. package/src/commands/lint/cli.js +31 -0
  63. package/{commands/lint-long.md → src/commands/lint/long-description.md} +0 -0
  64. package/src/commands/make-this-awesome/cli.d.ts +17 -0
  65. package/{commands/easter-egg-impl.js → src/commands/make-this-awesome/cli.js} +17 -10
  66. package/src/commands/new/cli.d.ts +23 -0
  67. package/src/commands/new/cli.js +36 -0
  68. package/src/commands/new/new-impl.d.ts +18 -0
  69. package/{commands → src/commands/new}/new-impl.js +7 -6
  70. package/src/commands/run/cli.d.ts +23 -0
  71. package/src/commands/run/cli.js +59 -0
  72. package/{commands/run-long.md → src/commands/run/long-description.md} +0 -0
  73. package/src/commands/serve/cli.d.ts +16 -0
  74. package/src/commands/serve/cli.js +21 -0
  75. package/src/commands/test/cli.d.ts +16 -0
  76. package/src/commands/test/cli.js +23 -0
  77. package/{commands/test-long.md → src/commands/test/long-description.md} +0 -0
  78. package/src/commands/update/cli.d.ts +29 -0
  79. package/src/commands/update/cli.js +83 -0
  80. package/{commands/update-long.md → src/commands/update/long-description.md} +0 -0
  81. package/src/commands/update/schematic/index.js +1 -1
  82. package/{commands → src/commands/update}/update-impl.d.ts +8 -6
  83. package/{commands → src/commands/update}/update-impl.js +22 -31
  84. package/src/commands/version/cli.d.ts +19 -0
  85. package/{commands/version-impl.js → src/commands/version/cli.js} +44 -38
  86. package/src/typings.d.ts +2 -2
  87. package/{utilities → src/utilities}/color.d.ts +0 -0
  88. package/{utilities → src/utilities}/color.js +0 -0
  89. package/{utilities → src/utilities}/config.d.ts +1 -1
  90. package/{utilities → src/utilities}/config.js +2 -5
  91. package/{utilities → src/utilities}/find-up.d.ts +0 -0
  92. package/{utilities → src/utilities}/find-up.js +0 -0
  93. package/{utilities → src/utilities}/install-package.d.ts +2 -2
  94. package/{utilities → src/utilities}/install-package.js +1 -1
  95. package/{utilities → src/utilities}/json-file.d.ts +0 -0
  96. package/{utilities → src/utilities}/json-file.js +0 -0
  97. package/{utilities → src/utilities}/log-file.d.ts +0 -0
  98. package/{utilities → src/utilities}/log-file.js +0 -0
  99. package/{utilities → src/utilities}/package-json.d.ts +0 -0
  100. package/{utilities → src/utilities}/package-json.js +0 -0
  101. package/{utilities → src/utilities}/package-manager.d.ts +1 -1
  102. package/{utilities → src/utilities}/package-manager.js +1 -1
  103. package/{utilities → src/utilities}/package-metadata.d.ts +0 -0
  104. package/{utilities → src/utilities}/package-metadata.js +0 -0
  105. package/{utilities → src/utilities}/package-tree.d.ts +0 -0
  106. package/{utilities → src/utilities}/package-tree.js +0 -0
  107. package/{utilities → src/utilities}/project.d.ts +0 -0
  108. package/{utilities → src/utilities}/project.js +0 -0
  109. package/{utilities → src/utilities}/prompt.d.ts +0 -0
  110. package/{utilities → src/utilities}/prompt.js +0 -0
  111. package/{utilities → src/utilities}/spinner.d.ts +0 -0
  112. package/{utilities → src/utilities}/spinner.js +0 -0
  113. package/{utilities → src/utilities}/tty.d.ts +0 -0
  114. package/{utilities → src/utilities}/tty.js +0 -0
  115. package/{models → src/utilities}/version.d.ts +2 -1
  116. package/{models → src/utilities}/version.js +6 -6
  117. package/commands/add-impl.d.ts +0 -21
  118. package/commands/add.d.ts +0 -42
  119. package/commands/add.js +0 -10
  120. package/commands/add.json +0 -54
  121. package/commands/analytics-impl.d.ts +0 -13
  122. package/commands/analytics-impl.js +0 -80
  123. package/commands/analytics-long.md +0 -8
  124. package/commands/analytics.d.ts +0 -46
  125. package/commands/analytics.js +0 -31
  126. package/commands/analytics.json +0 -37
  127. package/commands/build-impl.d.ts +0 -14
  128. package/commands/build-impl.js +0 -21
  129. package/commands/build.d.ts +0 -30
  130. package/commands/build.js +0 -10
  131. package/commands/build.json +0 -16
  132. package/commands/config.d.ts +0 -34
  133. package/commands/config.js +0 -10
  134. package/commands/config.json +0 -43
  135. package/commands/definitions.json +0 -66
  136. package/commands/deploy-impl.d.ts +0 -15
  137. package/commands/deploy-impl.js +0 -36
  138. package/commands/deploy.d.ts +0 -30
  139. package/commands/deploy.js +0 -10
  140. package/commands/deploy.json +0 -34
  141. package/commands/doc-impl.d.ts +0 -13
  142. package/commands/doc.d.ts +0 -39
  143. package/commands/doc.js +0 -14
  144. package/commands/doc.json +0 -46
  145. package/commands/e2e-impl.d.ts +0 -16
  146. package/commands/e2e-impl.js +0 -36
  147. package/commands/e2e-long.md +0 -4
  148. package/commands/e2e.d.ts +0 -29
  149. package/commands/e2e.js +0 -10
  150. package/commands/e2e.json +0 -17
  151. package/commands/easter-egg-impl.d.ts +0 -12
  152. package/commands/easter-egg.d.ts +0 -14
  153. package/commands/easter-egg.js +0 -10
  154. package/commands/easter-egg.json +0 -12
  155. package/commands/extract-i18n-impl.d.ts +0 -14
  156. package/commands/extract-i18n-impl.js +0 -21
  157. package/commands/extract-i18n.d.ts +0 -29
  158. package/commands/extract-i18n.js +0 -10
  159. package/commands/extract-i18n.json +0 -15
  160. package/commands/generate-impl.d.ts +0 -18
  161. package/commands/generate-impl.js +0 -89
  162. package/commands/generate.d.ts +0 -37
  163. package/commands/generate.js +0 -10
  164. package/commands/generate.json +0 -31
  165. package/commands/help-impl.d.ts +0 -12
  166. package/commands/help-impl.js +0 -26
  167. package/commands/help-long.md +0 -7
  168. package/commands/help.d.ts +0 -17
  169. package/commands/help.js +0 -10
  170. package/commands/help.json +0 -13
  171. package/commands/lint-impl.d.ts +0 -16
  172. package/commands/lint-impl.js +0 -69
  173. package/commands/lint.d.ts +0 -29
  174. package/commands/lint.js +0 -10
  175. package/commands/lint.json +0 -36
  176. package/commands/new-impl.d.ts +0 -16
  177. package/commands/new.d.ts +0 -41
  178. package/commands/new.js +0 -10
  179. package/commands/new.json +0 -34
  180. package/commands/new.md +0 -16
  181. package/commands/run-impl.d.ts +0 -13
  182. package/commands/run-impl.js +0 -22
  183. package/commands/run.d.ts +0 -30
  184. package/commands/run.js +0 -10
  185. package/commands/run.json +0 -36
  186. package/commands/serve-impl.d.ts +0 -15
  187. package/commands/serve-impl.js +0 -24
  188. package/commands/serve.d.ts +0 -29
  189. package/commands/serve.js +0 -10
  190. package/commands/serve.json +0 -17
  191. package/commands/test-impl.d.ts +0 -15
  192. package/commands/test-impl.js +0 -22
  193. package/commands/test.d.ts +0 -29
  194. package/commands/test.js +0 -10
  195. package/commands/test.json +0 -17
  196. package/commands/update.d.ts +0 -61
  197. package/commands/update.js +0 -10
  198. package/commands/update.json +0 -78
  199. package/commands/version-impl.d.ts +0 -17
  200. package/commands/version.d.ts +0 -17
  201. package/commands/version.js +0 -10
  202. package/commands/version.json +0 -13
  203. package/commands.json +0 -20
  204. package/models/architect-command.d.ts +0 -35
  205. package/models/architect-command.js +0 -364
  206. package/models/command-runner.d.ts +0 -24
  207. package/models/command-runner.js +0 -241
  208. package/models/parser.d.ts +0 -39
  209. package/models/parser.js +0 -349
  210. package/utilities/INITIAL_COMMIT_MESSAGE.txt +0 -8
  211. package/utilities/json-schema.d.ts +0 -17
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.jsonHelpUsage = void 0;
14
+ const yargs_1 = __importDefault(require("yargs"));
15
+ function jsonHelpUsage() {
16
+ var _a, _b, _c;
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ const localYargs = yargs_1.default;
19
+ const { deprecatedOptions, alias: aliases, array, string, boolean, number, choices, demandedOptions, default: defaultVal, hiddenOptions = [], } = localYargs.getOptions();
20
+ const internalMethods = localYargs.getInternalMethods();
21
+ const usageInstance = internalMethods.getUsageInstance();
22
+ const context = internalMethods.getContext();
23
+ const descriptions = usageInstance.getDescriptions();
24
+ const groups = localYargs.getGroups();
25
+ const positional = groups[usageInstance.getPositionalGroupName()];
26
+ const hidden = new Set(hiddenOptions);
27
+ const normalizeOptions = [];
28
+ const allAliases = new Set([...Object.values(aliases).flat()]);
29
+ for (const [names, type] of [
30
+ [array, 'array'],
31
+ [string, 'string'],
32
+ [boolean, 'boolean'],
33
+ [number, 'number'],
34
+ ]) {
35
+ for (const name of names) {
36
+ if (allAliases.has(name) || hidden.has(name)) {
37
+ // Ignore hidden, aliases and already visited option.
38
+ continue;
39
+ }
40
+ const positionalIndex = (_a = positional === null || positional === void 0 ? void 0 : positional.indexOf(name)) !== null && _a !== void 0 ? _a : -1;
41
+ const alias = aliases[name];
42
+ normalizeOptions.push({
43
+ name,
44
+ type,
45
+ deprecated: deprecatedOptions[name],
46
+ aliases: (alias === null || alias === void 0 ? void 0 : alias.length) > 0 ? alias : undefined,
47
+ default: defaultVal[name],
48
+ required: demandedOptions[name],
49
+ enum: choices[name],
50
+ description: (_b = descriptions[name]) === null || _b === void 0 ? void 0 : _b.replace('__yargsString__:', ''),
51
+ positional: positionalIndex >= 0 ? positionalIndex : undefined,
52
+ });
53
+ }
54
+ }
55
+ // https://github.com/yargs/yargs/blob/00e4ebbe3acd438e73fdb101e75b4f879eb6d345/lib/usage.ts#L124
56
+ const subcommands = usageInstance.getCommands()
57
+ .map(([name, description, _, aliases, deprecated]) => ({
58
+ name: name.split(' ', 1)[0],
59
+ command: name,
60
+ description,
61
+ aliases,
62
+ deprecated,
63
+ }))
64
+ .sort((a, b) => a.name.localeCompare(b.name));
65
+ const parseDescription = (rawDescription) => {
66
+ try {
67
+ const { longDescription, describe: shortDescription, longDescriptionRelativePath, } = JSON.parse(rawDescription);
68
+ return {
69
+ shortDescription,
70
+ longDescriptionRelativePath,
71
+ longDescription,
72
+ };
73
+ }
74
+ catch {
75
+ return {
76
+ shortDescription: rawDescription,
77
+ };
78
+ }
79
+ };
80
+ const [command, rawDescription] = (_c = usageInstance.getUsage()[0]) !== null && _c !== void 0 ? _c : [];
81
+ const output = {
82
+ name: [...context.commands].pop(),
83
+ command: command === null || command === void 0 ? void 0 : command.replace('$0', localYargs['$0']),
84
+ ...parseDescription(rawDescription),
85
+ options: normalizeOptions.sort((a, b) => a.name.localeCompare(b.name)),
86
+ subcommands: subcommands.length ? subcommands : undefined,
87
+ };
88
+ return JSON.stringify(output, undefined, 2);
89
+ }
90
+ exports.jsonHelpUsage = jsonHelpUsage;
@@ -0,0 +1,40 @@
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 { json } from '@angular-devkit/core';
9
+ import yargs from 'yargs';
10
+ /**
11
+ * An option description.
12
+ */
13
+ export interface Option extends yargs.Options {
14
+ /**
15
+ * The name of the option.
16
+ */
17
+ name: string;
18
+ /**
19
+ * Whether this option is required or not.
20
+ */
21
+ required?: boolean;
22
+ /**
23
+ * Format field of this option.
24
+ */
25
+ format?: string;
26
+ /**
27
+ * Whether this option should be hidden from the help output. It will still show up in JSON help.
28
+ */
29
+ hidden?: boolean;
30
+ /**
31
+ * If this option can be used as an argument, the position of the argument. Otherwise omitted.
32
+ */
33
+ positional?: number;
34
+ /**
35
+ * Whether or not to report this option to the Angular Team, and which custom field to use.
36
+ * If this is falsey, do not report this option.
37
+ */
38
+ userAnalytics?: number;
39
+ }
40
+ export declare function parseJsonSchemaToOptions(registry: json.schema.SchemaRegistry, schema: json.JsonObject, interactive?: boolean): Promise<Option[]>;
@@ -7,102 +7,9 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.parseJsonSchemaToOptions = exports.parseJsonSchemaToCommandDescription = exports.parseJsonSchemaToSubCommandDescription = exports.CommandJsonPathException = void 0;
10
+ exports.parseJsonSchemaToOptions = void 0;
11
11
  const core_1 = require("@angular-devkit/core");
12
- const tools_1 = require("@angular-devkit/schematics/tools");
13
- const fs_1 = require("fs");
14
- const path_1 = require("path");
15
- const interface_1 = require("../models/interface");
16
- class CommandJsonPathException extends core_1.BaseException {
17
- constructor(path, name) {
18
- super(`File ${path} was not found while constructing the subcommand ${name}.`);
19
- this.path = path;
20
- this.name = name;
21
- }
22
- }
23
- exports.CommandJsonPathException = CommandJsonPathException;
24
- function _getEnumFromValue(value, enumeration, defaultValue) {
25
- if (typeof value !== 'string') {
26
- return defaultValue;
27
- }
28
- if (Object.values(enumeration).includes(value)) {
29
- return value;
30
- }
31
- return defaultValue;
32
- }
33
- async function parseJsonSchemaToSubCommandDescription(name, jsonPath, registry, schema) {
34
- const options = await parseJsonSchemaToOptions(registry, schema);
35
- const aliases = [];
36
- if (core_1.json.isJsonArray(schema.$aliases)) {
37
- schema.$aliases.forEach((value) => {
38
- if (typeof value == 'string') {
39
- aliases.push(value);
40
- }
41
- });
42
- }
43
- if (core_1.json.isJsonArray(schema.aliases)) {
44
- schema.aliases.forEach((value) => {
45
- if (typeof value == 'string') {
46
- aliases.push(value);
47
- }
48
- });
49
- }
50
- if (typeof schema.alias == 'string') {
51
- aliases.push(schema.alias);
52
- }
53
- let longDescription = '';
54
- if (typeof schema.$longDescription == 'string' && schema.$longDescription) {
55
- const ldPath = (0, path_1.resolve)((0, path_1.dirname)(jsonPath), schema.$longDescription);
56
- try {
57
- longDescription = (0, fs_1.readFileSync)(ldPath, 'utf-8');
58
- }
59
- catch (e) {
60
- throw new CommandJsonPathException(ldPath, name);
61
- }
62
- }
63
- let usageNotes = '';
64
- if (typeof schema.$usageNotes == 'string' && schema.$usageNotes) {
65
- const unPath = (0, path_1.resolve)((0, path_1.dirname)(jsonPath), schema.$usageNotes);
66
- try {
67
- usageNotes = (0, fs_1.readFileSync)(unPath, 'utf-8');
68
- }
69
- catch (e) {
70
- throw new CommandJsonPathException(unPath, name);
71
- }
72
- }
73
- const description = '' + (schema.description === undefined ? '' : schema.description);
74
- return {
75
- name,
76
- description,
77
- ...(longDescription ? { longDescription } : {}),
78
- ...(usageNotes ? { usageNotes } : {}),
79
- options,
80
- aliases,
81
- };
82
- }
83
- exports.parseJsonSchemaToSubCommandDescription = parseJsonSchemaToSubCommandDescription;
84
- async function parseJsonSchemaToCommandDescription(name, jsonPath, registry, schema) {
85
- const subcommand = await parseJsonSchemaToSubCommandDescription(name, jsonPath, registry, schema);
86
- // Before doing any work, let's validate the implementation.
87
- if (typeof schema.$impl != 'string') {
88
- throw new Error(`Command ${name} has an invalid implementation.`);
89
- }
90
- const ref = new tools_1.ExportStringRef(schema.$impl, (0, path_1.dirname)(jsonPath));
91
- const impl = ref.ref;
92
- if (impl === undefined || typeof impl !== 'function') {
93
- throw new Error(`Command ${name} has an invalid implementation.`);
94
- }
95
- const scope = _getEnumFromValue(schema.$scope, interface_1.CommandScope, interface_1.CommandScope.Default);
96
- const hidden = !!schema.$hidden;
97
- return {
98
- ...subcommand,
99
- scope,
100
- hidden,
101
- impl,
102
- };
103
- }
104
- exports.parseJsonSchemaToCommandDescription = parseJsonSchemaToCommandDescription;
105
- async function parseJsonSchemaToOptions(registry, schema) {
12
+ async function parseJsonSchemaToOptions(registry, schema, interactive = true) {
106
13
  const options = [];
107
14
  function visitor(current, pointer, parentSchema) {
108
15
  if (!parentSchema) {
@@ -131,8 +38,7 @@ async function parseJsonSchemaToOptions(registry, schema) {
131
38
  throw new Error('Cannot find type of schema.');
132
39
  }
133
40
  // We only support number, string or boolean (or array of those), so remove everything else.
134
- const types = [...typeSet]
135
- .filter((x) => {
41
+ const types = [...typeSet].filter((x) => {
136
42
  switch (x) {
137
43
  case 'boolean':
138
44
  case 'number':
@@ -149,8 +55,7 @@ async function parseJsonSchemaToOptions(registry, schema) {
149
55
  default:
150
56
  return false;
151
57
  }
152
- })
153
- .map((x) => _getEnumFromValue(x, interface_1.OptionType, interface_1.OptionType.String));
58
+ });
154
59
  if (types.length == 0) {
155
60
  // This means it's not usable on the command line. e.g. an Object.
156
61
  return;
@@ -190,10 +95,11 @@ async function parseJsonSchemaToOptions(registry, schema) {
190
95
  const $default = current.$default;
191
96
  const $defaultIndex = core_1.json.isJsonObject($default) && $default['$source'] == 'argv' ? $default['index'] : undefined;
192
97
  const positional = typeof $defaultIndex == 'number' ? $defaultIndex : undefined;
193
- const required = core_1.json.isJsonArray(current.required)
194
- ? current.required.indexOf(name) != -1
195
- : false;
196
- const aliases = core_1.json.isJsonArray(current.aliases)
98
+ let required = core_1.json.isJsonArray(schema.required) ? schema.required.includes(name) : false;
99
+ if (required && interactive && current['x-prompt']) {
100
+ required = false;
101
+ }
102
+ const alias = core_1.json.isJsonArray(current.aliases)
197
103
  ? [...current.aliases].map((x) => '' + x)
198
104
  : current.alias
199
105
  ? ['' + current.alias]
@@ -209,37 +115,30 @@ async function parseJsonSchemaToOptions(registry, schema) {
209
115
  const option = {
210
116
  name,
211
117
  description: '' + (current.description === undefined ? '' : current.description),
212
- ...(types.length == 1 ? { type } : { type, types }),
213
- ...(defaultValue !== undefined ? { default: defaultValue } : {}),
214
- ...(enumValues && enumValues.length > 0 ? { enum: enumValues } : {}),
118
+ type,
119
+ default: defaultValue,
120
+ choices: enumValues.length ? enumValues : undefined,
215
121
  required,
216
- aliases,
217
- ...(format !== undefined ? { format } : {}),
122
+ alias,
123
+ format,
218
124
  hidden,
219
- ...(userAnalytics ? { userAnalytics } : {}),
220
- ...(deprecated !== undefined ? { deprecated } : {}),
221
- ...(positional !== undefined ? { positional } : {}),
125
+ userAnalytics,
126
+ deprecated,
127
+ positional,
222
128
  };
223
129
  options.push(option);
224
130
  }
225
131
  const flattenedSchema = await registry.flatten(schema).toPromise();
226
132
  core_1.json.schema.visitJsonSchema(flattenedSchema, visitor);
227
- // Sort by positional.
133
+ // Sort by positional and name.
228
134
  return options.sort((a, b) => {
229
135
  if (a.positional) {
230
- if (b.positional) {
231
- return a.positional - b.positional;
232
- }
233
- else {
234
- return 1;
235
- }
136
+ return b.positional ? a.positional - b.positional : a.name.localeCompare(b.name);
236
137
  }
237
138
  else if (b.positional) {
238
139
  return -1;
239
140
  }
240
- else {
241
- return 0;
242
- }
141
+ return a.name.localeCompare(b.name);
243
142
  });
244
143
  }
245
144
  exports.parseJsonSchemaToOptions = parseJsonSchemaToOptions;
@@ -0,0 +1,22 @@
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 { SchematicCommand } from '../../../models/schematic-command';
9
+ import { Options } from '../../command-builder/command-module';
10
+ import { AddCommandArgs } from './cli';
11
+ declare type AddCommandOptions = Options<AddCommandArgs>;
12
+ export declare class AddCommandModule extends SchematicCommand<AddCommandOptions> {
13
+ readonly allowPrivateSchematics = true;
14
+ run(options: AddCommandOptions): Promise<number | void>;
15
+ private isProjectVersionValid;
16
+ reportAnalytics(paths: string[], options: AddCommandOptions, dimensions?: (boolean | number | string)[], metrics?: (boolean | number | string)[]): Promise<void>;
17
+ private isPackageInstalled;
18
+ private executeSchematic;
19
+ private findProjectVersion;
20
+ private hasMismatchedPeer;
21
+ }
22
+ export {};
@@ -10,22 +10,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.AddCommand = void 0;
13
+ exports.AddCommandModule = void 0;
14
14
  const core_1 = require("@angular-devkit/core");
15
15
  const tools_1 = require("@angular-devkit/schematics/tools");
16
16
  const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
17
17
  const path_1 = require("path");
18
18
  const semver_1 = require("semver");
19
- const workspace_schema_1 = require("../lib/config/workspace-schema");
20
- const analytics_1 = require("../models/analytics");
21
- const schematic_command_1 = require("../models/schematic-command");
22
- const color_1 = require("../utilities/color");
23
- const install_package_1 = require("../utilities/install-package");
24
- const package_manager_1 = require("../utilities/package-manager");
25
- const package_metadata_1 = require("../utilities/package-metadata");
26
- const prompt_1 = require("../utilities/prompt");
27
- const spinner_1 = require("../utilities/spinner");
28
- const tty_1 = require("../utilities/tty");
19
+ const workspace_schema_1 = require("../../../lib/config/workspace-schema");
20
+ const schematic_command_1 = require("../../../models/schematic-command");
21
+ const analytics_1 = require("../../analytics/analytics");
22
+ const color_1 = require("../../utilities/color");
23
+ const install_package_1 = require("../../utilities/install-package");
24
+ const package_manager_1 = require("../../utilities/package-manager");
25
+ const package_metadata_1 = require("../../utilities/package-metadata");
26
+ const prompt_1 = require("../../utilities/prompt");
27
+ const spinner_1 = require("../../utilities/spinner");
28
+ const tty_1 = require("../../utilities/tty");
29
29
  /**
30
30
  * The set of packages that should have certain versions excluded from consideration
31
31
  * when attempting to find a compatible version for a package.
@@ -35,19 +35,11 @@ const packageVersionExclusions = {
35
35
  // @angular/localize@9.x versions do not have peer dependencies setup
36
36
  '@angular/localize': '9.x',
37
37
  };
38
- class AddCommand extends schematic_command_1.SchematicCommand {
38
+ class AddCommandModule extends schematic_command_1.SchematicCommand {
39
39
  constructor() {
40
40
  super(...arguments);
41
41
  this.allowPrivateSchematics = true;
42
42
  }
43
- async initialize(options) {
44
- if (options.registry) {
45
- return super.initialize({ ...options, packageRegistry: options.registry });
46
- }
47
- else {
48
- return super.initialize(options);
49
- }
50
- }
51
43
  // eslint-disable-next-line max-lines-per-function
52
44
  async run(options) {
53
45
  var _a;
@@ -72,7 +64,7 @@ class AddCommand extends schematic_command_1.SchematicCommand {
72
64
  if (validVersion) {
73
65
  // Already installed so just run schematic
74
66
  this.logger.info('Skipping installation: Package already installed');
75
- return this.executeSchematic(packageIdentifier.name, options['--']);
67
+ return this.executeSchematic(packageIdentifier.name, options);
76
68
  }
77
69
  }
78
70
  const spinner = new spinner_1.Spinner();
@@ -205,7 +197,7 @@ class AddCommand extends schematic_command_1.SchematicCommand {
205
197
  return status;
206
198
  }
207
199
  }
208
- return this.executeSchematic(collectionName, options['--']);
200
+ return this.executeSchematic(collectionName, options);
209
201
  }
210
202
  async isProjectVersionValid(packageIdentifier) {
211
203
  if (!packageIdentifier.name) {
@@ -251,16 +243,16 @@ class AddCommand extends schematic_command_1.SchematicCommand {
251
243
  }
252
244
  return false;
253
245
  }
254
- async executeSchematic(collectionName, options = []) {
255
- const runOptions = {
256
- schematicOptions: options,
257
- collectionName,
258
- schematicName: 'ng-add',
259
- dryRun: false,
260
- force: false,
261
- };
246
+ async executeSchematic(collectionName, options) {
262
247
  try {
263
- return await this.runSchematic(runOptions);
248
+ const { collection, verbose, registry, skipConfirmation, skipInstall, interactive, force, dryRun, defaults: defaultVal, ...schematicOptions } = options;
249
+ return await this.runSchematic({
250
+ schematicOptions,
251
+ collectionName,
252
+ schematicName: 'ng-add',
253
+ dryRun: false,
254
+ force: false,
255
+ });
264
256
  }
265
257
  catch (e) {
266
258
  if (e instanceof tools_1.NodePackageDoesNotSupportSchematics) {
@@ -336,4 +328,4 @@ class AddCommand extends schematic_command_1.SchematicCommand {
336
328
  return false;
337
329
  }
338
330
  }
339
- exports.AddCommand = AddCommand;
331
+ exports.AddCommandModule = AddCommandModule;
@@ -0,0 +1,23 @@
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 { Argv } from 'yargs';
9
+ import { CommandModuleImplementation, Options, OtherOptions } from '../../command-builder/command-module';
10
+ import { SchematicsCommandArgs, SchematicsCommandModule } from '../../command-builder/schematics-command-module';
11
+ export interface AddCommandArgs extends SchematicsCommandArgs {
12
+ collection: string;
13
+ verbose?: boolean;
14
+ registry?: string;
15
+ 'skip-confirmation'?: boolean;
16
+ }
17
+ export declare class AddCommandModule extends SchematicsCommandModule implements CommandModuleImplementation<AddCommandArgs> {
18
+ command: string;
19
+ describe: string;
20
+ longDescriptionPath: string;
21
+ builder(argv: Argv): Promise<Argv<AddCommandArgs>>;
22
+ run(options: Options<AddCommandArgs> & OtherOptions): Promise<number | void>;
23
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AddCommandModule = void 0;
11
+ const path_1 = require("path");
12
+ const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
13
+ const add_impl_1 = require("./add-impl");
14
+ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModule {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.command = 'add <collection>';
18
+ this.describe = 'Adds support for an external library to your project.';
19
+ this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
20
+ }
21
+ async builder(argv) {
22
+ const localYargs = await super.builder(argv);
23
+ return localYargs
24
+ .positional('collection', {
25
+ description: 'The package to be added.',
26
+ type: 'string',
27
+ demandOption: true,
28
+ })
29
+ .option('registry', { description: 'The NPM registry to use.', type: 'string' })
30
+ .option('verbose', {
31
+ description: 'Display additional details about internal operations during execution.',
32
+ type: 'boolean',
33
+ default: false,
34
+ })
35
+ .option('skip-confirmation', {
36
+ description: 'Skip asking a confirmation prompt before installing and executing the package. ' +
37
+ 'Ensure package name is correct prior to using this option.',
38
+ type: 'boolean',
39
+ default: false,
40
+ })
41
+ .strict(false);
42
+ }
43
+ run(options) {
44
+ const command = new add_impl_1.AddCommandModule(this.context, 'add');
45
+ return command.validateAndRun(options);
46
+ }
47
+ }
48
+ exports.AddCommandModule = AddCommandModule;
@@ -0,0 +1,21 @@
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 { Argv } from 'yargs';
9
+ import { CommandModule, Options } from '../../command-builder/command-module';
10
+ interface AnalyticsCommandArgs {
11
+ 'setting-or-project': 'on' | 'off' | 'ci' | 'project' | 'prompt' | string;
12
+ 'project-setting'?: 'on' | 'off' | 'prompt' | string;
13
+ }
14
+ export declare class AnalyticsCommandModule extends CommandModule<AnalyticsCommandArgs> {
15
+ command: string;
16
+ describe: string;
17
+ longDescriptionPath: string;
18
+ builder(localYargs: Argv): Argv<AnalyticsCommandArgs>;
19
+ run({ settingOrProject, projectSetting, }: Options<AnalyticsCommandArgs>): Promise<number | void>;
20
+ }
21
+ export {};
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AnalyticsCommandModule = void 0;
11
+ const path_1 = require("path");
12
+ const analytics_1 = require("../../analytics/analytics");
13
+ const command_module_1 = require("../../command-builder/command-module");
14
+ class AnalyticsCommandModule extends command_module_1.CommandModule {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.command = 'analytics <setting-or-project>';
18
+ this.describe = 'Configures the gathering of Angular CLI usage metrics.';
19
+ this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
20
+ }
21
+ builder(localYargs) {
22
+ return localYargs
23
+ .positional('setting-or-project', {
24
+ description: 'Directly enables or disables all usage analytics for the user, or prompts the user to set the status interactively, ' +
25
+ 'or sets the default status for the project.',
26
+ choices: ['on', 'off', 'ci', 'prompt'],
27
+ type: 'string',
28
+ demandOption: true,
29
+ })
30
+ .positional('project-setting', {
31
+ description: 'Sets the default analytics enablement status for the project.',
32
+ choices: ['on', 'off', 'prompt'],
33
+ type: 'string',
34
+ })
35
+ .strict();
36
+ }
37
+ async run({ settingOrProject, projectSetting, }) {
38
+ if (settingOrProject === 'project' && projectSetting === undefined) {
39
+ throw new Error('Argument "project" requires a second argument of one of the following value: on, off.');
40
+ }
41
+ switch (settingOrProject) {
42
+ case 'off':
43
+ (0, analytics_1.setAnalyticsConfig)('global', false);
44
+ break;
45
+ case 'on':
46
+ (0, analytics_1.setAnalyticsConfig)('global', true);
47
+ break;
48
+ case 'ci':
49
+ (0, analytics_1.setAnalyticsConfig)('global', 'ci');
50
+ break;
51
+ case 'project':
52
+ switch (projectSetting) {
53
+ case 'off':
54
+ (0, analytics_1.setAnalyticsConfig)('local', false);
55
+ break;
56
+ case 'on':
57
+ (0, analytics_1.setAnalyticsConfig)('local', true);
58
+ break;
59
+ case 'prompt':
60
+ await (0, analytics_1.promptProjectAnalytics)(true);
61
+ break;
62
+ }
63
+ break;
64
+ case 'prompt':
65
+ await (0, analytics_1.promptGlobalAnalytics)(true);
66
+ break;
67
+ }
68
+ }
69
+ }
70
+ exports.AnalyticsCommandModule = AnalyticsCommandModule;
@@ -0,0 +1,10 @@
1
+ The value of `setting-or-project` is one of the following.
2
+
3
+ - `on`: Enables analytics gathering and reporting for the user.
4
+ - `off`: Disables analytics gathering and reporting for the user.
5
+ - `ci`: Enables analytics and configures reporting for use with Continuous Integration,
6
+ which uses a common CI user.
7
+ - `prompt`: Prompts the user to set the status interactively.
8
+ - `project`: Sets the default status for the project to the `project-setting` value, which can be any of the other values. The `project-setting` argument is ignored for all other values of `setting_or_project`.
9
+
10
+ For further details, see [Gathering an Viewing CLI Usage Analytics](cli/usage-analytics-gathering).
@@ -0,0 +1,16 @@
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 { ArchitectCommandModule } from '../../command-builder/architect-command-module';
9
+ import { CommandModuleImplementation } from '../../command-builder/command-module';
10
+ export declare class BuildCommandModule extends ArchitectCommandModule implements CommandModuleImplementation {
11
+ multiTarget: boolean;
12
+ command: string;
13
+ aliases: string[];
14
+ describe: string;
15
+ longDescriptionPath: string;
16
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.BuildCommandModule = void 0;
11
+ const path_1 = require("path");
12
+ const architect_command_module_1 = require("../../command-builder/architect-command-module");
13
+ class BuildCommandModule extends architect_command_module_1.ArchitectCommandModule {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.multiTarget = false;
17
+ this.command = 'build [project]';
18
+ this.aliases = ['b'];
19
+ this.describe = 'Compiles an Angular application or library into an output directory named dist/ at the given output path.';
20
+ this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
21
+ }
22
+ }
23
+ exports.BuildCommandModule = BuildCommandModule;