@angular/cli 15.0.0-next.4 → 15.0.0-next.6

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.
@@ -5,8 +5,10 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { analytics, logging } from '@angular-devkit/core';
8
+ import { logging } from '@angular-devkit/core';
9
9
  import { ArgumentsCamelCase, Argv, CamelCaseKey, CommandModule as YargsCommandModule } from 'yargs';
10
+ import { AnalyticsCollector } from '../analytics/analytics-collector';
11
+ import { EventCustomDimension, EventCustomMetric } from '../analytics/analytics-parameters';
10
12
  import { AngularWorkspace } from '../utilities/config';
11
13
  import { PackageManagerUtils } from '../utilities/package-manager';
12
14
  import { Option } from './utilities/json-schema';
@@ -74,8 +76,7 @@ export declare abstract class CommandModule<T extends {} = {}> implements Comman
74
76
  abstract builder(argv: Argv): Promise<Argv<T>> | Argv<T>;
75
77
  abstract run(options: Options<T> & OtherOptions): Promise<number | void> | number | void;
76
78
  handler(args: ArgumentsCamelCase<T> & OtherOptions): Promise<void>;
77
- reportAnalytics(options: (Options<T> & OtherOptions) | OtherOptions, paths?: string[], dimensions?: (boolean | number | string)[], title?: string): Promise<void>;
78
- protected getAnalytics(): Promise<analytics.Analytics>;
79
+ protected getAnalytics(): Promise<AnalyticsCollector | undefined>;
79
80
  /**
80
81
  * Adds schema options to a command also this keeps track of options that are required for analytics.
81
82
  * **Note:** This method should be called from the command bundler method.
@@ -88,7 +89,9 @@ export declare abstract class CommandModule<T extends {} = {}> implements Comman
88
89
  * @returns a method that when called will terminate the periodic
89
90
  * flush and call flush one last time.
90
91
  */
91
- private periodicAnalyticsFlush;
92
+ protected getAnalyticsParameters(options: (Options<T> & OtherOptions) | OtherOptions): Partial<Record<EventCustomDimension | EventCustomMetric, string | boolean | number>>;
93
+ private reportCommandRunAnalytics;
94
+ private reportWorkspaceInfoAnalytics;
92
95
  }
