4lothru 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +22 -2
- package/bin/4lothru.js +2 -0
- package/dist/cli.js +386 -0
- package/dist/index.d.ts +1531 -0
- package/dist/index.js +5157 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ndivho Makhuvha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 4lothru
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Install the SDK and CLI from one self-contained package:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install 4lothru
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Initialize the browser SDK once at app startup:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Trail } from "4lothru";
|
|
13
|
+
|
|
14
|
+
Trail.init();
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The CLI is available as `4lothru`:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx 4lothru validate
|
|
21
|
+
npx 4lothru build
|
|
22
|
+
npx 4lothru preview
|
|
23
|
+
```
|
package/bin/4lothru.js
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
// ../cli/src/cli.ts
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
|
|
4
|
+
// ../cli/src/validate.ts
|
|
5
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
|
|
8
|
+
// ../guide-schema/dist/index.js
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { z as z2 } from "zod";
|
|
11
|
+
import { z as z3 } from "zod";
|
|
12
|
+
import { parse as parseYamlText } from "yaml";
|
|
13
|
+
var TargetSchema = z.object({
|
|
14
|
+
testId: z.string().min(1).optional(),
|
|
15
|
+
role: z.string().min(1).optional(),
|
|
16
|
+
name: z.string().min(1).optional(),
|
|
17
|
+
label: z.string().min(1).optional(),
|
|
18
|
+
text: z.string().min(1).optional(),
|
|
19
|
+
selector: z.string().min(1).optional()
|
|
20
|
+
}).strict().superRefine((value, ctx) => {
|
|
21
|
+
const hasStrategy = !!value.testId || !!value.role && !!value.name || !!value.label || !!value.text || !!value.selector;
|
|
22
|
+
if (!hasStrategy) {
|
|
23
|
+
ctx.addIssue({
|
|
24
|
+
code: z.ZodIssueCode.custom,
|
|
25
|
+
message: "Target must specify at least one of testId, role+name, label, text, or selector."
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (value.role && !value.name) {
|
|
29
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["name"], message: "A role target also requires a name." });
|
|
30
|
+
}
|
|
31
|
+
if (value.name && !value.role) {
|
|
32
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["role"], message: "A name target also requires a role." });
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
var id = z2.string().min(1);
|
|
36
|
+
var instruction = z2.string().min(1);
|
|
37
|
+
var autoAdvance = z2.boolean().optional();
|
|
38
|
+
var ClickStepSchema = z2.object({ id, action: z2.literal("click"), target: TargetSchema, instruction, autoAdvance }).strict();
|
|
39
|
+
var InputStepSchema = z2.object({
|
|
40
|
+
id,
|
|
41
|
+
action: z2.literal("input"),
|
|
42
|
+
target: TargetSchema,
|
|
43
|
+
value: z2.string(),
|
|
44
|
+
instruction,
|
|
45
|
+
autoAdvance
|
|
46
|
+
}).strict();
|
|
47
|
+
var SelectStepSchema = z2.object({
|
|
48
|
+
id,
|
|
49
|
+
action: z2.literal("select"),
|
|
50
|
+
target: TargetSchema,
|
|
51
|
+
value: z2.string(),
|
|
52
|
+
instruction,
|
|
53
|
+
autoAdvance
|
|
54
|
+
}).strict();
|
|
55
|
+
var VerifyStepSchema = z2.object({ id, action: z2.literal("verify"), target: TargetSchema, instruction }).strict();
|
|
56
|
+
var NavigateStepSchema = z2.object({ id, action: z2.literal("navigate"), url: z2.string().min(1), instruction }).strict();
|
|
57
|
+
var WaitStepSchema = z2.object({
|
|
58
|
+
id,
|
|
59
|
+
action: z2.literal("wait"),
|
|
60
|
+
target: TargetSchema.optional(),
|
|
61
|
+
timeoutMs: z2.number().int().positive().optional(),
|
|
62
|
+
instruction
|
|
63
|
+
}).strict();
|
|
64
|
+
var GuideStepSchema = z2.discriminatedUnion("action", [
|
|
65
|
+
ClickStepSchema,
|
|
66
|
+
InputStepSchema,
|
|
67
|
+
SelectStepSchema,
|
|
68
|
+
VerifyStepSchema,
|
|
69
|
+
NavigateStepSchema,
|
|
70
|
+
WaitStepSchema
|
|
71
|
+
]);
|
|
72
|
+
var placementFields = {
|
|
73
|
+
before: z2.string().min(1).optional(),
|
|
74
|
+
after: z2.string().min(1).optional()
|
|
75
|
+
};
|
|
76
|
+
var AuthorGuideStepSchema = z2.discriminatedUnion("action", [
|
|
77
|
+
ClickStepSchema.extend(placementFields),
|
|
78
|
+
InputStepSchema.extend(placementFields),
|
|
79
|
+
SelectStepSchema.extend(placementFields),
|
|
80
|
+
VerifyStepSchema.extend(placementFields),
|
|
81
|
+
NavigateStepSchema.extend(placementFields),
|
|
82
|
+
WaitStepSchema.extend(placementFields)
|
|
83
|
+
]);
|
|
84
|
+
var GuideSchema = z3.object({
|
|
85
|
+
id: z3.string().min(1),
|
|
86
|
+
title: z3.string().min(1),
|
|
87
|
+
application: z3.string().min(1),
|
|
88
|
+
release: z3.string().min(1),
|
|
89
|
+
start: z3.object({ url: z3.string().min(1) }).strict(),
|
|
90
|
+
steps: z3.array(GuideStepSchema).min(1, "A guide must contain at least one step.")
|
|
91
|
+
}).passthrough();
|
|
92
|
+
var AuthorGuideSchema = z3.object({
|
|
93
|
+
id: z3.string().min(1),
|
|
94
|
+
title: z3.string().min(1),
|
|
95
|
+
application: z3.string().min(1),
|
|
96
|
+
release: z3.string().min(1),
|
|
97
|
+
start: z3.object({ url: z3.string().min(1) }).strict(),
|
|
98
|
+
extends: z3.string().min(1).optional(),
|
|
99
|
+
steps: z3.array(AuthorGuideStepSchema).min(1, "A guide must contain at least one step.")
|
|
100
|
+
}).passthrough().superRefine((guide, context) => {
|
|
101
|
+
guide.steps.forEach((step, index) => {
|
|
102
|
+
const hasBefore = step.before !== void 0;
|
|
103
|
+
const hasAfter = step.after !== void 0;
|
|
104
|
+
if (hasBefore && hasAfter) {
|
|
105
|
+
context.addIssue({
|
|
106
|
+
code: z3.ZodIssueCode.custom,
|
|
107
|
+
path: ["steps", index],
|
|
108
|
+
message: "An extension step must use either before or after, not both."
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (guide.extends && !hasBefore && !hasAfter) {
|
|
112
|
+
context.addIssue({
|
|
113
|
+
code: z3.ZodIssueCode.custom,
|
|
114
|
+
path: ["steps", index],
|
|
115
|
+
message: "An extension step must specify before or after."
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (!guide.extends && (hasBefore || hasAfter)) {
|
|
119
|
+
context.addIssue({
|
|
120
|
+
code: z3.ZodIssueCode.custom,
|
|
121
|
+
path: ["steps", index],
|
|
122
|
+
message: "before and after are only valid on a guide with extends."
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
function formatPath(path3) {
|
|
128
|
+
if (path3.length === 0) return "(root)";
|
|
129
|
+
let out = "";
|
|
130
|
+
for (const segment of path3) {
|
|
131
|
+
if (typeof segment === "number") {
|
|
132
|
+
out += `[${segment}]`;
|
|
133
|
+
} else {
|
|
134
|
+
out += out ? `.${segment}` : segment;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
function issuesFromZodError(error) {
|
|
140
|
+
return error.issues.map((issue) => {
|
|
141
|
+
const path3 = formatPath(issue.path);
|
|
142
|
+
const lastSegment = issue.path[issue.path.length - 1];
|
|
143
|
+
if (lastSegment === "target" && issue.code === "invalid_type") {
|
|
144
|
+
return { path: path3, message: "Target is required." };
|
|
145
|
+
}
|
|
146
|
+
return { path: path3, message: issue.message };
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function parseAuthorData(raw) {
|
|
150
|
+
const result = AuthorGuideSchema.safeParse(raw);
|
|
151
|
+
if (!result.success) {
|
|
152
|
+
return { success: false, issues: issuesFromZodError(result.error) };
|
|
153
|
+
}
|
|
154
|
+
return { success: true, guide: result.data };
|
|
155
|
+
}
|
|
156
|
+
function parseAuthorGuideYaml(yamlText) {
|
|
157
|
+
let raw;
|
|
158
|
+
try {
|
|
159
|
+
raw = parseYamlText(yamlText);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
return {
|
|
162
|
+
success: false,
|
|
163
|
+
issues: [
|
|
164
|
+
{ path: "(yaml)", message: error instanceof Error ? error.message : "Invalid YAML." }
|
|
165
|
+
]
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return parseAuthorData(raw);
|
|
169
|
+
}
|
|
170
|
+
function withoutPlacement(step) {
|
|
171
|
+
const { before: _before, after: _after, ...runtimeStep } = step;
|
|
172
|
+
return runtimeStep;
|
|
173
|
+
}
|
|
174
|
+
function duplicateStepIssue(steps) {
|
|
175
|
+
const ids = /* @__PURE__ */ new Set();
|
|
176
|
+
for (const step of steps) {
|
|
177
|
+
if (ids.has(step.id)) {
|
|
178
|
+
return { path: "steps", message: `Duplicate step id: ${step.id}.` };
|
|
179
|
+
}
|
|
180
|
+
ids.add(step.id);
|
|
181
|
+
}
|
|
182
|
+
return void 0;
|
|
183
|
+
}
|
|
184
|
+
function runtimeGuideData(guide, steps) {
|
|
185
|
+
const { extends: _extends, steps: _steps, ...runtimeGuide } = guide;
|
|
186
|
+
return { ...runtimeGuide, steps };
|
|
187
|
+
}
|
|
188
|
+
function resolveGuide(guide, guidesById, resolving = /* @__PURE__ */ new Set()) {
|
|
189
|
+
var _a;
|
|
190
|
+
if (resolving.has(guide.id)) {
|
|
191
|
+
return { success: false, issues: [{ path: "extends", message: "Guide inheritance cycle detected." }] };
|
|
192
|
+
}
|
|
193
|
+
if (!guide.extends) {
|
|
194
|
+
const steps2 = guide.steps.map(withoutPlacement);
|
|
195
|
+
const duplicateIssue2 = duplicateStepIssue(steps2);
|
|
196
|
+
if (duplicateIssue2) return { success: false, issues: [duplicateIssue2] };
|
|
197
|
+
const parsed2 = GuideSchema.safeParse(runtimeGuideData(guide, steps2));
|
|
198
|
+
return parsed2.success ? { success: true, guide: parsed2.data } : { success: false, issues: parsed2.error.issues.map((issue) => ({ path: issue.path.join("."), message: issue.message })) };
|
|
199
|
+
}
|
|
200
|
+
const base = guidesById.get(guide.extends);
|
|
201
|
+
if (!base) {
|
|
202
|
+
return { success: false, issues: [{ path: "extends", message: `Base guide not found: ${guide.extends}.` }] };
|
|
203
|
+
}
|
|
204
|
+
if (guide.release !== base.release || guide.application !== base.application) {
|
|
205
|
+
return {
|
|
206
|
+
success: false,
|
|
207
|
+
issues: [{ path: "extends", message: "An extension must match its base guide's release and application." }]
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const nextResolving = new Set(resolving);
|
|
211
|
+
nextResolving.add(guide.id);
|
|
212
|
+
const baseResult = resolveGuide(base, guidesById, nextResolving);
|
|
213
|
+
if (!baseResult.success) return baseResult;
|
|
214
|
+
const steps = [...baseResult.guide.steps];
|
|
215
|
+
for (const extensionStep of guide.steps) {
|
|
216
|
+
const anchorId = (_a = extensionStep.before) != null ? _a : extensionStep.after;
|
|
217
|
+
const anchorIndex = steps.findIndex((step) => step.id === anchorId);
|
|
218
|
+
if (anchorIndex === -1) {
|
|
219
|
+
return { success: false, issues: [{ path: "steps", message: `Anchor step not found: ${anchorId}.` }] };
|
|
220
|
+
}
|
|
221
|
+
steps.splice(extensionStep.before ? anchorIndex : anchorIndex + 1, 0, withoutPlacement(extensionStep));
|
|
222
|
+
}
|
|
223
|
+
const duplicateIssue = duplicateStepIssue(steps);
|
|
224
|
+
if (duplicateIssue) return { success: false, issues: [duplicateIssue] };
|
|
225
|
+
const parsed = GuideSchema.safeParse(runtimeGuideData(guide, steps));
|
|
226
|
+
return parsed.success ? { success: true, guide: parsed.data } : { success: false, issues: parsed.error.issues.map((issue) => ({ path: issue.path.join("."), message: issue.message })) };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// ../cli/src/validate.ts
|
|
230
|
+
var REPO_ROOT = process.cwd();
|
|
231
|
+
var GUIDES_ROOT = path.join(REPO_ROOT, "guides", "releases");
|
|
232
|
+
function discoverGuides(guidesRoot = GUIDES_ROOT) {
|
|
233
|
+
if (!existsSync(guidesRoot)) return [];
|
|
234
|
+
const guides = [];
|
|
235
|
+
const releases = readdirSync(guidesRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
|
|
236
|
+
for (const release of releases) {
|
|
237
|
+
const releaseDir = path.join(guidesRoot, release.name);
|
|
238
|
+
const files = readdirSync(releaseDir).filter((f) => f.endsWith(".yaml") || f.endsWith(".yml"));
|
|
239
|
+
for (const file of files.sort()) {
|
|
240
|
+
guides.push({ release: release.name, file, filePath: path.join(releaseDir, file) });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return guides;
|
|
244
|
+
}
|
|
245
|
+
function resolveDiscoveredGuides(guidesRoot = GUIDES_ROOT) {
|
|
246
|
+
const parsed = discoverGuides(guidesRoot).map((source) => ({
|
|
247
|
+
source,
|
|
248
|
+
result: parseAuthorGuideYaml(readFileSync(source.filePath, "utf-8"))
|
|
249
|
+
}));
|
|
250
|
+
const releases = /* @__PURE__ */ new Map();
|
|
251
|
+
for (const entry of parsed) {
|
|
252
|
+
const release = releases.get(entry.source.release) ?? [];
|
|
253
|
+
release.push(entry);
|
|
254
|
+
releases.set(entry.source.release, release);
|
|
255
|
+
}
|
|
256
|
+
const results = [];
|
|
257
|
+
for (const [release, entries] of releases) {
|
|
258
|
+
const guidesById = /* @__PURE__ */ new Map();
|
|
259
|
+
const duplicateIds = /* @__PURE__ */ new Set();
|
|
260
|
+
for (const { result } of entries) {
|
|
261
|
+
if (!result.success) continue;
|
|
262
|
+
if (guidesById.has(result.guide.id)) duplicateIds.add(result.guide.id);
|
|
263
|
+
else guidesById.set(result.guide.id, result.guide);
|
|
264
|
+
}
|
|
265
|
+
for (const { source, result } of entries) {
|
|
266
|
+
if (!result.success) {
|
|
267
|
+
results.push({ source, success: false, issues: result.issues });
|
|
268
|
+
} else if (duplicateIds.has(result.guide.id)) {
|
|
269
|
+
results.push({
|
|
270
|
+
source,
|
|
271
|
+
success: false,
|
|
272
|
+
issues: [{ path: "id", message: `Duplicate guide id in release ${release}: ${result.guide.id}.` }]
|
|
273
|
+
});
|
|
274
|
+
} else {
|
|
275
|
+
const resolved = resolveGuide(result.guide, guidesById);
|
|
276
|
+
results.push(
|
|
277
|
+
resolved.success ? { source, success: true, guide: resolved.guide } : { source, success: false, issues: resolved.issues }
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return results;
|
|
283
|
+
}
|
|
284
|
+
function validateGuides() {
|
|
285
|
+
const results = resolveDiscoveredGuides().map((result) => {
|
|
286
|
+
const file = `${result.source.release}/${result.source.file}`;
|
|
287
|
+
return result.success ? { file, success: true } : { file, success: false, issues: result.issues };
|
|
288
|
+
});
|
|
289
|
+
return { results };
|
|
290
|
+
}
|
|
291
|
+
function runValidate() {
|
|
292
|
+
const { results } = validateGuides();
|
|
293
|
+
if (results.length === 0) {
|
|
294
|
+
console.log("No guides found under guides/releases/.");
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const failures = results.filter((r) => !r.success);
|
|
298
|
+
for (const result of results) {
|
|
299
|
+
if (result.success) {
|
|
300
|
+
console.log(`\u2713 ${result.file}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (failures.length > 0) {
|
|
304
|
+
for (const failure of failures) {
|
|
305
|
+
console.log("");
|
|
306
|
+
console.log(`\u2717 ${failure.file}`);
|
|
307
|
+
console.log("");
|
|
308
|
+
for (const issue of failure.issues ?? []) {
|
|
309
|
+
console.log(`${issue.path}:`);
|
|
310
|
+
console.log(issue.message);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
console.log("");
|
|
314
|
+
console.error(`${failures.length} of ${results.length} guide(s) invalid.`);
|
|
315
|
+
process.exitCode = 1;
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
console.log("");
|
|
319
|
+
console.log(`${results.length} guides valid.`);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// ../cli/src/build.ts
|
|
323
|
+
import { mkdirSync, mkdtempSync, renameSync, rmSync, writeFileSync } from "fs";
|
|
324
|
+
import path2 from "path";
|
|
325
|
+
var OUTPUT_ROOT = path2.join(REPO_ROOT, "dist", "releases");
|
|
326
|
+
function runBuild(options = {}) {
|
|
327
|
+
const outputRoot = options.outputRoot ?? OUTPUT_ROOT;
|
|
328
|
+
const guidesRoot = options.guidesRoot;
|
|
329
|
+
const guides = resolveDiscoveredGuides(guidesRoot);
|
|
330
|
+
if (guides.length === 0) {
|
|
331
|
+
rmSync(outputRoot, { recursive: true, force: true });
|
|
332
|
+
console.log(`No guides found under ${guidesRoot ?? "guides/releases/"}.`);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const failures = guides.filter((result) => !result.success);
|
|
336
|
+
if (failures.length > 0) {
|
|
337
|
+
for (const result of failures) {
|
|
338
|
+
console.error(`\u2717 ${result.source.release}/${result.source.file}`);
|
|
339
|
+
for (const issue of result.issues) {
|
|
340
|
+
console.error(` ${issue.path}: ${issue.message}`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
console.log("");
|
|
344
|
+
console.error("Build failed: one or more guides are invalid.");
|
|
345
|
+
process.exitCode = 1;
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
mkdirSync(path2.dirname(outputRoot), { recursive: true });
|
|
349
|
+
const stagingRoot = mkdtempSync(`${outputRoot}.tmp-`);
|
|
350
|
+
for (const result of guides) {
|
|
351
|
+
if (!result.success) continue;
|
|
352
|
+
const outDir = path2.join(stagingRoot, result.source.release);
|
|
353
|
+
mkdirSync(outDir, { recursive: true });
|
|
354
|
+
const outFile = path2.join(outDir, `${result.guide.id}.json`);
|
|
355
|
+
writeFileSync(outFile, JSON.stringify(result.guide, null, 2));
|
|
356
|
+
console.log(`\u2713 built ${result.source.release}/${path2.basename(outFile)}`);
|
|
357
|
+
}
|
|
358
|
+
rmSync(outputRoot, { recursive: true, force: true });
|
|
359
|
+
renameSync(stagingRoot, outputRoot);
|
|
360
|
+
console.log("");
|
|
361
|
+
console.log(`Built ${guides.length} guide(s) to ${outputRoot}.`);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// ../cli/src/preview.ts
|
|
365
|
+
import { spawn } from "child_process";
|
|
366
|
+
function runPreview() {
|
|
367
|
+
console.log("Starting local preview server...");
|
|
368
|
+
console.log("Example: http://localhost:5173/g/2026.08.26/PAY-1245");
|
|
369
|
+
console.log("");
|
|
370
|
+
const child = spawn("pnpm", ["--filter", "@4lothru/viewer", "dev"], {
|
|
371
|
+
cwd: REPO_ROOT,
|
|
372
|
+
stdio: "inherit",
|
|
373
|
+
shell: process.platform === "win32"
|
|
374
|
+
});
|
|
375
|
+
child.on("exit", (code) => {
|
|
376
|
+
process.exitCode = code ?? 0;
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// ../cli/src/cli.ts
|
|
381
|
+
var program = new Command();
|
|
382
|
+
program.name("4lothru").description("4lothru CLI").version("0.1.0");
|
|
383
|
+
program.command("validate").description("Validate all YAML guides under guides/releases/").action(() => runValidate());
|
|
384
|
+
program.command("build").description("Convert YAML guides into static JSON assets under dist/releases/").action(() => runBuild());
|
|
385
|
+
program.command("preview").description("Start a local preview server for the viewer").action(() => runPreview());
|
|
386
|
+
program.parse(process.argv);
|