@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
@@ -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 analytics_1 = require("../../analytics/analytics");
21
+ const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
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,34 +35,64 @@ 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 schematics_command_module_1.SchematicsCommandModule {
39
39
  constructor() {
40
40
  super(...arguments);
41
+ this.command = 'add <collection>';
42
+ this.describe = 'Adds support for an external library to your project.';
43
+ this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
41
44
  this.allowPrivateSchematics = true;
45
+ this.schematicName = 'ng-add';
42
46
  }
43
- async initialize(options) {
44
- if (options.registry) {
45
- return super.initialize({ ...options, packageRegistry: options.registry });
47
+ async builder(argv) {
48
+ const localYargs = (await super.builder(argv))
49
+ .positional('collection', {
50
+ description: 'The package to be added.',
51
+ type: 'string',
52
+ demandOption: true,
53
+ })
54
+ .option('registry', { description: 'The NPM registry to use.', type: 'string' })
55
+ .option('verbose', {
56
+ description: 'Display additional details about internal operations during execution.',
57
+ type: 'boolean',
58
+ default: false,
59
+ })
60
+ .option('skip-confirmation', {
61
+ description: 'Skip asking a confirmation prompt before installing and executing the package. ' +
62
+ 'Ensure package name is correct prior to using this option.',
63
+ type: 'boolean',
64
+ default: false,
65
+ })
66
+ // Prior to downloading we don't know the full schema and therefore we cannot be strict on the options.
67
+ // Possibly in the future update the logic to use the following syntax:
68
+ // `ng add @angular/localize -- --package-options`.
69
+ .strict(false);
70
+ const collectionName = await this.getCollectionName();
71
+ const workflow = await this.getOrCreateWorkflowForBuilder(collectionName);
72
+ try {
73
+ const collection = workflow.engine.createCollection(collectionName);
74
+ const options = await this.getSchematicOptions(collection, this.schematicName, workflow);
75
+ return this.addSchemaOptionsToCommand(localYargs, options);
46
76
  }
47
- else {
48
- return super.initialize(options);
77
+ catch (error) {
78
+ // During `ng add` prior to the downloading of the package
79
+ // we are not able to resolve and create a collection.
80
+ // Or when the the collection value is a path to a tarball.
49
81
  }
82
+ return localYargs;
50
83
  }
51
84
  // eslint-disable-next-line max-lines-per-function
52
85
  async run(options) {
53
86
  var _a;
54
- await (0, package_manager_1.ensureCompatibleNpm)(this.context.root);
55
- if (!options.collection) {
56
- this.logger.fatal(`The "ng add" command requires a name argument to be specified eg. ` +
57
- `${color_1.colors.yellow('ng add [name] ')}. For more details, use "ng help".`);
58
- return 1;
59
- }
87
+ const { root, logger, packageManager } = this.context;
88
+ const { verbose, registry, collection, skipConfirmation } = options;
89
+ await (0, package_manager_1.ensureCompatibleNpm)(root);
60
90
  let packageIdentifier;
61
91
  try {
62
- packageIdentifier = (0, npm_package_arg_1.default)(options.collection);
92
+ packageIdentifier = (0, npm_package_arg_1.default)(collection);
63
93
  }
64
94
  catch (e) {
65
- this.logger.error(e.message);
95
+ logger.error(e.message);
66
96
  return 1;
67
97
  }
68
98
  if (packageIdentifier.name &&
@@ -71,13 +101,12 @@ class AddCommand extends schematic_command_1.SchematicCommand {
71
101
  const validVersion = await this.isProjectVersionValid(packageIdentifier);
72
102
  if (validVersion) {
73
103
  // Already installed so just run schematic
74
- this.logger.info('Skipping installation: Package already installed');
75
- return this.executeSchematic(packageIdentifier.name, options['--']);
104
+ logger.info('Skipping installation: Package already installed');
105
+ return this.executeSchematic({ ...options, collection: packageIdentifier.name });
76
106
  }
77
107
  }
78
108
  const spinner = new spinner_1.Spinner();
79
109
  spinner.start('Determining package manager...');
80
- const packageManager = await (0, package_manager_1.getPackageManager)(this.context.root);
81
110
  const usingYarn = packageManager === workspace_schema_1.PackageManager.Yarn;
82
111
  spinner.info(`Using package manager: ${color_1.colors.grey(packageManager)}`);
83
112
  if (packageIdentifier.name && packageIdentifier.type === 'tag' && !packageIdentifier.rawSpec) {
@@ -86,14 +115,14 @@ class AddCommand extends schematic_command_1.SchematicCommand {
86
115
  spinner.start('Searching for compatible package version...');
87
116
  let packageMetadata;
88
117
  try {
89
- packageMetadata = await (0, package_metadata_1.fetchPackageMetadata)(packageIdentifier.name, this.logger, {
90
- registry: options.registry,
118
+ packageMetadata = await (0, package_metadata_1.fetchPackageMetadata)(packageIdentifier.name, logger, {
119
+ registry,
91
120
  usingYarn,
92
- verbose: options.verbose,
121
+ verbose,
93
122
  });
94
123
  }
95
124
  catch (e) {
96
- spinner.fail('Unable to load package information from registry: ' + e.message);
125
+ spinner.fail(`Unable to load package information from registry: ${e.message}`);
97
126
  return 1;
98
127
  }
99
128
  // Start with the version tagged as `latest` if it exists
@@ -103,15 +132,6 @@ class AddCommand extends schematic_command_1.SchematicCommand {
103
132
  }
104
133
  // Adjust the version based on name and peer dependencies
105
134
  if (latestManifest && Object.keys(latestManifest.peerDependencies).length === 0) {
106
- if (latestManifest.name === '@angular/pwa') {
107
- const version = await this.findProjectVersion('@angular/cli');
108
- const semverOptions = { includePrerelease: true };
109
- if (version &&
110
- (((0, semver_1.validRange)(version) && (0, semver_1.intersects)(version, '7', semverOptions)) ||
111
- ((0, semver_1.valid)(version) && (0, semver_1.satisfies)(version, '7', semverOptions)))) {
112
- packageIdentifier = npm_package_arg_1.default.resolve('@angular/pwa', '0.12');
113
- }
114
- }
115
135
  spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier.toString())}.`);
116
136
  }
117
137
  else if (!latestManifest || (await this.hasMismatchedPeer(latestManifest))) {
@@ -132,7 +152,7 @@ class AddCommand extends schematic_command_1.SchematicCommand {
132
152
  }
133
153
  return true;
134
154
  });
135
- versionManifests.sort((a, b) => (0, semver_1.rcompare)(a.version, b.version, true));
155
+ versionManifests.sort((a, b) => (0, semver_1.compare)(a.version, b.version, true));
136
156
  let newIdentifier;
137
157
  for (const versionManifest of versionManifests) {
138
158
  if (!(await this.hasMismatchedPeer(versionManifest))) {
@@ -156,9 +176,9 @@ class AddCommand extends schematic_command_1.SchematicCommand {
156
176
  let savePackage;
157
177
  try {
158
178
  spinner.start('Loading package information from registry...');
159
- const manifest = await (0, package_metadata_1.fetchPackageManifest)(packageIdentifier.toString(), this.logger, {
160
- registry: options.registry,
161
- verbose: options.verbose,
179
+ const manifest = await (0, package_metadata_1.fetchPackageManifest)(packageIdentifier.toString(), logger, {
180
+ registry,
181
+ verbose,
162
182
  usingYarn,
163
183
  });
164
184
  savePackage = (_a = manifest['ng-add']) === null || _a === void 0 ? void 0 : _a.save;
@@ -174,23 +194,23 @@ class AddCommand extends schematic_command_1.SchematicCommand {
174
194
  spinner.fail(`Unable to fetch package information for '${packageIdentifier}': ${e.message}`);
175
195
  return 1;
176
196
  }
177
- if (!options.skipConfirmation) {
197
+ if (!skipConfirmation) {
178
198
  const confirmationResponse = await (0, prompt_1.askConfirmation)(`\nThe package ${color_1.colors.blue(packageIdentifier.raw)} will be installed and executed.\n` +
179
199
  'Would you like to proceed?', true, false);
180
200
  if (!confirmationResponse) {
181
201
  if (!(0, tty_1.isTTY)()) {
182
- this.logger.error('No terminal detected. ' +
202
+ logger.error('No terminal detected. ' +
183
203
  `'--skip-confirmation' can be used to bypass installation confirmation. ` +
184
204
  `Ensure package name is correct prior to '--skip-confirmation' option usage.`);
185
205
  }
186
- this.logger.error('Command aborted.');
206
+ logger.error('Command aborted.');
187
207
  return 1;
188
208
  }
189
209
  }
190
210
  if (savePackage === false) {
191
211
  // Temporary packages are located in a different directory
192
212
  // Hence we need to resolve them using the temp path
193
- const { status, tempNodeModules } = await (0, install_package_1.installTempPackage)(packageIdentifier.raw, packageManager, options.registry ? [`--registry="${options.registry}"`] : undefined);
213
+ const { status, tempNodeModules } = await (0, install_package_1.installTempPackage)(packageIdentifier.raw, packageManager, registry ? [`--registry="${registry}"`] : undefined);
194
214
  const resolvedCollectionPath = require.resolve((0, path_1.join)(collectionName, 'package.json'), {
195
215
  paths: [tempNodeModules],
196
216
  });
@@ -200,12 +220,12 @@ class AddCommand extends schematic_command_1.SchematicCommand {
200
220
  collectionName = (0, path_1.dirname)(resolvedCollectionPath);
201
221
  }
202
222
  else {
203
- const status = await (0, install_package_1.installPackage)(packageIdentifier.raw, packageManager, savePackage, options.registry ? [`--registry="${options.registry}"`] : undefined);
223
+ const status = await (0, install_package_1.installPackage)(packageIdentifier.raw, packageManager, savePackage, registry ? [`--registry="${registry}"`] : undefined);
204
224
  if (status !== 0) {
205
225
  return status;
206
226
  }
207
227
  }
208
- return this.executeSchematic(collectionName, options['--']);
228
+ return this.executeSchematic({ ...options, collection: collectionName });
209
229
  }
210
230
  async isProjectVersionValid(packageIdentifier) {
211
231
  if (!packageIdentifier.name) {
@@ -228,16 +248,18 @@ class AddCommand extends schematic_command_1.SchematicCommand {
228
248
  }
229
249
  return validVersion;
230
250
  }
231
- async reportAnalytics(paths, options, dimensions = [], metrics = []) {
232
- const collection = options.collection;
251
+ async reportAnalytics(options, paths) {
252
+ const collection = await this.getCollectionName();
253
+ const dimensions = [];
233
254
  // Add the collection if it's safe listed.
234
255
  if (collection && (0, analytics_1.isPackageNameSafeForAnalytics)(collection)) {
235
256
  dimensions[core_1.analytics.NgCliAnalyticsDimensions.NgAddCollection] = collection;
236
257
  }
237
- else {
238
- delete dimensions[core_1.analytics.NgCliAnalyticsDimensions.NgAddCollection];
239
- }
240
- return super.reportAnalytics(paths, options, dimensions, metrics);
258
+ return super.reportAnalytics(options, paths, dimensions);
259
+ }
260
+ async getCollectionName() {
261
+ const [, collectionName] = this.context.args.positional;
262
+ return collectionName;
241
263
  }
242
264
  isPackageInstalled(name) {
243
265
  try {
@@ -251,20 +273,25 @@ class AddCommand extends schematic_command_1.SchematicCommand {
251
273
  }
252
274
  return false;
253
275
  }
254
- async executeSchematic(collectionName, options = []) {
255
- const runOptions = {
256
- schematicOptions: options,
257
- collectionName,
258
- schematicName: 'ng-add',
259
- dryRun: false,
260
- force: false,
261
- };
276
+ async executeSchematic(options) {
262
277
  try {
263
- return await this.runSchematic(runOptions);
278
+ const { verbose, skipConfirmation, interactive, force, dryRun, registry, defaults, collection: collectionName, ...schematicOptions } = options;
279
+ return await this.runSchematic({
280
+ schematicOptions,
281
+ schematicName: this.schematicName,
282
+ collectionName,
283
+ executionOptions: {
284
+ interactive,
285
+ force,
286
+ dryRun,
287
+ defaults,
288
+ packageRegistry: registry,
289
+ },
290
+ });
264
291
  }
265
292
  catch (e) {
266
293
  if (e instanceof tools_1.NodePackageDoesNotSupportSchematics) {
267
- this.logger.error(core_1.tags.oneLine `
294
+ this.context.logger.error(core_1.tags.oneLine `
268
295
  The package that you are trying to add does not support schematics. You can try using
269
296
  a different version of the package or contact the package author to add ng-add support.
270
297
  `);
@@ -274,23 +301,24 @@ class AddCommand extends schematic_command_1.SchematicCommand {
274
301
  }
275
302
  }
276
303
  async findProjectVersion(name) {
304
+ const { logger, root } = this.context;
277
305
  let installedPackage;
278
306
  try {
279
307
  installedPackage = require.resolve((0, path_1.join)(name, 'package.json'), {
280
- paths: [this.context.root],
308
+ paths: [root],
281
309
  });
282
310
  }
283
311
  catch { }
284
312
  if (installedPackage) {
285
313
  try {
286
- const installed = await (0, package_metadata_1.fetchPackageManifest)((0, path_1.dirname)(installedPackage), this.logger);
314
+ const installed = await (0, package_metadata_1.fetchPackageManifest)((0, path_1.dirname)(installedPackage), logger);
287
315
  return installed.version;
288
316
  }
289
317
  catch { }
290
318
  }
291
319
  let projectManifest;
292
320
  try {
293
- projectManifest = await (0, package_metadata_1.fetchPackageManifest)(this.context.root, this.logger);
321
+ projectManifest = await (0, package_metadata_1.fetchPackageManifest)(root, logger);
294
322
  }
295
323
  catch { }
296
324
  if (projectManifest) {
@@ -308,7 +336,7 @@ class AddCommand extends schematic_command_1.SchematicCommand {
308
336
  peerIdentifier = npm_package_arg_1.default.resolve(peer, manifest.peerDependencies[peer]);
309
337
  }
310
338
  catch {
311
- this.logger.warn(`Invalid peer dependency ${peer} found in package.`);
339
+ this.context.logger.warn(`Invalid peer dependency ${peer} found in package.`);
312
340
  continue;
313
341
  }
314
342
  if (peerIdentifier.type === 'version' || peerIdentifier.type === 'range') {
@@ -336,4 +364,4 @@ class AddCommand extends schematic_command_1.SchematicCommand {
336
364
  return false;
337
365
  }
338
366
  }
339
- exports.AddCommand = AddCommand;
367
+ exports.AddCommandModule = AddCommandModule;
@@ -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 { Argv } from 'yargs';
9
+ import { CommandModule, CommandModuleImplementation, Options } from '../../command-builder/command-module';
10
+ export declare class AnalyticsCommandModule extends CommandModule implements CommandModuleImplementation {
11
+ command: string;
12
+ describe: string;
13
+ longDescriptionPath?: string | undefined;
14
+ builder(localYargs: Argv): Argv;
15
+ run(_options: Options<{}>): void;
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.AnalyticsCommandModule = void 0;
11
+ const command_module_1 = require("../../command-builder/command-module");
12
+ const command_1 = require("../../command-builder/utilities/command");
13
+ const cli_1 = require("./info/cli");
14
+ const cli_2 = require("./settings/cli");
15
+ class AnalyticsCommandModule extends command_module_1.CommandModule {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.command = 'analytics';
19
+ this.describe = 'Configures the gathering of Angular CLI usage metrics. See https://angular.io/cli/usage-analytics-gathering';
20
+ }
21
+ builder(localYargs) {
22
+ const subcommands = [
23
+ cli_1.AnalyticsInfoCommandModule,
24
+ cli_2.AnalyticsDisableModule,
25
+ cli_2.AnalyticsEnableModule,
26
+ cli_2.AnalyticsPromptModule,
27
+ ].sort(); // sort by class name.
28
+ for (const module of subcommands) {
29
+ localYargs = (0, command_1.addCommandModuleToYargs)(localYargs, module, this.context);
30
+ }
31
+ return localYargs.demandCommand(1, command_1.demandCommandFailureMessage).strict();
32
+ }
33
+ run(_options) { }
34
+ }
35
+ exports.AnalyticsCommandModule = AnalyticsCommandModule;
@@ -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 { Argv } from 'yargs';
9
+ import { CommandModule, CommandModuleImplementation, Options } from '../../../command-builder/command-module';
10
+ export declare class AnalyticsInfoCommandModule extends CommandModule implements CommandModuleImplementation {
11
+ command: string;
12
+ describe: string;
13
+ longDescriptionPath?: string | undefined;
14
+ builder(localYargs: Argv): Argv;
15
+ run(_options: Options<{}>): Promise<void>;
16
+ }
@@ -0,0 +1,26 @@
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.AnalyticsInfoCommandModule = void 0;
11
+ const analytics_1 = require("../../../analytics/analytics");
12
+ const command_module_1 = require("../../../command-builder/command-module");
13
+ class AnalyticsInfoCommandModule extends command_module_1.CommandModule {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.command = 'info';
17
+ this.describe = 'Prints analytics gathering and reporting configuration in the console.';
18
+ }
19
+ builder(localYargs) {
20
+ return localYargs.strict();
21
+ }
22
+ async run(_options) {
23
+ this.context.logger.info(await (0, analytics_1.getAnalyticsInfoString)());
24
+ }
25
+ }
26
+ exports.AnalyticsInfoCommandModule = AnalyticsInfoCommandModule;
@@ -0,0 +1,35 @@
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 AnalyticsCommandArgs {
11
+ global: boolean;
12
+ }
13
+ declare abstract class AnalyticsSettingModule extends CommandModule<AnalyticsCommandArgs> implements CommandModuleImplementation<AnalyticsCommandArgs> {
14
+ longDescriptionPath?: string | undefined;
15
+ builder(localYargs: Argv): Argv<AnalyticsCommandArgs>;
16
+ abstract run({ global }: Options<AnalyticsCommandArgs>): Promise<void>;
17
+ }
18
+ export declare class AnalyticsDisableModule extends AnalyticsSettingModule implements CommandModuleImplementation<AnalyticsCommandArgs> {
19
+ command: string;
20
+ aliases: string;
21
+ describe: string;
22
+ run({ global }: Options<AnalyticsCommandArgs>): Promise<void>;
23
+ }
24
+ export declare class AnalyticsEnableModule extends AnalyticsSettingModule implements CommandModuleImplementation<AnalyticsCommandArgs> {
25
+ command: string;
26
+ aliases: string;
27
+ describe: string;
28
+ run({ global }: Options<AnalyticsCommandArgs>): Promise<void>;
29
+ }
30
+ export declare class AnalyticsPromptModule extends AnalyticsSettingModule implements CommandModuleImplementation<AnalyticsCommandArgs> {
31
+ command: string;
32
+ describe: string;
33
+ run({ global }: Options<AnalyticsCommandArgs>): Promise<void>;
34
+ }
35
+ export {};
@@ -0,0 +1,61 @@
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.AnalyticsPromptModule = exports.AnalyticsEnableModule = exports.AnalyticsDisableModule = void 0;
11
+ const analytics_1 = require("../../../analytics/analytics");
12
+ const command_module_1 = require("../../../command-builder/command-module");
13
+ class AnalyticsSettingModule extends command_module_1.CommandModule {
14
+ builder(localYargs) {
15
+ return localYargs
16
+ .option('global', {
17
+ description: `Configure analytics gathering and reporting globally in the caller's home directory.`,
18
+ alias: ['g'],
19
+ type: 'boolean',
20
+ default: false,
21
+ })
22
+ .strict();
23
+ }
24
+ }
25
+ class AnalyticsDisableModule extends AnalyticsSettingModule {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.command = 'disable';
29
+ this.aliases = 'off';
30
+ this.describe = 'Disables analytics gathering and reporting for the user.';
31
+ }
32
+ async run({ global }) {
33
+ (0, analytics_1.setAnalyticsConfig)(global, false);
34
+ process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
35
+ }
36
+ }
37
+ exports.AnalyticsDisableModule = AnalyticsDisableModule;
38
+ class AnalyticsEnableModule extends AnalyticsSettingModule {
39
+ constructor() {
40
+ super(...arguments);
41
+ this.command = 'enable';
42
+ this.aliases = 'on';
43
+ this.describe = 'Enables analytics gathering and reporting for the user.';
44
+ }
45
+ async run({ global }) {
46
+ (0, analytics_1.setAnalyticsConfig)(global, true);
47
+ process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
48
+ }
49
+ }
50
+ exports.AnalyticsEnableModule = AnalyticsEnableModule;
51
+ class AnalyticsPromptModule extends AnalyticsSettingModule {
52
+ constructor() {
53
+ super(...arguments);
54
+ this.command = 'prompt';
55
+ this.describe = 'Prompts the user to set the analytics gathering status interactively.';
56
+ }
57
+ async run({ global }) {
58
+ await (0, analytics_1.promptAnalytics)(global, true);
59
+ }
60
+ }
61
+ exports.AnalyticsPromptModule = AnalyticsPromptModule;
@@ -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;
@@ -0,0 +1,24 @@
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 ConfigCommandArgs {
11
+ 'json-path': string;
12
+ value?: string;
13
+ global?: boolean;
14
+ }
15
+ export declare class ConfigCommandModule extends CommandModule<ConfigCommandArgs> implements CommandModuleImplementation<ConfigCommandArgs> {
16
+ command: string;
17
+ describe: string;
18
+ longDescriptionPath: string;
19
+ builder(localYargs: Argv): Argv<ConfigCommandArgs>;
20
+ run(options: Options<ConfigCommandArgs>): Promise<number | void>;
21
+ private get;
22
+ private set;
23
+ }
24
+ export {};