@powerhousedao/ph-cli 6.2.3-dev.93 → 6.2.3-dev.95

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.
Files changed (88) hide show
  1. package/dist/build-BYl_Uu3s.mjs +4 -0
  2. package/dist/build-Dfrq_MIX.mjs +2036 -0
  3. package/dist/build-Dfrq_MIX.mjs.map +1 -0
  4. package/dist/check-XulH7-hn.mjs +4 -0
  5. package/dist/check-bEVuToRY.mjs +60 -0
  6. package/dist/check-bEVuToRY.mjs.map +1 -0
  7. package/dist/{check-Dmx8U75w.mjs → check-d-VEsSZX.mjs} +4 -4
  8. package/dist/{check-Dmx8U75w.mjs.map → check-d-VEsSZX.mjs.map} +1 -1
  9. package/dist/{cli-connect-override-CLHLCeF5.mjs → cli-connect-override-BQr3yjC_.mjs} +4 -4
  10. package/dist/{cli-connect-override-CLHLCeF5.mjs.map → cli-connect-override-BQr3yjC_.mjs.map} +1 -1
  11. package/dist/cli.mjs +4 -4
  12. package/dist/{compound-Cv5yxdLC-DAYAbASE.mjs → compound-DO_mvh0O-D254asEo.mjs} +36 -19
  13. package/dist/{compound-Cv5yxdLC-DAYAbASE.mjs.map → compound-DO_mvh0O-D254asEo.mjs.map} +1 -1
  14. package/dist/{connect-build-D20s-YzT.mjs → connect-build-DrKrCMPR.mjs} +8 -7
  15. package/dist/connect-build-DrKrCMPR.mjs.map +1 -0
  16. package/dist/{connect-config-CoB5ejxj.mjs → connect-config-DWJf22Ro.mjs} +4 -4
  17. package/dist/{connect-config-CoB5ejxj.mjs.map → connect-config-DWJf22Ro.mjs.map} +1 -1
  18. package/dist/{connect-preview-DBcsUnSB.mjs → connect-preview-CdFvlANO.mjs} +5 -4
  19. package/dist/connect-preview-CdFvlANO.mjs.map +1 -0
  20. package/dist/{connect-studio-CCjF7Fo2.mjs → connect-studio-DTZEwZ4C.mjs} +3 -3
  21. package/dist/{connect-studio-DWKRk0Zc.mjs → connect-studio-DWty6fZd.mjs} +4 -4
  22. package/dist/{connect-studio-DWKRk0Zc.mjs.map → connect-studio-DWty6fZd.mjs.map} +1 -1
  23. package/dist/definitions-worker.d.mts +96 -0
  24. package/dist/definitions-worker.d.mts.map +1 -0
  25. package/dist/definitions-worker.mjs +28 -0
  26. package/dist/definitions-worker.mjs.map +1 -0
  27. package/dist/{dist-CF0RfguD.mjs → dist-BOjmQhjX.mjs} +5 -5
  28. package/dist/dist-BOjmQhjX.mjs.map +1 -0
  29. package/dist/evidence-BiMKzRLV.mjs +120 -0
  30. package/dist/evidence-BiMKzRLV.mjs.map +1 -0
  31. package/dist/{explain-BD6bemOK.mjs → explain-DKS-t7dS.mjs} +5 -5
  32. package/dist/{explain-BD6bemOK.mjs.map → explain-DKS-t7dS.mjs.map} +1 -1
  33. package/dist/{export-BiIRQJ7L.mjs → export-DRw3XVfG.mjs} +4 -4
  34. package/dist/{export-BiIRQJ7L.mjs.map → export-DRw3XVfG.mjs.map} +1 -1
  35. package/dist/{index-CuWHsoBB.d.mts → external-M25AgDIE.d.mts} +2 -186
  36. package/dist/external-M25AgDIE.d.mts.map +1 -0
  37. package/dist/files-D05VjxVj.mjs +350 -0
  38. package/dist/files-D05VjxVj.mjs.map +1 -0
  39. package/dist/{generate-all-BWpiTcED.mjs → generate-all-CMpNPpD8.mjs} +4 -4
  40. package/dist/{generate-all-BWpiTcED.mjs.map → generate-all-CMpNPpD8.mjs.map} +1 -1
  41. package/dist/{generate-desktop-shell-NeH89X6S.mjs → generate-desktop-shell-B-Rf7ds8.mjs} +4 -4
  42. package/dist/{generate-desktop-shell-NeH89X6S.mjs.map → generate-desktop-shell-B-Rf7ds8.mjs.map} +1 -1
  43. package/dist/{generate-document-model-vzFHWp4O.mjs → generate-document-model-DCjzz3Sa.mjs} +4 -4
  44. package/dist/{generate-document-model-vzFHWp4O.mjs.map → generate-document-model-DCjzz3Sa.mjs.map} +1 -1
  45. package/dist/{generate-piece-DpFUr1ON.mjs → generate-piece-5Nyr2UZj.mjs} +4 -4
  46. package/dist/{generate-piece-DpFUr1ON.mjs.map → generate-piece-5Nyr2UZj.mjs.map} +1 -1
  47. package/dist/{get-version-S4MNTClf.mjs → get-version-qXfoI8qS.mjs} +4 -4
  48. package/dist/{get-version-S4MNTClf.mjs.map → get-version-qXfoI8qS.mjs.map} +1 -1
  49. package/dist/index-BdxG1c0H.d.mts +188 -0
  50. package/dist/index-BdxG1c0H.d.mts.map +1 -0
  51. package/dist/{inspect-CzjDr590.mjs → inspect-DlRPzee1.mjs} +4 -4
  52. package/dist/{inspect-CzjDr590.mjs.map → inspect-DlRPzee1.mjs.map} +1 -1
  53. package/dist/{mcp-TXHDNfgL.mjs → mcp-BSigu-6U.mjs} +4 -4
  54. package/dist/{mcp-TXHDNfgL.mjs.map → mcp-BSigu-6U.mjs.map} +1 -1
  55. package/dist/npm-args-g1Tgel4s.mjs +78 -0
  56. package/dist/npm-args-g1Tgel4s.mjs.map +1 -0
  57. package/dist/ph-cli-commands-DAqHeYm7.mjs +4 -0
  58. package/dist/{ph-cli-commands-B2QmvOUS.mjs → ph-cli-commands-XNEhuXzO.mjs} +65 -20
  59. package/dist/ph-cli-commands-XNEhuXzO.mjs.map +1 -0
  60. package/dist/render-CTQG4359.mjs +4 -0
  61. package/dist/{run-C7ExLhAm.mjs → run-DEKE4MJY.mjs} +34 -20
  62. package/dist/run-DEKE4MJY.mjs.map +1 -0
  63. package/dist/{run-BiS1kA5W.mjs → run-DP3fNgPv.mjs} +3 -3
  64. package/dist/{run-sugar-DZjQhZb1.mjs → run-sugar-yf2ggYJ9.mjs} +4 -4
  65. package/dist/{run-sugar-DZjQhZb1.mjs.map → run-sugar-yf2ggYJ9.mjs.map} +1 -1
  66. package/dist/runners/connect.d.mts +1 -1
  67. package/dist/runners/connect.mjs +3 -3
  68. package/dist/runners/switchboard.d.mts +1 -1
  69. package/dist/runners/switchboard.mjs +1 -1
  70. package/dist/{schemas-ByfuhvAb.mjs → schemas-ZQiV98u4.mjs} +186 -4
  71. package/dist/{schemas-ByfuhvAb.mjs.map → schemas-ZQiV98u4.mjs.map} +1 -1
  72. package/dist/verify-D16BN0dO.mjs +64 -0
  73. package/dist/verify-D16BN0dO.mjs.map +1 -0
  74. package/dist/{vetra-s0oeZqMz.mjs → vetra-CdYsxlvS.mjs} +6 -6
  75. package/dist/{vetra-s0oeZqMz.mjs.map → vetra-CdYsxlvS.mjs.map} +1 -1
  76. package/package.json +16 -15
  77. package/dist/build-t5pFQx0f.mjs +0 -304
  78. package/dist/build-t5pFQx0f.mjs.map +0 -1
  79. package/dist/build-wvc_NiGr.mjs +0 -4
  80. package/dist/check-B_uGHUz3.mjs +0 -20
  81. package/dist/check-B_uGHUz3.mjs.map +0 -1
  82. package/dist/connect-build-D20s-YzT.mjs.map +0 -1
  83. package/dist/connect-preview-DBcsUnSB.mjs.map +0 -1
  84. package/dist/dist-CF0RfguD.mjs.map +0 -1
  85. package/dist/index-CuWHsoBB.d.mts.map +0 -1
  86. package/dist/ph-cli-commands-B2QmvOUS.mjs.map +0 -1
  87. package/dist/ph-cli-commands-B7Lxqvqu.mjs +0 -4
  88. package/dist/run-C7ExLhAm.mjs.map +0 -1
