@angular/cli 15.0.0-next.4 → 15.0.0-next.5
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/bin/ng.js +6 -6
- package/lib/config/schema.json +7 -36
- package/lib/config/workspace-schema.d.ts +6 -13
- package/package.json +13 -14
- package/src/analytics/analytics-collector.d.ts +20 -18
- package/src/analytics/analytics-collector.js +93 -170
- package/src/analytics/analytics-parameters.d.ts +95 -0
- package/src/analytics/analytics-parameters.js +101 -0
- package/src/analytics/analytics.d.ts +4 -24
- package/src/analytics/analytics.js +49 -142
- package/src/command-builder/architect-base-command-module.d.ts +1 -1
- package/src/command-builder/architect-base-command-module.js +53 -11
- package/src/command-builder/command-module.d.ts +5 -4
- package/src/command-builder/command-module.js +40 -33
- package/src/command-builder/schematics-command-module.d.ts +0 -1
- package/src/command-builder/schematics-command-module.js +12 -19
- package/src/command-builder/utilities/json-schema.d.ts +1 -1
- package/src/command-builder/utilities/json-schema.js +1 -1
- package/src/commands/add/cli.d.ts +0 -1
- package/src/commands/add/cli.js +0 -10
- package/src/commands/analytics/info/cli.js +1 -1
- package/src/commands/analytics/settings/cli.js +3 -3
- package/src/commands/update/cli.js +5 -4
- package/src/commands/version/cli.js +2 -2
- package/src/utilities/completion.d.ts +2 -2
- package/src/utilities/completion.js +18 -30
- package/src/utilities/environment-options.d.ts +0 -1
- package/src/utilities/environment-options.js +1 -2
- package/src/utilities/package-metadata.js +1 -6
|
@@ -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 {
|
|
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
|
-
|
|
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,7 @@ 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
|
-
|
|
92
|
+
protected getAnalyticsParameters(options: (Options<T> & OtherOptions) | OtherOptions): Partial<Record<EventCustomDimension | EventCustomMetric, string | boolean | number>>;
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
* 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,25 @@ class CommandModule {
|
|
|
99
105
|
}
|
|
100
106
|
// Gather and report analytics.
|
|
101
107
|
const analytics = await this.getAnalytics();
|
|
102
|
-
|
|
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
111
|
// Run and time command.
|
|
110
|
-
|
|
112
|
+
if (analytics) {
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
const internalMethods = yargs_1.default.getInternalMethods();
|
|
115
|
+
// $0 generate component [name] -> generate_component
|
|
116
|
+
// $0 add <collection> -> add
|
|
117
|
+
const fullCommand = internalMethods.getUsageInstance().getUsage()[0][0]
|
|
118
|
+
.split(' ')
|
|
119
|
+
.filter((x) => {
|
|
120
|
+
const code = x.charCodeAt(0);
|
|
121
|
+
return code >= 97 && code <= 122;
|
|
122
|
+
})
|
|
123
|
+
.join('_');
|
|
124
|
+
analytics.reportCommandRunEvent(fullCommand);
|
|
125
|
+
}
|
|
111
126
|
exitCode = await this.run(camelCasedOptions);
|
|
112
|
-
const endTime = Date.now();
|
|
113
|
-
analytics.timing(this.commandName, 'duration', endTime - startTime);
|
|
114
127
|
}
|
|
115
128
|
catch (e) {
|
|
116
129
|
if (e instanceof core_1.schema.SchemaValidationException) {
|
|
@@ -128,24 +141,14 @@ class CommandModule {
|
|
|
128
141
|
}
|
|
129
142
|
}
|
|
130
143
|
}
|
|
131
|
-
async
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
135
|
-
dimensions[ua] = value;
|
|
136
|
-
}
|
|
144
|
+
async getAnalytics() {
|
|
145
|
+
if (!this.shouldReportAnalytics) {
|
|
146
|
+
return undefined;
|
|
137
147
|
}
|
|
138
|
-
const
|
|
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,
|
|
148
|
+
const userId = await (0, analytics_1.getAnalyticsUserId)(this.context,
|
|
147
149
|
// Don't prompt for `ng update` and `ng analytics` commands.
|
|
148
150
|
['update', 'analytics'].includes(this.commandName));
|
|
151
|
+
return userId ? new analytics_collector_1.AnalyticsCollector(this.context, userId) : undefined;
|
|
149
152
|
}
|
|
150
153
|
/**
|
|
151
154
|
* Adds schema options to a command also this keeps track of options that are required for analytics.
|
|
@@ -213,16 +216,20 @@ class CommandModule {
|
|
|
213
216
|
* @returns a method that when called will terminate the periodic
|
|
214
217
|
* flush and call flush one last time.
|
|
215
218
|
*/
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
219
|
+
getAnalyticsParameters(options) {
|
|
220
|
+
const parameters = {};
|
|
221
|
+
const validEventCustomDimensionAndMetrics = new Set([
|
|
222
|
+
...Object.values(analytics_parameters_1.EventCustomDimension),
|
|
223
|
+
...Object.values(analytics_parameters_1.EventCustomMetric),
|
|
224
|
+
]);
|
|
225
|
+
for (const [name, ua] of this.optionsWithAnalytics) {
|
|
226
|
+
const value = options[name];
|
|
227
|
+
if ((typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') &&
|
|
228
|
+
validEventCustomDimensionAndMetrics.has(ua)) {
|
|
229
|
+
parameters[ua] = value;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return parameters;
|
|
226
233
|
}
|
|
227
234
|
}
|
|
228
235
|
__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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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?:
|
|
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
|
|
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;
|
package/src/commands/add/cli.js
CHANGED
|
@@ -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
|
-
|
|
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 (
|
|
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, ((
|
|
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
|
|
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
|
|
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())
|
|
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
|
|
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
|
-
|
|
244
|
-
var _a;
|
|
243
|
+
function hasGlobalCliInstall() {
|
|
245
244
|
// List all binaries with the `ng` name on the user's `$PATH`.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
|
|
272
|
-
|
|
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.
|
|
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
|
|
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
|
}
|