@angular/cli 14.0.0-next.3 → 14.0.0-next.6

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 (217) hide show
  1. package/bin/ng.js +3 -5
  2. package/bin/postinstall/analytics-prompt.js +3 -3
  3. package/lib/cli/index.d.ts +1 -1
  4. package/lib/cli/index.js +16 -18
  5. package/lib/config/schema.json +8 -12
  6. package/lib/config/workspace-schema.d.ts +1 -1
  7. package/lib/init.js +8 -4
  8. package/package.json +17 -16
  9. package/{models → src/analytics}/analytics-collector.d.ts +0 -0
  10. package/{models → src/analytics}/analytics-collector.js +6 -2
  11. package/src/analytics/analytics-environment-options.d.ts +9 -0
  12. package/src/analytics/analytics-environment-options.js +20 -0
  13. package/src/analytics/analytics.d.ts +47 -0
  14. package/src/analytics/analytics.js +303 -0
  15. package/src/command-builder/architect-base-command-module.d.ts +23 -0
  16. package/src/command-builder/architect-base-command-module.js +103 -0
  17. package/src/command-builder/architect-command-module.d.ts +22 -0
  18. package/src/command-builder/architect-command-module.js +108 -0
  19. package/src/command-builder/command-module.d.ts +88 -0
  20. package/src/command-builder/command-module.js +191 -0
  21. package/src/command-builder/command-runner.d.ts +10 -0
  22. package/src/command-builder/command-runner.js +135 -0
  23. package/src/command-builder/schematics-command-module.d.ts +44 -0
  24. package/src/command-builder/schematics-command-module.js +295 -0
  25. package/src/command-builder/utilities/command.d.ts +13 -0
  26. package/src/command-builder/utilities/command.js +27 -0
  27. package/src/command-builder/utilities/json-help.d.ts +36 -0
  28. package/src/command-builder/utilities/json-help.js +94 -0
  29. package/src/command-builder/utilities/json-schema.d.ts +40 -0
  30. package/{utilities → src/command-builder/utilities}/json-schema.js +20 -121
  31. package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +0 -0
  32. package/{models → src/command-builder/utilities}/schematic-engine-host.js +0 -0
  33. package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
  34. package/src/command-builder/utilities/schematic-workflow.js +68 -0
  35. package/src/commands/add/cli.d.ts +33 -0
  36. package/{commands/add-impl.js → src/commands/add/cli.js} +100 -72
  37. package/{commands/add.md → src/commands/add/long-description.md} +0 -0
  38. package/src/commands/analytics/cli.d.ts +16 -0
  39. package/src/commands/analytics/cli.js +35 -0
  40. package/src/commands/analytics/info/cli.d.ts +16 -0
  41. package/src/commands/analytics/info/cli.js +26 -0
  42. package/src/commands/analytics/settings/cli.d.ts +35 -0
  43. package/src/commands/analytics/settings/cli.js +61 -0
  44. package/src/commands/build/cli.d.ts +16 -0
  45. package/src/commands/build/cli.js +23 -0
  46. package/{commands/build-long.md → src/commands/build/long-description.md} +0 -0
  47. package/src/commands/config/cli.d.ts +24 -0
  48. package/{commands/config-impl.js → src/commands/config/cli.js} +102 -89
  49. package/{commands/config-long.md → src/commands/config/long-description.md} +2 -2
  50. package/src/commands/deploy/cli.d.ts +16 -0
  51. package/src/commands/deploy/cli.js +35 -0
  52. package/{commands/deploy-long.md → src/commands/deploy/long-description.md} +0 -0
  53. package/src/commands/doc/cli.d.ts +23 -0
  54. package/{commands/doc-impl.js → src/commands/doc/cli.js} +41 -12
  55. package/src/commands/e2e/cli.d.ts +17 -0
  56. package/src/commands/e2e/cli.js +34 -0
  57. package/src/commands/extract-i18n/cli.d.ts +15 -0
  58. package/src/commands/extract-i18n/cli.js +20 -0
  59. package/src/commands/generate/cli.d.ts +29 -0
  60. package/src/commands/generate/cli.js +114 -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 +25 -0
  67. package/src/commands/new/cli.js +66 -0
  68. package/src/commands/run/cli.d.ts +23 -0
  69. package/src/commands/run/cli.js +59 -0
  70. package/{commands/run-long.md → src/commands/run/long-description.md} +0 -0
  71. package/src/commands/serve/cli.d.ts +16 -0
  72. package/src/commands/serve/cli.js +21 -0
  73. package/src/commands/test/cli.d.ts +16 -0
  74. package/src/commands/test/cli.js +23 -0
  75. package/{commands/test-long.md → src/commands/test/long-description.md} +0 -0
  76. package/{commands/update-impl.d.ts → src/commands/update/cli.d.ts} +25 -9
  77. package/{commands/update-impl.js → src/commands/update/cli.js} +323 -306
  78. package/{commands/update-long.md → src/commands/update/long-description.md} +0 -0
  79. package/src/commands/update/schematic/index.js +6 -2
  80. package/src/commands/version/cli.d.ts +19 -0
  81. package/{commands/version-impl.js → src/commands/version/cli.js} +57 -56
  82. package/src/typings.d.ts +2 -2
  83. package/{utilities → src/utilities}/color.d.ts +0 -0
  84. package/{utilities → src/utilities}/color.js +5 -1
  85. package/{utilities → src/utilities}/config.d.ts +2 -1
  86. package/{utilities → src/utilities}/config.js +38 -7
  87. package/{utilities → src/utilities}/find-up.d.ts +0 -0
  88. package/{utilities → src/utilities}/find-up.js +5 -1
  89. package/{utilities → src/utilities}/install-package.d.ts +2 -2
  90. package/{utilities → src/utilities}/install-package.js +1 -1
  91. package/{utilities → src/utilities}/json-file.d.ts +0 -0
  92. package/{utilities → src/utilities}/json-file.js +0 -0
  93. package/{utilities → src/utilities}/log-file.d.ts +0 -0
  94. package/{utilities → src/utilities}/log-file.js +0 -0
  95. package/{utilities → src/utilities}/package-json.d.ts +0 -0
  96. package/{utilities → src/utilities}/package-json.js +0 -0
  97. package/{utilities → src/utilities}/package-manager.d.ts +1 -1
  98. package/{utilities → src/utilities}/package-manager.js +1 -1
  99. package/{utilities → src/utilities}/package-metadata.d.ts +0 -0
  100. package/{utilities → src/utilities}/package-metadata.js +5 -1
  101. package/{utilities → src/utilities}/package-tree.d.ts +0 -0
  102. package/{utilities → src/utilities}/package-tree.js +5 -1
  103. package/{utilities → src/utilities}/project.d.ts +0 -0
  104. package/{utilities → src/utilities}/project.js +5 -1
  105. package/{utilities → src/utilities}/prompt.d.ts +0 -0
  106. package/{utilities → src/utilities}/prompt.js +5 -1
  107. package/{utilities → src/utilities}/spinner.d.ts +0 -0
  108. package/{utilities → src/utilities}/spinner.js +0 -0
  109. package/{utilities → src/utilities}/tty.d.ts +0 -0
  110. package/{utilities → src/utilities}/tty.js +0 -0
  111. package/{models → src/utilities}/version.d.ts +2 -1
  112. package/{models → src/utilities}/version.js +6 -6
  113. package/commands/add-impl.d.ts +0 -21
  114. package/commands/add.d.ts +0 -42
  115. package/commands/add.js +0 -10
  116. package/commands/add.json +0 -54
  117. package/commands/analytics-impl.d.ts +0 -13
  118. package/commands/analytics-impl.js +0 -80
  119. package/commands/analytics-long.md +0 -8
  120. package/commands/analytics.d.ts +0 -46
  121. package/commands/analytics.js +0 -31
  122. package/commands/analytics.json +0 -37
  123. package/commands/build-impl.d.ts +0 -14
  124. package/commands/build-impl.js +0 -21
  125. package/commands/build.d.ts +0 -30
  126. package/commands/build.js +0 -10
  127. package/commands/build.json +0 -16
  128. package/commands/config-impl.d.ts +0 -15
  129. package/commands/config.d.ts +0 -34
  130. package/commands/config.js +0 -10
  131. package/commands/config.json +0 -43
  132. package/commands/definitions.json +0 -66
  133. package/commands/deploy-impl.d.ts +0 -15
  134. package/commands/deploy-impl.js +0 -36
  135. package/commands/deploy.d.ts +0 -30
  136. package/commands/deploy.js +0 -10
  137. package/commands/deploy.json +0 -34
  138. package/commands/doc-impl.d.ts +0 -13
  139. package/commands/doc.d.ts +0 -39
  140. package/commands/doc.js +0 -14
  141. package/commands/doc.json +0 -46
  142. package/commands/e2e-impl.d.ts +0 -16
  143. package/commands/e2e-impl.js +0 -36
  144. package/commands/e2e-long.md +0 -4
  145. package/commands/e2e.d.ts +0 -29
  146. package/commands/e2e.js +0 -10
  147. package/commands/e2e.json +0 -17
  148. package/commands/easter-egg-impl.d.ts +0 -12
  149. package/commands/easter-egg.d.ts +0 -14
  150. package/commands/easter-egg.js +0 -10
  151. package/commands/easter-egg.json +0 -12
  152. package/commands/extract-i18n-impl.d.ts +0 -14
  153. package/commands/extract-i18n-impl.js +0 -21
  154. package/commands/extract-i18n.d.ts +0 -29
  155. package/commands/extract-i18n.js +0 -10
  156. package/commands/extract-i18n.json +0 -15
  157. package/commands/generate-impl.d.ts +0 -18
  158. package/commands/generate-impl.js +0 -89
  159. package/commands/generate.d.ts +0 -37
  160. package/commands/generate.js +0 -10
  161. package/commands/generate.json +0 -31
  162. package/commands/help-impl.d.ts +0 -12
  163. package/commands/help-impl.js +0 -26
  164. package/commands/help-long.md +0 -7
  165. package/commands/help.d.ts +0 -17
  166. package/commands/help.js +0 -10
  167. package/commands/help.json +0 -13
  168. package/commands/lint-impl.d.ts +0 -16
  169. package/commands/lint-impl.js +0 -69
  170. package/commands/lint.d.ts +0 -29
  171. package/commands/lint.js +0 -10
  172. package/commands/lint.json +0 -36
  173. package/commands/new-impl.d.ts +0 -16
  174. package/commands/new-impl.js +0 -37
  175. package/commands/new.d.ts +0 -41
  176. package/commands/new.js +0 -10
  177. package/commands/new.json +0 -34
  178. package/commands/new.md +0 -16
  179. package/commands/run-impl.d.ts +0 -13
  180. package/commands/run-impl.js +0 -22
  181. package/commands/run.d.ts +0 -30
  182. package/commands/run.js +0 -10
  183. package/commands/run.json +0 -36
  184. package/commands/serve-impl.d.ts +0 -15
  185. package/commands/serve-impl.js +0 -24
  186. package/commands/serve.d.ts +0 -29
  187. package/commands/serve.js +0 -10
  188. package/commands/serve.json +0 -17
  189. package/commands/test-impl.d.ts +0 -15
  190. package/commands/test-impl.js +0 -22
  191. package/commands/test.d.ts +0 -29
  192. package/commands/test.js +0 -10
  193. package/commands/test.json +0 -17
  194. package/commands/update.d.ts +0 -61
  195. package/commands/update.js +0 -10
  196. package/commands/update.json +0 -78
  197. package/commands/version-impl.d.ts +0 -17
  198. package/commands/version.d.ts +0 -17
  199. package/commands/version.js +0 -10
  200. package/commands/version.json +0 -13
  201. package/commands.json +0 -20
  202. package/models/analytics.d.ts +0 -58
  203. package/models/analytics.js +0 -358
  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/command.d.ts +0 -34
  209. package/models/command.js +0 -143
  210. package/models/interface.d.ts +0 -196
  211. package/models/interface.js +0 -31
  212. package/models/parser.d.ts +0 -39
  213. package/models/parser.js +0 -349
  214. package/models/schematic-command.d.ts +0 -55
  215. package/models/schematic-command.js +0 -485
  216. package/utilities/INITIAL_COMMIT_MESSAGE.txt +0 -8
  217. package/utilities/json-schema.d.ts +0 -17
