@angular/cli 14.0.0-next.4 → 14.0.0-next.7
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 +3 -5
- package/lib/cli/index.d.ts +1 -2
- package/lib/cli/index.js +16 -45
- package/lib/config/schema.json +30 -15
- package/lib/config/workspace-schema.d.ts +6 -1
- package/lib/init.js +10 -9
- package/package.json +18 -20
- package/{models → src/analytics}/analytics-collector.d.ts +0 -0
- package/{models → src/analytics}/analytics-collector.js +8 -2
- package/src/analytics/analytics.d.ts +47 -0
- package/src/analytics/analytics.js +304 -0
- package/src/command-builder/architect-base-command-module.d.ts +23 -0
- package/src/command-builder/architect-base-command-module.js +103 -0
- package/src/command-builder/architect-command-module.d.ts +22 -0
- package/src/command-builder/architect-command-module.js +108 -0
- package/src/command-builder/command-module.d.ts +89 -0
- package/src/command-builder/command-module.js +191 -0
- package/{utilities/package-json.js → src/command-builder/command-runner.d.ts} +2 -2
- package/src/command-builder/command-runner.js +152 -0
- package/src/command-builder/schematics-command-module.d.ts +46 -0
- package/src/command-builder/schematics-command-module.js +335 -0
- package/src/command-builder/utilities/command.d.ts +13 -0
- package/src/command-builder/utilities/command.js +27 -0
- package/src/command-builder/utilities/json-help.d.ts +36 -0
- package/src/command-builder/utilities/json-help.js +94 -0
- package/src/command-builder/utilities/json-schema.d.ts +40 -0
- package/{utilities → src/command-builder/utilities}/json-schema.js +20 -121
- package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +0 -0
- package/{models → src/command-builder/utilities}/schematic-engine-host.js +0 -0
- package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
- package/src/command-builder/utilities/schematic-workflow.js +68 -0
- package/src/commands/add/cli.d.ts +33 -0
- package/{commands/add-impl.js → src/commands/add/cli.js} +108 -80
- package/src/commands/add/long-description.md +7 -0
- package/src/commands/analytics/cli.d.ts +16 -0
- package/src/commands/analytics/cli.js +35 -0
- package/src/commands/analytics/info/cli.d.ts +16 -0
- package/src/commands/analytics/info/cli.js +26 -0
- package/src/commands/analytics/settings/cli.d.ts +35 -0
- package/src/commands/analytics/settings/cli.js +61 -0
- package/src/commands/build/cli.d.ts +16 -0
- package/src/commands/build/cli.js +23 -0
- package/{commands/build-long.md → src/commands/build/long-description.md} +0 -0
- package/src/commands/cache/clean/cli.d.ts +17 -0
- package/src/commands/cache/clean/cli.js +32 -0
- package/src/commands/cache/cli.d.ts +17 -0
- package/src/commands/cache/cli.js +38 -0
- package/src/commands/cache/info/cli.d.ts +20 -0
- package/src/commands/cache/info/cli.js +82 -0
- package/src/commands/cache/long-description.md +53 -0
- package/src/commands/cache/settings/cli.d.ts +27 -0
- package/src/commands/cache/settings/cli.js +42 -0
- package/src/commands/cache/utilities.d.ts +11 -0
- package/src/commands/cache/utilities.js +50 -0
- package/src/commands/config/cli.d.ts +24 -0
- package/{commands/config-impl.js → src/commands/config/cli.js} +102 -89
- package/{commands/config-long.md → src/commands/config/long-description.md} +2 -2
- package/src/commands/deploy/cli.d.ts +16 -0
- package/src/commands/deploy/cli.js +35 -0
- package/{commands/deploy-long.md → src/commands/deploy/long-description.md} +0 -0
- package/src/commands/doc/cli.d.ts +23 -0
- package/{commands/doc-impl.js → src/commands/doc/cli.js} +41 -12
- package/src/commands/e2e/cli.d.ts +17 -0
- package/src/commands/e2e/cli.js +34 -0
- package/src/commands/extract-i18n/cli.d.ts +15 -0
- package/src/commands/extract-i18n/cli.js +20 -0
- package/src/commands/generate/cli.d.ts +39 -0
- package/src/commands/generate/cli.js +145 -0
- package/src/commands/lint/cli.d.ts +16 -0
- package/src/commands/lint/cli.js +31 -0
- package/{commands/lint-long.md → src/commands/lint/long-description.md} +0 -0
- package/src/commands/make-this-awesome/cli.d.ts +17 -0
- package/{commands/easter-egg-impl.js → src/commands/make-this-awesome/cli.js} +17 -10
- package/src/commands/new/cli.d.ts +27 -0
- package/src/commands/new/cli.js +77 -0
- package/src/commands/run/cli.d.ts +23 -0
- package/src/commands/run/cli.js +59 -0
- package/{commands/run-long.md → src/commands/run/long-description.md} +0 -0
- package/src/commands/serve/cli.d.ts +16 -0
- package/src/commands/serve/cli.js +21 -0
- package/src/commands/test/cli.d.ts +16 -0
- package/src/commands/test/cli.js +23 -0
- package/{commands/test-long.md → src/commands/test/long-description.md} +0 -0
- package/{commands/update-impl.d.ts → src/commands/update/cli.d.ts} +26 -9
- package/{commands/update-impl.js → src/commands/update/cli.js} +362 -316
- package/{commands/update-long.md → src/commands/update/long-description.md} +0 -0
- package/src/commands/update/schematic/index.js +33 -20
- package/src/commands/version/cli.d.ts +18 -0
- package/{commands/version-impl.js → src/commands/version/cli.js} +56 -74
- package/src/typings-bazel.d.ts +14 -0
- package/src/typings.d.ts +1 -14
- package/{utilities → src/utilities}/color.d.ts +0 -0
- package/{utilities → src/utilities}/color.js +5 -1
- package/{utilities → src/utilities}/config.d.ts +2 -2
- package/{utilities → src/utilities}/config.js +24 -16
- package/src/utilities/environment-options.d.ts +12 -0
- package/src/utilities/environment-options.js +24 -0
- package/{utilities → src/utilities}/find-up.d.ts +0 -0
- package/{utilities → src/utilities}/find-up.js +5 -1
- package/{utilities → src/utilities}/json-file.d.ts +0 -0
- package/{utilities → src/utilities}/json-file.js +0 -0
- package/{utilities → src/utilities}/log-file.d.ts +0 -0
- package/{utilities → src/utilities}/log-file.js +0 -0
- package/src/utilities/package-manager.d.ts +41 -0
- package/src/utilities/package-manager.js +276 -0
- package/{utilities → src/utilities}/package-metadata.d.ts +15 -37
- package/{utilities → src/utilities}/package-metadata.js +15 -27
- package/{utilities → src/utilities}/package-tree.d.ts +2 -2
- package/{utilities → src/utilities}/package-tree.js +5 -1
- package/{utilities → src/utilities}/project.d.ts +0 -0
- package/{utilities → src/utilities}/project.js +5 -1
- package/{utilities → src/utilities}/prompt.d.ts +0 -0
- package/{utilities → src/utilities}/prompt.js +7 -3
- package/{utilities → src/utilities}/spinner.d.ts +0 -0
- package/{utilities → src/utilities}/spinner.js +0 -0
- package/{utilities → src/utilities}/tty.d.ts +0 -0
- package/{utilities → src/utilities}/tty.js +0 -0
- package/{models → src/utilities}/version.d.ts +2 -1
- package/{models → src/utilities}/version.js +6 -6
- package/bin/postinstall/analytics-prompt.js +0 -27
- package/bin/postinstall/script.js +0 -16
- package/commands/add-impl.d.ts +0 -21
- package/commands/add.d.ts +0 -42
- package/commands/add.js +0 -10
- package/commands/add.json +0 -54
- package/commands/add.md +0 -10
- package/commands/analytics-impl.d.ts +0 -13
- package/commands/analytics-impl.js +0 -80
- package/commands/analytics-long.md +0 -8
- package/commands/analytics.d.ts +0 -46
- package/commands/analytics.js +0 -31
- package/commands/analytics.json +0 -37
- package/commands/build-impl.d.ts +0 -14
- package/commands/build-impl.js +0 -21
- package/commands/build.d.ts +0 -30
- package/commands/build.js +0 -10
- package/commands/build.json +0 -16
- package/commands/config-impl.d.ts +0 -15
- package/commands/config.d.ts +0 -34
- package/commands/config.js +0 -10
- package/commands/config.json +0 -43
- package/commands/definitions.json +0 -66
- package/commands/deploy-impl.d.ts +0 -15
- package/commands/deploy-impl.js +0 -36
- package/commands/deploy.d.ts +0 -30
- package/commands/deploy.js +0 -10
- package/commands/deploy.json +0 -34
- package/commands/doc-impl.d.ts +0 -13
- package/commands/doc.d.ts +0 -39
- package/commands/doc.js +0 -14
- package/commands/doc.json +0 -46
- package/commands/e2e-impl.d.ts +0 -16
- package/commands/e2e-impl.js +0 -36
- package/commands/e2e-long.md +0 -4
- package/commands/e2e.d.ts +0 -29
- package/commands/e2e.js +0 -10
- package/commands/e2e.json +0 -17
- package/commands/easter-egg-impl.d.ts +0 -12
- package/commands/easter-egg.d.ts +0 -14
- package/commands/easter-egg.js +0 -10
- package/commands/easter-egg.json +0 -12
- package/commands/extract-i18n-impl.d.ts +0 -14
- package/commands/extract-i18n-impl.js +0 -21
- package/commands/extract-i18n.d.ts +0 -29
- package/commands/extract-i18n.js +0 -10
- package/commands/extract-i18n.json +0 -15
- package/commands/generate-impl.d.ts +0 -18
- package/commands/generate-impl.js +0 -89
- package/commands/generate.d.ts +0 -37
- package/commands/generate.js +0 -10
- package/commands/generate.json +0 -31
- package/commands/help-impl.d.ts +0 -12
- package/commands/help-impl.js +0 -26
- package/commands/help-long.md +0 -7
- package/commands/help.d.ts +0 -17
- package/commands/help.js +0 -10
- package/commands/help.json +0 -13
- package/commands/lint-impl.d.ts +0 -16
- package/commands/lint-impl.js +0 -69
- package/commands/lint.d.ts +0 -29
- package/commands/lint.js +0 -10
- package/commands/lint.json +0 -36
- package/commands/new-impl.d.ts +0 -16
- package/commands/new-impl.js +0 -37
- package/commands/new.d.ts +0 -41
- package/commands/new.js +0 -10
- package/commands/new.json +0 -34
- package/commands/new.md +0 -16
- package/commands/run-impl.d.ts +0 -13
- package/commands/run-impl.js +0 -22
- package/commands/run.d.ts +0 -30
- package/commands/run.js +0 -10
- package/commands/run.json +0 -36
- package/commands/serve-impl.d.ts +0 -15
- package/commands/serve-impl.js +0 -24
- package/commands/serve.d.ts +0 -29
- package/commands/serve.js +0 -10
- package/commands/serve.json +0 -17
- package/commands/test-impl.d.ts +0 -15
- package/commands/test-impl.js +0 -22
- package/commands/test.d.ts +0 -29
- package/commands/test.js +0 -10
- package/commands/test.json +0 -17
- package/commands/update.d.ts +0 -61
- package/commands/update.js +0 -10
- package/commands/update.json +0 -78
- package/commands/version-impl.d.ts +0 -17
- package/commands/version.d.ts +0 -17
- package/commands/version.js +0 -10
- package/commands/version.json +0 -13
- package/commands.json +0 -20
- package/models/analytics.d.ts +0 -58
- package/models/analytics.js +0 -358
- package/models/architect-command.d.ts +0 -35
- package/models/architect-command.js +0 -364
- package/models/command-runner.d.ts +0 -24
- package/models/command-runner.js +0 -241
- package/models/command.d.ts +0 -34
- package/models/command.js +0 -143
- package/models/interface.d.ts +0 -196
- package/models/interface.js +0 -31
- package/models/parser.d.ts +0 -39
- package/models/parser.js +0 -349
- package/models/schematic-command.d.ts +0 -55
- package/models/schematic-command.js +0 -485
- package/utilities/install-package.d.ts +0 -16
- package/utilities/install-package.js +0 -193
- package/utilities/json-schema.d.ts +0 -17
- package/utilities/package-json.d.ts +0 -249
- package/utilities/package-manager.d.ts +0 -13
- package/utilities/package-manager.js +0 -106
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getAnalyticsInfoString = exports.createAnalytics = exports.getSharedAnalytics = exports.getAnalytics = exports.promptAnalytics = exports.setAnalyticsConfig = exports.isPackageNameSafeForAnalytics = exports.analyticsPackageSafelist = exports.AnalyticsProperties = void 0;
|
|
37
|
+
const core_1 = require("@angular-devkit/core");
|
|
38
|
+
const debug_1 = __importDefault(require("debug"));
|
|
39
|
+
const uuid_1 = require("uuid");
|
|
40
|
+
const color_1 = require("../utilities/color");
|
|
41
|
+
const config_1 = require("../utilities/config");
|
|
42
|
+
const environment_options_1 = require("../utilities/environment-options");
|
|
43
|
+
const tty_1 = require("../utilities/tty");
|
|
44
|
+
const version_1 = require("../utilities/version");
|
|
45
|
+
const analytics_collector_1 = require("./analytics-collector");
|
|
46
|
+
/* eslint-disable no-console */
|
|
47
|
+
const analyticsDebug = (0, debug_1.default)('ng:analytics'); // Generate analytics, including settings and users.
|
|
48
|
+
let _defaultAngularCliPropertyCache;
|
|
49
|
+
exports.AnalyticsProperties = {
|
|
50
|
+
AngularCliProd: 'UA-8594346-29',
|
|
51
|
+
AngularCliStaging: 'UA-8594346-32',
|
|
52
|
+
get AngularCliDefault() {
|
|
53
|
+
if (_defaultAngularCliPropertyCache) {
|
|
54
|
+
return _defaultAngularCliPropertyCache;
|
|
55
|
+
}
|
|
56
|
+
const v = version_1.VERSION.full;
|
|
57
|
+
// The logic is if it's a full version then we should use the prod GA property.
|
|
58
|
+
_defaultAngularCliPropertyCache =
|
|
59
|
+
/^\d+\.\d+\.\d+$/.test(v) && v !== '0.0.0'
|
|
60
|
+
? exports.AnalyticsProperties.AngularCliProd
|
|
61
|
+
: exports.AnalyticsProperties.AngularCliStaging;
|
|
62
|
+
return _defaultAngularCliPropertyCache;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* This is the ultimate safelist for checking if a package name is safe to report to analytics.
|
|
67
|
+
*/
|
|
68
|
+
exports.analyticsPackageSafelist = [
|
|
69
|
+
/^@angular\//,
|
|
70
|
+
/^@angular-devkit\//,
|
|
71
|
+
/^@ngtools\//,
|
|
72
|
+
'@schematics/angular',
|
|
73
|
+
];
|
|
74
|
+
function isPackageNameSafeForAnalytics(name) {
|
|
75
|
+
return exports.analyticsPackageSafelist.some((pattern) => {
|
|
76
|
+
if (typeof pattern == 'string') {
|
|
77
|
+
return pattern === name;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return pattern.test(name);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
exports.isPackageNameSafeForAnalytics = isPackageNameSafeForAnalytics;
|
|
85
|
+
/**
|
|
86
|
+
* Set analytics settings. This does not work if the user is not inside a project.
|
|
87
|
+
* @param global Which config to use. "global" for user-level, and "local" for project-level.
|
|
88
|
+
* @param value Either a user ID, true to generate a new User ID, or false to disable analytics.
|
|
89
|
+
*/
|
|
90
|
+
function setAnalyticsConfig(global, value) {
|
|
91
|
+
const level = global ? 'global' : 'local';
|
|
92
|
+
analyticsDebug('setting %s level analytics to: %s', level, value);
|
|
93
|
+
const [config, configPath] = (0, config_1.getWorkspaceRaw)(level);
|
|
94
|
+
if (!config || !configPath) {
|
|
95
|
+
throw new Error(`Could not find ${level} workspace.`);
|
|
96
|
+
}
|
|
97
|
+
const cli = config.get(['cli']);
|
|
98
|
+
if (cli !== undefined && !core_1.json.isJsonObject(cli)) {
|
|
99
|
+
throw new Error(`Invalid config found at ${configPath}. CLI should be an object.`);
|
|
100
|
+
}
|
|
101
|
+
if (value === true) {
|
|
102
|
+
value = (0, uuid_1.v4)();
|
|
103
|
+
}
|
|
104
|
+
config.modify(['cli', 'analytics'], value);
|
|
105
|
+
config.save();
|
|
106
|
+
analyticsDebug('done');
|
|
107
|
+
}
|
|
108
|
+
exports.setAnalyticsConfig = setAnalyticsConfig;
|
|
109
|
+
/**
|
|
110
|
+
* Prompt the user for usage gathering permission.
|
|
111
|
+
* @param force Whether to ask regardless of whether or not the user is using an interactive shell.
|
|
112
|
+
* @return Whether or not the user was shown a prompt.
|
|
113
|
+
*/
|
|
114
|
+
async function promptAnalytics(global, force = false) {
|
|
115
|
+
analyticsDebug('prompting user');
|
|
116
|
+
const level = global ? 'global' : 'local';
|
|
117
|
+
const [config, configPath] = (0, config_1.getWorkspaceRaw)(level);
|
|
118
|
+
if (!config || !configPath) {
|
|
119
|
+
throw new Error(`Could not find a ${level} workspace. Are you in a project?`);
|
|
120
|
+
}
|
|
121
|
+
if (force || (0, tty_1.isTTY)()) {
|
|
122
|
+
const { prompt } = await Promise.resolve().then(() => __importStar(require('inquirer')));
|
|
123
|
+
const answers = await prompt([
|
|
124
|
+
{
|
|
125
|
+
type: 'confirm',
|
|
126
|
+
name: 'analytics',
|
|
127
|
+
message: core_1.tags.stripIndents `
|
|
128
|
+
Would you like to share anonymous usage data about this project with the Angular Team at
|
|
129
|
+
Google under Google’s Privacy Policy at https://policies.google.com/privacy. For more
|
|
130
|
+
details and how to change this setting, see https://angular.io/analytics.
|
|
131
|
+
|
|
132
|
+
`,
|
|
133
|
+
default: false,
|
|
134
|
+
},
|
|
135
|
+
]);
|
|
136
|
+
setAnalyticsConfig(global, answers.analytics);
|
|
137
|
+
if (answers.analytics) {
|
|
138
|
+
console.log('');
|
|
139
|
+
console.log(core_1.tags.stripIndent `
|
|
140
|
+
Thank you for sharing anonymous usage data. Should you change your mind, the following
|
|
141
|
+
command will disable this feature entirely:
|
|
142
|
+
|
|
143
|
+
${color_1.colors.yellow(`ng analytics disable${global ? ' --global' : ''}`)}
|
|
144
|
+
`);
|
|
145
|
+
console.log('');
|
|
146
|
+
// Send back a ping with the user `optin`.
|
|
147
|
+
const ua = new analytics_collector_1.AnalyticsCollector(exports.AnalyticsProperties.AngularCliDefault, 'optin');
|
|
148
|
+
ua.pageview('/telemetry/project/optin');
|
|
149
|
+
await ua.flush();
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// Send back a ping with the user `optout`. This is the only thing we send.
|
|
153
|
+
const ua = new analytics_collector_1.AnalyticsCollector(exports.AnalyticsProperties.AngularCliDefault, 'optout');
|
|
154
|
+
ua.pageview('/telemetry/project/optout');
|
|
155
|
+
await ua.flush();
|
|
156
|
+
}
|
|
157
|
+
process.stderr.write(await getAnalyticsInfoString());
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
exports.promptAnalytics = promptAnalytics;
|
|
163
|
+
/**
|
|
164
|
+
* Get the analytics object for the user.
|
|
165
|
+
*
|
|
166
|
+
* @returns
|
|
167
|
+
* - `AnalyticsCollector` when enabled.
|
|
168
|
+
* - `analytics.NoopAnalytics` when disabled.
|
|
169
|
+
* - `undefined` when not configured.
|
|
170
|
+
*/
|
|
171
|
+
async function getAnalytics(level) {
|
|
172
|
+
analyticsDebug('getAnalytics');
|
|
173
|
+
if (environment_options_1.analyticsDisabled) {
|
|
174
|
+
analyticsDebug('NG_CLI_ANALYTICS is false');
|
|
175
|
+
return new core_1.analytics.NoopAnalytics();
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
const workspace = await (0, config_1.getWorkspace)(level);
|
|
179
|
+
const analyticsConfig = workspace === null || workspace === void 0 ? void 0 : workspace.getCli()['analytics'];
|
|
180
|
+
analyticsDebug('Workspace Analytics config found: %j', analyticsConfig);
|
|
181
|
+
if (analyticsConfig === false) {
|
|
182
|
+
return new core_1.analytics.NoopAnalytics();
|
|
183
|
+
}
|
|
184
|
+
else if (analyticsConfig === undefined || analyticsConfig === null) {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
let uid = undefined;
|
|
189
|
+
if (typeof analyticsConfig == 'string') {
|
|
190
|
+
uid = analyticsConfig;
|
|
191
|
+
}
|
|
192
|
+
else if (typeof analyticsConfig == 'object' && typeof analyticsConfig['uid'] == 'string') {
|
|
193
|
+
uid = analyticsConfig['uid'];
|
|
194
|
+
}
|
|
195
|
+
analyticsDebug('client id: %j', uid);
|
|
196
|
+
if (uid == undefined) {
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
return new analytics_collector_1.AnalyticsCollector(exports.AnalyticsProperties.AngularCliDefault, uid);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
analyticsDebug('Error happened during reading of analytics config: %s', err.message);
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
exports.getAnalytics = getAnalytics;
|
|
208
|
+
/**
|
|
209
|
+
* Return the usage analytics sharing setting, which is either a property string (GA-XXXXXXX-XX),
|
|
210
|
+
* or undefined if no sharing.
|
|
211
|
+
*/
|
|
212
|
+
async function getSharedAnalytics() {
|
|
213
|
+
analyticsDebug('getSharedAnalytics');
|
|
214
|
+
if (environment_options_1.analyticsShareDisabled) {
|
|
215
|
+
analyticsDebug('NG_CLI_ANALYTICS is false');
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
// If anything happens we just keep the NOOP analytics.
|
|
219
|
+
try {
|
|
220
|
+
const globalWorkspace = await (0, config_1.getWorkspace)('global');
|
|
221
|
+
const analyticsConfig = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.getCli()['analyticsSharing'];
|
|
222
|
+
if (!analyticsConfig || !analyticsConfig.tracking || !analyticsConfig.uuid) {
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
analyticsDebug('Analytics sharing info: %j', analyticsConfig);
|
|
227
|
+
return new analytics_collector_1.AnalyticsCollector(analyticsConfig.tracking, analyticsConfig.uuid);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch (err) {
|
|
231
|
+
analyticsDebug('Error happened during reading of analytics sharing config: %s', err.message);
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
exports.getSharedAnalytics = getSharedAnalytics;
|
|
236
|
+
async function createAnalytics(workspace, skipPrompt = false) {
|
|
237
|
+
// Global config takes precedence over local config only for the disabled check.
|
|
238
|
+
// IE:
|
|
239
|
+
// global: disabled & local: enabled = disabled
|
|
240
|
+
// global: id: 123 & local: id: 456 = 456
|
|
241
|
+
var _a;
|
|
242
|
+
// check global
|
|
243
|
+
const globalConfig = await getAnalytics('global');
|
|
244
|
+
if (globalConfig instanceof core_1.analytics.NoopAnalytics) {
|
|
245
|
+
return globalConfig;
|
|
246
|
+
}
|
|
247
|
+
let config = globalConfig;
|
|
248
|
+
// Not disabled globally, check locally or not set globally and command is run outside of workspace example: `ng new`
|
|
249
|
+
if (workspace || globalConfig === undefined) {
|
|
250
|
+
const level = workspace ? 'local' : 'global';
|
|
251
|
+
let localOrGlobalConfig = await getAnalytics(level);
|
|
252
|
+
if (localOrGlobalConfig === undefined) {
|
|
253
|
+
if (!skipPrompt) {
|
|
254
|
+
// config is unset, prompt user.
|
|
255
|
+
// TODO: This should honor the `no-interactive` option.
|
|
256
|
+
// It is currently not an `ng` option but rather only an option for specific commands.
|
|
257
|
+
// The concept of `ng`-wide options are needed to cleanly handle this.
|
|
258
|
+
await promptAnalytics(!workspace /** global */);
|
|
259
|
+
localOrGlobalConfig = await getAnalytics(level);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (localOrGlobalConfig instanceof core_1.analytics.NoopAnalytics) {
|
|
263
|
+
return localOrGlobalConfig;
|
|
264
|
+
}
|
|
265
|
+
else if (localOrGlobalConfig) {
|
|
266
|
+
// Favor local settings over global when defined.
|
|
267
|
+
config = localOrGlobalConfig;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Get shared analytics
|
|
271
|
+
// TODO: evalute if this should be completly removed.
|
|
272
|
+
const maybeSharedAnalytics = await getSharedAnalytics();
|
|
273
|
+
if (config && maybeSharedAnalytics) {
|
|
274
|
+
return new core_1.analytics.MultiAnalytics([config, maybeSharedAnalytics]);
|
|
275
|
+
}
|
|
276
|
+
return (_a = config !== null && config !== void 0 ? config : maybeSharedAnalytics) !== null && _a !== void 0 ? _a : new core_1.analytics.NoopAnalytics();
|
|
277
|
+
}
|
|
278
|
+
exports.createAnalytics = createAnalytics;
|
|
279
|
+
function analyticsConfigValueToHumanFormat(value) {
|
|
280
|
+
if (value === false) {
|
|
281
|
+
return 'disabled';
|
|
282
|
+
}
|
|
283
|
+
else if (typeof value === 'string' || value === true) {
|
|
284
|
+
return 'enabled';
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
return 'not set';
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
async function getAnalyticsInfoString() {
|
|
291
|
+
const [globalWorkspace] = (0, config_1.getWorkspaceRaw)('global');
|
|
292
|
+
const [localWorkspace] = (0, config_1.getWorkspaceRaw)('local');
|
|
293
|
+
const globalSetting = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.get(['cli', 'analytics']);
|
|
294
|
+
const localSetting = localWorkspace === null || localWorkspace === void 0 ? void 0 : localWorkspace.get(['cli', 'analytics']);
|
|
295
|
+
const analyticsInstance = await createAnalytics(!!localWorkspace /** workspace */, true /** skipPrompt */);
|
|
296
|
+
return (core_1.tags.stripIndents `
|
|
297
|
+
Global setting: ${analyticsConfigValueToHumanFormat(globalSetting)}
|
|
298
|
+
Local setting: ${localWorkspace
|
|
299
|
+
? analyticsConfigValueToHumanFormat(localSetting)
|
|
300
|
+
: 'No local workspace configuration file.'}
|
|
301
|
+
Effective status: ${analyticsInstance instanceof core_1.analytics.NoopAnalytics ? 'disabled' : 'enabled'}
|
|
302
|
+
` + '\n');
|
|
303
|
+
}
|
|
304
|
+
exports.getAnalyticsInfoString = getAnalyticsInfoString;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Architect, Target } from '@angular-devkit/architect';
|
|
9
|
+
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
|
|
10
|
+
import { CommandModule, CommandModuleImplementation, CommandScope, OtherOptions } from './command-module';
|
|
11
|
+
import { Option } from './utilities/json-schema';
|
|
12
|
+
export declare abstract class ArchitectBaseCommandModule<T> extends CommandModule<T> implements CommandModuleImplementation<T> {
|
|
13
|
+
static scope: CommandScope;
|
|
14
|
+
protected shouldReportAnalytics: boolean;
|
|
15
|
+
protected readonly missingErrorTarget: string | undefined;
|
|
16
|
+
protected runSingleTarget(target: Target, options: OtherOptions): Promise<number>;
|
|
17
|
+
private _architectHost;
|
|
18
|
+
protected getArchitectHost(): WorkspaceNodeModulesArchitectHost;
|
|
19
|
+
private _architect;
|
|
20
|
+
protected getArchitect(): Architect;
|
|
21
|
+
protected getArchitectTargetOptions(target: Target): Promise<Option[]>;
|
|
22
|
+
private warnOnMissingNodeModules;
|
|
23
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ArchitectBaseCommandModule = void 0;
|
|
11
|
+
const architect_1 = require("@angular-devkit/architect");
|
|
12
|
+
const node_1 = require("@angular-devkit/architect/node");
|
|
13
|
+
const core_1 = require("@angular-devkit/core");
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
const path_1 = require("path");
|
|
16
|
+
const analytics_1 = require("../analytics/analytics");
|
|
17
|
+
const command_module_1 = require("./command-module");
|
|
18
|
+
const json_schema_1 = require("./utilities/json-schema");
|
|
19
|
+
class ArchitectBaseCommandModule extends command_module_1.CommandModule {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.shouldReportAnalytics = false;
|
|
23
|
+
}
|
|
24
|
+
async runSingleTarget(target, options) {
|
|
25
|
+
var _a;
|
|
26
|
+
const architectHost = await this.getArchitectHost();
|
|
27
|
+
let builderName;
|
|
28
|
+
try {
|
|
29
|
+
builderName = await architectHost.getBuilderNameForTarget(target);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
throw new command_module_1.CommandModuleError((_a = this.missingErrorTarget) !== null && _a !== void 0 ? _a : e.message);
|
|
33
|
+
}
|
|
34
|
+
await this.reportAnalytics({
|
|
35
|
+
...(await architectHost.getOptionsForTarget(target)),
|
|
36
|
+
...options,
|
|
37
|
+
});
|
|
38
|
+
const { logger } = this.context;
|
|
39
|
+
const run = await this.getArchitect().scheduleTarget(target, options, {
|
|
40
|
+
logger,
|
|
41
|
+
analytics: (0, analytics_1.isPackageNameSafeForAnalytics)(builderName) ? await this.getAnalytics() : undefined,
|
|
42
|
+
});
|
|
43
|
+
const { error, success } = await run.output.toPromise();
|
|
44
|
+
await run.stop();
|
|
45
|
+
if (error) {
|
|
46
|
+
logger.error(error);
|
|
47
|
+
}
|
|
48
|
+
return success ? 0 : 1;
|
|
49
|
+
}
|
|
50
|
+
getArchitectHost() {
|
|
51
|
+
if (this._architectHost) {
|
|
52
|
+
return this._architectHost;
|
|
53
|
+
}
|
|
54
|
+
const workspace = this.getWorkspaceOrThrow();
|
|
55
|
+
return (this._architectHost = new node_1.WorkspaceNodeModulesArchitectHost(workspace, workspace.basePath));
|
|
56
|
+
}
|
|
57
|
+
getArchitect() {
|
|
58
|
+
if (this._architect) {
|
|
59
|
+
return this._architect;
|
|
60
|
+
}
|
|
61
|
+
const registry = new core_1.json.schema.CoreSchemaRegistry();
|
|
62
|
+
registry.addPostTransform(core_1.json.schema.transforms.addUndefinedDefaults);
|
|
63
|
+
registry.useXDeprecatedProvider((msg) => this.context.logger.warn(msg));
|
|
64
|
+
const architectHost = this.getArchitectHost();
|
|
65
|
+
return (this._architect = new architect_1.Architect(architectHost, registry));
|
|
66
|
+
}
|
|
67
|
+
async getArchitectTargetOptions(target) {
|
|
68
|
+
const architectHost = this.getArchitectHost();
|
|
69
|
+
const builderConf = await architectHost.getBuilderNameForTarget(target);
|
|
70
|
+
let builderDesc;
|
|
71
|
+
try {
|
|
72
|
+
builderDesc = await architectHost.resolveBuilder(builderConf);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
if (e.code === 'MODULE_NOT_FOUND') {
|
|
76
|
+
this.warnOnMissingNodeModules();
|
|
77
|
+
throw new command_module_1.CommandModuleError(`Could not find the '${builderConf}' builder's node package.`);
|
|
78
|
+
}
|
|
79
|
+
throw e;
|
|
80
|
+
}
|
|
81
|
+
return (0, json_schema_1.parseJsonSchemaToOptions)(new core_1.json.schema.CoreSchemaRegistry(), builderDesc.optionSchema, true);
|
|
82
|
+
}
|
|
83
|
+
warnOnMissingNodeModules() {
|
|
84
|
+
var _a;
|
|
85
|
+
const basePath = (_a = this.context.workspace) === null || _a === void 0 ? void 0 : _a.basePath;
|
|
86
|
+
if (!basePath) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// Check for a `node_modules` directory (npm, yarn non-PnP, etc.)
|
|
90
|
+
if ((0, fs_1.existsSync)((0, path_1.resolve)(basePath, 'node_modules'))) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// Check for yarn PnP files
|
|
94
|
+
if ((0, fs_1.existsSync)((0, path_1.resolve)(basePath, '.pnp.js')) ||
|
|
95
|
+
(0, fs_1.existsSync)((0, path_1.resolve)(basePath, '.pnp.cjs')) ||
|
|
96
|
+
(0, fs_1.existsSync)((0, path_1.resolve)(basePath, '.pnp.mjs'))) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.context.logger.warn(`Node packages may not be installed. Try installing with '${this.context.packageManager} install'.`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.ArchitectBaseCommandModule = ArchitectBaseCommandModule;
|
|
103
|
+
ArchitectBaseCommandModule.scope = command_module_1.CommandScope.In;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Argv } from 'yargs';
|
|
9
|
+
import { ArchitectBaseCommandModule } from './architect-base-command-module';
|
|
10
|
+
import { CommandModuleImplementation, Options, OtherOptions } from './command-module';
|
|
11
|
+
export interface ArchitectCommandArgs {
|
|
12
|
+
configuration?: string;
|
|
13
|
+
project?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare abstract class ArchitectCommandModule extends ArchitectBaseCommandModule<ArchitectCommandArgs> implements CommandModuleImplementation<ArchitectCommandArgs> {
|
|
16
|
+
abstract readonly multiTarget: boolean;
|
|
17
|
+
builder(argv: Argv): Promise<Argv<ArchitectCommandArgs>>;
|
|
18
|
+
run(options: Options<ArchitectCommandArgs> & OtherOptions): Promise<number | void>;
|
|
19
|
+
private getArchitectProject;
|
|
20
|
+
private getArchitectTarget;
|
|
21
|
+
private getProjectNamesByTarget;
|
|
22
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ArchitectCommandModule = void 0;
|
|
11
|
+
const config_1 = require("../utilities/config");
|
|
12
|
+
const architect_base_command_module_1 = require("./architect-base-command-module");
|
|
13
|
+
const command_module_1 = require("./command-module");
|
|
14
|
+
class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBaseCommandModule {
|
|
15
|
+
async builder(argv) {
|
|
16
|
+
const localYargs = argv
|
|
17
|
+
.positional('project', {
|
|
18
|
+
describe: 'The name of the project to build. Can be an application or a library.',
|
|
19
|
+
type: 'string',
|
|
20
|
+
})
|
|
21
|
+
.option('configuration', {
|
|
22
|
+
describe: `One or more named builder configurations as a comma-separated ` +
|
|
23
|
+
`list as specified in the "configurations" section in angular.json.\n` +
|
|
24
|
+
`The builder uses the named configurations to run the given target.\n` +
|
|
25
|
+
`For more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.`,
|
|
26
|
+
alias: 'c',
|
|
27
|
+
type: 'string',
|
|
28
|
+
})
|
|
29
|
+
.strict();
|
|
30
|
+
const project = this.getArchitectProject();
|
|
31
|
+
if (!project) {
|
|
32
|
+
return localYargs;
|
|
33
|
+
}
|
|
34
|
+
const target = this.getArchitectTarget();
|
|
35
|
+
const schemaOptions = await this.getArchitectTargetOptions({
|
|
36
|
+
project,
|
|
37
|
+
target,
|
|
38
|
+
});
|
|
39
|
+
return this.addSchemaOptionsToCommand(localYargs, schemaOptions);
|
|
40
|
+
}
|
|
41
|
+
async run(options) {
|
|
42
|
+
var _a;
|
|
43
|
+
const target = this.getArchitectTarget();
|
|
44
|
+
const { configuration = '', project, ...architectOptions } = options;
|
|
45
|
+
if (!project) {
|
|
46
|
+
// This runs each target sequentially.
|
|
47
|
+
// Running them in parallel would jumble the log messages.
|
|
48
|
+
let result = 0;
|
|
49
|
+
const projectNames = this.getProjectNamesByTarget(target);
|
|
50
|
+
if (!projectNames) {
|
|
51
|
+
throw new command_module_1.CommandModuleError((_a = this.missingErrorTarget) !== null && _a !== void 0 ? _a : 'Cannot determine project or target for command.');
|
|
52
|
+
}
|
|
53
|
+
for (const project of projectNames) {
|
|
54
|
+
result |= await this.runSingleTarget({ configuration, target, project }, architectOptions);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return await this.runSingleTarget({ configuration, target, project }, architectOptions);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
getArchitectProject() {
|
|
63
|
+
const workspace = this.context.workspace;
|
|
64
|
+
if (!workspace) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const [, projectName] = this.context.args.positional;
|
|
68
|
+
if (projectName) {
|
|
69
|
+
if (!workspace.projects.has(projectName)) {
|
|
70
|
+
throw new command_module_1.CommandModuleError(`Project '${projectName}' does not exist.`);
|
|
71
|
+
}
|
|
72
|
+
return projectName;
|
|
73
|
+
}
|
|
74
|
+
const target = this.getArchitectTarget();
|
|
75
|
+
const projectFromTarget = this.getProjectNamesByTarget(target);
|
|
76
|
+
return (projectFromTarget === null || projectFromTarget === void 0 ? void 0 : projectFromTarget.length) ? projectFromTarget[0] : undefined;
|
|
77
|
+
}
|
|
78
|
+
getArchitectTarget() {
|
|
79
|
+
return this.commandName;
|
|
80
|
+
}
|
|
81
|
+
getProjectNamesByTarget(target) {
|
|
82
|
+
const workspace = this.getWorkspaceOrThrow();
|
|
83
|
+
const allProjectsForTargetName = [];
|
|
84
|
+
for (const [name, project] of workspace.projects) {
|
|
85
|
+
if (project.targets.has(target)) {
|
|
86
|
+
allProjectsForTargetName.push(name);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (allProjectsForTargetName.length === 0) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
if (this.multiTarget) {
|
|
93
|
+
// For multi target commands, we always list all projects that have the target.
|
|
94
|
+
return allProjectsForTargetName;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
if (allProjectsForTargetName.length === 1) {
|
|
98
|
+
return allProjectsForTargetName;
|
|
99
|
+
}
|
|
100
|
+
const maybeProject = (0, config_1.getProjectByCwd)(workspace);
|
|
101
|
+
if (maybeProject && allProjectsForTargetName.includes(maybeProject)) {
|
|
102
|
+
return [maybeProject];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.ArchitectCommandModule = ArchitectCommandModule;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { analytics, logging } from '@angular-devkit/core';
|
|
9
|
+
import { ArgumentsCamelCase, Argv, CamelCaseKey, CommandModule as YargsCommandModule } from 'yargs';
|
|
10
|
+
import { AngularWorkspace } from '../utilities/config';
|
|
11
|
+
import { PackageManagerUtils } from '../utilities/package-manager';
|
|
12
|
+
import { Option } from './utilities/json-schema';
|
|
13
|
+
export declare type Options<T> = {
|
|
14
|
+
[key in keyof T as CamelCaseKey<key>]: T[key];
|
|
15
|
+
};
|
|
16
|
+
export declare enum CommandScope {
|
|
17
|
+
/** Command can only run inside an Angular workspace. */
|
|
18
|
+
In = 0,
|
|
19
|
+
/** Command can only run outside an Angular workspace. */
|
|
20
|
+
Out = 1,
|
|
21
|
+
/** Command can run inside and outside an Angular workspace. */
|
|
22
|
+
Both = 2
|
|
23
|
+
}
|
|
24
|
+
export interface CommandContext {
|
|
25
|
+
currentDirectory: string;
|
|
26
|
+
root: string;
|
|
27
|
+
workspace?: AngularWorkspace;
|
|
28
|
+
globalConfiguration?: AngularWorkspace;
|
|
29
|
+
logger: logging.Logger;
|
|
30
|
+
packageManager: PackageManagerUtils;
|
|
31
|
+
/** Arguments parsed in free-from without parser configuration. */
|
|
32
|
+
args: {
|
|
33
|
+
positional: string[];
|
|
34
|
+
options: {
|
|
35
|
+
help: boolean;
|
|
36
|
+
jsonHelp: boolean;
|
|
37
|
+
} & Record<string, unknown>;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export declare type OtherOptions = Record<string, unknown>;
|
|
41
|
+
export interface CommandModuleImplementation<T extends {} = {}> extends Omit<YargsCommandModule<{}, T>, 'builder' | 'handler'> {
|
|
42
|
+
/** Path used to load the long description for the command in JSON help text. */
|
|
43
|
+
longDescriptionPath?: string;
|
|
44
|
+
/** Object declaring the options the command accepts, or a function accepting and returning a yargs instance. */
|
|
45
|
+
builder(argv: Argv): Promise<Argv<T>> | Argv<T>;
|
|
46
|
+
/** A function which will be passed the parsed argv. */
|
|
47
|
+
run(options: Options<T> & OtherOptions): Promise<number | void> | number | void;
|
|
48
|
+
}
|
|
49
|
+
export interface FullDescribe {
|
|
50
|
+
describe?: string;
|
|
51
|
+
longDescription?: string;
|
|
52
|
+
longDescriptionRelativePath?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare abstract class CommandModule<T extends {} = {}> implements CommandModuleImplementation<T> {
|
|
55
|
+
protected readonly context: CommandContext;
|
|
56
|
+
abstract readonly command: string;
|
|
57
|
+
abstract readonly describe: string | false;
|
|
58
|
+
abstract readonly longDescriptionPath?: string;
|
|
59
|
+
protected readonly shouldReportAnalytics: boolean;
|
|
60
|
+
static scope: CommandScope;
|
|
61
|
+
private readonly optionsWithAnalytics;
|
|
62
|
+
constructor(context: CommandContext);
|
|
63
|
+
/**
|
|
64
|
+
* Description object which contains the long command descroption.
|
|
65
|
+
* This is used to generate JSON help wich is used in AIO.
|
|
66
|
+
*
|
|
67
|
+
* `false` will result in a hidden command.
|
|
68
|
+
*/
|
|
69
|
+
get fullDescribe(): FullDescribe | false;
|
|
70
|
+
protected get commandName(): string;
|
|
71
|
+
abstract builder(argv: Argv): Promise<Argv<T>> | Argv<T>;
|
|
72
|
+
abstract run(options: Options<T> & OtherOptions): Promise<number | void> | number | void;
|
|
73
|
+
handler(args: ArgumentsCamelCase<T> & OtherOptions): Promise<void>;
|
|
74
|
+
reportAnalytics(options: (Options<T> & OtherOptions) | OtherOptions, paths?: string[], dimensions?: (boolean | number | string)[]): Promise<void>;
|
|
75
|
+
private _analytics;
|
|
76
|
+
protected getAnalytics(): Promise<analytics.Analytics>;
|
|
77
|
+
/**
|
|
78
|
+
* Adds schema options to a command also this keeps track of options that are required for analytics.
|
|
79
|
+
* **Note:** This method should be called from the command bundler method.
|
|
80
|
+
*/
|
|
81
|
+
protected addSchemaOptionsToCommand<T>(localYargs: Argv<T>, options: Option[]): Argv<T>;
|
|
82
|
+
protected getWorkspaceOrThrow(): AngularWorkspace;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates an known command module error.
|
|
86
|
+
* This is used so during executation we can filter between known validation error and real non handled errors.
|
|
87
|
+
*/
|
|
88
|
+
export declare class CommandModuleError extends Error {
|
|
89
|
+
}
|