@angular/cli 12.0.0-rc.0 → 12.0.0

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 (134) hide show
  1. package/README.md +34 -30
  2. package/bin/ng +3 -3
  3. package/bin/postinstall/analytics-prompt.js +1 -1
  4. package/commands/add-impl.d.ts +7 -0
  5. package/commands/add-impl.js +18 -20
  6. package/commands/add.json +1 -2
  7. package/commands/add.md +1 -0
  8. package/commands/analytics-impl.d.ts +8 -1
  9. package/commands/analytics-impl.js +7 -7
  10. package/commands/analytics-long.md +8 -7
  11. package/commands/analytics.json +3 -15
  12. package/commands/build-impl.d.ts +1 -1
  13. package/commands/build-impl.js +3 -3
  14. package/commands/build.json +1 -1
  15. package/commands/config-impl.d.ts +2 -2
  16. package/commands/config-impl.js +16 -11
  17. package/commands/config-long.md +1 -1
  18. package/commands/config.json +1 -2
  19. package/commands/definitions.json +3 -5
  20. package/commands/deploy-impl.d.ts +1 -1
  21. package/commands/deploy-impl.js +3 -3
  22. package/commands/deploy-long.md +1 -1
  23. package/commands/deploy.json +1 -3
  24. package/commands/doc-impl.d.ts +1 -1
  25. package/commands/doc-impl.js +2 -2
  26. package/commands/doc.json +3 -4
  27. package/commands/e2e-impl.d.ts +1 -1
  28. package/commands/e2e-impl.js +1 -1
  29. package/commands/e2e-long.md +1 -1
  30. package/commands/e2e.json +1 -1
  31. package/commands/easter-egg-impl.d.ts +1 -1
  32. package/commands/easter-egg-impl.js +3 -3
  33. package/commands/easter-egg.json +1 -3
  34. package/commands/extract-i18n-impl.d.ts +1 -1
  35. package/commands/extract-i18n-impl.js +5 -4
  36. package/commands/generate-impl.d.ts +1 -1
  37. package/commands/generate-impl.js +9 -2
  38. package/commands/generate.json +2 -3
  39. package/commands/help-impl.d.ts +1 -1
  40. package/commands/help-impl.js +3 -3
  41. package/commands/help-long.md +5 -5
  42. package/commands/help.json +1 -3
  43. package/commands/lint-impl.d.ts +1 -1
  44. package/commands/lint-impl.js +3 -3
  45. package/commands/lint-long.md +1 -1
  46. package/commands/lint.json +1 -3
  47. package/commands/new-impl.d.ts +1 -1
  48. package/commands/new-impl.js +8 -1
  49. package/commands/new.json +3 -3
  50. package/commands/new.md +5 -5
  51. package/commands/run-impl.d.ts +1 -1
  52. package/commands/run-impl.js +1 -1
  53. package/commands/run-long.md +1 -1
  54. package/commands/run.json +2 -3
  55. package/commands/serve-impl.d.ts +2 -2
  56. package/commands/serve-impl.js +4 -4
  57. package/commands/serve.json +1 -1
  58. package/commands/test-impl.d.ts +1 -1
  59. package/commands/test-impl.js +1 -1
  60. package/commands/test-long.md +1 -1
  61. package/commands/test.json +1 -1
  62. package/commands/update-impl.d.ts +9 -2
  63. package/commands/update-impl.js +29 -23
  64. package/commands/update.d.ts +2 -1
  65. package/commands/update.json +1 -1
  66. package/commands/version-impl.d.ts +8 -0
  67. package/commands/version-impl.js +19 -6
  68. package/commands/version.json +2 -4
  69. package/lib/cli/index.d.ts +7 -0
  70. package/lib/cli/index.js +14 -16
  71. package/lib/config/schema.json +20 -12
  72. package/lib/config/workspace-schema.d.ts +4 -0
  73. package/lib/init.d.ts +1 -1
  74. package/lib/init.js +11 -10
  75. package/models/analytics-collector.d.ts +1 -2
  76. package/models/analytics-collector.js +7 -8
  77. package/models/analytics.d.ts +7 -0
  78. package/models/analytics.js +6 -8
  79. package/models/architect-command.d.ts +2 -2
  80. package/models/architect-command.js +10 -11
  81. package/models/command-runner.d.ts +1 -1
  82. package/models/command-runner.js +8 -7
  83. package/models/command.d.ts +3 -4
  84. package/models/command.js +17 -21
  85. package/models/error.d.ts +1 -1
  86. package/models/error.js +1 -1
  87. package/models/interface.d.ts +2 -2
  88. package/models/interface.js +7 -0
  89. package/models/parser.d.ts +1 -2
  90. package/models/parser.js +12 -15
  91. package/models/schematic-command.d.ts +1 -1
  92. package/models/schematic-command.js +48 -49
  93. package/models/schematic-engine-host.d.ts +1 -1
  94. package/models/schematic-engine-host.js +4 -4
  95. package/models/version.d.ts +1 -1
  96. package/models/version.js +1 -1
  97. package/package.json +14 -14
  98. package/src/commands/update/schematic/index.d.ts +7 -0
  99. package/src/commands/update/schematic/index.js +59 -56
  100. package/src/commands/update/schematic/npm-package-json.d.ts +1 -1
  101. package/src/commands/update/schematic/npm-package-json.js +7 -0
  102. package/src/commands/update/schematic/npm.d.ts +1 -1
  103. package/src/commands/update/schematic/npm.js +9 -4
  104. package/src/commands/update/schematic/package-json.d.ts +1 -1
  105. package/src/commands/update/schematic/package-json.js +1 -7
  106. package/src/commands/update/schematic/schema.json +2 -8
  107. package/utilities/color.d.ts +1 -1
  108. package/utilities/color.js +3 -3
  109. package/utilities/config.d.ts +1 -1
  110. package/utilities/config.js +24 -7
  111. package/utilities/find-up.d.ts +1 -1
  112. package/utilities/find-up.js +1 -1
  113. package/utilities/install-package.d.ts +7 -5
  114. package/utilities/install-package.js +37 -23
  115. package/utilities/json-file.d.ts +1 -1
  116. package/utilities/json-file.js +4 -4
  117. package/utilities/json-schema.d.ts +1 -1
  118. package/utilities/json-schema.js +30 -27
  119. package/utilities/log-file.d.ts +1 -1
  120. package/utilities/log-file.js +1 -1
  121. package/utilities/package-manager.d.ts +7 -0
  122. package/utilities/package-manager.js +5 -5
  123. package/utilities/package-metadata.d.ts +1 -1
  124. package/utilities/package-metadata.js +8 -1
  125. package/utilities/package-tree.d.ts +1 -1
  126. package/utilities/package-tree.js +1 -1
  127. package/utilities/project.d.ts +7 -0
  128. package/utilities/project.js +3 -3
  129. package/utilities/prompt.d.ts +7 -0
  130. package/utilities/prompt.js +3 -3
  131. package/utilities/spinner.d.ts +1 -1
  132. package/utilities/spinner.js +1 -1
  133. package/utilities/tty.d.ts +1 -1
  134. package/utilities/tty.js +1 -1
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SchematicCommand = exports.UnknownCollectionError = void 0;
4
2
  /**
5
3
  * @license
6
- * Copyright Google Inc. All Rights Reserved.
4
+ * Copyright Google LLC All Rights Reserved.
7
5
  *
8
6
  * Use of this source code is governed by an MIT-style license that can be
9
7
  * found in the LICENSE file at https://angular.io/license
10
8
  */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SchematicCommand = exports.UnknownCollectionError = void 0;
