Skip to content

Commit f2fe32d

Browse files
authored
refactor: Nuxi Module command
refactor: Nuxi Module command
2 parents 924c3f4 + 1d217cd commit f2fe32d

File tree

3 files changed

+6
-39
lines changed

3 files changed

+6
-39
lines changed

src/commands/Devtools.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ async function nuxtDevToolsHandler() {
150150
let nuxtVersion = getNuxtVersion();
151151
if (typeof nuxtVersion === 'string') {
152152
isDevtoolsNative = nuxtVersion.startsWith('3.8') ? true : false;
153-
console.log('isDevtoolsNative', isDevtoolsNative);
154-
155153
}
156154

157155
if (!isInstalled && !isDevtoolsNative) {

src/commands/Nuxi/multiStepCommands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const runCommand = pm ? pm.runCommand : 'npx';
88

99

1010
const fetchModules = async () => {
11-
let res = await ofetch('https://nuxt.com/api/modules');
11+
let res = await ofetch('https://api.nuxt.com/modules');
1212
return res.modules;
1313
}
1414

@@ -67,7 +67,7 @@ export const handleModuleCommand = async () => {
6767
};
6868

6969
const items = modules
70-
.filter(module => isNuxtTwo() ? module.tags.includes('2.x') : module.tags.includes('3.x'))
70+
.filter(module => isNuxtTwo() ? module.compatibility.nuxt.includes('2.0.0') : module.compatibility.nuxt.includes('3.0.0'))
7171
.map((module) => {
7272
const item: QuickPickItem = {
7373
label: module.name,

src/index.ts

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,9 @@
1-
import { workspace, ExtensionContext, commands, window } from 'vscode'
2-
import { existsSync, promises as fs } from 'fs'
3-
import { join } from 'pathe'
4-
import { isNuxtProject, getConfiguration } from './utils'
1+
import { ExtensionContext, commands } from 'vscode';
52
import { activateExtension } from './extension'
63

74
export async function activate(context: ExtensionContext) {
5+
const nuxtProject = true
86

9-
let userRoot: string | undefined
10-
11-
const configuration = getConfiguration().monorepoMode.DirectoryName
12-
13-
if (!configuration) {
14-
userRoot = workspace.workspaceFolders?.[0]?.uri.fsPath
15-
} else {
16-
userRoot = workspace.workspaceFolders?.[0]?.uri.fsPath + `/` + configuration
17-
}
18-
19-
if (!userRoot && !existsSync(`${userRoot}/package.json`)) { return }
20-
21-
const nuxtConfigPathTS = join(`${userRoot}/`, 'nuxt.config.ts')
22-
const nuxtConfigPathJS = join(`${userRoot}/`, 'nuxt.config.js')
23-
24-
const nuxtConfigExistsTS = await fs.access(nuxtConfigPathTS).then(() => true).catch(() => false)
25-
const nuxtConfigExistsJS = await fs.access(nuxtConfigPathJS).then(() => true).catch(() => false)
26-
27-
if (!nuxtConfigExistsTS && !nuxtConfigExistsJS) { return }
28-
29-
30-
const nuxtProject = await isNuxtProject()
31-
32-
if (nuxtProject) {
33-
commands.executeCommand('setContext', 'nuxtr.isNuxtProject', nuxtProject)
34-
activateExtension(context)
35-
36-
} else {
37-
commands.executeCommand('setContext', 'nuxtr.isNuxtProject', nuxtProject)
38-
window.showInformationMessage('Nuxtr: Not a Nuxt project')
39-
}
7+
commands.executeCommand('setContext', 'nuxtr.isNuxtProject', nuxtProject)
8+
activateExtension(context)
409
}

0 commit comments

Comments
 (0)