@riddledc/riddle-proof 0.8.36 → 0.8.37
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/advanced/index.d.cts +1 -1
- package/dist/advanced/index.d.ts +1 -1
- package/dist/advanced/proof-run-engine.d.cts +1 -1
- package/dist/advanced/proof-run-engine.d.ts +1 -1
- package/dist/{chunk-TWTEUS7R.js → chunk-DI2XNGEZ.js} +126 -1
- package/dist/{chunk-E25K5PDM.js → chunk-F4HKK2YH.js} +34 -3
- package/dist/cli/index.js +2 -2
- package/dist/cli.cjs +159 -3
- package/dist/cli.js +2 -2
- package/dist/index.cjs +126 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{proof-run-engine-DYUu2mqY.d.cts → proof-run-engine-4dM37pEx.d.cts} +3 -3
- package/dist/{proof-run-engine-BmNYuOJ7.d.ts → proof-run-engine-BqaeqAze.d.ts} +3 -3
- package/dist/proof-run-engine.d.cts +1 -1
- package/dist/proof-run-engine.d.ts +1 -1
- package/dist/riddle-client.cjs +126 -1
- package/dist/riddle-client.d.cts +21 -1
- package/dist/riddle-client.d.ts +21 -1
- package/dist/riddle-client.js +1 -1
- package/dist/runtime/index.cjs +126 -1
- package/dist/runtime/index.d.cts +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/riddle-client.cjs +126 -1
- package/dist/runtime/riddle-client.d.cts +1 -1
- package/dist/runtime/riddle-client.d.ts +1 -1
- package/dist/runtime/riddle-client.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { b as runner } from '../runner-4LJ5z0D-.cjs';
|
|
2
2
|
export { l as engineHarness } from '../engine-harness-LBfqbFSe.cjs';
|
|
3
3
|
export { p as proofRunCore } from '../proof-run-core-B1GeqkR8.cjs';
|
|
4
|
-
export { p as proofRunEngine } from '../proof-run-engine-
|
|
4
|
+
export { p as proofRunEngine } from '../proof-run-engine-4dM37pEx.cjs';
|
|
5
5
|
import '../types.cjs';
|
package/dist/advanced/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { b as runner } from '../runner-BdQpOkZD.js';
|
|
2
2
|
export { l as engineHarness } from '../engine-harness-CMACHP6A.js';
|
|
3
3
|
export { p as proofRunCore } from '../proof-run-core-B1GeqkR8.js';
|
|
4
|
-
export { p as proofRunEngine } from '../proof-run-engine-
|
|
4
|
+
export { p as proofRunEngine } from '../proof-run-engine-BqaeqAze.js';
|
|
5
5
|
import '../types.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from '../proof-run-engine-
|
|
1
|
+
export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from '../proof-run-engine-4dM37pEx.cjs';
|
|
2
2
|
import '../proof-run-core-B1GeqkR8.cjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from '../proof-run-engine-
|
|
1
|
+
export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from '../proof-run-engine-BqaeqAze.js';
|
|
2
2
|
import '../proof-run-core-B1GeqkR8.js';
|
|
@@ -81,10 +81,68 @@ function previewDeployResultFromRecord(input) {
|
|
|
81
81
|
function canRecoverPreviewPublish(error) {
|
|
82
82
|
return error instanceof RiddleApiError && PREVIEW_PUBLISH_RECOVERY_STATUSES.has(error.status);
|
|
83
83
|
}
|
|
84
|
+
function summarizePreviewDirectory(directory) {
|
|
85
|
+
const stack = [directory];
|
|
86
|
+
let fileCount = 0;
|
|
87
|
+
let totalBytes = 0;
|
|
88
|
+
while (stack.length) {
|
|
89
|
+
const current = stack.pop();
|
|
90
|
+
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
91
|
+
const fullPath = path.join(current, entry.name);
|
|
92
|
+
if (entry.isDirectory()) {
|
|
93
|
+
stack.push(fullPath);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (!entry.isFile()) continue;
|
|
97
|
+
const stat = statSync(fullPath);
|
|
98
|
+
fileCount += 1;
|
|
99
|
+
totalBytes += stat.size;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return { file_count: fileCount, total_bytes: totalBytes };
|
|
103
|
+
}
|
|
104
|
+
function previewProgressEmitter(config, base) {
|
|
105
|
+
return async (snapshot) => {
|
|
106
|
+
if (!config.onPreviewProgress) return;
|
|
107
|
+
await config.onPreviewProgress({
|
|
108
|
+
label: base.label,
|
|
109
|
+
framework: base.framework,
|
|
110
|
+
directory: base.directory,
|
|
111
|
+
elapsed_ms: Math.max(0, Date.now() - base.startedAt),
|
|
112
|
+
warnings: base.warnings?.length ? base.warnings : void 0,
|
|
113
|
+
...snapshot
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
}
|
|
84
117
|
async function waitForPublishedPreview(config, input) {
|
|
118
|
+
await input.emitProgress?.({
|
|
119
|
+
stage: "publish_recovering",
|
|
120
|
+
id: input.id,
|
|
121
|
+
file_count: input.localSummary?.file_count,
|
|
122
|
+
total_bytes: input.localSummary?.total_bytes,
|
|
123
|
+
publish_error: input.publishError.message,
|
|
124
|
+
message: `publish returned ${input.publishError.status}; polling preview status`
|
|
125
|
+
});
|
|
85
126
|
for (let attempt = 1; attempt <= PREVIEW_PUBLISH_RECOVERY_ATTEMPTS; attempt += 1) {
|
|
86
127
|
const status = await riddleRequestJson(config, `/v1/preview/${input.id}`);
|
|
128
|
+
await input.emitProgress?.({
|
|
129
|
+
stage: "checking_status",
|
|
130
|
+
id: input.id,
|
|
131
|
+
attempt,
|
|
132
|
+
attempts: PREVIEW_PUBLISH_RECOVERY_ATTEMPTS,
|
|
133
|
+
status: typeof status.status === "string" ? status.status : null,
|
|
134
|
+
preview_url: typeof status.preview_url === "string" ? status.preview_url : void 0,
|
|
135
|
+
file_count: typeof status.file_count === "number" ? status.file_count : input.localSummary?.file_count,
|
|
136
|
+
total_bytes: typeof status.total_bytes === "number" ? status.total_bytes : input.localSummary?.total_bytes
|
|
137
|
+
});
|
|
87
138
|
if (String(status.status || "") === "ready" && String(status.preview_url || "").trim()) {
|
|
139
|
+
await input.emitProgress?.({
|
|
140
|
+
stage: "ready",
|
|
141
|
+
id: input.id,
|
|
142
|
+
preview_url: String(status.preview_url),
|
|
143
|
+
file_count: typeof status.file_count === "number" ? status.file_count : input.localSummary?.file_count,
|
|
144
|
+
total_bytes: typeof status.total_bytes === "number" ? status.total_bytes : input.localSummary?.total_bytes
|
|
145
|
+
});
|
|
88
146
|
return previewDeployResultFromRecord({
|
|
89
147
|
record: status,
|
|
90
148
|
id: input.id,
|
|
@@ -106,7 +164,17 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
106
164
|
if (!directory?.trim()) throw new Error("directory is required");
|
|
107
165
|
if (!label?.trim()) throw new Error("label is required");
|
|
108
166
|
if (framework !== "spa" && framework !== "static") throw new Error("framework must be spa or static");
|
|
167
|
+
const startedAt = Date.now();
|
|
109
168
|
const warnings = collectRiddlePreviewDeployWarnings(directory, framework);
|
|
169
|
+
const emitProgress = previewProgressEmitter(config, { label, framework, directory, startedAt, warnings });
|
|
170
|
+
await emitProgress({ stage: "validating", message: "checking preview input directory" });
|
|
171
|
+
const localSummary = summarizePreviewDirectory(directory);
|
|
172
|
+
await emitProgress({
|
|
173
|
+
stage: "creating",
|
|
174
|
+
file_count: localSummary.file_count,
|
|
175
|
+
total_bytes: localSummary.total_bytes,
|
|
176
|
+
message: "creating preview upload target"
|
|
177
|
+
});
|
|
110
178
|
const created = await riddleRequestJson(config, "/v1/preview", {
|
|
111
179
|
method: "POST",
|
|
112
180
|
body: JSON.stringify({ framework, label })
|
|
@@ -114,10 +182,42 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
114
182
|
const id = String(created.id || "");
|
|
115
183
|
const uploadUrl = String(created.upload_url || "");
|
|
116
184
|
if (!id || !uploadUrl) throw new Error("Riddle preview create response was missing id or upload_url.");
|
|
185
|
+
await emitProgress({
|
|
186
|
+
stage: "created",
|
|
187
|
+
id,
|
|
188
|
+
file_count: localSummary.file_count,
|
|
189
|
+
total_bytes: localSummary.total_bytes,
|
|
190
|
+
message: "preview upload target created"
|
|
191
|
+
});
|
|
117
192
|
const scratch = mkdtempSync(path.join(tmpdir(), "riddle-preview-upload-"));
|
|
118
193
|
const tarball = path.join(scratch, `${id}.tar.gz`);
|
|
194
|
+
let tarballBytes = 0;
|
|
119
195
|
try {
|
|
196
|
+
await emitProgress({
|
|
197
|
+
stage: "archiving",
|
|
198
|
+
id,
|
|
199
|
+
file_count: localSummary.file_count,
|
|
200
|
+
total_bytes: localSummary.total_bytes,
|
|
201
|
+
message: "creating preview archive"
|
|
202
|
+
});
|
|
120
203
|
execFileSync("tar", ["czf", tarball, "-C", directory, "."], { stdio: "pipe" });
|
|
204
|
+
tarballBytes = statSync(tarball).size;
|
|
205
|
+
await emitProgress({
|
|
206
|
+
stage: "archived",
|
|
207
|
+
id,
|
|
208
|
+
file_count: localSummary.file_count,
|
|
209
|
+
total_bytes: localSummary.total_bytes,
|
|
210
|
+
tarball_bytes: tarballBytes,
|
|
211
|
+
message: "preview archive created"
|
|
212
|
+
});
|
|
213
|
+
await emitProgress({
|
|
214
|
+
stage: "uploading",
|
|
215
|
+
id,
|
|
216
|
+
file_count: localSummary.file_count,
|
|
217
|
+
total_bytes: localSummary.total_bytes,
|
|
218
|
+
tarball_bytes: tarballBytes,
|
|
219
|
+
message: "uploading preview archive"
|
|
220
|
+
});
|
|
121
221
|
const upload = await fetchFor(config)(uploadUrl, {
|
|
122
222
|
method: "PUT",
|
|
123
223
|
headers: { "Content-Type": "application/gzip" },
|
|
@@ -126,14 +226,37 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
126
226
|
if (!upload.ok) {
|
|
127
227
|
throw new RiddleApiError(uploadUrl, upload.status, await upload.text());
|
|
128
228
|
}
|
|
229
|
+
await emitProgress({
|
|
230
|
+
stage: "uploaded",
|
|
231
|
+
id,
|
|
232
|
+
file_count: localSummary.file_count,
|
|
233
|
+
total_bytes: localSummary.total_bytes,
|
|
234
|
+
tarball_bytes: tarballBytes,
|
|
235
|
+
message: "preview archive uploaded"
|
|
236
|
+
});
|
|
129
237
|
} finally {
|
|
130
238
|
rmSync(scratch, { recursive: true, force: true });
|
|
131
239
|
}
|
|
132
240
|
const expiresAt = typeof created.expires_at === "string" ? created.expires_at : void 0;
|
|
133
241
|
try {
|
|
242
|
+
await emitProgress({
|
|
243
|
+
stage: "publishing",
|
|
244
|
+
id,
|
|
245
|
+
file_count: localSummary.file_count,
|
|
246
|
+
total_bytes: localSummary.total_bytes,
|
|
247
|
+
tarball_bytes: tarballBytes || void 0,
|
|
248
|
+
message: "publishing preview"
|
|
249
|
+
});
|
|
134
250
|
const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
|
|
135
251
|
method: "POST"
|
|
136
252
|
});
|
|
253
|
+
await emitProgress({
|
|
254
|
+
stage: "ready",
|
|
255
|
+
id,
|
|
256
|
+
preview_url: String(published.preview_url || ""),
|
|
257
|
+
file_count: typeof published.file_count === "number" ? published.file_count : localSummary.file_count,
|
|
258
|
+
total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : localSummary.total_bytes
|
|
259
|
+
});
|
|
137
260
|
return previewDeployResultFromRecord({ record: published, id, label, framework, expiresAt, warnings });
|
|
138
261
|
} catch (error) {
|
|
139
262
|
if (!canRecoverPreviewPublish(error)) throw error;
|
|
@@ -143,7 +266,9 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
143
266
|
framework,
|
|
144
267
|
expiresAt,
|
|
145
268
|
publishError: error,
|
|
146
|
-
warnings
|
|
269
|
+
warnings,
|
|
270
|
+
localSummary,
|
|
271
|
+
emitProgress
|
|
147
272
|
});
|
|
148
273
|
}
|
|
149
274
|
}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
createRiddleApiClient,
|
|
18
18
|
isTerminalRiddleJobStatus,
|
|
19
19
|
parseRiddleViewport
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-DI2XNGEZ.js";
|
|
21
21
|
import {
|
|
22
22
|
createDisabledRiddleProofAgentAdapter,
|
|
23
23
|
readRiddleProofRunStatus,
|
|
@@ -140,7 +140,7 @@ function usage() {
|
|
|
140
140
|
" riddle-proof-loop regression-pack run [--pack oc-flow-regression|--pack-file <file>] [--local-core true|false; default true] [--hosted-riddle true|false; default false] [--format json|markdown|compact-json; default json] [--output <dir>|--output-dir <dir>]",
|
|
141
141
|
" riddle-proof-loop profile-body-assertions --artifact <file|url|-> --candidates-json <file|json|-> [--required-json <file|json|->] [--format json|body-contains]",
|
|
142
142
|
" riddle-proof-loop profile-http-status-preflight --profile <file|json|-> --url <base-url> [--format json|summary]",
|
|
143
|
-
" riddle-proof-loop riddle-preview-deploy <build-dir> <label> [--framework spa|static]",
|
|
143
|
+
" riddle-proof-loop riddle-preview-deploy <build-dir> <label> [--framework spa|static] [--quiet]",
|
|
144
144
|
" riddle-proof-loop riddle-server-preview <directory> --script-file <file> [--path /route] [--wait-for-selector selector]",
|
|
145
145
|
" riddle-proof-loop riddle-run-script --url <url> --script-file <file> [--viewport 1280x720] [--strict true|false]",
|
|
146
146
|
" riddle-proof-loop riddle-poll <job-id> [--wait] [--attempts n] [--quiet]",
|
|
@@ -909,6 +909,18 @@ function formatPollDuration(ms) {
|
|
|
909
909
|
const remainder = seconds % 60;
|
|
910
910
|
return minutes > 0 ? `${minutes}m${String(remainder).padStart(2, "0")}s` : `${seconds}s`;
|
|
911
911
|
}
|
|
912
|
+
function formatByteCount(bytes) {
|
|
913
|
+
if (typeof bytes !== "number" || !Number.isFinite(bytes)) return "n/a";
|
|
914
|
+
if (bytes < 1024) return `${bytes}B`;
|
|
915
|
+
const units = ["KB", "MB", "GB", "TB"];
|
|
916
|
+
let value = bytes / 1024;
|
|
917
|
+
let unitIndex = 0;
|
|
918
|
+
while (value >= 1024 && unitIndex < units.length - 1) {
|
|
919
|
+
value /= 1024;
|
|
920
|
+
unitIndex += 1;
|
|
921
|
+
}
|
|
922
|
+
return `${value >= 10 ? value.toFixed(0) : value.toFixed(1)}${units[unitIndex]}`;
|
|
923
|
+
}
|
|
912
924
|
function riddlePollProgressLine(snapshot) {
|
|
913
925
|
const submittedAt = snapshot.submitted_at || "not-submitted";
|
|
914
926
|
const queuePart = snapshot.running_without_submission ? ` waiting_for_submit=${formatPollDuration(snapshot.pre_submission_elapsed_ms)}${snapshot.queue_elapsed_ms !== null ? ` queued_for=${formatPollDuration(snapshot.queue_elapsed_ms)}` : ""}` : snapshot.queue_elapsed_ms !== null ? ` queue=${formatPollDuration(snapshot.queue_elapsed_ms)}` : "";
|
|
@@ -922,6 +934,18 @@ function riddlePollProgressLine(snapshot) {
|
|
|
922
934
|
`submitted_at=${submittedAt}${queuePart}${terminalPart}`
|
|
923
935
|
].join(" ");
|
|
924
936
|
}
|
|
937
|
+
function riddlePreviewProgressLine(snapshot) {
|
|
938
|
+
const idPart = snapshot.id ? ` id=${snapshot.id}` : "";
|
|
939
|
+
const statusPart = snapshot.status ? ` status=${snapshot.status}` : "";
|
|
940
|
+
const attemptPart = snapshot.attempt && snapshot.attempts ? ` attempt=${snapshot.attempt}/${snapshot.attempts}` : "";
|
|
941
|
+
const previewPart = snapshot.preview_url ? ` url=${snapshot.preview_url}` : "";
|
|
942
|
+
const filePart = typeof snapshot.file_count === "number" ? ` files=${snapshot.file_count}` : "";
|
|
943
|
+
const totalPart = typeof snapshot.total_bytes === "number" ? ` bytes=${formatByteCount(snapshot.total_bytes)}` : "";
|
|
944
|
+
const archivePart = typeof snapshot.tarball_bytes === "number" ? ` archive=${formatByteCount(snapshot.tarball_bytes)}` : "";
|
|
945
|
+
const recoveryPart = snapshot.publish_error ? ` publish_error=${JSON.stringify(snapshot.publish_error)}` : "";
|
|
946
|
+
const messagePart = snapshot.message ? ` ${snapshot.message}` : "";
|
|
947
|
+
return `[riddle-preview] ${snapshot.stage}${idPart}${statusPart}${attemptPart} elapsed=${formatPollDuration(snapshot.elapsed_ms)} label=${snapshot.label} framework=${snapshot.framework}${filePart}${totalPart}${archivePart}${previewPart}${recoveryPart}${messagePart}`;
|
|
948
|
+
}
|
|
925
949
|
function readJsonValue(value, label) {
|
|
926
950
|
if (!value) throw new Error(`${label} is required.`);
|
|
927
951
|
const raw = value === "-" ? readStdin() : existsSync(value) ? readFileSync(value, "utf-8") : value;
|
|
@@ -4597,7 +4621,14 @@ async function main() {
|
|
|
4597
4621
|
if (command === "riddle-preview-deploy") {
|
|
4598
4622
|
const buildDir = positional[1];
|
|
4599
4623
|
const label = positional[2];
|
|
4600
|
-
const
|
|
4624
|
+
const clientConfig = riddleClientConfig(options);
|
|
4625
|
+
if (options.quiet !== true) {
|
|
4626
|
+
clientConfig.onPreviewProgress = (snapshot) => {
|
|
4627
|
+
process.stderr.write(`${riddlePreviewProgressLine(snapshot)}
|
|
4628
|
+
`);
|
|
4629
|
+
};
|
|
4630
|
+
}
|
|
4631
|
+
const result = await createRiddleApiClient(clientConfig).deployPreview(buildDir, label, previewFrameworkOption(options));
|
|
4601
4632
|
for (const warning of result.warnings ?? []) {
|
|
4602
4633
|
process.stderr.write(`Warning: ${warning}
|
|
4603
4634
|
`);
|
package/dist/cli/index.js
CHANGED
package/dist/cli.cjs
CHANGED
|
@@ -7438,10 +7438,68 @@ function previewDeployResultFromRecord(input) {
|
|
|
7438
7438
|
function canRecoverPreviewPublish(error) {
|
|
7439
7439
|
return error instanceof RiddleApiError && PREVIEW_PUBLISH_RECOVERY_STATUSES.has(error.status);
|
|
7440
7440
|
}
|
|
7441
|
+
function summarizePreviewDirectory(directory) {
|
|
7442
|
+
const stack = [directory];
|
|
7443
|
+
let fileCount = 0;
|
|
7444
|
+
let totalBytes = 0;
|
|
7445
|
+
while (stack.length) {
|
|
7446
|
+
const current = stack.pop();
|
|
7447
|
+
for (const entry of (0, import_node_fs5.readdirSync)(current, { withFileTypes: true })) {
|
|
7448
|
+
const fullPath = import_node_path5.default.join(current, entry.name);
|
|
7449
|
+
if (entry.isDirectory()) {
|
|
7450
|
+
stack.push(fullPath);
|
|
7451
|
+
continue;
|
|
7452
|
+
}
|
|
7453
|
+
if (!entry.isFile()) continue;
|
|
7454
|
+
const stat = (0, import_node_fs5.statSync)(fullPath);
|
|
7455
|
+
fileCount += 1;
|
|
7456
|
+
totalBytes += stat.size;
|
|
7457
|
+
}
|
|
7458
|
+
}
|
|
7459
|
+
return { file_count: fileCount, total_bytes: totalBytes };
|
|
7460
|
+
}
|
|
7461
|
+
function previewProgressEmitter(config, base) {
|
|
7462
|
+
return async (snapshot) => {
|
|
7463
|
+
if (!config.onPreviewProgress) return;
|
|
7464
|
+
await config.onPreviewProgress({
|
|
7465
|
+
label: base.label,
|
|
7466
|
+
framework: base.framework,
|
|
7467
|
+
directory: base.directory,
|
|
7468
|
+
elapsed_ms: Math.max(0, Date.now() - base.startedAt),
|
|
7469
|
+
warnings: base.warnings?.length ? base.warnings : void 0,
|
|
7470
|
+
...snapshot
|
|
7471
|
+
});
|
|
7472
|
+
};
|
|
7473
|
+
}
|
|
7441
7474
|
async function waitForPublishedPreview(config, input) {
|
|
7475
|
+
await input.emitProgress?.({
|
|
7476
|
+
stage: "publish_recovering",
|
|
7477
|
+
id: input.id,
|
|
7478
|
+
file_count: input.localSummary?.file_count,
|
|
7479
|
+
total_bytes: input.localSummary?.total_bytes,
|
|
7480
|
+
publish_error: input.publishError.message,
|
|
7481
|
+
message: `publish returned ${input.publishError.status}; polling preview status`
|
|
7482
|
+
});
|
|
7442
7483
|
for (let attempt = 1; attempt <= PREVIEW_PUBLISH_RECOVERY_ATTEMPTS; attempt += 1) {
|
|
7443
7484
|
const status = await riddleRequestJson(config, `/v1/preview/${input.id}`);
|
|
7485
|
+
await input.emitProgress?.({
|
|
7486
|
+
stage: "checking_status",
|
|
7487
|
+
id: input.id,
|
|
7488
|
+
attempt,
|
|
7489
|
+
attempts: PREVIEW_PUBLISH_RECOVERY_ATTEMPTS,
|
|
7490
|
+
status: typeof status.status === "string" ? status.status : null,
|
|
7491
|
+
preview_url: typeof status.preview_url === "string" ? status.preview_url : void 0,
|
|
7492
|
+
file_count: typeof status.file_count === "number" ? status.file_count : input.localSummary?.file_count,
|
|
7493
|
+
total_bytes: typeof status.total_bytes === "number" ? status.total_bytes : input.localSummary?.total_bytes
|
|
7494
|
+
});
|
|
7444
7495
|
if (String(status.status || "") === "ready" && String(status.preview_url || "").trim()) {
|
|
7496
|
+
await input.emitProgress?.({
|
|
7497
|
+
stage: "ready",
|
|
7498
|
+
id: input.id,
|
|
7499
|
+
preview_url: String(status.preview_url),
|
|
7500
|
+
file_count: typeof status.file_count === "number" ? status.file_count : input.localSummary?.file_count,
|
|
7501
|
+
total_bytes: typeof status.total_bytes === "number" ? status.total_bytes : input.localSummary?.total_bytes
|
|
7502
|
+
});
|
|
7445
7503
|
return previewDeployResultFromRecord({
|
|
7446
7504
|
record: status,
|
|
7447
7505
|
id: input.id,
|
|
@@ -7463,7 +7521,17 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
7463
7521
|
if (!directory?.trim()) throw new Error("directory is required");
|
|
7464
7522
|
if (!label?.trim()) throw new Error("label is required");
|
|
7465
7523
|
if (framework !== "spa" && framework !== "static") throw new Error("framework must be spa or static");
|
|
7524
|
+
const startedAt = Date.now();
|
|
7466
7525
|
const warnings = collectRiddlePreviewDeployWarnings(directory, framework);
|
|
7526
|
+
const emitProgress = previewProgressEmitter(config, { label, framework, directory, startedAt, warnings });
|
|
7527
|
+
await emitProgress({ stage: "validating", message: "checking preview input directory" });
|
|
7528
|
+
const localSummary = summarizePreviewDirectory(directory);
|
|
7529
|
+
await emitProgress({
|
|
7530
|
+
stage: "creating",
|
|
7531
|
+
file_count: localSummary.file_count,
|
|
7532
|
+
total_bytes: localSummary.total_bytes,
|
|
7533
|
+
message: "creating preview upload target"
|
|
7534
|
+
});
|
|
7467
7535
|
const created = await riddleRequestJson(config, "/v1/preview", {
|
|
7468
7536
|
method: "POST",
|
|
7469
7537
|
body: JSON.stringify({ framework, label })
|
|
@@ -7471,10 +7539,42 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
7471
7539
|
const id = String(created.id || "");
|
|
7472
7540
|
const uploadUrl = String(created.upload_url || "");
|
|
7473
7541
|
if (!id || !uploadUrl) throw new Error("Riddle preview create response was missing id or upload_url.");
|
|
7542
|
+
await emitProgress({
|
|
7543
|
+
stage: "created",
|
|
7544
|
+
id,
|
|
7545
|
+
file_count: localSummary.file_count,
|
|
7546
|
+
total_bytes: localSummary.total_bytes,
|
|
7547
|
+
message: "preview upload target created"
|
|
7548
|
+
});
|
|
7474
7549
|
const scratch = (0, import_node_fs5.mkdtempSync)(import_node_path5.default.join((0, import_node_os2.tmpdir)(), "riddle-preview-upload-"));
|
|
7475
7550
|
const tarball = import_node_path5.default.join(scratch, `${id}.tar.gz`);
|
|
7551
|
+
let tarballBytes = 0;
|
|
7476
7552
|
try {
|
|
7553
|
+
await emitProgress({
|
|
7554
|
+
stage: "archiving",
|
|
7555
|
+
id,
|
|
7556
|
+
file_count: localSummary.file_count,
|
|
7557
|
+
total_bytes: localSummary.total_bytes,
|
|
7558
|
+
message: "creating preview archive"
|
|
7559
|
+
});
|
|
7477
7560
|
(0, import_node_child_process4.execFileSync)("tar", ["czf", tarball, "-C", directory, "."], { stdio: "pipe" });
|
|
7561
|
+
tarballBytes = (0, import_node_fs5.statSync)(tarball).size;
|
|
7562
|
+
await emitProgress({
|
|
7563
|
+
stage: "archived",
|
|
7564
|
+
id,
|
|
7565
|
+
file_count: localSummary.file_count,
|
|
7566
|
+
total_bytes: localSummary.total_bytes,
|
|
7567
|
+
tarball_bytes: tarballBytes,
|
|
7568
|
+
message: "preview archive created"
|
|
7569
|
+
});
|
|
7570
|
+
await emitProgress({
|
|
7571
|
+
stage: "uploading",
|
|
7572
|
+
id,
|
|
7573
|
+
file_count: localSummary.file_count,
|
|
7574
|
+
total_bytes: localSummary.total_bytes,
|
|
7575
|
+
tarball_bytes: tarballBytes,
|
|
7576
|
+
message: "uploading preview archive"
|
|
7577
|
+
});
|
|
7478
7578
|
const upload = await fetchFor(config)(uploadUrl, {
|
|
7479
7579
|
method: "PUT",
|
|
7480
7580
|
headers: { "Content-Type": "application/gzip" },
|
|
@@ -7483,14 +7583,37 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
7483
7583
|
if (!upload.ok) {
|
|
7484
7584
|
throw new RiddleApiError(uploadUrl, upload.status, await upload.text());
|
|
7485
7585
|
}
|
|
7586
|
+
await emitProgress({
|
|
7587
|
+
stage: "uploaded",
|
|
7588
|
+
id,
|
|
7589
|
+
file_count: localSummary.file_count,
|
|
7590
|
+
total_bytes: localSummary.total_bytes,
|
|
7591
|
+
tarball_bytes: tarballBytes,
|
|
7592
|
+
message: "preview archive uploaded"
|
|
7593
|
+
});
|
|
7486
7594
|
} finally {
|
|
7487
7595
|
(0, import_node_fs5.rmSync)(scratch, { recursive: true, force: true });
|
|
7488
7596
|
}
|
|
7489
7597
|
const expiresAt = typeof created.expires_at === "string" ? created.expires_at : void 0;
|
|
7490
7598
|
try {
|
|
7599
|
+
await emitProgress({
|
|
7600
|
+
stage: "publishing",
|
|
7601
|
+
id,
|
|
7602
|
+
file_count: localSummary.file_count,
|
|
7603
|
+
total_bytes: localSummary.total_bytes,
|
|
7604
|
+
tarball_bytes: tarballBytes || void 0,
|
|
7605
|
+
message: "publishing preview"
|
|
7606
|
+
});
|
|
7491
7607
|
const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
|
|
7492
7608
|
method: "POST"
|
|
7493
7609
|
});
|
|
7610
|
+
await emitProgress({
|
|
7611
|
+
stage: "ready",
|
|
7612
|
+
id,
|
|
7613
|
+
preview_url: String(published.preview_url || ""),
|
|
7614
|
+
file_count: typeof published.file_count === "number" ? published.file_count : localSummary.file_count,
|
|
7615
|
+
total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : localSummary.total_bytes
|
|
7616
|
+
});
|
|
7494
7617
|
return previewDeployResultFromRecord({ record: published, id, label, framework, expiresAt, warnings });
|
|
7495
7618
|
} catch (error) {
|
|
7496
7619
|
if (!canRecoverPreviewPublish(error)) throw error;
|
|
@@ -7500,7 +7623,9 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
7500
7623
|
framework,
|
|
7501
7624
|
expiresAt,
|
|
7502
7625
|
publishError: error,
|
|
7503
|
-
warnings
|
|
7626
|
+
warnings,
|
|
7627
|
+
localSummary,
|
|
7628
|
+
emitProgress
|
|
7504
7629
|
});
|
|
7505
7630
|
}
|
|
7506
7631
|
}
|
|
@@ -17358,7 +17483,7 @@ function usage() {
|
|
|
17358
17483
|
" riddle-proof-loop regression-pack run [--pack oc-flow-regression|--pack-file <file>] [--local-core true|false; default true] [--hosted-riddle true|false; default false] [--format json|markdown|compact-json; default json] [--output <dir>|--output-dir <dir>]",
|
|
17359
17484
|
" riddle-proof-loop profile-body-assertions --artifact <file|url|-> --candidates-json <file|json|-> [--required-json <file|json|->] [--format json|body-contains]",
|
|
17360
17485
|
" riddle-proof-loop profile-http-status-preflight --profile <file|json|-> --url <base-url> [--format json|summary]",
|
|
17361
|
-
" riddle-proof-loop riddle-preview-deploy <build-dir> <label> [--framework spa|static]",
|
|
17486
|
+
" riddle-proof-loop riddle-preview-deploy <build-dir> <label> [--framework spa|static] [--quiet]",
|
|
17362
17487
|
" riddle-proof-loop riddle-server-preview <directory> --script-file <file> [--path /route] [--wait-for-selector selector]",
|
|
17363
17488
|
" riddle-proof-loop riddle-run-script --url <url> --script-file <file> [--viewport 1280x720] [--strict true|false]",
|
|
17364
17489
|
" riddle-proof-loop riddle-poll <job-id> [--wait] [--attempts n] [--quiet]",
|
|
@@ -18127,6 +18252,18 @@ function formatPollDuration(ms) {
|
|
|
18127
18252
|
const remainder = seconds % 60;
|
|
18128
18253
|
return minutes > 0 ? `${minutes}m${String(remainder).padStart(2, "0")}s` : `${seconds}s`;
|
|
18129
18254
|
}
|
|
18255
|
+
function formatByteCount(bytes) {
|
|
18256
|
+
if (typeof bytes !== "number" || !Number.isFinite(bytes)) return "n/a";
|
|
18257
|
+
if (bytes < 1024) return `${bytes}B`;
|
|
18258
|
+
const units = ["KB", "MB", "GB", "TB"];
|
|
18259
|
+
let value = bytes / 1024;
|
|
18260
|
+
let unitIndex = 0;
|
|
18261
|
+
while (value >= 1024 && unitIndex < units.length - 1) {
|
|
18262
|
+
value /= 1024;
|
|
18263
|
+
unitIndex += 1;
|
|
18264
|
+
}
|
|
18265
|
+
return `${value >= 10 ? value.toFixed(0) : value.toFixed(1)}${units[unitIndex]}`;
|
|
18266
|
+
}
|
|
18130
18267
|
function riddlePollProgressLine(snapshot) {
|
|
18131
18268
|
const submittedAt = snapshot.submitted_at || "not-submitted";
|
|
18132
18269
|
const queuePart = snapshot.running_without_submission ? ` waiting_for_submit=${formatPollDuration(snapshot.pre_submission_elapsed_ms)}${snapshot.queue_elapsed_ms !== null ? ` queued_for=${formatPollDuration(snapshot.queue_elapsed_ms)}` : ""}` : snapshot.queue_elapsed_ms !== null ? ` queue=${formatPollDuration(snapshot.queue_elapsed_ms)}` : "";
|
|
@@ -18140,6 +18277,18 @@ function riddlePollProgressLine(snapshot) {
|
|
|
18140
18277
|
`submitted_at=${submittedAt}${queuePart}${terminalPart}`
|
|
18141
18278
|
].join(" ");
|
|
18142
18279
|
}
|
|
18280
|
+
function riddlePreviewProgressLine(snapshot) {
|
|
18281
|
+
const idPart = snapshot.id ? ` id=${snapshot.id}` : "";
|
|
18282
|
+
const statusPart = snapshot.status ? ` status=${snapshot.status}` : "";
|
|
18283
|
+
const attemptPart = snapshot.attempt && snapshot.attempts ? ` attempt=${snapshot.attempt}/${snapshot.attempts}` : "";
|
|
18284
|
+
const previewPart = snapshot.preview_url ? ` url=${snapshot.preview_url}` : "";
|
|
18285
|
+
const filePart = typeof snapshot.file_count === "number" ? ` files=${snapshot.file_count}` : "";
|
|
18286
|
+
const totalPart = typeof snapshot.total_bytes === "number" ? ` bytes=${formatByteCount(snapshot.total_bytes)}` : "";
|
|
18287
|
+
const archivePart = typeof snapshot.tarball_bytes === "number" ? ` archive=${formatByteCount(snapshot.tarball_bytes)}` : "";
|
|
18288
|
+
const recoveryPart = snapshot.publish_error ? ` publish_error=${JSON.stringify(snapshot.publish_error)}` : "";
|
|
18289
|
+
const messagePart = snapshot.message ? ` ${snapshot.message}` : "";
|
|
18290
|
+
return `[riddle-preview] ${snapshot.stage}${idPart}${statusPart}${attemptPart} elapsed=${formatPollDuration(snapshot.elapsed_ms)} label=${snapshot.label} framework=${snapshot.framework}${filePart}${totalPart}${archivePart}${previewPart}${recoveryPart}${messagePart}`;
|
|
18291
|
+
}
|
|
18143
18292
|
function readJsonValue(value, label) {
|
|
18144
18293
|
if (!value) throw new Error(`${label} is required.`);
|
|
18145
18294
|
const raw = value === "-" ? readStdin() : (0, import_node_fs6.existsSync)(value) ? (0, import_node_fs6.readFileSync)(value, "utf-8") : value;
|
|
@@ -21815,7 +21964,14 @@ async function main() {
|
|
|
21815
21964
|
if (command === "riddle-preview-deploy") {
|
|
21816
21965
|
const buildDir = positional[1];
|
|
21817
21966
|
const label = positional[2];
|
|
21818
|
-
const
|
|
21967
|
+
const clientConfig = riddleClientConfig(options);
|
|
21968
|
+
if (options.quiet !== true) {
|
|
21969
|
+
clientConfig.onPreviewProgress = (snapshot) => {
|
|
21970
|
+
process.stderr.write(`${riddlePreviewProgressLine(snapshot)}
|
|
21971
|
+
`);
|
|
21972
|
+
};
|
|
21973
|
+
}
|
|
21974
|
+
const result = await createRiddleApiClient(clientConfig).deployPreview(buildDir, label, previewFrameworkOption(options));
|
|
21819
21975
|
for (const warning of result.warnings ?? []) {
|
|
21820
21976
|
process.stderr.write(`Warning: ${warning}
|
|
21821
21977
|
`);
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-F4HKK2YH.js";
|
|
3
3
|
import "./chunk-Z2LCVROU.js";
|
|
4
|
-
import "./chunk-
|
|
4
|
+
import "./chunk-DI2XNGEZ.js";
|
|
5
5
|
import "./chunk-ZREWMTFA.js";
|
|
6
6
|
import "./chunk-ZQWVXQKJ.js";
|
|
7
7
|
import "./chunk-RDPG554T.js";
|