pnpmc
Version:
PNPM Catalogs Tooling
106 lines (98 loc) • 3 kB
JavaScript
import { runner_default } from "./runner-FWSEFY4j.js";
import { fail } from "./utils-nUJKoOjh.js";
import { interopDefault } from "@kazupon/jts-utils";
import { cli } from "gunshi";
import { renderHeader, renderValidationErrors } from "gunshi/renderer";
import pc from "picocolors";
import { lazy } from "gunshi/definition";
//#region src/commands/register/meta.ts
const args$1 = {
catalog: {
type: "string",
description: "Register the catalog. Use with --dependency and --alias options.",
short: "c",
default: "default"
},
dependency: {
type: "string",
description: "Register the dependency, required. use with --alias and --catalog options",
short: "d",
required: true
},
alias: {
type: "string",
description: "Register the alias, required. Use with --dependency and --catalog options",
short: "a",
required: true
}
};
var meta_default$1 = {
name: "register",
description: "Register the dependency to the catalog",
args: args$1,
examples: `
pnpmc register --dependency typescript --alias ^5.7.9 --catalog tools`
};
//#endregion
//#region src/commands/register/lazy.ts
var lazy_default$1 = lazy(async () => interopDefault(import("./runner-C21gupv8.js")), meta_default$1);
//#endregion
//#region src/commands/show/meta.ts
const args = {
catalog: {
type: "boolean",
description: "Display the catalog only",
short: "c",
default: false
},
dependency: {
type: "boolean",
description: "Display the catalogable dependencies only",
short: "d",
default: false
}
};
var meta_default = {
name: "show",
description: "Show the catalog and catalogable dependencies (default command)",
args,
examples: `
pnpmc
};
//#endregion
//#region src/commands/show/lazy.ts
var lazy_default = lazy(async () => interopDefault(import("./runner-HZTG_Yvh.js")), meta_default);
//#endregion
//#region src/commands/index.ts
const commands = new Map();
commands.set("show", lazy_default);
commands.set("register", lazy_default$1);
//#endregion
//#region src/commands/show/index.ts
var show_default = {
...meta_default,
run: runner_default
};
//#endregion
//#region src/index.ts
async function main() {
const pkgJson = await interopDefault(import("../package.json", { with: { type: "json" } }));
await cli(process.argv.slice(2), show_default, {
name: "pnpmc",
cwd: process.cwd(),
description: pkgJson.description,
version: pkgJson.version,
subCommands: commands,
renderHeader: async (ctx) => pc.cyanBright(await renderHeader(ctx)),
renderValidationErrors: async (ctx, e) => {
const messages = [];
messages.push(pc.redBright(await renderValidationErrors(ctx, e)));
messages.push("", `For more info, run \`${ctx.env.name || ctx.translate("COMMAND")} ${ctx.name || ctx.translate("SUBCOMMAND")} --help\``, "");
return messages.join("\n");
}
});
}
main().catch((error) => {
fail(error);
});
//#endregion