UNPKG

1.9 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.listCommunityPlugins = exports.fetchCommunityPlugins = void 0;
4const tslib_1 = require("tslib");
5const https_1 = require("https");
6const chalk = require("chalk");
7const output_1 = require("../output");
8const COMMUNITY_PLUGINS_JSON_URL = 'https://raw.githubusercontent.com/nrwl/nx/master/community/approved-plugins.json';
9function 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}
34exports.fetchCommunityPlugins = fetchCommunityPlugins;
35function 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}
46exports.listCommunityPlugins = listCommunityPlugins;
47//# sourceMappingURL=community-plugins.js.map
\No newline at end of file