11
11
  const core_1 = require("@angular-devkit/core");
12
12
  const schematics_1 = require("@angular-devkit/schematics");
13
13
  const tools_1 = require("@angular-devkit/schematics/tools");
@@ -43,7 +43,8 @@ class SchematicCommand extends command_1.Command {
43
43
  const collection = this.getCollection(this.collectionName);
44
44
  const schematic = this.getSchematic(collection, this.schematicName, true);
45
45
  const options = await json_schema_1.parseJsonSchemaToOptions(this._workflow.registry, schematic.description.schemaJson || {});
46
- this.description.options.push(...options.filter(x => !x.hidden));
46
+ this.description.description = schematic.description.description;
47
+ this.description.options.push(...options.filter((x) => !x.hidden));
47
48
  // Remove any user analytics from schematics that are NOT part of our safelist.
48
49
  for (const o of this.description.options) {
49
50
  if (o.userAnalytics && !analytics_1.isPackageNameSafeForAnalytics(this.collectionName)) {
@@ -55,7 +56,7 @@ class SchematicCommand extends command_1.Command {
55
56
  async printHelp() {
56
57
  await super.printHelp();
57
58
  this.logger.info('');
58
- const subCommandOption = this.description.options.filter(x => x.subcommands)[0];
59
+ const subCommandOption = this.description.options.filter((x) => x.subcommands)[0];
59
60
  if (!subCommandOption || !subCommandOption.subcommands) {
60
61
  return 0;
61
62
  }
@@ -63,7 +64,7 @@ class SchematicCommand extends command_1.Command {
63
64
  if (schematicNames.length > 1) {
64
65
  this.logger.info('Available Schematics:');
65
66
  const namesPerCollection = {};
66
- schematicNames.forEach(name => {
67
+ schematicNames.forEach((name) => {
67
68
  let [collectionName, schematicName] = name.split(/:/, 2);
68
69
  if (!schematicName) {
69
70
  schematicName = collectionName;
@@ -75,29 +76,25 @@ class SchematicCommand extends command_1.Command {
75
76
  namesPerCollection[collectionName].push(schematicName);
76
77
  });
77
78
  const defaultCollection = await this.getDefaultSchematicCollection();
78
- Object.keys(namesPerCollection).forEach(collectionName => {
79
+ Object.keys(namesPerCollection).forEach((collectionName) => {
79
80
  const isDefault = defaultCollection == collectionName;
80
81
  this.logger.info(` Collection "${collectionName}"${isDefault ? ' (default)' : ''}:`);
81
- namesPerCollection[collectionName].forEach(schematicName => {
82
+ namesPerCollection[collectionName].forEach((schematicName) => {
82
83
  this.logger.info(` ${schematicName}`);
83
84
  });
84
85
  });
85
86
  }
86
- else if (schematicNames.length == 1) {
87
- this.logger.info('Help for schematic ' + schematicNames[0]);
88
- await this.printHelpSubcommand(subCommandOption.subcommands[schematicNames[0]]);
89
- }
90
87
  return 0;
91
88
  }
92
89
  async printHelpUsage() {
93
- const subCommandOption = this.description.options.filter(x => x.subcommands)[0];
90
+ const subCommandOption = this.description.options.filter((x) => x.subcommands)[0];
94
91
  if (!subCommandOption || !subCommandOption.subcommands) {
95
92
  return;
96
93
  }
97
94
  const schematicNames = Object.keys(subCommandOption.subcommands);
98
95
  if (schematicNames.length == 1) {
99
96
  this.logger.info(this.description.description);
100
- const opts = this.description.options.filter(x => x.positional === undefined);
97
+ const opts = this.description.options.filter((x) => x.positional === undefined);
101
98
  const [collectionName, schematicName] = schematicNames[0].split(/:/)[0];
102
99
  // Display <collectionName:schematicName> if this is not the default collectionName,
103
100
  // otherwise just show the schematicName.
@@ -105,9 +102,9 @@ class SchematicCommand extends command_1.Command {
105
102
  ? schematicName
106
103
  : schematicNames[0];
107
104
  const schematicOptions = subCommandOption.subcommands[schematicNames[0]].options;
108
- const schematicArgs = schematicOptions.filter(x => x.positional !== undefined);
105
+ const schematicArgs = schematicOptions.filter((x) => x.positional !== undefined);
109
106
  const argDisplay = schematicArgs.length > 0
110
- ? ' ' + schematicArgs.map(a => `<${core_1.strings.dasherize(a.name)}>`).join(' ')
107
+ ? ' ' + schematicArgs.map((a) => `<${core_1.strings.dasherize(a.name)}>`).join(' ')
111
108
  : '';
112
109
  this.logger.info(core_1.tags.oneLine `
113
110
  usage: ng ${this.description.name} ${displayName}${argDisplay}
@@ -138,8 +135,8 @@ class SchematicCommand extends command_1.Command {
138
135
  return {};
139
136
  }
140
137
  return options
141
- .filter(o => o.format === 'path')
142
- .map(o => o.name)
138
+ .filter((o) => o.format === 'path')
139
+ .map((o) => o.name)
143
140
  .reduce((acc, curr) => {
144
141
  acc[curr] = workingDir;
145
142
  return acc;
@@ -161,21 +158,26 @@ class SchematicCommand extends command_1.Command {
161
158
  packageRegistry: options.packageRegistry,
162
159
  // A schema registry is required to allow customizing addUndefinedDefaults
163
160
  registry: new core_1.schema.CoreSchemaRegistry(schematics_1.formats.standardFormats),
164
- resolvePaths: !!this.workspace
165
- // Workspace
166
- ? this.collectionName === this.defaultCollectionName
167
- // Favor __dirname for @schematics/angular to use the build-in version
168
- ? [__dirname, process.cwd(), root]
169
- : [process.cwd(), root, __dirname]
170
- // Global
171
- : [__dirname, process.cwd()],
161
+ resolvePaths: this.workspace
162
+ ? // Workspace
163
+ this.collectionName === this.defaultCollectionName
164
+ ? // Favor __dirname for @schematics/angular to use the build-in version
165
+ [__dirname, process.cwd(), root]
166
+ : [process.cwd(), root, __dirname]
167
+ : // Global
168
+ [__dirname, process.cwd()],
172
169
  schemaValidation: true,
173
170
  optionTransforms: [
174
171
  // Add configuration file defaults
175
- async (schematic, current) => ({
176
- ...(await config_1.getSchematicDefaults(schematic.collection.name, schematic.name, getProjectName())),
177
- ...current,
178
- }),
172
+ async (schematic, current) => {
173
+ const projectName = typeof current.project === 'string'
174
+ ? current.project
175
+ : getProjectName();
176
+ return {
177
+ ...(await config_1.getSchematicDefaults(schematic.collection.name, schematic.name, projectName)),
178
+ ...current,
179
+ };
180
+ },
179
181
  ],
180
182
  engineHostCreator: (options) => new schematic_engine_host_1.SchematicEngineHost(options.resolvePaths),
181
183
  });
@@ -203,7 +205,7 @@ class SchematicCommand extends command_1.Command {
203
205
  };
204
206
  workflow.registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
205
207
  workflow.registry.addSmartDefaultProvider('projectName', getProjectName);
206
- workflow.registry.useXDeprecatedProvider(msg => this.logger.warn(msg));
208
+ workflow.registry.useXDeprecatedProvider((msg) => this.logger.warn(msg));
207
209
  let shouldReportAnalytics = true;
208
210
  workflow.engineHost.registerOptionsTransform(async (_, options) => {
209
211
  if (shouldReportAnalytics) {
@@ -215,8 +217,8 @@ class SchematicCommand extends command_1.Command {
215
217
  if (options.interactive !== false && tty_1.isTTY()) {
216
218
  workflow.registry.usePromptProvider((definitions) => {
217
219
  const questions = definitions
218
- .filter(definition => !options.defaults || definition.default === undefined)
219
- .map(definition => {
220
+ .filter((definition) => !options.defaults || definition.default === undefined)
221
+ .map((definition) => {
220
222
  var _a;
221
223
  const question = {
222
224
  name: definition.id,
@@ -225,7 +227,7 @@ class SchematicCommand extends command_1.Command {
225
227
  };
226
228
  const validator = definition.validator;
227
229
  if (validator) {
228
- question.validate = input => validator(input);
230
+ question.validate = (input) => validator(input);
229
231
  // Filter allows transformation of the value prior to validation
230
232
  question.filter = async (input) => {
231
233
  for (const type of definition.propertyTypes) {
@@ -257,7 +259,7 @@ class SchematicCommand extends command_1.Command {
257
259
  break;
258
260
  case 'list':
259
261
  question.type = definition.multiselect ? 'checkbox' : 'list';
260
- question.choices = (_a = definition.items) === null || _a === void 0 ? void 0 : _a.map(item => {
262
+ question.choices = (_a = definition.items) === null || _a === void 0 ? void 0 : _a.map((item) => {
261
263
  return typeof item == 'string'
262
264
  ? item
263
265
  : {
@@ -327,21 +329,18 @@ class SchematicCommand extends command_1.Command {
327
329
  o = await json_schema_1.parseJsonSchemaToOptions(workflow.registry, schematic.description.schemaJson);
328
330
  args = await this.parseArguments(schematicOptions || [], o);
329
331
  }
330
- const allowAdditionalProperties = typeof schematic.description.schemaJson === 'object' && schematic.description.schemaJson.additionalProperties;
332
+ const allowAdditionalProperties = typeof schematic.description.schemaJson === 'object' &&
333
+ schematic.description.schemaJson.additionalProperties;
331
334
  if (args['--'] && !allowAdditionalProperties) {
332
- args['--'].forEach(additional => {
335
+ args['--'].forEach((additional) => {
333
336
  this.logger.fatal(`Unknown option: '${additional.split(/=/)[0]}'`);
334
337
  });
335
338
  return 1;
336
339
  }
337
340
  const pathOptions = o ? this.setPathOptions(o, workingDir) : {};
338
- let input = { ...pathOptions, ...args };
339
- // Read the default values from the workspace.
340
- const projectName = input.project !== undefined ? '' + input.project : null;
341
- const defaults = await config_1.getSchematicDefaults(collectionName, schematicName, projectName);
342
- input = {
343
- ...defaults,
344
- ...input,
341
+ const input = {
342
+ ...pathOptions,
343
+ ...args,
345
344
  ...options.additionalOptions,
346
345
  };
347
346
  workflow.reporter.subscribe((event) => {
@@ -373,11 +372,11 @@ class SchematicCommand extends command_1.Command {
373
372
  break;
374
373
  }
375
374
  });
376
- workflow.lifeCycle.subscribe(event => {
375
+ workflow.lifeCycle.subscribe((event) => {
377
376
  if (event.kind == 'end' || event.kind == 'post-tasks-start') {
378
377
  if (!error) {
379
378
  // Output the logging queue, no error happened.
380
- loggingQueue.forEach(log => this.logger.info(log));
379
+ loggingQueue.forEach((log) => this.logger.info(log));
381
380
  }
382
381
  loggingQueue = [];
383
382
  error = false;
@@ -390,7 +389,7 @@ class SchematicCommand extends command_1.Command {
390
389
  await package_manager_1.ensureCompatibleNpm(this.context.root);
391
390
  }
392
391
  }
393
- return new Promise(resolve => {
392
+ return new Promise((resolve) => {
394
393
  workflow
395
394
  .execute({
396
395
  collection: collectionName,
@@ -451,7 +450,7 @@ function getProjectsByPath(workspace, path, root) {
451
450
  };
452
451
  const projects = Array.from(workspace.projects.entries())
453
452
  .map(([name, project]) => [systemPath.resolve(root, project.root), name])
454
- .filter(tuple => isInside(tuple[0], path))
453
+ .filter((tuple) => isInside(tuple[0], path))
455
454
  // Sort tuples by depth, with the deeper ones first. Since the first member is a path and
456
455
  // we filtered all invalid paths, the longest will be the deepest (and in case of equality
457
456
  // the sort is stable and the first declared project will win).
@@ -461,7 +460,7 @@ function getProjectsByPath(workspace, path, root) {
461
460
  }
462
461
  else if (projects.length > 1) {
463
462
  const firstPath = projects[0][0];
464
- return projects.filter(v => v[0] === firstPath).map(v => v[1]);
463
+ return projects.filter((v) => v[0] === firstPath).map((v) => v[1]);
465
464
  }
466
465
  return [];
467
466
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright Google Inc. All Rights Reserved.
3
+ * Copyright Google LLC All Rights Reserved.
4
4
  *
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.SchematicEngineHost = void 0;
5
2
  /**
6
3
  * @license
7
- * Copyright Google Inc. All Rights Reserved.
4
+ * Copyright Google LLC All Rights Reserved.
8
5
  *
9
6
  * Use of this source code is governed by an MIT-style license that can be
10
7
  * found in the LICENSE file at https://angular.io/license
11
8
  */
9
+ var _a;
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.SchematicEngineHost = void 0;
12
12
  const schematics_1 = require("@angular-devkit/schematics");
13
13
  const tools_1 = require("@angular-devkit/schematics/tools");
14
14
  const fs_1 = require("fs");
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright Google Inc. All Rights Reserved.
3
+ * Copyright Google LLC All Rights Reserved.
4
4
  *
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
package/models/version.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /**
3
3
  * @license
4
- * Copyright Google Inc. All Rights Reserved.
4
+ * Copyright Google LLC All Rights Reserved.
5
5
  *
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://angular.io/license
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/cli",
3
- "version": "12.0.0-rc.0",
3
+ "version": "12.0.0",
4
4
  "description": "CLI tool for Angular",
5
5
  "main": "lib/cli/index.js",
6
6
  "bin": {
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "homepage": "https://github.com/angular/angular-cli",
30
30
  "dependencies": {
31
- "@angular-devkit/architect": "0.1200.0-rc.0",
32
- "@angular-devkit/core": "12.0.0-rc.0",
33
- "@angular-devkit/schematics": "12.0.0-rc.0",
34
- "@schematics/angular": "12.0.0-rc.0",
31
+ "@angular-devkit/architect": "0.1200.0",
32
+ "@angular-devkit/core": "12.0.0",
33
+ "@angular-devkit/schematics": "12.0.0",
34
+ "@schematics/angular": "12.0.0",
35
35
  "@yarnpkg/lockfile": "1.1.0",
36
36
  "ansi-colors": "4.1.1",
37
37
  "debug": "4.3.1",
@@ -40,9 +40,9 @@
40
40
  "jsonc-parser": "3.0.0",
41
41
  "npm-package-arg": "8.1.2",
42
42
  "npm-pick-manifest": "6.1.1",
43
- "open": "8.0.6",
43
+ "open": "8.0.7",
44
44
  "ora": "5.4.0",
45
- "pacote": "11.3.1",
45
+ "pacote": "11.3.2",
46
46
  "resolve": "1.20.0",
47
47
  "rimraf": "3.0.2",
48
48
  "semver": "7.3.5",
@@ -52,16 +52,16 @@
52
52
  "ng-update": {
53
53
  "migrations": "@schematics/angular/migrations/migration-collection.json",
54
54
  "packageGroup": {
55
- "@angular/cli": "12.0.0-rc.0",
56
- "@angular-devkit/architect": "0.1200.0-rc.0",
57
- "@angular-devkit/build-angular": "12.0.0-rc.0",
58
- "@angular-devkit/build-webpack": "0.1200.0-rc.0",
59
- "@angular-devkit/core": "12.0.0-rc.0",
60
- "@angular-devkit/schematics": "12.0.0-rc.0"
55
+ "@angular/cli": "12.0.0",
56
+ "@angular-devkit/architect": "0.1200.0",
57
+ "@angular-devkit/build-angular": "12.0.0",
58
+ "@angular-devkit/build-webpack": "0.1200.0",
59
+ "@angular-devkit/core": "12.0.0",
60
+ "@angular-devkit/schematics": "12.0.0"
61
61
  }
62
62
  },
63
63
  "engines": {
64
- "node": ">= 12.13.0",
64
+ "node": "^12.14.1 || ^14.0.0",
65
65
  "npm": "^6.11.0 || ^7.5.6",
66
66
  "yarn": ">= 1.13.0"
67
67
  }
@@ -1,3 +1,10 @@
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
+ */
1
8
  import { Rule } from '@angular-devkit/schematics';
2
9
  import { Schema as UpdateSchema } from './schema';
3
10
  export declare function angularMajorCompatGuarantee(range: string): string;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.angularMajorCompatGuarantee = void 0;
4
2
  /**
5
3
  * @license
6
- * Copyright Google Inc. All Rights Reserved.
4
+ * Copyright Google LLC All Rights Reserved.
7
5
  *
8
6
  * Use of this source code is governed by an MIT-style license that can be
9
7
  * found in the LICENSE file at https://angular.io/license
10
8
  */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.angularMajorCompatGuarantee = void 0;
11
11
  const core_1 = require("@angular-devkit/core");
12
12
  const schematics_1 = require("@angular-devkit/schematics");
13
13
  const tasks_1 = require("@angular-devkit/schematics/tasks");
@@ -141,13 +141,13 @@ function _validateReversePeerDependencies(name, version, infoMap, logger, next)
141
141
  }
142
142
  function _validateUpdatePackages(infoMap, force, next, logger) {
143
143
  logger.debug('Updating the following packages:');
144
- infoMap.forEach(info => {
144
+ infoMap.forEach((info) => {
145
145
  if (info.target) {
146
146
  logger.debug(` ${info.name} => ${info.target.version}`);
147
147
  }
148
148
  });
149
149
  let peerErrors = false;
150
- infoMap.forEach(info => {
150
+ infoMap.forEach((info) => {
151
151
  const { name, target } = info;
152
152
  if (!target) {
153
153
  return;
@@ -155,10 +155,11 @@ function _validateUpdatePackages(infoMap, force, next, logger) {
155
155
  const pkgLogger = logger.createChild(name);
156
156
  logger.debug(`${name}...`);
157
157
  const { peerDependencies = {}, peerDependenciesMeta = {} } = target.packageJson;
158
- peerErrors = _validateForwardPeerDependencies(name, infoMap, peerDependencies, peerDependenciesMeta, pkgLogger, next) || peerErrors;
159
- peerErrors
160
- = _validateReversePeerDependencies(name, target.version, infoMap, pkgLogger, next)
161
- || peerErrors;
158
+ peerErrors =
159
+ _validateForwardPeerDependencies(name, infoMap, peerDependencies, peerDependenciesMeta, pkgLogger, next) || peerErrors;
160
+ peerErrors =
161
+ _validateReversePeerDependencies(name, target.version, infoMap, pkgLogger, next) ||
162
+ peerErrors;
162
163
  });
163
164
  if (!force && peerErrors) {
164
165
  throw new schematics_1.SchematicsException(core_1.tags.stripIndents `Incompatible peer dependencies found.
@@ -185,14 +186,13 @@ function _performUpdate(tree, context, infoMap, logger, migrateOnly) {
185
186
  deps[name] = `${execResult ? execResult[0] : ''}${newVersion}`;
186
187
  };
187
188
  const toInstall = [...infoMap.values()]
188
- .map(x => [x.name, x.target, x.installed])
189
- // tslint:disable-next-line:no-non-null-assertion
189
+ .map((x) => [x.name, x.target, x.installed])
190
190
  .filter(([name, target, installed]) => {
191
191
  return !!name && !!target && !!installed;
192
192
  });
193
193
  toInstall.forEach(([name, target, installed]) => {
194
- logger.info(`Updating package.json with dependency ${name} `
195
- + `@ ${JSON.stringify(target.version)} (was ${JSON.stringify(installed.version)})...`);
194
+ logger.info(`Updating package.json with dependency ${name} ` +
195
+ `@ ${JSON.stringify(target.version)} (was ${JSON.stringify(installed.version)})...`);
196
196
  if (packageJson.dependencies && packageJson.dependencies[name]) {
197
197
  updateDependency(packageJson.dependencies, name, target.version);
198
198
  if (packageJson.devDependencies && packageJson.devDependencies[name]) {
@@ -231,9 +231,8 @@ function _performUpdate(tree, context, infoMap, logger, migrateOnly) {
231
231
  if (!target.updateMetadata.migrations) {
232
232
  return;
233
233
  }
234
- const collection = (target.updateMetadata.migrations.match(/^[./]/)
235
- ? name + '/'
236
- : '') + target.updateMetadata.migrations;
234
+ const collection = (target.updateMetadata.migrations.match(/^[./]/) ? name + '/' : '') +
235
+ target.updateMetadata.migrations;
237
236
  externalMigrations.push({
238
237
  package: name,
239
238
  collection,
@@ -243,7 +242,7 @@ function _performUpdate(tree, context, infoMap, logger, migrateOnly) {
243
242
  return;
244
243
  });
245
244
  if (externalMigrations.length > 0) {
246
- // tslint:disable-next-line: no-any
245
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
247
246
  global.externalMigrations = externalMigrations;
248
247
  }
249
248
  }
@@ -261,14 +260,15 @@ function _getUpdateMetadata(packageJson, logger) {
261
260
  const packageGroup = metadata['packageGroup'];
262
261
  // Verify that packageGroup is an array of strings or an map of versions. This is not an error
263
262
  // but we still warn the user and ignore the packageGroup keys.
264
- if (Array.isArray(packageGroup) && packageGroup.every(x => typeof x == 'string')) {
263
+ if (Array.isArray(packageGroup) && packageGroup.every((x) => typeof x == 'string')) {
265
264
  result.packageGroup = packageGroup.reduce((group, name) => {
266
265
  group[name] = packageJson.version;
267
266
  return group;
268
267
  }, result.packageGroup);
269
268
  }
270
- else if (typeof packageGroup == 'object' && packageGroup
271
- && Object.values(packageGroup).every(x => typeof x == 'string')) {
269
+ else if (typeof packageGroup == 'object' &&
270
+ packageGroup &&
271
+ Object.values(packageGroup).every((x) => typeof x == 'string')) {
272
272
  result.packageGroup = packageGroup;
273
273
  }
274
274
  else {
@@ -282,9 +282,9 @@ function _getUpdateMetadata(packageJson, logger) {
282
282
  if (metadata['requirements']) {
283
283
  const requirements = metadata['requirements'];
284
284
  // Verify that requirements are
285
- if (typeof requirements != 'object'
286
- || Array.isArray(requirements)
287
- || Object.keys(requirements).some(name => typeof requirements[name] != 'string')) {
285
+ if (typeof requirements != 'object' ||
286
+ Array.isArray(requirements) ||
287
+ Object.keys(requirements).some((name) => typeof requirements[name] != 'string')) {
288
288
  logger.warn(`requirements metadata of package ${packageJson.name} is malformed. Ignoring.`);
289
289
  }
290
290
  else {
@@ -307,7 +307,10 @@ function _usageMessage(options, infoMap, logger) {
307
307
  const packagesToUpdate = [...infoMap.entries()]
308
308
  .map(([name, info]) => {
309
309
  const tag = options.next
310
- ? (info.npmPackageJson['dist-tags']['next'] ? 'next' : 'latest') : 'latest';
310
+ ? info.npmPackageJson['dist-tags']['next']
311
+ ? 'next'
312
+ : 'latest'
313
+ : 'latest';
311
314
  const version = info.npmPackageJson['dist-tags'][tag];
312
315
  const target = info.npmPackageJson.versions[version];
313
316
  return {
@@ -318,8 +321,8 @@ function _usageMessage(options, infoMap, logger) {
318
321
  target,
319
322
  };
320
323
  })
321
- .filter(({ name, info, version, target }) => {
322
- return (target && semver.compare(info.installed.version, version) < 0);
324
+ .filter(({ info, version, target }) => {
325
+ return target && semver.compare(info.installed.version, version) < 0;
323
326
  })
324
327
  .filter(({ target }) => {
325
328
  return target['ng-update'];
@@ -328,8 +331,7 @@ function _usageMessage(options, infoMap, logger) {
328
331
  // Look for packageGroup.
329
332
  if (target['ng-update'] && target['ng-update']['packageGroup']) {
330
333
  const packageGroup = target['ng-update']['packageGroup'];
331
- const packageGroupName = target['ng-update']['packageGroupName']
332
- || target['ng-update']['packageGroup'][0];
334
+ const packageGroupName = target['ng-update']['packageGroupName'] || target['ng-update']['packageGroup'][0];
333
335
  if (packageGroupName) {
334
336
  if (packageGroups.has(name)) {
335
337
  return null;
@@ -345,30 +347,29 @@ function _usageMessage(options, infoMap, logger) {
345
347
  }
346
348
  return [name, `${info.installed.version} -> ${version} `, command];
347
349
  })
348
- .filter(x => x !== null)
349
- .sort((a, b) => a && b ? a[0].localeCompare(b[0]) : 0);
350
+ .filter((x) => x !== null)
351
+ .sort((a, b) => (a && b ? a[0].localeCompare(b[0]) : 0));
350
352
  if (packagesToUpdate.length == 0) {
351
353
  logger.info('We analyzed your package.json and everything seems to be in order. Good work!');
352
354
  return;
353
355
  }
354
356
  logger.info('We analyzed your package.json, there are some packages to update:\n');
355
357
  // Find the largest name to know the padding needed.
356
- let namePad = Math.max(...[...infoMap.keys()].map(x => x.length)) + 2;
358
+ let namePad = Math.max(...[...infoMap.keys()].map((x) => x.length)) + 2;
357
359
  if (!Number.isFinite(namePad)) {
358
360
  namePad = 30;
359
361
  }
360
362
  const pads = [namePad, 25, 0];
361
- logger.info(' '
362
- + ['Name', 'Version', 'Command to update'].map((x, i) => x.padEnd(pads[i])).join(''));
363
- logger.info(' ' + '-'.repeat(pads.reduce((s, x) => s += x, 0) + 20));
364
- packagesToUpdate.forEach(fields => {
363
+ logger.info(' ' + ['Name', 'Version', 'Command to update'].map((x, i) => x.padEnd(pads[i])).join(''));
364
+ logger.info(' ' + '-'.repeat(pads.reduce((s, x) => (s += x), 0) + 20));
365
+ packagesToUpdate.forEach((fields) => {
365
366
  if (!fields) {
366
367
  return;
367
368
  }
368
369
  logger.info(' ' + fields.map((x, i) => x.padEnd(pads[i])).join(''));
369
370
  });
370
- logger.info(`\nThere might be additional packages which don't provide 'ng update' capabilities that are outdated.\n`
371
- + `You can update the additional packages by running the update command of your package manager.`);
371
+ logger.info(`\nThere might be additional packages which don't provide 'ng update' capabilities that are outdated.\n` +
372
+ `You can update the additional packages by running the update command of your package manager.`);
372
373
  return;
373
374
  }
374
375
  function _buildPackageInfo(tree, packages, allDependencies, npmPackageJson, logger) {
@@ -435,9 +436,7 @@ function _buildPackageInfo(tree, packages, allDependencies, npmPackageJson, logg
435
436
  function _buildPackageList(options, projectDeps, logger) {
436
437
  // Parse the packages options to set the targeted version.
437
438
  const packages = new Map();
438
- const commandLinePackages = (options.packages && options.packages.length > 0)
439
- ? options.packages
440
- : [];
439
+ const commandLinePackages = options.packages && options.packages.length > 0 ? options.packages : [];
441
440
  for (const pkg of commandLinePackages) {
442
441
  // Split the version asked on command line.
443
442
  const m = pkg.match(/^((?:@[^/]{1,100}\/)?[^@]{1,100})(?:@(.{1,100}))?$/);
@@ -461,9 +460,9 @@ function _addPackageGroup(tree, packages, allDependencies, npmPackageJson, logge
461
460
  return;
462
461
  }
463
462
  const info = _buildPackageInfo(tree, packages, allDependencies, npmPackageJson, logger);
464
- const version = (info.target && info.target.version)
465
- || npmPackageJson['dist-tags'][maybePackage]
466
- || maybePackage;
463
+ const version = (info.target && info.target.version) ||
464
+ npmPackageJson['dist-tags'][maybePackage] ||
465
+ maybePackage;
467
466
  if (!npmPackageJson.versions[version]) {
468
467
  return;
469
468
  }
@@ -475,23 +474,23 @@ function _addPackageGroup(tree, packages, allDependencies, npmPackageJson, logge
475
474
  if (!packageGroup) {
476
475
  return;
477
476
  }
478
- if (Array.isArray(packageGroup) && !packageGroup.some(x => typeof x != 'string')) {
477
+ if (Array.isArray(packageGroup) && !packageGroup.some((x) => typeof x != 'string')) {
479
478
  packageGroup = packageGroup.reduce((acc, curr) => {
480
479
  acc[curr] = maybePackage;
481
480
  return acc;
482
481
  }, {});
483
482
  }
484
483
  // Only need to check if it's an object because we set it right the time before.
485
- if (typeof packageGroup != 'object'
486
- || packageGroup === null
487
- || Object.values(packageGroup).some(v => typeof v != 'string')) {
484
+ if (typeof packageGroup != 'object' ||
485
+ packageGroup === null ||
486
+ Object.values(packageGroup).some((v) => typeof v != 'string')) {
488
487
  logger.warn(`packageGroup metadata of package ${npmPackageJson.name} is malformed.`);
489
488
  return;
490
489
  }
491
490
  Object.keys(packageGroup)
492
- .filter(name => !packages.has(name)) // Don't override names from the command line.
493
- .filter(name => allDependencies.has(name)) // Remove packages that aren't installed.
494
- .forEach(name => {
491
+ .filter((name) => !packages.has(name)) // Don't override names from the command line.
492
+ .filter((name) => allDependencies.has(name)) // Remove packages that aren't installed.
493
+ .forEach((name) => {
495
494
  packages.set(name, packageGroup[name]);
496
495
  });
497
496
  }
@@ -507,9 +506,9 @@ function _addPeerDependencies(tree, packages, allDependencies, npmPackageJson, n
507
506
  return;
508
507
  }
509
508
  const info = _buildPackageInfo(tree, packages, allDependencies, npmPackageJson, logger);
510
- const version = (info.target && info.target.version)
511
- || npmPackageJson['dist-tags'][maybePackage]
512
- || maybePackage;
509
+ const version = (info.target && info.target.version) ||
510
+ npmPackageJson['dist-tags'][maybePackage] ||
511
+ maybePackage;
513
512
  if (!npmPackageJson.versions[version]) {
514
513
  return;
515
514
  }
@@ -608,7 +607,11 @@ function default_1(options) {
608
607
  const packages = _buildPackageList(options, npmDeps, logger);
609
608
  // Grab all package.json from the npm repository. This requires a lot of HTTP calls so we
610
609
  // try to parallelize as many as possible.
611
- const allPackageMetadata = await Promise.all(Array.from(npmDeps.keys()).map(depName => npm_1.getNpmPackageJson(depName, logger, { registryUrl: options.registry, usingYarn, verbose: options.verbose })));
610
+ const allPackageMetadata = await Promise.all(Array.from(npmDeps.keys()).map((depName) => npm_1.getNpmPackageJson(depName, logger, {
611
+ registryUrl: options.registry,
612
+ usingYarn,
613
+ verbose: options.verbose,
614
+ })));
612
615
  // Build a map of all dependencies and their packageJson.
613
616
  const npmPackageJsonMap = allPackageMetadata.reduce((acc, npmPackageJson) => {
614
617
  // If the package was not found on the registry. It could be private, so we will just
@@ -618,8 +621,8 @@ function default_1(options) {
618
621
  // private one, but it's rare enough.
619
622
  if (!npmPackageJson.name) {
620
623
  if (npmPackageJson.requestedName && packages.has(npmPackageJson.requestedName)) {
621
- throw new schematics_1.SchematicsException(`Package ${JSON.stringify(npmPackageJson.requestedName)} was not found on the `
622
- + 'registry. Cannot continue as this may be an error.');
624
+ throw new schematics_1.SchematicsException(`Package ${JSON.stringify(npmPackageJson.requestedName)} was not found on the ` +
625
+ 'registry. Cannot continue as this may be an error.');
623
626
  }
624
627
  }
625
628
  else {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright Google Inc. All Rights Reserved.
3
+ * Copyright Google LLC All Rights Reserved.
4
4
  *
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license