rattail
Version:
A Vite+ oriented, AI Agent friendly front-end toolchain
64 lines (63 loc) • 3.91 kB
JavaScript
import { Command } from "commander";
import fs from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
//#region src/cli/utils.ts
function getCliVersion() {
return JSON.parse(fs.readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../../package.json"), "utf-8")).version;
}
//#endregion
//#region src/cli/bin.ts
const program = new Command();
program.version(getCliVersion());
program.command("clean").description("Remove files and directories").argument("[patterns...]").action(async (patterns) => {
const { clean } = await import("../clean-ChrJ3VXV.mjs").then((n) => n.n);
return clean(patterns.length ? patterns : void 0);
});
program.command("api").description("Generate API modules from OpenAPI/Swagger schema").action(async () => {
const { api } = await import("../api-BZphli-u.mjs").then((n) => n.n);
return api();
});
program.command("hook").description("Install git hooks from config").action(async () => {
const { hook } = await import("../hook-e3tLJA2D.mjs").then((n) => n.r);
return hook();
});
program.command("release").description("Release all packages and generate changelogs").option("-t, --npmTag <tag>", "npm dist-tag (e.g. beta, next)").option("-r, --remote <remote>", "Git remote name for pushing").option("--skip-npm-publish", "Skip npm publish").option("--skip-changelog", "Skip changelog generation").option("--skip-git-tag", "Skip git tag").option("-c, --check-remote-version", "Skip publish if the current version already exists on npm").action(async (options) => {
const { getConfig } = await import("../config-CpH0B9DB.mjs").then((n) => n.t);
const { release } = await import("../release-CtpGDUcn.mjs").then((n) => n.n);
return release({
...(await getConfig()).release ?? {},
...options.npmTag != null ? { npmTag: options.npmTag } : {},
...options.remote != null ? { remote: options.remote } : {},
...options.skipNpmPublish ? { skipNpmPublish: true } : {},
...options.skipChangelog ? { skipChangelog: true } : {},
...options.skipGitTag ? { skipGitTag: true } : {},
...options.checkRemoteVersion ? { checkRemoteVersion: true } : {}
});
});
program.command("publish").description("Publish workspace packages to npm (pnpm recursive publish)").option("-c, --checkRemoteVersion", "Skip publish if the current version already exists on npm").option("-t, --npmTag <tag>", "npm dist-tag (e.g. beta, next); ignored when --pre-release is set").option("--pre-release", "Publish with alpha dist-tag").action(async (options) => {
const { getConfig } = await import("../config-CpH0B9DB.mjs").then((n) => n.t);
const { publish } = await import("../publish-C86CKyEw.mjs").then((n) => n.n);
return publish({
...(await getConfig()).publish ?? {},
...options.checkRemoteVersion ? { checkRemoteVersion: true } : {},
...options.npmTag != null ? { npmTag: options.npmTag } : {},
...options.preRelease ? { preRelease: true } : {}
});
});
program.command("changelog").description("Generate changelog").action(async () => {
const { changelog } = await import("../changelog-CbLZqT8o.mjs").then((n) => n.n);
return changelog();
});
program.command("commit-lint").description("Lint commit message").argument("<commitMessagePath>", "Git commit message path").action(async (commitMessagePath) => {
const { commitLint } = await import("../commitLint-eVcRXbbH.mjs").then((n) => n.n);
return commitLint({ commitMessagePath });
});
program.command("lockfile-check").description("Check if lockfile has been updated and auto-install dependencies").option("-m, --packageManager <manager>", "Package manager (npm, yarn, pnpm)").option("-s, --skipInstall", "Skip install dependencies when lockfile changed").action(async (options) => {
const { lockfileCheck } = await import("../lockfileCheck-DKW6MKdC.mjs").then((n) => n.n);
return lockfileCheck(options);
});
program.parse();
//#endregion
export {};