@angular/cli 14.0.0-next.1 → 14.0.0-next.12

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 (239) hide show
  1. package/bin/ng.js +3 -5
  2. package/lib/cli/index.d.ts +1 -2
  3. package/lib/cli/index.js +16 -45
  4. package/lib/config/schema.json +48 -15
  5. package/lib/config/workspace-schema.d.ts +18 -1
  6. package/lib/init.js +10 -9
  7. package/package.json +21 -23
  8. package/{models → src/analytics}/analytics-collector.d.ts +0 -0
  9. package/{models → src/analytics}/analytics-collector.js +8 -2
  10. package/src/analytics/analytics.d.ts +47 -0
  11. package/src/analytics/analytics.js +306 -0
  12. package/src/command-builder/architect-base-command-module.d.ts +30 -0
  13. package/src/command-builder/architect-base-command-module.js +165 -0
  14. package/src/command-builder/architect-command-module.d.ts +25 -0
  15. package/src/command-builder/architect-command-module.js +134 -0
  16. package/src/command-builder/command-module.d.ts +89 -0
  17. package/src/command-builder/command-module.js +198 -0
  18. package/{utilities/package-json.js → src/command-builder/command-runner.d.ts} +2 -2
  19. package/src/command-builder/command-runner.js +168 -0
  20. package/src/command-builder/schematics-command-module.d.ts +43 -0
  21. package/src/command-builder/schematics-command-module.js +333 -0
  22. package/src/command-builder/utilities/command.d.ts +13 -0
  23. package/src/command-builder/utilities/command.js +27 -0
  24. package/src/command-builder/utilities/json-help.d.ts +36 -0
  25. package/src/command-builder/utilities/json-help.js +94 -0
  26. package/src/command-builder/utilities/json-schema.d.ts +40 -0
  27. package/{utilities → src/command-builder/utilities}/json-schema.js +20 -121
  28. package/src/command-builder/utilities/normalize-options-middleware.d.ts +18 -0
  29. package/src/command-builder/utilities/normalize-options-middleware.js +59 -0
  30. package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +2 -2
  31. package/{models → src/command-builder/utilities}/schematic-engine-host.js +33 -18
  32. package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
  33. package/src/command-builder/utilities/schematic-workflow.js +68 -0
  34. package/src/commands/add/cli.d.ts +33 -0
  35. package/{commands/add-impl.js → src/commands/add/cli.js} +108 -80
  36. package/src/commands/add/long-description.md +7 -0
  37. package/src/commands/analytics/cli.d.ts +16 -0
  38. package/src/commands/analytics/cli.js +35 -0
  39. package/src/commands/analytics/info/cli.d.ts +16 -0
  40. package/src/commands/analytics/info/cli.js +26 -0
  41. package/src/commands/analytics/settings/cli.d.ts +35 -0
  42. package/src/commands/analytics/settings/cli.js +61 -0
  43. package/src/commands/build/cli.d.ts +16 -0
  44. package/src/commands/build/cli.js +23 -0
  45. package/{commands/build-long.md → src/commands/build/long-description.md} +0 -0
  46. package/src/commands/cache/clean/cli.d.ts +17 -0
  47. package/src/commands/cache/clean/cli.js +32 -0
  48. package/src/commands/cache/cli.d.ts +17 -0
  49. package/src/commands/cache/cli.js +38 -0
  50. package/src/commands/cache/info/cli.d.ts +20 -0
  51. package/src/commands/cache/info/cli.js +82 -0
  52. package/src/commands/cache/long-description.md +53 -0
  53. package/src/commands/cache/settings/cli.d.ts +27 -0
  54. package/src/commands/cache/settings/cli.js +42 -0
  55. package/src/commands/cache/utilities.d.ts +11 -0
  56. package/src/commands/cache/utilities.js +49 -0
  57. package/src/commands/completion/cli.d.ts +16 -0
  58. package/src/commands/completion/cli.js +31 -0
  59. package/src/commands/completion/long-description.md +1 -0
  60. package/src/commands/config/cli.d.ts +24 -0
  61. package/{commands/config-impl.js → src/commands/config/cli.js} +102 -89
  62. package/{commands/config-long.md → src/commands/config/long-description.md} +2 -2
  63. package/src/commands/deploy/cli.d.ts +17 -0
  64. package/src/commands/deploy/cli.js +49 -0
  65. package/{commands/deploy-long.md → src/commands/deploy/long-description.md} +0 -0
  66. package/src/commands/doc/cli.d.ts +23 -0
  67. package/{commands/doc-impl.js → src/commands/doc/cli.js} +41 -12
  68. package/src/commands/e2e/cli.d.ts +18 -0
  69. package/src/commands/e2e/cli.js +35 -0
  70. package/src/commands/extract-i18n/cli.d.ts +15 -0
  71. package/src/commands/extract-i18n/cli.js +20 -0
  72. package/src/commands/generate/cli.d.ts +39 -0
  73. package/src/commands/generate/cli.js +145 -0
  74. package/src/commands/lint/cli.d.ts +17 -0
  75. package/src/commands/lint/cli.js +28 -0
  76. package/{commands/lint-long.md → src/commands/lint/long-description.md} +0 -0
  77. package/src/commands/make-this-awesome/cli.d.ts +17 -0
  78. package/{commands/easter-egg-impl.js → src/commands/make-this-awesome/cli.js} +17 -10
  79. package/src/commands/new/cli.d.ts +27 -0
  80. package/src/commands/new/cli.js +82 -0
  81. package/src/commands/run/cli.d.ts +25 -0
  82. package/src/commands/run/cli.js +83 -0
  83. package/{commands/run-long.md → src/commands/run/long-description.md} +0 -0
  84. package/src/commands/serve/cli.d.ts +16 -0
  85. package/src/commands/serve/cli.js +21 -0
  86. package/src/commands/test/cli.d.ts +16 -0
  87. package/src/commands/test/cli.js +23 -0
  88. package/{commands/test-long.md → src/commands/test/long-description.md} +0 -0
  89. package/{commands/update-impl.d.ts → src/commands/update/cli.d.ts} +26 -9
  90. package/{commands/update-impl.js → src/commands/update/cli.js} +363 -316
  91. package/{commands/update-long.md → src/commands/update/long-description.md} +0 -0
  92. package/src/commands/update/schematic/index.js +33 -20
  93. package/src/commands/version/cli.d.ts +18 -0
  94. package/{commands/version-impl.js → src/commands/version/cli.js} +56 -74
  95. package/src/typings-bazel.d.ts +14 -0
  96. package/src/typings.d.ts +1 -14
  97. package/{utilities → src/utilities}/color.d.ts +0 -0
  98. package/{utilities → src/utilities}/color.js +5 -1
  99. package/{utilities → src/utilities}/config.d.ts +6 -5
  100. package/{utilities → src/utilities}/config.js +33 -19
  101. package/src/utilities/environment-options.d.ts +12 -0
  102. package/src/utilities/environment-options.js +24 -0
  103. package/{utilities → src/utilities}/find-up.d.ts +0 -0
  104. package/{utilities → src/utilities}/find-up.js +5 -1
  105. package/{utilities → src/utilities}/json-file.d.ts +0 -0
  106. package/{utilities → src/utilities}/json-file.js +1 -0
  107. package/{utilities → src/utilities}/log-file.d.ts +0 -0
  108. package/{utilities → src/utilities}/log-file.js +0 -0
  109. package/src/utilities/memoize.d.ts +15 -0
  110. package/src/utilities/memoize.js +69 -0
  111. package/src/utilities/package-manager.d.ts +41 -0
  112. package/src/utilities/package-manager.js +287 -0
  113. package/{utilities → src/utilities}/package-metadata.d.ts +15 -37
  114. package/{utilities → src/utilities}/package-metadata.js +15 -27
  115. package/{utilities → src/utilities}/package-tree.d.ts +2 -2
  116. package/{utilities → src/utilities}/package-tree.js +5 -1
  117. package/{utilities → src/utilities}/project.d.ts +0 -0
  118. package/{utilities → src/utilities}/project.js +5 -1
  119. package/{utilities → src/utilities}/prompt.d.ts +2 -0
  120. package/{utilities → src/utilities}/prompt.js +25 -4
  121. package/{utilities → src/utilities}/spinner.d.ts +0 -0
  122. package/{utilities → src/utilities}/spinner.js +0 -0
  123. package/{utilities → src/utilities}/tty.d.ts +0 -0
  124. package/{utilities → src/utilities}/tty.js +0 -0
  125. package/{models → src/utilities}/version.d.ts +2 -1
  126. package/{models → src/utilities}/version.js +6 -6
  127. package/bin/postinstall/analytics-prompt.js +0 -27
  128. package/bin/postinstall/script.js +0 -16
  129. package/commands/add-impl.d.ts +0 -21
  130. package/commands/add.d.ts +0 -42
  131. package/commands/add.js +0 -10
  132. package/commands/add.json +0 -54
  133. package/commands/add.md +0 -10
  134. package/commands/analytics-impl.d.ts +0 -13
  135. package/commands/analytics-impl.js +0 -80
  136. package/commands/analytics-long.md +0 -8
  137. package/commands/analytics.d.ts +0 -46
  138. package/commands/analytics.js +0 -31
  139. package/commands/analytics.json +0 -37
  140. package/commands/build-impl.d.ts +0 -14
  141. package/commands/build-impl.js +0 -21
  142. package/commands/build.d.ts +0 -30
  143. package/commands/build.js +0 -10
  144. package/commands/build.json +0 -16
  145. package/commands/config-impl.d.ts +0 -15
  146. package/commands/config.d.ts +0 -34
  147. package/commands/config.js +0 -10
  148. package/commands/config.json +0 -43
  149. package/commands/definitions.json +0 -66
  150. package/commands/deploy-impl.d.ts +0 -15
  151. package/commands/deploy-impl.js +0 -36
  152. package/commands/deploy.d.ts +0 -30
  153. package/commands/deploy.js +0 -10
  154. package/commands/deploy.json +0 -34
  155. package/commands/doc-impl.d.ts +0 -13
  156. package/commands/doc.d.ts +0 -39
  157. package/commands/doc.js +0 -14
  158. package/commands/doc.json +0 -46
  159. package/commands/e2e-impl.d.ts +0 -16
  160. package/commands/e2e-impl.js +0 -36
  161. package/commands/e2e-long.md +0 -4
  162. package/commands/e2e.d.ts +0 -29
  163. package/commands/e2e.js +0 -10
  164. package/commands/e2e.json +0 -17
  165. package/commands/easter-egg-impl.d.ts +0 -12
  166. package/commands/easter-egg.d.ts +0 -14
  167. package/commands/easter-egg.js +0 -10
  168. package/commands/easter-egg.json +0 -12
  169. package/commands/extract-i18n-impl.d.ts +0 -14
  170. package/commands/extract-i18n-impl.js +0 -32
  171. package/commands/extract-i18n.d.ts +0 -29
  172. package/commands/extract-i18n.js +0 -10
  173. package/commands/extract-i18n.json +0 -17
  174. package/commands/generate-impl.d.ts +0 -18
  175. package/commands/generate-impl.js +0 -89
  176. package/commands/generate.d.ts +0 -37
  177. package/commands/generate.js +0 -10
  178. package/commands/generate.json +0 -31
  179. package/commands/help-impl.d.ts +0 -12
  180. package/commands/help-impl.js +0 -26
  181. package/commands/help-long.md +0 -7
  182. package/commands/help.d.ts +0 -17
  183. package/commands/help.js +0 -10
  184. package/commands/help.json +0 -13
  185. package/commands/lint-impl.d.ts +0 -16
  186. package/commands/lint-impl.js +0 -69
  187. package/commands/lint.d.ts +0 -29
  188. package/commands/lint.js +0 -10
  189. package/commands/lint.json +0 -36
  190. package/commands/new-impl.d.ts +0 -16
  191. package/commands/new-impl.js +0 -37
  192. package/commands/new.d.ts +0 -41
  193. package/commands/new.js +0 -10
  194. package/commands/new.json +0 -34
  195. package/commands/new.md +0 -16
  196. package/commands/run-impl.d.ts +0 -13
  197. package/commands/run-impl.js +0 -22
  198. package/commands/run.d.ts +0 -30
  199. package/commands/run.js +0 -10
  200. package/commands/run.json +0 -36
  201. package/commands/serve-impl.d.ts +0 -15
  202. package/commands/serve-impl.js +0 -24
  203. package/commands/serve.d.ts +0 -29
  204. package/commands/serve.js +0 -10
  205. package/commands/serve.json +0 -17
  206. package/commands/test-impl.d.ts +0 -15
  207. package/commands/test-impl.js +0 -22
  208. package/commands/test.d.ts +0 -29
  209. package/commands/test.js +0 -10
  210. package/commands/test.json +0 -17
  211. package/commands/update.d.ts +0 -61
  212. package/commands/update.js +0 -10
  213. package/commands/update.json +0 -78
  214. package/commands/version-impl.d.ts +0 -17
  215. package/commands/version.d.ts +0 -17
  216. package/commands/version.js +0 -10
  217. package/commands/version.json +0 -13
  218. package/commands.json +0 -20
  219. package/models/analytics.d.ts +0 -58
  220. package/models/analytics.js +0 -358
  221. package/models/architect-command.d.ts +0 -35
  222. package/models/architect-command.js +0 -364
  223. package/models/command-runner.d.ts +0 -24
  224. package/models/command-runner.js +0 -241
  225. package/models/command.d.ts +0 -34
  226. package/models/command.js +0 -143
  227. package/models/interface.d.ts +0 -196
  228. package/models/interface.js +0 -31
  229. package/models/parser.d.ts +0 -39
  230. package/models/parser.js +0 -349
  231. package/models/schematic-command.d.ts +0 -55
  232. package/models/schematic-command.js +0 -485
  233. package/utilities/INITIAL_COMMIT_MESSAGE.txt +0 -8
  234. package/utilities/install-package.d.ts +0 -16
  235. package/utilities/install-package.js +0 -193
  236. package/utilities/json-schema.d.ts +0 -17
  237. package/utilities/package-json.d.ts +0 -249
  238. package/utilities/package-manager.d.ts +0 -13
  239. package/utilities/package-manager.js +0 -106
