@lizard-build/cli 4.0.130 → 4.0.132
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-environments.d.ts +4 -0
- package/dist/commands/sandbox-environments.js +235 -0
- package/dist/commands/sandbox-environments.js.map +1 -0
- package/dist/commands/sandbox-schedules.d.ts +42 -0
- package/dist/commands/sandbox-schedules.js +107 -8
- package/dist/commands/sandbox-schedules.js.map +1 -1
- package/dist/commands/sandbox.js +39 -3
- package/dist/commands/sandbox.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/updater.d.ts +1 -1
- package/dist/lib/updater.js +1 -1
- package/package.json +1 -1
- package/skill-data/core/SKILL.md +1 -1
- package/skill-data/core/references/sandboxes.md +71 -6
- package/src/commands/sandbox-environments.ts +235 -0
- package/src/commands/sandbox-schedules.ts +99 -8
- package/src/commands/sandbox.ts +38 -3
- package/src/lib/updater.ts +1 -1
- package/test/unit/sandbox-environments.test.ts +43 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { parseAssignments } from "../../src/commands/sandbox-environments.js";
|
|
6
|
+
import { dailyCron, createScheduleBody } from "../../src/commands/sandbox-schedules.js";
|
|
7
|
+
|
|
8
|
+
afterEach(() => vi.restoreAllMocks());
|
|
9
|
+
const exits = () => vi.spyOn(process, "exit").mockImplementation(((c?: number) => { throw new Error(`exit ${c}`); }) as never);
|
|
10
|
+
|
|
11
|
+
describe("sandbox environment-set assignments", () => {
|
|
12
|
+
it("takes KEY=VALUE, keeping = in the value", () => {
|
|
13
|
+
expect(parseAssignments(["A=1", "URL=https://x/?a=b", "EMPTY="])).toEqual({ A: "1", URL: "https://x/?a=b", EMPTY: "" });
|
|
14
|
+
});
|
|
15
|
+
it("reads a .env file: comments, export, quotes; arguments win", () => {
|
|
16
|
+
const f = path.join(fs.mkdtempSync(path.join(os.tmpdir(), "lz-env-")), ".env");
|
|
17
|
+
fs.writeFileSync(f, "# note\nexport A=1\nB=\"two words\"\n\nC='x'\n");
|
|
18
|
+
expect(parseAssignments(["A=9"], f)).toEqual({ A: "9", B: "two words", C: "x" });
|
|
19
|
+
});
|
|
20
|
+
it("refuses an argument that is not KEY=VALUE", () => {
|
|
21
|
+
exits(); vi.spyOn(console, "error").mockImplementation(() => {});
|
|
22
|
+
expect(() => parseAssignments(["JUSTAKEY"])).toThrow("exit 2");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("sandbox schedule --daily-at", () => {
|
|
27
|
+
it("makes the cron the dashboard's Daily at makes", () => {
|
|
28
|
+
expect(dailyCron("09:00", false)).toBe("0 9 * * *");
|
|
29
|
+
expect(dailyCron("18:30", true)).toBe("30 18 * * 1-5");
|
|
30
|
+
});
|
|
31
|
+
it("refuses a time that is not HH:MM", () => {
|
|
32
|
+
exits(); vi.spyOn(console, "error").mockImplementation(() => {});
|
|
33
|
+
expect(() => dailyCron("9am", false)).toThrow("exit 2");
|
|
34
|
+
});
|
|
35
|
+
it("is a schedule's timing on sandbox create", () => {
|
|
36
|
+
expect(createScheduleBody({ dailyAt: "07:15", weekdays: true, tz: "Europe/Berlin", command: "./report.sh" }))
|
|
37
|
+
.toEqual({ cron: "15 7 * * 1-5", timezone: "Europe/Berlin", command: "./report.sh" });
|
|
38
|
+
});
|
|
39
|
+
it("refuses two timings at once", () => {
|
|
40
|
+
exits(); vi.spyOn(console, "error").mockImplementation(() => {});
|
|
41
|
+
expect(() => createScheduleBody({ every: "5m", dailyAt: "07:15", command: "x" })).toThrow("exit 2");
|
|
42
|
+
});
|
|
43
|
+
});
|