diff --git a/packages/nuxi/src/commands/devtools.ts b/packages/nuxi/src/commands/devtools.ts new file mode 100644 index 0000000000..9d43134aac --- /dev/null +++ b/packages/nuxi/src/commands/devtools.ts @@ -0,0 +1,25 @@ +import { resolve } from 'pathe' +import { execa } from 'execa' +import { showHelp } from '../utils/help' +import { defineNuxtCommand } from './index' + +export default defineNuxtCommand({ + meta: { + name: 'enable', + usage: 'npx nuxi devtools enable|disable [rootDir]', + description: 'Enable or disable features in a Nuxt project' + }, + async invoke (args) { + const [command, _rootDir = '.'] = args._ + const rootDir = resolve(_rootDir) + + if (!['enable', 'disable'].includes(command)) { + console.error(`Unknown command \`${command}\`.`) + showHelp(this.meta) + process.exit(1) + } + + // Defer to feature setup + await execa('npx', ['@nuxt/devtools@latest', command, rootDir], { stdio: 'inherit', cwd: rootDir }) + } +}) diff --git a/packages/nuxi/src/commands/index.ts b/packages/nuxi/src/commands/index.ts index 1efc57bced..b450945bf3 100644 --- a/packages/nuxi/src/commands/index.ts +++ b/packages/nuxi/src/commands/index.ts @@ -18,6 +18,7 @@ export const commands = { info: () => import('./info').then(_rDefault), init: () => import('./init').then(_rDefault), create: () => import('./init').then(_rDefault), + devtools: () => import('./devtools').then(_rDefault), upgrade: () => import('./upgrade').then(_rDefault), test: () => import('./test').then(_rDefault), add: () => import('./add').then(_rDefault),