feat: add ucas command alias to cli-json-cas bin field

Fixes #24

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 14:06:23 +08:00
parent 98dc91e848
commit 1e8ccb8962
2 changed files with 35 additions and 1 deletions
+2 -1
View File
@@ -3,7 +3,8 @@
"version": "0.5.3",
"type": "module",
"bin": {
"json-cas": "./src/index.ts"
"json-cas": "./src/index.ts",
"ucas": "./src/index.ts"
},
"scripts": {
"test": "bun test",
+33
View File
@@ -0,0 +1,33 @@
import { describe, expect, test } from "bun:test";
import { resolve } from "node:path";
const pkgPath = resolve(import.meta.dir, "../package.json");
describe("ucas command alias", () => {
test("T1: ucas bin entry exists in package.json", async () => {
const pkg = await Bun.file(pkgPath).json();
expect(pkg.bin.ucas).toBe("./src/index.ts");
});
test("T2: json-cas bin entry is preserved in package.json", async () => {
const pkg = await Bun.file(pkgPath).json();
expect(pkg.bin["json-cas"]).toBe("./src/index.ts");
});
test("T3: ucas command is executable and shows help", async () => {
const entrypoint = resolve(import.meta.dir, "index.ts");
const proc = Bun.spawn(["bun", entrypoint, "--help"], {
stdout: "pipe",
stderr: "pipe",
});
const exitCode = await proc.exited;
const stdout = await new Response(proc.stdout).text();
expect(exitCode).toBe(0);
expect(stdout.length).toBeGreaterThan(0);
});
test("T4: both commands point to the same entrypoint", async () => {
const pkg = await Bun.file(pkgPath).json();
expect(pkg.bin.ucas).toBe(pkg.bin["json-cas"]);
});
});