@angular/cli 13.0.0 → 13.0.4

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.
package/commands/new.md CHANGED
@@ -5,7 +5,7 @@ All prompts can safely be allowed to default.
5
5
 
6
6
  - The new workspace folder is given the specified project name, and contains configuration files at the top level.
7
7
 
8
- - By default, the files for a new initial application (with the same name as the workspace) are placed in the `src/` subfolder. Corresponding end-to-end tests are placed in the `e2e/` subfolder.
8
+ - By default, the files for a new initial application (with the same name as the workspace) are placed in the `src/` subfolder.
9
9
 
10
10
  - The new application's configuration appears in the `projects` section of the `angular.json` workspace configuration file, under its project name.
11
11
 
@@ -30,8 +30,9 @@ export declare class UpdateCommand extends Command<UpdateCommandSchema> {
30
30
  private commit;
31
31
  private checkCleanGit;
32
32
  /**
33
- * Checks if the current installed CLI version is older than the latest version.
34
- * @returns `true` when the installed version is older.
33
+ * Checks if the current installed CLI version is older or newer than a compatible version.
34
+ * @returns the version to install or null when there is no update to install.
35
35
  */
36
- private checkCLILatestVersion;
36
+ private checkCLIVersion;
37
+ private getCLIUpdateRunnerVersion;
37
38
  }
@@ -48,8 +48,6 @@ const log_file_1 = require("../utilities/log-file");
48
48
  const package_manager_1 = require("../utilities/package-manager");
49
49
  const package_metadata_1 = require("../utilities/package-metadata");
50
50
  const package_tree_1 = require("../utilities/package-tree");
51
- const NG_VERSION_9_POST_MSG = color_1.colors.cyan('\nYour project has been updated to Angular version 9!\n' +
52
- 'For more info, please see: https://v9.angular.io/guide/updating-to-version-9');
53
51
  const UPDATE_SCHEMATIC_COLLECTION = path.join(__dirname, '../src/commands/update/schematic/collection.json');
