reeval 0.0.1
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 +202 -0
- package/THIRD_PARTY_NOTICES.md +2160 -0
- package/assets/package.json +9 -0
- package/assets/pnpm-lock.yaml +1336 -0
- package/dist/agent-DVHkx8aT.js +532 -0
- package/dist/agent-DVHkx8aT.js.map +1 -0
- package/dist/analysis-CxSCt1YY.js +16 -0
- package/dist/analysis-CxSCt1YY.js.map +1 -0
- package/dist/assemble-B-nmz8oH.js +695 -0
- package/dist/assemble-B-nmz8oH.js.map +1 -0
- package/dist/assemble-CmRVDZ2Q.js +2 -0
- package/dist/attempt-BdRQ9jKX.js +176 -0
- package/dist/attempt-BdRQ9jKX.js.map +1 -0
- package/dist/bridge/index.mjs +1911 -0
- package/dist/bridge/package.json +13 -0
- package/dist/bridge/pnpm-lock.yaml +1041 -0
- package/dist/bridge/pnpm-workspace.yaml +2 -0
- package/dist/budget-DBUrH4jX.js +8 -0
- package/dist/budget-DBUrH4jX.js.map +1 -0
- package/dist/cli--CQ3Iy9q.js +1865 -0
- package/dist/cli--CQ3Iy9q.js.map +1 -0
- package/dist/cli-spec-DKAu09Gi.js +478 -0
- package/dist/cli-spec-DKAu09Gi.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +8 -0
- package/dist/cli.js.map +1 -0
- package/dist/colors-QV9dFVhN.js +34 -0
- package/dist/colors-QV9dFVhN.js.map +1 -0
- package/dist/command-BSJzHMtP.js +280 -0
- package/dist/command-BSJzHMtP.js.map +1 -0
- package/dist/command-CEm8PZ1N.js +1043 -0
- package/dist/command-CEm8PZ1N.js.map +1 -0
- package/dist/command-D-jnQWVG.js +673 -0
- package/dist/command-D-jnQWVG.js.map +1 -0
- package/dist/command-DQAvbG7d.js +432 -0
- package/dist/command-DQAvbG7d.js.map +1 -0
- package/dist/commands-A4udfyKZ.js +2 -0
- package/dist/commands-CF8mOfiu.js +207 -0
- package/dist/commands-CF8mOfiu.js.map +1 -0
- package/dist/config-Cuj0kVYj.js +415 -0
- package/dist/config-Cuj0kVYj.js.map +1 -0
- package/dist/context-loi9OCZv.js +106 -0
- package/dist/context-loi9OCZv.js.map +1 -0
- package/dist/core-tLN-z1Be.js +96 -0
- package/dist/core-tLN-z1Be.js.map +1 -0
- package/dist/db-Cjj2ZsfQ.js +2 -0
- package/dist/db-DxDzMhtB.js +827 -0
- package/dist/db-DxDzMhtB.js.map +1 -0
- package/dist/debug-D24NOQH1.js +89 -0
- package/dist/debug-D24NOQH1.js.map +1 -0
- package/dist/debug-SEmW4w8f.js +2 -0
- package/dist/dist-BZXYHN2X.js +1673 -0
- package/dist/dist-BZXYHN2X.js.map +1 -0
- package/dist/docker-DQDZWXF9.js +20 -0
- package/dist/docker-DQDZWXF9.js.map +1 -0
- package/dist/docker-DnWAVdEm.js +2 -0
- package/dist/docker-oSbCExHL.js +153 -0
- package/dist/docker-oSbCExHL.js.map +1 -0
- package/dist/doctor-CxlH1pDM.js +525 -0
- package/dist/doctor-CxlH1pDM.js.map +1 -0
- package/dist/egress-73SQfKdx.js +619 -0
- package/dist/egress-73SQfKdx.js.map +1 -0
- package/dist/env-BQqj93gu.js +21 -0
- package/dist/env-BQqj93gu.js.map +1 -0
- package/dist/environment-Mz7wvrtD.js +552 -0
- package/dist/environment-Mz7wvrtD.js.map +1 -0
- package/dist/errors-C9w_ud7g.js +160 -0
- package/dist/errors-C9w_ud7g.js.map +1 -0
- package/dist/errors-CSxfJ4qu.js +11 -0
- package/dist/errors-CSxfJ4qu.js.map +1 -0
- package/dist/files--6CEUXm7.js +2 -0
- package/dist/files-BLlrhU4-.js +62 -0
- package/dist/files-BLlrhU4-.js.map +1 -0
- package/dist/files-Bd25OAQH.js +2 -0
- package/dist/files-BvHCFWgD.js +2 -0
- package/dist/files-D2-qn_Dl.js +275 -0
- package/dist/files-D2-qn_Dl.js.map +1 -0
- package/dist/files-bF2fPuT9.js +99 -0
- package/dist/files-bF2fPuT9.js.map +1 -0
- package/dist/git-D6hMeieS.js +44 -0
- package/dist/git-D6hMeieS.js.map +1 -0
- package/dist/harness-ls5aX1UO.js +131 -0
- package/dist/harness-ls5aX1UO.js.map +1 -0
- package/dist/harness.d.ts +74 -0
- package/dist/harness.js +2 -0
- package/dist/header-DzFDoMCI.js +78 -0
- package/dist/header-DzFDoMCI.js.map +1 -0
- package/dist/ids-Bp6ut7ZD.js +49 -0
- package/dist/ids-Bp6ut7ZD.js.map +1 -0
- package/dist/images-Cc1-coFc.js +286 -0
- package/dist/images-Cc1-coFc.js.map +1 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +1959 -0
- package/dist/index.js.map +1 -0
- package/dist/init-CFljS8BJ.js +344 -0
- package/dist/init-CFljS8BJ.js.map +1 -0
- package/dist/init-z2ZPn9Tj.js +2 -0
- package/dist/invocations-rXktgSAn.js +157 -0
- package/dist/invocations-rXktgSAn.js.map +1 -0
- package/dist/jiti-BOLXpKyG.js +46 -0
- package/dist/jiti-BOLXpKyG.js.map +1 -0
- package/dist/judge-D8Uf4dA9.js +146 -0
- package/dist/judge-D8Uf4dA9.js.map +1 -0
- package/dist/judge.d.ts +21 -0
- package/dist/judge.js +19 -0
- package/dist/judge.js.map +1 -0
- package/dist/live-Bs3LReMV.js +98 -0
- package/dist/live-Bs3LReMV.js.map +1 -0
- package/dist/matchers-DyLvm7EG.js +374 -0
- package/dist/matchers-DyLvm7EG.js.map +1 -0
- package/dist/model-BdO79gWz.js +44 -0
- package/dist/model-BdO79gWz.js.map +1 -0
- package/dist/model-CDL98xue.js +725 -0
- package/dist/model-CDL98xue.js.map +1 -0
- package/dist/model-v-0_Ik7S.js +2 -0
- package/dist/node-kG64XxdE.js +506 -0
- package/dist/node-kG64XxdE.js.map +1 -0
- package/dist/opencode-providers-DZuD_oYt.js +3149 -0
- package/dist/opencode-providers-DZuD_oYt.js.map +1 -0
- package/dist/options-CAQhu--C.js +452 -0
- package/dist/options-CAQhu--C.js.map +1 -0
- package/dist/patch-BkKje4cp.js +69 -0
- package/dist/patch-BkKje4cp.js.map +1 -0
- package/dist/paths-CBvm6pap.js +72 -0
- package/dist/paths-CBvm6pap.js.map +1 -0
- package/dist/plan-gwk6dJ8c.js +237 -0
- package/dist/plan-gwk6dJ8c.js.map +1 -0
- package/dist/preflight-BtubXKQ8.js +2 -0
- package/dist/preflight-BypZMNBG.js +185 -0
- package/dist/preflight-BypZMNBG.js.map +1 -0
- package/dist/prepare-Cwv0bHs_.js +3 -0
- package/dist/prepare-D6Uzcubb.js +213 -0
- package/dist/prepare-D6Uzcubb.js.map +1 -0
- package/dist/provenance-Dfb8YY5Y.js +129 -0
- package/dist/provenance-Dfb8YY5Y.js.map +1 -0
- package/dist/provider-BDbNOQhQ.js +2 -0
- package/dist/provider-CmAYTQQs.js +14 -0
- package/dist/provider-CmAYTQQs.js.map +1 -0
- package/dist/providers-2p3ylMHI.js +107 -0
- package/dist/providers-2p3ylMHI.js.map +1 -0
- package/dist/providers-BUOxitcT.js +2 -0
- package/dist/query-CFATHZmV.js +91 -0
- package/dist/query-CFATHZmV.js.map +1 -0
- package/dist/query-DR4m6CXf.js +2 -0
- package/dist/record-DQ8wzyco.js +99 -0
- package/dist/record-DQ8wzyco.js.map +1 -0
- package/dist/redact-C4fL_bZP.js +167 -0
- package/dist/redact-C4fL_bZP.js.map +1 -0
- package/dist/results-CeXb8Wde.js +37 -0
- package/dist/results-CeXb8Wde.js.map +1 -0
- package/dist/root-CFDjpWuc.js +110 -0
- package/dist/root-CFDjpWuc.js.map +1 -0
- package/dist/sandbox-By2gkdkC.js +133 -0
- package/dist/sandbox-By2gkdkC.js.map +1 -0
- package/dist/sandbox.d.ts +41 -0
- package/dist/sandbox.js +2 -0
- package/dist/server-Bi61uiY0.js +350 -0
- package/dist/server-Bi61uiY0.js.map +1 -0
- package/dist/server-CsSBL8NC.js +2 -0
- package/dist/source-BXzrmof5.js +2 -0
- package/dist/source-Bsfa3LZH.js +40 -0
- package/dist/source-Bsfa3LZH.js.map +1 -0
- package/dist/src-55j1zNHH.js +3 -0
- package/dist/src-AEwxd1UP.js +602 -0
- package/dist/src-AEwxd1UP.js.map +1 -0
- package/dist/src-BDwSuyIo.js +3 -0
- package/dist/src-BQyMiWri.js +490 -0
- package/dist/src-BQyMiWri.js.map +1 -0
- package/dist/src-C-LHyTSV.js +3 -0
- package/dist/src-Cmp-7YrD.js +1136 -0
- package/dist/src-Cmp-7YrD.js.map +1 -0
- package/dist/src-D0RdqpNb.js +252 -0
- package/dist/src-D0RdqpNb.js.map +1 -0
- package/dist/src-D8KYzxBX.js +793 -0
- package/dist/src-D8KYzxBX.js.map +1 -0
- package/dist/src-DEgff9Z7.js +4 -0
- package/dist/src-DXx_29pq.js +567 -0
- package/dist/src-DXx_29pq.js.map +1 -0
- package/dist/src-DwwiVLqv.js +2937 -0
- package/dist/src-DwwiVLqv.js.map +1 -0
- package/dist/src-N7E_mfcZ.js +2 -0
- package/dist/src-W9g-y5X5.js +3 -0
- package/dist/src-daS0wKH2.js +3 -0
- package/dist/state-Cyw3QTsN.js +2 -0
- package/dist/state-DZ7eqb1F.js +167 -0
- package/dist/state-DZ7eqb1F.js.map +1 -0
- package/dist/stats-BNAHlNMD.js +114 -0
- package/dist/stats-BNAHlNMD.js.map +1 -0
- package/dist/studio-app/assets/index-D6XyfFSH.js +58 -0
- package/dist/studio-app/assets/index-xwzWdcE_.css +2 -0
- package/dist/studio-app/favicon.svg +1 -0
- package/dist/studio-app/index.html +15 -0
- package/dist/summary-D7Ttky0z.js +166 -0
- package/dist/summary-D7Ttky0z.js.map +1 -0
- package/dist/text-gEcKjAyp.js +29 -0
- package/dist/text-gEcKjAyp.js.map +1 -0
- package/dist/types-C5vI3g1C.js +9 -0
- package/dist/types-C5vI3g1C.js.map +1 -0
- package/dist/types-DLec-6Cx.d.ts +1535 -0
- package/dist/usage-DsYUqIUM.js +24 -0
- package/dist/usage-DsYUqIUM.js.map +1 -0
- package/dist/view/index.d.ts +645 -0
- package/dist/view/index.js +8 -0
- package/dist/views-BrHOv6wg.js +220 -0
- package/dist/views-BrHOv6wg.js.map +1 -0
- package/dist/views-CwCWLWqo.js +3 -0
- package/dist/worker-entry-DnYkANPG.js +506 -0
- package/dist/worker-entry-DnYkANPG.js.map +1 -0
- package/dist/workspace-C2S0Z6gl.js +327 -0
- package/dist/workspace-C2S0Z6gl.js.map +1 -0
- package/dist/workspace-CyoXG6CY.js +2 -0
- package/docker/Dockerfile +19 -0
- package/package.json +79 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors-QV9dFVhN.js","names":[],"sources":["../src/ui/colors.ts"],"mappings":";AAaA,MAAM,OAAO,IAAI,OAAO,GAAG,OAAO,aAAa,EAAE,EAAE,yBAAyB,GAAG;AAE/E,MAAa,aAAa,SAAyB,KAAK,QAAQ,MAAM,EAAE;AAGxE,MAAM,UAAU;CAAC;CAAI;CAAI;CAAI;CAAI;AAAE;AAEnC,SAAgB,OAAO,SAA0B;CAC/C,MAAM,SACH,MAAc,QAAQ,QACtB,SACC,UAAU,QAAQ,KAAK,GAAG,KAAK,OAAO,MAAM,KAAK;CACrD,MAAM,uBAAO,IAAI,IAAmB;CACpC,OAAO;EACL;EACA,OAAO,MAAM,EAAE;EACf,KAAK,MAAM,EAAE;EACb,QAAQ,MAAM,EAAE;EAChB,KAAK,MAAM,GAAG,EAAE;EAChB,MAAM,MAAM,GAAG,EAAE;EACjB,IAAI,KAAK;GACP,IAAI,IAAI,KAAK,IAAI,GAAG;GACpB,IAAI,CAAC,GAAG;IACN,IAAI,MAAM,QAAQ,KAAK,OAAO,QAAQ,WAAW,EAAE;IACnD,KAAK,IAAI,KAAK,CAAC;GACjB;GACA,OAAO;EACT;CACF;AACF"}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { t as UsageError } from "./errors-CSxfJ4qu.js";
|
|
2
|
+
import { c as ownDir } from "./root-CFDjpWuc.js";
|
|
3
|
+
import { l as studioPath, o as recordPath } from "./paths-CBvm6pap.js";
|
|
4
|
+
import { a as fromCwd } from "./ids-Bp6ut7ZD.js";
|
|
5
|
+
import { a as sortAnalyses, r as analysisDataPath } from "./analysis-CxSCt1YY.js";
|
|
6
|
+
import { g as indexFiles } from "./model-CDL98xue.js";
|
|
7
|
+
import { f as scratchDir, l as recordNames } from "./files-D2-qn_Dl.js";
|
|
8
|
+
import { t as listHeaders } from "./source-Bsfa3LZH.js";
|
|
9
|
+
import { a as watchLive, i as newToken, n as allowedHosts, r as createStudioApp } from "./server-Bi61uiY0.js";
|
|
10
|
+
import { existsSync, lstatSync, watch } from "node:fs";
|
|
11
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
12
|
+
import { spawn } from "node:child_process";
|
|
13
|
+
import { cp, mkdir, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
14
|
+
import { serve } from "@hono/node-server";
|
|
15
|
+
//#region src/studio/watch.ts
|
|
16
|
+
/**
|
|
17
|
+
* Calls `onChange` (debounced) when the set of run records in any of `dirs` changes. Records land
|
|
18
|
+
* last and whole, so a new top-level `.json` means a run finished or was recorded. `fs.watch`
|
|
19
|
+
* gives quick notice; a listing poll covers folders created later and filesystems without events.
|
|
20
|
+
*/
|
|
21
|
+
function watchRuns(dirs, onChange, pollMs = 1500) {
|
|
22
|
+
const watchers = /* @__PURE__ */ new Map();
|
|
23
|
+
let signature = "";
|
|
24
|
+
let timer;
|
|
25
|
+
let closed = false;
|
|
26
|
+
const listing = async () => {
|
|
27
|
+
const parts = [];
|
|
28
|
+
for (const dir of dirs) {
|
|
29
|
+
const names = await recordNames(dir).catch(() => null);
|
|
30
|
+
parts.push(`${dir}:${names ? names.join(",") : "-"}`);
|
|
31
|
+
}
|
|
32
|
+
return parts.join("|");
|
|
33
|
+
};
|
|
34
|
+
const check = async () => {
|
|
35
|
+
if (closed) return;
|
|
36
|
+
for (const dir of dirs) {
|
|
37
|
+
if (watchers.has(dir)) continue;
|
|
38
|
+
try {
|
|
39
|
+
const w = watch(dir, { persistent: false }, () => schedule());
|
|
40
|
+
w.on("error", () => {
|
|
41
|
+
w.close();
|
|
42
|
+
watchers.delete(dir);
|
|
43
|
+
});
|
|
44
|
+
watchers.set(dir, w);
|
|
45
|
+
} catch {}
|
|
46
|
+
}
|
|
47
|
+
const next = await listing();
|
|
48
|
+
if (signature && next !== signature) onChange();
|
|
49
|
+
signature = next;
|
|
50
|
+
};
|
|
51
|
+
const schedule = () => {
|
|
52
|
+
clearTimeout(timer);
|
|
53
|
+
timer = setTimeout(() => void check(), 150);
|
|
54
|
+
};
|
|
55
|
+
check();
|
|
56
|
+
const poll = setInterval(() => void check(), pollMs);
|
|
57
|
+
poll.unref();
|
|
58
|
+
return () => {
|
|
59
|
+
closed = true;
|
|
60
|
+
clearInterval(poll);
|
|
61
|
+
clearTimeout(timer);
|
|
62
|
+
for (const w of watchers.values()) w.close();
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/studio/build.ts
|
|
67
|
+
var StudioBuildError = class extends Error {
|
|
68
|
+
name = "StudioBuildError";
|
|
69
|
+
};
|
|
70
|
+
async function sizeOf(dir) {
|
|
71
|
+
let files = 0;
|
|
72
|
+
let bytes = 0;
|
|
73
|
+
for (const entry of await readdir(dir, {
|
|
74
|
+
recursive: true,
|
|
75
|
+
withFileTypes: true
|
|
76
|
+
})) {
|
|
77
|
+
if (!entry.isFile()) continue;
|
|
78
|
+
files++;
|
|
79
|
+
bytes += (await stat(join(entry.parentPath, entry.name))).size;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
files,
|
|
83
|
+
bytes
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Writes the studio as a static site: the prebuilt app, `studio.json`, the index shards, and every
|
|
88
|
+
* run under `data/runs/` at the same paths `reeval studio` serves. The app uses hash routing and
|
|
89
|
+
* relative URLs, so the folder works from any host and subpath.
|
|
90
|
+
*/
|
|
91
|
+
async function buildStudio(options) {
|
|
92
|
+
const { out, source } = options;
|
|
93
|
+
if (!existsSync(join(options.appDir, "index.html"))) throw new StudioBuildError(`The studio web app is missing from ${options.appDir}`);
|
|
94
|
+
if (existsSync(out)) {
|
|
95
|
+
const names = await readdir(out);
|
|
96
|
+
if (names.length > 0 && !names.includes("studio.json")) throw new StudioBuildError(`${out} isn't empty and isn't a previous studio build; choose another --out`);
|
|
97
|
+
await rm(out, {
|
|
98
|
+
recursive: true,
|
|
99
|
+
force: true
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
await mkdir(out, { recursive: true });
|
|
103
|
+
await cp(options.appDir, out, { recursive: true });
|
|
104
|
+
const headers = await listHeaders(source);
|
|
105
|
+
const generatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
106
|
+
const info = {
|
|
107
|
+
mode: "static",
|
|
108
|
+
es: options.es,
|
|
109
|
+
project: options.project,
|
|
110
|
+
generatedAt,
|
|
111
|
+
features: {
|
|
112
|
+
live: false,
|
|
113
|
+
scratch: source.scratch,
|
|
114
|
+
artifacts: options.artifacts,
|
|
115
|
+
debug: false
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
await writeFile(join(out, studioPath), `${JSON.stringify(info, null, 2)}\n`);
|
|
119
|
+
for (const [path, body] of indexFiles(headers, generatedAt)) {
|
|
120
|
+
await mkdir(dirname(join(out, path)), { recursive: true });
|
|
121
|
+
await writeFile(join(out, path), JSON.stringify(body));
|
|
122
|
+
}
|
|
123
|
+
const { listAnalyses } = await import("./files-Bd25OAQH.js");
|
|
124
|
+
for (const header of headers) {
|
|
125
|
+
const dir = header.recorded ? source.historyDir : scratchDir(source.root);
|
|
126
|
+
const saved = header.recorded ? await listAnalyses(source.root, [source.historyDir], header.runId, false) : [];
|
|
127
|
+
if (saved.length) {
|
|
128
|
+
const index = {
|
|
129
|
+
runId: header.runId,
|
|
130
|
+
entries: sortAnalyses(saved)
|
|
131
|
+
};
|
|
132
|
+
const file = join(out, analysisDataPath(header.runId));
|
|
133
|
+
await mkdir(dirname(file), { recursive: true });
|
|
134
|
+
await writeFile(file, JSON.stringify(index));
|
|
135
|
+
}
|
|
136
|
+
const target = join(out, recordPath(header.runId));
|
|
137
|
+
await mkdir(dirname(target), { recursive: true });
|
|
138
|
+
await cp(join(dir, `${header.runId}.json`), target);
|
|
139
|
+
const artifacts = join(dir, header.runId);
|
|
140
|
+
if (options.artifacts && existsSync(artifacts)) await cp(artifacts, join(dirname(target), header.runId), {
|
|
141
|
+
recursive: true,
|
|
142
|
+
filter: (src) => !/[\\/]\.tmp-/.test(src) && !lstatSync(src).isSymbolicLink()
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
runs: headers.length,
|
|
147
|
+
...await sizeOf(out)
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/studio/index.ts
|
|
152
|
+
/** Where the prebuilt web app ships inside the package (copied from packages/studio-web). */
|
|
153
|
+
const APP_DIR = ownDir("dist/studio-app");
|
|
154
|
+
function listen(app, host, port) {
|
|
155
|
+
return new Promise((resolve, reject) => {
|
|
156
|
+
const server = serve({
|
|
157
|
+
fetch: app.fetch,
|
|
158
|
+
hostname: host,
|
|
159
|
+
port
|
|
160
|
+
});
|
|
161
|
+
server.once("error", reject);
|
|
162
|
+
server.once("listening", () => resolve(server));
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/** Starts `reeval studio`: the next free port from `port`, a fresh token, and a history watcher. */
|
|
166
|
+
async function startStudio(options) {
|
|
167
|
+
const { source, host } = options;
|
|
168
|
+
const token = options.token ? newToken() : null;
|
|
169
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
170
|
+
const send = (event) => {
|
|
171
|
+
for (const l of listeners) l(event);
|
|
172
|
+
};
|
|
173
|
+
const stopRuns = watchRuns(source.scratch ? [source.historyDir, scratchDir(source.root)] : [source.historyDir], () => send({ type: "history.changed" }));
|
|
174
|
+
const stopLive = watchLive(source, (runs) => send({
|
|
175
|
+
type: "run.progress",
|
|
176
|
+
runs
|
|
177
|
+
}));
|
|
178
|
+
const stopWatching = () => {
|
|
179
|
+
stopRuns();
|
|
180
|
+
stopLive();
|
|
181
|
+
};
|
|
182
|
+
for (let port = options.port; port < options.port + 20; port++) {
|
|
183
|
+
const app = createStudioApp({
|
|
184
|
+
source,
|
|
185
|
+
appDir: options.appDir ?? APP_DIR,
|
|
186
|
+
es: options.es,
|
|
187
|
+
project: options.project,
|
|
188
|
+
token,
|
|
189
|
+
hosts: allowedHosts(host, port),
|
|
190
|
+
subscribe: (listener) => {
|
|
191
|
+
listeners.add(listener);
|
|
192
|
+
return () => listeners.delete(listener);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
try {
|
|
196
|
+
const server = await listen(app, host, port);
|
|
197
|
+
const origin = `http://${host.includes(":") ? `[${host}]` : host}:${port}`;
|
|
198
|
+
return {
|
|
199
|
+
url: token ? `${origin}/?token=${token}` : `${origin}/`,
|
|
200
|
+
port,
|
|
201
|
+
close() {
|
|
202
|
+
stopWatching();
|
|
203
|
+
server.close();
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
} catch (error) {
|
|
207
|
+
if (error.code !== "EADDRINUSE") {
|
|
208
|
+
stopWatching();
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
stopWatching();
|
|
214
|
+
throw new Error(`Ports ${options.port}–${options.port + 19} are all in use; pass --port`);
|
|
215
|
+
}
|
|
216
|
+
function openBrowser(url) {
|
|
217
|
+
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open";
|
|
218
|
+
spawn(command, [url], {
|
|
219
|
+
stdio: "ignore",
|
|
220
|
+
detached: true
|
|
221
|
+
}).on("error", () => {}).unref();
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/studio/command.ts
|
|
225
|
+
const kb = (bytes) => bytes > 1048576 ? `${(bytes / 1024 / 1024).toFixed(1)} MB` : `${(bytes / 1024).toFixed(0)} KB`;
|
|
226
|
+
async function studioCommand({ config, flags, version, build }) {
|
|
227
|
+
const project = basename(config.root);
|
|
228
|
+
const rel = (path) => fromCwd(path) || ".";
|
|
229
|
+
if (build) {
|
|
230
|
+
const out = flags.out ? resolve(flags.out) : join(config.root, "studio-dist");
|
|
231
|
+
const artifacts = !flags["no-artifacts"];
|
|
232
|
+
const result = await buildStudio({
|
|
233
|
+
source: {
|
|
234
|
+
root: config.root,
|
|
235
|
+
historyDir: config.history.dir,
|
|
236
|
+
scratch: !!flags.scratch
|
|
237
|
+
},
|
|
238
|
+
appDir: APP_DIR,
|
|
239
|
+
out,
|
|
240
|
+
artifacts,
|
|
241
|
+
es: version,
|
|
242
|
+
project
|
|
243
|
+
});
|
|
244
|
+
console.log(`built ${rel(out)}/: ${result.runs} run${result.runs === 1 ? "" : "s"}, ${result.files} files, ${kb(result.bytes)}${artifacts ? " (records, transcripts, diffs, logs and judge inputs)" : " (records only: --no-artifacts)"}`);
|
|
245
|
+
console.log("Serve it from any static host. Anyone who can open it can read every included file.");
|
|
246
|
+
return 0;
|
|
247
|
+
}
|
|
248
|
+
const port = flags.port === void 0 ? 4984 : Number(flags.port);
|
|
249
|
+
if (!(Number.isInteger(port) && port > 0 && port < 65536)) throw new UsageError(`--port must be a port number (got ${flags.port})`);
|
|
250
|
+
const host = flags.host ?? "127.0.0.1";
|
|
251
|
+
if (host !== "127.0.0.1" && host !== "localhost" && host !== "::1") console.error(`warning: studio is listening on ${host}, reachable beyond this machine`);
|
|
252
|
+
const token = !flags["no-token"];
|
|
253
|
+
if (!token) console.error("warning: --no-token lets any local process or user read the studio");
|
|
254
|
+
const studio = await startStudio({
|
|
255
|
+
source: {
|
|
256
|
+
root: config.root,
|
|
257
|
+
historyDir: config.history.dir,
|
|
258
|
+
scratch: !flags["no-scratch"]
|
|
259
|
+
},
|
|
260
|
+
host,
|
|
261
|
+
port,
|
|
262
|
+
token,
|
|
263
|
+
es: version,
|
|
264
|
+
project
|
|
265
|
+
});
|
|
266
|
+
console.log(`reeval studio · ${project} · ${rel(config.history.dir)}/`);
|
|
267
|
+
console.log(` ${studio.url}`);
|
|
268
|
+
console.log("Ctrl-C to stop.");
|
|
269
|
+
if (flags.open) openBrowser(studio.url);
|
|
270
|
+
await new Promise((resolveStop) => {
|
|
271
|
+
process.once("SIGINT", resolveStop);
|
|
272
|
+
process.once("SIGTERM", resolveStop);
|
|
273
|
+
});
|
|
274
|
+
studio.close();
|
|
275
|
+
return 0;
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
export { studioCommand };
|
|
279
|
+
|
|
280
|
+
//# sourceMappingURL=command-BSJzHMtP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-BSJzHMtP.js","names":[],"sources":["../src/studio/watch.ts","../src/studio/build.ts","../src/studio/index.ts","../src/studio/command.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQA,SAAgB,UAAU,MAAgB,UAAsB,SAAS,MAAM;CAC7E,MAAM,2BAAW,IAAI,IAAuB;CAC5C,IAAI,YAAY;CAChB,IAAI;CACJ,IAAI,SAAS;CAEb,MAAM,UAAU,YAAY;EAC1B,MAAM,QAAkB,CAAC;EACzB,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,QAAQ,MAAM,YAAY,GAAG,CAAC,CAAC,YAAY,IAAI;GACrD,MAAM,KAAK,GAAG,IAAI,GAAG,QAAQ,MAAM,KAAK,GAAG,IAAI,KAAK;EACtD;EACA,OAAO,MAAM,KAAK,GAAG;CACvB;CAEA,MAAM,QAAQ,YAAY;EACxB,IAAI,QAAQ;EACZ,KAAK,MAAM,OAAO,MAAM;GACtB,IAAI,SAAS,IAAI,GAAG,GAAG;GACvB,IAAI;IACF,MAAM,IAAI,MAAM,KAAK,EAAE,YAAY,MAAM,SAAS,SAAS,CAAC;IAC5D,EAAE,GAAG,eAAe;K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