@@ -0,0 +1,49 @@
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 path_1 = require("path");
12
+ const architect_command_module_1 = require("../../command-builder/architect-command-module");
13
+ class DeployCommandModule extends architect_command_module_1.ArchitectCommandModule {
14
+ constructor() {
15
+ super(...arguments);
16
+ // The below choices should be kept in sync with the list in https://angular.io/guide/deployment
17
+ this.missingTargetChoices = [
18
+ {
19
+ name: 'Amazon S3',
20
+ value: '@jefiozie/ngx-aws-deploy',
21
+ },
22
+ {
23
+ name: 'Azure',
24
+ value: '@azure/ng-deploy',
25
+ },
26
+ {
27
+ name: 'Firebase',
28
+ value: '@angular/fire',
29
+ },
30
+ {
31
+ name: 'Netlify',
32
+ value: '@netlify-builder/deploy',
33
+ },
34
+ {
35
+ name: 'NPM',
36
+ value: 'ngx-deploy-npm',
37
+ },
38
+ {
39
+ name: 'GitHub Pages',
40
+ value: 'angular-cli-ghpages',
41
+ },
42
+ ];
43
+ this.multiTarget = false;
44
+ this.command = 'deploy [project]';
45
+ this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
46
+ this.describe = 'Invokes the deploy builder for a specified project or for the default project in the workspace.';
47
+ }
48
+ }
49
+ 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;
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,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 { MissingTargetChoice } from '../../command-builder/architect-base-command-module';
9
+ import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
10
+ import { CommandModuleImplementation } from '../../command-builder/command-module';
11
+ export declare class E2eCommandModule extends ArchitectCommandModule implements CommandModuleImplementation {
12
+ missingTargetChoices: MissingTargetChoice[];
13
+ multiTarget: boolean;
14
+ command: string;
15
+ aliases: string[];
16
+ describe: string;
17
+ longDescriptionPath?: string;
18
+ }
@@ -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.E2eCommandModule = void 0;
11
+ const architect_command_module_1 = require("../../command-builder/architect-command-module");
12
+ class E2eCommandModule extends architect_command_module_1.ArchitectCommandModule {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.missingTargetChoices = [
16
+ {
17
+ name: 'Cypress',
18
+ value: '@cypress/schematic',
19
+ },
20
+ {
21
+ name: 'Nightwatch',
22
+ value: '@nightwatch/schematics',
23
+ },
24
+ {
25
+ name: 'WebdriverIO',
26
+ value: '@wdio/schematics',
27
+ },
28
+ ];
29
+ this.multiTarget = true;
30
+ this.command = 'e2e [project]';
31
+ this.aliases = ['e'];
32
+ this.describe = 'Builds and serves an Angular application, then runs end-to-end tests.';
33
+ }
34
+ }
35
+ 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,39 @@
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 getCollectionNames;
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
+ * Get schematics that can to be registered as subcommands.
30
+ */
31
+ private getSchematics;
32
+ /**
33
+ * Get schematics that should to be registered as subcommands.
34
+ *
35
+ * @returns a sorted list of schematic that needs to be registered as subcommands.
36
+ */
37
+ private getSchematicsToRegister;
38
+ }
39
+ export {};
@@ -0,0 +1,145 @@
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 command_module_1 = require("../../command-builder/command-module");
13
+ const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
14
+ const command_1 = require("../../command-builder/utilities/command");
15
+ class GenerateCommandModule extends schematics_command_module_1.SchematicsCommandModule {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.command = 'generate';
19
+ this.aliases = 'g';
20
+ this.describe = 'Generates and/or modifies files based on a schematic.';
21
+ }
22
+ async builder(argv) {
23
+ let localYargs = (await super.builder(argv)).command({
24
+ command: '$0 <schematic>',
25
+ describe: 'Run the provided schematic.',
26
+ builder: (localYargs) => localYargs
27
+ .positional('schematic', {
28
+ describe: 'The [collection:schematic] to run.',
29
+ type: 'string',
30
+ demandOption: true,
31
+ })
32
+ .strict(),
33
+ handler: (options) => this.handler(options),
34
+ });
35
+ for (const [schematicName, collectionName] of await this.getSchematicsToRegister()) {
36
+ const workflow = this.getOrCreateWorkflowForBuilder(collectionName);
37
+ const collection = workflow.engine.createCollection(collectionName);
38
+ const { description: { schemaJson, aliases: schematicAliases, hidden: schematicHidden, description: schematicDescription, }, } = collection.createSchematic(schematicName, true);
39
+ if (!schemaJson) {
40
+ continue;
41
+ }
42
+ const { 'x-deprecated': xDeprecated, description = schematicDescription, aliases = schematicAliases, hidden = schematicHidden, } = schemaJson;
43
+ const options = await this.getSchematicOptions(collection, schematicName, workflow);
44
+ localYargs = localYargs.command({
45
+ command: await this.generateCommandString(collectionName, schematicName, options),
46
+ // When 'describe' is set to false, it results in a hidden command.
47
+ describe: hidden === true ? false : typeof description === 'string' ? description : '',
48
+ deprecated: xDeprecated === true || typeof xDeprecated === 'string' ? xDeprecated : false,
49
+ aliases: Array.isArray(aliases) ? aliases : undefined,
50
+ builder: (localYargs) => this.addSchemaOptionsToCommand(localYargs, options).strict(),
51
+ handler: (options) => this.handler({ ...options, schematic: `${collectionName}:${schematicName}` }),
52
+ });
53
+ }
54
+ return localYargs.demandCommand(1, command_1.demandCommandFailureMessage);
55
+ }
56
+ async run(options) {
57
+ const { dryRun, schematic, defaults, force, interactive, ...schematicOptions } = options;
58
+ const [collectionName, schematicName] = this.parseSchematicInfo(schematic);
59
+ if (!collectionName || !schematicName) {
60
+ throw new command_module_1.CommandModuleError('A collection and schematic is required during execution.');
61
+ }
62
+ return this.runSchematic({
63
+ collectionName,
64
+ schematicName,
65
+ schematicOptions,
66
+ executionOptions: {
67
+ dryRun,
68
+ defaults,
69
+ force,
70
+ interactive,
71
+ },
72
+ });
73
+ }
74
+ async getCollectionNames() {
75
+ const [collectionName] = this.parseSchematicInfo(
76
+ // positional = [generate, component] or [generate]
77
+ this.context.args.positional[1]);
78
+ return collectionName ? [collectionName] : [...(await this.getSchematicCollections())];
79
+ }
80
+ /**
81
+ * Generate a command string to be passed to the command builder.
82
+ *
83
+ * @example `component [name]` or `@schematics/angular:component [name]`.
84
+ */
85
+ async generateCommandString(collectionName, schematicName, options) {
86
+ const [collectionNameFromArgs] = this.parseSchematicInfo(
87
+ // positional = [generate, component] or [generate]
88
+ this.context.args.positional[1]);
89
+ const dasherizedSchematicName = core_1.strings.dasherize(schematicName);
90
+ const schematicCollectionsFromConfig = await this.getSchematicCollections();
91
+ const collectionNames = await this.getCollectionNames();
92
+ // Only add the collection name as part of the command when it's not a known
93
+ // schematics collection or when it has been provided via the CLI.
94
+ // Ex:`ng generate @schematics/angular:component`
95
+ const commandName = !!collectionNameFromArgs ||
96
+ !collectionNames.some((c) => schematicCollectionsFromConfig.has(c))
97
+ ? collectionName + ':' + dasherizedSchematicName
98
+ : dasherizedSchematicName;
99
+ const positionalArgs = options
100
+ .filter((o) => o.positional !== undefined)
101
+ .map((o) => {
102
+ const label = `${core_1.strings.dasherize(o.name)}${o.type === 'array' ? ' ..' : ''}`;
103
+ return o.required ? `<${label}>` : `[${label}]`;
104
+ })
105
+ .join(' ');
106
+ return `${commandName}${positionalArgs ? ' ' + positionalArgs : ''}`;
107
+ }
108
+ /**
109
+ * Get schematics that can to be registered as subcommands.
110
+ */
111
+ async *getSchematics() {
112
+ const seenNames = new Set();
113
+ for (const collectionName of await this.getCollectionNames()) {
114
+ const workflow = this.getOrCreateWorkflowForBuilder(collectionName);
115
+ const collection = workflow.engine.createCollection(collectionName);
116
+ for (const schematicName of collection.listSchematicNames(true /** includeHidden */)) {
117
+ // If a schematic with this same name is already registered skip.
118
+ if (!seenNames.has(schematicName)) {
119
+ seenNames.add(schematicName);
120
+ yield { schematicName, collectionName };
121
+ }
122
+ }
123
+ }
124
+ }
125
+ /**
126
+ * Get schematics that should to be registered as subcommands.
127
+ *
128
+ * @returns a sorted list of schematic that needs to be registered as subcommands.
129
+ */
130
+ async getSchematicsToRegister() {
131
+ const schematicsToRegister = [];
132
+ const [, schematicNameFromArgs] = this.parseSchematicInfo(
133
+ // positional = [generate, component] or [generate]
134
+ this.context.args.positional[1]);
135
+ for await (const { schematicName, collectionName } of this.getSchematics()) {
136
+ if (schematicName === schematicNameFromArgs) {
137
+ return [[schematicName, collectionName]];
138
+ }
139
+ schematicsToRegister.push([schematicName, collectionName]);
140
+ }
141
+ // Didn't find the schematic or no schematic name was provided Ex: `ng generate --help`.
142
+ return schematicsToRegister.sort(([nameA], [nameB]) => nameA.localeCompare(nameB, undefined, { sensitivity: 'accent' }));
143
+ }
144
+ }
145
+ exports.GenerateCommandModule = GenerateCommandModule;
@@ -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 { MissingTargetChoice } from '../../command-builder/architect-base-command-module';
9
+ import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
10
+ import { CommandModuleImplementation } from '../../command-builder/command-module';
11
+ export declare class LintCommandModule extends ArchitectCommandModule implements CommandModuleImplementation {
12
+ missingTargetChoices: MissingTargetChoice[];
13
+ multiTarget: boolean;
14
+ command: string;
15
+ longDescriptionPath: string;
16
+ describe: string;
17
+ }
@@ -0,0 +1,28 @@
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 path_1 = require("path");
12
+ const architect_command_module_1 = require("../../command-builder/architect-command-module");
13
+ class LintCommandModule extends architect_command_module_1.ArchitectCommandModule {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.missingTargetChoices = [
17
+ {
18
+ name: 'ESLint',
19
+ value: '@angular-eslint/schematics',
20
+ },
21
+ ];
22
+ this.multiTarget = true;
23
+ this.command = 'lint [project]';
24
+ this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
25
+ this.describe = 'Runs linting tools on Angular application code in a given project folder.';
26
+ }
27
+ }
28
+ exports.LintCommandModule = LintCommandModule;
@@ -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 { Argv } from 'yargs';
9
+ import { CommandModule, CommandModuleImplementation } from '../../command-builder/command-module';
10
+ export declare class AwesomeCommandModule extends CommandModule implements CommandModuleImplementation {
11
+ command: string;
12
+ describe: false;
13
+ deprecated: boolean;
14
+ longDescriptionPath?: string | undefined;
15
+ builder(localYargs: Argv): Argv;
16
+ run(): void;
17
+ }
@@ -7,14 +7,21 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.AwesomeCommand = void 0;
11
- const command_1 = require("../models/command");
12
- const color_1 = require("../utilities/color");
13
- function pickOne(of) {
14
- return of[Math.floor(Math.random() * of.length)];
15
- }
16
- class AwesomeCommand extends command_1.Command {
17
- async run() {
10
+ exports.AwesomeCommandModule = void 0;
11
+ const command_module_1 = require("../../command-builder/command-module");
12
+ const color_1 = require("../../utilities/color");
13
+ class AwesomeCommandModule extends command_module_1.CommandModule {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.command = 'make-this-awesome';
17
+ this.describe = false;
18
+ this.deprecated = false;
19
+ }
20
+ builder(localYargs) {
21
+ return localYargs;
22
+ }
23
+ run() {
24
+ const pickOne = (of) => of[Math.floor(Math.random() * of.length)];
18
25
  const phrase = pickOne([
19
26
  `You're on it, there's nothing for me to do!`,
20
27
  `Let's take a look... nope, it's all good!`,
@@ -25,7 +32,7 @@ class AwesomeCommand extends command_1.Command {
25
32
  `I spy with my little eye a great developer!`,
26
33
  `Noop... already awesome.`,
27
34
  ]);
28
- this.logger.info(color_1.colors.green(phrase));
35
+ this.context.logger.info(color_1.colors.green(phrase));
29
36
  }
30
37
  }
31
- exports.AwesomeCommand = AwesomeCommand;
38
+ exports.AwesomeCommandModule = AwesomeCommandModule;
@@ -0,0 +1,27 @@
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, CommandScope, Options, OtherOptions } from '../../command-builder/command-module';
10
+ import { SchematicsCommandArgs, SchematicsCommandModule } from '../../command-builder/schematics-command-module';
11
+ interface NewCommandArgs extends SchematicsCommandArgs {
12
+ collection?: string;
13
+ }
14
+ export declare class NewCommandModule extends SchematicsCommandModule implements CommandModuleImplementation<NewCommandArgs> {
15
+ private readonly schematicName;
16
+ static scope: CommandScope;
17
+ protected allowPrivateSchematics: boolean;
18
+ command: string;
19
+ aliases: string;
20
+ describe: string;
21
+ longDescriptionPath?: string | undefined;
22
+ builder(argv: Argv): Promise<Argv<NewCommandArgs>>;
23
+ run(options: Options<NewCommandArgs> & OtherOptions): Promise<number | void>;
24
+ /** Find a collection from config that has an `ng-new` schematic. */
25
+ private getCollectionFromConfig;
26
+ }
27
+ export {};
@@ -0,0 +1,82 @@
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.NewCommandModule = void 0;
11
+ const command_module_1 = require("../../command-builder/command-module");
12
+ const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
13
+ const version_1 = require("../../utilities/version");
14
+ class NewCommandModule extends schematics_command_module_1.SchematicsCommandModule {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.schematicName = 'ng-new';
18
+ this.allowPrivateSchematics = true;
19
+ this.command = 'new [name]';
20
+ this.aliases = 'n';
21
+ this.describe = 'Creates a new Angular workspace.';
22
+ }
23
+ async builder(argv) {
24
+ const localYargs = (await super.builder(argv)).option('collection', {
25
+ alias: 'c',
26
+ describe: 'A collection of schematics to use in generating the initial application.',
27
+ type: 'string',
28
+ });
29
+ const { options: { collectionNameFromArgs }, } = this.context.args;
30
+ const collectionName = typeof collectionNameFromArgs === 'string'
31
+ ? collectionNameFromArgs
32
+ : await this.getCollectionFromConfig();
33
+ const workflow = await this.getOrCreateWorkflowForBuilder(collectionName);
34
+ const collection = workflow.engine.createCollection(collectionName);
35
+ const options = await this.getSchematicOptions(collection, this.schematicName, workflow);
36
+ return this.addSchemaOptionsToCommand(localYargs, options);
37
+ }
38
+ async run(options) {
39
+ var _a;
40
+ // Register the version of the CLI in the registry.
41
+ const collectionName = (_a = options.collection) !== null && _a !== void 0 ? _a : (await this.getCollectionFromConfig());
42
+ const { dryRun, force, interactive, defaults, collection, ...schematicOptions } = options;
43
+ const workflow = await this.getOrCreateWorkflowForExecution(collectionName, {
44
+ dryRun,
45
+ force,
46
+ interactive,
47
+ defaults,
48
+ });
49
+ workflow.registry.addSmartDefaultProvider('ng-cli-version', () => version_1.VERSION.full);
50
+ // Compatibility check for NPM 7
51
+ if (collectionName === '@schematics/angular' &&
52
+ !schematicOptions.skipInstall &&
53
+ (schematicOptions.packageManager === undefined || schematicOptions.packageManager === 'npm')) {
54
+ this.context.packageManager.ensureCompatibility();
55
+ }
56
+ return this.runSchematic({
57
+ collectionName,
58
+ schematicName: this.schematicName,
59
+ schematicOptions,
60
+ executionOptions: {
61
+ dryRun,
62
+ force,
63
+ interactive,
64
+ defaults,
65
+ },
66
+ });
67
+ }
68
+ /** Find a collection from config that has an `ng-new` schematic. */
69
+ async getCollectionFromConfig() {
70
+ for (const collectionName of await this.getSchematicCollections()) {
71
+ const workflow = this.getOrCreateWorkflowForBuilder(collectionName);
72
+ const collection = workflow.engine.createCollection(collectionName);
73
+ const schematicsInCollection = collection.description.schematics;
74
+ if (Object.keys(schematicsInCollection).includes(this.schematicName)) {
75
+ return collectionName;
76
+ }
77
+ }
78
+ return schematics_command_module_1.DEFAULT_SCHEMATICS_COLLECTION;
79
+ }
80
+ }
81
+ exports.NewCommandModule = NewCommandModule;
82
+ NewCommandModule.scope = command_module_1.CommandScope.Out;