@angular/cli 12.2.0-next.0 → 12.2.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.
@@ -12,6 +12,7 @@ export declare class AddCommand extends SchematicCommand<AddCommandSchema> {
12
12
  readonly allowPrivateSchematics = true;
13
13
  initialize(options: AddCommandSchema & Arguments): Promise<void>;
14
14
  run(options: AddCommandSchema & Arguments): Promise<number | void>;
15
+ private isProjectVersionValid;
15
16
  reportAnalytics(paths: string[], options: AddCommandSchema & Arguments, dimensions?: (boolean | number | string)[], metrics?: (boolean | number | string)[]): Promise<void>;
16
17
  private isPackageInstalled;
17
18
  private executeSchematic;
@@ -6,10 +6,14 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
9
12
  Object.defineProperty(exports, "__esModule", { value: true });
10
13
  exports.AddCommand = void 0;
11
14
  const core_1 = require("@angular-devkit/core");
12
15
  const tools_1 = require("@angular-devkit/schematics/tools");
16
+ const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
13
17
  const path_1 = require("path");
14
18
  const semver_1 = require("semver");
15
19
  const workspace_schema_1 = require("../lib/config/workspace-schema");
@@ -22,7 +26,6 @@ const package_metadata_1 = require("../utilities/package-metadata");
22
26
  const prompt_1 = require("../utilities/prompt");
23
27
  const spinner_1 = require("../utilities/spinner");
24
28
  const tty_1 = require("../utilities/tty");
25
- const npa = require('npm-package-arg');
26
29
  class AddCommand extends schematic_command_1.SchematicCommand {
27
30
  constructor() {
28
31
  super(...arguments);
@@ -46,28 +49,16 @@ class AddCommand extends schematic_command_1.SchematicCommand {
46
49
  }
47
50
  let packageIdentifier;
48
51
  try {
49
- packageIdentifier = npa(options.collection);
52
+ packageIdentifier = npm_package_arg_1.default(options.collection);
50
53
  }
51
54
  catch (e) {
52
55
  this.logger.error(e.message);
53
56
  return 1;
54
57
  }
55
- if (packageIdentifier.registry && this.isPackageInstalled(packageIdentifier.name)) {
56
- let validVersion = false;
57
- const installedVersion = await this.findProjectVersion(packageIdentifier.name);
58
- if (installedVersion) {
59
- if (packageIdentifier.type === 'range') {
60
- validVersion = semver_1.satisfies(installedVersion, packageIdentifier.fetchSpec);
61
- }
62
- else if (packageIdentifier.type === 'version') {
63
- const v1 = semver_1.valid(packageIdentifier.fetchSpec);
64
- const v2 = semver_1.valid(installedVersion);
65
- validVersion = v1 !== null && v1 === v2;
66
- }
67
- else if (!packageIdentifier.rawSpec) {
68
- validVersion = true;
69
- }
70
- }
58
+ if (packageIdentifier.name &&
59
+ packageIdentifier.registry &&
60
+ this.isPackageInstalled(packageIdentifier.name)) {
61
+ const validVersion = await this.isProjectVersionValid(packageIdentifier);
71
62
  if (validVersion) {
72
63
  // Already installed so just run schematic
73
64
  this.logger.info('Skipping installation: Package already installed');
@@ -79,7 +70,7 @@ class AddCommand extends schematic_command_1.SchematicCommand {
79
70
  const packageManager = await package_manager_1.getPackageManager(this.context.root);
80
71
  const usingYarn = packageManager === workspace_schema_1.PackageManager.Yarn;
81
72
  spinner.info(`Using package manager: ${color_1.colors.grey(packageManager)}`);
82
- if (packageIdentifier.type === 'tag' && !packageIdentifier.rawSpec) {
73
+ if (packageIdentifier.name && packageIdentifier.type === 'tag' && !packageIdentifier.rawSpec) {
83
74
  // only package name provided; search for viable version
84
75
  // plus special cases for packages that did not have peer deps setup
85
76
  spinner.start('Searching for compatible package version...');
@@ -103,13 +94,13 @@ class AddCommand extends schematic_command_1.SchematicCommand {
103
94
  if (version &&
104
95
  ((semver_1.validRange(version) && semver_1.intersects(version, '7', semverOptions)) ||
105
96
  (semver_1.valid(version) && semver_1.satisfies(version, '7', semverOptions)))) {
106
- packageIdentifier = npa.resolve('@angular/pwa', '0.12');
97
+ packageIdentifier = npm_package_arg_1.default.resolve('@angular/pwa', '0.12');
107
98
  }
108
99
  }
109
100
  else {
110
- packageIdentifier = npa.resolve(latestManifest.name, latestManifest.version);
101
+ packageIdentifier = npm_package_arg_1.default.resolve(latestManifest.name, latestManifest.version);
111
102
  }
112
- spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier)}.`);
103
+ spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier.toString())}.`);
113
104
  }
114
105
  else if (!latestManifest || (await this.hasMismatchedPeer(latestManifest))) {
115
106
  // 'latest' is invalid so search for most recent matching package
@@ -118,7 +109,7 @@ class AddCommand extends schematic_command_1.SchematicCommand {
118
109
  let newIdentifier;
119
110
  for (const versionManifest of versionManifests) {
120
111
  if (!(await this.hasMismatchedPeer(versionManifest))) {
121
- newIdentifier = npa.resolve(packageIdentifier.name, versionManifest.version);
112
+ newIdentifier = npm_package_arg_1.default.resolve(packageIdentifier.name, versionManifest.version);
122
113
  break;
123
114
  }
124
115
  }
@@ -127,19 +118,19 @@ class AddCommand extends schematic_command_1.SchematicCommand {
127
118
  }
128
119
  else {
129
120
  packageIdentifier = newIdentifier;
130
- spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier)}.`);
121
+ spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier.toString())}.`);
131
122
  }
132
123
  }
133
124
  else {
134
- packageIdentifier = npa.resolve(latestManifest.name, latestManifest.version);
135
- spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier)}.`);
125
+ packageIdentifier = npm_package_arg_1.default.resolve(latestManifest.name, latestManifest.version);
126
+ spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier.toString())}.`);
136
127
  }
