@poli-page/cli 0.8.2 → 0.9.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/README.md +98 -20
- package/dist/api-client.d.ts +1 -15
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +54 -26
- package/dist/api-client.js.map +1 -1
- package/dist/commands/dev.d.ts +100 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +593 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/init.d.ts +42 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +153 -10
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/link.d.ts +8 -0
- package/dist/commands/link.d.ts.map +1 -1
- package/dist/commands/link.js +21 -13
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/versions.d.ts +0 -8
- package/dist/commands/versions.d.ts.map +1 -1
- package/dist/commands/versions.js +0 -57
- package/dist/commands/versions.js.map +1 -1
- package/dist/commands/watch.d.ts +1 -1
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +14 -123
- package/dist/commands/watch.js.map +1 -1
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +15 -3
- package/dist/credentials.js.map +1 -1
- package/dist/dev-page.d.ts +22 -0
- package/dist/dev-page.d.ts.map +1 -0
- package/dist/dev-page.js +336 -0
- package/dist/dev-page.js.map +1 -0
- package/dist/dev-server.d.ts +51 -0
- package/dist/dev-server.d.ts.map +1 -0
- package/dist/dev-server.js +228 -0
- package/dist/dev-server.js.map +1 -0
- package/dist/exit-codes.d.ts.map +1 -1
- package/dist/exit-codes.js +3 -2
- package/dist/exit-codes.js.map +1 -1
- package/dist/manifest.schema.d.ts +1 -1
- package/dist/manifest.schema.d.ts.map +1 -1
- package/dist/manifest.schema.js +7 -12
- package/dist/manifest.schema.js.map +1 -1
- package/dist/program.js +2 -2
- package/dist/program.js.map +1 -1
- package/dist/project-sync.d.ts +49 -0
- package/dist/project-sync.d.ts.map +1 -0
- package/dist/project-sync.js +164 -0
- package/dist/project-sync.js.map +1 -0
- package/dist/template-importer.d.ts +15 -0
- package/dist/template-importer.d.ts.map +1 -1
- package/dist/template-importer.js +44 -0
- package/dist/template-importer.js.map +1 -1
- package/package.json +3 -3
- package/dist/commands/checkout.d.ts +0 -15
- package/dist/commands/checkout.d.ts.map +0 -1
- package/dist/commands/checkout.js +0 -145
- package/dist/commands/checkout.js.map +0 -1
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { resolveCloudContext } from '../cloud-context.js';
|
|
4
|
+
import { createFileWatcher } from '../file-watcher.js';
|
|
5
|
+
import { createProjectSyncer } from '../project-sync.js';
|
|
6
|
+
import { findTemplate, loadProject, loadTemplate, unwrapMockJson, } from '../project-loader.js';
|
|
7
|
+
import { resolveAuth } from '../auth.js';
|
|
8
|
+
import { errorToExitCode } from '../exit-codes.js';
|
|
9
|
+
import { startDevServer, DEFAULT_DEV_PORT, } from '../dev-server.js';
|
|
10
|
+
import { DEV_PAGE_HTML, DEV_PLACEHOLDER_HTML } from '../dev-page.js';
|
|
11
|
+
const DEFAULT_DEBOUNCE_MS = 300;
|
|
12
|
+
const PDF_CACHE_LIMIT = 4;
|
|
13
|
+
/**
|
|
14
|
+
* A `templates/<name>/…` path belongs to `<name>`. Anything else — a
|
|
15
|
+
* shared partial, `tailwind.css`, an asset, the manifest — belongs to no
|
|
16
|
+
* single template, so it cannot move the follow target.
|
|
17
|
+
*/
|
|
18
|
+
export function attributeChangedTemplate(changedPath, templateNames) {
|
|
19
|
+
const segments = changedPath.split('/');
|
|
20
|
+
if (segments.length < 3)
|
|
21
|
+
return null;
|
|
22
|
+
if (segments[0] !== 'templates')
|
|
23
|
+
return null;
|
|
24
|
+
const name = segments[1];
|
|
25
|
+
return templateNames.includes(name) ? name : null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Decide which template the view should follow after a sync.
|
|
29
|
+
*
|
|
30
|
+
* "Most recently changed" is resolved per *template-owned* file: only
|
|
31
|
+
* paths under `templates/<name>/` name a template. A batch that touches
|
|
32
|
+
* several of them picks the one whose file has the newest mtime (ties
|
|
33
|
+
* broken alphabetically, so the answer is deterministic).
|
|
34
|
+
*
|
|
35
|
+
* Editing a shared partial, `tailwind.css`, an asset, or the manifest
|
|
36
|
+
* changes many templates at once and therefore names none: the function
|
|
37
|
+
* returns `null`, meaning "keep whatever is on screen and re-render it".
|
|
38
|
+
* That is the honest reading — a shared edit has no single owner, and
|
|
39
|
+
* yanking the user to an arbitrary template would be worse than staying.
|
|
40
|
+
*/
|
|
41
|
+
export async function pickFollowTarget(cwd, changedPaths, templateNames) {
|
|
42
|
+
const newest = new Map();
|
|
43
|
+
for (const changedPath of changedPaths) {
|
|
44
|
+
const template = attributeChangedTemplate(changedPath, templateNames);
|
|
45
|
+
if (!template)
|
|
46
|
+
continue;
|
|
47
|
+
let mtime = 0;
|
|
48
|
+
try {
|
|
49
|
+
mtime = (await stat(join(cwd, changedPath))).mtimeMs;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// Deleted between the sync and this stat — it still counts as a
|
|
53
|
+
// change, just without a usable timestamp.
|
|
54
|
+
mtime = 0;
|
|
55
|
+
}
|
|
56
|
+
const current = newest.get(template);
|
|
57
|
+
if (current === undefined || mtime > current) {
|
|
58
|
+
newest.set(template, mtime);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (newest.size === 0)
|
|
62
|
+
return null;
|
|
63
|
+
return [...newest.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0][0];
|
|
64
|
+
}
|
|
65
|
+
const POSITION_PATTERNS = [
|
|
66
|
+
// `templates/invoice/invoice.html:42:7`
|
|
67
|
+
/([\w./\\-]+\.(?:html|css|json)):(\d+)(?::(\d+))?/i,
|
|
68
|
+
// `… in invoice.html at line 42, column 7`
|
|
69
|
+
/(?:in|at)\s+([\w./\\-]+\.(?:html|css|json))\D+line\s+(\d+)(?:\D+column\s+(\d+))?/i,
|
|
70
|
+
];
|
|
71
|
+
/**
|
|
72
|
+
* Pull a `file:line[:column]` out of an engine error message when the
|
|
73
|
+
* engine bothered to include one. The message is always shown verbatim —
|
|
74
|
+
* this only enriches the overlay header, never replaces the text.
|
|
75
|
+
*/
|
|
76
|
+
export function extractErrorPosition(message) {
|
|
77
|
+
for (const pattern of POSITION_PATTERNS) {
|
|
78
|
+
const match = pattern.exec(message);
|
|
79
|
+
if (!match)
|
|
80
|
+
continue;
|
|
81
|
+
const line = Number.parseInt(match[2], 10);
|
|
82
|
+
const column = match[3] ? Number.parseInt(match[3], 10) : undefined;
|
|
83
|
+
return {
|
|
84
|
+
file: match[1],
|
|
85
|
+
...(Number.isFinite(line) ? { line } : {}),
|
|
86
|
+
...(column !== undefined && Number.isFinite(column) ? { column } : {}),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {};
|
|
90
|
+
}
|
|
91
|
+
function toDevError(stage, err) {
|
|
92
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
93
|
+
return { stage, message, ...extractErrorPosition(message) };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Start the `poli dev` loop and its local server.
|
|
97
|
+
*
|
|
98
|
+
* Deliberately does **not** require a TTY: `poli dev` is a server meant
|
|
99
|
+
* to be composed into a user's own dev script (`concurrently`, `npm-run-all`,
|
|
100
|
+
* a Procfile), all of which pipe child stdout.
|
|
101
|
+
*/
|
|
102
|
+
export async function startDevSession(templateName, options = {}) {
|
|
103
|
+
const cwd = options.cwd ?? process.cwd();
|
|
104
|
+
const emit = (event) => options.onEvent?.(event);
|
|
105
|
+
// Resolves the manifest, the session token and the org — throws the
|
|
106
|
+
// familiar "not linked" / "not logged in" errors before anything is
|
|
107
|
+
// served, so a misconfigured project fails fast instead of booting a
|
|
108
|
+
// server that can never work.
|
|
109
|
+
const { client, ctx } = await resolveCloudContext({
|
|
110
|
+
cwd,
|
|
111
|
+
apiClient: options.apiClient,
|
|
112
|
+
homeDir: options.homeDir,
|
|
113
|
+
});
|
|
114
|
+
const initial = await loadProject(cwd);
|
|
115
|
+
let manifest = initial.manifest;
|
|
116
|
+
let templates = templateNamesOf(manifest);
|
|
117
|
+
// `projectSlug` is optional in the manifest schema (legacy links lack
|
|
118
|
+
// it) but every render payload needs it. Without this guard the
|
|
119
|
+
// server boots and then fails every render into the overlay forever —
|
|
120
|
+
// fail fast instead, with the same message (and exit code) as
|
|
121
|
+
// `poli preview`.
|
|
122
|
+
if (!manifest.cloud?.projectSlug) {
|
|
123
|
+
throw new Error("This folder isn't linked to a cloud project. Run `poli link` first.");
|
|
124
|
+
}
|
|
125
|
+
if (templateName !== undefined) {
|
|
126
|
+
// Fail fast on an unknown name given on the command line — same
|
|
127
|
+
// message (and exit code) as `poli render` / `poli preview`.
|
|
128
|
+
findTemplate(manifest, templateName);
|
|
129
|
+
}
|
|
130
|
+
const auth = await resolveAuth({
|
|
131
|
+
manifestOrgId: manifest.cloud?.orgId ?? ctx.orgId,
|
|
132
|
+
homeDir: options.homeDir,
|
|
133
|
+
});
|
|
134
|
+
const state = {
|
|
135
|
+
templates,
|
|
136
|
+
// The positional argument only chooses the *initial* view. It does
|
|
137
|
+
// not pin — the documented default stays "follow the most recently
|
|
138
|
+
// changed template" until the user clicks Pin.
|
|
139
|
+
activeTemplate: templateName ?? templates[0] ?? null,
|
|
140
|
+
pinned: false,
|
|
141
|
+
status: 'idle',
|
|
142
|
+
renderVersion: 0,
|
|
143
|
+
pageCount: 0,
|
|
144
|
+
error: null,
|
|
145
|
+
lastRenderedAt: null,
|
|
146
|
+
};
|
|
147
|
+
if (templates.length === 0) {
|
|
148
|
+
state.error = {
|
|
149
|
+
stage: 'project',
|
|
150
|
+
message: `No templates declared in poli-page.json. Add one with \`poli new <name>\`.`,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
let lastGoodHtml = null;
|
|
154
|
+
let renderSeq = 0;
|
|
155
|
+
let pdfSeq = 0;
|
|
156
|
+
const pdfCache = [];
|
|
157
|
+
let server = null;
|
|
158
|
+
let stopped = false;
|
|
159
|
+
// The last sync failure, until a sync succeeds: a render of the (stale)
|
|
160
|
+
// draft must not hide that the local files were not uploaded.
|
|
161
|
+
let syncError = null;
|
|
162
|
+
/** Set the moment `close()` is called — the session is shutting down. */
|
|
163
|
+
let closing = null;
|
|
164
|
+
/**
|
|
165
|
+
* The watcher batch currently being processed. `close()` awaits it so
|
|
166
|
+
* "resolves once the in-flight sync/render work has settled" is true
|
|
167
|
+
* even for a batch that was already past the `stopped` check.
|
|
168
|
+
*/
|
|
169
|
+
let inflightBatch = Promise.resolve();
|
|
170
|
+
function broadcast() {
|
|
171
|
+
// During shutdown the SSE responses are being ended — a batch
|
|
172
|
+
// still settling must not write into them.
|
|
173
|
+
if (closing)
|
|
174
|
+
return;
|
|
175
|
+
server?.broadcast('state', state);
|
|
176
|
+
}
|
|
177
|
+
function setStatus(next) {
|
|
178
|
+
state.status = next;
|
|
179
|
+
broadcast();
|
|
180
|
+
}
|
|
181
|
+
const syncer = createProjectSyncer({ cwd, client, ctx, signal: options.signal });
|
|
182
|
+
/**
|
|
183
|
+
* Re-read the manifest so templates added, renamed or removed during
|
|
184
|
+
* the session show up in the switcher. A broken manifest surfaces in
|
|
185
|
+
* the overlay and leaves the previous list in place.
|
|
186
|
+
*/
|
|
187
|
+
async function refreshManifest() {
|
|
188
|
+
try {
|
|
189
|
+
const loaded = await loadProject(cwd);
|
|
190
|
+
manifest = loaded.manifest;
|
|
191
|
+
templates = templateNamesOf(manifest);
|
|
192
|
+
state.templates = templates;
|
|
193
|
+
if (state.activeTemplate && !templates.includes(state.activeTemplate)) {
|
|
194
|
+
const gone = state.activeTemplate;
|
|
195
|
+
state.activeTemplate = templates[0] ?? null;
|
|
196
|
+
const message = state.activeTemplate
|
|
197
|
+
? `Template "${gone}" is gone from poli-page.json — switched to "${state.activeTemplate}".`
|
|
198
|
+
: `Template "${gone}" is gone from poli-page.json and none is left.`;
|
|
199
|
+
state.error = { stage: 'project', message };
|
|
200
|
+
emit({ type: 'error', message });
|
|
201
|
+
}
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
state.error = toDevError('project', err);
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async function resolveRenderInput(template) {
|
|
210
|
+
const entry = findTemplate(manifest, template);
|
|
211
|
+
const loaded = await loadTemplate(cwd, entry);
|
|
212
|
+
if (!options.data) {
|
|
213
|
+
return { entry, data: loaded.data, locale: loaded.locale };
|
|
214
|
+
}
|
|
215
|
+
// Re-read on every render so edits to the override file are picked
|
|
216
|
+
// up without restarting the server.
|
|
217
|
+
const dataPath = resolve(cwd, options.data);
|
|
218
|
+
const raw = JSON.parse(await readFile(dataPath, 'utf-8'));
|
|
219
|
+
const unwrapped = unwrapMockJson(raw);
|
|
220
|
+
return { entry, data: unwrapped.data, locale: unwrapped.locale };
|
|
221
|
+
}
|
|
222
|
+
function previewPayload(entry, data, locale) {
|
|
223
|
+
return {
|
|
224
|
+
project: manifest.cloud?.projectSlug,
|
|
225
|
+
template: entry.name,
|
|
226
|
+
version: 'draft',
|
|
227
|
+
data,
|
|
228
|
+
format: entry.format,
|
|
229
|
+
orientation: entry.orientation,
|
|
230
|
+
...(locale ? { locale } : {}),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
async function render() {
|
|
234
|
+
const template = state.activeTemplate;
|
|
235
|
+
if (!template) {
|
|
236
|
+
setStatus('idle');
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const seq = ++renderSeq;
|
|
240
|
+
setStatus('rendering');
|
|
241
|
+
emit({ type: 'rendering', template });
|
|
242
|
+
try {
|
|
243
|
+
const { entry, data, locale } = await resolveRenderInput(template);
|
|
244
|
+
const result = await client.renderPreview(auth.authorization, auth.orgIdHeader, previewPayload(entry, data, locale));
|
|
245
|
+
// A newer render was requested while this one was in flight —
|
|
246
|
+
// drop the stale result rather than flashing it on screen.
|
|
247
|
+
if (seq !== renderSeq)
|
|
248
|
+
return;
|
|
249
|
+
lastGoodHtml = result.html;
|
|
250
|
+
state.pageCount = result.totalPages;
|
|
251
|
+
state.renderVersion += 1;
|
|
252
|
+
state.lastRenderedAt = new Date().toISOString();
|
|
253
|
+
state.error = syncError;
|
|
254
|
+
emit({
|
|
255
|
+
type: 'rendered',
|
|
256
|
+
template,
|
|
257
|
+
message: `${result.totalPages} page${result.totalPages === 1 ? '' : 's'}`,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
if (seq !== renderSeq)
|
|
262
|
+
return;
|
|
263
|
+
// The last good render stays on screen behind the overlay.
|
|
264
|
+
state.error = toDevError('render', err);
|
|
265
|
+
emit({ type: 'error', template, message: state.error.message });
|
|
266
|
+
}
|
|
267
|
+
finally {
|
|
268
|
+
if (seq === renderSeq)
|
|
269
|
+
setStatus('idle');
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
async function renderPdf() {
|
|
273
|
+
const template = state.activeTemplate;
|
|
274
|
+
if (!template)
|
|
275
|
+
return { error: 'No template selected.' };
|
|
276
|
+
try {
|
|
277
|
+
const { entry, data, locale } = await resolveRenderInput(template);
|
|
278
|
+
const descriptor = await client.render(auth.authorization, auth.orgIdHeader, previewPayload(entry, data, locale));
|
|
279
|
+
const buffer = options.fetchPdf
|
|
280
|
+
? await options.fetchPdf(descriptor.presignedPdfUrl)
|
|
281
|
+
: await defaultFetchPdf(descriptor.presignedPdfUrl);
|
|
282
|
+
const id = ++pdfSeq;
|
|
283
|
+
pdfCache.push({ id, template, buffer });
|
|
284
|
+
while (pdfCache.length > PDF_CACHE_LIMIT)
|
|
285
|
+
pdfCache.shift();
|
|
286
|
+
state.error = syncError;
|
|
287
|
+
emit({ type: 'pdf', template, message: `${descriptor.pageCount} page(s)` });
|
|
288
|
+
broadcast();
|
|
289
|
+
return { url: `/pdf/${id}` };
|
|
290
|
+
}
|
|
291
|
+
catch (err) {
|
|
292
|
+
state.error = toDevError('pdf', err);
|
|
293
|
+
emit({ type: 'error', template, message: state.error.message });
|
|
294
|
+
broadcast();
|
|
295
|
+
return { error: state.error.message };
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async function onBatch() {
|
|
299
|
+
if (stopped || options.signal?.aborted)
|
|
300
|
+
return;
|
|
301
|
+
try {
|
|
302
|
+
setStatus('syncing');
|
|
303
|
+
emit({ type: 'syncing' });
|
|
304
|
+
const outcome = await syncer.sync();
|
|
305
|
+
syncError = null;
|
|
306
|
+
if (!(await refreshManifest())) {
|
|
307
|
+
setStatus('idle');
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (outcome.changed) {
|
|
311
|
+
emit({ type: 'synced', message: `${outcome.changedPaths.length} file(s)` });
|
|
312
|
+
if (!state.pinned) {
|
|
313
|
+
const target = await pickFollowTarget(cwd, outcome.changedPaths, templates);
|
|
314
|
+
if (target)
|
|
315
|
+
state.activeTemplate = target;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// Render on the sync-completed event — never on a timer. Even a
|
|
319
|
+
// "no changes" batch re-renders: the draft is known good and the
|
|
320
|
+
// user asked for feedback.
|
|
321
|
+
await render();
|
|
322
|
+
}
|
|
323
|
+
catch (err) {
|
|
324
|
+
if (options.signal?.aborted)
|
|
325
|
+
return;
|
|
326
|
+
syncError = state.error = toDevError('sync', err);
|
|
327
|
+
emit({ type: 'error', message: state.error.message });
|
|
328
|
+
setStatus('idle');
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
async function handleRequest(request) {
|
|
332
|
+
const { method, pathname, query, res } = request;
|
|
333
|
+
if (method === 'GET' && (pathname === '/' || pathname === '/index.html')) {
|
|
334
|
+
sendHtml(res, DEV_PAGE_HTML);
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (method === 'GET' && pathname === '/preview') {
|
|
338
|
+
sendHtml(res, lastGoodHtml ?? DEV_PLACEHOLDER_HTML);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (method === 'GET' && pathname === '/state') {
|
|
342
|
+
sendJson(res, 200, state);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (method === 'POST' && pathname === '/api/select') {
|
|
346
|
+
const requested = query.get('template');
|
|
347
|
+
if (!requested || !templates.includes(requested)) {
|
|
348
|
+
state.error = {
|
|
349
|
+
stage: 'project',
|
|
350
|
+
message: `Template "${requested ?? ''}" is not in poli-page.json.`,
|
|
351
|
+
};
|
|
352
|
+
sendJson(res, 404, state);
|
|
353
|
+
broadcast();
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (requested !== state.activeTemplate) {
|
|
357
|
+
state.activeTemplate = requested;
|
|
358
|
+
state.error = syncError;
|
|
359
|
+
sendJson(res, 200, state);
|
|
360
|
+
broadcast();
|
|
361
|
+
await render();
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
sendJson(res, 200, state);
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
if (method === 'POST' && pathname === '/api/pin') {
|
|
368
|
+
state.pinned = query.get('value') !== 'false';
|
|
369
|
+
sendJson(res, 200, state);
|
|
370
|
+
broadcast();
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (method === 'POST' && pathname === '/api/pdf') {
|
|
374
|
+
const result = await renderPdf();
|
|
375
|
+
sendJson(res, 'error' in result ? 502 : 200, result);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (method === 'GET' && pathname.startsWith('/pdf/')) {
|
|
379
|
+
const id = Number.parseInt(pathname.slice('/pdf/'.length), 10);
|
|
380
|
+
const entry = pdfCache.find((candidate) => candidate.id === id);
|
|
381
|
+
if (!entry) {
|
|
382
|
+
sendJson(res, 404, { error: 'That PDF is no longer cached — render it again.' });
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
res.writeHead(200, {
|
|
386
|
+
'Content-Type': 'application/pdf',
|
|
387
|
+
'Content-Length': String(entry.buffer.byteLength),
|
|
388
|
+
'Content-Disposition': `inline; filename="${encodeURIComponent(entry.template)}.pdf"`,
|
|
389
|
+
'Cache-Control': 'no-store',
|
|
390
|
+
});
|
|
391
|
+
res.end(entry.buffer);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
sendJson(res, 404, { error: `No route for ${method} ${pathname}` });
|
|
395
|
+
}
|
|
396
|
+
// The server comes up before the first render so the URL is printable
|
|
397
|
+
// (and the browser openable) immediately: the page shows its
|
|
398
|
+
// placeholder and follows the first sync/render live over SSE.
|
|
399
|
+
server = await startDevServer({
|
|
400
|
+
port: options.port ?? DEFAULT_DEV_PORT,
|
|
401
|
+
maxPortAttempts: options.maxPortAttempts,
|
|
402
|
+
handleRequest,
|
|
403
|
+
});
|
|
404
|
+
emit({
|
|
405
|
+
type: 'ready',
|
|
406
|
+
message: server.url,
|
|
407
|
+
...(state.activeTemplate ? { template: state.activeTemplate } : {}),
|
|
408
|
+
});
|
|
409
|
+
if (options.open !== false) {
|
|
410
|
+
const opener = options.openFn ?? defaultOpen;
|
|
411
|
+
try {
|
|
412
|
+
await opener(server.url);
|
|
413
|
+
}
|
|
414
|
+
catch {
|
|
415
|
+
// No browser available (headless box, container, CI) — the URL
|
|
416
|
+
// is already printed, so this is not worth failing over.
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
// Snapshot the tree, then push all of it so the cloud draft matches
|
|
420
|
+
// the working copy before the very first render. Without it, run #1
|
|
421
|
+
// would render whatever the draft happened to contain.
|
|
422
|
+
await syncer.prime();
|
|
423
|
+
try {
|
|
424
|
+
setStatus('syncing');
|
|
425
|
+
emit({ type: 'syncing' });
|
|
426
|
+
await syncer.syncAll();
|
|
427
|
+
}
|
|
428
|
+
catch (err) {
|
|
429
|
+
syncError = state.error = toDevError('sync', err);
|
|
430
|
+
emit({ type: 'error', message: state.error.message });
|
|
431
|
+
}
|
|
432
|
+
state.status = 'idle';
|
|
433
|
+
if (!stopped) {
|
|
434
|
+
await render();
|
|
435
|
+
}
|
|
436
|
+
// Only now start watching: a batch arriving mid-bootstrap would race
|
|
437
|
+
// the initial full sync.
|
|
438
|
+
const watcher = (options.watcherFactory ?? createFileWatcher)({
|
|
439
|
+
cwd,
|
|
440
|
+
debounceMs: options.debounceMs ?? DEFAULT_DEBOUNCE_MS,
|
|
441
|
+
onBatch: () => {
|
|
442
|
+
// Chained rather than fire-and-forget so `close()` can await
|
|
443
|
+
// the batch already in flight. `onBatch` handles its own
|
|
444
|
+
// failures; the catch only keeps a surprise rejection from
|
|
445
|
+
// wedging the chain (and with it, `close()`).
|
|
446
|
+
inflightBatch = inflightBatch.then(onBatch).catch(() => { });
|
|
447
|
+
},
|
|
448
|
+
});
|
|
449
|
+
const close = async () => {
|
|
450
|
+
if (closing)
|
|
451
|
+
return closing;
|
|
452
|
+
stopped = true;
|
|
453
|
+
closing = (async () => {
|
|
454
|
+
// No new batches once the watcher is down…
|
|
455
|
+
await watcher.close();
|
|
456
|
+
// …and the one already past the `stopped` check finishes
|
|
457
|
+
// before the SSE responses and the port go away.
|
|
458
|
+
await inflightBatch;
|
|
459
|
+
await server?.close();
|
|
460
|
+
emit({ type: 'stopped' });
|
|
461
|
+
})();
|
|
462
|
+
return closing;
|
|
463
|
+
};
|
|
464
|
+
if (options.signal) {
|
|
465
|
+
if (options.signal.aborted) {
|
|
466
|
+
await close();
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
options.signal.addEventListener('abort', () => void close(), { once: true });
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return {
|
|
473
|
+
url: server.url,
|
|
474
|
+
port: server.port,
|
|
475
|
+
getState: () => ({ ...state, templates: [...state.templates] }),
|
|
476
|
+
close,
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
/** Start the session and stay up until the abort signal fires. */
|
|
480
|
+
export async function executeDev(templateName, options = {}) {
|
|
481
|
+
const session = await startDevSession(templateName, options);
|
|
482
|
+
await new Promise((done) => {
|
|
483
|
+
// No signal → the server runs until the process itself is killed.
|
|
484
|
+
// The CLI action always supplies one (SIGINT / SIGTERM).
|
|
485
|
+
if (!options.signal)
|
|
486
|
+
return;
|
|
487
|
+
if (options.signal.aborted) {
|
|
488
|
+
done();
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
options.signal.addEventListener('abort', () => done(), { once: true });
|
|
492
|
+
});
|
|
493
|
+
await session.close();
|
|
494
|
+
}
|
|
495
|
+
function templateNamesOf(manifest) {
|
|
496
|
+
return (manifest.templates ?? []).map((entry) => entry.name);
|
|
497
|
+
}
|
|
498
|
+
function sendHtml(res, html) {
|
|
499
|
+
res.writeHead(200, {
|
|
500
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
501
|
+
'Cache-Control': 'no-store',
|
|
502
|
+
});
|
|
503
|
+
res.end(html);
|
|
504
|
+
}
|
|
505
|
+
function sendJson(res, status, payload) {
|
|
506
|
+
res.writeHead(status, {
|
|
507
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
508
|
+
'Cache-Control': 'no-store',
|
|
509
|
+
});
|
|
510
|
+
res.end(JSON.stringify(payload));
|
|
511
|
+
}
|
|
512
|
+
async function defaultOpen(url) {
|
|
513
|
+
const open = await import('open');
|
|
514
|
+
return open.default(url);
|
|
515
|
+
}
|
|
516
|
+
async function defaultFetchPdf(url) {
|
|
517
|
+
const response = await fetch(url);
|
|
518
|
+
if (!response.ok) {
|
|
519
|
+
throw new Error(`Failed to download PDF from presigned URL (HTTP ${response.status}).`);
|
|
520
|
+
}
|
|
521
|
+
return Buffer.from(await response.arrayBuffer());
|
|
522
|
+
}
|
|
523
|
+
export function parsePort(raw) {
|
|
524
|
+
const port = Number.parseInt(raw, 10);
|
|
525
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
526
|
+
const error = new Error(`Invalid --port "${raw}": expected an integer between 1 and 65535.`);
|
|
527
|
+
Object.assign(error, { exitCode: 2 });
|
|
528
|
+
throw error;
|
|
529
|
+
}
|
|
530
|
+
return port;
|
|
531
|
+
}
|
|
532
|
+
export function registerDevCommand(program) {
|
|
533
|
+
program
|
|
534
|
+
.command('dev')
|
|
535
|
+
.description('Serve a live-reloading preview of a template: sync on save, re-render, push to the browser')
|
|
536
|
+
.argument('[template]', 'Template to show first (defaults to the first in the manifest)')
|
|
537
|
+
.option('-p, --port <n>', `Port to listen on (default: ${DEFAULT_DEV_PORT})`)
|
|
538
|
+
.option('-d, --data <path>', 'JSON data file (overrides the template mock)')
|
|
539
|
+
.option('--no-open', 'Do not open the browser on start')
|
|
540
|
+
.action(async (template, opts) => {
|
|
541
|
+
const { default: chalk } = await import('chalk');
|
|
542
|
+
const controller = new AbortController();
|
|
543
|
+
const stop = () => controller.abort();
|
|
544
|
+
process.on('SIGINT', stop);
|
|
545
|
+
process.on('SIGTERM', stop);
|
|
546
|
+
try {
|
|
547
|
+
await executeDev(template, {
|
|
548
|
+
signal: controller.signal,
|
|
549
|
+
port: opts.port ? parsePort(opts.port) : undefined,
|
|
550
|
+
data: opts.data,
|
|
551
|
+
open: opts.open !== false,
|
|
552
|
+
// Line-oriented, never carriage-return overwrites: the
|
|
553
|
+
// output has to stay readable when piped through
|
|
554
|
+
// `concurrently` or captured in a log file.
|
|
555
|
+
onEvent: (event) => {
|
|
556
|
+
const ts = new Date().toLocaleTimeString();
|
|
557
|
+
switch (event.type) {
|
|
558
|
+
case 'ready':
|
|
559
|
+
console.log(chalk.cyan(`▸ poli dev — ${event.message ?? ''}`) +
|
|
560
|
+
(event.template ? chalk.dim(` (${event.template})`) : ''));
|
|
561
|
+
console.log(chalk.dim(' Save a file to re-render. Ctrl-C to stop.'));
|
|
562
|
+
break;
|
|
563
|
+
case 'syncing':
|
|
564
|
+
console.log(chalk.dim(`[${ts}] syncing...`));
|
|
565
|
+
break;
|
|
566
|
+
case 'rendered':
|
|
567
|
+
console.log(chalk.green(`[${ts}] ✓ rendered ${event.template ?? ''}${event.message ? ` — ${event.message}` : ''}`));
|
|
568
|
+
break;
|
|
569
|
+
case 'pdf':
|
|
570
|
+
console.log(chalk.green(`[${ts}] ✓ PDF ready for ${event.template ?? ''}${event.message ? ` — ${event.message}` : ''}`));
|
|
571
|
+
break;
|
|
572
|
+
case 'error':
|
|
573
|
+
console.error(chalk.red(`[${ts}] ✗ ${event.message ?? 'error'}`));
|
|
574
|
+
break;
|
|
575
|
+
case 'stopped':
|
|
576
|
+
console.log(chalk.dim('Dev server stopped.'));
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
catch (err) {
|
|
583
|
+
const message = err instanceof Error ? err.message : 'Dev server failed';
|
|
584
|
+
console.error(chalk.red(message));
|
|
585
|
+
process.exitCode = errorToExitCode(err);
|
|
586
|
+
}
|
|
587
|
+
finally {
|
|
588
|
+
process.removeListener('SIGINT', stop);
|
|
589
|
+
process.removeListener('SIGTERM', stop);
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAA6C,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACN,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,GAEd,MAAM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