@angular/cli 13.1.0-next.0 → 13.1.0-rc.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;
@@ -597,6 +597,7 @@
597
597
  "name": {
598
598
  "description": "The name of the new app.",
599
599
  "type": "string",
600
+ "pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$",
600
601
  "$default": {
601
602
  "$source": "argv",
602
603
  "index": 0
@@ -1151,6 +1152,7 @@
1151
1152
  "name": {
1152
1153
  "type": "string",
1153
1154
  "description": "The name of the library.",
1155
+ "pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$",
1154
1156
  "$default": {
1155
1157
  "$source": "argv",
1156
1158
  "index": 0
@@ -1258,7 +1260,6 @@
1258
1260
  "name": {
1259
1261
  "description": "The name of the new workspace and initial project.",
1260
1262
  "type": "string",
1261
- "format": "html-selector",
1262
1263
  "$default": {
1263
1264
  "$source": "argv",
1264
1265
  "index": 0
@@ -484,7 +484,7 @@ export interface LibraryOptionsSchema {
484
484
  /**
485
485
  * The name of the library.
486
486
  */
487
- name?: string;
487
+ name: string;
488
488
  /**
489
489
  * A prefix to apply to generated selectors.
490
490
  */
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,7 +24,9 @@ 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>;
29
+ private warnOnMissingNodeModules;
28
30
  run(options: ArchitectCommandOptions & Arguments): Promise<number>;
29
31
  protected runSingleTarget(target: Target, targetOptions: string[]): Promise<0 | 1>;
30
32
  protected runArchitectTarget(options: ArchitectCommandOptions & Arguments): Promise<number>;
@@ -6,12 +6,34 @@
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.ArchitectCommand = void 0;
11
30
  const architect_1 = require("@angular-devkit/architect");
12
31
  const node_1 = require("@angular-devkit/architect/node");
13
32
  const core_1 = require("@angular-devkit/core");
33
+ const fs_1 = require("fs");
34
+ const path = __importStar(require("path"));
14
35
  const json_schema_1 = require("../utilities/json-schema");
36
+ const package_manager_1 = require("../utilities/package-manager");
15
37
  const analytics_1 = require("./analytics");
16
38
  const command_1 = require("./command");
17
39
  const parser_1 = require("./parser");
@@ -22,6 +44,20 @@ class ArchitectCommand extends command_1.Command {
22
44
  // If this command supports running multiple targets.
23
45
  this.multiTarget = false;
24
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
25
61
  async initialize(options) {
26
62
  this._registry = new core_1.json.schema.CoreSchemaRegistry();
27
63
  this._registry.addPostTransform(core_1.json.schema.transforms.addUndefinedDefaults);
@@ -56,14 +92,11 @@ class ArchitectCommand extends command_1.Command {
56
92
  targetProjectNames.push(name);
57
93
  }
58
94
  }
59
- if (targetProjectNames.length === 0) {
60
- this.logger.fatal(this.missingTargetError || `No projects support the '${this.target}' target.`);
61
- return 1;
62
- }
63
95
  if (projectName && !targetProjectNames.includes(projectName)) {
64
- this.logger.fatal(this.missingTargetError ||
65
- `Project '${projectName}' does not support the '${this.target}' target.`);
66
- return 1;
96
+ return await this.onMissingTarget(projectName);
97
+ }
98
+ if (targetProjectNames.length === 0) {
99
+ return await this.onMissingTarget();
67
100
  }
68
101
  if (!projectName && commandLeftovers && commandLeftovers.length > 0) {
69
102
  const builderNames = new Set();
@@ -77,7 +110,18 @@ class ArchitectCommand extends command_1.Command {
77
110
  if (this.multiTarget) {
78
111
  builderNames.add(builderName);
79
112
  }
80
- const builderDesc = await this._architectHost.resolveBuilder(builderName);
113
+ let builderDesc;
114
+ try {
115
+ builderDesc = await this._architectHost.resolveBuilder(builderName);
116
+ }
117
+ catch (e) {
118
+ if (e.code === 'MODULE_NOT_FOUND') {
119
+ await this.warnOnMissingNodeModules(this.workspace.basePath);
120
+ this.logger.fatal(`Could not find the '${builderName}' builder's node package.`);
121
+ return 1;
122
+ }
123
+ throw e;
124
+ }
81
125
  const optionDefs = await (0, json_schema_1.parseJsonSchemaToOptions)(this._registry, builderDesc.optionSchema);
82
126
  const parsedOptions = (0, parser_1.parseArguments)([...commandLeftovers], optionDefs);
83
127
  const builderLeftovers = parsedOptions['--'] || [];
@@ -142,7 +186,18 @@ class ArchitectCommand extends command_1.Command {
142
186
  project: projectName || (targetProjectNames.length > 0 ? targetProjectNames[0] : ''),
143
187
  target: this.target,
144
188
  });
145
- const builderDesc = await this._architectHost.resolveBuilder(builderConf);
189
+ let builderDesc;
190
+ try {
191
+ builderDesc = await this._architectHost.resolveBuilder(builderConf);
192
+ }
193
+ catch (e) {
194
+ if (e.code === 'MODULE_NOT_FOUND') {
195
+ await this.warnOnMissingNodeModules(this.workspace.basePath);
196
+ this.logger.fatal(`Could not find the '${builderConf}' builder's node package.`);
197
+ return 1;
198
+ }
199
+ throw e;
200
+ }
146
201
  this.description.options.push(...(await (0, json_schema_1.parseJsonSchemaToOptions)(this._registry, builderDesc.optionSchema)));
147
202
  // Update options to remove analytics from options if the builder isn't safelisted.
148
203
  for (const o of this.description.options) {
@@ -151,6 +206,32 @@ class ArchitectCommand extends command_1.Command {
151
206
  }
152
207
  }
153
208
  }
209
+ async warnOnMissingNodeModules(basePath) {
210
+ // Check for a `node_modules` directory (npm, yarn non-PnP, etc.)
211
+ if ((0, fs_1.existsSync)(path.resolve(basePath, 'node_modules'))) {
212
+ return;
213
+ }
214
+ // Check for yarn PnP files
215
+ if ((0, fs_1.existsSync)(path.resolve(basePath, '.pnp.js')) ||
216
+ (0, fs_1.existsSync)(path.resolve(basePath, '.pnp.cjs')) ||
217
+ (0, fs_1.existsSync)(path.resolve(basePath, '.pnp.mjs'))) {
218
+ return;
219
+ }
220
+ const packageManager = await (0, package_manager_1.getPackageManager)(basePath);
221
+ let installSuggestion = 'Try installing with ';
222
+ switch (packageManager) {
223
+ case 'npm':
224
+ installSuggestion += `'npm install'`;
225
+ break;
226
+ case 'yarn':
227
+ installSuggestion += `'yarn'`;
228
+ break;
229
+ default:
230
+ installSuggestion += `the project's package manager`;
231
+ break;
232
+ }
233
+ this.logger.warn(`Node packages may not be installed. ${installSuggestion}.`);
234
+ }
154
235
  async run(options) {
155
236
  return await this.runArchitectTarget(options);
156
237
  }
@@ -159,7 +240,19 @@ class ArchitectCommand extends command_1.Command {
159
240
  // overrides separately (getting the configuration builds the whole project, including
160
241
  // overrides).
161
242
  const builderConf = await this._architectHost.getBuilderNameForTarget(target);
162
- const builderDesc = await this._architectHost.resolveBuilder(builderConf);
243
+ let builderDesc;
244
+ try {
245
+ builderDesc = await this._architectHost.resolveBuilder(builderConf);
246
+ }
247
+ catch (e) {
248
+ if (e.code === 'MODULE_NOT_FOUND') {
249
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
250
+ await this.warnOnMissingNodeModules(this.workspace.basePath);
251
+ this.logger.fatal(`Could not find the '${builderConf}' builder's node package.`);
252
+ return 1;
253
+ }
254
+ throw e;
255
+ }
163
256
  const targetOptionArray = await (0, json_schema_1.parseJsonSchemaToOptions)(this._registry, builderDesc.optionSchema);
164
257
  const overrides = (0, parser_1.parseArguments)(targetOptions, targetOptionArray, this.logger);
165
258
  const allowAdditionalProperties = typeof builderDesc.optionSchema === 'object' && builderDesc.optionSchema.additionalProperties;
@@ -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.1.0-next.0",
3
+ "version": "13.1.0-rc.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.0",
32
- "@angular-devkit/core": "13.1.0-next.0",
33
- "@angular-devkit/schematics": "13.1.0-next.0",
34
- "@schematics/angular": "13.1.0-next.0",
31
+ "@angular-devkit/architect": "0.1301.0-rc.0",
32
+ "@angular-devkit/core": "13.1.0-rc.0",
33
+ "@angular-devkit/schematics": "13.1.0-rc.0",
34
+ "@schematics/angular": "13.1.0-rc.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.0",
55
- "@angular-devkit/architect": "0.1301.0-next.0",
56
- "@angular-devkit/build-angular": "13.1.0-next.0",
57
- "@angular-devkit/build-webpack": "0.1301.0-next.0",
58
- "@angular-devkit/core": "13.1.0-next.0",
59
- "@angular-devkit/schematics": "13.1.0-next.0"
54
+ "@angular/cli": "13.1.0-rc.0",
55
+ "@angular-devkit/architect": "0.1301.0-rc.0",
56
+ "@angular-devkit/build-angular": "13.1.0-rc.0",
57
+ "@angular-devkit/build-webpack": "0.1301.0-rc.0",
58
+ "@angular-devkit/core": "13.1.0-rc.0",
59
+ "@angular-devkit/schematics": "13.1.0-rc.0"
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';