54
52
  /**
55
53
  * Disable CLI version mismatch checks and forces usage of the invoked CLI
@@ -59,6 +57,7 @@ const disableVersionCheckEnv = process.env['NG_DISABLE_VERSION_CHECK'];
59
57
  const disableVersionCheck = disableVersionCheckEnv !== undefined &&
60
58
  disableVersionCheckEnv !== '0' &&
61
59
  disableVersionCheckEnv.toLowerCase() !== 'false';
60
+ const ANGULAR_PACKAGES_REGEXP = /^@(?:angular|nguniversal)\//;
62
61
  class UpdateCommand extends command_1.Command {
63
62
  constructor() {
64
63
  super(...arguments);
@@ -217,10 +216,14 @@ class UpdateCommand extends command_1.Command {
217
216
  async run(options) {
218
217
  var _a;
219
218
  await (0, package_manager_1.ensureCompatibleNpm)(this.context.root);
220
- // Check if the current installed CLI version is older than the latest version.
221
- if (!disableVersionCheck && (await this.checkCLILatestVersion(options.verbose, options.next))) {
222
- this.logger.warn(`The installed local Angular CLI version is older than the latest ${options.next ? 'pre-release' : 'stable'} version.\n` + 'Installing a temporary version to perform the update.');
223
- return (0, install_package_1.runTempPackageBin)(`@angular/cli@${options.next ? 'next' : 'latest'}`, this.packageManager, process.argv.slice(2));
219
+ // Check if the current installed CLI version is older than the latest compatible version.
220
+ if (!disableVersionCheck) {
221
+ const cliVersionToInstall = await this.checkCLIVersion(options['--'], options.verbose, options.next);
222
+ if (cliVersionToInstall) {
223
+ this.logger.warn('The installed Angular CLI version is outdated.\n' +
224
+ `Installing a temporary Angular CLI versioned ${cliVersionToInstall} to perform the update.`);
225
+ return (0, install_package_1.runTempPackageBin)(`@angular/cli@${cliVersionToInstall}`, this.packageManager, process.argv.slice(2));
226
+ }
224
227
  }
225
228
  const logVerbose = (message) => {
226
229
  if (options.verbose) {
@@ -346,8 +349,7 @@ class UpdateCommand extends command_1.Command {
346
349
  // Normalize slashes
347
350
  migrations = migrations.replace(/\\/g, '/');
348
351
  if (migrations.startsWith('../')) {
349
- this.logger.error('Package contains an invalid migrations field. ' +
350
- 'Paths outside the package root are not permitted.');
352
+ this.logger.error('Package contains an invalid migrations field. Paths outside the package root are not permitted.');
351
353
  return 1;
352
354
  }
353
355
  // Check if it is a package-local location
@@ -371,9 +373,9 @@ class UpdateCommand extends command_1.Command {
371
373
  return 1;
372
374
  }
373
375
  }
374
- let success = false;
376
+ let result;
375
377
  if (typeof options.migrateOnly == 'string') {
376
- success = await this.executeMigration(packageName, migrations, options.migrateOnly, options.createCommits);
378
+ result = await this.executeMigration(packageName, migrations, options.migrateOnly, options.createCommits);
377
379
  }
378
380
  else {
379
381
  const from = coerceVersionNumber(options.from);
@@ -381,18 +383,9 @@ class UpdateCommand extends command_1.Command {
381
383
  this.logger.error(`"from" value [${options.from}] is not a valid version.`);
382
384
  return 1;
383
385
  }
384
- success = await this.executeMigrations(packageName, migrations, from, options.to || packageNode.version, options.createCommits);
385
- }
386
- if (success) {
387
- if (packageName === '@angular/core' &&
388
- options.from &&
389
- +options.from.split('.')[0] < 9 &&
390
- (options.to || packageNode.version).split('.')[0] === '9') {
391
- this.logger.info(NG_VERSION_9_POST_MSG);
392
- }
393
- return 0;
386
+ result = await this.executeMigrations(packageName, migrations, from, options.to || packageNode.version, options.createCommits);
394
387
  }
395
- return 1;
388
+ return result ? 0 : 1;
396
389
  }
397
390
  const requests = [];
398
391
  // Validate packages actually are part of the workspace
@@ -467,7 +460,7 @@ class UpdateCommand extends command_1.Command {
467
460
  this.logger.info(`Package '${packageName}' is already up to date.`);
468
461
  continue;
469
462
  }
470
- if (node.package && /^@(?:angular|nguniversal)\//.test(node.package.name)) {
463
+ if (node.package && ANGULAR_PACKAGES_REGEXP.test(node.package.name)) {
471
464
  const { name, version } = node.package;
472
465
  const toBeInstalledMajorVersion = +manifest.version.split('.')[0];
473
466
  const currentMajorVersion = +version.split('.')[0];
@@ -598,11 +591,6 @@ class UpdateCommand extends command_1.Command {
598
591
  return 0;
599
592
  }
600
593
  }
601
- if (migrations.some((m) => m.package === '@angular/core' &&
602
- m.to.split('.')[0] === '9' &&
603
- +m.from.split('.')[0] < 9)) {
604
- this.logger.info(NG_VERSION_9_POST_MSG);
605
- }
606
594
  }
607
595
  return success ? 0 : 1;
608
596
  }
@@ -667,16 +655,38 @@ class UpdateCommand extends command_1.Command {
667
655
  return true;
668
656
  }
669
657
  /**
670
- * Checks if the current installed CLI version is older than the latest version.
671
- * @returns `true` when the installed version is older.
658
+ * Checks if the current installed CLI version is older or newer than a compatible version.
659
+ * @returns the version to install or null when there is no update to install.
672
660
  */