93
96
  /**
94
97
  * Creates an known command module error.
@@ -35,13 +35,19 @@ var __importStar = (this && this.__importStar) || function (mod) {
35
35
  __setModuleDefault(result, mod);
36
36
  return result;
37
37
  };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
38
41
  Object.defineProperty(exports, "__esModule", { value: true });
39
42
  exports.CommandModuleError = exports.CommandModule = exports.CommandScope = void 0;
40
43
  const core_1 = require("@angular-devkit/core");
41
44
  const fs_1 = require("fs");
42
45
  const path = __importStar(require("path"));
46
+ const yargs_1 = __importDefault(require("yargs"));
43
47
  const helpers_1 = require("yargs/helpers");
44
48
  const analytics_1 = require("../analytics/analytics");
49
+ const analytics_collector_1 = require("../analytics/analytics-collector");
50
+ const analytics_parameters_1 = require("../analytics/analytics-parameters");
45
51
  const completion_1 = require("../utilities/completion");
46
52
  const memoize_1 = require("../utilities/memoize");
47
53
  var CommandScope;
@@ -99,18 +105,14 @@ class CommandModule {
99
105
  }
100
106
  // Gather and report analytics.
101
107
  const analytics = await this.getAnalytics();
102
- let stopPeriodicFlushes;
103
- if (this.shouldReportAnalytics) {
104
- await this.reportAnalytics(camelCasedOptions);
105
- stopPeriodicFlushes = this.periodicAnalyticsFlush(analytics);
106
- }
108
+ const stopPeriodicFlushes = analytics && analytics.periodFlush();
107
109
  let exitCode;
108
110
  try {
109
- // Run and time command.
110
- const startTime = Date.now();
111
+ if (analytics) {
112
+ this.reportCommandRunAnalytics(analytics);
113
+ this.reportWorkspaceInfoAnalytics(analytics);
114
+ }
111
115
  exitCode = await this.run(camelCasedOptions);
112
- const endTime = Date.now();
113
- analytics.timing(this.commandName, 'duration', endTime - startTime);
114
116
  }
115
117
  catch (e) {
116
118
  if (e instanceof core_1.schema.SchemaValidationException) {
@@ -128,24 +130,14 @@ class CommandModule {
128
130
  }
129
131
  }
130
132
  }
131
- async reportAnalytics(options, paths = [], dimensions = [], title) {
132
- for (const [name, ua] of this.optionsWithAnalytics) {
133
- const value = options[name];
134
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
135
- dimensions[ua] = value;
136
- }
133
+ async getAnalytics() {
134
+ if (!this.shouldReportAnalytics) {
135
+ return undefined;
137
136
  }
138
- const analytics = await this.getAnalytics();
139
- analytics.pageview('/command/' + [this.commandName, ...paths].join('/'), {
140
- dimensions,
141
- metrics: [],
142
- title,
143
- });
144
- }
145
- getAnalytics() {
146
- return (0, analytics_1.createAnalytics)(!!this.context.workspace,
137
+ const userId = await (0, analytics_1.getAnalyticsUserId)(this.context,
147
138
  // Don't prompt for `ng update` and `ng analytics` commands.
148
139
  ['update', 'analytics'].includes(this.commandName));
140
+ return userId ? new analytics_collector_1.AnalyticsCollector(this.context, userId) : undefined;
149
141
  }
150
142
  /**
151
143
  * Adds schema options to a command also this keeps track of options that are required for analytics.
@@ -213,16 +205,57 @@ class CommandModule {
213
205
  * @returns a method that when called will terminate the periodic
214
206
  * flush and call flush one last time.
215
207
  */
