Skip to content

Commit 5760549

Browse files
committed
feat: modules filters
1 parent a2230e6 commit 5760549

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/commands/NuxtCLI/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ThemeIcon, QuickPickItem, window } from 'vscode';
22
import { newTerminal, projectRootDirectory, jiti, detectPackageManagerByName } from '../../utils';
33
import { nuxtDev, nuxtBuild, nuxtGenerate, nuxtCleanUp, nuxtAnalyze, nuxtInfo } from './commonCommands';
44
import { handleModuleCommand, handleAddCommand, handleDevtoolsCommand } from './multiStepCommands';
5+
import { cliCommands } from '../../nuxtCLI';
56

67
const pm = detectPackageManagerByName();
78
const runCommand = pm ? pm.runCommand : 'npx';
@@ -37,8 +38,7 @@ const shouldDirectlyRun = (command: any) => directlyExecutableCommands.includes(
3738
const shouldIndirectlyRun = (command: any) => indirectlyExecutableCommands.includes(command);
3839

3940
const showCLICommands = async () => {
40-
const { main } = jiti("nuxi-edge");
41-
const commands = Object.keys(main.subCommands);
41+
const commands = Object.keys(await cliCommands);
4242

4343
const options = {
4444
placeHolder: 'Select a command',

src/commands/NuxtCLI/multiStepCommands.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { QuickPickItem, window, QuickPickOptions } from 'vscode';
2-
import { newTerminal, detectPackageManagerByName, projectRootDirectory } from '../../utils';
2+
import { newTerminal, detectPackageManagerByName, projectRootDirectory, isNuxtTwo } from '../../utils';
33
import type { nuxtModule } from '../../types';
44
import axios from 'axios';
55

@@ -66,14 +66,16 @@ export const handleModuleCommand = async () => {
6666
canPickMany: true
6767
};
6868

69-
const items = modules.map((module) => {
70-
const item: QuickPickItem = {
71-
label: module.name,
72-
description: module.description
73-
};
69+
const items = modules
70+
.filter(module => isNuxtTwo() ? module.tags.includes('2.x') : module.tags.includes('3.x'))
71+
.map((module) => {
72+
const item: QuickPickItem = {
73+
label: module.name,
74+
description: module.description
75+
};
7476

75-
return item;
76-
});
77+
return item;
78+
});
7779

7880
window.showQuickPick(items, options).then((selection) => {
7981
if (!selection) {

src/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ type nuxtModule = {
7474
nuxt: string;
7575
requires: Record<string, any>;
7676
};
77+
tags: string[];
7778
};

0 commit comments

Comments
 (0)