@angular/cli 13.0.4 → 13.1.0-next.3

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.
@@ -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;
@@ -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
  */
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/cli",
3
- "version": "13.0.4",
3
+ "version": "13.1.0-next.3",
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.1300.4",
32
- "@angular-devkit/core": "13.0.4",
33
- "@angular-devkit/schematics": "13.0.4",
34
- "@schematics/angular": "13.0.4",
31
+ "@angular-devkit/architect": "0.1301.0-next.3",
32
+ "@angular-devkit/core": "13.1.0-next.3",
33
+ "@angular-devkit/schematics": "13.1.0-next.3",
34
+ "@schematics/angular": "13.1.0-next.3",
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.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"
54
+ "@angular/cli": "13.1.0-next.3",
55
+ "@angular-devkit/architect": "0.1301.0-next.3",
56
+ "@angular-devkit/build-angular": "13.1.0-next.3",
57
+ "@angular-devkit/build-webpack": "0.1301.0-next.3",
58
+ "@angular-devkit/core": "13.1.0-next.3",
59
+ "@angular-devkit/schematics": "13.1.0-next.3"
60
60
  }
61
61
  },
62
62
  "engines": {