@angular/cli 13.1.0-next.2 → 13.2.0-next.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.
package/README.md CHANGED
@@ -234,26 +234,26 @@ For more informations about Node.js debugging in VS Code, see the related [VS Co
234
234
 
235
235
  In order to investigate performance issues, CPU profiling is often useful.
236
236
 
237
- To capture a CPU profiling, you can:
237
+ #### Creating a profile
238
238
 
239
- 1. install the v8-profiler-node8 dependency: `npm install v8-profiler-node8 --no-save`
240
- 1. set the NG_CLI_PROFILING Environment variable to the file name you want:
241
- - on Unix systems (Linux & Mac OS X): ̀`export NG_CLI_PROFILING=my-profile`
242
- - on Windows: ̀̀`setx NG_CLI_PROFILING my-profile`
239
+ Node.js 16+ users can use the Node.js command line argument `--cpu-prof` to create a CPU profile.
243
240
 
244
- Then, just run the ng command on which you want to capture a CPU profile.
245
- You will then obtain a `my-profile.cpuprofile` file in the folder from which you ran the ng command.
241
+ ```bash
242
+ node --cpu-prof node_modules/.bin/ng build
243
+ ```
244
+
245
+ In addition to this one, another, more elaborated way to capture a CPU profile using the Chrome Devtools is detailed in https://github.com/angular/angular-cli/issues/8259#issue-269908550.
246
+
247
+ #### Opening a profile
246
248
 
247
249
  You can use the Chrome Devtools to process it. To do so:
248
250
 
249
- 1. open `chrome://inspect/#devices` in Chrome
251
+ 1. open `chrome://inspect` in Chrome
250
252
  1. click on "Open dedicated DevTools for Node"
251
253
  1. go to the "profiler" tab
252
- 1. click on the "Load" button and select the generated .cpuprofile file
254
+ 1. click on the "Load" button and select the generated `.cpuprofile` file
253
255
  1. on the left panel, select the associated file
254
256
 
255
- In addition to this one, another, more elaborated way to capture a CPU profile using the Chrome Devtools is detailed in https://github.com/angular/angular-cli/issues/8259#issue-269908550.
256
-
257
257
  ## Documentation
258
258
 
259
259
  The documentation for the Angular CLI is located on our [documentation website](https://angular.io/cli).
@@ -10,6 +10,6 @@ import { Arguments } from '../models/interface';
10
10
  import { Schema as DeployCommandSchema } from './deploy';
11
11
  export declare class DeployCommand extends ArchitectCommand<DeployCommandSchema> {
12
12
  readonly target = "deploy";
13
- readonly missingTargetError = "\nCannot find \"deploy\" target for the specified project.\n\nYou should add a package that implements deployment capabilities for your\nfavorite platform.\n\nFor example:\n ng add @angular/fire\n ng add @azure/ng-deploy\n ng add @zeit/ng-deploy\n\nFind more packages on npm https://www.npmjs.com/search?q=ng%20deploy\n";
13
+ readonly missingTargetError = "\nCannot find \"deploy\" target for the specified project.\n\nYou should add a package that implements deployment capabilities for your\nfavorite platform.\n\nFor example:\n ng add @angular/fire\n ng add @azure/ng-deploy\n\nFind more packages on npm https://www.npmjs.com/search?q=ng%20deploy\n";
14
14
  initialize(options: DeployCommandSchema & Arguments): Promise<number | void>;
15
15
  }
@@ -18,7 +18,6 @@ favorite platform.
18
18
  For example:
19
19
  ng add @angular/fire
20
20
  ng add @azure/ng-deploy
21
- ng add @zeit/ng-deploy
22
21
 
23
22
  Find more packages on npm https://www.npmjs.com/search?q=ng%20deploy
24
23
  `;
@@ -61,15 +61,11 @@ class DocCommand extends command_1.Command {
61
61
  const currentNgVersion = (await Promise.resolve().then(() => __importStar(require('@angular/core')))).VERSION.major;
62
62
  domain = `v${currentNgVersion}.angular.io`;
63
63
  }
64
- catch (e) { }
64
+ catch { }
65
65
  }
66
- let searchUrl = `https://${domain}/api?query=${options.keyword}`;
67
- if (options.search) {
68
- searchUrl = `https://${domain}/docs?search=${options.keyword}`;
69
- }
70
- await (0, open_1.default)(searchUrl, {
71
- wait: false,
72
- });
66
+ await (0, open_1.default)(options.search
67
+ ? `https://${domain}/api?query=${options.keyword}`
68
+ : `https://${domain}/docs?search=${options.keyword}`);
73
69
  }
74
70
  }