216
- periodicAnalyticsFlush(analytics) {
217
- let analyticsFlushPromise = Promise.resolve();
218
- const analyticsFlushInterval = setInterval(() => {
219
- analyticsFlushPromise = analyticsFlushPromise.then(() => analytics.flush());
220
- }, 2000);
221
- return () => {
222
- clearInterval(analyticsFlushInterval);
223
- // Flush one last time.
224
- return analyticsFlushPromise.then(() => analytics.flush());
225
- };
208
+ getAnalyticsParameters(options) {
209
+ const parameters = {};
210
+ const validEventCustomDimensionAndMetrics = new Set([
211
+ ...Object.values(analytics_parameters_1.EventCustomDimension),
212
+ ...Object.values(analytics_parameters_1.EventCustomMetric),
213
+ ]);
214
+ for (const [name, ua] of this.optionsWithAnalytics) {
215
+ const value = options[name];
216
+ if ((typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') &&
217
+ validEventCustomDimensionAndMetrics.has(ua)) {
218
+ parameters[ua] = value;
219
+ }
220
+ }
221
+ return parameters;
222
+ }
223
+ reportCommandRunAnalytics(analytics) {
224
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
225
+ const internalMethods = yargs_1.default.getInternalMethods();
226
+ // $0 generate component [name] -> generate_component
227
+ // $0 add <collection> -> add
228
+ const fullCommand = internalMethods.getUsageInstance().getUsage()[0][0]
229
+ .split(' ')
230
+ .filter((x) => {
231
+ const code = x.charCodeAt(0);
232
+ return code >= 97 && code <= 122;
233
+ })
234
+ .join('_');
235
+ analytics.reportCommandRunEvent(fullCommand);
236
+ }
237
+ reportWorkspaceInfoAnalytics(analytics) {
238
+ const { workspace } = this.context;
239
+ if (!workspace) {
240
+ return;
241
+ }
242
+ let applicationProjectsCount = 0;
243
+ let librariesProjectsCount = 0;
244
+ for (const project of workspace.projects.values()) {
245
+ switch (project.extensions['projectType']) {
246
+ case 'application':
247
+ applicationProjectsCount++;
248
+ break;
249
+ case 'library':
250
+ librariesProjectsCount++;
251
+ break;
252
+ }
253
+ }
254
+ analytics.reportWorkspaceInfoEvent({
255
+ [analytics_parameters_1.EventCustomMetric.AllProjectsCount]: librariesProjectsCount + applicationProjectsCount,
256
+ [analytics_parameters_1.EventCustomMetric.ApplicationProjectsCount]: applicationProjectsCount,
257
+ [analytics_parameters_1.EventCustomMetric.LibraryProjectsCount]: librariesProjectsCount,
258
+ });
226
259
  }
227
260
  }
228
261
  __decorate([
@@ -23,7 +23,6 @@ export interface SchematicsExecutionOptions extends Options<SchematicsCommandArg
23
23
  export declare abstract class SchematicsCommandModule extends CommandModule<SchematicsCommandArgs> implements CommandModuleImplementation<SchematicsCommandArgs> {
24
24
  scope: CommandScope;
25
25
  protected readonly allowPrivateSchematics: boolean;
26
- protected readonly shouldReportAnalytics = false;
27
26
  builder(argv: Argv): Promise<Argv<SchematicsCommandArgs>>;
28
27
  /** Get schematic schema options.*/
29
28
  protected getSchematicOptions(collection: Collection<FileSystemCollectionDescription, FileSystemSchematicDescription>, schematicName: string, workflow: NodeWorkflow): Promise<Option[]>;
@@ -41,6 +41,8 @@ const core_1 = require("@angular-devkit/core");
41
41
  const schematics_1 = require("@angular-devkit/schematics");
42
42
  const tools_1 = require("@angular-devkit/schematics/tools");
43
43
  const path_1 = require("path");
44
+ const analytics_1 = require("../analytics/analytics");
45
+ const analytics_parameters_1 = require("../analytics/analytics-parameters");
44
46
  const config_1 = require("../utilities/config");
45
47
  const error_1 = require("../utilities/error");
46
48
  const memoize_1 = require("../utilities/memoize");
@@ -55,7 +57,6 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
55
57
  super(...arguments);
56
58
  this.scope = command_module_1.CommandScope.In;
57
59
  this.allowPrivateSchematics = false;
58
- this.shouldReportAnalytics = false;
59
60
  this.defaultProjectDeprecationWarningShown = false;
60
61
  }
61
62
  async builder(argv) {
@@ -128,26 +129,18 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
128
129
  workflow.registry.addSmartDefaultProvider('workingDirectory', () => workingDir === '' ? undefined : workingDir);
129
130
  let shouldReportAnalytics = true;
130
131
  workflow.engineHost.registerOptionsTransform(async (schematic, options) => {
132
+ // Report analytics
131
133
  if (shouldReportAnalytics) {
132
134
  shouldReportAnalytics = false;
133
- await this.reportAnalytics(options, undefined /** paths */, undefined /** dimensions */, schematic.collection.name + ':' + schematic.name);
134
- }
135
- // TODO: The below should be removed in version 15 when we change 1P schematics to use the `workingDirectory smart default`.
136
- // Handle `"format": "path"` options.
137
- const schema = schematic === null || schematic === void 0 ? void 0 : schematic.schemaJson;
138
- if (!options || !schema || !(0, core_1.isJsonObject)(schema)) {
139
- return options;
140
- }
141
- if (!('path' in options && options['path'] === undefined)) {
142
- return options;
143
- }
144
- const properties = schema === null || schema === void 0 ? void 0 : schema['properties'];
145
- if (!properties || !(0, core_1.isJsonObject)(properties)) {
146
- return options;
147
- }
148
- const property = properties['path'];
149
- if (!property || !(0, core_1.isJsonObject)(property)) {
150
- return options;
135
+ const { collection: { name: collectionName }, name: schematicName, } = schematic;
136
+ const analytics = (0, analytics_1.isPackageNameSafeForAnalytics)(collectionName)
137
+ ? await this.getAnalytics()
138
+ : undefined;
139
+ analytics === null || analytics === void 0 ? void 0 : analytics.reportSchematicRunEvent({
140
+ [analytics_parameters_1.EventCustomDimension.SchematicCollectionName]: collectionName,
141
+ [analytics_parameters_1.EventCustomDimension.SchematicName]: schematicName,
142
+ ...this.getAnalyticsParameters(options),
143
+ });
151
144
  }
152
145
  return options;
153
146
  });
@@ -35,6 +35,6 @@ export interface Option extends yargs.Options {
35
35
  * Whether or not to report this option to the Angular Team, and which custom field to use.
36
36
  * If this is falsey, do not report this option.
37
37
  */
38
- userAnalytics?: number;
38
+ userAnalytics?: string;
39
39
  }
40
40
  export declare function parseJsonSchemaToOptions(registry: json.schema.SchemaRegistry, schema: json.JsonObject, interactive?: boolean): Promise<Option[]>;
@@ -108,7 +108,7 @@ async function parseJsonSchemaToOptions(registry, schema, interactive = true) {
108
108
  const visible = current.visible === undefined || current.visible === true;
109
109
  const hidden = !!current.hidden || !visible;
110
110
  const xUserAnalytics = current['x-user-analytics'];
111
- const userAnalytics = typeof xUserAnalytics == 'number' ? xUserAnalytics : undefined;
111
+ const userAnalytics = typeof xUserAnalytics === 'string' ? xUserAnalytics : undefined;
112
112
  // Deprecated is set only if it's true or a string.
113
113
  const xDeprecated = current['x-deprecated'];
114
114
  const deprecated = xDeprecated === true || typeof xDeprecated === 'string' ? xDeprecated : undefined;
@@ -24,7 +24,6 @@ export declare class AddCommandModule extends SchematicsCommandModule implements
24
24
  builder(argv: Argv): Promise<Argv<AddCommandArgs>>;
25
25
  run(options: Options<AddCommandArgs> & OtherOptions): Promise<number | void>;
26
26
  private isProjectVersionValid;
27
- reportAnalytics(options: OtherOptions, paths: string[]): Promise<void>;
28
27
  private getCollectionName;
29
28
  private isPackageInstalled;
30
29
  private executeSchematic;
@@ -18,7 +18,6 @@ const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
18
18
  const path_1 = require("path");
19
19
  const semver_1 = require("semver");
20
20
  const workspace_schema_1 = require("../../../lib/config/workspace-schema");
21
- const analytics_1 = require("../../analytics/analytics");
22
21
  const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
23
22
  const color_1 = require("../../utilities/color");
24
23
  const error_1 = require("../../utilities/error");
@@ -252,15 +251,6 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
252
251
  }
253
252
  return validVersion;
254
253
  }
255
- async reportAnalytics(options, paths) {
256
- const collection = await this.getCollectionName();
257
- const dimensions = [];
258
- // Add the collection if it's safe listed.
259
- if (collection && (0, analytics_1.isPackageNameSafeForAnalytics)(collection)) {
260
- dimensions[core_1.analytics.NgCliAnalyticsDimensions.NgAddCollection] = collection;
261
- }
262
- return super.reportAnalytics(options, paths, dimensions);
263
- }
264
254
  async getCollectionName() {
265
255
  const [, collectionName] = this.context.args.positional;
266
256
  return collectionName;
@@ -20,7 +20,7 @@ class AnalyticsInfoCommandModule extends command_module_1.CommandModule {
20
20
  return localYargs.strict();
21
21
  }
22
22
  async run(_options) {
23
- this.context.logger.info(await (0, analytics_1.getAnalyticsInfoString)());
23
+ this.context.logger.info(await (0, analytics_1.getAnalyticsInfoString)(this.context));
24
24
  }
25
25
  }
26
26
  exports.AnalyticsInfoCommandModule = AnalyticsInfoCommandModule;
@@ -31,7 +31,7 @@ class AnalyticsDisableModule extends AnalyticsSettingModule {
31
31
  }
32
32
  async run({ global }) {
33
33
  await (0, analytics_1.setAnalyticsConfig)(global, false);
34
- process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
34
+ process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)(this.context));
35
35
  }
36
36
  }
