1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.listCommunityPlugins = exports.fetchCommunityPlugins = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 | const https_1 = require("https");
|
6 | const chalk = require("chalk");
|
7 | const output_1 = require("../output");
|
8 | const COMMUNITY_PLUGINS_JSON_URL = 'https://raw.githubusercontent.com/nrwl/nx/master/community/approved-plugins.json';
|
9 | function fetchCommunityPlugins() {
|
10 | return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
11 | return new Promise((resolve, reject) => {
|
12 | const req = (0, https_1.get)(COMMUNITY_PLUGINS_JSON_URL, (res) => {
|
13 | if (res.statusCode < 200 || res.statusCode >= 300) {
|
14 | reject(new Error(`Request failed with status code ${res.statusCode}`));
|
15 | }
|
16 | const data = [];
|
17 | res.on('data', (chunk) => {
|
18 | data.push(chunk);
|
19 | });
|
20 | res.on('end', () => {
|
21 | try {
|
22 | resolve(JSON.parse(Buffer.concat(data).toString('utf-8')));
|
23 | }
|
24 | catch (e) {
|
25 | reject(e);
|
26 | }
|
27 | });
|
28 | });
|
29 | req.on('error', reject);
|
30 | req.end();
|
31 | });
|
32 | });
|
33 | }
|
34 | exports.fetchCommunityPlugins = fetchCommunityPlugins;
|
35 | function listCommunityPlugins(installedPlugins, communityPlugins) {
|
36 | if (!communityPlugins)
|
37 | return;
|
38 | const availableCommunityPlugins = communityPlugins.filter((p) => !installedPlugins.has(p.name));
|
39 | output_1.output.log({
|
40 | title: `Community plugins:`,
|
41 | bodyLines: availableCommunityPlugins.map((p) => {
|
42 | return `${chalk.bold(p.name)} - ${p.description}`;
|
43 | }),
|
44 | });
|
45 | }
|
46 | exports.listCommunityPlugins = listCommunityPlugins;
|
47 |
|
\ | No newline at end of file |