@nuxt/module-builder
Version:
Complete solution for building Nuxt modules
48 lines (45 loc) • 1.16 kB
JavaScript
import { defineCommand } from 'citty';
import { resolve } from 'pathe';
const prepare = defineCommand({
meta: {
name: "prepare",
description: "Prepare @nuxt/module-builder environment by writing types and stubs"
},
args: {
cwd: {
type: "string",
description: "Current working directory"
},
rootDir: {
type: "positional",
description: "Root directory",
required: false
}
},
async run(context) {
const { runCommand } = await import('nuxi');
const cwd = resolve(context.args.cwd || context.args.rootDir || ".");
return runCommand("prepare", [cwd], {
overrides: {
compatibilityDate: "2024-04-03",
typescript: {
builder: "shared"
},
imports: {
autoImport: false
},
modules: [
resolve(cwd, "./src/module"),
function(_options, nuxt) {
nuxt.hooks.hook("app:templates", (app) => {
for (const template of app.templates) {
template.write = true;
}
});
}
]
}
});
}
});
export { prepare as default };