75
71
  exports.DocCommand = DocCommand;
@@ -11,6 +11,6 @@ import { Schema as LintCommandSchema } from './lint';
11
11
  export declare class LintCommand extends ArchitectCommand<LintCommandSchema> {
12
12
  readonly target = "lint";
13
13
  readonly multiTarget = true;
14
- readonly missingTargetError = "\nCannot find \"lint\" target for the specified project.\n\nYou should add a package that implements linting capabilities.\n\nFor example:\n ng add @angular-eslint/schematics\n";
15
14
  initialize(options: LintCommandSchema & Arguments): Promise<number | void>;
15
+ onMissingTarget(): Promise<void | number>;
16
16
  }
@@ -6,9 +6,31 @@
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
8
8
  */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
9
28
  Object.defineProperty(exports, "__esModule", { value: true });
10
29
  exports.LintCommand = void 0;
30
+ const child_process_1 = require("child_process");
31
+ const path = __importStar(require("path"));
11
32
  const architect_command_1 = require("../models/architect-command");
33
+ const prompt_1 = require("../utilities/prompt");
12
34
  const MissingBuilder = `
13
35
  Cannot find "lint" target for the specified project.
14
36
 
@@ -22,12 +44,26 @@ class LintCommand extends architect_command_1.ArchitectCommand {
22
44
  super(...arguments);
23
45
  this.target = 'lint';
24
46
  this.multiTarget = true;
25
- this.missingTargetError = MissingBuilder;
26
47
  }
27
48
  async initialize(options) {
28
49
  if (!options.help) {
29
50
  return super.initialize(options);
30
51
  }
31
52
  }
53
+ async onMissingTarget() {
54
+ this.logger.warn(MissingBuilder);
55
+ const shouldAdd = await (0, prompt_1.askConfirmation)('Would you like to add ESLint now?', true, false);
56
+ if (shouldAdd) {
57
+ // Run `ng add @angular-eslint/schematics`
58
+ const binPath = path.resolve(__dirname, '../bin/ng.js');
59
+ const { status, error } = (0, child_process_1.spawnSync)(process.execPath, [binPath, 'add', '@angular-eslint/schematics'], {
60
+ stdio: 'inherit',
61
+ });
62
+ if (error) {
63
+ throw error;
64
+ }
65
+ return status !== null && status !== void 0 ? status : 0;
66
+ }
67
+ }
32
68
  }
33
69
  exports.LintCommand = LintCommand;
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')) {
@@ -24,6 +24,7 @@ export declare abstract class ArchitectCommand<T extends ArchitectCommandOptions
24
24
  protected multiTarget: boolean;
25
25
  target: string | undefined;
26
26
  missingTargetError: string | undefined;
27
+ protected onMissingTarget(projectName?: string): Promise<void | number>;
27
28
  initialize(options: T & Arguments): Promise<number | void>;
28
29
  private warnOnMissingNodeModules;
29
30
  run(options: ArchitectCommandOptions & Arguments): Promise<number>;
@@ -44,6 +44,20 @@ class ArchitectCommand extends command_1.Command {
44
44
  // If this command supports running multiple targets.
45
45
  this.multiTarget = false;
46
46
  }
47
+ async onMissingTarget(projectName) {
48
+ if (this.missingTargetError) {
49
+ this.logger.fatal(this.missingTargetError);
50
+ return 1;
51
+ }
52
+ if (projectName) {
53
+ this.logger.fatal(`Project '${projectName}' does not support the '${this.target}' target.`);
54
+ }
55
+ else {
56
+ this.logger.fatal(`No projects support the '${this.target}' target.`);
57
+ }
58
+ return 1;
59
+ }
60
+ // eslint-disable-next-line max-lines-per-function
47
61
  async initialize(options) {
48
62
  this._registry = new core_1.json.schema.CoreSchemaRegistry();
49
63
  this._registry.addPostTransform(core_1.json.schema.transforms.addUndefinedDefaults);
@@ -78,14 +92,11 @@ class ArchitectCommand extends command_1.Command {
78
92
  targetProjectNames.push(name);
79
93
  }
80
94
  }
81
- if (targetProjectNames.length === 0) {
82
- this.logger.fatal(this.missingTargetError || `No projects support the '${this.target}' target.`);
83
- return 1;
84
- }
85
95
  if (projectName && !targetProjectNames.includes(projectName)) {
86
- this.logger.fatal(this.missingTargetError ||
87
- `Project '${projectName}' does not support the '${this.target}' target.`);
88
- return 1;
96
+ return await this.onMissingTarget(projectName);
97
+ }
98
+ if (targetProjectNames.length === 0) {
99
+ return await this.onMissingTarget();
89
100
  }
90
101
  if (!projectName && commandLeftovers && commandLeftovers.length > 0) {
91
102
  const builderNames = new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/cli",
3
- "version": "13.1.0-next.2",
3
+ "version": "13.2.0-next.0",
4
4
  "description": "CLI tool for Angular",
5
5
  "main": "lib/cli/index.js",
6
6
  "bin": {
@@ -28,13 +28,13 @@
28
28
  },
29
29
  "homepage": "https://github.com/angular/angular-cli",
30
30
  "dependencies": {
31
- "@angular-devkit/architect": "0.1301.0-next.2",
32
- "@angular-devkit/core": "13.1.0-next.2",
33
- "@angular-devkit/schematics": "13.1.0-next.2",
34
- "@schematics/angular": "13.1.0-next.2",
31
+ "@angular-devkit/architect": "0.1302.0-next.0",
32
+ "@angular-devkit/core": "13.2.0-next.0",
33
+ "@angular-devkit/schematics": "13.2.0-next.0",
34
+ "@schematics/angular": "13.2.0-next.0",
35
35
  "@yarnpkg/lockfile": "1.1.0",
36
36
  "ansi-colors": "4.1.1",
37
- "debug": "4.3.2",
37
+ "debug": "4.3.3",
38
38
  "ini": "2.0.0",
39
39
  "inquirer": "8.2.0",
40
40
  "jsonc-parser": "3.0.0",
@@ -51,12 +51,12 @@
51
51
  "ng-update": {
52
52
  "migrations": "@schematics/angular/migrations/migration-collection.json",
53
53
  "packageGroup": {
54
- "@angular/cli": "13.1.0-next.2",
55
- "@angular-devkit/architect": "0.1301.0-next.2",
56
- "@angular-devkit/build-angular": "13.1.0-next.2",
57
- "@angular-devkit/build-webpack": "0.1301.0-next.2",
58
- "@angular-devkit/core": "13.1.0-next.2",
59
- "@angular-devkit/schematics": "13.1.0-next.2"
54
+ "@angular/cli": "13.2.0-next.0",
55
+ "@angular-devkit/architect": "0.1302.0-next.0",
56
+ "@angular-devkit/build-angular": "13.2.0-next.0",
57
+ "@angular-devkit/build-webpack": "0.1302.0-next.0",
58
+ "@angular-devkit/core": "13.2.0-next.0",
59
+ "@angular-devkit/schematics": "13.2.0-next.0"
60
60
  }
61
61
  },
62
62
  "engines": {