@@ -7,23 +7,108 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ConfigCommand = void 0;
10
+ exports.ConfigCommandModule = void 0;
11
+ const path_1 = require("path");
11
12
  const uuid_1 = require("uuid");
12
- const command_1 = require("../models/command");
13
- const interface_1 = require("../models/interface");
14
- const config_1 = require("../utilities/config");
15
- const json_file_1 = require("../utilities/json-file");
16
- const validCliPaths = new Map([
17
- ['cli.warnings.versionMismatch', undefined],
18
- ['cli.defaultCollection', undefined],
19
- ['cli.packageManager', undefined],
20
- ['cli.analytics', undefined],
21
- ['cli.analyticsSharing.tracking', undefined],
22
- ['cli.analyticsSharing.uuid', (v) => (v === '' ? (0, uuid_1.v4)() : `${v}`)],
23
- ['cli.cache.enabled', undefined],
24
- ['cli.cache.environment', undefined],
25
- ['cli.cache.path', undefined],
26
- ]);
13
+ const command_module_1 = require("../../command-builder/command-module");
14
+ const config_1 = require("../../utilities/config");
15
+ const json_file_1 = require("../../utilities/json-file");
16
+ class ConfigCommandModule extends command_module_1.CommandModule {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.command = 'config <json-path> [value]';
20
+ this.describe = 'Retrieves or sets Angular configuration values in the angular.json file for the workspace.';
21
+ this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
22
+ }
23
+ builder(localYargs) {
24
+ return localYargs
25
+ .positional('json-path', {
26
+ description: `The configuration key to set or query, in JSON path format. ` +
27
+ `For example: "a[3].foo.bar[2]". If no new value is provided, returns the current value of this key.`,
28
+ type: 'string',
29
+ demandOption: true,
30
+ })
31
+ .positional('value', {
32
+ description: 'If provided, a new value for the given configuration key.',
33
+ type: 'string',
34
+ })
35
+ .option('global', {
36
+ description: `Access the global configuration in the caller's home directory.`,
37
+ alias: ['g'],
38
+ type: 'boolean',
39
+ default: false,
40
+ })
41
+ .strict();
42
+ }
43
+ async run(options) {
44
+ const level = options.global ? 'global' : 'local';
45
+ const [config] = (0, config_1.getWorkspaceRaw)(level);
46
+ if (options.value == undefined) {
47
+ if (!config) {
48
+ this.context.logger.error('No config found.');
49
+ return 1;
50
+ }
51
+ return this.get(config, options);
52
+ }
53
+ else {
54
+ return this.set(options);
55
+ }
56
+ }
57
+ get(jsonFile, options) {
58
+ const { logger } = this.context;
59
+ const value = options.jsonPath
60
+ ? jsonFile.get(parseJsonPath(options.jsonPath))
61
+ : jsonFile.content;
62
+ if (value === undefined) {
63
+ logger.error('Value cannot be found.');
64
+ return 1;
65
+ }
66
+ else if (typeof value === 'string') {
67
+ logger.info(value);
68
+ }
69
+ else {
70
+ logger.info(JSON.stringify(value, null, 2));
71
+ }
72
+ return 0;
73
+ }
74
+ async set(options) {
75
+ var _a, _b, _c;
76
+ if (!((_a = options.jsonPath) === null || _a === void 0 ? void 0 : _a.trim())) {
77
+ throw new command_module_1.CommandModuleError('Invalid Path.');
78
+ }
79
+ const validCliPaths = new Map([
80
+ ['cli.warnings.versionMismatch', undefined],
81
+ ['cli.defaultCollection', undefined],
82
+ ['cli.packageManager', undefined],
83
+ ['cli.analytics', undefined],
84
+ ['cli.analyticsSharing.tracking', undefined],
85
+ ['cli.analyticsSharing.uuid', (v) => (v === '' ? (0, uuid_1.v4)() : `${v}`)],
86
+ ['cli.cache.enabled', undefined],
87
+ ['cli.cache.environment', undefined],
88
+ ['cli.cache.path', undefined],
89
+ ]);
90
+ if (options.global &&
91
+ !options.jsonPath.startsWith('schematics.') &&
92
+ !validCliPaths.has(options.jsonPath)) {
93
+ throw new command_module_1.CommandModuleError('Invalid Path.');
94
+ }
95
+ const [config, configPath] = (0, config_1.getWorkspaceRaw)(options.global ? 'global' : 'local');
96
+ const { logger } = this.context;
97
+ if (!config || !configPath) {
98
+ throw new command_module_1.CommandModuleError('Confguration file cannot be found.');
99
+ }
100
+ const value = (_c = (_b = validCliPaths.get(options.jsonPath)) === null || _b === void 0 ? void 0 : _b(options.value)) !== null && _c !== void 0 ? _c : options.value;
101
+ const modified = config.modify(parseJsonPath(options.jsonPath), normalizeValue(value));
102
+ if (!modified) {
103
+ logger.error('Value cannot be found.');
104
+ return 1;
105
+ }
106
+ await (0, config_1.validateWorkspace)((0, json_file_1.parseJson)(config.content));
107
+ config.save();
108
+ return 0;
109
+ }
110
+ }
111
+ exports.ConfigCommandModule = ConfigCommandModule;
27
112
  /**
28
113
  * Splits a JSON path string into fragments. Fragments can be used to get the value referenced
29
114
  * by the path. For example, a path of "a[3].foo.bar[2]" would give you a fragment array of
@@ -42,7 +127,7 @@ function parseJsonPath(path) {
42
127
  }
43
128
  const match = fragment.match(/([^[]+)((\[.*\])*)/);
44
129
  if (!match) {
45
- throw new Error('Invalid JSON path.');
130
+ throw new command_module_1.CommandModuleError('Invalid JSON path.');
46
131
  }
47
132
  result.push(match[1]);
48
133
  if (match[2]) {
@@ -81,75 +166,3 @@ function normalizeValue(value) {
81
166
  return value;
82
167
  }
83
168
  }
84
- class ConfigCommand extends command_1.Command {
85
- async run(options) {
86
- const level = options.global ? 'global' : 'local';
87
- if (!options.global) {
88
- await this.validateScope(interface_1.CommandScope.InProject);
89
- }
90
- const [config] = (0, config_1.getWorkspaceRaw)(level);
91
- if (options.value == undefined) {
92
- if (!config) {
93
- this.logger.error('No config found.');
94
- return 1;
95
- }
96
- return this.get(config, options);
97
- }
98
- else {
99
- return this.set(options);
100
- }
101
- }
102
- get(jsonFile, options) {
103
- let value;
104
- if (options.jsonPath) {
105
- value = jsonFile.get(parseJsonPath(options.jsonPath));
106
- }
107
- else {
108
- value = jsonFile.content;
109
- }
110
- if (value === undefined) {
111
- this.logger.error('Value cannot be found.');
112
- return 1;
113
- }
114
- else if (typeof value === 'string') {
115
- this.logger.info(value);
116
- }
117
- else {
118
- this.logger.info(JSON.stringify(value, null, 2));
119
- }
120
- return 0;
121
- }
122
- async set(options) {
123
- var _a, _b, _c;
124
- if (!((_a = options.jsonPath) === null || _a === void 0 ? void 0 : _a.trim())) {
125
- throw new Error('Invalid Path.');
126
- }
127
- if (options.global &&
128
- !options.jsonPath.startsWith('schematics.') &&
129
- !validCliPaths.has(options.jsonPath)) {
130
- throw new Error('Invalid Path.');
131
- }
132
- const [config, configPath] = (0, config_1.getWorkspaceRaw)(options.global ? 'global' : 'local');
133
- if (!config || !configPath) {
134
- this.logger.error('Confguration file cannot be found.');
135
- return 1;
136
- }
137
- const jsonPath = parseJsonPath(options.jsonPath);
138
- const value = (_c = (_b = validCliPaths.get(options.jsonPath)) === null || _b === void 0 ? void 0 : _b(options.value)) !== null && _c !== void 0 ? _c : options.value;
139
- const modified = config.modify(jsonPath, normalizeValue(value));
140
- if (!modified) {
141
- this.logger.error('Value cannot be found.');
142
- return 1;
143
- }
144
- try {
145
- await (0, config_1.validateWorkspace)((0, json_file_1.parseJson)(config.content));
146
- }
147
- catch (error) {
148
- this.logger.fatal(error.message);
149
- return 1;
150
- }
151
- config.save();
152
- return 0;
153
- }
154
- }
155
- exports.ConfigCommand = ConfigCommand;
@@ -6,8 +6,8 @@ or indirectly on the command line using this command.
6
6
 
7
7
  The configurable property names match command option names,
8
8
  except that in the configuration file, all names must use camelCase,
9
- while on the command line options can be given in either camelCase or dash-case.
9
+ while on the command line options can be given dash-case.
10
10
 
11
11
  For further details, see [Workspace Configuration](guide/workspace-config).
12
12
 
13
- For configuration of CLI usage analytics, see [Gathering an Viewing CLI Usage Analytics](./usage-analytics-gathering).
13
+ For configuration of CLI usage analytics, 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 DeployCommandModule extends ArchitectCommandModule implements CommandModuleImplementation {
11
+ missingErrorTarget: string;
12
+ multiTarget: boolean;
13
+ command: string;
14
+ longDescriptionPath: string;
15
+ describe: string;
16
+ }
@@ -0,0 +1,35 @@
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.DeployCommandModule = void 0;
11
+ const core_1 = require("@angular-devkit/core");
12
+ const path_1 = require("path");
13
+ const architect_command_module_1 = require("../../command-builder/architect-command-module");
14
+ class DeployCommandModule extends architect_command_module_1.ArchitectCommandModule {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.missingErrorTarget = core_1.tags.stripIndents `
18
+ Cannot find "deploy" target for the specified project.
19
+
20
+ You should add a package that implements deployment capabilities for your
21
+ favorite platform.
22
+
23
+ For example:
24
+ ng add @angular/fire
25
+ ng add @azure/ng-deploy
26
+
27
+ Find more packages on npm https://www.npmjs.com/search?q=ng%20deploy
28
+ `;
29
+ this.multiTarget = false;
30
+ this.command = 'deploy [project]';
31
+ this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
32
+ this.describe = 'Invokes the deploy builder for a specified project or for the default project in the workspace.';
33
+ }
34
+ }
35
+ exports.DeployCommandModule = DeployCommandModule;
@@ -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 { CommandModule, CommandModuleImplementation, Options } from '../../command-builder/command-module';
10
+ interface DocCommandArgs {
11
+ keyword: string;
12
+ search?: boolean;
13
+ version?: string;
14
+ }
15
+ export declare class DocCommandModule extends CommandModule<DocCommandArgs> implements CommandModuleImplementation<DocCommandArgs> {
16
+ command: string;
17
+ aliases: string[];
18
+ describe: string;
19
+ longDescriptionPath?: string | undefined;
20
+ builder(localYargs: Argv): Argv<DocCommandArgs>;
21
+ run(options: Options<DocCommandArgs>): Promise<number | void>;
22
+ }
23
+ export {};
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -29,28 +33,53 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
34
  };
31
35
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.DocCommand = void 0;
36
+ exports.DocCommandModule = void 0;
33
37
  const open_1 = __importDefault(require("open"));
34
- const command_1 = require("../models/command");
35
- class DocCommand extends command_1.Command {
38
+ const command_module_1 = require("../../command-builder/command-module");
39
+ class DocCommandModule extends command_module_1.CommandModule {
40
+ constructor() {
41
+ super(...arguments);
42
+ this.command = 'doc <keyword>';
43
+ this.aliases = ['d'];
44
+ this.describe = 'Opens the official Angular documentation (angular.io) in a browser, and searches for a given keyword.';
45
+ }
46
+ builder(localYargs) {
47
+ return localYargs
48
+ .positional('keyword', {
49
+ description: 'The keyword to search for, as provided in the search bar in angular.io.',
50
+ type: 'string',
51
+ demandOption: true,
52
+ })
53
+ .option('search', {
54
+ description: `Search all of angular.io. Otherwise, searches only API reference documentation.`,
55
+ alias: ['s'],
56
+ type: 'boolean',
57
+ default: false,
58
+ })
59
+ .option('version', {
60
+ description: 'Contains the version of Angular to use for the documentation. ' +
61
+ 'If not provided, the command uses your current Angular core version.',
62
+ type: 'string',
63
+ })
64
+ .strict();
65
+ }
36
66
  async run(options) {
37
- if (!options.keyword) {
38
- this.logger.error('You should specify a keyword, for instance, `ng doc ActivatedRoute`.');
39
- return 0;
40
- }
41
67
  let domain = 'angular.io';
42
68
  if (options.version) {
43
69
  // version can either be a string containing "next"
44
- if (options.version == 'next') {
70
+ if (options.version === 'next') {
45
71
  domain = 'next.angular.io';
72
+ }
73
+ else if (options.version === 'rc') {
74
+ domain = 'rc.angular.io';
46
75
  // or a number where version must be a valid Angular version (i.e. not 0, 1 or 3)
47
76
  }
48
77
  else if (!isNaN(+options.version) && ![0, 1, 3].includes(+options.version)) {
49
78
  domain = `v${options.version}.angular.io`;
50
79
  }
51
80
  else {
52
- this.logger.error('Version should either be a number (2, 4, 5, 6...) or "next"');
53
- return 0;
81
+ this.context.logger.error('Version should either be a number (2, 4, 5, 6...), "rc" or "next"');
82
+ return 1;
54
83
  }
55
84
  }
56
85
  else {
@@ -68,4 +97,4 @@ class DocCommand extends command_1.Command {
68
97
  : `https://${domain}/docs?search=${options.keyword}`);
69
98
  }
70
99
  }
71
- exports.DocCommand = DocCommand;
100
+ exports.DocCommandModule = DocCommandModule;
@@ -0,0 +1,17 @@
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 E2eCommandModule extends ArchitectCommandModule implements CommandModuleImplementation {
11
+ multiTarget: boolean;
12
+ missingErrorTarget: string;
13
+ command: string;
14
+ aliases: string[];
15
+ describe: string;
16
+ longDescriptionPath?: string | undefined;
17
+ }
@@ -0,0 +1,34 @@
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.E2eCommandModule = void 0;
11
+ const core_1 = require("@angular-devkit/core");
12
+ const architect_command_module_1 = require("../../command-builder/architect-command-module");
13
+ class E2eCommandModule extends architect_command_module_1.ArchitectCommandModule {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.multiTarget = true;
17
+ this.missingErrorTarget = core_1.tags.stripIndents `
18
+ Cannot find "e2e" target for the specified project.
19
+
20
+ You should add a package that implements end-to-end testing capabilities.
21
+
22
+ For example:
23
+ Cypress: ng add @cypress/schematic
24
+ Nightwatch: ng add @nightwatch/schematics
25
+ WebdriverIO: ng add @wdio/schematics
26
+
27
+ More options will be added to the list as they become available.
28
+ `;
29
+ this.command = 'e2e [project]';
30
+ this.aliases = ['e'];
31
+ this.describe = 'Builds and serves an Angular application, then runs end-to-end tests.';
32
+ }
33
+ }
34
+ exports.E2eCommandModule = E2eCommandModule;
@@ -0,0 +1,15 @@
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 ExtractI18nCommandModule extends ArchitectCommandModule implements CommandModuleImplementation {
11
+ multiTarget: boolean;
12
+ command: string;
13
+ describe: string;
14
+ longDescriptionPath?: string | undefined;
15
+ }
@@ -0,0 +1,20 @@
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.ExtractI18nCommandModule = void 0;
11
+ const architect_command_module_1 = require("../../command-builder/architect-command-module");
12
+ class ExtractI18nCommandModule extends architect_command_module_1.ArchitectCommandModule {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.multiTarget = false;
16
+ this.command = 'extract-i18n [project]';
17
+ this.describe = 'Extracts i18n messages from source code.';
18
+ }
19
+ }
20
+ exports.ExtractI18nCommandModule = ExtractI18nCommandModule;
@@ -0,0 +1,29 @@
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
+ interface GenerateCommandArgs extends SchematicsCommandArgs {
12
+ schematic?: string;
13
+ }
14
+ export declare class GenerateCommandModule extends SchematicsCommandModule implements CommandModuleImplementation<GenerateCommandArgs> {
15
+ command: string;
16
+ aliases: string;
17
+ describe: string;
18
+ longDescriptionPath?: string | undefined;
19
+ builder(argv: Argv): Promise<Argv<GenerateCommandArgs>>;
20
+ run(options: Options<GenerateCommandArgs> & OtherOptions): Promise<number | void>;
21
+ private getCollectionName;
22
+ /**
23
+ * Generate a command string to be passed to the command builder.
24
+ *
25
+ * @example `component [name]` or `@schematics/angular:component [name]`.
26
+ */
27
+ private generateCommandString;
28
+ }
29
+ export {};
@@ -0,0 +1,114 @@
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.GenerateCommandModule = void 0;
11
+ const core_1 = require("@angular-devkit/core");
12
+ const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
13
+ const command_1 = require("../../command-builder/utilities/command");
14
+ class GenerateCommandModule extends schematics_command_module_1.SchematicsCommandModule {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.command = 'generate';
18
+ this.aliases = 'g';
19
+ this.describe = 'Generates and/or modifies files based on a schematic.';
20
+ }
21
+ async builder(argv) {
22
+ let localYargs = (await super.builder(argv)).command({
23
+ command: '$0 <schematic>',
24
+ describe: 'Run the provided schematic.',
25
+ builder: (localYargs) => localYargs
26
+ .positional('schematic', {
27
+ describe: 'The [collection:schematic] to run.',
28
+ type: 'string',
29
+ demandOption: true,
30
+ })
31
+ .strict(),
32
+ handler: (options) => this.handler(options),
33
+ });
34
+ const collectionName = await this.getCollectionName();
35
+ const workflow = this.getOrCreateWorkflowForBuilder(collectionName);
36
+ const collection = workflow.engine.createCollection(collectionName);
37
+ const schematicsInCollection = collection.description.schematics;
38
+ // We cannot use `collection.listSchematicNames()` as this doesn't return hidden schematics.
39
+ const schematicNames = new Set(Object.keys(schematicsInCollection).sort());
40
+ const [, schematicNameFromArgs] = this.parseSchematicInfo(
41
+ // positional = [generate, component] or [generate]
42
+ this.context.args.positional[1]);
43
+ if (schematicNameFromArgs && schematicNames.has(schematicNameFromArgs)) {
44
+ // No need to process all schematics since we know which one the user invoked.
45
+ schematicNames.clear();
46
+ schematicNames.add(schematicNameFromArgs);
47
+ }
48
+ for (const schematicName of schematicNames) {
49
+ const { description: { schemaJson, aliases: schematicAliases, hidden: schematicHidden }, } = collection.createSchematic(schematicName, true);
50
+ if (!schemaJson) {
51
+ continue;
52
+ }
53
+ const { description, 'x-deprecated': xDeprecated, aliases = schematicAliases, hidden = schematicHidden, } = schemaJson;
54
+ const options = await this.getSchematicOptions(collection, schematicName, workflow);
55
+ localYargs = localYargs.command({
56
+ command: await this.generateCommandString(collectionName, schematicName, options),
57
+ // When 'describe' is set to false, it results in a hidden command.
58
+ describe: hidden === true ? false : typeof description === 'string' ? description : '',
59
+ deprecated: xDeprecated === true || typeof xDeprecated === 'string' ? xDeprecated : false,
60
+ aliases: Array.isArray(aliases) ? aliases : undefined,
61
+ builder: (localYargs) => this.addSchemaOptionsToCommand(localYargs, options).strict(),
62
+ handler: (options) => this.handler({ ...options, schematic: `${collectionName}:${schematicName}` }),
63
+ });
64
+ }
65
+ return localYargs.demandCommand(1, command_1.demandCommandFailureMessage);
66
+ }
67
+ async run(options) {
68
+ const { dryRun, schematic, defaults, force, interactive, ...schematicOptions } = options;
69
+ const [collectionName = await this.getCollectionName(), schematicName = ''] = this.parseSchematicInfo(schematic);
70
+ return this.runSchematic({
71
+ collectionName,
72
+ schematicName,
73
+ schematicOptions,
74
+ executionOptions: {
75
+ dryRun,
76
+ defaults,
77
+ force,
78
+ interactive,
79
+ },
80
+ });
81
+ }
82
+ async getCollectionName() {
83
+ const [collectionName = await this.getDefaultSchematicCollection()] = this.parseSchematicInfo(
84
+ // positional = [generate, component] or [generate]
85
+ this.context.args.positional[1]);
86
+ return collectionName;
87
+ }
88
+ /**
89
+ * Generate a command string to be passed to the command builder.
90
+ *
91
+ * @example `component [name]` or `@schematics/angular:component [name]`.
92
+ */
93
+ async generateCommandString(collectionName, schematicName, options) {
94
+ const [collectionNameFromArgs] = this.parseSchematicInfo(
95
+ // positional = [generate, component] or [generate]
96
+ this.context.args.positional[1]);
97
+ const dasherizedSchematicName = core_1.strings.dasherize(schematicName);
98
+ // Only add the collection name as part of the command when it's not the default collection or when it has been provided via the CLI.
99
+ // Ex:`ng generate @schematics/angular:component`
100
+ const commandName = !!collectionNameFromArgs ||
101
+ (await this.getDefaultSchematicCollection()) !== (await this.getCollectionName())
102
+ ? collectionName + ':' + dasherizedSchematicName
103
+ : dasherizedSchematicName;
104
+ const positionalArgs = options
105
+ .filter((o) => o.positional !== undefined)
106
+ .map((o) => {
107
+ const label = `${core_1.strings.dasherize(o.name)}${o.type === 'array' ? ' ..' : ''}`;
108
+ return o.required ? `<${label}>` : `[${label}]`;
109
+ })
110
+ .join(' ');
111
+ return `${commandName}${positionalArgs ? ' ' + positionalArgs : ''}`;
112
+ }
113
+ }
114
+ exports.GenerateCommandModule = GenerateCommandModule;
@@ -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 LintCommandModule extends ArchitectCommandModule implements CommandModuleImplementation {
11
+ missingErrorTarget: string;
12
+ multiTarget: boolean;
13
+ command: string;
14
+ longDescriptionPath: string;
15
+ describe: string;
16
+ }
@@ -0,0 +1,31 @@
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.LintCommandModule = void 0;
11
+ const core_1 = require("@angular-devkit/core");
12
+ const path_1 = require("path");
13
+ const architect_command_module_1 = require("../../command-builder/architect-command-module");
14
+ class LintCommandModule extends architect_command_module_1.ArchitectCommandModule {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.missingErrorTarget = core_1.tags.stripIndents `
18
+ Cannot find "lint" target for the specified project.
19
+
20
+ You should add a package that implements linting capabilities.
21
+
22
+ For example:
23
+ ng add @angular-eslint/schematics
24
+ `;
25
+ this.multiTarget = true;
26
+ this.command = 'lint [project]';
27
+ this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
28
+ this.describe = 'Runs linting tools on Angular application code in a given project folder.';
29
+ }
30
+ }
31
+ exports.LintCommandModule = LintCommandModule;