mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 22:55:24 +00:00
feat: make each plugin an npm workspace built by a termix-plugin CLI
This commit is contained in:
1 parent
4758016f41
commit
5796186a1c
448 files changed
+3087
-2003
No files matched your search
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* termix-plugin: build, validate, test and pack a Termix plugin.
|
||||
*
|
||||
* Run from a plugin directory (npm run build inside plugins/<id>/ 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 <command>",
|
||||
"",
|
||||
" 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);
|
||||
}
|
||||
Reference in new issue
Block a user