137
128
  }
138
129
  let collectionName = packageIdentifier.name;
139
130
  let savePackage;
140
131
  try {
141
132
  spinner.start('Loading package information from registry...');
142
- const manifest = await package_metadata_1.fetchPackageManifest(packageIdentifier, this.logger, {
133
+ const manifest = await package_metadata_1.fetchPackageManifest(packageIdentifier.toString(), this.logger, {
143
134
  registry: options.registry,
144
135
  verbose: options.verbose,
145
136
  usingYarn,
@@ -190,6 +181,27 @@ class AddCommand extends schematic_command_1.SchematicCommand {
190
181
  }
191
182
  return this.executeSchematic(collectionName, options['--']);
192
183
  }
184
+ async isProjectVersionValid(packageIdentifier) {
185
+ if (!packageIdentifier.name) {
186
+ return false;
187
+ }
188
+ let validVersion = false;
189
+ const installedVersion = await this.findProjectVersion(packageIdentifier.name);
190
+ if (installedVersion) {
191
+ if (packageIdentifier.type === 'range' && packageIdentifier.fetchSpec) {
192
+ validVersion = semver_1.satisfies(installedVersion, packageIdentifier.fetchSpec);
193
+ }
194
+ else if (packageIdentifier.type === 'version') {
195
+ const v1 = semver_1.valid(packageIdentifier.fetchSpec);
196
+ const v2 = semver_1.valid(installedVersion);
197
+ validVersion = v1 !== null && v1 === v2;
198
+ }
199
+ else if (!packageIdentifier.rawSpec) {
200
+ validVersion = true;
201
+ }
202
+ }
203
+ return validVersion;
204
+ }
193
205
  async reportAnalytics(paths, options, dimensions = [], metrics = []) {
194
206
  const collection = options.collection;
195
207
  // Add the collection if it's safe listed.
@@ -267,7 +279,7 @@ class AddCommand extends schematic_command_1.SchematicCommand {
267
279
  for (const peer in manifest.peerDependencies) {
268
280
  let peerIdentifier;
269
281
  try {
270
- peerIdentifier = npa.resolve(peer, manifest.peerDependencies[peer]);
282
+ peerIdentifier = npm_package_arg_1.default.resolve(peer, manifest.peerDependencies[peer]);
271
283
  }
272
284
  catch {
273
285
  this.logger.warn(`Invalid peer dependency ${peer} found in package.`);
@@ -1,2 +1,4 @@
1
- Must be executed from within a workspace directory.
2
- When a project name is not supplied, it will execute for all projects.
1
+ The command takes an optional project name, as specified in the `projects` section of the `angular.json` workspace configuration file.
2
+ When a project name is not supplied, executes the `e2e` builder for the default project.
3
+
4
+ To use the `ng e2e` command, use `ng add` to add a package that implements end-to-end testing capabilities. Adding the package automatically updates your workspace configuration, adding an `e2e` [CLI builder](guide/cli-builder).
@@ -25,12 +25,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  __setModuleDefault(result, mod);
26
26
  return result;
27
27
  };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
28
31
  Object.defineProperty(exports, "__esModule", { value: true });
29
32
  exports.UpdateCommand = void 0;
30
33
  const schematics_1 = require("@angular-devkit/schematics");
31
34
  const tools_1 = require("@angular-devkit/schematics/tools");
32
35
  const child_process_1 = require("child_process");
33
36
  const fs = __importStar(require("fs"));
37
+ const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
34
38
  const path = __importStar(require("path"));
35
39
  const semver = __importStar(require("semver"));
36
40
  const workspace_schema_1 = require("../lib/config/workspace-schema");
@@ -43,7 +47,6 @@ const log_file_1 = require("../utilities/log-file");
43
47
  const package_manager_1 = require("../utilities/package-manager");
44
48
  const package_metadata_1 = require("../utilities/package-metadata");
45
49
  const package_tree_1 = require("../utilities/package-tree");
46
- const npa = require('npm-package-arg');
47
50
  const pickManifest = require('npm-pick-manifest');
48
51
  const NG_VERSION_9_POST_MSG = color_1.colors.cyan('\nYour project has been updated to Angular version 9!\n' +
49
52
  'For more info, please see: https://v9.angular.io/guide/updating-to-version-9');
@@ -238,7 +241,7 @@ class UpdateCommand extends command_1.Command {
238
241
  const packages = [];
239
242
  for (const request of options['--'] || []) {
240
243
  try {
241
- const packageIdentifier = npa(request);
244
+ const packageIdentifier = npm_package_arg_1.default(request);
242
245
  // only registry identifiers are supported
243
246
  if (!packageIdentifier.registry) {
244
247
  this.logger.error(`Package '${request}' is not a registry package identifer.`);
@@ -168,7 +168,16 @@ class VersionCommand extends command_1.Command {
168
168
  async getPackageManager() {
169
169
  try {
170
170
  const manager = await package_manager_1.getPackageManager(this.context.root);
171
- const version = child_process_1.execSync(`${manager} --version`, { encoding: 'utf8', stdio: 'pipe' }).trim();
171
+ const version = child_process_1.execSync(`${manager} --version`, {
172
+ encoding: 'utf8',
173
+ stdio: ['ignore', 'pipe', 'ignore'],
174
+ env: {
175
+ ...process.env,
176
+ // NPM updater notifier will prevents the child process from closing until it timeout after 3 minutes.
177
+ NO_UPDATE_NOTIFIER: '1',
178
+ NPM_CONFIG_UPDATE_NOTIFIER: 'false',
179
+ },
180
+ }).trim();
172
181
  return `${manager} ${version}`;
173
182
  }
174
183
  catch {
@@ -1749,7 +1749,7 @@
1749
1749
  "properties": {
1750
1750
  "inline": {
1751
1751
  "type": "boolean",
1752
- "description": "Reduce render blocking requests by inlining external Google fonts and icons CSS definitions in the application's HTML index file. This option requires internet access. `HTTPS_PROXY` environment variable can be used to specify a proxy server.",
1752
+ "description": "Reduce render blocking requests by inlining external Google Fonts and Adobe Fonts CSS definitions in the application's HTML index file. This option requires internet access. `HTTPS_PROXY` environment variable can be used to specify a proxy server.",
1753
1753
  "default": true
1754
1754
  }
1755
1755
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/cli",
3
- "version": "12.2.0-next.0",
3
+ "version": "12.2.0",
4
4
  "description": "CLI tool for Angular",
5
5
  "main": "lib/cli/index.js",
6
6
  "bin": {
@@ -28,21 +28,21 @@
28
28
  },
29
29
  "homepage": "https://github.com/angular/angular-cli",
30
30
  "dependencies": {
31
- "@angular-devkit/architect": "0.1202.0-next.0",
32
- "@angular-devkit/core": "12.2.0-next.0",
33
- "@angular-devkit/schematics": "12.2.0-next.0",
34
- "@schematics/angular": "12.2.0-next.0",
31
+ "@angular-devkit/architect": "0.1202.0",
32
+ "@angular-devkit/core": "12.2.0",
33
+ "@angular-devkit/schematics": "12.2.0",
34
+ "@schematics/angular": "12.2.0",
35
35
  "@yarnpkg/lockfile": "1.1.0",
36
36
  "ansi-colors": "4.1.1",
37
- "debug": "4.3.1",
37
+ "debug": "4.3.2",
38
38
  "ini": "2.0.0",
39
- "inquirer": "8.1.1",
39
+ "inquirer": "8.1.2",
40
40
  "jsonc-parser": "3.0.0",
41
41
  "npm-package-arg": "8.1.5",
42
42
  "npm-pick-manifest": "6.1.1",
43
43
  "open": "8.2.1",
44
44
  "ora": "5.4.1",
45
- "pacote": "11.3.4",
45
+ "pacote": "11.3.5",
46
46
  "resolve": "1.20.0",
47
47
  "semver": "7.3.5",
48
48
  "symbol-observable": "4.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": "12.2.0-next.0",
55
- "@angular-devkit/architect": "0.1202.0-next.0",
56
- "@angular-devkit/build-angular": "12.2.0-next.0",
57
- "@angular-devkit/build-webpack": "0.1202.0-next.0",
58
- "@angular-devkit/core": "12.2.0-next.0",
59
- "@angular-devkit/schematics": "12.2.0-next.0"
54
+ "@angular/cli": "12.2.0",
55
+ "@angular-devkit/architect": "0.1202.0",
56
+ "@angular-devkit/build-angular": "12.2.0",
57
+ "@angular-devkit/build-webpack": "0.1202.0",
58
+ "@angular-devkit/core": "12.2.0",
59
+ "@angular-devkit/schematics": "12.2.0"
60
60
  }
61
61
  },
62
62
  "engines": {
@@ -50,7 +50,6 @@ function ensureNpmrc(logger, usingYarn, verbose) {
50
50
  }
51
51
  }
52
52
  function readOptions(logger, yarn = false, showPotentials = false) {
53
- var _a;
54
53
  const cwd = process.cwd();
55
54
  const baseFilename = yarn ? 'yarnrc' : 'npmrc';
56
55
  const dotFilename = '.' + baseFilename;
@@ -78,7 +77,7 @@ function readOptions(logger, yarn = false, showPotentials = false) {
78
77
  if (showPotentials) {
79
78
  logger.info(`Locating potential ${baseFilename} files:`);
80
79
  }
81
- const options = {};
80
+ let rcOptions = {};
82
81
  for (const location of [...defaultConfigLocations, ...projectConfigLocations]) {
83
82
  if (fs_1.existsSync(location)) {
84
83
  if (showPotentials) {
@@ -88,57 +87,81 @@ function readOptions(logger, yarn = false, showPotentials = false) {
88
87
  // Normalize RC options that are needed by 'npm-registry-fetch'.
89
88
  // See: https://github.com/npm/npm-registry-fetch/blob/ebddbe78a5f67118c1f7af2e02c8a22bcaf9e850/index.js#L99-L126
90
89
  const rcConfig = yarn ? lockfile.parse(data) : ini.parse(data);
91
- for (const [key, value] of Object.entries(rcConfig)) {
92
- let substitutedValue = value;
93
- // Substitute any environment variable references.
94
- if (typeof value === 'string') {
95
- substitutedValue = value.replace(/\$\{([^\}]+)\}/, (_, name) => process.env[name] || '');
96
- }
97
- switch (key) {
98
- // Unless auth options are scope with the registry url it appears that npm-registry-fetch ignores them,
99
- // even though they are documented.
100
- // https://github.com/npm/npm-registry-fetch/blob/8954f61d8d703e5eb7f3d93c9b40488f8b1b62ac/README.md
101
- // https://github.com/npm/npm-registry-fetch/blob/8954f61d8d703e5eb7f3d93c9b40488f8b1b62ac/auth.js#L45-L91
102
- case '_authToken':
103
- case 'token':
104
- case 'username':
105
- case 'password':
106
- case '_auth':
107
- case 'auth':
108
- (_a = options['forceAuth']) !== null && _a !== void 0 ? _a : (options['forceAuth'] = {});
109
- options['forceAuth'][key] = substitutedValue;
110
- break;
111
- case 'noproxy':
112
- case 'no-proxy':
113
- options['noProxy'] = substitutedValue;
114
- break;
115
- case 'maxsockets':
116
- options['maxSockets'] = substitutedValue;
117
- break;
118
- case 'https-proxy':
119
- case 'proxy':
120
- options['proxy'] = substitutedValue;
121
- break;
122
- case 'strict-ssl':
123
- options['strictSSL'] = substitutedValue;
124
- break;
125
- case 'local-address':
126
- options['localAddress'] = substitutedValue;
127
- break;
128
- case 'cafile':
129
- if (typeof substitutedValue === 'string') {
130
- const cafile = path.resolve(path.dirname(location), substitutedValue);
131
- try {
132
- options['ca'] = fs_1.readFileSync(cafile, 'utf8').replace(/\r?\n/g, '\n');
133
- }
134
- catch { }
135
- }
136
- break;
137
- default:
138
- options[key] = substitutedValue;
139
- break;
90
+ rcOptions = normalizeOptions(rcConfig, location, rcOptions);
91
+ }
92
+ }
93
+ const envVariablesOptions = {};
94
+ for (const [key, value] of Object.entries(process.env)) {
95
+ if (!value) {
96
+ continue;
97
+ }
98
+ let normalizedName = key.toLowerCase();
99
+ if (normalizedName.startsWith('npm_config_')) {
100
+ normalizedName = normalizedName.substring(11);
101
+ }
102
+ else if (yarn && normalizedName.startsWith('yarn_')) {
103
+ normalizedName = normalizedName.substring(5);
104
+ }
105
+ else {
106
+ continue;
107
+ }
108
+ normalizedName = normalizedName.replace(/(?!^)_/g, '-'); // don't replace _ at the start of the key.s
109
+ envVariablesOptions[normalizedName] = value;
110
+ }
111
+ return normalizeOptions(envVariablesOptions, undefined, rcOptions);
112
+ }
113
+ function normalizeOptions(rawOptions, location = process.cwd(), existingNormalizedOptions = {}) {
114
+ var _a;
115
+ const options = { ...existingNormalizedOptions };
116
+ for (const [key, value] of Object.entries(rawOptions)) {
117
+ let substitutedValue = value;
118
+ // Substitute any environment variable references.
119
+ if (typeof value === 'string') {
120
+ substitutedValue = value.replace(/\$\{([^\}]+)\}/, (_, name) => process.env[name] || '');
121
+ }
122
+ switch (key) {
123
+ // Unless auth options are scope with the registry url it appears that npm-registry-fetch ignores them,
124
+ // even though they are documented.
125
+ // https://github.com/npm/npm-registry-fetch/blob/8954f61d8d703e5eb7f3d93c9b40488f8b1b62ac/README.md
126
+ // https://github.com/npm/npm-registry-fetch/blob/8954f61d8d703e5eb7f3d93c9b40488f8b1b62ac/auth.js#L45-L91
127
+ case '_authToken':
128
+ case 'token':
129
+ case 'username':
130
+ case 'password':
131
+ case '_auth':
132
+ case 'auth':
133
+ (_a = options['forceAuth']) !== null && _a !== void 0 ? _a : (options['forceAuth'] = {});
134
+ options['forceAuth'][key] = substitutedValue;
135
+ break;
136
+ case 'noproxy':
137
+ case 'no-proxy':
138
+ options['noProxy'] = substitutedValue;
139
+ break;
140
+ case 'maxsockets':
141
+ options['maxSockets'] = substitutedValue;
142
+ break;
143
+ case 'https-proxy':
144
+ case 'proxy':
145
+ options['proxy'] = substitutedValue;
146
+ break;
147
+ case 'strict-ssl':
148
+ options['strictSSL'] = substitutedValue;
149
+ break;
150
+ case 'local-address':
151
+ options['localAddress'] = substitutedValue;
152
+ break;
153
+ case 'cafile':
154
+ if (typeof substitutedValue === 'string') {
155
+ const cafile = path.resolve(path.dirname(location), substitutedValue);
156
+ try {
157
+ options['ca'] = fs_1.readFileSync(cafile, 'utf8').replace(/\r?\n/g, '\n');
158
+ }
159
+ catch { }
140
160
  }
141
- }
161
+ break;
162
+ default:
163
+ options[key] = substitutedValue;
164
+ break;
142
165
  }
143
166
  }
144
167
  return options;
@@ -210,18 +233,7 @@ function getNpmPackageJson(packageName, logger, options = {}) {
210
233
  return cachedResponse;
211
234
  }
212
235
  const { usingYarn = false, verbose = false, registry } = options;
213
- if (!npmrc) {
214
- try {
215
- npmrc = readOptions(logger, false, verbose);
216
- }
217
- catch { }
218
- if (usingYarn) {
219
- try {
220
- npmrc = { ...npmrc, ...readOptions(logger, true, verbose) };
221
- }
222
- catch { }
223
- }
224
- }
236
+ ensureNpmrc(logger, usingYarn, verbose);
225
237
  const resultPromise = pacote.packument(packageName, {
226
238
  fullMetadata: true,
227
239
  ...npmrc,