@angular/cli 14.0.0-next.1 → 14.0.0-next.10
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 +21 -23
- 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 +306 -0
- package/src/command-builder/architect-base-command-module.d.ts +30 -0
- package/src/command-builder/architect-base-command-module.js +165 -0
- package/src/command-builder/architect-command-module.d.ts +25 -0
- package/src/command-builder/architect-command-module.js +134 -0
- package/src/command-builder/command-module.d.ts +89 -0
- package/src/command-builder/command-module.js +198 -0
- package/{utilities/package-json.js → src/command-builder/command-runner.d.ts} +2 -2
- package/src/command-builder/command-runner.js +168 -0
- package/src/command-builder/schematics-command-module.d.ts +43 -0
- package/src/command-builder/schematics-command-module.js +333 -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/src/command-builder/utilities/normalize-options-middleware.d.ts +18 -0
- package/src/command-builder/utilities/normalize-options-middleware.js +59 -0
- package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +2 -2
- package/{models → src/command-builder/utilities}/schematic-engine-host.js +30 -17
- 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 +49 -0
- package/src/commands/completion/cli.d.ts +16 -0
- package/src/commands/completion/cli.js +31 -0
- package/src/commands/completion/long-description.md +1 -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 +17 -0
- package/src/commands/deploy/cli.js +49 -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 +18 -0
- package/src/commands/e2e/cli.js +35 -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 +17 -0
- package/src/commands/lint/cli.js +28 -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 +82 -0
- package/src/commands/run/cli.d.ts +25 -0
- package/src/commands/run/cli.js +83 -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} +363 -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 +6 -5
- package/{utilities → src/utilities}/config.js +33 -19
- 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 +1 -0
- package/{utilities → src/utilities}/log-file.d.ts +0 -0
- package/{utilities → src/utilities}/log-file.js +0 -0
- package/src/utilities/memoize.d.ts +15 -0
- package/src/utilities/memoize.js +69 -0
- package/src/utilities/package-manager.d.ts +41 -0
- package/src/utilities/package-manager.js +287 -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 +2 -0
- package/{utilities → src/utilities}/prompt.js +25 -4
- 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 -32
- package/commands/extract-i18n.d.ts +0 -29
- package/commands/extract-i18n.js +0 -10
- package/commands/extract-i18n.json +0 -17
- 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/INITIAL_COMMIT_MESSAGE.txt +0 -8
- 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,306 @@
|
|
|
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
|
+
async function setAnalyticsConfig(global, value) {
|
|
91
|
+
var _a;
|
|
92
|
+
var _b;
|
|
93
|
+
const level = global ? 'global' : 'local';
|
|
94
|
+
analyticsDebug('setting %s level analytics to: %s', level, value);
|
|
95
|
+
const workspace = await (0, config_1.getWorkspace)(level);
|
|
96
|
+
if (!workspace) {
|
|
97
|
+
throw new Error(`Could not find ${level} workspace.`);
|
|
98
|
+
}
|
|
99
|
+
const cli = ((_a = (_b = workspace.extensions)['cli']) !== null && _a !== void 0 ? _a : (_b['cli'] = {}));
|
|
100
|
+
if (!workspace || !core_1.json.isJsonObject(cli)) {
|
|
101
|
+
throw new Error(`Invalid config found at ${workspace.filePath}. CLI should be an object.`);
|
|
102
|
+
}
|
|
103
|
+
cli.analytics = value === true ? (0, uuid_1.v4)() : value;
|
|
104
|
+
await workspace.save();
|
|
105
|
+
analyticsDebug('done');
|
|
106
|
+
}
|
|
107
|
+
exports.setAnalyticsConfig = setAnalyticsConfig;
|
|
108
|
+
/**
|
|
109
|
+
* Prompt the user for usage gathering permission.
|
|
110
|
+
* @param force Whether to ask regardless of whether or not the user is using an interactive shell.
|
|
111
|
+
* @return Whether or not the user was shown a prompt.
|
|
112
|
+
*/
|
|
113
|
+
async function promptAnalytics(global, force = false) {
|
|
114
|
+
analyticsDebug('prompting user');
|
|
115
|
+
const level = global ? 'global' : 'local';
|
|
116
|
+
const workspace = await (0, config_1.getWorkspace)(level);
|
|
117
|
+
if (!workspace) {
|
|
118
|
+
throw new Error(`Could not find a ${level} workspace. Are you in a project?`);
|
|
119
|
+
}
|
|
120
|
+
if (force || (0, tty_1.isTTY)()) {
|
|
121
|
+
const { prompt } = await Promise.resolve().then(() => __importStar(require('inquirer')));
|
|
122
|
+
const answers = await prompt([
|
|
123
|
+
{
|
|
124
|
+
type: 'confirm',
|
|
125
|
+
name: 'analytics',
|
|
126
|
+
message: core_1.tags.stripIndents `
|
|
127
|
+
Would you like to share anonymous usage data about this project with the Angular Team at
|
|
128
|
+
Google under Google’s Privacy Policy at https://policies.google.com/privacy. For more
|
|
129
|
+
details and how to change this setting, see https://angular.io/analytics.
|
|
130
|
+
|
|
131
|
+
`,
|
|
132
|
+
default: false,
|
|
133
|
+
},
|
|
134
|
+
]);
|
|
135
|
+
await setAnalyticsConfig(global, answers.analytics);
|
|
136
|
+
if (answers.analytics) {
|
|
137
|
+
console.log('');
|
|
138
|
+
console.log(core_1.tags.stripIndent `
|
|
139
|
+
Thank you for sharing anonymous usage data. Should you change your mind, the following
|
|
140
|
+
command will disable this feature entirely:
|
|
141
|
+
|
|
142
|
+
${color_1.colors.yellow(`ng analytics disable${global ? ' --global' : ''}`)}
|
|
143
|
+
`);
|
|
144
|
+
console.log('');
|
|
145
|
+
// Send back a ping with the user `optin`.
|
|
146
|
+
const ua = new analytics_collector_1.AnalyticsCollector(exports.AnalyticsProperties.AngularCliDefault, 'optin');
|
|
147
|
+
ua.pageview('/telemetry/project/optin');
|
|
148
|
+
await ua.flush();
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
// Send back a ping with the user `optout`. This is the only thing we send.
|
|
152
|
+
const ua = new analytics_collector_1.AnalyticsCollector(exports.AnalyticsProperties.AngularCliDefault, 'optout');
|
|
153
|
+
ua.pageview('/telemetry/project/optout');
|
|
154
|
+
await ua.flush();
|
|
155
|
+
}
|
|
156
|
+
process.stderr.write(await getAnalyticsInfoString());
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
exports.promptAnalytics = promptAnalytics;
|
|
162
|
+
/**
|
|
163
|
+
* Get the analytics object for the user.
|
|
164
|
+
*
|
|
165
|
+
* @returns
|
|
166
|
+
* - `AnalyticsCollector` when enabled.
|
|
167
|
+
* - `analytics.NoopAnalytics` when disabled.
|
|
168
|
+
* - `undefined` when not configured.
|
|
169
|
+
*/
|
|
170
|
+
async function getAnalytics(level) {
|
|
171
|
+
var _a;
|
|
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 = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.getCli()) === null || _a === void 0 ? void 0 : _a['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
|
+
var _a;
|
|
214
|
+
analyticsDebug('getSharedAnalytics');
|
|
215
|
+
if (environment_options_1.analyticsShareDisabled) {
|
|
216
|
+
analyticsDebug('NG_CLI_ANALYTICS is false');
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
219
|
+
// If anything happens we just keep the NOOP analytics.
|
|
220
|
+
try {
|
|
221
|
+
const globalWorkspace = await (0, config_1.getWorkspace)('global');
|
|
222
|
+
const analyticsConfig = (_a = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.getCli()) === null || _a === void 0 ? void 0 : _a['analyticsSharing'];
|
|
223
|
+
if (!analyticsConfig || !analyticsConfig.tracking || !analyticsConfig.uuid) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
analyticsDebug('Analytics sharing info: %j', analyticsConfig);
|
|
228
|
+
return new analytics_collector_1.AnalyticsCollector(analyticsConfig.tracking, analyticsConfig.uuid);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (err) {
|
|
232
|
+
analyticsDebug('Error happened during reading of analytics sharing config: %s', err.message);
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.getSharedAnalytics = getSharedAnalytics;
|
|
237
|
+
async function createAnalytics(workspace, skipPrompt = false) {
|
|
238
|
+
// Global config takes precedence over local config only for the disabled check.
|
|
239
|
+
// IE:
|
|
240
|
+
// global: disabled & local: enabled = disabled
|
|
241
|
+
// global: id: 123 & local: id: 456 = 456
|
|
242
|
+
var _a;
|
|
243
|
+
// check global
|
|
244
|
+
const globalConfig = await getAnalytics('global');
|
|
245
|
+
if (globalConfig instanceof core_1.analytics.NoopAnalytics) {
|
|
246
|
+
return globalConfig;
|
|
247
|
+
}
|
|
248
|
+
let config = globalConfig;
|
|
249
|
+
// Not disabled globally, check locally or not set globally and command is run outside of workspace example: `ng new`
|
|
250
|
+
if (workspace || globalConfig === undefined) {
|
|
251
|
+
const level = workspace ? 'local' : 'global';
|
|
252
|
+
let localOrGlobalConfig = await getAnalytics(level);
|
|
253
|
+
if (localOrGlobalConfig === undefined) {
|
|
254
|
+
if (!skipPrompt) {
|
|
255
|
+
// config is unset, prompt user.
|
|
256
|
+
// TODO: This should honor the `no-interactive` option.
|
|
257
|
+
// It is currently not an `ng` option but rather only an option for specific commands.
|
|
258
|
+
// The concept of `ng`-wide options are needed to cleanly handle this.
|
|
259
|
+
await promptAnalytics(!workspace /** global */);
|
|
260
|
+
localOrGlobalConfig = await getAnalytics(level);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (localOrGlobalConfig instanceof core_1.analytics.NoopAnalytics) {
|
|
264
|
+
return localOrGlobalConfig;
|
|
265
|
+
}
|
|
266
|
+
else if (localOrGlobalConfig) {
|
|
267
|
+
// Favor local settings over global when defined.
|
|
268
|
+
config = localOrGlobalConfig;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// Get shared analytics
|
|
272
|
+
// TODO: evalute if this should be completly removed.
|
|
273
|
+
const maybeSharedAnalytics = await getSharedAnalytics();
|
|
274
|
+
if (config && maybeSharedAnalytics) {
|
|
275
|
+
return new core_1.analytics.MultiAnalytics([config, maybeSharedAnalytics]);
|
|
276
|
+
}
|
|
277
|
+
return (_a = config !== null && config !== void 0 ? config : maybeSharedAnalytics) !== null && _a !== void 0 ? _a : new core_1.analytics.NoopAnalytics();
|
|
278
|
+
}
|
|
279
|
+
exports.createAnalytics = createAnalytics;
|
|
280
|
+
function analyticsConfigValueToHumanFormat(value) {
|
|
281
|
+
if (value === false) {
|
|
282
|
+
return 'disabled';
|
|
283
|
+
}
|
|
284
|
+
else if (typeof value === 'string' || value === true) {
|
|
285
|
+
return 'enabled';
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
return 'not set';
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
async function getAnalyticsInfoString() {
|
|
292
|
+
var _a, _b;
|
|
293
|
+
const globalWorkspace = await (0, config_1.getWorkspace)('global');
|
|
294
|
+
const localWorkspace = await (0, config_1.getWorkspace)('local');
|
|
295
|
+
const globalSetting = (_a = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.getCli()) === null || _a === void 0 ? void 0 : _a['analytics'];
|
|
296
|
+
const localSetting = (_b = localWorkspace === null || localWorkspace === void 0 ? void 0 : localWorkspace.getCli()) === null || _b === void 0 ? void 0 : _b['analytics'];
|
|
297
|
+
const analyticsInstance = await createAnalytics(!!localWorkspace /** workspace */, true /** skipPrompt */);
|
|
298
|
+
return (core_1.tags.stripIndents `
|
|
299
|
+
Global setting: ${analyticsConfigValueToHumanFormat(globalSetting)}
|
|
300
|
+
Local setting: ${localWorkspace
|
|
301
|
+
? analyticsConfigValueToHumanFormat(localSetting)
|
|
302
|
+
: 'No local workspace configuration file.'}
|
|
303
|
+
Effective status: ${analyticsInstance instanceof core_1.analytics.NoopAnalytics ? 'disabled' : 'enabled'}
|
|
304
|
+
` + '\n');
|
|
305
|
+
}
|
|
306
|
+
exports.getAnalyticsInfoString = getAnalyticsInfoString;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 interface MissingTargetChoice {
|
|
13
|
+
name: string;
|
|
14
|
+
value: string;
|
|
15
|
+
}
|
|
16
|
+
export declare abstract class ArchitectBaseCommandModule<T> extends CommandModule<T> implements CommandModuleImplementation<T> {
|
|
17
|
+
static scope: CommandScope;
|
|
18
|
+
protected shouldReportAnalytics: boolean;
|
|
19
|
+
protected readonly missingTargetChoices: MissingTargetChoice[] | undefined;
|
|
20
|
+
protected runSingleTarget(target: Target, options: OtherOptions): Promise<number>;
|
|
21
|
+
private _architectHost;
|
|
22
|
+
protected getArchitectHost(): WorkspaceNodeModulesArchitectHost;
|
|
23
|
+
private _architect;
|
|
24
|
+
protected getArchitect(): Architect;
|
|
25
|
+
protected getArchitectTargetOptions(target: Target): Promise<Option[]>;
|
|
26
|
+
private warnOnMissingNodeModules;
|
|
27
|
+
protected getArchitectTarget(): string;
|
|
28
|
+
protected onMissingTarget(defaultMessage: string): Promise<1>;
|
|
29
|
+
private getMissingTargetPackageToInstall;
|
|
30
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
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 child_process_1 = require("child_process");
|
|
15
|
+
const fs_1 = require("fs");
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const analytics_1 = require("../analytics/analytics");
|
|
18
|
+
const prompt_1 = require("../utilities/prompt");
|
|
19
|
+
const tty_1 = require("../utilities/tty");
|
|
20
|
+
const command_module_1 = require("./command-module");
|
|
21
|
+
const json_schema_1 = require("./utilities/json-schema");
|
|
22
|
+
class ArchitectBaseCommandModule extends command_module_1.CommandModule {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.shouldReportAnalytics = false;
|
|
26
|
+
}
|
|
27
|
+
async runSingleTarget(target, options) {
|
|
28
|
+
const architectHost = await this.getArchitectHost();
|
|
29
|
+
let builderName;
|
|
30
|
+
try {
|
|
31
|
+
builderName = await architectHost.getBuilderNameForTarget(target);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
return this.onMissingTarget(e.message);
|
|
35
|
+
}
|
|
36
|
+
await this.reportAnalytics({
|
|
37
|
+
...(await architectHost.getOptionsForTarget(target)),
|
|
38
|
+
...options,
|
|
39
|
+
});
|
|
40
|
+
const { logger } = this.context;
|
|
41
|
+
const run = await this.getArchitect().scheduleTarget(target, options, {
|
|
42
|
+
logger,
|
|
43
|
+
analytics: (0, analytics_1.isPackageNameSafeForAnalytics)(builderName) ? await this.getAnalytics() : undefined,
|
|
44
|
+
});
|
|
45
|
+
const { error, success } = await run.output.toPromise();
|
|
46
|
+
await run.stop();
|
|
47
|
+
if (error) {
|
|
48
|
+
logger.error(error);
|
|
49
|
+
}
|
|
50
|
+
return success ? 0 : 1;
|
|
51
|
+
}
|
|
52
|
+
getArchitectHost() {
|
|
53
|
+
if (this._architectHost) {
|
|
54
|
+
return this._architectHost;
|
|
55
|
+
}
|
|
56
|
+
const workspace = this.getWorkspaceOrThrow();
|
|
57
|
+
return (this._architectHost = new node_1.WorkspaceNodeModulesArchitectHost(workspace, workspace.basePath));
|
|
58
|
+
}
|
|
59
|
+
getArchitect() {
|
|
60
|
+
if (this._architect) {
|
|
61
|
+
return this._architect;
|
|
62
|
+
}
|
|
63
|
+
const registry = new core_1.json.schema.CoreSchemaRegistry();
|
|
64
|
+
registry.addPostTransform(core_1.json.schema.transforms.addUndefinedDefaults);
|
|
65
|
+
registry.useXDeprecatedProvider((msg) => this.context.logger.warn(msg));
|
|
66
|
+
const architectHost = this.getArchitectHost();
|
|
67
|
+
return (this._architect = new architect_1.Architect(architectHost, registry));
|
|
68
|
+
}
|
|
69
|
+
async getArchitectTargetOptions(target) {
|
|
70
|
+
const architectHost = this.getArchitectHost();
|
|
71
|
+
let builderConf;
|
|
72
|
+
try {
|
|
73
|
+
builderConf = await architectHost.getBuilderNameForTarget(target);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
let builderDesc;
|
|
79
|
+
try {
|
|
80
|
+
builderDesc = await architectHost.resolveBuilder(builderConf);
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
if (e.code === 'MODULE_NOT_FOUND') {
|
|
84
|
+
this.warnOnMissingNodeModules();
|
|
85
|
+
throw new command_module_1.CommandModuleError(`Could not find the '${builderConf}' builder's node package.`);
|
|
86
|
+
}
|
|
87
|
+
throw e;
|
|
88
|
+
}
|
|
89
|
+
return (0, json_schema_1.parseJsonSchemaToOptions)(new core_1.json.schema.CoreSchemaRegistry(), builderDesc.optionSchema, true);
|
|
90
|
+
}
|
|
91
|
+
warnOnMissingNodeModules() {
|
|
92
|
+
var _a;
|
|
93
|
+
const basePath = (_a = this.context.workspace) === null || _a === void 0 ? void 0 : _a.basePath;
|
|
94
|
+
if (!basePath) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Check for a `node_modules` directory (npm, yarn non-PnP, etc.)
|
|
98
|
+
if ((0, fs_1.existsSync)((0, path_1.resolve)(basePath, 'node_modules'))) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// Check for yarn PnP files
|
|
102
|
+
if ((0, fs_1.existsSync)((0, path_1.resolve)(basePath, '.pnp.js')) ||
|
|
103
|
+
(0, fs_1.existsSync)((0, path_1.resolve)(basePath, '.pnp.cjs')) ||
|
|
104
|
+
(0, fs_1.existsSync)((0, path_1.resolve)(basePath, '.pnp.mjs'))) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.context.logger.warn(`Node packages may not be installed. Try installing with '${this.context.packageManager} install'.`);
|
|
108
|
+
}
|
|
109
|
+
getArchitectTarget() {
|
|
110
|
+
return this.commandName;
|
|
111
|
+
}
|
|
112
|
+
async onMissingTarget(defaultMessage) {
|
|
113
|
+
const { logger } = this.context;
|
|
114
|
+
const choices = this.missingTargetChoices;
|
|
115
|
+
if (!(choices === null || choices === void 0 ? void 0 : choices.length)) {
|
|
116
|
+
logger.error(defaultMessage);
|
|
117
|
+
return 1;
|
|
118
|
+
}
|
|
119
|
+
const missingTargetMessage = `Cannot find "${this.getArchitectTarget()}" target for the specified project.\n` +
|
|
120
|
+
`You can add a package that implements these capabilities.\n\n` +
|
|
121
|
+
`For example:\n` +
|
|
122
|
+
choices.map(({ name, value }) => ` ${name}: ng add ${value}`).join('\n') +
|
|
123
|
+
'\n';
|
|
124
|
+
if ((0, tty_1.isTTY)()) {
|
|
125
|
+
// Use prompts to ask the user if they'd like to install a package.
|
|
126
|
+
logger.warn(missingTargetMessage);
|
|
127
|
+
const packageToInstall = await this.getMissingTargetPackageToInstall(choices);
|
|
128
|
+
if (packageToInstall) {
|
|
129
|
+
// Example run: `ng add @angular-eslint/schematics`.
|
|
130
|
+
const binPath = (0, path_1.resolve)(__dirname, '../../bin/ng.js');
|
|
131
|
+
const { error } = (0, child_process_1.spawnSync)(process.execPath, [binPath, 'add', packageToInstall], {
|
|
132
|
+
stdio: 'inherit',
|
|
133
|
+
});
|
|
134
|
+
if (error) {
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// Non TTY display error message.
|
|
141
|
+
logger.error(missingTargetMessage);
|
|
142
|
+
}
|
|
143
|
+
return 1;
|
|
144
|
+
}
|
|
145
|
+
async getMissingTargetPackageToInstall(choices) {
|
|
146
|
+
if (choices.length === 1) {
|
|
147
|
+
// Single choice
|
|
148
|
+
const { name, value } = choices[0];
|
|
149
|
+
if (await (0, prompt_1.askConfirmation)(`Would you like to add ${name} now?`, true, false)) {
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
// Multiple choice
|
|
155
|
+
return (0, prompt_1.askQuestion)(`Would you like to add a package with "${this.getArchitectTarget()}" capabilities now?`, [
|
|
156
|
+
{
|
|
157
|
+
name: 'No',
|
|
158
|
+
value: null,
|
|
159
|
+
},
|
|
160
|
+
...choices,
|
|
161
|
+
], 0, null);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.ArchitectBaseCommandModule = ArchitectBaseCommandModule;
|
|
165
|
+
ArchitectBaseCommandModule.scope = command_module_1.CommandScope.In;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 getProjectNamesByTarget;
|
|
21
|
+
/** @returns a sorted list of project names to be used for auto completion. */
|
|
22
|
+
private getProjectChoices;
|
|
23
|
+
/** @returns a sorted list of configuration names to be used for auto completion. */
|
|
24
|
+
private getConfigurationChoices;
|
|
25
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
10
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ArchitectCommandModule = void 0;
|
|
17
|
+
const config_1 = require("../utilities/config");
|
|
18
|
+
const memoize_1 = require("../utilities/memoize");
|
|
19
|
+
const architect_base_command_module_1 = require("./architect-base-command-module");
|
|
20
|
+
class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBaseCommandModule {
|
|
21
|
+
async builder(argv) {
|
|
22
|
+
const project = this.getArchitectProject();
|
|
23
|
+
const { jsonHelp, getYargsCompletions, help } = this.context.args.options;
|
|
24
|
+
const localYargs = argv
|
|
25
|
+
.positional('project', {
|
|
26
|
+
describe: 'The name of the project to build. Can be an application or a library.',
|
|
27
|
+
type: 'string',
|
|
28
|
+
// Hide choices from JSON help so that we don't display them in AIO.
|
|
29
|
+
choices: jsonHelp ? undefined : this.getProjectChoices(),
|
|
30
|
+
})
|
|
31
|
+
.option('configuration', {
|
|
32
|
+
describe: `One or more named builder configurations as a comma-separated ` +
|
|
33
|
+
`list as specified in the "configurations" section in angular.json.\n` +
|
|
34
|
+
`The builder uses the named configurations to run the given target.\n` +
|
|
35
|
+
`For more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.`,
|
|
36
|
+
alias: 'c',
|
|
37
|
+
type: 'string',
|
|
38
|
+
// Show only in when using --help and auto completion because otherwise comma seperated configuration values will be invalid.
|
|
39
|
+
// Also, hide choices from JSON help so that we don't display them in AIO.
|
|
40
|
+
choices: (getYargsCompletions || help) && !jsonHelp && project
|
|
41
|
+
? this.getConfigurationChoices(project)
|
|
42
|
+
: undefined,
|
|
43
|
+
})
|
|
44
|
+
.strict();
|
|
45
|
+
if (!project) {
|
|
46
|
+
return localYargs;
|
|
47
|
+
}
|
|
48
|
+
const target = this.getArchitectTarget();
|
|
49
|
+
const schemaOptions = await this.getArchitectTargetOptions({
|
|
50
|
+
project,
|
|
51
|
+
target,
|
|
52
|
+
});
|
|
53
|
+
return this.addSchemaOptionsToCommand(localYargs, schemaOptions);
|
|
54
|
+
}
|
|
55
|
+
async run(options) {
|
|
56
|
+
const target = this.getArchitectTarget();
|
|
57
|
+
const { configuration = '', project, ...architectOptions } = options;
|
|
58
|
+
if (!project) {
|
|
59
|
+
// This runs each target sequentially.
|
|
60
|
+
// Running them in parallel would jumble the log messages.
|
|
61
|
+
let result = 0;
|
|
62
|
+
const projectNames = this.getProjectNamesByTarget(target);
|
|
63
|
+
if (!projectNames) {
|
|
64
|
+
return this.onMissingTarget('Cannot determine project or target for command.');
|
|
65
|
+
}
|
|
66
|
+
for (const project of projectNames) {
|
|
67
|
+
result |= await this.runSingleTarget({ configuration, target, project }, architectOptions);
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return await this.runSingleTarget({ configuration, target, project }, architectOptions);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
getArchitectProject() {
|
|
76
|
+
const workspace = this.context.workspace;
|
|
77
|
+
if (!workspace) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const [, projectName] = this.context.args.positional;
|
|
81
|
+
if (projectName) {
|
|
82
|
+
return workspace.projects.has(projectName) ? projectName : undefined;
|
|
83
|
+
}
|
|
84
|
+
const target = this.getArchitectTarget();
|
|
85
|
+
const projectFromTarget = this.getProjectNamesByTarget(target);
|
|
86
|
+
return (projectFromTarget === null || projectFromTarget === void 0 ? void 0 : projectFromTarget.length) ? projectFromTarget[0] : undefined;
|
|
87
|
+
}
|
|
88
|
+
getProjectNamesByTarget(target) {
|
|
89
|
+
const workspace = this.getWorkspaceOrThrow();
|
|
90
|
+
const allProjectsForTargetName = [];
|
|
91
|
+
for (const [name, project] of workspace.projects) {
|
|
92
|
+
if (project.targets.has(target)) {
|
|
93
|
+
allProjectsForTargetName.push(name);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (allProjectsForTargetName.length === 0) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
if (this.multiTarget) {
|
|
100
|
+
// For multi target commands, we always list all projects that have the target.
|
|
101
|
+
return allProjectsForTargetName;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
if (allProjectsForTargetName.length === 1) {
|
|
105
|
+
return allProjectsForTargetName;
|
|
106
|
+
}
|
|
107
|
+
const maybeProject = (0, config_1.getProjectByCwd)(workspace);
|
|
108
|
+
if (maybeProject && allProjectsForTargetName.includes(maybeProject)) {
|
|
109
|
+
return [maybeProject];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
/** @returns a sorted list of project names to be used for auto completion. */
|
|
115
|
+
getProjectChoices() {
|
|
116
|
+
const { workspace } = this.context;
|
|
117
|
+
return workspace ? [...workspace.projects.keys()].sort() : undefined;
|
|
118
|
+
}
|
|
119
|
+
/** @returns a sorted list of configuration names to be used for auto completion. */
|
|
120
|
+
getConfigurationChoices(project) {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
const projectDefinition = (_a = this.context.workspace) === null || _a === void 0 ? void 0 : _a.projects.get(project);
|
|
123
|
+
if (!projectDefinition) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
const target = this.getArchitectTarget();
|
|
127
|
+
const configurations = (_b = projectDefinition.targets.get(target)) === null || _b === void 0 ? void 0 : _b.configurations;
|
|
128
|
+
return configurations ? Object.keys(configurations).sort() : undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
__decorate([
|
|
132
|
+
memoize_1.memoize
|
|
133
|
+
], ArchitectCommandModule.prototype, "getProjectNamesByTarget", null);
|
|
134
|
+
exports.ArchitectCommandModule = ArchitectCommandModule;
|