#!/usr/bin/env node /** * termix-plugin: build, validate, test and pack a Termix plugin. * * Run from a plugin directory (npm run build inside plugins// does). */ import process from "node:process"; import { build } from "./commands/build.mjs"; import { validate } from "./commands/validate.mjs"; import { test } from "./commands/test.mjs"; import { pack } from "./commands/pack.mjs"; const COMMANDS = { build, validate, test, pack }; const [command, ...args] = process.argv.slice(2); if (!command || command === "--help" || command === "-h") { console.log( [ "Usage: termix-plugin ", "", " build Bundle the plugin into dist/", " validate Check manifest.json and the files it names", " test Run the plugin's vitest suite", " pack Write a .tgz of the built plugin", ].join("\n"), ); process.exit(command ? 0 : 1); } const run = COMMANDS[command]; if (!run) { console.error(`Unknown command: ${command}`); process.exit(1); } try { await run({ cwd: process.cwd(), args }); } catch (error) { console.error(error?.message ?? error); process.exit(1); }