@powerhousedao/ph-cli 6.4.0-next.3 → 6.4.0-next.5
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/auth-5bqHASGL.mjs +4 -0
- package/dist/auth-DYknkWfW.mjs +23 -0
- package/dist/auth-DYknkWfW.mjs.map +1 -0
- package/dist/{build-B-rPwjM8.mjs → build-CBKlv5E3.mjs} +8 -8
- package/dist/{build-B-rPwjM8.mjs.map → build-CBKlv5E3.mjs.map} +1 -1
- package/dist/build-Dr1lnv4h.mjs +4 -0
- package/dist/{check-B7C3Vi_b.mjs → check-CW81vbe9.mjs} +4 -4
- package/dist/{check-B7C3Vi_b.mjs.map → check-CW81vbe9.mjs.map} +1 -1
- package/dist/{check-DM7UdFTK.mjs → check-Cx_AeBQe.mjs} +7 -7
- package/dist/check-Cx_AeBQe.mjs.map +1 -0
- package/dist/{check-DeUTd514.mjs → check-DhFd9tO8.mjs} +3 -3
- package/dist/{cli-connect-override-Bx_g3-ZE.mjs → cli-connect-override-DKxY3lCi.mjs} +4 -4
- package/dist/{cli-connect-override-Bx_g3-ZE.mjs.map → cli-connect-override-DKxY3lCi.mjs.map} +1 -1
- package/dist/cli.mjs +9 -8
- package/dist/cli.mjs.map +1 -1
- package/dist/{compound-Q9sZSEZF-DQvtoigb.mjs → compound-g6x_KkWp-Bs7olmlI.mjs} +465 -361
- package/dist/compound-g6x_KkWp-Bs7olmlI.mjs.map +1 -0
- package/dist/{connect-build-CaTxdYcc.mjs → connect-build-DpGUrtct.mjs} +5 -5
- package/dist/{connect-build-CaTxdYcc.mjs.map → connect-build-DpGUrtct.mjs.map} +1 -1
- package/dist/{connect-config-A-U83U8U.mjs → connect-config-BpzwJln3.mjs} +4 -4
- package/dist/{connect-config-A-U83U8U.mjs.map → connect-config-BpzwJln3.mjs.map} +1 -1
- package/dist/{connect-preview-BvxXGo_W.mjs → connect-preview-B_E4SIV6.mjs} +21 -4
- package/dist/connect-preview-B_E4SIV6.mjs.map +1 -0
- package/dist/connect-studio-BPZOcwUM.mjs +214 -0
- package/dist/connect-studio-BPZOcwUM.mjs.map +1 -0
- package/dist/credentials-CmtYywgk.mjs +132 -0
- package/dist/credentials-CmtYywgk.mjs.map +1 -0
- package/dist/definitions-worker.mjs +4 -4
- package/dist/definitions-worker.mjs.map +1 -1
- package/dist/{dev-host-RhWeATKB.mjs → dev-host-CM-Jg2kY.mjs} +4 -4
- package/dist/{dev-host-RhWeATKB.mjs.map → dev-host-CM-Jg2kY.mjs.map} +1 -1
- package/dist/{dist-D_UjZsgt.mjs → dist-DPj_FB8H.mjs} +5 -5
- package/dist/dist-DPj_FB8H.mjs.map +1 -0
- package/dist/{explain-DbbHpa61.mjs → explain-DQ5ymlco.mjs} +5 -5
- package/dist/{explain-DbbHpa61.mjs.map → explain-DQ5ymlco.mjs.map} +1 -1
- package/dist/{export-FduYVQEM.mjs → export-CzeF8pob.mjs} +4 -4
- package/dist/{export-FduYVQEM.mjs.map → export-CzeF8pob.mjs.map} +1 -1
- package/dist/{files-DEHg350R.mjs → files-D6_euBBn.mjs} +4 -4
- package/dist/{files-DEHg350R.mjs.map → files-D6_euBBn.mjs.map} +1 -1
- package/dist/{generate-all-BE8UmbJv.mjs → generate-all-B9MwWXlq.mjs} +4 -4
- package/dist/{generate-all-BE8UmbJv.mjs.map → generate-all-B9MwWXlq.mjs.map} +1 -1
- package/dist/{generate-document-model-DSYPTMZg.mjs → generate-document-model-D3LKY1D7.mjs} +6 -8
- package/dist/generate-document-model-D3LKY1D7.mjs.map +1 -0
- package/dist/{generate-subgraph-EQ2ZjMp9.mjs → generate-subgraph-Q1VLh3SC.mjs} +10 -17
- package/dist/generate-subgraph-Q1VLh3SC.mjs.map +1 -0
- package/dist/{get-version-7oKMD8Gt.mjs → get-version-CTP__ORu.mjs} +4 -4
- package/dist/{get-version-7oKMD8Gt.mjs.map → get-version-CTP__ORu.mjs.map} +1 -1
- package/dist/identity-DXZFeQfC.mjs +137 -0
- package/dist/identity-DXZFeQfC.mjs.map +1 -0
- package/dist/{index-Bs1PfL3W.d.mts → index-aosqo7aM.d.mts} +5 -4
- package/dist/index-aosqo7aM.d.mts.map +1 -0
- package/dist/{inspect-CulIpVsF.mjs → inspect-BgKI8Fhd.mjs} +6 -6
- package/dist/{inspect-CulIpVsF.mjs.map → inspect-BgKI8Fhd.mjs.map} +1 -1
- package/dist/{keyframes-bFo9iDhT.mjs → keyframes-BkeORfEu.mjs} +4 -4
- package/dist/{keyframes-bFo9iDhT.mjs.map → keyframes-BkeORfEu.mjs.map} +1 -1
- package/dist/{mcp-CcZT9zT9.mjs → mcp-gcG7SW9L.mjs} +149 -7
- package/dist/mcp-gcG7SW9L.mjs.map +1 -0
- package/dist/{migrate-Ddr7YAtM.mjs → migrate-BaWZhorc.mjs} +4 -4
- package/dist/{migrate-Ddr7YAtM.mjs.map → migrate-BaWZhorc.mjs.map} +1 -1
- package/dist/{migrate-document-models-X_mVTljj.mjs → migrate-document-models-DYmkJzq3.mjs} +5 -6
- package/dist/migrate-document-models-DYmkJzq3.mjs.map +1 -0
- package/dist/{migrate-subgraphs-Ffwwm7Oy.mjs → migrate-subgraphs-BUgTeHcm.mjs} +6 -7
- package/dist/migrate-subgraphs-BUgTeHcm.mjs.map +1 -0
- package/dist/migrate-subgraphs-ChhXynqd.mjs +4 -0
- package/dist/{ph-cli-commands-D4Z6YSwd.mjs → ph-cli-commands-B5VkGW99.mjs} +161 -107
- package/dist/ph-cli-commands-B5VkGW99.mjs.map +1 -0
- package/dist/ph-cli-commands-CGXSo1wx.mjs +4 -0
- package/dist/{registry-auth-Bm5AR-fB.mjs → registry-auth-C8D5cno2.mjs} +4 -4
- package/dist/{registry-auth-Bm5AR-fB.mjs.map → registry-auth-C8D5cno2.mjs.map} +1 -1
- package/dist/render-BQE20Cnd.mjs +4 -0
- package/dist/{render-SVfj3m8A.mjs → render-CQdi685k.mjs} +6 -6
- package/dist/render-CQdi685k.mjs.map +1 -0
- package/dist/{run-LRGy7zGo.mjs → run-C6Vha5VN.mjs} +3 -3
- package/dist/{run--de_-WAz.mjs → run-sVzTTEUx.mjs} +5 -36
- package/dist/run-sVzTTEUx.mjs.map +1 -0
- package/dist/{run-sugar-CkuGJuPg.mjs → run-sugar-BuxOaRzE.mjs} +5 -5
- package/dist/{run-sugar-CkuGJuPg.mjs.map → run-sugar-BuxOaRzE.mjs.map} +1 -1
- package/dist/{run-sugar-Dd_Mu058.mjs → run-sugar-Dz-rpeMO.mjs} +3 -3
- package/dist/runners/connect.d.mts +20 -3
- package/dist/runners/connect.d.mts.map +1 -1
- package/dist/runners/connect.mjs +37 -15
- package/dist/runners/connect.mjs.map +1 -1
- package/dist/runners/switchboard.d.mts +1 -1
- package/dist/runners/switchboard.mjs +3 -3
- package/dist/scripts/generate-commands-docs.ts +12 -0
- package/dist/{subgraphs-7OYWwP-C.mjs → subgraphs-Bm9NHTCn.mjs} +5 -38
- package/dist/subgraphs-Bm9NHTCn.mjs.map +1 -0
- package/dist/{sugar-checks-CAtgUIem.mjs → sugar-checks-DL-J3l2y.mjs} +6 -6
- package/dist/{sugar-checks-CAtgUIem.mjs.map → sugar-checks-DL-J3l2y.mjs.map} +1 -1
- package/dist/{verify-DXrs0JUp.mjs → verify-BLn76w09.mjs} +5 -5
- package/dist/{verify-DXrs0JUp.mjs.map → verify-BLn76w09.mjs.map} +1 -1
- package/dist/{vetra-gateway-BHuz7pvS.mjs → vetra-gateway-D30pZgha.mjs} +5 -5
- package/dist/{vetra-gateway-BHuz7pvS.mjs.map → vetra-gateway-D30pZgha.mjs.map} +1 -1
- package/dist/vetra-gateway-DE5Hc0Fp.mjs +4 -0
- package/dist/vetra-host-0rSW35_r.mjs +230 -0
- package/dist/vetra-host-0rSW35_r.mjs.map +1 -0
- package/dist/{vetra-launcher-B5L3yXPo.mjs → vetra-launcher-6NKfi6Au.mjs} +45 -5
- package/dist/vetra-launcher-6NKfi6Au.mjs.map +1 -0
- package/dist/vetra-launcher-XMk_Hv0c.mjs +4 -0
- package/package.json +17 -15
- package/dist/auth-BFUq7CvE.mjs +0 -18
- package/dist/auth-BFUq7CvE.mjs.map +0 -1
- package/dist/auth-CNhbN5UM.mjs +0 -4
- package/dist/build-DuwAPWMY.mjs +0 -4
- package/dist/check-DM7UdFTK.mjs.map +0 -1
- package/dist/compound-Q9sZSEZF-DQvtoigb.mjs.map +0 -1
- package/dist/connect-preview-BvxXGo_W.mjs.map +0 -1
- package/dist/connect-studio-B2gugCJU.mjs +0 -106
- package/dist/connect-studio-B2gugCJU.mjs.map +0 -1
- package/dist/dist-D_UjZsgt.mjs.map +0 -1
- package/dist/generate-document-model-DSYPTMZg.mjs.map +0 -1
- package/dist/generate-subgraph-EQ2ZjMp9.mjs.map +0 -1
- package/dist/index-Bs1PfL3W.d.mts.map +0 -1
- package/dist/mcp-CcZT9zT9.mjs.map +0 -1
- package/dist/migrate-document-models-X_mVTljj.mjs.map +0 -1
- package/dist/migrate-subgraphs-DEqWkLoh.mjs +0 -4
- package/dist/migrate-subgraphs-Ffwwm7Oy.mjs.map +0 -1
- package/dist/ph-cli-commands-D4Z6YSwd.mjs.map +0 -1
- package/dist/ph-cli-commands-p9cO6MsE.mjs +0 -4
- package/dist/render-3M3DwFzO.mjs +0 -4
- package/dist/render-SVfj3m8A.mjs.map +0 -1
- package/dist/run--de_-WAz.mjs.map +0 -1
- package/dist/subgraphs-7OYWwP-C.mjs.map +0 -1
- package/dist/vetra-gateway-ag33E_Ta.mjs +0 -4
- package/dist/vetra-host-CYdbd3J3.mjs +0 -111
- package/dist/vetra-host-CYdbd3J3.mjs.map +0 -1
- package/dist/vetra-launcher-B5L3yXPo.mjs.map +0 -1
- package/dist/vetra-launcher-BUO9e74r.mjs +0 -4
|
@@ -1,11 +1,11 @@
|
|
|
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]="
|
|
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]="fe8bf27c-1748-57ef-aec3-baf7d689bdaa")}catch(e){}}();
|
|
3
3
|
import { _ as unknown, c as literal, d as object, f as record, h as templateLiteral, l as looseObject, m as string, n as _enum, o as discriminatedUnion, r as array } from "./schemas-DzgKfQIx.mjs";
|
|
4
4
|
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { basename, dirname, join, posix, relative, resolve, sep } from "node:path";
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
6
7
|
import { createHash } from "node:crypto";
|
|
7
8
|
import { tmpdir } from "node:os";
|
|
8
|
-
import { spawnSync } from "node:child_process";
|
|
9
9
|
import { gunzipSync } from "node:zlib";
|
|
10
10
|
//#region src/services/build-control.ts
|
|
11
11
|
/** Scratch space of `ph build`, per package. */
|
|
@@ -453,5 +453,5 @@ function writeReleaseApproval(packageRoot, approval) {
|
|
|
453
453
|
//#endregion
|
|
454
454
|
export { pendingPrefix as _, writeReleaseApproval as a, PH_CLI_BINDING as c, listed as d, verifyReleaseApproval as f, LOCK_FILE as g, BUILD_DIRECTORY as h, revisionFiles as i, RELEASE_APPROVAL_PATH as l, packageRevision as m, publishedFiles as n, packRelease as o, changedPaths as p, readReleaseApproval as r, packedDigests as s, packagePath as t, decisionWithoutApproval as u, takeoverPrefix as v };
|
|
455
455
|
|
|
456
|
-
//# sourceMappingURL=files-
|
|
457
|
-
//# debugId=
|
|
456
|
+
//# sourceMappingURL=files-D6_euBBn.mjs.map
|
|
457
|
+
//# debugId=fe8bf27c-1748-57ef-aec3-baf7d689bdaa
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files-DEHg350R.mjs","sources":["../src/services/build-control.ts","../src/services/release/revision.ts","../src/services/release/approval.ts","../src/services/release/pack.ts","../src/services/release/files.ts"],"sourcesContent":["import { basename, join, posix, sep } from \"node:path\";\n\n/** Scratch space of `ph build`, per package. */\nexport const BUILD_DIRECTORY = join(\".ph\", \"build\");\nexport const LOCK_FILE = join(BUILD_DIRECTORY, \"lock\");\n\nexport const takeoverPrefix = (lockName: string) => `${lockName}.takeover-`;\nexport const pendingPrefix = (fileName: string) => `.${fileName}.`;\n\nexport function isBuildLockFile(path: string): boolean {\n const lockName = basename(LOCK_FILE);\n const name = posix.basename(path);\n return (\n posix.dirname(path) === BUILD_DIRECTORY.split(sep).join(\"/\") &&\n (name === lockName ||\n name.startsWith(takeoverPrefix(lockName)) ||\n name.startsWith(pendingPrefix(lockName)))\n );\n}\n","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 \"scalar-uncomparable\",\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 mkdtempSync,\n readdirSync,\n readFileSync,\n realpathSync,\n rmSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join, posix } from \"node:path\";\nimport { gunzipSync } from \"node:zlib\";\nimport { z } from \"zod\";\nimport { isBuildLockFile } from \"../build-control.js\";\nimport { RELEASE_APPROVAL_PATH } from \"./approval.js\";\nimport { byPath, type FileDigest } from \"./revision.js\";\n\nexport type PackedRelease = {\n readonly directory: string;\n readonly tarball: string;\n readonly manifest: PackedManifest;\n readonly files: ReadonlyMap<string, Buffer>;\n readonly dispose: () => void;\n};\n\nconst manifestSchema = z.looseObject({\n name: z.string(),\n version: z.string(),\n main: z.string().optional(),\n exports: z.unknown().optional(),\n dependencies: z.record(z.string(), z.string()).optional(),\n optionalDependencies: z.record(z.string(), z.string()).optional(),\n peerDependencies: z.record(z.string(), z.string()).optional(),\n});\n\nexport type PackedManifest = z.infer<typeof manifestSchema>;\n\nconst packListing = z.array(\n z.object({ name: z.string(), version: z.string(), filename: z.string() }),\n);\n\n/** npm refuses `--workspaces=false` while its configuration selects one. */\nconst SELECTS_WORKSPACE = /--no-workspaces and --workspace/;\n\nexport const 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\nconst BLOCK = 512;\n\nfunction field(header: Buffer, start: number, length: number): string {\n const bytes = header.subarray(start, start + length);\n const end = bytes.indexOf(0);\n return bytes.subarray(0, end === -1 ? length : end).toString(\"utf8\");\n}\n\nfunction paxPath(body: Buffer): string | undefined {\n for (let offset = 0; offset < body.length;) {\n const space = body.indexOf(0x20, offset);\n const length = Number(body.subarray(offset, space).toString(\"ascii\"));\n if (space === -1 || !(length > 0)) return undefined;\n const record = body\n .subarray(space + 1, offset + length - 1)\n .toString(\"utf8\");\n if (record.startsWith(\"path=\")) return record.slice(\"path=\".length);\n offset += length;\n }\n return undefined;\n}\n\nexport function readTarball(tarball: string): Map<string, Buffer> {\n const tar = gunzipSync(readFileSync(tarball));\n const files = new Map<string, Buffer>();\n let longPath: string | undefined;\n for (let offset = 0; offset + BLOCK <= tar.length;) {\n const header = tar.subarray(offset, offset + BLOCK);\n if (header.every((byte) => byte === 0)) break;\n const size = parseInt(field(header, 124, 12).trim() || \"0\", 8);\n const type = String.fromCharCode(header[156] || 48);\n const body = tar.subarray(offset + BLOCK, offset + BLOCK + size);\n offset += BLOCK + Math.ceil(size / BLOCK) * BLOCK;\n if (type === \"x\") {\n longPath = paxPath(body) ?? longPath;\n continue;\n }\n if (type === \"L\") {\n longPath = field(body, 0, body.length);\n continue;\n }\n if (type === \"g\") continue;\n const prefix = field(header, 345, 155);\n const name = field(header, 0, 100);\n const path = longPath ?? (prefix === \"\" ? name : `${prefix}/${name}`);\n longPath = undefined;\n if (type === \"5\") continue;\n const inside = posix.normalize(path.split(\"/\").slice(1).join(\"/\"));\n if (\n inside === \".\" ||\n inside.startsWith(\"../\") ||\n posix.isAbsolute(inside)\n ) {\n throw new Error(`the tarball has an entry outside the package: ${path}`);\n }\n const bytes =\n type === \"1\" || type === \"2\"\n ? Buffer.from(field(header, 157, 100))\n : Buffer.from(body);\n files.set(inside, bytes);\n }\n return files;\n}\n\nexport function packRelease(packageRoot: string): PackedRelease {\n const directory = realpathSync.native(\n mkdtempSync(join(tmpdir(), \"ph-release-\")),\n );\n const dispose = () => rmSync(directory, { recursive: true, force: true });\n try {\n const packed = spawnSync(\n \"npm\",\n [\n \"pack\",\n \"--json\",\n \"--ignore-scripts\",\n \"--workspaces=false\",\n \"--pack-destination\",\n // cmd.exe splits an unquoted path at its spaces.\n process.platform === \"win32\" ? `\"${directory}\"` : directory,\n ],\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 pack the package: ${(packed.stderr || packed.error?.message || packed.stdout).trim()}`,\n );\n }\n const listings = packListing.parse(JSON.parse(packed.stdout));\n const root = z\n .object({ name: z.string(), version: z.string() })\n .parse(\n JSON.parse(readFileSync(join(packageRoot, \"package.json\"), \"utf8\")),\n );\n const [listing] = listings;\n const tarballs = readdirSync(directory);\n if (\n listings.length !== 1 ||\n listing.name !== root.name ||\n listing.version !== root.version ||\n tarballs.length !== 1\n ) {\n const packs = listings.map(({ name, version }) => `${name}@${version}`);\n throw new Error(\n `npm pack packs ${packs.join(\", \") || \"no package\"}, not ${root.name}@${root.version}: ${selectsAnotherPackage(packageRoot)}`,\n );\n }\n const tarball = join(directory, tarballs[0]);\n const files = readTarball(tarball);\n const manifestBytes = files.get(\"package.json\");\n if (manifestBytes === undefined) {\n throw new Error(\"npm pack wrote a tarball without a package.json\");\n }\n const manifest = manifestSchema.parse(\n JSON.parse(manifestBytes.toString(\"utf8\")),\n );\n return { directory, tarball, manifest, files, dispose };\n } catch (error) {\n dispose();\n throw error;\n }\n}\n\nexport function packedDigests(packed: PackedRelease): FileDigest[] {\n return [...packed.files]\n .filter(\n ([path]) => path !== RELEASE_APPROVAL_PATH && !isBuildLockFile(path),\n )\n .map(([path, bytes]) => ({\n path,\n sha256: createHash(\"sha256\").update(bytes).digest(\"hex\"),\n }))\n .sort(byPath);\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, relative, resolve, sep } from \"node:path\";\nimport {\n type ApprovalRead,\n parseReleaseApproval,\n RELEASE_APPROVAL_PATH,\n type ReleaseApproval,\n} from \"./approval.js\";\nimport { packedDigests, packRelease } from \"./pack.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\n/**\n * What `npm pack` publishes from the package root, with digests read from the\n * packed tarball. Workspaces are off, so npm packs the root package or\n * refuses; a tarball of another package than the root's package.json names\n * throws as well.\n */\nexport function publishedFiles(packageRoot: string): FileDigest[] {\n const packed = packRelease(packageRoot);\n try {\n return packedDigests(packed);\n } finally {\n packed.dispose();\n }\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.looseObject","z.string","z.unknown","z.record","z.array","z.object","z\n .object"],"mappings":";;;;;;;;;;;AAGA,MAAa,kBAAkB,KAAK,OAAO,OAAO;AAClD,MAAa,YAAY,KAAK,iBAAiB,MAAM;AAErD,MAAa,kBAAkB,aAAqB,GAAG,SAAS;AAChE,MAAa,iBAAi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AAU,OAAO,KAAK;EAC/D;CACF;CACA,OAAO,qBAAqB,IAAI;AAClC;;AAGA,SAAgB,qBACd,aACA,UACM;CACN,MAAM,OAAO,aAAa,WAAW;CACrC,UAAU,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;CAC5C,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,IAAI;CACzC,IAAI;EACF,cAAc,WAAW,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,EAAE,GAAG;EACjE,WAAW,WAAW,IAAI;CAC5B,UAAU;EACR,OAAO,WAAW,EAAE,OAAO,KAAK,CAAC;CACnC;AACF","debug_id":"f99e2579-f543-5f1e-a61e-983f65051040"}
|
|
1
|
+
{"version":3,"file":"files-D6_euBBn.mjs","sources":["../src/services/build-control.ts","../src/services/release/revision.ts","../src/services/release/approval.ts","../src/services/release/pack.ts","../src/services/release/files.ts"],"sourcesContent":["import { basename, join, posix, sep } from \"node:path\";\n\n/** Scratch space of `ph build`, per package. */\nexport const BUILD_DIRECTORY = join(\".ph\", \"build\");\nexport const LOCK_FILE = join(BUILD_DIRECTORY, \"lock\");\n\nexport const takeoverPrefix = (lockName: string) => `${lockName}.takeover-`;\nexport const pendingPrefix = (fileName: string) => `.${fileName}.`;\n\nexport function isBuildLockFile(path: string): boolean {\n const lockName = basename(LOCK_FILE);\n const name = posix.basename(path);\n return (\n posix.dirname(path) === BUILD_DIRECTORY.split(sep).join(\"/\") &&\n (name === lockName ||\n name.startsWith(takeoverPrefix(lockName)) ||\n name.startsWith(pendingPrefix(lockName)))\n );\n}\n","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 \"scalar-uncomparable\",\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 mkdtempSync,\n readdirSync,\n readFileSync,\n realpathSync,\n rmSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join, posix } from \"node:path\";\nimport { gunzipSync } from \"node:zlib\";\nimport { z } from \"zod\";\nimport { isBuildLockFile } from \"../build-control.js\";\nimport { RELEASE_APPROVAL_PATH } from \"./approval.js\";\nimport { byPath, type FileDigest } from \"./revision.js\";\n\nexport type PackedRelease = {\n readonly directory: string;\n readonly tarball: string;\n readonly manifest: PackedManifest;\n readonly files: ReadonlyMap<string, Buffer>;\n readonly dispose: () => void;\n};\n\nconst manifestSchema = z.looseObject({\n name: z.string(),\n version: z.string(),\n main: z.string().optional(),\n exports: z.unknown().optional(),\n dependencies: z.record(z.string(), z.string()).optional(),\n optionalDependencies: z.record(z.string(), z.string()).optional(),\n peerDependencies: z.record(z.string(), z.string()).optional(),\n});\n\nexport type PackedManifest = z.infer<typeof manifestSchema>;\n\nconst packListing = z.array(\n z.object({ name: z.string(), version: z.string(), filename: z.string() }),\n);\n\n/** npm refuses `--workspaces=false` while its configuration selects one. */\nconst SELECTS_WORKSPACE = /--no-workspaces and --workspace/;\n\nexport const 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\nconst BLOCK = 512;\n\nfunction field(header: Buffer, start: number, length: number): string {\n const bytes = header.subarray(start, start + length);\n const end = bytes.indexOf(0);\n return bytes.subarray(0, end === -1 ? length : end).toString(\"utf8\");\n}\n\nfunction paxPath(body: Buffer): string | undefined {\n for (let offset = 0; offset < body.length;) {\n const space = body.indexOf(0x20, offset);\n const length = Number(body.subarray(offset, space).toString(\"ascii\"));\n if (space === -1 || !(length > 0)) return undefined;\n const record = body\n .subarray(space + 1, offset + length - 1)\n .toString(\"utf8\");\n if (record.startsWith(\"path=\")) return record.slice(\"path=\".length);\n offset += length;\n }\n return undefined;\n}\n\nexport function readTarball(tarball: string): Map<string, Buffer> {\n const tar = gunzipSync(readFileSync(tarball));\n const files = new Map<string, Buffer>();\n let longPath: string | undefined;\n for (let offset = 0; offset + BLOCK <= tar.length;) {\n const header = tar.subarray(offset, offset + BLOCK);\n if (header.every((byte) => byte === 0)) break;\n const size = parseInt(field(header, 124, 12).trim() || \"0\", 8);\n const type = String.fromCharCode(header[156] || 48);\n const body = tar.subarray(offset + BLOCK, offset + BLOCK + size);\n offset += BLOCK + Math.ceil(size / BLOCK) * BLOCK;\n if (type === \"x\") {\n longPath = paxPath(body) ?? longPath;\n continue;\n }\n if (type === \"L\") {\n longPath = field(body, 0, body.length);\n continue;\n }\n if (type === \"g\") continue;\n const prefix = field(header, 345, 155);\n const name = field(header, 0, 100);\n const path = longPath ?? (prefix === \"\" ? name : `${prefix}/${name}`);\n longPath = undefined;\n if (type === \"5\") continue;\n const inside = posix.normalize(path.split(\"/\").slice(1).join(\"/\"));\n if (\n inside === \".\" ||\n inside.startsWith(\"../\") ||\n posix.isAbsolute(inside)\n ) {\n throw new Error(`the tarball has an entry outside the package: ${path}`);\n }\n const bytes =\n type === \"1\" || type === \"2\"\n ? Buffer.from(field(header, 157, 100))\n : Buffer.from(body);\n files.set(inside, bytes);\n }\n return files;\n}\n\nexport function packRelease(packageRoot: string): PackedRelease {\n const directory = realpathSync.native(\n mkdtempSync(join(tmpdir(), \"ph-release-\")),\n );\n const dispose = () => rmSync(directory, { recursive: true, force: true });\n try {\n const packed = spawnSync(\n \"npm\",\n [\n \"pack\",\n \"--json\",\n \"--ignore-scripts\",\n \"--workspaces=false\",\n \"--pack-destination\",\n // cmd.exe splits an unquoted path at its spaces.\n process.platform === \"win32\" ? `\"${directory}\"` : directory,\n ],\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 pack the package: ${(packed.stderr || packed.error?.message || packed.stdout).trim()}`,\n );\n }\n const listings = packListing.parse(JSON.parse(packed.stdout));\n const root = z\n .object({ name: z.string(), version: z.string() })\n .parse(\n JSON.parse(readFileSync(join(packageRoot, \"package.json\"), \"utf8\")),\n );\n const [listing] = listings;\n const tarballs = readdirSync(directory);\n if (\n listings.length !== 1 ||\n listing.name !== root.name ||\n listing.version !== root.version ||\n tarballs.length !== 1\n ) {\n const packs = listings.map(({ name, version }) => `${name}@${version}`);\n throw new Error(\n `npm pack packs ${packs.join(\", \") || \"no package\"}, not ${root.name}@${root.version}: ${selectsAnotherPackage(packageRoot)}`,\n );\n }\n const tarball = join(directory, tarballs[0]);\n const files = readTarball(tarball);\n const manifestBytes = files.get(\"package.json\");\n if (manifestBytes === undefined) {\n throw new Error(\"npm pack wrote a tarball without a package.json\");\n }\n const manifest = manifestSchema.parse(\n JSON.parse(manifestBytes.toString(\"utf8\")),\n );\n return { directory, tarball, manifest, files, dispose };\n } catch (error) {\n dispose();\n throw error;\n }\n}\n\nexport function packedDigests(packed: PackedRelease): FileDigest[] {\n return [...packed.files]\n .filter(\n ([path]) => path !== RELEASE_APPROVAL_PATH && !isBuildLockFile(path),\n )\n .map(([path, bytes]) => ({\n path,\n sha256: createHash(\"sha256\").update(bytes).digest(\"hex\"),\n }))\n .sort(byPath);\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, relative, resolve, sep } from \"node:path\";\nimport {\n type ApprovalRead,\n parseReleaseApproval,\n RELEASE_APPROVAL_PATH,\n type ReleaseApproval,\n} from \"./approval.js\";\nimport { packedDigests, packRelease } from \"./pack.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\n/**\n * What `npm pack` publishes from the package root, with digests read from the\n * packed tarball. Workspaces are off, so npm packs the root package or\n * refuses; a tarball of another package than the root's package.json names\n * throws as well.\n */\nexport function publishedFiles(packageRoot: string): FileDigest[] {\n const packed = packRelease(packageRoot);\n try {\n return packedDigests(packed);\n } finally {\n packed.dispose();\n }\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.looseObject","z.string","z.unknown","z.record","z.array","z.object","z\n .object"],"mappings":";;;;;;;;;;;AAGA,MAAa,kBAAkB,KAAK,OAAO,OAAO;AAClD,MAAa,YAAY,KAAK,iBAAiB,MAAM;AAErD,MAAa,kBAAkB,aAAqB,GAAG,SAAS;AAChE,MAAa,iBAAiB,aAAqB,IAAI,SAAS;AAEhE,SAAgB,gBAAgB,MAAuB;CACrD,MAAM,WAAW,SAAS,SAAS;CACnC,MAAM,OAAO,MAAM,SAAS,IAAI;CAChC,OACE,MAAM,QAAQ,IAAI,MAAM,gBAAgB,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,MAC1D,SAAS,YACR,KAAK,WAAW,eAAe,QAAQ,CAAC,KACxC,KAAK,WAAW,cAAc,QAAQ,CAAC;AAE7C;;;;;;;;ACNA,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,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SAAS,YAAY,WAAW;CACtC,IAAI;EACF,OAAO,cAAc,MAAM;CAC7B,UAAU;EACR,OAAO,QAAQ;CACjB;AACF;AAEA,MAAM,gBAAgB,gBACpB,KAAK,aAAa,GAAG,sBAAsB,MAAM,GAAG,CAAC;AAEvD,SAAgB,oBAAoB,aAAmC;CACrE,MAAM,OAAO,aAAa,WAAW;CACrC,IAAI,CAAC,WAAW,IAAI,GAAG,OAAO,EAAE,MAAM,UAAU;CAChD,IAAI;CACJ,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,SAAS,OAAO;EACd,OAAO;GACL,MAAM;GACN,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC/D;CACF;CACA,OAAO,qBAAqB,IAAI;AAClC;;AAGA,SAAgB,qBACd,aACA,UACM;CACN,MAAM,OAAO,aAAa,WAAW;CACrC,UAAU,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;CAC5C,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,IAAI;CACzC,IAAI;EACF,cAAc,WAAW,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,EAAE,GAAG;EACjE,WAAW,WAAW,IAAI;CAC5B,UAAU;EACR,OAAO,WAAW,EAAE,OAAO,KAAK,CAAC;CACnC;AACF","debug_id":"fe8bf27c-1748-57ef-aec3-baf7d689bdaa"}
|
|
@@ -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]="
|
|
3
|
-
import {
|
|
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]="19ce57c6-f865-5a10-92bc-2d47a2188201")}catch(e){}}();
|
|
3
|
+
import { R as probeHostsFolder } from "./compound-g6x_KkWp-Bs7olmlI.mjs";
|
|
4
4
|
import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-BZ4NwLx5.mjs";
|
|
5
5
|
import { t as startGenerateHosts } from "./generate-hosts-BFmPIW2X.mjs";
|
|
6
6
|
import { modelGeneration } from "@powerhousedao/codegen";
|
|
@@ -16,5 +16,5 @@ async function startGenerateAll(projectDir) {
|
|
|
16
16
|
//#endregion
|
|
17
17
|
export { startGenerateAll };
|
|
18
18
|
|
|
19
|
-
//# sourceMappingURL=generate-all-
|
|
20
|
-
//# debugId=
|
|
19
|
+
//# sourceMappingURL=generate-all-B9MwWXlq.mjs.map
|
|
20
|
+
//# debugId=19ce57c6-f865-5a10-92bc-2d47a2188201
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-all-
|
|
1
|
+
{"version":3,"file":"generate-all-B9MwWXlq.mjs","sources":["../src/services/generate-all.ts"],"sourcesContent":["import { modelGeneration } from \"@powerhousedao/codegen\";\nimport { buildTsMorphProject } from \"@powerhousedao/codegen/utils\";\nimport { probeHostsFolder } from \"@powerhousedao/host-core\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\nimport { startGenerateHosts } from \"./generate-hosts.js\";\n\nexport async function startGenerateAll(projectDir: string) {\n const project = buildTsMorphProject(projectDir);\n await modelGeneration.generateAll(project);\n await project.save();\n await warnSubgraphTypeConflicts(projectDir);\n if (\n probeHostsFolder(projectDir).kind === \"present\" &&\n !(await startGenerateHosts(projectDir))\n ) {\n process.exitCode = 1;\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAMA,eAAsB,iBAAiB,YAAoB;CACzD,MAAM,UAAU,oBAAoB,UAAU;CAC9C,MAAM,gBAAgB,YAAY,OAAO;CACzC,MAAM,QAAQ,KAAK;CACnB,MAAM,0BAA0B,UAAU;CAC1C,IACE,iBAAiB,UAAU,CAAC,CAAC,SAAS,aACtC,CAAE,MAAM,mBAAmB,UAAU,GAErC,QAAQ,WAAW;AAEvB","debug_id":"19ce57c6-f865-5a10-92bc-2d47a2188201"}
|
|
@@ -1,5 +1,5 @@
|
|
|
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]="
|
|
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]="5187a467-142e-5020-8a3f-c60f48df6fe7")}catch(e){}}();
|
|
3
3
|
import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-BZ4NwLx5.mjs";
|
|
4
4
|
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
@@ -51,10 +51,8 @@ function modelsDirOf(projectDir) {
|
|
|
51
51
|
return relative(projectDir, documentModelsDirOf(projectDir).path).replaceAll("\\", "/");
|
|
52
52
|
}
|
|
53
53
|
async function startGenerateDocumentModel(args, projectDir) {
|
|
54
|
-
const { dir, all, name,
|
|
54
|
+
const { dir, all, name, debug } = args;
|
|
55
55
|
if (debug) console.log({ args });
|
|
56
|
-
if (name !== void 0 && !codeFirst) throw new Error("--name creates a code-first document model. Pass --code-first.");
|
|
57
|
-
if (codeFirst && name === void 0) throw new Error("--code-first only chooses how --name creates a model. Existing models of both styles are discovered without it; drop --code-first. To convert a schema-first model, run ph migrate --document-model <dir>.");
|
|
58
56
|
const project = buildTsMorphProject(projectDir);
|
|
59
57
|
if (name !== void 0) {
|
|
60
58
|
handleMutuallyExclusiveOptions({
|
|
@@ -70,8 +68,8 @@ async function startGenerateDocumentModel(args, projectDir) {
|
|
|
70
68
|
await project.save();
|
|
71
69
|
if (documentModels.length === 0 && unreadableDirs.length === 0 && codeFirstDocumentModels.length === 0) console.log(`No document models found in ${modelsDirOf(projectDir)}/.`);
|
|
72
70
|
for (const { name } of documentModels) console.log(`Regenerated document model "${name}"`);
|
|
73
|
-
for (const { name } of codeFirstDocumentModels) console.log(`Updated the exports of
|
|
74
|
-
for (const dirName of unreadableDirs) console.warn(`Skipped ${modelsDirOf(projectDir)}/${dirName}: it has no readable ${dirName}.json, and no index.ts in it exports a
|
|
71
|
+
for (const { name } of codeFirstDocumentModels) console.log(`Updated the exports of document model "${name}"`);
|
|
72
|
+
for (const dirName of unreadableDirs) console.warn(`Skipped ${modelsDirOf(projectDir)}/${dirName}: it has no readable ${dirName}.json, and no index.ts in it exports a document model with a definition. Kept the manifest's document models.`);
|
|
75
73
|
await warnSubgraphTypeConflicts(projectDir);
|
|
76
74
|
return;
|
|
77
75
|
}
|
|
@@ -92,5 +90,5 @@ async function startGenerateDocumentModel(args, projectDir) {
|
|
|
92
90
|
//#endregion
|
|
93
91
|
export { startGenerateDocumentModel };
|
|
94
92
|
|
|
95
|
-
//# sourceMappingURL=generate-document-model-
|
|
96
|
-
//# debugId=
|
|
93
|
+
//# sourceMappingURL=generate-document-model-D3LKY1D7.mjs.map
|
|
94
|
+
//# debugId=5187a467-142e-5020-8a3f-c60f48df6fe7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-document-model-D3LKY1D7.mjs","sources":["../src/services/definitions/code-first-scaffold.ts","../src/services/generate-document-model.ts"],"sourcesContent":["import type { ModelGeneration } from \"@powerhousedao/codegen\";\nimport { capitalCase, kebabCase } from \"change-case\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { readPackage } from \"read-pkg\";\nimport type { Project } from \"ts-morph\";\n\nexport async function scaffoldCodeFirstDocumentModel(\n generation: ModelGeneration,\n name: string,\n projectDir: string,\n project: Project,\n) {\n const modelName = name.trim();\n if (modelName === \"\") {\n throw new Error(\"--name needs a document model name.\");\n }\n const namespace = await documentTypeNamespace(projectDir);\n const documentType = `${namespace}/${kebabCase(modelName)}`;\n const editorName = `${capitalCase(modelName)} Editor`;\n const editorDirName = kebabCase(editorName);\n if (existsSync(join(projectDir, \"editors\", editorDirName))) {\n throw new Error(\n `editors/${editorDirName} already exists. Choose another --name, or move that editor first.`,\n );\n }\n\n const result = await generation.scaffoldDocumentModel(\n {\n name: modelName,\n documentType,\n author: { name: namespace, website: null },\n },\n project,\n );\n for (const path of result.written) {\n console.log(`Wrote ${path}`);\n }\n\n await generation.generateEditor(\n {\n editorName,\n documentTypes: [documentType],\n editorId: editorDirName,\n editorDirName,\n },\n project,\n );\n await project.save();\n console.log(`Generated editor \"${editorName}\" in editors/${editorDirName}`);\n}\n\nasync function documentTypeNamespace(projectDir: string) {\n const { name } = await readPackage({ cwd: projectDir, normalize: false });\n if (!name) {\n throw new Error(\n \"--name puts the document type under the package name. Add a name to package.json.\",\n );\n }\n return name.replace(/^@/, \"\").replaceAll(\"/\", \"-\");\n}\n","import { loadDocumentModel, modelGeneration } from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n documentModelsDirOf,\n} from \"@powerhousedao/codegen/utils\";\nimport { handleMutuallyExclusiveOptions } from \"@powerhousedao/shared/clis\";\nimport { existsSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\nimport type { GenerateDocumentModelArgs } from \"../types.js\";\nimport { resolveModuleDirName } from \"../utils/module-dir.js\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\nimport { scaffoldCodeFirstDocumentModel } from \"./definitions/code-first-scaffold.js\";\n\n/** The configured documentModelsDir, package-relative, for messages and paths. */\nfunction modelsDirOf(projectDir: string) {\n return relative(projectDir, documentModelsDirOf(projectDir).path).replaceAll(\n \"\\\\\",\n \"/\",\n );\n}\n\nexport async function startGenerateDocumentModel(\n args: GenerateDocumentModelArgs,\n projectDir: string,\n) {\n const { dir, all, name, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n if (name !== undefined) {\n handleMutuallyExclusiveOptions(\n {\n \"--name\": name,\n \"--dir\": dir,\n \"--all\": all || undefined,\n },\n \"generation mode\",\n );\n await scaffoldCodeFirstDocumentModel(\n modelGeneration,\n name,\n projectDir,\n project,\n );\n return;\n }\n if (all) {\n const { documentModels, unreadableDirs, codeFirstDocumentModels } =\n await modelGeneration.generateAllDocumentModels(project);\n await project.save();\n if (\n documentModels.length === 0 &&\n unreadableDirs.length === 0 &&\n codeFirstDocumentModels.length === 0\n ) {\n console.log(`No document models found in ${modelsDirOf(projectDir)}/.`);\n }\n for (const { name } of documentModels) {\n console.log(`Regenerated document model \"${name}\"`);\n }\n for (const { name } of codeFirstDocumentModels) {\n console.log(`Updated the exports of document model \"${name}\"`);\n }\n for (const dirName of unreadableDirs) {\n console.warn(\n `Skipped ${modelsDirOf(projectDir)}/${dirName}: it has no readable ${dirName}.json, and no index.ts in it exports a document model with a definition. Kept the manifest's document models.`,\n );\n }\n await warnSubgraphTypeConflicts(projectDir);\n return;\n }\n if (dir) {\n const modelsDir = modelsDirOf(projectDir);\n const dirName = resolveModuleDirName(\n projectDir,\n modelsDir,\n dir,\n \"my-document-model\",\n );\n const specPath = join(projectDir, modelsDir, dirName, `${dirName}.json`);\n if (!existsSync(specPath)) {\n throw new Error(`${modelsDir}/${dirName} has no ${dirName}.json.`);\n }\n const state = await loadDocumentModel(specPath);\n await modelGeneration.generateDocumentModel(state, project);\n await project.save();\n console.log(\n `Regenerated document model \"${state.name}\" in ${modelsDir}/${dirName}`,\n );\n await warnSubgraphTypeConflicts(projectDir);\n return;\n }\n console.log(\"Please specify one of `name`, `dir`, or `all`.\");\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAOA,eAAsB,+BACpB,YACA,MACA,YACA,SACA;CACA,MAAM,YAAY,KAAK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ClB,GACA,iBACF;EACA,MAAM,+BACJ,iBACA,MACA,YACA,OACF;EACA;CACF;CACA,IAAI,KAAK;EACP,MAAM,EAAE,gBAAgB,gBAAgB,4BACtC,MAAM,gBAAgB,0BAA0B,OAAO;EACzD,MAAM,QAAQ,KAAK;EACnB,IACE,eAAe,WAAW,KAC1B,eAAe,WAAW,KAC1B,wBAAwB,WAAW,GAEnC,QAAQ,IAAI,+BAA+B,YAAY,UAAU,EAAE,GAAG;EAExE,KAAK,MAAM,EAAE,UAAU,gBACrB,QAAQ,IAAI,+BAA+B,KAAK,EAAE;EAEpD,KAAK,MAAM,EAAE,UAAU,yBACrB,QAAQ,IAAI,0CAA0C,KAAK,EAAE;EAE/D,KAAK,MAAM,WAAW,gBACpB,QAAQ,KACN,WAAW,YAAY,UAAU,EAAE,GAAG,QAAQ,uBAAuB,QAAQ,8GAC/E;EAEF,MAAM,0BAA0B,UAAU;EAC1C;CACF;CACA,IAAI,KAAK;EACP,MAAM,YAAY,YAAY,UAAU;EACxC,MAAM,UAAU,qBACd,YACA,WACA,KACA,mBACF;EACA,MAAM,WAAW,KAAK,YAAY,WAAW,SAAS,GAAG,QAAQ,MAAM;EACvE,IAAI,CAAC,WAAW,QAAQ,GACtB,MAAM,IAAI,MAAM,GAAG,UAAU,GAAG,QAAQ,UAAU,QAAQ,OAAO;EAEnE,MAAM,QAAQ,MAAM,kBAAkB,QAAQ;EAC9C,MAAM,gBAAgB,sBAAsB,OAAO,OAAO;EAC1D,MAAM,QAAQ,KAAK;EACnB,QAAQ,IACN,+BAA+B,MAAM,KAAK,OAAO,UAAU,GAAG,SAChE;EACA,MAAM,0BAA0B,UAAU;EAC1C;CACF;CACA,QAAQ,IAAI,gDAAgD;AAC9D","debug_id":"5187a467-142e-5020-8a3f-c60f48df6fe7"}
|
|
@@ -1,5 +1,5 @@
|
|
|
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]="
|
|
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]="b7dd8da1-5da0-5f0c-934e-afd9a52da5e1")}catch(e){}}();
|
|
3
3
|
import { t as installAddedDependencies$1 } from "./install-added-dependencies-DnZFR3aE.mjs";
|
|
4
4
|
import { n as findSubgraphNameConflict, t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-BZ4NwLx5.mjs";
|
|
5
5
|
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
@@ -17,14 +17,12 @@ async function assertSubgraphNameFree(projectDir, name) {
|
|
|
17
17
|
const conflict = await findSubgraphNameConflict(projectDir, name);
|
|
18
18
|
if (conflict) throw new Error(conflict);
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
if (!existsSync(join(subgraphsDir, dirName, "index.ts")) || subgraphDirStyle(subgraphsDir, dirName) !== "schema-first") return void 0;
|
|
27
|
-
return `subgraphs/${dirName} is schema-first; --code-first only applies to new subgraphs. To convert it, run ph migrate --subgraph ${dirName}.`;
|
|
20
|
+
/** Codegen reads a directory's form from its index.ts. When that file is
|
|
21
|
+
* gone, lib.ts or resolvers.ts still marks a legacy subgraph: only the legacy
|
|
22
|
+
* subgraph generator writes them. */
|
|
23
|
+
function holdsLegacySubgraphFiles(projectDir, name) {
|
|
24
|
+
const dir = join(projectDir, "subgraphs", kebabCase(name));
|
|
25
|
+
return ["lib.ts", "resolvers.ts"].some((file) => existsSync(join(dir, file)));
|
|
28
26
|
}
|
|
29
27
|
async function startGenerateSubgraph(args, projectDir) {
|
|
30
28
|
const { name, dir, all, debug } = args;
|
|
@@ -37,13 +35,8 @@ async function startGenerateSubgraph(args, projectDir) {
|
|
|
37
35
|
for (const subgraphName of subgraphNames) report.push(`Regenerated subgraph "${subgraphName}"`);
|
|
38
36
|
for (const dirName of unreadableDirs) console.warn(`Skipped subgraphs/${dirName}: expected its index.ts to export ${INDEX_FILE_EXPECTATION[subgraphDirStyle(join(projectDir, "subgraphs"), dirName)]}. Kept the manifest's subgraphs.`);
|
|
39
37
|
} else if (name) {
|
|
40
|
-
const notice = codeFirstOnSchemaFirst(args, projectDir, name);
|
|
41
|
-
if (notice) {
|
|
42
|
-
console.log(notice);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
38
|
await assertSubgraphNameFree(projectDir, name);
|
|
46
|
-
await generateSubgraph(name, project, { codeFirst:
|
|
39
|
+
await generateSubgraph(name, project, { codeFirst: !holdsLegacySubgraphFiles(projectDir, name) });
|
|
47
40
|
} else if (dir) {
|
|
48
41
|
const dirName = resolveModuleDirName(projectDir, "subgraphs", dir, "my-subgraph");
|
|
49
42
|
if (!existsSync(join(projectDir, "subgraphs", dirName, "index.ts"))) throw new Error(`subgraphs/${dirName} has no index.ts.`);
|
|
@@ -63,5 +56,5 @@ async function startGenerateSubgraph(args, projectDir) {
|
|
|
63
56
|
//#endregion
|
|
64
57
|
export { startGenerateSubgraph };
|
|
65
58
|
|
|
66
|
-
//# sourceMappingURL=generate-subgraph-
|
|
67
|
-
//# debugId=
|
|
59
|
+
//# sourceMappingURL=generate-subgraph-Q1VLh3SC.mjs.map
|
|
60
|
+
//# debugId=b7dd8da1-5da0-5f0c-934e-afd9a52da5e1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-subgraph-Q1VLh3SC.mjs","sources":["../src/services/generate-subgraph.ts"],"sourcesContent":["import {\n detectFeatures,\n generateAllSubgraphs,\n generateSubgraph,\n generateSubgraphDir,\n syncFeatureDependencies,\n} from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n subgraphDirStyle,\n type SubgraphStyle,\n} from \"@powerhousedao/codegen/utils\";\nimport { kebabCase } from \"change-case\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { GenerateSubgraphArgs } from \"../types.js\";\nimport { installAddedDependencies } from \"../utils/install-added-dependencies.js\";\nimport { resolveModuleDirName } from \"../utils/module-dir.js\";\nimport { findSubgraphNameConflict } from \"../utils/subgraph-type-lint.js\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\n\nconst INDEX_FILE_EXPECTATION = {\n \"schema-first\": \"a class extending BaseSubgraph with a string literal `name`\",\n \"code-first\":\n \"a class extending Subgraph with a string literal `static subgraphName`\",\n} satisfies Record<SubgraphStyle, string>;\n\nasync function assertSubgraphNameFree(projectDir: string, name: string) {\n const conflict = await findSubgraphNameConflict(projectDir, name);\n if (conflict) throw new Error(conflict);\n}\n\n/** Codegen reads a directory's form from its index.ts. When that file is\n * gone, lib.ts or resolvers.ts still marks a legacy subgraph: only the legacy\n * subgraph generator writes them. */\nfunction holdsLegacySubgraphFiles(projectDir: string, name: string) {\n const dir = join(projectDir, \"subgraphs\", kebabCase(name));\n return [\"lib.ts\", \"resolvers.ts\"].some((file) => existsSync(join(dir, file)));\n}\n\nexport async function startGenerateSubgraph(\n args: GenerateSubgraphArgs,\n projectDir: string,\n) {\n const { name, dir, all, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n const report: string[] = [];\n if (all) {\n const { subgraphNames, unreadableDirs } =\n await generateAllSubgraphs(project);\n if (subgraphNames.length === 0 && unreadableDirs.length === 0) {\n report.push(\"No subgraphs found in subgraphs/.\");\n }\n for (const subgraphName of subgraphNames) {\n report.push(`Regenerated subgraph \"${subgraphName}\"`);\n }\n for (const dirName of unreadableDirs) {\n console.warn(\n `Skipped subgraphs/${dirName}: expected its index.ts to export ${INDEX_FILE_EXPECTATION[subgraphDirStyle(join(projectDir, \"subgraphs\"), dirName)]}. Kept the manifest's subgraphs.`,\n );\n }\n } else if (name) {\n await assertSubgraphNameFree(projectDir, name);\n await generateSubgraph(name, project, {\n codeFirst: !holdsLegacySubgraphFiles(projectDir, name),\n });\n } else if (dir) {\n const dirName = resolveModuleDirName(\n projectDir,\n \"subgraphs\",\n dir,\n \"my-subgraph\",\n );\n if (!existsSync(join(projectDir, \"subgraphs\", dirName, \"index.ts\"))) {\n throw new Error(`subgraphs/${dirName} has no index.ts.`);\n }\n const { subgraphName, style } = await generateSubgraphDir(dirName, project);\n if (!subgraphName) {\n throw new Error(\n `Could not read subgraphs/${dirName}/index.ts: expected ${INDEX_FILE_EXPECTATION[style]}.`,\n );\n }\n report.push(`Regenerated subgraph \"${subgraphName}\"`);\n } else {\n console.log(\"Please specify one of `name`, `dir`, or `all`.\");\n return;\n }\n await project.save();\n for (const line of report) {\n console.log(line);\n }\n await warnSubgraphTypeConflicts(projectDir);\n const added = await syncFeatureDependencies(\n detectFeatures(projectDir),\n projectDir,\n );\n await installAddedDependencies(added, projectDir, args.skipInstall);\n}\n"],"names":["installAddedDependencies"],"mappings":";;;;;;;;;;;AAqBA,MAAM,yBAAyB;CAC7B,gBAAgB;CAChB,cACE;AACJ;AAEA,eAAe,uBAAuB,YAAoB,MAAc;CACtE,MAAM,WAAW,MAAM,yBAAyB,YAAY,IAAI;CAChE,IAAI,UAAU,MAAM,IAAI,MAAM,QAAQ;AACxC;;;;AAKA,SAAS,yBAAyB,YAAoB,MAAc;CAClE,MAAM,MAAM,KAAK,YAAY,aAAa,UAAU,IAAI,CAAC;CACzD,OAAO,CAAC,UAAU,cAAc,CAAC,CAAC,MAAM,SAAS,WAAW,KAAK,KAAK,IAAI,CAAC,CAAC;AAC9E;AAEA,eAAsB,sBACpB,MACA,YACA;CACA,MAAM,EAAE,MAAM,KAAK,KAAK,UAAU;CAClC,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UA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
3
|
-
!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]="
|
|
3
|
+
!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]="7b15c1d5-e9e7-5d18-9bf0-80f3184cc19d")}catch(e){}}();
|
|
4
4
|
function getVersion() {
|
|
5
|
-
return "6.4.0-next.
|
|
5
|
+
return "6.4.0-next.5";
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
export { getVersion as t };
|
|
9
9
|
|
|
10
|
-
//# sourceMappingURL=get-version-
|
|
11
|
-
//# debugId=
|
|
10
|
+
//# sourceMappingURL=get-version-CTP__ORu.mjs.map
|
|
11
|
+
//# debugId=7b15c1d5-e9e7-5d18-9bf0-80f3184cc19d
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-version-
|
|
1
|
+
{"version":3,"file":"get-version-CTP__ORu.mjs","sources":["../src/get-version.ts"],"sourcesContent":["declare const CLI_VERSION: string | undefined;\ndeclare const CLI_GIT_SHA: string | undefined;\n\nexport function getVersion() {\n if (typeof CLI_VERSION !== \"undefined\") return CLI_VERSION;\n return (\n process.env.WORKSPACE_VERSION ||\n process.env.npm_package_version ||\n \"unknown\"\n );\n}\n\nexport function getGitHash() {\n if (typeof CLI_GIT_SHA !== \"undefined\") return CLI_GIT_SHA;\n return process.env.WORKSPACE_GIT_SHA || \"unknown\";\n}\n"],"names":[],"mappings":";;;AAGA,SAAgB,aAAa;CACa,OAAA;AAM1C","debug_id":"7b15c1d5-e9e7-5d18-9bf0-80f3184cc19d"}
|
|
@@ -0,0 +1,137 @@
|
|
|
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]="cee9f7e8-d1fe-5e9e-b0c8-f66c5d03af19")}catch(e){}}();
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { IDENTITY_KEY_ENV, askPassword, changePseudonymPassword, identityDataDir, loginPaths, pseudonymLabel, readActiveIdentity, readPseudonym } from "@powerhousedao/shared/clis/identity";
|
|
6
|
+
//#region src/services/identity.ts
|
|
7
|
+
function keyLine(info) {
|
|
8
|
+
switch (info.source) {
|
|
9
|
+
case "env": return `${IDENTITY_KEY_ENV} (never written)`;
|
|
10
|
+
case "data-folder": return `${info.file} (this store's own)`;
|
|
11
|
+
default: return `${info.file} (copied into this store at its first signature)`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** What `ph whoami` prints for `info`. */
|
|
15
|
+
function describeIdentity(info) {
|
|
16
|
+
if (!info) return [
|
|
17
|
+
"Nobody yet: no Renown login, and no pseudonym on this computer.",
|
|
18
|
+
"A pseudonym is made, readable by you only, when something must be signed here.",
|
|
19
|
+
"`ph login` logs in with Renown."
|
|
20
|
+
];
|
|
21
|
+
if (info.kind === "renown") {
|
|
22
|
+
const login = info.renown;
|
|
23
|
+
if (login.expired) return [`Your Renown login as ${login.label} expired on ${login.expiresAt}.`, "Nothing signs with it: run `ph login` again, or `ph logout` to act as your pseudonym."];
|
|
24
|
+
return [
|
|
25
|
+
`Logged in with Renown as ${login.label}`,
|
|
26
|
+
` Address: ${login.address}`,
|
|
27
|
+
...login.expiresAt ? [` Expires: ${login.expiresAt}`] : [],
|
|
28
|
+
` Login: ${login.file}`
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
return [
|
|
32
|
+
`${info.label} (no Renown login)`,
|
|
33
|
+
` Address: ${info.address}`,
|
|
34
|
+
` Key: ${keyLine(info)}`,
|
|
35
|
+
` Password: ${info.encrypted ? "yes" : "no"}`,
|
|
36
|
+
...info.differsFromHome ? [` Your default pseudonym is ${pseudonymLabel(info.differsFromHome)}; this store keeps its own, which wrote its documents.`] : []
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
/** A login `ph login` wrote into the project before 6.4: no longer read. */
|
|
40
|
+
function projectLoginNotice(dataDir) {
|
|
41
|
+
const file = path.join(dataDir, ".ph", ".renown.json");
|
|
42
|
+
try {
|
|
43
|
+
if (!JSON.parse(fs.readFileSync(file, "utf8")).user) return void 0;
|
|
44
|
+
} catch {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
return `This project holds a login from before 6.4 in ${file}. It is no longer read; the upgrade step withdraws and removes it.`;
|
|
48
|
+
}
|
|
49
|
+
async function runWhoami(args, print = console.log) {
|
|
50
|
+
const dataDir = identityDataDir();
|
|
51
|
+
let info = readActiveIdentity({ dataDir });
|
|
52
|
+
let checked;
|
|
53
|
+
if (args.check && info?.kind === "renown" && !info.renown.expired) {
|
|
54
|
+
const { homeLoginRenown } = await import("@renown/sdk/identity");
|
|
55
|
+
checked = (await homeLoginRenown({ baseUrl: args.renownUrl })).user ? "valid" : "withdrawn";
|
|
56
|
+
info = readActiveIdentity({ dataDir });
|
|
57
|
+
}
|
|
58
|
+
if (args.json) {
|
|
59
|
+
print(JSON.stringify({
|
|
60
|
+
identity: info ?? null,
|
|
61
|
+
...checked ? { renown: checked } : {}
|
|
62
|
+
}, null, 2));
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
if (checked === "withdrawn") print("Renown no longer knows your login: it was withdrawn or has expired.");
|
|
66
|
+
for (const line of describeIdentity(info)) print(line);
|
|
67
|
+
if (checked === "valid") print(" Renown: still valid");
|
|
68
|
+
const notice = projectLoginNotice(dataDir);
|
|
69
|
+
if (notice) print(notice);
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
async function runLogout(args, print = console.log) {
|
|
73
|
+
const paths = loginPaths();
|
|
74
|
+
if (!fs.existsSync(paths.file) && !fs.existsSync(paths.keypair)) print("Not logged in.");
|
|
75
|
+
else {
|
|
76
|
+
const { logoutHome } = await import("@renown/sdk/identity");
|
|
77
|
+
const { withdraw, removed } = await logoutHome({ renownUrl: args.renownUrl });
|
|
78
|
+
switch (withdraw.status) {
|
|
79
|
+
case "withdrawn":
|
|
80
|
+
print("Withdrew the login at Renown.");
|
|
81
|
+
break;
|
|
82
|
+
case "not-found":
|
|
83
|
+
print("Renown holds no such login any more.");
|
|
84
|
+
break;
|
|
85
|
+
case "refused": {
|
|
86
|
+
print(`Renown did not take this computer's key as proof (${withdraw.reason}).`);
|
|
87
|
+
print(`Withdraw it with your wallet at ${withdraw.revokeUrl} (opening it now).`);
|
|
88
|
+
const { openBrowser } = await import("@renown/sdk/node");
|
|
89
|
+
await openBrowser(withdraw.revokeUrl).catch(() => void 0);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case "unavailable": print(`Could not withdraw the login at Renown: ${withdraw.reason}. It lapses ${withdraw.expiresAt ? `on ${withdraw.expiresAt}` : "at its expiry"}.`);
|
|
93
|
+
}
|
|
94
|
+
for (const file of removed) print(`Deleted ${file}`);
|
|
95
|
+
}
|
|
96
|
+
const now = readActiveIdentity({ dataDir: identityDataDir() });
|
|
97
|
+
print(now ? `Now acting as ${now.label}.` : "Now acting as your pseudonym, made at the first signature.");
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
async function runIdentityPassword(args, print = console.log) {
|
|
101
|
+
const dataDir = identityDataDir();
|
|
102
|
+
if (readPseudonym({ dataDir })?.source === "env") {
|
|
103
|
+
print(`${IDENTITY_KEY_ENV} is set: that key has no file to protect.`);
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
if (!process.stdin.isTTY) {
|
|
107
|
+
print("`ph identity password` asks for passwords: run it in a terminal.");
|
|
108
|
+
return 1;
|
|
109
|
+
}
|
|
110
|
+
let newPassword;
|
|
111
|
+
if (!args.remove) {
|
|
112
|
+
newPassword = await askPassword("New password: ");
|
|
113
|
+
if (!newPassword) {
|
|
114
|
+
print("An empty password: use --remove to remove the password.");
|
|
115
|
+
return 1;
|
|
116
|
+
}
|
|
117
|
+
if (await askPassword("Repeat it: ") !== newPassword) {
|
|
118
|
+
print("The two passwords differ; nothing changed.");
|
|
119
|
+
return 1;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const result = await changePseudonymPassword({
|
|
123
|
+
dataDir,
|
|
124
|
+
unlock: { interactive: true },
|
|
125
|
+
...newPassword ? { newPassword } : {}
|
|
126
|
+
});
|
|
127
|
+
const label = pseudonymLabel(result.address);
|
|
128
|
+
print(result.created ? `Made your pseudonym ${label}${newPassword ? ", locked with the password" : ""}.` : newPassword ? `${label} is locked with the new password.` : `${label} has no password now: its files are readable by you only.`);
|
|
129
|
+
for (const file of result.written) print(` wrote ${file}`);
|
|
130
|
+
for (const file of result.missing) print(` not found (moved or deleted): ${file}`);
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { projectLoginNotice, runIdentityPassword, runLogout, runWhoami };
|
|
135
|
+
|
|
136
|
+
//# sourceMappingURL=identity-DXZFeQfC.mjs.map
|
|
137
|
+
//# debugId=cee9f7e8-d1fe-5e9e-b0c8-f66c5d03af19
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-DXZFeQfC.mjs","sources":["../src/services/identity.ts"],"sourcesContent":["import {\n askPassword,\n changePseudonymPassword,\n identityDataDir,\n type IdentityInfo,\n IDENTITY_KEY_ENV,\n loginPaths,\n pseudonymLabel,\n readActiveIdentity,\n readPseudonym,\n} from \"@powerhousedao/shared/clis/identity\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * `ph whoami`, `ph logout` and `ph identity`: who acts here, the Renown login\n * in the home folder, and the pseudonym when nobody is logged in.\n */\n\ntype Print = (line: string) => void;\n\nfunction keyLine(info: IdentityInfo): string {\n switch (info.source) {\n case \"env\":\n return `${IDENTITY_KEY_ENV} (never written)`;\n case \"data-folder\":\n return `${info.file} (this store's own)`;\n default:\n return `${info.file} (copied into this store at its first signature)`;\n }\n}\n\n/** What `ph whoami` prints for `info`. */\nexport function describeIdentity(info: IdentityInfo | undefined): string[] {\n if (!info) {\n return [\n \"Nobody yet: no Renown login, and no pseudonym on this computer.\",\n \"A pseudonym is made, readable by you only, when something must be signed here.\",\n \"`ph login` logs in with Renown.\",\n ];\n }\n if (info.kind === \"renown\") {\n const login = info.renown!;\n if (login.expired) {\n return [\n `Your Renown login as ${login.label} expired on ${login.expiresAt}.`,\n \"Nothing signs with it: run `ph login` again, or `ph logout` to act as your pseudonym.\",\n ];\n }\n return [\n `Logged in with Renown as ${login.label}`,\n ` Address: ${login.address}`,\n ...(login.expiresAt ? [` Expires: ${login.expiresAt}`] : []),\n ` Login: ${login.file}`,\n ];\n }\n return [\n `${info.label} (no Renown login)`,\n ` Address: ${info.address}`,\n ` Key: ${keyLine(info)}`,\n ` Password: ${info.encrypted ? \"yes\" : \"no\"}`,\n ...(info.differsFromHome\n ? [\n ` Your default pseudonym is ${pseudonymLabel(info.differsFromHome)}; this store keeps its own, which wrote its documents.`,\n ]\n : []),\n ];\n}\n\n/** A login `ph login` wrote into the project before 6.4: no longer read. */\nexport function projectLoginNotice(dataDir: string): string | undefined {\n const file = path.join(dataDir, \".ph\", \".renown.json\");\n try {\n const stored = JSON.parse(fs.readFileSync(file, \"utf8\")) as {\n user?: unknown;\n };\n if (!stored.user) return undefined;\n } catch {\n return undefined;\n }\n return `This project holds a login from before 6.4 in ${file}. It is no longer read; the upgrade step withdraws and removes it.`;\n}\n\nexport async function runWhoami(\n args: { json?: boolean; check?: boolean; renownUrl: string },\n print: Print = console.log,\n): Promise<number> {\n const dataDir = identityDataDir();\n let info = readActiveIdentity({ dataDir });\n let checked: \"valid\" | \"withdrawn\" | undefined;\n if (args.check && info?.kind === \"renown\" && !info.renown!.expired) {\n const { homeLoginRenown } = await import(\"@renown/sdk/identity\");\n // Revalidation logs out a login Renown no longer knows.\n const renown = await homeLoginRenown({ baseUrl: args.renownUrl });\n checked = renown.user ? \"valid\" : \"withdrawn\";\n info = readActiveIdentity({ dataDir });\n }\n if (args.json) {\n print(\n JSON.stringify(\n { identity: info ?? null, ...(checked ? { renown: checked } : {}) },\n null,\n 2,\n ),\n );\n return 0;\n }\n if (checked === \"withdrawn\") {\n print(\n \"Renown no longer knows your login: it was withdrawn or has expired.\",\n );\n }\n for (const line of describeIdentity(info)) print(line);\n if (checked === \"valid\") print(\" Renown: still valid\");\n const notice = projectLoginNotice(dataDir);\n if (notice) print(notice);\n return 0;\n}\n\nexport async function runLogout(\n args: { renownUrl: string },\n print: Print = console.log,\n): Promise<number> {\n const paths = loginPaths();\n if (!fs.existsSync(paths.file) && !fs.existsSync(paths.keypair)) {\n print(\"Not logged in.\");\n } else {\n const { logoutHome } = await import(\"@renown/sdk/identity\");\n const { withdraw, removed } = await logoutHome({\n renownUrl: args.renownUrl,\n });\n switch (withdraw.status) {\n case \"withdrawn\":\n print(\"Withdrew the login at Renown.\");\n break;\n case \"not-found\":\n print(\"Renown holds no such login any more.\");\n break;\n case \"refused\": {\n print(\n `Renown did not take this computer's key as proof (${withdraw.reason}).`,\n );\n print(\n `Withdraw it with your wallet at ${withdraw.revokeUrl} (opening it now).`,\n );\n const { openBrowser } = await import(\"@renown/sdk/node\");\n await openBrowser(withdraw.revokeUrl).catch(() => undefined);\n break;\n }\n case \"unavailable\":\n print(\n `Could not withdraw the login at Renown: ${withdraw.reason}. It lapses ${withdraw.expiresAt ? `on ${withdraw.expiresAt}` : \"at its expiry\"}.`,\n );\n break;\n case \"not-logged-in\":\n break;\n }\n for (const file of removed) print(`Deleted ${file}`);\n }\n const now = readActiveIdentity({ dataDir: identityDataDir() });\n print(\n now\n ? `Now acting as ${now.label}.`\n : \"Now acting as your pseudonym, made at the first signature.\",\n );\n return 0;\n}\n\nexport async function runIdentityPassword(\n args: { remove?: boolean },\n print: Print = console.log,\n): Promise<number> {\n const dataDir = identityDataDir();\n const info = readPseudonym({ dataDir });\n if (info?.source === \"env\") {\n print(`${IDENTITY_KEY_ENV} is set: that key has no file to protect.`);\n return 1;\n }\n if (!process.stdin.isTTY) {\n print(\"`ph identity password` asks for passwords: run it in a terminal.\");\n return 1;\n }\n let newPassword: string | undefined;\n if (!args.remove) {\n newPassword = await askPassword(\"New password: \");\n if (!newPassword) {\n print(\"An empty password: use --remove to remove the password.\");\n return 1;\n }\n if ((await askPassword(\"Repeat it: \")) !== newPassword) {\n print(\"The two passwords differ; nothing changed.\");\n return 1;\n }\n }\n const result = await changePseudonymPassword({\n dataDir,\n unlock: { interactive: true },\n ...(newPassword ? { newPassword } : {}),\n });\n const label = pseudonymLabel(result.address);\n print(\n result.created\n ? `Made your pseudonym ${label}${newPassword ? \", locked with the password\" : \"\"}.`\n : newPassword\n ? `${label} is locked with the new password.`\n : `${label} has no password now: its files are readable by you only.`,\n );\n for (const file of result.written) print(` wrote ${file}`);\n for (const file of result.missing)\n print(` not found (moved or deleted): ${file}`);\n return 0;\n}\n"],"names":[],"mappings":";;;;;;AAqBA,SAAS,QAAQ,MAA4B;CAC3C,QAAQ,KAAK,QAAb;EACE,KAAK,OACH,OAAO,GAAG,iBAAiB;EAC7B,KAAK,eACH,OAAO,GAAG,KAAK,KAAK;EACtB,SACE,OAAO,GAAG,KAAK,KAAK;CACxB;AACF;;AAGA,SAAgB,iBAAiB,MAA0C;CACzE,IAAI,CAAC,MACH,OAAO;EACL;EACA;EACA;CACF;CAEF,IAAI,KAAK,SAAS,UAAU;EAC1B,MAAM,QAAQ,KAAK;EACnB,IAAI,MAAM,SACR,OAAO,CACL,wBAAwB,MAAM,MAAM,cAAc,MAAM,UAAU,IAClE,uFACF;EAEF,OAAO;GACL,4BAA4B,MAAM;GAClC,eAAe,MAAM;GACrB,GAAI,MAAM,YAAY,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C/D,OAAO;EACT;EACA,IAAK,MAAM,YAAY,aAAa,MAAO,aAAa;GACtD,MAAM,4CAA4C;GAClD,OAAO;EACT;CACF;CACA,MAAM,SAAS,MAAM,wBAAwB;EAC3C;EACA,QAAQ,EAAE,aAAa,KAAK;EAC5B,GAAI,cAAc,EAAE,YAAY,IAAI,CAAC;CACvC,CAAC;CACD,MAAM,QAAQ,eAAe,OAAO,OAAO;CAC3C,MACE,OAAO,UACH,uBAAuB,QAAQ,cAAc,+BAA+B,GAAG,KAC/E,cACE,GAAG,MAAM,qCACT,GAAG,MAAM,0DACjB;CACA,KAAK,MAAM,QAAQ,OAAO,SAAS,MAAM,WAAW,MAAM;CAC1D,KAAK,MAAM,QAAQ,OAAO,SACxB,MAAM,mCAAmC,MAAM;CACjD,OAAO;AACT","debug_id":"cee9f7e8-d1fe-5e9e-b0c8-f66c5d03af19"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { S as $strip, _ as ZodUnion, b as $loose, d as ZodOptional, g as ZodURL, i as ZodBoolean, l as ZodNumber, m as ZodString, n as input, o as ZodEnum, p as ZodRecord, r as ZodArray, s as ZodLiteral, t as external_d_exports, u as ZodObject, v as ZodUnknown, x as $strict, y as output } from "./external-M25AgDIE.mjs";
|
|
2
|
-
import net from "node:net";
|
|
3
2
|
import { EnvToken, TokenableSchema } from "@powerhousedao/shared/host-tokens";
|
|
4
3
|
import "@powerhousedao/shared/connect/origin-placeholder";
|
|
4
|
+
import "@powerhousedao/shared/clis/owner-only";
|
|
5
|
+
import net from "node:net";
|
|
5
6
|
import "@powerhousedao/shared/clis";
|
|
6
|
-
//#region ../../packages/host-core/dist/control-channel-
|
|
7
|
+
//#region ../../packages/host-core/dist/control-channel-DVn4dvfQ.d.mts
|
|
7
8
|
/** A run record's `extra.control`. */
|
|
8
9
|
declare const controlRecordSchema: ZodObject<{
|
|
9
10
|
protocol: ZodNumber;
|
|
@@ -12,7 +13,7 @@ declare const controlRecordSchema: ZodObject<{
|
|
|
12
13
|
}, $strip>;
|
|
13
14
|
type ControlRecord = output<typeof controlRecordSchema>;
|
|
14
15
|
//#endregion
|
|
15
|
-
//#region ../../packages/host-core/dist/compound-
|
|
16
|
+
//#region ../../packages/host-core/dist/compound-BLhEewO6.d.mts
|
|
16
17
|
/** An installed package that supplies hosts: its name and its real folder,
|
|
17
18
|
* which its host files and their module specifiers resolve from. */
|
|
18
19
|
interface HostPackage {
|
|
@@ -257,4 +258,4 @@ declare global {
|
|
|
257
258
|
//#endregion
|
|
258
259
|
export { RunnerHandle as n, RunnerContext as t };
|
|
259
260
|
export {};
|
|
260
|
-
//# sourceMappingURL=index-
|
|
261
|
+
//# sourceMappingURL=index-aosqo7aM.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-aosqo7aM.d.mts","names":[],"sources":["../../../packages/host-core/dist/control-channel-DVn4dvfQ.d.mts","../../../packages/host-core/dist/compound-BLhEewO6.d.mts","../../../packages/host-core/dist/index.d.mts"],"mappings":";;;;;;;;cA+Ec,qBAAqB;EACjC,UAAU;EACV,SAAS;EACT,OAAO;GACN;KACE,gBAAgB,cAAe;;;;;UCjE1B;EACR;EACA;;cAykEY,mCAAmC;EAC/C,MAAM;EACN,QAAQ;IACN,QAAQ;IACR,aAAa,YAAc;IAC3B,MAAM,YAAc;IACpB,MAAM,YAAc;IACpB,SAAS,YAAc,SAAW,mBAAqB,WAAa;MAClE,QAAQ;MACR,SAAS,YAAc;MACvB,OAAO,YAAc,mBAAqB,iBAAmB,SAAW;MACxE,QAAQ,YAAc,UAAY,WAAa;OAC9C;KACF;EACH,UAAU,UAAY,WAAa;IACjC,MAAM;IACN,QAAQ,YAAc;MACpB,QAAQ,YAAc;MACtB,aAAa,YAAc,YAAc;MACzC,MAAM,YAAc,YAAc;MAClC,SAAS,YAAc,YAAc,SAAW,mBAAqB,WAAa;QAChF,QAAQ;QACR,SAAS,YAAc;QACvB,OAAO,YAAc,mBAAqB,iBAAmB,SAAW;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C/B,aAAa,YAAc;UACzB;UACA;UACA;;QAEF,kBAAkB,YAAc;QAChC,QAAQ,YAAc;UACpB,KAAK,gBAAgB;WACpB;SACF;OACF;IACH,SAAS,YAAc;MACrB;MACA;;KAED;EACH,SAAS,YAAc;IACrB,OAAO,YAAc;IACrB,MAAM,YAAc;IACpB,aAAa,YAAc;IAC3B,MAAM,YAAc;KACnB;EACH,QAAQ,YAAc;IACpB,YAAY,YAAc,SAAW;IACrC,eAAe,YAAc;IAC7B,iBAAiB,YAAc;KAC9B;GACF;UA2GO;;;EAGR;;;;EAIA,cAAc;;;EAGd;EACA,KAAK;;;EAGL;IACE;IACA;;;;;EAKF;;;;;;EAMA,mBAAmB;;;;EAInB,aAAa;;;UAGL;;EAER,oBAAoB;;;;EAIpB;;EAEA;;EAEA,UAAU;;;;;;;UAOF;;EAER;;EAEA;EACA;EACA;;EAEA;;EAEA,WAAW;;EAEX;EACA;;;;;;;;;;UA8MQ,aAAa,IAAI;EACzB,SAAS;;EAET,OAAO;;EAEP,YAAY;;;;;;QC/iEN;;;YAGI;;YAEA;;QA0CJ;YACI;IACR;MACE,MAAM,aAAe;MACrB,SAAS"}
|
|
@@ -1,8 +1,8 @@
|
|
|
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]="
|
|
3
|
-
import { t as readProjectSubgraphs } from "./subgraphs-
|
|
4
|
-
import { n as processStreams, r as runModelCommand } from "./run
|
|
5
|
-
import { n as renderInspectionReport } from "./render-
|
|
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]="687714a8-f025-597f-969a-65d01d37ab69")}catch(e){}}();
|
|
3
|
+
import { t as readProjectSubgraphs } from "./subgraphs-Bm9NHTCn.mjs";
|
|
4
|
+
import { n as processStreams, r as runModelCommand } from "./run-sVzTTEUx.mjs";
|
|
5
|
+
import { n as renderInspectionReport } from "./render-CQdi685k.mjs";
|
|
6
6
|
import { inspectProjectDefinitions, withSubgraphInspection } from "document-model/tooling";
|
|
7
7
|
//#region src/services/model/inspect.ts
|
|
8
8
|
/** `<documentType>@<version>`; a document type may itself contain `@`. */
|
|
@@ -48,5 +48,5 @@ async function runModelInspect(args, options = {}) {
|
|
|
48
48
|
//#endregion
|
|
49
49
|
export { runModelInspect };
|
|
50
50
|
|
|
51
|
-
//# sourceMappingURL=inspect-
|
|
52
|
-
//# debugId=
|
|
51
|
+
//# sourceMappingURL=inspect-BgKI8Fhd.mjs.map
|
|
52
|
+
//# debugId=687714a8-f025-597f-969a-65d01d37ab69
|