2021-07-26 14:04:35 +00:00
|
|
|
import type { Argv } from 'mri'
|
|
|
|
|
2021-10-02 16:01:17 +00:00
|
|
|
const _rDefault = r => r.default || r
|
|
|
|
|
2021-04-09 15:52:45 +00:00
|
|
|
export const commands = {
|
2021-10-02 16:01:17 +00:00
|
|
|
dev: () => import('./dev').then(_rDefault),
|
|
|
|
build: () => import('./build').then(_rDefault),
|
2021-12-21 11:46:42 +00:00
|
|
|
preview: () => import('./preview').then(_rDefault),
|
|
|
|
start: () => import('./preview').then(_rDefault),
|
2021-10-21 19:51:44 +00:00
|
|
|
analyze: () => import('./analyze').then(_rDefault),
|
2021-10-12 08:52:28 +00:00
|
|
|
generate: () => import('./generate').then(_rDefault),
|
2021-10-02 16:01:17 +00:00
|
|
|
prepare: () => import('./prepare').then(_rDefault),
|
2021-11-24 16:02:57 +00:00
|
|
|
typecheck: () => import('./typecheck').then(_rDefault),
|
2021-10-02 16:01:17 +00:00
|
|
|
usage: () => import('./usage').then(_rDefault),
|
2021-10-05 20:35:23 +00:00
|
|
|
info: () => import('./info').then(_rDefault),
|
|
|
|
init: () => import('./init').then(_rDefault),
|
2021-10-26 17:36:22 +00:00
|
|
|
create: () => import('./init').then(_rDefault),
|
2022-03-16 12:34:27 +00:00
|
|
|
upgrade: () => import('./upgrade').then(_rDefault),
|
2022-03-25 14:56:36 +00:00
|
|
|
test: () => import('./test').then(_rDefault),
|
|
|
|
add: () => import('./add').then(_rDefault),
|
|
|
|
new: () => import('./add').then(_rDefault)
|
2021-04-09 15:52:45 +00:00
|
|
|
}
|
2021-07-26 14:04:35 +00:00
|
|
|
|
|
|
|
export type Command = keyof typeof commands
|
|
|
|
|
|
|
|
export interface NuxtCommandMeta {
|
|
|
|
name: string;
|
|
|
|
usage: string;
|
|
|
|
description: string;
|
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
|
2022-04-09 10:02:56 +00:00
|
|
|
export type CLIInvokeResult = void | 'error' | 'wait'
|
|
|
|
|
2021-07-26 14:04:35 +00:00
|
|
|
export interface NuxtCommand {
|
2022-04-09 10:02:56 +00:00
|
|
|
invoke(args: Argv): Promise<CLIInvokeResult> | CLIInvokeResult
|
2021-07-26 14:04:35 +00:00
|
|
|
meta: NuxtCommandMeta
|
|
|
|
}
|
|
|
|
|
|
|
|
export function defineNuxtCommand (command: NuxtCommand): NuxtCommand {
|
|
|
|
return command
|
|
|
|
}
|