Skip to content

Commit 7079400

Browse files
committed
Merge remote-tracking branch 'origin/main' into refactor/bundling
2 parents 37063ee + 5fe4d62 commit 7079400

File tree

10 files changed

+2616
-1096
lines changed

10 files changed

+2616
-1096
lines changed

pnpm-lock.yaml

Lines changed: 2589 additions & 1060 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { ThemeIcon, QuickPickItem, window } from 'vscode';
2-
import { newTerminal, projectRootDirectory, jiti, detectPackageManagerByName } from '../../utils';
2+
import { newTerminal, projectRootDirectory, 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';
5+
import { tryImportNuxi } from '../../nuxi';
66

77
const pm = detectPackageManagerByName();
88
const runCommand = pm ? pm.runCommand : 'npx';
@@ -38,7 +38,12 @@ const shouldDirectlyRun = (command: any) => directlyExecutableCommands.includes(
3838
const shouldIndirectlyRun = (command: any) => indirectlyExecutableCommands.includes(command);
3939

4040
const showCLICommands = async () => {
41-
const commands = Object.keys(await cliCommands);
41+
const nuxi = await tryImportNuxi()
42+
if (!nuxi) {
43+
console.log('nuxi not found')
44+
return
45+
}
46+
const commands = Object.keys(nuxi.main.subCommands);
4247

4348
const options = {
4449
placeHolder: 'Select a command',

src/commands/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createMiddleware, directCreateMiddleware } from './Middleware'
77
import { createNitroAPI, directCreateNitroAPI, createNitroRoute, directCreateNitroRoute, createNitroPlugin, createNitroMiddleware, createNitroUtil } from './Nitro'
88
import { projectStructure, appConfig, nuxtIgnore, nuxtRC } from './Structure'
99
import { openDocumentation, openModules } from './externalLinks'
10-
import { nuxtDev, nuxtBuild, nuxtGenerate, nuxtCleanUp, nuxtAnalyze, nuxtInfo, showCLICommands } from './NuxtCLI'
10+
import { nuxtDev, nuxtBuild, nuxtGenerate, nuxtCleanUp, nuxtAnalyze, nuxtInfo, showCLICommands } from './Nuxi'
1111
import { createStore, directCreateStore } from './Store'
1212
import { installDependencies, searchAndInstallDependencies } from './InstallDependencies'
1313
import { openSettings } from '../utils/navigation'

src/extension.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import codelens from './codelens'
66
import { statusBars, activateStatusBarIcons } from './statusBar'
77
import { activateIntellisense } from './intellisense'
88
import { filesWatcher } from './watchers'
9-
import { checkCLIInstallation } from './nuxtCLI';
109

1110
const commandList = [
1211
{ command: 'nuxtr.createPage', function: nuxtrCommands.createPage },
@@ -87,13 +86,9 @@ export async function activateExtension(context: ExtensionContext) {
8786
// activate intellisense
8887
activateIntellisense(context)
8988

90-
// check nuxt cli installation
91-
await checkCLIInstallation()
92-
9389
// activate codelens
9490
codelens.activateCodelenses(context)
9591

96-
9792
commandList.forEach(({ command, function: commandFunction }) => {
9893
context.subscriptions.push(commands.registerCommand(command, commandFunction));
9994
});

src/nuxi/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { window } from 'vscode'
2+
import { tryImport, isNuxiInstalled, newTerminal } from '../utils'
3+
4+
export async function tryImportNuxi() {
5+
return (await tryImport('nuxi') || await tryImport('nuxi-edge')) as undefined | typeof import('nuxi-edge')
6+
}

src/nuxtCLI/index.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/utils/global.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,13 @@ export const runCommand = async (args: {
114114
};
115115

116116

117-
export const jiti = require("jiti")(__filename, { esmResolve: true, interopDefault: true });
117+
const _jiti = require("jiti")(projectRootDirectory(), { esmResolve: true, interopDefault: true });
118+
119+
export async function tryImport (path: string): Promise<undefined | unknown> {
120+
try {
121+
return _jiti(path)
122+
} catch (error) {
123+
return undefined;
124+
}
125+
}
126+

src/utils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getNonce, getUri, projectRootDirectory, openExternalLink, getConfiguration, newTerminal, runCommand, projectSrcDirectory, jiti } from './global'
1+
import { getNonce, getUri, projectRootDirectory, openExternalLink, getConfiguration, newTerminal, runCommand, projectSrcDirectory, tryImport } from './global'
22

33
import {
44
addNuxtModule,
@@ -44,7 +44,7 @@ export {
4444
openExternalLink,
4545
getProjectDependencies,
4646
getProjectScripts,
47-
jiti,
47+
tryImport,
4848
getNuxtVersion,
4949
isNuxtTwo,
5050
hasSrcDir,

0 commit comments

Comments
 (0)