1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.listInstalledPlugins = exports.getInstalledPluginsFromPackageJson = void 0;
|
4 | const chalk = require("chalk");
|
5 | const devkit_1 = require("@nrwl/devkit");
|
6 | const output_1 = require("../output");
|
7 | const plugin_capabilities_1 = require("./plugin-capabilities");
|
8 | const shared_1 = require("./shared");
|
9 | const package_json_1 = require("nx/src/utils/package-json");
|
10 | function getInstalledPluginsFromPackageJson(workspaceRoot, corePlugins, communityPlugins = []) {
|
11 | const packageJson = (0, devkit_1.readJsonFile)(`${workspaceRoot}/package.json`);
|
12 | const plugins = new Set([
|
13 | ...corePlugins.map((p) => p.name),
|
14 | ...communityPlugins.map((p) => p.name),
|
15 | ...Object.keys(packageJson.dependencies || {}),
|
16 | ...Object.keys(packageJson.devDependencies || {}),
|
17 | ]);
|
18 | return new Map(Array.from(plugins)
|
19 | .filter((name) => {
|
20 | try {
|
21 |
|
22 |
|
23 | (0, package_json_1.readModulePackageJson)(name);
|
24 | return true;
|
25 | }
|
26 | catch (_a) {
|
27 | return false;
|
28 | }
|
29 | })
|
30 | .sort()
|
31 | .map((name) => [
|
32 | name,
|
33 | (0, plugin_capabilities_1.getPluginCapabilities)(workspaceRoot, name),
|
34 | ])
|
35 | .filter(([, x]) => x && !!(x.generators || x.executors)));
|
36 | }
|
37 | exports.getInstalledPluginsFromPackageJson = getInstalledPluginsFromPackageJson;
|
38 | function listInstalledPlugins(installedPlugins) {
|
39 | const bodyLines = [];
|
40 | for (const [, p] of installedPlugins) {
|
41 | const capabilities = [];
|
42 | if ((0, shared_1.hasElements)(p.executors)) {
|
43 | capabilities.push('executors');
|
44 | }
|
45 | if ((0, shared_1.hasElements)(p.generators)) {
|
46 | capabilities.push('generators');
|
47 | }
|
48 | bodyLines.push(`${chalk.bold(p.name)} (${capabilities.join()})`);
|
49 | }
|
50 | output_1.output.log({
|
51 | title: `Installed plugins:`,
|
52 | bodyLines: bodyLines,
|
53 | });
|
54 | }
|
55 | exports.listInstalledPlugins = listInstalledPlugins;
|
56 |
|
\ | No newline at end of file |