@@ -0,0 +1,350 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="feb8bf19-81c5-51df-8a73-68f475b463bc")}catch(e){}}();
3
+ import { c as looseObject, m as templateLiteral, n as _enum, o as discriminatedUnion, p as string, r as array, s as literal, u as object } from "./schemas-ZQiV98u4.mjs";
4
+ import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, writeFileSync } from "node:fs";
5
+ import { dirname, join, posix, relative, resolve, sep } from "node:path";
6
+ import { spawnSync } from "node:child_process";
7
+ import { createHash } from "node:crypto";
8
+ //#region src/services/release/revision.ts
9
+ /**
10
+ * The package revision: one digest over its files, sorted by path, bound to
11
+ * the given values (the ph-cli version), so the same files under another
12
+ * ph-cli are another revision.
13
+ */
14
+ function packageRevision(files, bindings) {
15
+ const hash = createHash("sha256");
16
+ for (const { path, sha256 } of [...files].sort(byPath)) hash.update(`${path}\0${sha256}\n`);
17
+ for (const key of Object.keys(bindings).sort()) hash.update(`binding:${key}\0${bindings[key]}\n`);
18
+ return `sha256:${hash.digest("hex")}`;
19
+ }
20
+ function byPath(left, right) {
21
+ return left.path < right.path ? -1 : left.path > right.path ? 1 : 0;
22
+ }
23
+ /** Paths added, removed or with other bytes in `after`, sorted. */
24
+ function changedPaths(before, after) {
25
+ const was = new Map(before.map(({ path, sha256 }) => [path, sha256]));
26
+ const now = new Map(after.map(({ path, sha256 }) => [path, sha256]));
27
+ return [.../* @__PURE__ */ new Set([...was.keys(), ...now.keys()])].filter((path) => was.get(path) !== now.get(path)).sort();
28
+ }
29
+ //#endregion
30
+ //#region src/services/release/approval.ts
31
+ /** Where `ph build --release` records its approval, relative to the package root. */
32
+ const RELEASE_APPROVAL_PATH = ".ph/build/release-approval.json";
33
+ /** The binding key of the ph-cli version in the package revision. */
34
+ const PH_CLI_BINDING = "ph-cli";
35
+ const fileDigest = object({
36
+ path: string(),
37
+ sha256: string().regex(/^[0-9a-f]{64}$/)
38
+ });
39
+ const hostFinding = looseObject({
40
+ kind: _enum([
41
+ "scalar-unbound",
42
+ "scalar-mismatch",
43
+ "definition-invalid",
44
+ "definition-mismatch"
45
+ ]),
46
+ documentType: string(),
47
+ scalar: string().optional()
48
+ });
49
+ const approvalSchema = object({
50
+ kind: literal("powerhouse.release-approval"),
51
+ formatVersion: literal(1),
52
+ phCliVersion: string(),
53
+ /** POSIX, relative to the package root: the output directory the build replaced. */
54
+ outDir: string(),
55
+ packageRevision: object({
56
+ digest: templateLiteral(["sha256:", string()]),
57
+ /** Compiler outputs left out besides the fixed exclusions, POSIX and package relative. */
58
+ excluded: array(string()).readonly()
59
+ }),
60
+ /** What `npm pack` publishes, sorted by path. */
61
+ publishedFiles: array(fileDigest).readonly(),
62
+ report: object({
63
+ profile: literal("release"),
64
+ status: _enum([
65
+ "ok",
66
+ "invalid",
67
+ "failed",
68
+ "skipped"
69
+ ]),
70
+ definitions: array(looseObject({
71
+ kind: string(),
72
+ key: string()
73
+ })).readonly()
74
+ }),
75
+ scalars: array(object({
76
+ scalar: string(),
77
+ packageName: string(),
78
+ version: string().nullable()
79
+ })).readonly(),
80
+ hostValidation: discriminatedUnion("completed", [object({
81
+ completed: literal(true),
82
+ findings: array(hostFinding).readonly()
83
+ }), object({
84
+ completed: literal(false),
85
+ reason: string(),
86
+ findings: array(hostFinding).readonly()
87
+ })])
88
+ });
89
+ /** Parses an approval file's text. */
90
+ function parseReleaseApproval(text) {
91
+ let json;
92
+ try {
93
+ json = JSON.parse(text);
94
+ } catch {
95
+ return {
96
+ kind: "unreadable",
97
+ reason: "it is not JSON"
98
+ };
99
+ }
100
+ const parsed = approvalSchema.safeParse(json);
101
+ if (parsed.success) return {
102
+ kind: "found",
103
+ approval: parsed.data
104
+ };
105
+ const [issue] = parsed.error.issues;
106
+ const at = issue.path.length > 0 ? ` at ${issue.path.join(".")}` : "";
107
+ return {
108
+ kind: "unreadable",
109
+ reason: `it is not an approval this ph-cli reads (${issue.message}${at})`
110
+ };
111
+ }
112
+ /** The decision when there is no approval to compare. */
113
+ function decisionWithoutApproval(read) {
114
+ return read.kind === "missing" ? {
115
+ decision: "missing",
116
+ reasons: [`there is no release approval (${RELEASE_APPROVAL_PATH}); ph build --release writes one`]
117
+ } : {
118
+ decision: "unreadable",
119
+ reasons: [`the release approval (${RELEASE_APPROVAL_PATH}) cannot be read: ${read.reason}`]
120
+ };
121
+ }
122
+ const LISTED = 5;
123
+ /** Up to five items, then how many more. */
124
+ function listed(items) {
125
+ const shown = items.slice(0, LISTED).join(", ");
126
+ return items.length > LISTED ? `${shown} and ${items.length - LISTED} more` : shown;
127
+ }
128
+ const plural = (count, one, many) => `${count} ${count === 1 ? one : many}`;
129
+ function describeFinding(finding) {
130
+ return finding.scalar === void 0 ? `${finding.kind} in ${finding.documentType}` : `${finding.kind} ${finding.scalar} in ${finding.documentType}`;
131
+ }
132
+ function refusalReasons(approval) {
133
+ const { report, hostValidation } = approval;
134
+ const reasons = [];
135
+ if (report.status === "invalid" || report.status === "failed") reasons.push(`its release check reported ${report.status}`);
136
+ if (!hostValidation.completed) reasons.push(`host validation did not complete: ${hostValidation.reason}`);
137
+ if (hostValidation.findings.length > 0) reasons.push(`host validation found ${plural(hostValidation.findings.length, "problem", "problems")}: ${listed(hostValidation.findings.map(describeFinding))}`);
138
+ return reasons;
139
+ }
140
+ function staleReasons(approval, current) {
141
+ const reasons = [];
142
+ if (approval.phCliVersion !== current.phCliVersion) reasons.push(`it was made by ph-cli ${approval.phCliVersion}, and this is ph-cli ${current.phCliVersion}`);
143
+ if (packageRevision(current.files, { ["ph-cli"]: approval.phCliVersion }) !== approval.packageRevision.digest) reasons.push("the package's files changed since the approval was made");
144
+ const approved = new Map(approval.publishedFiles.map(({ path, sha256 }) => [path, sha256]));
145
+ const now = new Map(current.publishedFiles.map(({ path, sha256 }) => [path, sha256]));
146
+ const added = [...now.keys()].filter((path) => !approved.has(path));
147
+ const removed = [...approved.keys()].filter((path) => !now.has(path));
148
+ const changed = [...now].filter(([path, sha256]) => approved.has(path) && approved.get(path) !== sha256);
149
+ const files = (paths, what) => `${plural(paths.length, "published file", "published files")} ${what} since the approval was made: ${listed(paths)}`;
150
+ if (added.length > 0) reasons.push(files(added, "added"));
151
+ if (removed.length > 0) reasons.push(files(removed, "removed"));
152
+ if (changed.length > 0) reasons.push(files(changed.map(([path]) => path), "changed"));
153
+ return reasons;
154
+ }
155
+ function decided(decision, reasons) {
156
+ if (reasons.length === 0) return void 0;
157
+ const [first, ...rest] = reasons;
158
+ return {
159
+ decision,
160
+ reasons: [first, ...rest]
161
+ };
162
+ }
163
+ /**
164
+ * Whether the package as it is now is the one the approval checked. Refused
165
+ * when the approval records a failed check; stale when ph-cli, the package's
166
+ * files or the published files changed since.
167
+ */
168
+ function verifyReleaseApproval(approval, current) {
169
+ return decided("refused", refusalReasons(approval)) ?? decided("stale", staleReasons(approval, current)) ?? {
170
+ decision: "approved",
171
+ reasons: []
172
+ };
173
+ }
174
+ //#endregion
175
+ //#region src/services/release/files.ts
176
+ const ALWAYS_EXCLUDED = /* @__PURE__ */ new Set([
177
+ "node_modules",
178
+ ".git",
179
+ ".ph"
180
+ ]);
181
+ const BUILD_SCRATCH = /^\..+\.ph-(stage|old)-/;
182
+ const toPosix = (path) => path.split(sep).join("/");
183
+ /** `path` relative to the package root, in POSIX form. */
184
+ function packagePath(packageRoot, path) {
185
+ return toPosix(relative(packageRoot, resolve(packageRoot, path)));
186
+ }
187
+ function sha256(bytes) {
188
+ return createHash("sha256").update(bytes).digest("hex");
189
+ }
190
+ /** A file's digest; a symlink's is its target text, which is not followed. */
191
+ function digestOf(packageRoot, path) {
192
+ const absolute = join(packageRoot, ...path.split("/"));
193
+ const stat = lstatSync(absolute, { throwIfNoEntry: false });
194
+ if (stat?.isSymbolicLink()) return {
195
+ path,
196
+ sha256: sha256(toPosix(readlinkSync(absolute)))
197
+ };
198
+ return stat?.isFile() ? {
199
+ path,
200
+ sha256: sha256(readFileSync(absolute))
201
+ } : void 0;
202
+ }
203
+ function insideWorkTree(packageRoot) {
204
+ const probe = spawnSync("git", ["rev-parse", "--is-inside-work-tree"], {
205
+ cwd: packageRoot,
206
+ encoding: "utf8",
207
+ stdio: [
208
+ "ignore",
209
+ "pipe",
210
+ "ignore"
211
+ ]
212
+ });
213
+ return probe.status === 0 && probe.stdout.trim() === "true";
214
+ }
215
+ /** Tracked and untracked files git does not ignore, relative to the package root. */
216
+ function gitFiles(packageRoot) {
217
+ const listed = spawnSync("git", [
218
+ "ls-files",
219
+ "-co",
220
+ "--exclude-standard",
221
+ "-z"
222
+ ], {
223
+ cwd: packageRoot,
224
+ encoding: "utf8",
225
+ maxBuffer: 268435456,
226
+ stdio: [
227
+ "ignore",
228
+ "pipe",
229
+ "pipe"
230
+ ]
231
+ });
232
+ if (listed.status !== 0) throw new Error(`git ls-files could not list the package's files: ${listed.stderr || listed.error?.message}`);
233
+ return [...new Set(listed.stdout.split("\0").filter(Boolean))];
234
+ }
235
+ /**
236
+ * Every file under the package root, by POSIX path, without entering a
237
+ * directory `included` rejects. Throws when a directory cannot be read.
238
+ */
239
+ function walkedFiles(packageRoot, included) {
240
+ const files = [];
241
+ const visit = (directory, prefix) => {
242
+ let entries;
243
+ try {
244
+ entries = readdirSync(directory, { withFileTypes: true });
245
+ } catch (error) {
246
+ throw new Error(`the package directory ${prefix || "."} cannot be read: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
247
+ }
248
+ for (const entry of entries) {
249
+ const path = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
250
+ if (!included(path)) continue;
251
+ if (entry.isDirectory()) visit(join(directory, entry.name), path);
252
+ else files.push(path);
253
+ }
254
+ };
255
+ visit(packageRoot, "");
256
+ return files;
257
+ }
258
+ /**
259
+ * The files the package revision reads, with their digests: what git tracks
260
+ * or would track inside a work tree, every file otherwise. Leaves out
261
+ * node_modules, .git, .ph, a build's stage, and each excluded path (the
262
+ * output directory, compiler outputs) with what is under it.
263
+ */
264
+ function revisionFiles(packageRoot, excluded) {
265
+ const included = (path) => !path.split("/").some((segment) => ALWAYS_EXCLUDED.has(segment) || BUILD_SCRATCH.test(segment)) && !excluded.some((exclusion) => path === exclusion || path.startsWith(`${exclusion}/`));
266
+ return (insideWorkTree(packageRoot) ? gitFiles(packageRoot) : walkedFiles(packageRoot, included)).filter(included).flatMap((path) => digestOf(packageRoot, path) ?? []).sort(byPath);
267
+ }
268
+ const packListing = array(object({
269
+ name: string(),
270
+ version: string(),
271
+ files: array(object({ path: string() }))
272
+ }));
273
+ const packageIdentity = object({
274
+ name: string(),
275
+ version: string()
276
+ });
277
+ /** npm refuses `--workspaces=false` while its configuration selects one. */
278
+ const SELECTS_WORKSPACE = /--no-workspaces and --workspace/;
279
+ const selectsAnotherPackage = (packageRoot) => `npm's configuration (a workspace setting in the environment or an .npmrc) selects a package other than the one in ${packageRoot}; the release approval covers that package only.`;
280
+ /**
281
+ * What `npm pack` would publish from the package root, with digests. The
282
+ * package's own scratch under .ph is left out: it changes on every build.
283
+ * Workspaces are off, so npm lists the root package or refuses; a listing
284
+ * of another package than the root's package.json names throws as well.
285
+ */
286
+ function publishedFiles(packageRoot) {
287
+ const packed = spawnSync("npm", [
288
+ "pack",
289
+ "--dry-run",
290
+ "--json",
291
+ "--ignore-scripts",
292
+ "--workspaces=false"
293
+ ], {
294
+ cwd: packageRoot,
295
+ encoding: "utf8",
296
+ maxBuffer: 268435456,
297
+ stdio: [
298
+ "ignore",
299
+ "pipe",
300
+ "pipe"
301
+ ],
302
+ shell: process.platform === "win32"
303
+ });
304
+ if (packed.status !== 0) {
305
+ if (SELECTS_WORKSPACE.test(`${packed.stdout}${packed.stderr}`)) throw new Error(selectsAnotherPackage(packageRoot));
306
+ throw new Error(`npm pack could not list the published files: ${(packed.stderr || packed.error?.message || packed.stdout).trim()}`);
307
+ }
308
+ const listings = packListing.parse(JSON.parse(packed.stdout));
309
+ const root = packageIdentity.parse(JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8")));
310
+ const packs = listings.map(({ name, version }) => `${name}@${version}`);
311
+ const [listing] = listings;
312
+ if (listings.length !== 1 || listing.name !== root.name || listing.version !== root.version) throw new Error(`npm pack lists ${packs.join(", ") || "no package"}, not ${root.name}@${root.version}: ${selectsAnotherPackage(packageRoot)}`);
313
+ return listing.files.map(({ path }) => posix.normalize(toPosix(path))).filter((path) => path !== ".ph" && !path.startsWith(".ph/")).flatMap((path) => {
314
+ const digest = digestOf(packageRoot, path);
315
+ if (digest === void 0) throw new Error(`npm pack lists ${path}, which cannot be read.`);
316
+ return [digest];
317
+ }).sort(byPath);
318
+ }
319
+ const approvalFile = (packageRoot) => join(packageRoot, ...RELEASE_APPROVAL_PATH.split("/"));
320
+ function readReleaseApproval(packageRoot) {
321
+ const file = approvalFile(packageRoot);
322
+ if (!existsSync(file)) return { kind: "missing" };
323
+ let text;
324
+ try {
325
+ text = readFileSync(file, "utf8");
326
+ } catch (error) {
327
+ return {
328
+ kind: "unreadable",
329
+ reason: error instanceof Error ? error.message : String(error)
330
+ };
331
+ }
332
+ return parseReleaseApproval(text);
333
+ }
334
+ /** Replaces the approval in one rename, so a reader never sees half of one. */
335
+ function writeReleaseApproval(packageRoot, approval) {
336
+ const file = approvalFile(packageRoot);
337
+ mkdirSync(dirname(file), { recursive: true });
338
+ const temporary = `${file}.${process.pid}.tmp`;
339
+ try {
340
+ writeFileSync(temporary, `${JSON.stringify(approval, null, 2)}\n`);
341
+ renameSync(temporary, file);
342
+ } finally {
343
+ rmSync(temporary, { force: true });
344
+ }
345
+ }
346
+ //#endregion
347
+ export { writeReleaseApproval as a, decisionWithoutApproval as c, changedPaths as d, packageRevision as f, revisionFiles as i, listed as l, publishedFiles as n, PH_CLI_BINDING as o, readReleaseApproval as r, RELEASE_APPROVAL_PATH as s, packagePath as t, verifyReleaseApproval as u };
348
+
349
+ //# sourceMappingURL=files-D05VjxVj.mjs.map
350
+ //# debugId=feb8bf19-81c5-51df-8a73-68f475b463bc
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files-D05VjxVj.mjs","sources":["../src/services/release/revision.ts","../src/services/release/approval.ts","../src/services/release/files.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\n\nexport type Sha256 = `sha256:${string}`;\n\n/** One file, by its POSIX path relative to the package root, and the hex sha256 of its bytes. */\nexport type FileDigest = { readonly path: string; readonly sha256: string };\n\n/**\n * The package revision: one digest over its files, sorted by path, bound to\n * the given values (the ph-cli version), so the same files under another\n * ph-cli are another revision.\n */\nexport function packageRevision(\n files: readonly FileDigest[],\n bindings: Readonly<Record<string, string>>,\n): Sha256 {\n const hash = createHash(\"sha256\");\n for (const { path, sha256 } of [...files].sort(byPath)) {\n hash.update(`${path}\\0${sha256}\\n`);\n }\n for (const key of Object.keys(bindings).sort()) {\n hash.update(`binding:${key}\\0${bindings[key]}\\n`);\n }\n return `sha256:${hash.digest(\"hex\")}`;\n}\n\nexport function byPath(left: FileDigest, right: FileDigest): number {\n return left.path < right.path ? -1 : left.path > right.path ? 1 : 0;\n}\n\n/** Paths added, removed or with other bytes in `after`, sorted. */\nexport function changedPaths(\n before: readonly FileDigest[],\n after: readonly FileDigest[],\n): string[] {\n const was = new Map(before.map(({ path, sha256 }) => [path, sha256]));\n const now = new Map(after.map(({ path, sha256 }) => [path, sha256]));\n return [...new Set([...was.keys(), ...now.keys()])]\n .filter((path) => was.get(path) !== now.get(path))\n .sort();\n}\n","import { z } from \"zod\";\nimport { type FileDigest, packageRevision } from \"./revision.js\";\n\n/** Where `ph build --release` records its approval, relative to the package root. */\nexport const RELEASE_APPROVAL_PATH = \".ph/build/release-approval.json\";\n\n/** The binding key of the ph-cli version in the package revision. */\nexport const PH_CLI_BINDING = \"ph-cli\";\n\nconst fileDigest = z.object({\n path: z.string(),\n sha256: z.string().regex(/^[0-9a-f]{64}$/),\n});\n\nconst hostFinding = z.looseObject({\n kind: z.enum([\n \"scalar-unbound\",\n \"scalar-mismatch\",\n \"definition-invalid\",\n \"definition-mismatch\",\n ]),\n documentType: z.string(),\n scalar: z.string().optional(),\n});\n\nconst approvalSchema = z.object({\n kind: z.literal(\"powerhouse.release-approval\"),\n formatVersion: z.literal(1),\n phCliVersion: z.string(),\n /** POSIX, relative to the package root: the output directory the build replaced. */\n outDir: z.string(),\n packageRevision: z.object({\n digest: z.templateLiteral([\"sha256:\", z.string()]),\n /** Compiler outputs left out besides the fixed exclusions, POSIX and package relative. */\n excluded: z.array(z.string()).readonly(),\n }),\n /** What `npm pack` publishes, sorted by path. */\n publishedFiles: z.array(fileDigest).readonly(),\n report: z.object({\n profile: z.literal(\"release\"),\n status: z.enum([\"ok\", \"invalid\", \"failed\", \"skipped\"]),\n definitions: z\n .array(z.looseObject({ kind: z.string(), key: z.string() }))\n .readonly(),\n }),\n scalars: z\n .array(\n z.object({\n scalar: z.string(),\n packageName: z.string(),\n version: z.string().nullable(),\n }),\n )\n .readonly(),\n hostValidation: z.discriminatedUnion(\"completed\", [\n z.object({\n completed: z.literal(true),\n findings: z.array(hostFinding).readonly(),\n }),\n z.object({\n completed: z.literal(false),\n reason: z.string(),\n findings: z.array(hostFinding).readonly(),\n }),\n ]),\n});\n\n/** `.ph/build/release-approval.json`: what a successful `ph build --release` checked and built. */\nexport type ReleaseApproval = z.infer<typeof approvalSchema>;\n\n/** One scalar the package's models use, and the package and version that provide it. */\nexport type ScalarBinding = ReleaseApproval[\"scalars\"][number];\n\nexport type ApprovalRead =\n | { readonly kind: \"missing\" }\n | { readonly kind: \"unreadable\"; readonly reason: string }\n | { readonly kind: \"found\"; readonly approval: ReleaseApproval };\n\n/** Parses an approval file's text. */\nexport function parseReleaseApproval(\n text: string,\n): Exclude<ApprovalRead, { kind: \"missing\" }> {\n let json: unknown;\n try {\n json = JSON.parse(text);\n } catch {\n return { kind: \"unreadable\", reason: \"it is not JSON\" };\n }\n const parsed = approvalSchema.safeParse(json);\n if (parsed.success) return { kind: \"found\", approval: parsed.data };\n const [issue] = parsed.error.issues;\n const at = issue.path.length > 0 ? ` at ${issue.path.join(\".\")}` : \"\";\n return {\n kind: \"unreadable\",\n reason: `it is not an approval this ph-cli reads (${issue.message}${at})`,\n };\n}\n\n/** The package as it is now, read with the approval's output directory and exclusions. */\nexport type CurrentRelease = {\n readonly phCliVersion: string;\n /** The files the package revision reads. */\n readonly files: readonly FileDigest[];\n readonly publishedFiles: readonly FileDigest[];\n};\n\ntype Reasons = readonly [string, ...string[]];\n\n/** Whether the package may be published as the approval describes it, and why not. */\nexport type ReleaseDecision =\n | { readonly decision: \"approved\"; readonly reasons: readonly [] }\n | {\n readonly decision: \"missing\" | \"unreadable\" | \"stale\" | \"refused\";\n readonly reasons: Reasons;\n };\n\n/** The decision when there is no approval to compare. */\nexport function decisionWithoutApproval(\n read: Exclude<ApprovalRead, { kind: \"found\" }>,\n): ReleaseDecision {\n return read.kind === \"missing\"\n ? {\n decision: \"missing\",\n reasons: [\n `there is no release approval (${RELEASE_APPROVAL_PATH}); ph build --release writes one`,\n ],\n }\n : {\n decision: \"unreadable\",\n reasons: [\n `the release approval (${RELEASE_APPROVAL_PATH}) cannot be read: ${read.reason}`,\n ],\n };\n}\n\nconst LISTED = 5;\n\n/** Up to five items, then how many more. */\nexport function listed(items: readonly string[]): string {\n const shown = items.slice(0, LISTED).join(\", \");\n return items.length > LISTED\n ? `${shown} and ${items.length - LISTED} more`\n : shown;\n}\n\nconst plural = (count: number, one: string, many: string) =>\n `${count} ${count === 1 ? one : many}`;\n\nfunction describeFinding(\n finding: ReleaseApproval[\"hostValidation\"][\"findings\"][number],\n): string {\n return finding.scalar === undefined\n ? `${finding.kind} in ${finding.documentType}`\n : `${finding.kind} ${finding.scalar} in ${finding.documentType}`;\n}\n\nfunction refusalReasons(approval: ReleaseApproval): string[] {\n const { report, hostValidation } = approval;\n const reasons: string[] = [];\n if (report.status === \"invalid\" || report.status === \"failed\") {\n reasons.push(`its release check reported ${report.status}`);\n }\n if (!hostValidation.completed) {\n reasons.push(`host validation did not complete: ${hostValidation.reason}`);\n }\n if (hostValidation.findings.length > 0) {\n reasons.push(\n `host validation found ${plural(hostValidation.findings.length, \"problem\", \"problems\")}: ${listed(hostValidation.findings.map(describeFinding))}`,\n );\n }\n return reasons;\n}\n\nfunction staleReasons(\n approval: ReleaseApproval,\n current: CurrentRelease,\n): string[] {\n const reasons: string[] = [];\n if (approval.phCliVersion !== current.phCliVersion) {\n reasons.push(\n `it was made by ph-cli ${approval.phCliVersion}, and this is ph-cli ${current.phCliVersion}`,\n );\n }\n // Under the approval's own binding, so a new ph-cli alone does not read as edited files.\n const revision = packageRevision(current.files, {\n [PH_CLI_BINDING]: approval.phCliVersion,\n });\n if (revision !== approval.packageRevision.digest) {\n reasons.push(\"the package's files changed since the approval was made\");\n }\n const approved = new Map(\n approval.publishedFiles.map(({ path, sha256 }) => [path, sha256]),\n );\n const now = new Map(\n current.publishedFiles.map(({ path, sha256 }) => [path, sha256]),\n );\n const added = [...now.keys()].filter((path) => !approved.has(path));\n const removed = [...approved.keys()].filter((path) => !now.has(path));\n const changed = [...now].filter(\n ([path, sha256]) => approved.has(path) && approved.get(path) !== sha256,\n );\n const files = (paths: readonly string[], what: string) =>\n `${plural(paths.length, \"published file\", \"published files\")} ${what} since the approval was made: ${listed(paths)}`;\n if (added.length > 0) reasons.push(files(added, \"added\"));\n if (removed.length > 0) reasons.push(files(removed, \"removed\"));\n if (changed.length > 0) {\n reasons.push(\n files(\n changed.map(([path]) => path),\n \"changed\",\n ),\n );\n }\n return reasons;\n}\n\nfunction decided(\n decision: \"stale\" | \"refused\",\n reasons: readonly string[],\n): ReleaseDecision | undefined {\n if (reasons.length === 0) return undefined;\n const [first, ...rest] = reasons;\n return { decision, reasons: [first, ...rest] };\n}\n\n/**\n * Whether the package as it is now is the one the approval checked. Refused\n * when the approval records a failed check; stale when ph-cli, the package's\n * files or the published files changed since.\n */\nexport function verifyReleaseApproval(\n approval: ReleaseApproval,\n current: CurrentRelease,\n): ReleaseDecision {\n return (\n decided(\"refused\", refusalReasons(approval)) ??\n decided(\"stale\", staleReasons(approval, current)) ?? {\n decision: \"approved\",\n reasons: [],\n }\n );\n}\n","import { spawnSync } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport {\n type Dirent,\n existsSync,\n lstatSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n readlinkSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { dirname, join, posix, relative, resolve, sep } from \"node:path\";\nimport { z } from \"zod\";\nimport {\n type ApprovalRead,\n parseReleaseApproval,\n RELEASE_APPROVAL_PATH,\n type ReleaseApproval,\n} from \"./approval.js\";\nimport { byPath, type FileDigest } from \"./revision.js\";\n\nconst ALWAYS_EXCLUDED = new Set([\"node_modules\", \".git\", \".ph\"]);\n// A build's stage and retired tree, beside its output while it runs.\nconst BUILD_SCRATCH = /^\\..+\\.ph-(stage|old)-/;\n\nconst toPosix = (path: string) => path.split(sep).join(\"/\");\n\n/** `path` relative to the package root, in POSIX form. */\nexport function packagePath(packageRoot: string, path: string): string {\n return toPosix(relative(packageRoot, resolve(packageRoot, path)));\n}\n\nfunction sha256(bytes: string | Buffer): string {\n return createHash(\"sha256\").update(bytes).digest(\"hex\");\n}\n\n/** A file's digest; a symlink's is its target text, which is not followed. */\nfunction digestOf(packageRoot: string, path: string): FileDigest | undefined {\n const absolute = join(packageRoot, ...path.split(\"/\"));\n const stat = lstatSync(absolute, { throwIfNoEntry: false });\n if (stat?.isSymbolicLink()) {\n return { path, sha256: sha256(toPosix(readlinkSync(absolute))) };\n }\n return stat?.isFile()\n ? { path, sha256: sha256(readFileSync(absolute)) }\n : undefined;\n}\n\nfunction insideWorkTree(packageRoot: string): boolean {\n const probe = spawnSync(\"git\", [\"rev-parse\", \"--is-inside-work-tree\"], {\n cwd: packageRoot,\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n });\n return probe.status === 0 && probe.stdout.trim() === \"true\";\n}\n\n/** Tracked and untracked files git does not ignore, relative to the package root. */\nfunction gitFiles(packageRoot: string): string[] {\n const listed = spawnSync(\n \"git\",\n [\"ls-files\", \"-co\", \"--exclude-standard\", \"-z\"],\n {\n cwd: packageRoot,\n encoding: \"utf8\",\n maxBuffer: 256 * 1024 * 1024,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n },\n );\n if (listed.status !== 0) {\n throw new Error(\n `git ls-files could not list the package's files: ${listed.stderr || listed.error?.message}`,\n );\n }\n return [...new Set(listed.stdout.split(\"\\0\").filter(Boolean))];\n}\n\n/**\n * Every file under the package root, by POSIX path, without entering a\n * directory `included` rejects. Throws when a directory cannot be read.\n */\nfunction walkedFiles(\n packageRoot: string,\n included: (path: string) => boolean,\n): string[] {\n const files: string[] = [];\n const visit = (directory: string, prefix: string) => {\n let entries: Dirent[];\n try {\n entries = readdirSync(directory, { withFileTypes: true });\n } catch (error) {\n throw new Error(\n `the package directory ${prefix || \".\"} cannot be read: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n for (const entry of entries) {\n const path = prefix === \"\" ? entry.name : `${prefix}/${entry.name}`;\n if (!included(path)) continue;\n if (entry.isDirectory()) {\n visit(join(directory, entry.name), path);\n } else {\n files.push(path);\n }\n }\n };\n visit(packageRoot, \"\");\n return files;\n}\n\n/**\n * The files the package revision reads, with their digests: what git tracks\n * or would track inside a work tree, every file otherwise. Leaves out\n * node_modules, .git, .ph, a build's stage, and each excluded path (the\n * output directory, compiler outputs) with what is under it.\n */\nexport function revisionFiles(\n packageRoot: string,\n excluded: readonly string[],\n): FileDigest[] {\n const included = (path: string) =>\n !path\n .split(\"/\")\n .some(\n (segment) =>\n ALWAYS_EXCLUDED.has(segment) || BUILD_SCRATCH.test(segment),\n ) &&\n !excluded.some(\n (exclusion) => path === exclusion || path.startsWith(`${exclusion}/`),\n );\n const paths = insideWorkTree(packageRoot)\n ? gitFiles(packageRoot)\n : walkedFiles(packageRoot, included);\n return paths\n .filter(included)\n .flatMap((path) => digestOf(packageRoot, path) ?? [])\n .sort(byPath);\n}\n\nconst packListing = z.array(\n z.object({\n name: z.string(),\n version: z.string(),\n files: z.array(z.object({ path: z.string() })),\n }),\n);\n\nconst packageIdentity = z.object({ name: z.string(), version: z.string() });\n\n/** npm refuses `--workspaces=false` while its configuration selects one. */\nconst SELECTS_WORKSPACE = /--no-workspaces and --workspace/;\n\nconst selectsAnotherPackage = (packageRoot: string) =>\n `npm's configuration (a workspace setting in the environment or an .npmrc) selects a package other than the one in ${packageRoot}; the release approval covers that package only.`;\n\n/**\n * What `npm pack` would publish from the package root, with digests. The\n * package's own scratch under .ph is left out: it changes on every build.\n * Workspaces are off, so npm lists the root package or refuses; a listing\n * of another package than the root's package.json names throws as well.\n */\nexport function publishedFiles(packageRoot: string): FileDigest[] {\n const packed = spawnSync(\n \"npm\",\n [\"pack\", \"--dry-run\", \"--json\", \"--ignore-scripts\", \"--workspaces=false\"],\n {\n cwd: packageRoot,\n encoding: \"utf8\",\n maxBuffer: 256 * 1024 * 1024,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n shell: process.platform === \"win32\",\n },\n );\n if (packed.status !== 0) {\n if (SELECTS_WORKSPACE.test(`${packed.stdout}${packed.stderr}`)) {\n throw new Error(selectsAnotherPackage(packageRoot));\n }\n throw new Error(\n `npm pack could not list the published files: ${(packed.stderr || packed.error?.message || packed.stdout).trim()}`,\n );\n }\n const listings = packListing.parse(JSON.parse(packed.stdout));\n const root = packageIdentity.parse(\n JSON.parse(readFileSync(join(packageRoot, \"package.json\"), \"utf8\")),\n );\n const packs = listings.map(({ name, version }) => `${name}@${version}`);\n const [listing] = listings;\n if (\n listings.length !== 1 ||\n listing.name !== root.name ||\n listing.version !== root.version\n ) {\n throw new Error(\n `npm pack lists ${packs.join(\", \") || \"no package\"}, not ${root.name}@${root.version}: ${selectsAnotherPackage(packageRoot)}`,\n );\n }\n return listing.files\n .map(({ path }) => posix.normalize(toPosix(path)))\n .filter((path) => path !== \".ph\" && !path.startsWith(\".ph/\"))\n .flatMap((path) => {\n const digest = digestOf(packageRoot, path);\n if (digest === undefined) {\n throw new Error(`npm pack lists ${path}, which cannot be read.`);\n }\n return [digest];\n })\n .sort(byPath);\n}\n\nconst approvalFile = (packageRoot: string) =>\n join(packageRoot, ...RELEASE_APPROVAL_PATH.split(\"/\"));\n\nexport function readReleaseApproval(packageRoot: string): ApprovalRead {\n const file = approvalFile(packageRoot);\n if (!existsSync(file)) return { kind: \"missing\" };\n let text: string;\n try {\n text = readFileSync(file, \"utf8\");\n } catch (error) {\n return {\n kind: \"unreadable\",\n reason: error instanceof Error ? error.message : String(error),\n };\n }\n return parseReleaseApproval(text);\n}\n\n/** Replaces the approval in one rename, so a reader never sees half of one. */\nexport function writeReleaseApproval(\n packageRoot: string,\n approval: ReleaseApproval,\n): void {\n const file = approvalFile(packageRoot);\n mkdirSync(dirname(file), { recursive: true });\n const temporary = `${file}.${process.pid}.tmp`;\n try {\n writeFileSync(temporary, `${JSON.stringify(approval, null, 2)}\\n`);\n renameSync(temporary, file);\n } finally {\n rmSync(temporary, { force: true });\n }\n}\n"],"names":["z.object","z.string","z.looseObject","z.enum","z.literal","z.templateLiteral","z.array","z\n .array","z\n .array","z.discriminatedUnion","z.array","z.object","z.string"],"mappings":";;;;;;;;;;;;;AAYA,SAAgB,gBACd,OACA,UACQ;CACR,MAAM,OAAO,WAAW,QAAQ;CAChC,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,MAAM,GACnD,KAAK,OAAO,GAAG,KAAK,IAAI,OAAO,GAAG;CAEpC,KAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,KAAK,GAC3C,KAAK,OAAO,WAAW,IAAI,IAAI,SAAS,KAAK,GAAG;CAElD,OAAO,UAAU,KAAK,OAAO,KAAK;AACpC;AAEA,SAAgB,OAAO,MAAkB,OAA2B;CAClE,OAAO,KAAK,OAAO,MAAM,OAAO,KAAK,KAAK,OAAO,MAAM,OAAO,IAAI;AACpE;;AAGA,SAAgB,aACd,QACA,OACU;CACV,MAAM,MAAM,IAAI,IAAI,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC,MAAM,MAAM,CAAC,CAAC;CACpE,MAAM,MAAM,IAAI,IAAI,MAAM,KAAK,EAAE,MAAM,aAAa,CAAC,MAAM,MAAM,CAAC,CAAC;CACnE,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,IAAI,KAAK,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAChD,QAAQ,SAAS,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,CAAC,CAAC,CACjD,KAAK;AACV;;;;ACpCA,MAAa,wBAAwB;;A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EACR,OAAO,WAAW,EAAE,OAAO,KAAK,CAAC;CACnC;AACF","debug_id":"feb8bf19-81c5-51df-8a73-68f475b463bc"}
@@ -1,7 +1,7 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="be895ade-c967-52d6-bb2f-bd4d1bc989a8")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a3df155f-b2e9-55a8-b53b-99549693cb80")}catch(e){}}();
3
3
  import { t as isUniformRunnersEnabled } from "./feature-flags-xwqcHEWC.mjs";
4
- import { M as probeHostsFolder } from "./compound-Cv5yxdLC-DAYAbASE.mjs";
4
+ import { M as probeHostsFolder } from "./compound-DO_mvh0O-D254asEo.mjs";
5
5
  import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-BOHBmThq.mjs";
6
6
  import { n as selectProjectModelGeneration } from "./authoring-mode-DWbbsuWh.mjs";
7
7
  import { t as startGenerateHosts } from "./generate-hosts-BFmPIW2X.mjs";
@@ -32,5 +32,5 @@ async function startGenerateAll(args, projectDir) {
32
32
  //#endregion
33
33
  export { startGenerateAll };
34
34
 
35
- //# sourceMappingURL=generate-all-BWpiTcED.mjs.map
36
- //# debugId=be895ade-c967-52d6-bb2f-bd4d1bc989a8
35
+ //# sourceMappingURL=generate-all-CMpNPpD8.mjs.map
36
+ //# debugId=a3df155f-b2e9-55a8-b53b-99549693cb80
@@ -1 +1 @@
1
- {"version":3,"file":"generate-all-BWpiTcED.mjs","sources":["../src/services/generate-all.ts"],"sourcesContent":["import { buildTsMorphProject } from \"@powerhousedao/codegen/utils\";\nimport { extractAllDocuments, saveSpec } from \"@powerhousedao/vetra/codegen\";\nimport { probeHostsFolder } from \"@powerhousedao/host-core\";\nimport { isUniformRunnersEnabled } from \"../utils/feature-flags.js\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\nimport { selectProjectModelGeneration } from \"./definitions/authoring-mode.js\";\nimport { startGenerateHosts } from \"./generate-hosts.js\";\n\nexport async function startGenerateAll(\n args: { extract?: boolean },\n projectDir: string,\n) {\n const project = buildTsMorphProject(projectDir);\n if (args.extract) {\n const all = extractAllDocuments(project);\n for (const doc of [\n ...all.documentModels,\n ...all.editors,\n ...all.processors,\n ...all.subgraphs,\n ...all.apps,\n ]) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n await selectProjectModelGeneration(projectDir).generateAll(project);\n await project.save();\n await warnSubgraphTypeConflicts(projectDir);\n if (\n isUniformRunnersEnabled() &&\n probeHostsFolder(projectDir).kind === \"present\" &&\n !(await startGenerateHosts(projectDir))\n ) {\n process.exitCode = 1;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAQA,eAAsB,iBACpB,MACA,YACA;CACA,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,KAAK,SAAS;EAChB,MAAM,MAAM,oBAAoB,OAAO;EACvC,KAAK,MAAM,OAAO;GAChB,GAAG,IAAI;GACP,GAAG,IAAI;GACP,GAAG,IAAI;GACP,GAAG,IAAI;GACP,GAAG,IAAI;EACT,GAAG;GACD,MAAM,OAAO,MAAM,SAAS,KAAK,UAAU;GAC3C,QAAQ,IAAI,SAAS,MAAM;EAC7B;EACA;CACF;CACA,MAAM,6BAA6B,UAAU,CAAC,CAAC,YAAY,OAAO;CAClE,MAAM,QAAQ,KAAK;CACnB,MAAM,0BAA0B,UAAU;CAC1C,IACE,wBAAwB,KACxB,iBAAiB,UAAU,CAAC,CAAC,SAAS,aACtC,CAAE,MAAM,mBAAmB,UAAU,GAErC,QAAQ,WAAW;AAEvB","debug_id":"be895ade-c967-52d6-bb2f-bd4d1bc989a8"}
1
+ {"version":3,"file":"generate-all-CMpNPpD8.mjs","sources":["../src/services/generate-all.ts"],"sourcesContent":["import { buildTsMorphProject } from \"@powerhousedao/codegen/utils\";\nimport { extractAllDocuments, saveSpec } from \"@powerhousedao/vetra/codegen\";\nimport { probeHostsFolder } from \"@powerhousedao/host-core\";\nimport { isUniformRunnersEnabled } from \"../utils/feature-flags.js\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\nimport { selectProjectModelGeneration } from \"./definitions/authoring-mode.js\";\nimport { startGenerateHosts } from \"./generate-hosts.js\";\n\nexport async function startGenerateAll(\n args: { extract?: boolean },\n projectDir: string,\n) {\n const project = buildTsMorphProject(projectDir);\n if (args.extract) {\n const all = extractAllDocuments(project);\n for (const doc of [\n ...all.documentModels,\n ...all.editors,\n ...all.processors,\n ...all.subgraphs,\n ...all.apps,\n ]) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n await selectProjectModelGeneration(projectDir).generateAll(project);\n await project.save();\n await warnSubgraphTypeConflicts(projectDir);\n if (\n isUniformRunnersEnabled() &&\n probeHostsFolder(projectDir).kind === \"present\" &&\n !(await startGenerateHosts(projectDir))\n ) {\n process.exitCode = 1;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAQA,eAAsB,iBACpB,MACA,YACA;CACA,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,KAAK,SAAS;EAChB,MAAM,MAAM,oBAAoB,OAAO;EACvC,KAAK,MAAM,OAAO;GAChB,GAAG,IAAI;GACP,GAAG,IAAI;GACP,GAAG,IAAI;GACP,GAAG,IAAI;GACP,GAAG,IAAI;EACT,GAAG;GACD,MAAM,OAAO,MAAM,SAAS,KAAK,UAAU;GAC3C,QAAQ,IAAI,SAAS,MAAM;EAC7B;EACA;CACF;CACA,MAAM,6BAA6B,UAAU,CAAC,CAAC,YAAY,OAAO;CAClE,MAAM,QAAQ,KAAK;CACnB,MAAM,0BAA0B,UAAU;CAC1C,IACE,wBAAwB,KACxB,iBAAiB,UAAU,CAAC,CAAC,SAAS,aACtC,CAAE,MAAM,mBAAmB,UAAU,GAErC,QAAQ,WAAW;AAEvB","debug_id":"a3df155f-b2e9-55a8-b53b-99549693cb80"}
@@ -1,6 +1,6 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="72fb1c62-bed0-553d-89df-e6b3d199ae33")}catch(e){}}();
3
- import { c as number, d as string, f as union, i as boolean, r as array, u as strictObject } from "./schemas-ByfuhvAb.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7388f6d3-8c22-5cac-b28f-125dde670f13")}catch(e){}}();
3
+ import { f as strictObject, h as union, i as boolean, l as number, p as string, r as array } from "./schemas-ZQiV98u4.mjs";
4
4
  import "node:module";
5
5
  import fs from "node:fs";
6
6
  import path from "node:path";
@@ -319,5 +319,5 @@ function startGenerateDesktopShell(args, cwd) {
319
319
  //#endregion
320
320
  export { startGenerateDesktopShell };
321
321
 
322
- //# sourceMappingURL=generate-desktop-shell-NeH89X6S.mjs.map
323
- //# debugId=72fb1c62-bed0-553d-89df-e6b3d199ae33
322
+ //# sourceMappingURL=generate-desktop-shell-B-Rf7ds8.mjs.map
323
+ //# debugId=7388f6d3-8c22-5cac-b28f-125dde670f13