673
- async checkCLILatestVersion(verbose = false, next = false) {
674
- const installedCLIVersion = version_1.VERSION.full;
675
- const LatestCLIManifest = await (0, package_metadata_1.fetchPackageManifest)(`@angular/cli@${next ? 'next' : 'latest'}`, this.logger, {
661
+ async checkCLIVersion(packagesToUpdate, verbose = false, next = false) {
662
+ const { version } = await (0, package_metadata_1.fetchPackageManifest)(`@angular/cli@${this.getCLIUpdateRunnerVersion(packagesToUpdate, next)}`, this.logger, {
676
663
  verbose,
677
664
  usingYarn: this.packageManager === workspace_schema_1.PackageManager.Yarn,
678
665
  });
679
- return semver.lt(installedCLIVersion, LatestCLIManifest.version);
666
+ return version_1.VERSION.full === version ? null : version;
667
+ }
668
+ getCLIUpdateRunnerVersion(packagesToUpdate, next) {
669
+ var _a, _b;
670
+ if (next) {
671
+ return 'next';
672
+ }
673
+ const updatingAngularPackage = packagesToUpdate === null || packagesToUpdate === void 0 ? void 0 : packagesToUpdate.find((r) => ANGULAR_PACKAGES_REGEXP.test(r));
674
+ if (updatingAngularPackage) {
675
+ // If we are updating any Angular package we can update the CLI to the target version because
676
+ // migrations for @angular/core@13 can be executed using Angular/cli@13.
677
+ // This is same behaviour as `npx @angular/cli@13 update @angular/core@13`.
678
+ // `@angular/cli@13` -> ['', 'angular/cli', '13']
679
+ // `@angular/cli` -> ['', 'angular/cli']
680
+ const tempVersion = coerceVersionNumber(updatingAngularPackage.split('@')[2]);
681
+ return (_b = (_a = semver.parse(tempVersion)) === null || _a === void 0 ? void 0 : _a.major) !== null && _b !== void 0 ? _b : 'latest';
682
+ }
683
+ // When not updating an Angular package we cannot determine which schematic runtime the migration should to be executed in.
684
+ // Typically, we can assume that the `@angular/cli` was updated previously.
685
+ // Example: Angular official packages are typically updated prior to NGRX etc...
686
+ // Therefore, we only update to the latest patch version of the installed major version of the Angular CLI.
687
+ // This is important because we might end up in a scenario where locally Angular v12 is installed, updating NGRX from 11 to 12.
688
+ // We end up using Angular ClI v13 to run the migrations if we run the migrations using the CLI installed major version + 1 logic.
689
+ return version_1.VERSION.major;
680
690
  }
681
691
  }
682
692
  exports.UpdateCommand = UpdateCommand;
package/lib/init.js CHANGED
@@ -84,7 +84,9 @@ const config_1 = require("../utilities/config");
84
84
  if (isGlobalGreater) {
85
85
  // If using the update command and the global version is greater, use the newer update command
86
86
  // This allows improvements in update to be used in older versions that do not have bootstrapping
87
- if (process.argv[2] === 'update') {
87
+ if (process.argv[2] === 'update' &&
88
+ cli.VERSION &&
89
+ cli.VERSION.major - globalVersion.major <= 1) {
88
90
  cli = await Promise.resolve().then(() => __importStar(require('./cli')));
89
91
  }
90
92
  else if (await (0, config_1.isWarningEnabled)('versionMismatch')) {
@@ -109,9 +109,21 @@ function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
109
109
  return legacyModules[id];
110
110
  }
111
111
  else if (id.startsWith('@angular-devkit/') || id.startsWith('@schematics/')) {
112
+ // Files should not redirect `@angular/core` and instead use the direct
113
+ // dependency if available. This allows old major version migrations to continue to function
114
+ // even though the latest major version may have breaking changes in `@angular/core`.
115
+ if (id.startsWith('@angular-devkit/core')) {
116
+ try {
117
+ return schematicRequire(id);
118
+ }
119
+ catch (e) {
120
+ if (e.code !== 'MODULE_NOT_FOUND') {
121
+ throw e;
122
+ }
123
+ }
124
+ }
112
125
  // Resolve from inside the `@angular/cli` project
113
- const packagePath = require.resolve(id);
114
- return hostRequire(packagePath);
126
+ return hostRequire(id);
115
127
  }
116
128
  else if (id.startsWith('.') || id.startsWith('@angular/cdk')) {
117
129
  // Wrap relative files inside the schematic collection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/cli",
3
- "version": "13.0.0",
3
+ "version": "13.0.4",
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.1300.0",
32
- "@angular-devkit/core": "13.0.0",
33
- "@angular-devkit/schematics": "13.0.0",
34
- "@schematics/angular": "13.0.0",
31
+ "@angular-devkit/architect": "0.1300.4",
32
+ "@angular-devkit/core": "13.0.4",
33
+ "@angular-devkit/schematics": "13.0.4",
34
+ "@schematics/angular": "13.0.4",
35
35
  "@yarnpkg/lockfile": "1.1.0",
36
36
  "ansi-colors": "4.1.1",
37
37
  "debug": "4.3.2",
@@ -51,12 +51,12 @@
51
51
  "ng-update": {
52
52
  "migrations": "@schematics/angular/migrations/migration-collection.json",
53
53
  "packageGroup": {
54
- "@angular/cli": "13.0.0",
55
- "@angular-devkit/architect": "0.1300.0",
56
- "@angular-devkit/build-angular": "13.0.0",
57
- "@angular-devkit/build-webpack": "0.1300.0",
58
- "@angular-devkit/core": "13.0.0",
59
- "@angular-devkit/schematics": "13.0.0"
54
+ "@angular/cli": "13.0.4",
55
+ "@angular-devkit/architect": "0.1300.4",
56
+ "@angular-devkit/build-angular": "13.0.4",
57
+ "@angular-devkit/build-webpack": "0.1300.4",
58
+ "@angular-devkit/core": "13.0.4",
59
+ "@angular-devkit/schematics": "13.0.4"
60
60
  }
61
61
  },
62
62
  "engines": {
@@ -356,18 +356,13 @@ function _usageMessage(options, infoMap, logger) {
356
356
  target,
357
357
  };
358
358
  })
359
- .filter(({ info, version, target }) => {
360
- return target && semver.compare(info.installed.version, version) < 0;
361
- })
362
- .filter(({ target }) => {
363
- return target['ng-update'];
364
- })
359
+ .filter(({ info, version, target }) => (target === null || target === void 0 ? void 0 : target['ng-update']) && semver.compare(info.installed.version, version) < 0)
365
360
  .map(({ name, info, version, tag, target }) => {
366
- var _a, _b;
361
+ var _a;
367
362
  // Look for packageGroup.
368
- const packageGroup = (_a = target['ng-update']) === null || _a === void 0 ? void 0 : _a['packageGroup'];
363
+ const packageGroup = target['ng-update']['packageGroup'];
369
364
  if (packageGroup) {
370
- const packageGroupName = packageGroup === null || packageGroup === void 0 ? void 0 : packageGroup[0];
365
+ const packageGroupName = target['ng-update']['packageGroupName'] || packageGroup[0];
371
366
  if (packageGroupName) {
372
367
  if (packageGroups.has(name)) {
373
368
  return null;
@@ -379,7 +374,7 @@ function _usageMessage(options, infoMap, logger) {
379
374
  }
380
375
  let command = `ng update ${name}`;
381
376
  if (!tag) {
382
- command += `@${((_b = semver.parse(version)) === null || _b === void 0 ? void 0 : _b.major) || version}`;
377
+ command += `@${((_a = semver.parse(version)) === null || _a === void 0 ? void 0 : _a.major) || version}`;
383
378
  }
384
379
  else if (tag == 'next') {
385
380
  command += ' --next';