@flatkey-ai/cli 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli.js +7 -1
- package/test/cli.test.js +9 -1
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -87,7 +87,7 @@ export async function runCommand(command, deps = {}) {
|
|
|
87
87
|
return command.options.ai ? getAiHelp() : getHumanHelp();
|
|
88
88
|
}
|
|
89
89
|
if (command.group === "version") {
|
|
90
|
-
return { version:
|
|
90
|
+
return { version: await readPackageVersion() };
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
if (command.group === "models") {
|
|
@@ -244,3 +244,9 @@ function formatHuman(result) {
|
|
|
244
244
|
if (typeof result === "string") return result;
|
|
245
245
|
return JSON.stringify(result, null, 2);
|
|
246
246
|
}
|
|
247
|
+
|
|
248
|
+
async function readPackageVersion() {
|
|
249
|
+
const { readFile } = await import("node:fs/promises");
|
|
250
|
+
const packageUrl = new URL("../package.json", import.meta.url);
|
|
251
|
+
return JSON.parse(await readFile(packageUrl, "utf8")).version;
|
|
252
|
+
}
|
package/test/cli.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { test } from "node:test";
|
|
3
3
|
|
|
4
|
-
import { parseArgv } from "../src/cli.js";
|
|
4
|
+
import { parseArgv, runCommand } from "../src/cli.js";
|
|
5
5
|
|
|
6
6
|
test("parses image generation with prompt and json mode", () => {
|
|
7
7
|
const command = parseArgv(["image", "generate", "--prompt", "city at dawn", "--json"]);
|
|
@@ -81,3 +81,11 @@ test("rejects unknown commands", () => {
|
|
|
81
81
|
/Unknown command: wat/,
|
|
82
82
|
);
|
|
83
83
|
});
|
|
84
|
+
|
|
85
|
+
test("version command matches package version", async () => {
|
|
86
|
+
const pkg = JSON.parse(await (await import("node:fs/promises")).readFile("package.json", "utf8"));
|
|
87
|
+
|
|
88
|
+
assert.deepEqual(await runCommand({ group: "version", options: {} }), {
|
|
89
|
+
version: pkg.version,
|
|
90
|
+
});
|
|
91
|
+
});
|