37
37
  exports.AnalyticsDisableModule = AnalyticsDisableModule;
@@ -44,7 +44,7 @@ class AnalyticsEnableModule extends AnalyticsSettingModule {
44
44
  }
45
45
  async run({ global }) {
46
46
  await (0, analytics_1.setAnalyticsConfig)(global, true);
47
- process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
47
+ process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)(this.context));
48
48
  }
49
49
  }
50
50
  exports.AnalyticsEnableModule = AnalyticsEnableModule;
@@ -55,7 +55,7 @@ class AnalyticsPromptModule extends AnalyticsSettingModule {
55
55
  this.describe = 'Prompts the user to set the analytics gathering status interactively.';
56
56
  }
57
57
  async run({ global }) {
58
- await (0, analytics_1.promptAnalytics)(global, true);
58
+ await (0, analytics_1.promptAnalytics)(this.context, global, true);
59
59
  }
60
60
  }
61
61
  exports.AnalyticsPromptModule = AnalyticsPromptModule;
@@ -145,11 +145,12 @@ class UpdateCommandModule extends command_module_1.CommandModule {
145
145
  .strict();
146
146
  }
147
147
  async run(options) {
148
- var _a, _b;
148
+ var _a, _b, _c;
149
149
  const { logger, packageManager } = this.context;
150
150
  packageManager.ensureCompatibility();
151
151
  // Check if the current installed CLI version is older than the latest compatible version.
152
- if (!environment_options_1.disableVersionCheck) {
152
+ // Skip when running `ng update` without a package name as this will not trigger an actual update.
153
+ if (!environment_options_1.disableVersionCheck && ((_a = options.packages) === null || _a === void 0 ? void 0 : _a.length)) {
153
154
  const cliVersionToInstall = await this.checkCLIVersion(options.packages, options.verbose, options.next);
154
155
  if (cliVersionToInstall) {
155
156
  logger.warn('The installed Angular CLI version is outdated.\n' +
@@ -158,7 +159,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
158
159
  }
159
160
  }
160
161
  const packages = [];
161
- for (const request of (_a = options.packages) !== null && _a !== void 0 ? _a : []) {
162
+ for (const request of (_b = options.packages) !== null && _b !== void 0 ? _b : []) {
162
163
  try {
163
164
  const packageIdentifier = (0, npm_package_arg_1.default)(request);
164
165
  // only registry identifiers are supported
@@ -210,7 +211,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
210
211
  return success ? 0 : 1;
211
212
  }
212
213
  return options.migrateOnly
213
- ? this.migrateOnly(workflow, ((_b = options.packages) !== null && _b !== void 0 ? _b : [])[0], rootDependencies, options)
214
+ ? this.migrateOnly(workflow, ((_c = options.packages) !== null && _c !== void 0 ? _c : [])[0], rootDependencies, options)
214
215
  : this.updatePackagesAndMigrate(workflow, rootDependencies, options, packages);
215
216
  }
216
217
  async executeSchematic(workflow, collection, schematic, options = {}) {
@@ -18,7 +18,7 @@ const color_1 = require("../../utilities/color");
18
18
  /**
19
19
  * Major versions of Node.js that are officially supported by Angular.
20
20
  */
21
- const SUPPORTED_NODE_MAJORS = [14, 16];
21
+ const SUPPORTED_NODE_MAJORS = [14, 16, 18];
22
22
  const PACKAGE_PATTERNS = [
23
23
  /^@angular\/.*/,
24
24
  /^@angular-devkit\/.*/,
@@ -100,7 +100,7 @@ class VersionCommandModule extends command_module_1.CommandModule {
100
100
  logger.info(`
101
101
  Angular CLI: ${ngCliVersion}
102
102
  Node: ${process.versions.node}${unsupportedNodeVersion ? ' (Unsupported)' : ''}
103
- Package Manager: ${packageManager.name} ${(_a = packageManager.version) !== null && _a !== void 0 ? _a : '<error>'}
103
+ Package Manager: ${packageManager.name} ${(_a = packageManager.version) !== null && _a !== void 0 ? _a : '<error>'}
104
104
  OS: ${process.platform} ${process.arch}
105
105
 
106
106
  Angular: ${angularCoreVersion}
@@ -21,10 +21,10 @@ export declare function considerSettingUpAutocompletion(command: string, logger:
21
21
  */
22
22
  export declare function initializeAutocomplete(): Promise<string>;
23
23
  /**
24
- * Returns whether the user has a global CLI install or `undefined` if this can't be determined.
24
+ * Returns whether the user has a global CLI install.
25
25
  * Execution from `npx` is *not* considered a global CLI install.
26
26
  *
27
27
  * This does *not* mean the current execution is from a global CLI install, only that a global
28
28
  * install exists on the system.
29
29
  */
30
- export declare function hasGlobalCliInstall(): Promise<boolean | undefined>;
30
+ export declare function hasGlobalCliInstall(): Promise<boolean>;
@@ -83,7 +83,7 @@ Appended \`source <(ng completion script)\` to \`${rcFile}\`. Restart your termi
83
83
 
84
84
  ${color_1.colors.yellow(`source <(ng completion script)`)}
85
85
  `.trim());
86
- if ((await hasGlobalCliInstall()) === false) {
86
+ if (!(await hasGlobalCliInstall())) {
87
87
  logger.warn('Setup completed successfully, but there does not seem to be a global install of the' +
88
88
  ' Angular CLI. For autocompletion to work, the CLI will need to be on your `$PATH`, which' +
89
89
  ' is typically done with the `-g` flag in `npm install -g @angular/cli`.' +
@@ -234,27 +234,26 @@ function getShellRunCommandCandidates(shell, home) {
234
234
  }
235
235
  }
236
236
  /**
237
- * Returns whether the user has a global CLI install or `undefined` if this can't be determined.
237
+ * Returns whether the user has a global CLI install.
238
238
  * Execution from `npx` is *not* considered a global CLI install.
239
239
  *
240
240
  * This does *not* mean the current execution is from a global CLI install, only that a global
241
241
  * install exists on the system.
242
242
  */
243
- async function hasGlobalCliInstall() {
244
- var _a;
243
+ function hasGlobalCliInstall() {
245
244
  // List all binaries with the `ng` name on the user's `$PATH`.
246
- const proc = (0, child_process_1.execFile)('which', ['-a', 'ng']);
247
- let stdout = '';
248
- (_a = proc.stdout) === null || _a === void 0 ? void 0 : _a.addListener('data', (content) => {
249
- stdout += content;
250
- });
251
- const exitCode = await new Promise((resolve) => {
252
- proc.addListener('exit', (exitCode) => {
253
- resolve(exitCode);
254
- });
255
- });
256
- switch (exitCode) {
257
- case 0:
245
+ return new Promise((resolve) => {
246
+ (0, child_process_1.execFile)('which', ['-a', 'ng'], (error, stdout) => {
247
+ if (error) {
248
+ // No instances of `ng` on the user's `$PATH`
249
+ // `which` returns exit code 2 if an invalid option is specified and `-a` doesn't appear to be
250
+ // supported on all systems. Other exit codes mean unknown errors occurred. Can't tell whether
251
+ // CLI is globally installed, so treat this as inconclusive.
252
+ // `which` was killed by a signal and did not exit gracefully. Maybe it hung or something else
253
+ // went very wrong, so treat this as inconclusive.
254
+ resolve(false);
255
+ return;
256
+ }
258
257
  // Successfully listed all `ng` binaries on the `$PATH`. Look for at least one line which is a
259
258
  // global install. We can't easily identify global installs, but local installs are typically
260
259
  // placed in `node_modules/.bin` by NPM / Yarn. `npx` also currently caches files at
@@ -267,19 +266,8 @@ async function hasGlobalCliInstall() {
267
266
  const localInstall = grandparent.base === 'node_modules' && parent.base === '.bin';
268
267
  return !localInstall;
269
268
  });
270
- return hasGlobalInstall;
271
- case 1:
272
- // No instances of `ng` on the user's `$PATH`.
273
- return false;
274
- case null:
275
- // `which` was killed by a signal and did not exit gracefully. Maybe it hung or something else
276
- // went very wrong, so treat this as inconclusive.
277
- return undefined;
278
- default:
279
- // `which` returns exit code 2 if an invalid option is specified and `-a` doesn't appear to be
280
- // supported on all systems. Other exit codes mean unknown errors occurred. Can't tell whether
281
- // CLI is globally installed, so treat this as inconclusive.
282
- return undefined;
283
- }
269
+ return resolve(hasGlobalInstall);
270
+ });
271
+ });
284
272
  }
285
273
  exports.hasGlobalCliInstall = hasGlobalCliInstall;
@@ -6,7 +6,6 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  export declare const analyticsDisabled: boolean;
9
- export declare const analyticsShareDisabled: boolean;
10
9
  export declare const isCI: boolean;
11
10
  export declare const disableVersionCheck: boolean;
12
11
  export declare const ngDebug: boolean;
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.forceAutocomplete = exports.ngDebug = exports.disableVersionCheck = exports.isCI = exports.analyticsShareDisabled = exports.analyticsDisabled = void 0;
10
+ exports.forceAutocomplete = exports.ngDebug = exports.disableVersionCheck = exports.isCI = exports.analyticsDisabled = void 0;
11
11
  function isPresent(variable) {
12
12
  return typeof variable === 'string' && variable !== '';
13
13
  }
@@ -24,7 +24,6 @@ function optional(variable) {
24
24
  return isEnabled(variable);
25
25
  }
26
26
  exports.analyticsDisabled = isDisabled(process.env['NG_CLI_ANALYTICS']);
27
- exports.analyticsShareDisabled = isDisabled(process.env['NG_CLI_ANALYTICS_SHARE']);
28
27
  exports.isCI = isEnabled(process.env['CI']);
29
28
  exports.disableVersionCheck = isEnabled(process.env['NG_DISABLE_VERSION_CHECK']);
30
29
  exports.ngDebug = isEnabled(process.env['NG_DEBUG']);
@@ -222,16 +222,11 @@ async function getNpmPackageJson(packageName, logger, options = {}) {
222
222
  const { usingYarn = false, verbose = false, registry } = options;
223
223
  ensureNpmrc(logger, usingYarn, verbose);
224
224
  const { packument } = await Promise.resolve().then(() => __importStar(require('pacote')));
225
- const resultPromise = packument(packageName, {
225
+ const response = packument(packageName, {
226
226
  fullMetadata: true,
227
227
  ...npmrc,
228
228
  ...(registry ? { registry } : {}),
229
229
  });
230
- // TODO: find some way to test this
231
- const response = resultPromise.catch((err) => {
232
- logger.warn(err.message || err);
233
- return { requestedName: packageName };
234
- });
235
230
  npmPackageJsonCache.set(packageName, response);
236
231
  return response;
237
232
  }