Skip to content

Commit

Permalink
feat(misc): list should link to nx.dev/community for more plugins (nr…
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder authored May 2, 2023
1 parent e164d50 commit a425f5b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 36 deletions.
20 changes: 9 additions & 11 deletions packages/nx/src/command-line/list.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { workspaceRoot } from '../utils/workspace-root';
import { output } from '../utils/output';
import {
fetchCommunityPlugins,
fetchCorePlugins,
getInstalledPluginsAndCapabilities,
listCommunityPlugins,
listCorePlugins,
listInstalledPlugins,
listPluginCapabilities,
Expand Down Expand Up @@ -36,14 +34,6 @@ export async function listHandler(args: ListArgs): Promise<void> {
await listPluginCapabilities(args.plugin);
} else {
const corePlugins = fetchCorePlugins();
const communityPlugins = await fetchCommunityPlugins().catch(() => {
output.warn({
title: `Community plugins:`,
bodyLines: [`Error fetching plugins.`],
});

return [];
});
const projectGraph = await createProjectGraphAsync({ exitOnError: true });

const localPlugins = await getLocalWorkspacePlugins(
Expand All @@ -58,7 +48,15 @@ export async function listHandler(args: ListArgs): Promise<void> {
}
listInstalledPlugins(installedPlugins);
listCorePlugins(installedPlugins, corePlugins);
listCommunityPlugins(installedPlugins, communityPlugins);

output.note({
title: 'Community Plugins',
bodyLines: [
'Looking for a technology / framework not listed above?',
'There are many excellent plugins matintained by the Nx community.',
'Search for the one you need here: https://nx.dev/community.',
],
});

output.note({
title: `Use "nx list [plugin]" to find out more`,
Expand Down
22 changes: 1 addition & 21 deletions packages/nx/src/utils/plugins/community-plugins.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { get } from 'https';
import * as chalk from 'chalk';
import { output } from '../output';
import type { CommunityPlugin, PluginCapabilities } from './models';
import type { CommunityPlugin } from './models';

const COMMUNITY_PLUGINS_JSON_URL =
'https://raw.githubusercontent.com/nrwl/nx/master/community/approved-plugins.json';
Expand Down Expand Up @@ -30,21 +28,3 @@ export async function fetchCommunityPlugins(): Promise<CommunityPlugin[]> {
req.end();
});
}

export function listCommunityPlugins(
installedPlugins: Map<string, PluginCapabilities>,
communityPlugins?: CommunityPlugin[]
): void {
if (!communityPlugins) return;

const availableCommunityPlugins = communityPlugins.filter(
(p) => !installedPlugins.has(p.name)
);

output.log({
title: `Community plugins:`,
bodyLines: availableCommunityPlugins.map((p) => {
return `${chalk.bold(p.name)} - ${p.description}`;
}),
});
}
5 changes: 1 addition & 4 deletions packages/nx/src/utils/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export {
fetchCommunityPlugins,
listCommunityPlugins,
} from './community-plugins';
export { fetchCommunityPlugins } from './community-plugins';
export { fetchCorePlugins, listCorePlugins } from './core-plugins';
export {
getInstalledPluginsAndCapabilities,
Expand Down

0 comments on commit a425f5b

Please sign in to comment.