@lizard-build/cli 4.0.105 → 4.0.108
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/dist/commands/sandbox.js +30 -8
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/commands/support.d.ts +2 -0
- package/dist/commands/support.js +100 -0
- package/dist/commands/support.js.map +1 -0
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api.js +13 -2
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.js +1 -1
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/skills-data.generated.js +2 -2
- package/dist/lib/skills-data.generated.js.map +1 -1
- package/dist/lib/support.d.ts +28 -0
- package/dist/lib/support.js +112 -0
- package/dist/lib/support.js.map +1 -0
- package/dist/lib/updater.d.ts +1 -1
- package/dist/lib/updater.js +1 -1
- package/package.json +1 -1
- package/skill-data/core/SKILL.md +22 -1
- package/skill-data/core/references/sandboxes.md +1 -1
- package/src/commands/sandbox.ts +27 -7
- package/src/commands/support.ts +103 -0
- package/src/index.ts +20 -1
- package/src/lib/api.ts +12 -2
- package/src/lib/config.ts +1 -1
- package/src/lib/support.ts +112 -0
- package/src/lib/updater.ts +1 -1
- package/test/unit/sandbox.test.ts +5 -0
- package/test/unit/support.test.ts +52 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { isPlatformFailure, printSupportInbox, recordFailedCall, ticketContext } from "../../src/lib/support.js";
|
|
6
|
+
|
|
7
|
+
let home: string;
|
|
8
|
+
beforeEach(() => { home = fs.mkdtempSync(path.join(os.tmpdir(), "lz-support-")); process.env.LIZARD_HOME = home; });
|
|
9
|
+
afterEach(() => { delete process.env.LIZARD_HOME; fs.rmSync(home, { recursive: true, force: true }); vi.restoreAllMocks(); });
|
|
10
|
+
|
|
11
|
+
const unread = { tickets: [{ ticket: "T-1043", subject: "eu create 500", status: "answered", messages: [{ from: "Lizard support (Mike)", body: "Which region?", at: "2026-11-07T18:00:00.000Z" }] }] };
|
|
12
|
+
|
|
13
|
+
describe("support inbox", () => {
|
|
14
|
+
it("prints a reply on stderr at most twice, never on stdout", async () => {
|
|
15
|
+
const err = vi.spyOn(process.stderr, "write").mockImplementation(() => true);
|
|
16
|
+
const out = vi.spyOn(process.stdout, "write").mockImplementation(() => true);
|
|
17
|
+
const fetch = vi.fn(async () => unread);
|
|
18
|
+
for (let i = 0; i < 3; i++) await printSupportInbox(fetch, { force: true });
|
|
19
|
+
const shown = err.mock.calls.map((c) => String(c[0])).filter((s) => s.includes("Which region?"));
|
|
20
|
+
expect(shown).toHaveLength(2);
|
|
21
|
+
expect(shown[0]).toContain("lizard support reply T-1043");
|
|
22
|
+
expect(out).not.toHaveBeenCalled();
|
|
23
|
+
});
|
|
24
|
+
it("checks at most once a minute", async () => {
|
|
25
|
+
vi.spyOn(process.stderr, "write").mockImplementation(() => true);
|
|
26
|
+
const fetch = vi.fn(async () => ({ tickets: [] }));
|
|
27
|
+
await printSupportInbox(fetch);
|
|
28
|
+
await printSupportInbox(fetch);
|
|
29
|
+
expect(fetch).toHaveBeenCalledTimes(1);
|
|
30
|
+
});
|
|
31
|
+
it("never throws when the platform fails", async () => {
|
|
32
|
+
await expect(printSupportInbox(async () => { throw new Error("down"); }, { force: true })).resolves.toBeUndefined();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe("ticket context", () => {
|
|
37
|
+
it("attaches recent failures with keys redacted", () => {
|
|
38
|
+
recordFailedCall("POST", "/api/sandboxes?workspaceId=w1", 500, "boom liz_abcdefghijkl123");
|
|
39
|
+
const ctx = ticketContext() as any;
|
|
40
|
+
expect(ctx.lastErrors).toHaveLength(1);
|
|
41
|
+
expect(ctx.lastErrors[0]).toMatchObject({ method: "POST", path: "/api/sandboxes", status: 500 });
|
|
42
|
+
expect(ctx.lastErrors[0].error).not.toContain("abcdefghijkl");
|
|
43
|
+
expect(ctx.cliVersion).toBeTruthy();
|
|
44
|
+
});
|
|
45
|
+
it("treats only platform-side failures as ticket-worthy", () => {
|
|
46
|
+
expect(isPlatformFailure(500)).toBe(true);
|
|
47
|
+
expect(isPlatformFailure(504)).toBe(true);
|
|
48
|
+
expect(isPlatformFailure(404)).toBe(false);
|
|
49
|
+
expect(isPlatformFailure(402)).toBe(false);
|
|
50
|
+
expect(isPlatformFailure(undefined, "ECONNRESET")).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
});
|