@powerhousedao/ph-cli 6.4.0-next.2 → 6.4.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/{build-C7RBpPwa.mjs → build-B-rPwjM8.mjs} +6 -6
- package/dist/{build-C7RBpPwa.mjs.map → build-B-rPwjM8.mjs.map} +1 -1
- package/dist/build-DuwAPWMY.mjs +4 -0
- package/dist/{check-1Hfe0lVO.mjs → check-B7C3Vi_b.mjs} +4 -4
- package/dist/{check-1Hfe0lVO.mjs.map → check-B7C3Vi_b.mjs.map} +1 -1
- package/dist/{check-MBdw9Lbm.mjs → check-DM7UdFTK.mjs} +4 -4
- package/dist/{check-MBdw9Lbm.mjs.map → check-DM7UdFTK.mjs.map} +1 -1
- package/dist/{check-ClxYRer4.mjs → check-DeUTd514.mjs} +3 -3
- package/dist/{cli-connect-override-DsuuectH.mjs → cli-connect-override-Bx_g3-ZE.mjs} +4 -4
- package/dist/{cli-connect-override-DsuuectH.mjs.map → cli-connect-override-Bx_g3-ZE.mjs.map} +1 -1
- package/dist/cli.mjs +8 -8
- package/dist/cli.mjs.map +1 -1
- package/dist/{compound-Q9sZSEZF-zZWzQ7VC.mjs → compound-Q9sZSEZF-DQvtoigb.mjs} +4 -4
- package/dist/{compound-Q9sZSEZF-zZWzQ7VC.mjs.map → compound-Q9sZSEZF-DQvtoigb.mjs.map} +1 -1
- package/dist/{connect-build-DAnGPSF5.mjs → connect-build-CaTxdYcc.mjs} +5 -5
- package/dist/{connect-build-DAnGPSF5.mjs.map → connect-build-CaTxdYcc.mjs.map} +1 -1
- package/dist/{connect-config-C0QZ7zTf.mjs → connect-config-A-U83U8U.mjs} +4 -4
- package/dist/{connect-config-C0QZ7zTf.mjs.map → connect-config-A-U83U8U.mjs.map} +1 -1
- package/dist/{connect-studio-BUth3UYP.mjs → connect-studio-B2gugCJU.mjs} +4 -4
- package/dist/{connect-studio-BUth3UYP.mjs.map → connect-studio-B2gugCJU.mjs.map} +1 -1
- package/dist/definitions-worker.mjs +1 -1
- package/dist/dev-host-RhWeATKB.mjs +19 -0
- package/dist/dev-host-RhWeATKB.mjs.map +1 -0
- package/dist/{dist-CRR5Anp2.mjs → dist-D_UjZsgt.mjs} +4 -4
- package/dist/{dist-CRR5Anp2.mjs.map → dist-D_UjZsgt.mjs.map} +1 -1
- package/dist/{explain-BfOC7Ngv.mjs → explain-DbbHpa61.mjs} +5 -5
- package/dist/{explain-BfOC7Ngv.mjs.map → explain-DbbHpa61.mjs.map} +1 -1
- package/dist/{export-CdTqYviH.mjs → export-FduYVQEM.mjs} +4 -4
- package/dist/{export-CdTqYviH.mjs.map → export-FduYVQEM.mjs.map} +1 -1
- package/dist/{files-D6_euBBn.mjs → files-DEHg350R.mjs} +4 -4
- package/dist/{files-D6_euBBn.mjs.map → files-DEHg350R.mjs.map} +1 -1
- package/dist/{generate-all-HujZHqCG.mjs → generate-all-BE8UmbJv.mjs} +6 -21
- package/dist/generate-all-BE8UmbJv.mjs.map +1 -0
- package/dist/{generate-app-hm6CJ_4O.mjs → generate-app-C7n0j8Ak.mjs} +5 -18
- package/dist/generate-app-C7n0j8Ak.mjs.map +1 -0
- package/dist/{generate-document-model-BiD6ovXc.mjs → generate-document-model-DSYPTMZg.mjs} +9 -31
- package/dist/generate-document-model-DSYPTMZg.mjs.map +1 -0
- package/dist/{generate-editor-DBj_Pxwa.mjs → generate-editor-DKuRUeIt.mjs} +5 -18
- package/dist/generate-editor-DKuRUeIt.mjs.map +1 -0
- package/dist/{generate-processor-BVjOsfjJ.mjs → generate-processor-CwJvJDpd.mjs} +5 -18
- package/dist/generate-processor-CwJvJDpd.mjs.map +1 -0
- package/dist/{generate-subgraph-DJZCr0Tk.mjs → generate-subgraph-EQ2ZjMp9.mjs} +6 -25
- package/dist/generate-subgraph-EQ2ZjMp9.mjs.map +1 -0
- package/dist/{get-version-DAYhm6MX.mjs → get-version-7oKMD8Gt.mjs} +4 -4
- package/dist/{get-version-DAYhm6MX.mjs.map → get-version-7oKMD8Gt.mjs.map} +1 -1
- package/dist/{mcp-rtMGg307.mjs → mcp-CcZT9zT9.mjs} +8 -8
- package/dist/mcp-CcZT9zT9.mjs.map +1 -0
- package/dist/{migrate-CWCJP19Q.mjs → migrate-Ddr7YAtM.mjs} +4 -4
- package/dist/{migrate-CWCJP19Q.mjs.map → migrate-Ddr7YAtM.mjs.map} +1 -1
- package/dist/{migrate-document-models-DTxM7D7p.mjs → migrate-document-models-X_mVTljj.mjs} +4 -4
- package/dist/{migrate-document-models-DTxM7D7p.mjs.map → migrate-document-models-X_mVTljj.mjs.map} +1 -1
- package/dist/migrate-subgraphs-DEqWkLoh.mjs +4 -0
- package/dist/{migrate-subgraphs-_yRnF7xt.mjs → migrate-subgraphs-Ffwwm7Oy.mjs} +5 -5
- package/dist/{migrate-subgraphs-_yRnF7xt.mjs.map → migrate-subgraphs-Ffwwm7Oy.mjs.map} +1 -1
- package/dist/{ph-cli-commands-FLZClR4x.mjs → ph-cli-commands-D4Z6YSwd.mjs} +39 -104
- package/dist/ph-cli-commands-D4Z6YSwd.mjs.map +1 -0
- package/dist/ph-cli-commands-p9cO6MsE.mjs +4 -0
- package/dist/{run-sugar-DUiDFl_T.mjs → run-sugar-CkuGJuPg.mjs} +16 -8
- package/dist/run-sugar-CkuGJuPg.mjs.map +1 -0
- package/dist/{run-sugar-YDxw0iV9.mjs → run-sugar-Dd_Mu058.mjs} +3 -3
- package/dist/runners/connect.mjs +2 -2
- package/dist/runners/switchboard.mjs +3 -3
- package/dist/{sugar-checks-BFu3sfFJ.mjs → sugar-checks-CAtgUIem.mjs} +16 -15
- package/dist/sugar-checks-CAtgUIem.mjs.map +1 -0
- package/dist/{verify-Dkb6K1fc.mjs → verify-DXrs0JUp.mjs} +5 -5
- package/dist/{verify-Dkb6K1fc.mjs.map → verify-DXrs0JUp.mjs.map} +1 -1
- package/dist/{vetra-gateway-BMzq0mqX.mjs → vetra-gateway-BHuz7pvS.mjs} +5 -5
- package/dist/{vetra-gateway-BMzq0mqX.mjs.map → vetra-gateway-BHuz7pvS.mjs.map} +1 -1
- package/dist/vetra-gateway-ag33E_Ta.mjs +4 -0
- package/dist/{vetra-host-C37IGwBM.mjs → vetra-host-CYdbd3J3.mjs} +28 -11
- package/dist/vetra-host-CYdbd3J3.mjs.map +1 -0
- package/dist/{vetra-launcher-Dq0tWyNW.mjs → vetra-launcher-B5L3yXPo.mjs} +16 -13
- package/dist/vetra-launcher-B5L3yXPo.mjs.map +1 -0
- package/dist/vetra-launcher-BUO9e74r.mjs +4 -0
- package/dist/{vetra-instance-CLUzbtbh.mjs → vetra-runtime-Bk6CW-BE.mjs} +6 -24
- package/dist/vetra-runtime-Bk6CW-BE.mjs.map +1 -0
- package/dist/warn-subgraph-type-conflicts-BZ4NwLx5.mjs +131 -0
- package/dist/warn-subgraph-type-conflicts-BZ4NwLx5.mjs.map +1 -0
- package/package.json +15 -16
- package/dist/build-BUpe1j4m.mjs +0 -4
- package/dist/generate-all-HujZHqCG.mjs.map +0 -1
- package/dist/generate-app-hm6CJ_4O.mjs.map +0 -1
- package/dist/generate-document-model-BiD6ovXc.mjs.map +0 -1
- package/dist/generate-editor-DBj_Pxwa.mjs.map +0 -1
- package/dist/generate-processor-BVjOsfjJ.mjs.map +0 -1
- package/dist/generate-subgraph-DJZCr0Tk.mjs.map +0 -1
- package/dist/mcp-rtMGg307.mjs.map +0 -1
- package/dist/migrate-subgraphs-DcJjLMFd.mjs +0 -4
- package/dist/ph-cli-commands-CRwA1aVX.mjs +0 -4
- package/dist/ph-cli-commands-FLZClR4x.mjs.map +0 -1
- package/dist/run-sugar-DUiDFl_T.mjs.map +0 -1
- package/dist/sugar-checks-BFu3sfFJ.mjs.map +0 -1
- package/dist/vetra-gateway-BP6Catg4.mjs +0 -4
- package/dist/vetra-host-C37IGwBM.mjs.map +0 -1
- package/dist/vetra-instance-CLUzbtbh.mjs.map +0 -1
- package/dist/vetra-launcher-CJ01qmS1.mjs +0 -4
- package/dist/vetra-launcher-Dq0tWyNW.mjs.map +0 -1
- package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +0 -19
- package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-subgraph-EQ2ZjMp9.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/** The notice for `--code-first` on an existing schema-first subgraph, which\n * is then left unchanged. */\nfunction codeFirstOnSchemaFirst(\n args: GenerateSubgraphArgs,\n projectDir: string,\n name: string,\n): string | undefined {\n if (!args.codeFirst) return undefined;\n const subgraphsDir = join(projectDir, \"subgraphs\");\n const dirName = kebabCase(name);\n if (\n !existsSync(join(subgraphsDir, dirName, \"index.ts\")) ||\n subgraphDirStyle(subgraphsDir, dirName) !== \"schema-first\"\n )\n return undefined;\n return `subgraphs/${dirName} is schema-first; --code-first only applies to new subgraphs. To convert it, run ph migrate --subgraph ${dirName}.`;\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 const notice = codeFirstOnSchemaFirst(args, projectDir, name);\n if (notice) {\n console.log(notice);\n return;\n }\n await assertSubgraphNameFree(projectDir, name);\n await generateSubgraph(name, project, { codeFirst: args.codeFirst });\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":["installA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UAAU,CAAC;CACrE,OAAO,IAAI,KAAK;EACd,MAAM,UAAU,qBACd,YACA,aACA,KACA,aACF;EACA,IAAI,CAAC,WAAW,KAAK,YAAY,aAAa,SAAS,UAAU,CAAC,GAChE,MAAM,IAAI,MAAM,aAAa,QAAQ,kBAAkB;EAEzD,MAAM,EAAE,cAAc,UAAU,MAAM,oBAAoB,SAAS,OAAO;EAC1E,IAAI,CAAC,cACH,MAAM,IAAI,MACR,4BAA4B,QAAQ,sBAAsB,uBAAuB,OAAO,EAC1F;EAEF,OAAO,KAAK,yBAAyB,aAAa,EAAE;CACtD,OAAO;EACL,QAAQ,IAAI,gDAAgD;EAC5D;CACF;CACA,MAAM,QAAQ,KAAK;CACnB,KAAK,MAAM,QAAQ,QACjB,QAAQ,IAAI,IAAI;CAElB,MAAM,0BAA0B,UAAU;CAC1C,MAAM,QAAQ,MAAM,wBAClB,eAAe,UAAU,GACzB,UACF;CACA,MAAMA,2BAAyB,OAAO,YAAY,KAAK,WAAW;AACpE","debug_id":"6106c53a-29b0-5d26-8dde-d0627343082d"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
//#region src/get-version.ts
|
|
2
2
|
|
|
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]="3b5e16f0-6fea-5b41-bdc0-5a5465da6b80")}catch(e){}}();
|
|
4
4
|
function getVersion() {
|
|
5
|
-
return "6.4.0-next.
|
|
5
|
+
return "6.4.0-next.3";
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
export { getVersion as t };
|
|
9
9
|
|
|
10
|
-
//# sourceMappingURL=get-version-
|
|
11
|
-
//# debugId=
|
|
10
|
+
//# sourceMappingURL=get-version-7oKMD8Gt.mjs.map
|
|
11
|
+
//# debugId=3b5e16f0-6fea-5b41-bdc0-5a5465da6b80
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-version-
|
|
1
|
+
{"version":3,"file":"get-version-7oKMD8Gt.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":"3b5e16f0-6fea-5b41-bdc0-5a5465da6b80"}
|
|
@@ -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 getVersion } from "./get-version-
|
|
4
|
-
import {
|
|
5
|
-
import { a as restartVetra, n as currentPhCliRunVetraCommand, r as ensureVetra, t as VetraStartError } from "./vetra-launcher-
|
|
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]="3310b97c-72c7-576c-91fb-40abfcad6119")}catch(e){}}();
|
|
3
|
+
import { t as getVersion } from "./get-version-7oKMD8Gt.mjs";
|
|
4
|
+
import { i as readVetraRuntime } from "./vetra-runtime-Bk6CW-BE.mjs";
|
|
5
|
+
import { a as restartVetra, n as currentPhCliRunVetraCommand, r as ensureVetra, t as VetraStartError } from "./vetra-launcher-B5L3yXPo.mjs";
|
|
6
6
|
import { resolveSwitchboardPortDefault } from "@powerhousedao/shared/clis/args";
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
@@ -61,7 +61,7 @@ function isStaleConnection(error) {
|
|
|
61
61
|
}
|
|
62
62
|
const restartVetraTool = {
|
|
63
63
|
name: "restartVetra",
|
|
64
|
-
description: "Restart this project's
|
|
64
|
+
description: "Restart this project's dev stack (its Switchboard and Connect, what `ph dev` runs) and wait until it is ready. Use it after a change the stack reads only at startup, such as the reactor or packages settings in powerhouse.config.json; Connect restarts by itself for connect.* changes. Returns the new Connect, Switchboard and MCP URLs.",
|
|
65
65
|
inputSchema: {
|
|
66
66
|
type: "object",
|
|
67
67
|
properties: {}
|
|
@@ -156,7 +156,7 @@ var Upstream = class {
|
|
|
156
156
|
projectDir,
|
|
157
157
|
projectName: name,
|
|
158
158
|
switchboardPort: resolveSwitchboardPortDefault(),
|
|
159
|
-
command: this.options.vetraCommand ?? currentPhCliRunVetraCommand(),
|
|
159
|
+
command: this.options.vetraCommand ?? currentPhCliRunVetraCommand(projectDir),
|
|
160
160
|
timeoutMs: this.options.startTimeoutSeconds * 1e3,
|
|
161
161
|
onProgress: this.#report
|
|
162
162
|
});
|
|
@@ -259,5 +259,5 @@ async function startMcpLauncher(options) {
|
|
|
259
259
|
//#endregion
|
|
260
260
|
export { startMcpLauncher };
|
|
261
261
|
|
|
262
|
-
//# sourceMappingURL=mcp-
|
|
263
|
-
//# debugId=
|
|
262
|
+
//# sourceMappingURL=mcp-CcZT9zT9.mjs.map
|
|
263
|
+
//# debugId=3310b97c-72c7-576c-91fb-40abfcad6119
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-CcZT9zT9.mjs","sources":["../src/services/mcp.ts"],"sourcesContent":["import { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport {\n StreamableHTTPClientTransport,\n StreamableHTTPError,\n} from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport { InMemoryTransport } from \"@modelcontextprotocol/sdk/inMemory.js\";\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n CallToolResultSchema,\n ListResourcesRequestSchema,\n ListResourceTemplatesRequestSchema,\n ListToolsRequestSchema,\n McpError,\n ReadResourceRequestSchema,\n type CallToolRequest,\n type CallToolResult,\n type Tool,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport type { IReactorClient } from \"@powerhousedao/reactor\";\nimport { createServer } from \"@powerhousedao/reactor-mcp\";\nimport { resolveSwitchboardPortDefault } from \"@powerhousedao/shared/clis/args\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { getVersion } from \"../get-version.js\";\nimport {\n ensureVetra,\n restartVetra,\n currentPhCliRunVetraCommand,\n VetraStartError,\n type EnsureVetraOptions,\n type VetraCommand,\n} from \"../utils/vetra-launcher.js\";\nimport {\n readVetraRuntime,\n type VetraRuntimeRecord,\n} from \"../utils/vetra-runtime.js\";\n\nconst CALL_TIMEOUT_MS = 10 * 60_000;\nconst CONFIG_FILE = \"powerhouse.config.json\";\n\nexport type McpLauncherOptions = {\n projectDir?: string;\n startTimeoutSeconds: number;\n /** Test seam: what starts Vetra; defaults to {@link currentPhCliRunVetraCommand}. */\n vetraCommand?: VetraCommand;\n};\n\n/** The nearest directory at or above `start` holding powerhouse.config.json. */\nexport function findProjectDir(start: string): string | undefined {\n let dir = path.resolve(start);\n for (;;) {\n if (fs.existsSync(path.join(dir, CONFIG_FILE))) return dir;\n const parent = path.dirname(dir);\n if (parent === dir) return undefined;\n dir = parent;\n }\n}\n\n// The tool list never touches the reactor, so a client that throws on use is enough.\nconst reactorlessClient = new Proxy({} as IReactorClient, {\n get(_target, property) {\n if (property === \"then\") return undefined;\n return () => {\n throw new Error(\"reactor-mcp's local tool list has no reactor\");\n };\n },\n});\n\n/** reactor-mcp's own server, in-process, for the tool list and resources. */\nasync function connectLocalReactorMcp(): Promise<Client> {\n const server = await createServer({ client: reactorlessClient });\n const [clientSide, serverSide] = InMemoryTransport.createLinkedPair();\n await server.connect(serverSide);\n const client = new Client({ name: \"ph-mcp\", version: getVersion() });\n await client.connect(clientSide);\n return client;\n}\n\nfunction toolError(message: string): CallToolResult {\n return { isError: true, content: [{ type: \"text\", text: message }] };\n}\n\n/** The call never reached a live session: Vetra is down, or restarted since. */\nfunction isStaleConnection(error: unknown): boolean {\n if (error instanceof StreamableHTTPError) {\n return error.code === 404 || error.code === 400;\n }\n for (let e = error; e instanceof Error; e = e.cause) {\n if ((e as NodeJS.ErrnoException).code === \"ECONNREFUSED\") return true;\n }\n return false;\n}\n\nexport const RESTART_VETRA_TOOL = \"restartVetra\";\n\nconst restartVetraTool: Tool = {\n name: RESTART_VETRA_TOOL,\n description:\n \"Restart this project's dev stack (its Switchboard and Connect, what `ph dev` runs) and wait until it is ready. \" +\n \"Use it after a change the stack reads only at startup, such as the reactor or packages settings \" +\n \"in powerhouse.config.json; Connect restarts by itself for connect.* changes. \" +\n \"Returns the new Connect, Switchboard and MCP URLs.\",\n inputSchema: { type: \"object\", properties: {} },\n outputSchema: {\n type: \"object\",\n properties: {\n pid: { type: \"number\" },\n connectUrl: { type: \"string\" },\n switchboardUrl: { type: \"string\" },\n mcpUrl: { type: \"string\" },\n },\n required: [\"pid\", \"mcpUrl\"],\n },\n};\n\nfunction vetraUrls(record: VetraRuntimeRecord) {\n return {\n pid: record.pid,\n ...(record.connectUrl ? { connectUrl: record.connectUrl } : {}),\n switchboardUrl:\n record.switchboardUrl ??\n `http://localhost:${record.switchboardPort}/graphql`,\n mcpUrl: record.mcpUrl || `http://localhost:${record.switchboardPort}/mcp`,\n };\n}\n\nfunction projectName(projectDir: string): string | undefined {\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(projectDir, \"package.json\"), \"utf8\"),\n ) as { name?: string };\n return pkg.name;\n } catch {\n return undefined;\n }\n}\n\n/** Connects to the project's Vetra `/mcp`, starting Vetra when it is down. */\ntype Progress = (message: string) => void;\n\nclass Upstream {\n #client: Promise<Client> | undefined;\n /** The Vetra the client talks to; another pid in the record means it restarted. */\n #pid: number | undefined;\n /** The calls waiting on the connection, told how Vetra's start goes. */\n #waiting = new Set<Progress>();\n\n constructor(\n private readonly projectDir: string | undefined,\n private readonly options: McpLauncherOptions,\n ) {}\n\n get(onProgress?: Progress): Promise<Client> {\n if (this.#client && this.#pid !== undefined && this.projectDir) {\n const pid = readVetraRuntime(this.projectDir)?.pid;\n if (pid !== this.#pid) this.reset();\n }\n this.#client ??= this.#connect(ensureVetra).catch((error: unknown) => {\n this.#client = undefined;\n throw error;\n });\n return this.#waitWith(this.#client, onProgress);\n }\n\n async #waitWith<T>(task: Promise<T>, onProgress?: Progress): Promise<T> {\n if (onProgress) this.#waiting.add(onProgress);\n try {\n return await task;\n } finally {\n if (onProgress) this.#waiting.delete(onProgress);\n }\n }\n\n #report = (message: string) => {\n for (const progress of this.#waiting) progress(message);\n };\n\n reset(): void {\n const stale = this.#client;\n this.#client = undefined;\n this.#pid = undefined;\n void stale?.then((client) => client.close()).catch(() => {});\n }\n\n /** Restarts Vetra and connects to the new one; resolves to its record. */\n async restart(onProgress?: Progress): Promise<VetraRuntimeRecord> {\n this.reset();\n let record: VetraRuntimeRecord | undefined;\n const connected = this.#connect(async (options) => {\n record = await restartVetra(options);\n return record;\n });\n this.#client = connected.catch((error: unknown) => {\n this.#client = undefined;\n throw error;\n });\n await this.#waitWith(this.#client, onProgress);\n return record!;\n }\n\n async #connect(\n start: (options: EnsureVetraOptions) => Promise<VetraRuntimeRecord>,\n ): Promise<Client> {\n const { projectDir } = this;\n if (!projectDir) {\n throw new VetraStartError(\n `No Powerhouse project (${CONFIG_FILE}) at or above ${process.cwd()}. Run \\`ph mcp\\` inside the project, or pass --project-dir.`,\n );\n }\n const name = projectName(projectDir);\n if (!name) {\n throw new VetraStartError(`${projectDir} has no package.json name.`);\n }\n console.error(`[ph mcp] connecting to Vetra for ${name}...`);\n const record = await start({\n projectDir,\n projectName: name,\n switchboardPort: resolveSwitchboardPortDefault(),\n command:\n this.options.vetraCommand ?? currentPhCliRunVetraCommand(projectDir),\n timeoutMs: this.options.startTimeoutSeconds * 1000,\n onProgress: this.#report,\n });\n const { mcpUrl } = vetraUrls(record);\n const client = new Client({ name: \"ph-mcp\", version: getVersion() });\n await client.connect(new StreamableHTTPClientTransport(new URL(mcpUrl)));\n this.#pid = record.pid;\n console.error(`[ph mcp] forwarding tool calls to ${mcpUrl}`);\n return client;\n }\n}\n\nasync function forwardToolCall(\n upstream: Upstream,\n params: CallToolRequest[\"params\"],\n signal: AbortSignal,\n onProgress: Progress,\n): Promise<CallToolResult> {\n for (let attempt = 0; ; attempt++) {\n const client = await upstream.get(onProgress);\n try {\n return await client.request(\n { method: \"tools/call\", params },\n CallToolResultSchema,\n { signal, timeout: CALL_TIMEOUT_MS },\n );\n } catch (error) {\n // It never arrived: Vetra went away or restarted, so find or start it again.\n if (attempt > 0 || !isStaleConnection(error)) throw error;\n upstream.reset();\n }\n }\n}\n\n/** `ph mcp`: tools listed by in-process reactor-mcp, calls forwarded to Vetra (started on first call). */\nexport async function startMcpLauncher(options: McpLauncherOptions) {\n // stdout carries JSON-RPC only.\n console.log = console.error;\n console.info = console.error;\n\n const projectDir = findProjectDir(\n options.projectDir ?? process.env.PH_CALLER_CWD ?? process.cwd(),\n );\n // Port resolution and `ph run dev` both read the project from the cwd.\n if (projectDir) process.chdir(projectDir);\n\n const local = await connectLocalReactorMcp();\n const upstream = new Upstream(projectDir, options);\n const server = new Server(\n local.getServerVersion() ?? { name: \"reactor-mcp-server\", version: \"\" },\n {\n capabilities: { tools: {}, resources: {} },\n instructions: local.getInstructions(),\n },\n );\n\n server.setRequestHandler(ListToolsRequestSchema, async (request) => {\n const listed = await local.listTools(request.params);\n return { ...listed, tools: [...listed.tools, restartVetraTool] };\n });\n server.setRequestHandler(ListResourcesRequestSchema, (request) =>\n local.listResources(request.params),\n );\n server.setRequestHandler(ListResourceTemplatesRequestSchema, (request) =>\n local.listResourceTemplates(request.params),\n );\n server.setRequestHandler(ReadResourceRequestSchema, (request) =>\n local.readResource(request.params),\n );\n server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {\n // How Vetra's start goes: progress notifications when the client asked, else stderr.\n const token = request.params._meta?.progressToken;\n let progress = 0;\n const onProgress: Progress = (message) => {\n if (token === undefined) {\n console.error(`[ph mcp] ${message}`);\n return;\n }\n void extra\n .sendNotification({\n method: \"notifications/progress\",\n params: { progressToken: token, progress: ++progress, message },\n })\n .catch(() => {});\n };\n try {\n if (request.params.name === RESTART_VETRA_TOOL) {\n const urls = vetraUrls(await upstream.restart(onProgress));\n return {\n content: [{ type: \"text\", text: JSON.stringify(urls) }],\n structuredContent: urls,\n };\n }\n return await forwardToolCall(\n upstream,\n request.params,\n extra.signal,\n onProgress,\n );\n } catch (error) {\n // Protocol errors from reactor-mcp reach the agent as they would over HTTP.\n if (error instanceof McpError) throw error;\n const message = error instanceof Error ? error.message : String(error);\n return toolError(\n error instanceof VetraStartError\n ? message\n : `reactor-mcp request failed: ${message}`,\n );\n }\n });\n\n const transport = new StdioServerTransport();\n transport.onclose = () => process.exit(0);\n process.stdin.once(\"end\", () => process.exit(0));\n await server.connect(transport);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuCA,MAAM,kBAAkB;AACxB,MAAM,cAAc;;AAUpB,SAAgB,eAAe,OAAmC;CAChE,IAAI,MAAM,KAAK,QAAQ,KAAK;CAC5B,SAAS;EACP,IAAI,GAAG,WAAW,KAAK,KAAK,KAAK,WAAW,CAAC,GAAG,OAAO;EACvD,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AAI,QAAQ,OAAO,SAAA,gBAA6B;IAC9C,MAAM,OAAO,UAAU,MAAM,SAAS,QAAQ,UAAU,CAAC;IACzD,OAAO;KACL,SAAS,CAAC;MAAE,MAAM;MAAQ,MAAM,KAAK,UAAU,IAAI;KAAE,CAAC;KACtD,mBAAmB;IACrB;GACF;GACA,OAAO,MAAM,gBACX,UACA,QAAQ,QACR,MAAM,QACN,UACF;EACF,SAAS,OAAO;GAEd,IAAI,iBAAiB,UAAU,MAAM;GACrC,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GACrE,OAAO,UACL,iBAAiB,kBACb,UACA,+BAA+B,SACrC;EACF;CACF,CAAC;CAED,MAAM,YAAY,IAAI,qBAAqB;CAC3C,UAAU,gBAAgB,QAAQ,KAAK,CAAC;CACxC,QAAQ,MAAM,KAAK,aAAa,QAAQ,KAAK,CAAC,CAAC;CAC/C,MAAM,OAAO,QAAQ,SAAS;AAChC","debug_id":"3310b97c-72c7-576c-91fb-40abfcad6119"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
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]="b871feee-1509-5354-9e80-365512977a3c")}catch(e){}}();
|
|
3
3
|
import { i as findNodeProjectRoot, s as isPowerhouseProject } from "./utils-D5VlY5AZ.mjs";
|
|
4
|
-
import { n as unifiedDiff } from "./migrate-subgraphs-
|
|
4
|
+
import { n as unifiedDiff } from "./migrate-subgraphs-Ffwwm7Oy.mjs";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { dirname, join, relative } from "node:path";
|
|
7
7
|
import { execSync } from "node:child_process";
|
|
@@ -205,5 +205,5 @@ async function startMigrate({ versionPositional, version, force, debug, dryRun }
|
|
|
205
205
|
//#endregion
|
|
206
206
|
export { startMigrate };
|
|
207
207
|
|
|
208
|
-
//# sourceMappingURL=migrate-
|
|
209
|
-
//# debugId=
|
|
208
|
+
//# sourceMappingURL=migrate-Ddr7YAtM.mjs.map
|
|
209
|
+
//# debugId=b871feee-1509-5354-9e80-365512977a3c
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-CWCJP19Q.mjs","sources":["../src/services/migrate.ts"],"sourcesContent":["import {\n fetchPackageVersionFromNpmRegistry,\n injectPnpmAllowBuilds,\n spawnAsync,\n} from \"@powerhousedao/shared/clis\";\nimport { ALL_POWERHOUSE_DEPENDENCIES } from \"@powerhousedao/shared/constants\";\nimport { execSync } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join, relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { detect, resolveCommand } from \"package-manager-detector\";\nimport { compare, minVersion, prerelease, rcompare, valid } from \"semver\";\nimport type { MigrateArgs } from \"../types.js\";\nimport { findNodeProjectRoot, isPowerhouseProject } from \"../utils.js\";\nimport { unifiedDiff } from \"./migrate-subgraphs.js\";\n\n// Dist-tags a prerelease version can name its channel by.\nconst PRERELEASE_TAGS = [\"dev\", \"staging\", \"rc\", \"next\"];\n\n// Set on the re-executed migrate, so the version check runs once.\nconst VERSION_CHECKED_ENV = \"PH_MIGRATE_VERSION_CHECKED\";\n\ntype ProjectPackageJson = Partial<\n Record<\n \"dependencies\" | \"devDependencies\" | \"peerDependencies\",\n Record<string, string>\n >\n>;\n\nfunction readProjectPackageJson(projectDir: string): ProjectPackageJson {\n try {\n return JSON.parse(\n readFileSync(join(projectDir, \"package.json\"), \"utf8\"),\n ) as ProjectPackageJson;\n } catch {\n return {};\n }\n}\n\n/** The newest Powerhouse package version the project's package.json pins */\nexport function newestPowerhouseVersion(packageJson: ProjectPackageJson) {\n const pinned = [\n packageJson.dependencies,\n packageJson.devDependencies,\n packageJson.peerDependencies,\n ].flatMap((deps) =>\n Object.entries(deps ?? {}).flatMap(([name, range]) => {\n if (!ALL_POWERHOUSE_DEPENDENCIES.includes(name)) return [];\n try {\n const version = minVersion(range)?.version;\n return version ? [{ name, version }] : [];\n } catch {\n // workspace:, catalog: and other non-semver specifiers\n return [];\n }\n }),\n );\n return pinned.sort((a, b) => rcompare(a.version, b.version)).at(0);\n}\n\n/** The dist-tag of the channel the project is on, and why */\nexport function inferReleaseTag(packageJson: ProjectPackageJson): {\n tag: string;\n reason: string;\n} {\n const newest = newestPowerhouseVersion(packageJson);\n if (!newest) {\n return { tag: \"latest\", reason: \"no Powerhouse package version is pinned\" };\n }\n const channel = prerelease(newest.version)?.[0];\n const pinned = `${newest.name}@${newest.version}`;\n if (typeof channel === \"string\" && PRERELEASE_TAGS.includes(channel)) {\n return { tag: channel, reason: `the project is on ${pinned}` };\n }\n return {\n tag: \"latest\",\n reason: `the project is on ${pinned}, ${channel === undefined ? \"a stable release\" : \"not on a dev, staging, rc or next channel\"}`,\n };\n}\n\n/** Whether `target` is an older release than `installed`: lower by semver, or\n * published earlier (6.2.3 ranks above 6.2.3-dev.49 but can predate it). */\nexport function isOlderRelease(\n installed: string,\n target: string,\n publishTimes: Partial<Record<string, string>> = {},\n): boolean {\n if (!valid(installed) || !valid(target)) return false;\n if (compare(target, installed) < 0) return true;\n const installedAt = publishTimes[installed];\n const targetAt = publishTimes[target];\n if (!installedAt || !targetAt) return false;\n return Date.parse(targetAt) < Date.parse(installedAt);\n}\n\nasync function fetchPublishTimes(\n packageName: string,\n): Promise<Partial<Record<string, string>>> {\n try {\n return JSON.parse(\n await spawnAsync(\"npm\", [\"view\", packageName, \"time\", \"--json\"]),\n ) as Partial<Record<string, string>>;\n } catch {\n return {};\n }\n}\n\nasync function warnIfOlderRelease(\n packageJson: ProjectPackageJson,\n targetVersion: string,\n) {\n const newest = newestPowerhouseVersion(packageJson);\n if (!newest) return;\n const publishTimes = await fetchPublishTimes(\"@powerhousedao/ph-cli\");\n if (!isOlderRelease(newest.version, targetVersion, publishTimes)) return;\n console.warn(\n `⚠ ${targetVersion} is an older release than the installed ${newest.name}@${newest.version}; migrating moves the project back. Pass a version or tag (e.g. \\`ph migrate dev\\`) to stay on yours.`,\n );\n}\n\nfunction getBundledPhCliVersion(): string | undefined {\n let dir = dirname(fileURLToPath(import.meta.url));\n for (let i = 0; i < 5; i++) {\n try {\n const pkg = JSON.parse(\n readFileSync(join(dir, \"package.json\"), \"utf8\"),\n ) as { name?: string; version?: string };\n if (pkg.name === \"@powerhousedao/ph-cli\") return pkg.version;\n } catch {\n // keep walking\n }\n dir = dirname(dir);\n }\n}\n\nexport function resolveCodegenVersion(\n codegenMod: Record<string, unknown>,\n): string | undefined {\n const getter = codegenMod.getCodegenVersion;\n if (typeof getter === \"function\") {\n const v = (getter as () => unknown)();\n if (typeof v === \"string\") return v;\n }\n return undefined;\n}\n\nexport function assertCodegenMatchesBundled(args: {\n codegenVersion: string | undefined;\n bundledVersion: string | undefined;\n force: boolean;\n}): void {\n const { codegenVersion, bundledVersion, force } = args;\n if (force) return;\n if (!codegenVersion) {\n throw new Error(\n `@powerhousedao/codegen is older than this ph-cli expects (no version export). ` +\n `Reinstall ph-cli to bring a matching codegen, or re-run with --force.`,\n );\n }\n if (bundledVersion && codegenVersion !== bundledVersion) {\n throw new Error(\n `@powerhousedao/codegen@${codegenVersion} does not match ph-cli@${bundledVersion}. ` +\n `Reinstall to align versions, or re-run with --force.`,\n );\n }\n}\n\ntype FileChange = {\n path: string;\n before: string | undefined;\n after: string | undefined;\n};\n\n/** What a dry run prints: one unified diff per file, paths relative to the\n * project, a deleted file against /dev/null. */\nexport function dryRunReport(\n projectDir: string,\n result: { changes: readonly FileChange[]; notRun: readonly string[] },\n): string {\n const diffs = result.changes.map(({ path, before, after }) => {\n const file = relative(projectDir, path).replaceAll(\"\\\\\", \"/\");\n if (after === undefined) {\n const removed = `--- a/${file}\\n+++ /dev/null\\n`;\n const diff = unifiedDiff({ path: file, before: before ?? \"\", after: \"\" });\n // An empty file has no lines to show.\n return diff === \"\"\n ? removed\n : diff.replace(`--- a/${file}\\n+++ b/${file}\\n`, removed);\n }\n // An added empty file has no lines either.\n return (\n unifiedDiff({ path: file, before: before ?? null, after }) ||\n `--- /dev/null\\n+++ b/${file}\\n`\n );\n });\n const notRun =\n result.notRun.length > 0\n ? `Not previewed; a real run would also:\\n${result.notRun.map((step) => ` - ${step}\\n`).join(\"\")}`\n : \"\";\n if (diffs.length === 0) {\n return `ph migrate would change no file.\\n${notRun}`;\n }\n return `${diffs.join(\"\")}ph migrate would write ${diffs.length} file(s); nothing was written.\\n${notRun}`;\n}\n\nexport async function startMigrate({\n versionPositional,\n version,\n force,\n debug,\n dryRun,\n}: MigrateArgs) {\n // The project is where powerhouse.config.json is: the command also runs\n // from a sub-folder, and from a package of a monorepo.\n const projectDir =\n findNodeProjectRoot(process.cwd(), isPowerhouseProject) ?? process.cwd();\n if (debug) console.log(`[migrate] project directory: ${projectDir}`);\n const packageJson = readProjectPackageJson(projectDir);\n let requested = versionPositional ?? version;\n if (requested === undefined) {\n const inferred = inferReleaseTag(packageJson);\n requested = inferred.tag;\n console.log(\n `No version given; migrating to \"${inferred.tag}\" because ${inferred.reason}.`,\n );\n }\n if (debug) console.log(`[migrate] requested version: ${requested}`);\n\n let targetVersion: string | undefined;\n try {\n targetVersion = await fetchPackageVersionFromNpmRegistry(\n `@powerhousedao/ph-cli@${requested}`,\n );\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n if (!force) {\n throw new Error(\n `Failed to resolve \"${requested}\" from the npm registry: ${reason}\\nRe-run with --force to migrate using the installed version.`,\n { cause: error },\n );\n }\n if (debug) {\n console.log(\n `[migrate] failed to resolve target version, --force is set, falling back to bundled codegen: ${reason}`,\n );\n }\n }\n\n if (targetVersion && !process.env[VERSION_CHECKED_ENV]) {\n await warnIfOlderRelease(packageJson, targetVersion);\n }\n\n const bundledVersion = getBundledPhCliVersion();\n if (debug) {\n console.log(\n `[migrate] resolved target version: ${targetVersion ?? \"(unknown)\"}`,\n );\n console.log(\n `[migrate] current ph-cli version: ${bundledVersion ?? \"(unknown)\"}`,\n );\n }\n\n if (!targetVersion || force || targetVersion === bundledVersion) {\n if (debug) console.log(`[migrate] running migrate from bundled codegen`);\n const codegenMod = await import(\"@powerhousedao/codegen\");\n const codegenVersion = resolveCodegenVersion(\n codegenMod as unknown as Record<string, unknown>,\n );\n assertCodegenMatchesBundled({\n codegenVersion,\n bundledVersion,\n force: Boolean(force),\n });\n console.log(\n `Running migrate with @powerhousedao/codegen@${codegenVersion ?? \"unknown\"}`,\n );\n const result = await codegenMod.migrate(\n targetVersion ?? requested,\n projectDir,\n { dryRun: Boolean(dryRun) },\n );\n if (dryRun) process.stdout.write(dryRunReport(projectDir, result));\n return;\n }\n\n const agent = (await detect({ cwd: projectDir }))?.agent ?? \"npm\";\n const resolved = resolveCommand(agent, \"execute\", [\n `@powerhousedao/ph-cli@${targetVersion}`,\n \"migrate\",\n \"--version\",\n targetVersion,\n ...(dryRun ? [\"--dry-run\"] : []),\n ...(debug ? [\"--debug\"] : []),\n ]);\n if (!resolved) {\n throw new Error(\n `Failed to resolve execute command for package manager \"${agent}\".`,\n );\n }\n\n injectPnpmAllowBuilds(agent, resolved);\n\n const command = `${resolved.command} ${resolved.args.join(\" \")}`;\n if (debug) {\n console.log(`[migrate] detected package manager: ${agent}`);\n console.log(`[migrate] re-executing: ${command}`);\n }\n execSync(command, {\n cwd: projectDir,\n stdio: \"inherit\",\n env: { ...process.env, [VERSION_CHECKED_ENV]: \"1\" },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAiBA,MAAM,kBAAkB;CAAC;CAAO;CAAW;CAAM;AAAM;AAGvD,MAAM,sBAAsB;AAS5B,SAAS,u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GAAG;CAC7D,IAAI,OAAO;EACT,QAAQ,IAAI,uCAAuC,OAAO;EAC1D,QAAQ,IAAI,2BAA2B,SAAS;CAClD;CACA,SAAS,SAAS;EAChB,KAAK;EACL,OAAO;EACP,KAAK;GAAE,GAAG,QAAQ;IAAM,sBAAsB;EAAI;CACpD,CAAC;AACH","debug_id":"dc4d100e-7192-5485-b14b-59361f032c90"}
|
|
1
|
+
{"version":3,"file":"migrate-Ddr7YAtM.mjs","sources":["../src/services/migrate.ts"],"sourcesContent":["import {\n fetchPackageVersionFromNpmRegistry,\n injectPnpmAllowBuilds,\n spawnAsync,\n} from \"@powerhousedao/shared/clis\";\nimport { ALL_POWERHOUSE_DEPENDENCIES } from \"@powerhousedao/shared/constants\";\nimport { execSync } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join, relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { detect, resolveCommand } from \"package-manager-detector\";\nimport { compare, minVersion, prerelease, rcompare, valid } from \"semver\";\nimport type { MigrateArgs } from \"../types.js\";\nimport { findNodeProjectRoot, isPowerhouseProject } from \"../utils.js\";\nimport { unifiedDiff } from \"./migrate-subgraphs.js\";\n\n// Dist-tags a prerelease version can name its channel by.\nconst PRERELEASE_TAGS = [\"dev\", \"staging\", \"rc\", \"next\"];\n\n// Set on the re-executed migrate, so the version check runs once.\nconst VERSION_CHECKED_ENV = \"PH_MIGRATE_VERSION_CHECKED\";\n\ntype ProjectPackageJson = Partial<\n Record<\n \"dependencies\" | \"devDependencies\" | \"peerDependencies\",\n Record<string, string>\n >\n>;\n\nfunction readProjectPackageJson(projectDir: string): ProjectPackageJson {\n try {\n return JSON.parse(\n readFileSync(join(projectDir, \"package.json\"), \"utf8\"),\n ) as ProjectPackageJson;\n } catch {\n return {};\n }\n}\n\n/** The newest Powerhouse package version the project's package.json pins */\nexport function newestPowerhouseVersion(packageJson: ProjectPackageJson) {\n const pinned = [\n packageJson.dependencies,\n packageJson.devDependencies,\n packageJson.peerDependencies,\n ].flatMap((deps) =>\n Object.entries(deps ?? {}).flatMap(([name, range]) => {\n if (!ALL_POWERHOUSE_DEPENDENCIES.includes(name)) return [];\n try {\n const version = minVersion(range)?.version;\n return version ? [{ name, version }] : [];\n } catch {\n // workspace:, catalog: and other non-semver specifiers\n return [];\n }\n }),\n );\n return pinned.sort((a, b) => rcompare(a.version, b.version)).at(0);\n}\n\n/** The dist-tag of the channel the project is on, and why */\nexport function inferReleaseTag(packageJson: ProjectPackageJson): {\n tag: string;\n reason: string;\n} {\n const newest = newestPowerhouseVersion(packageJson);\n if (!newest) {\n return { tag: \"latest\", reason: \"no Powerhouse package version is pinned\" };\n }\n const channel = prerelease(newest.version)?.[0];\n const pinned = `${newest.name}@${newest.version}`;\n if (typeof channel === \"string\" && PRERELEASE_TAGS.includes(channel)) {\n return { tag: channel, reason: `the project is on ${pinned}` };\n }\n return {\n tag: \"latest\",\n reason: `the project is on ${pinned}, ${channel === undefined ? \"a stable release\" : \"not on a dev, staging, rc or next channel\"}`,\n };\n}\n\n/** Whether `target` is an older release than `installed`: lower by semver, or\n * published earlier (6.2.3 ranks above 6.2.3-dev.49 but can predate it). */\nexport function isOlderRelease(\n installed: string,\n target: string,\n publishTimes: Partial<Record<string, string>> = {},\n): boolean {\n if (!valid(installed) || !valid(target)) return false;\n if (compare(target, installed) < 0) return true;\n const installedAt = publishTimes[installed];\n const targetAt = publishTimes[target];\n if (!installedAt || !targetAt) return false;\n return Date.parse(targetAt) < Date.parse(installedAt);\n}\n\nasync function fetchPublishTimes(\n packageName: string,\n): Promise<Partial<Record<string, string>>> {\n try {\n return JSON.parse(\n await spawnAsync(\"npm\", [\"view\", packageName, \"time\", \"--json\"]),\n ) as Partial<Record<string, string>>;\n } catch {\n return {};\n }\n}\n\nasync function warnIfOlderRelease(\n packageJson: ProjectPackageJson,\n targetVersion: string,\n) {\n const newest = newestPowerhouseVersion(packageJson);\n if (!newest) return;\n const publishTimes = await fetchPublishTimes(\"@powerhousedao/ph-cli\");\n if (!isOlderRelease(newest.version, targetVersion, publishTimes)) return;\n console.warn(\n `⚠ ${targetVersion} is an older release than the installed ${newest.name}@${newest.version}; migrating moves the project back. Pass a version or tag (e.g. \\`ph migrate dev\\`) to stay on yours.`,\n );\n}\n\nfunction getBundledPhCliVersion(): string | undefined {\n let dir = dirname(fileURLToPath(import.meta.url));\n for (let i = 0; i < 5; i++) {\n try {\n const pkg = JSON.parse(\n readFileSync(join(dir, \"package.json\"), \"utf8\"),\n ) as { name?: string; version?: string };\n if (pkg.name === \"@powerhousedao/ph-cli\") return pkg.version;\n } catch {\n // keep walking\n }\n dir = dirname(dir);\n }\n}\n\nexport function resolveCodegenVersion(\n codegenMod: Record<string, unknown>,\n): string | undefined {\n const getter = codegenMod.getCodegenVersion;\n if (typeof getter === \"function\") {\n const v = (getter as () => unknown)();\n if (typeof v === \"string\") return v;\n }\n return undefined;\n}\n\nexport function assertCodegenMatchesBundled(args: {\n codegenVersion: string | undefined;\n bundledVersion: string | undefined;\n force: boolean;\n}): void {\n const { codegenVersion, bundledVersion, force } = args;\n if (force) return;\n if (!codegenVersion) {\n throw new Error(\n `@powerhousedao/codegen is older than this ph-cli expects (no version export). ` +\n `Reinstall ph-cli to bring a matching codegen, or re-run with --force.`,\n );\n }\n if (bundledVersion && codegenVersion !== bundledVersion) {\n throw new Error(\n `@powerhousedao/codegen@${codegenVersion} does not match ph-cli@${bundledVersion}. ` +\n `Reinstall to align versions, or re-run with --force.`,\n );\n }\n}\n\ntype FileChange = {\n path: string;\n before: string | undefined;\n after: string | undefined;\n};\n\n/** What a dry run prints: one unified diff per file, paths relative to the\n * project, a deleted file against /dev/null. */\nexport function dryRunReport(\n projectDir: string,\n result: { changes: readonly FileChange[]; notRun: readonly string[] },\n): string {\n const diffs = result.changes.map(({ path, before, after }) => {\n const file = relative(projectDir, path).replaceAll(\"\\\\\", \"/\");\n if (after === undefined) {\n const removed = `--- a/${file}\\n+++ /dev/null\\n`;\n const diff = unifiedDiff({ path: file, before: before ?? \"\", after: \"\" });\n // An empty file has no lines to show.\n return diff === \"\"\n ? removed\n : diff.replace(`--- a/${file}\\n+++ b/${file}\\n`, removed);\n }\n // An added empty file has no lines either.\n return (\n unifiedDiff({ path: file, before: before ?? null, after }) ||\n `--- /dev/null\\n+++ b/${file}\\n`\n );\n });\n const notRun =\n result.notRun.length > 0\n ? `Not previewed; a real run would also:\\n${result.notRun.map((step) => ` - ${step}\\n`).join(\"\")}`\n : \"\";\n if (diffs.length === 0) {\n return `ph migrate would change no file.\\n${notRun}`;\n }\n return `${diffs.join(\"\")}ph migrate would write ${diffs.length} file(s); nothing was written.\\n${notRun}`;\n}\n\nexport async function startMigrate({\n versionPositional,\n version,\n force,\n debug,\n dryRun,\n}: MigrateArgs) {\n // The project is where powerhouse.config.json is: the command also runs\n // from a sub-folder, and from a package of a monorepo.\n const projectDir =\n findNodeProjectRoot(process.cwd(), isPowerhouseProject) ?? process.cwd();\n if (debug) console.log(`[migrate] project directory: ${projectDir}`);\n const packageJson = readProjectPackageJson(projectDir);\n let requested = versionPositional ?? version;\n if (requested === undefined) {\n const inferred = inferReleaseTag(packageJson);\n requested = inferred.tag;\n console.log(\n `No version given; migrating to \"${inferred.tag}\" because ${inferred.reason}.`,\n );\n }\n if (debug) console.log(`[migrate] requested version: ${requested}`);\n\n let targetVersion: string | undefined;\n try {\n targetVersion = await fetchPackageVersionFromNpmRegistry(\n `@powerhousedao/ph-cli@${requested}`,\n );\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n if (!force) {\n throw new Error(\n `Failed to resolve \"${requested}\" from the npm registry: ${reason}\\nRe-run with --force to migrate using the installed version.`,\n { cause: error },\n );\n }\n if (debug) {\n console.log(\n `[migrate] failed to resolve target version, --force is set, falling back to bundled codegen: ${reason}`,\n );\n }\n }\n\n if (targetVersion && !process.env[VERSION_CHECKED_ENV]) {\n await warnIfOlderRelease(packageJson, targetVersion);\n }\n\n const bundledVersion = getBundledPhCliVersion();\n if (debug) {\n console.log(\n `[migrate] resolved target version: ${targetVersion ?? \"(unknown)\"}`,\n );\n console.log(\n `[migrate] current ph-cli version: ${bundledVersion ?? \"(unknown)\"}`,\n );\n }\n\n if (!targetVersion || force || targetVersion === bundledVersion) {\n if (debug) console.log(`[migrate] running migrate from bundled codegen`);\n const codegenMod = await import(\"@powerhousedao/codegen\");\n const codegenVersion = resolveCodegenVersion(\n codegenMod as unknown as Record<string, unknown>,\n );\n assertCodegenMatchesBundled({\n codegenVersion,\n bundledVersion,\n force: Boolean(force),\n });\n console.log(\n `Running migrate with @powerhousedao/codegen@${codegenVersion ?? \"unknown\"}`,\n );\n const result = await codegenMod.migrate(\n targetVersion ?? requested,\n projectDir,\n { dryRun: Boolean(dryRun) },\n );\n if (dryRun) process.stdout.write(dryRunReport(projectDir, result));\n return;\n }\n\n const agent = (await detect({ cwd: projectDir }))?.agent ?? \"npm\";\n const resolved = resolveCommand(agent, \"execute\", [\n `@powerhousedao/ph-cli@${targetVersion}`,\n \"migrate\",\n \"--version\",\n targetVersion,\n ...(dryRun ? [\"--dry-run\"] : []),\n ...(debug ? [\"--debug\"] : []),\n ]);\n if (!resolved) {\n throw new Error(\n `Failed to resolve execute command for package manager \"${agent}\".`,\n );\n }\n\n injectPnpmAllowBuilds(agent, resolved);\n\n const command = `${resolved.command} ${resolved.args.join(\" \")}`;\n if (debug) {\n console.log(`[migrate] detected package manager: ${agent}`);\n console.log(`[migrate] re-executing: ${command}`);\n }\n execSync(command, {\n cwd: projectDir,\n stdio: \"inherit\",\n env: { ...process.env, [VERSION_CHECKED_ENV]: \"1\" },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAiBA,MAAM,kBAAkB;CAAC;CAAO;CAAW;CAAM;AAAM;AAGvD,MAAM,sBAAsB;AAS5B,SAAS,uBAAuB,YAAwC;CACtE,IAAI;EACF,OAAO,KAAK,MACV,aAAa,KAAK,YAAY,cAAc,GAAG,MAAM,CACvD;CACF,QAAQ;EACN,OAAO,C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;EAChB,KAAK;EACL,OAAO;EACP,KAAK;GAAE,GAAG,QAAQ;IAAM,sBAAsB;EAAI;CACpD,CAAC;AACH","debug_id":"b871feee-1509-5354-9e80-365512977a3c"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
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]="6e348e7c-4716-5f2b-9fc1-bdaa5d327671")}catch(e){}}();
|
|
3
3
|
import { i as readProjectDefinitions } from "./run--de_-WAz.mjs";
|
|
4
|
-
import { a as errorText, c as toPosix, i as assertChangesWritable, l as writeChanges, n as unifiedDiff, o as readProjectFiles, r as projectModuleReferences, s as restoreChanges, u as outdatedDependency } from "./migrate-subgraphs-
|
|
4
|
+
import { a as errorText, c as toPosix, i as assertChangesWritable, l as writeChanges, n as unifiedDiff, o as readProjectFiles, r as projectModuleReferences, s as restoreChanges, u as outdatedDependency } from "./migrate-subgraphs-Ffwwm7Oy.mjs";
|
|
5
5
|
import { statSync } from "node:fs";
|
|
6
6
|
import { basename, relative, resolve } from "node:path";
|
|
7
7
|
import { assertDocumentModelBarrelsWritable, migrateDocumentModel, regenerateDocumentModelBarrels } from "@powerhousedao/codegen";
|
|
@@ -485,5 +485,5 @@ function refusalText(migration) {
|
|
|
485
485
|
//#endregion
|
|
486
486
|
export { migrateDocumentModels };
|
|
487
487
|
|
|
488
|
-
//# sourceMappingURL=migrate-document-models-
|
|
489
|
-
//# debugId=
|
|
488
|
+
//# sourceMappingURL=migrate-document-models-X_mVTljj.mjs.map
|
|
489
|
+
//# debugId=6e348e7c-4716-5f2b-9fc1-bdaa5d327671
|
package/dist/{migrate-document-models-DTxM7D7p.mjs.map → migrate-document-models-X_mVTljj.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-document-models-DTxM7D7p.mjs","sources":["../src/services/migrate-document-models.ts"],"sourcesContent":["import {\n assertDocumentModelBarrelsWritable,\n type DocumentModelMigration,\n type DocumentModelMigrationFile,\n type DocumentModelMigrationReference,\n migrateDocumentModel,\n regenerateDocumentModelBarrels,\n} from \"@powerhousedao/codegen\";\nimport { documentModelsDirOf } from \"@powerhousedao/codegen/utils\";\nimport type {\n DocumentModelDefinition,\n DocumentModelModuleDefinition,\n DocumentModelOperationDefinition,\n DocumentModelSpecificationDefinition,\n StateDefinition,\n} from \"@powerhousedao/shared/document-model\";\nimport {\n discoverDocumentModelDirectories,\n inspectProjectDefinitions,\n} from \"document-model/tooling\";\nimport { statSync } from \"node:fs\";\nimport { basename, relative, resolve } from \"node:path\";\nimport { outdatedDependency } from \"./installed-version.js\";\nimport { unifiedDiff } from \"./migrate-subgraphs.js\";\nimport { readProjectDefinitions } from \"./model/project.js\";\nimport { projectModuleReferences } from \"./project-module-references.js\";\nimport {\n assertChangesWritable,\n errorText,\n type FileBackup,\n readProjectFiles,\n restoreChanges,\n toPosix,\n writeChanges,\n} from \"./project-files.js\";\n\nconst SOURCE_FILE = /\\.(?:[cm]?[jt]sx?|json|graphql)$/;\nexport type MigrateDocumentModelsOptions = {\n readonly projectDir: string;\n /** Model directories to convert; empty converts every schema-first one. */\n readonly dirs: readonly string[];\n readonly dryRun: boolean;\n /** Renames a type named like a scalar instead of refusing its model. */\n readonly renameConflictingTypes?: boolean;\n readonly out?: (text: string) => void;\n};\n\ntype Definitions = ReadonlyMap<number, unknown>;\n\n/**\n * `ph migrate --document-models`: converts schema-first document models into\n * code-first ones. Each converted model is loaded again as `ph model inspect`\n * loads it, and every version must keep the definition it had: the same\n * state, operations, inputs and errors. Otherwise its files are restored.\n * Returns the exit code: 0 when every requested model converted or was\n * already code-first, 1 otherwise.\n */\nexport async function migrateDocumentModels(\n options: MigrateDocumentModelsOptions,\n): Promise<0 | 1> {\n const out =\n options.out ?? ((text: string) => void process.stdout.write(text));\n const { projectDir } = options;\n let resolved: { readonly path: string };\n try {\n resolved = documentModelsDirOf(projectDir);\n } catch (error) {\n out(`${errorText(error)}\\n`);\n return 1;\n }\n const modelsDir = toPosix(relative(projectDir, resolved.path));\n const directories = new Map(\n discoverDocumentModelDirectories(projectDir, resolved.path).directories.map(\n (directory) => [directory.name, directory.kind] as const,\n ),\n );\n let failed = false;\n const requested: string[] = [];\n if (options.dirs.length === 0) {\n for (const [name, kind] of directories) {\n if (kind === \"stored\") requested.push(name);\n }\n }\n for (const dir of options.dirs) {\n const name = basename(dir.replace(/[\\\\/]+$/, \"\"));\n // A path names a directory of the models directory, not any directory.\n if (\n /[\\\\/]/.test(dir.replace(/[\\\\/]+$/, \"\")) &&\n resolve(projectDir, dir, \"..\") !== resolved.path\n ) {\n out(\n `${dir}: not a directory of ${modelsDir}/. Name a model directory, such as ${modelsDir}/${name}.\\n`,\n );\n failed = true;\n continue;\n }\n if (!requested.includes(name)) requested.push(name);\n }\n if (requested.length === 0 && !failed) {\n out(\"No schema-first document models to convert.\\n\");\n return 0;\n }\n\n const pending: string[] = [];\n for (const dirName of requested) {\n const label = `${modelsDir}/${dirName}`;\n const kind = directories.get(dirName);\n if (kind === undefined || kind === \"none\" || kind === \"invalid\") {\n out(\n `${label}: not found. Name a directory of ${modelsDir}/ that holds a document model.\\n`,\n );\n failed = true;\n } else if (kind === \"module\") {\n out(`${label}: already code-first\\n`);\n } else if (kind === \"generated\") {\n out(\n `${label}: not converted. It has generated code but no ${dirName}.json, so its specification cannot be read. Restore ${dirName}.json, then migrate again.\\n`,\n );\n failed = true;\n } else {\n pending.push(dirName);\n }\n }\n if (pending.length === 0) return failed ? 1 : 0;\n // The barrels are regenerated after the models are written, so a barrel\n // codegen would refuse to rewrite stops the run before anything changes.\n try {\n assertChangesWritable(projectDir, [\n { path: \"document-models/index.ts\" },\n { path: \"document-models/document-models.ts\" },\n { path: \"document-models/upgrade-manifests.ts\" },\n { path: \"powerhouse.manifest.json\" },\n ]);\n assertDocumentModelBarrelsWritable(projectDir);\n } catch (error) {\n out(`No document model was converted. ${errorText(error)}\\n`);\n return 1;\n }\n\n let moduleReferences: readonly DocumentModelMigrationReference[];\n try {\n moduleReferences = projectModuleReferences(projectDir).map((reference) => ({\n file: reference.file,\n specifier: reference.specifier,\n targets: reference.targets\n .filter((target) =>\n statSync(resolve(projectDir, target.path), {\n throwIfNoEntry: false,\n })?.isFile(),\n )\n .map((target) => target.path),\n }));\n } catch (error) {\n out(`No document model was converted. ${errorText(error)}\\n`);\n return 1;\n }\n const outdated = outdatedDependency(projectDir, \"document-model\");\n const run: ModelRun = {\n projectDir,\n modelsDir,\n pending,\n renameConflictingTypes: options.renameConflictingTypes ?? false,\n moduleReferences,\n out,\n };\n if (options.dryRun) {\n if (outdated !== undefined) {\n out(`Note: ${outdated} Until then, a real run converts nothing.\\n`);\n }\n return (await previewModels(run)) || failed ? 1 : 0;\n }\n if (outdated !== undefined) {\n out(`No document model was converted. ${outdated}\\n`);\n return 1;\n }\n return (await convertModels(run)) || failed ? 1 : 0;\n}\n\ntype ModelRun = {\n readonly moduleReferences: readonly DocumentModelMigrationReference[];\n readonly projectDir: string;\n readonly modelsDir: string;\n readonly pending: readonly string[];\n readonly renameConflictingTypes: boolean;\n readonly out: (text: string) => void;\n};\n\n/** `--dry-run`: prints what each conversion would write. Returns whether one was refused. */\nasync function previewModels(run: ModelRun): Promise<boolean> {\n const { out } = run;\n let files = readSourceTexts(run.projectDir);\n let refused = false;\n const notes = new Set<string>();\n for (const dirName of run.pending) {\n const label = `${run.modelsDir}/${dirName}`;\n let migration: DocumentModelMigration;\n try {\n migration = await migrateDocumentModel({\n documentModelsDir: run.modelsDir,\n dirName,\n files,\n moduleReferences: run.moduleReferences,\n renameConflictingTypes: run.renameConflictingTypes,\n });\n if (migration.kind === \"converted\") {\n assertChangesWritable(run.projectDir, migration.files);\n }\n } catch (error) {\n out(\n `${label}: would not convert. The conversion failed unexpectedly: ${errorText(error)}\\n`,\n );\n refused = true;\n continue;\n }\n if (migration.kind !== \"converted\") {\n out(`${label}: ${refusalText(migration)}\\n`);\n refused = true;\n continue;\n }\n out(\n `${label}: would convert ${migration.documentType} (versions ${migration.versions.join(\", \")}) to code-first, if the converted model keeps its definition when loaded\\n`,\n );\n for (const file of migration.files) out(fileDiff(file));\n for (const note of migration.notes) notes.add(note);\n files = applied(files, migration.files);\n }\n for (const note of notes) out(`Note: ${note}\\n`);\n return refused;\n}\n\n/**\n * Converts each model, writes it, loads it again and keeps it only when every\n * version has its stored definition; then regenerates the barrels. Returns\n * whether a model was not converted.\n */\nasync function convertModels(run: ModelRun): Promise<boolean> {\n const { projectDir, out } = run;\n let files = readSourceTexts(projectDir);\n const before = await storedDefinitions(\n projectDir,\n run.modelsDir,\n run.pending,\n files,\n );\n let failed = false;\n const converted = new Set<string>();\n const notes = new Set<string>();\n for (const dirName of run.pending) {\n const label = `${run.modelsDir}/${dirName}`;\n let outcome: ModelOutcome;\n try {\n outcome = await convertModel(run, dirName, files, before);\n } catch (error) {\n outcome = {\n ok: false,\n text: `not converted; its files are unchanged. The conversion failed unexpectedly: ${errorText(error)}`,\n };\n }\n if (!outcome.ok) {\n out(`${label}: ${outcome.text}\\n`);\n failed = true;\n continue;\n }\n const { migration } = outcome;\n files = applied(files, migration.files);\n out(\n `${label}: converted ${migration.documentType} (versions ${migration.versions.join(\", \")}) to code-first; every version keeps its definition\\n`,\n );\n for (const note of migration.notes) notes.add(note);\n converted.add(dirName);\n }\n for (const note of notes) out(`Note: ${note}\\n`);\n if (converted.size > 0) {\n try {\n const changed = await regenerateDocumentModelBarrels(\n projectDir,\n converted,\n );\n if (changed.length > 0) {\n out(`Regenerated ${changed.join(\", \")}.\\n`);\n }\n } catch (error) {\n out(\n `The converted models are written, but the document-models barrels could not be regenerated: ${errorText(error)}\\nFix that, then run ph generate.\\n`,\n );\n failed = true;\n }\n }\n return failed;\n}\n\ntype ModelOutcome =\n | {\n readonly ok: true;\n readonly migration: Extract<\n DocumentModelMigration,\n { kind: \"converted\" }\n >;\n }\n | { readonly ok: false; readonly text: string };\n\n/** Converts, writes and verifies one model, restoring its files when it fails. */\nasync function convertModel(\n run: ModelRun,\n dirName: string,\n files: ReadonlyMap<string, string>,\n before: StoredDefinitions,\n): Promise<ModelOutcome> {\n const migration = await migrateDocumentModel({\n documentModelsDir: run.modelsDir,\n dirName,\n files,\n moduleReferences: run.moduleReferences,\n renameConflictingTypes: run.renameConflictingTypes,\n });\n if (migration.kind !== \"converted\") {\n return { ok: false, text: refusalText(migration) };\n }\n const stored = before.definitions.get(dirName);\n const unread = migration.versions.filter(\n (version) => stored?.has(version) !== true,\n );\n if (stored === undefined || unread.length > 0) {\n return {\n ok: false,\n text: `not converted. Version ${unread.join(\", \")} of its stored definition could not be read, so the conversion could not be checked. Run ph model check to see why.`,\n };\n }\n let backup: FileBackup;\n try {\n backup = writeChanges(run.projectDir, migration.files);\n } catch (error) {\n return {\n ok: false,\n text: `not converted; its files are restored. Writing them failed: ${errorText(error)}`,\n };\n }\n let verification: Awaited<ReturnType<typeof verify>>;\n try {\n verification = await verify(\n run.projectDir,\n migration.documentType,\n renameTypes(stored, migration.renamedTypes),\n before.known,\n );\n } catch (error) {\n verification = {\n ok: false,\n reason: `Checking the converted model failed: ${errorText(error)}`,\n };\n }\n if (!verification.ok) {\n restoreChanges(run.projectDir, backup);\n return {\n ok: false,\n text: `not converted; its files are restored. ${verification.reason}`,\n };\n }\n return { ok: true, migration };\n}\n\n/** The package's source files as text, by project-relative POSIX path. */\nfunction readSourceTexts(projectDir: string): Map<string, string> {\n return new Map(\n [...readProjectFiles(projectDir, SOURCE_FILE)].map(([path, bytes]) => [\n path,\n bytes.toString(\"utf8\"),\n ]),\n );\n}\n\nfunction applied(\n files: ReadonlyMap<string, string>,\n changes: readonly DocumentModelMigrationFile[],\n): Map<string, string> {\n const next = new Map(files);\n for (const file of changes) {\n if (file.after === null) next.delete(file.path);\n else next.set(file.path, file.after);\n }\n return next;\n}\n\ntype StoredDefinitions = {\n readonly definitions: ReadonlyMap<string, Definitions>;\n /** The errors the project reported before anything was written. */\n readonly known: ReadonlySet<string>;\n};\n\n/** The stored versions of each model, read before anything is written. */\nasync function storedDefinitions(\n projectDir: string,\n modelsDir: string,\n dirNames: readonly string[],\n files: ReadonlyMap<string, string>,\n): Promise<StoredDefinitions> {\n const wanted = dirNames.flatMap((dirName) => {\n const text = files.get(`${modelsDir}/${dirName}/${dirName}.json`);\n if (text === undefined) return [];\n try {\n const stored = JSON.parse(text) as {\n id: string;\n specifications: { version: number }[];\n };\n return [\n {\n dirName,\n documentType: stored.id,\n versions: stored.specifications.map(({ version }) => version),\n },\n ];\n } catch {\n // The migration refuses a specification that is not JSON, and says why.\n return [];\n }\n });\n return await readProjectDefinitions(projectDir, (project) => {\n const result = new Map<string, Definitions>();\n const known = new Set<string>();\n for (const { dirName, documentType, versions } of wanted) {\n const definitions = new Map<number, unknown>();\n for (const version of versions) {\n const report = inspectProjectDefinitions(project, {\n selection: { documentType, version },\n });\n if (\"definition\" in report) definitions.set(version, report.definition);\n for (const message of errorMessages(report.diagnostics)) {\n known.add(message);\n }\n }\n result.set(dirName, definitions);\n }\n return { definitions: result, known };\n });\n}\n\nfunction errorMessages(\n diagnostics: readonly {\n readonly severity: string;\n readonly message: string;\n readonly repair?: string;\n }[],\n): string[] {\n return diagnostics\n .filter(({ severity }) => severity === \"error\")\n .map(({ message, repair }) => `${message} ${repair ?? \"\"}`.trim());\n}\n\ntype Verification =\n | { readonly ok: true }\n | { readonly ok: false; readonly reason: string };\n\n/**\n * The stored definitions with the types the conversion renamed off a\n * scalar's name renamed too, so the comparison expects the new names. The\n * stored definition also lists the scalar the type's name collided with,\n * which the converted model no longer names.\n */\nfunction renameTypes(\n definitions: Definitions,\n renamed: readonly { version: number; from: string; to: string }[],\n): Definitions {\n if (renamed.length === 0) return definitions;\n const result = new Map<number, unknown>();\n for (const [version, definition] of definitions) {\n const names = new Map(\n renamed\n .filter((entry) => entry.version === version)\n .map(({ from, to }) => [from, to] as const),\n );\n // A type is named by `name` in its definition and in every reference;\n // unions and interfaces list members and implemented types by name.\n const walk = (value: unknown, key?: string): unknown => {\n if (key === \"scalars\" && Array.isArray(value)) {\n return value.filter(\n (scalar) =>\n !(\n isRecord(scalar) &&\n typeof scalar.name === \"string\" &&\n names.has(scalar.name)\n ),\n );\n }\n if (Array.isArray(value)) {\n return value.map((item) =>\n (key === \"members\" || key === \"implements\") &&\n typeof item === \"string\"\n ? (names.get(item) ?? item)\n : walk(item),\n );\n }\n if (!isRecord(value)) return value;\n return Object.fromEntries(\n Object.entries(value).map(([entryKey, entry]) => [\n entryKey,\n entryKey === \"name\" &&\n typeof entry === \"string\" &&\n typeof value.kind === \"string\"\n ? (names.get(entry) ?? entry)\n : walk(entry, entryKey),\n ]),\n );\n };\n result.set(version, walk(definition));\n }\n return result;\n}\n\n/** Loads the converted model and compares each version with its stored definition. */\nasync function verify(\n projectDir: string,\n documentType: string,\n expected: Definitions,\n known: ReadonlySet<string>,\n): Promise<Verification> {\n let actual: ReadonlyMap<number, unknown>;\n let problems: readonly string[];\n try {\n [actual, problems] = await readProjectDefinitions(projectDir, (project) => {\n const definitions = new Map<number, unknown>();\n const errors: string[] = [];\n for (const version of expected.keys()) {\n const report = inspectProjectDefinitions(project, {\n selection: { documentType, version },\n });\n if (\"definition\" in report) definitions.set(version, report.definition);\n for (const message of errorMessages(report.diagnostics)) {\n // Errors the project had before, such as another model's, are not this conversion's.\n if (!known.has(message)) errors.push(message);\n }\n }\n return [definitions, errors] as const;\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n ok: false,\n reason: `The converted model does not load: ${message.replaceAll(projectDir, \".\")}`,\n };\n }\n if (problems.length > 0) {\n return {\n ok: false,\n reason: `The converted model does not pass ph model check:\\n${[...new Set(problems)].map((problem) => ` ${problem}`).join(\"\\n\")}`,\n };\n }\n for (const [version, stored] of expected) {\n const converted = actual.get(version);\n if (converted === undefined) {\n return {\n ok: false,\n reason: `The converted model exports no version ${version} of ${documentType}.`,\n };\n }\n const differences = definitionDifferences(stored, converted);\n if (differences.length > 0) {\n return {\n ok: false,\n reason: `Version ${version} of the converted model has a different definition:\\n${differences\n .slice(0, 20)\n .map((line) => ` ${line}`)\n .join(\"\\n\")}`,\n };\n }\n }\n return { ok: true };\n}\n\n/**\n * What a stored definition and the code-first one differ in. IDs, the\n * stored names of modules and operations, the reducer and template text, and\n * the GraphQL text a schema-first model keeps derive from the authoring\n * style, so they are not compared. The model, every named type (operation\n * inputs included), the state roots and initial values, and each operation's\n * key, action type, scope, input and errors are.\n */\nexport function definitionDifferences(\n stored: unknown,\n converted: unknown,\n): string[] {\n const differences: string[] = [];\n const walk = (left: unknown, right: unknown, path: string) => {\n if (differences.length >= 50) return;\n if (Array.isArray(left) && Array.isArray(right)) {\n if (left.length !== right.length) {\n differences.push(\n `${path}: ${left.length} entries stored, ${right.length} converted`,\n );\n }\n for (\n let index = 0;\n index < Math.min(left.length, right.length);\n index++\n ) {\n walk(left[index], right[index], `${path}[${index}]`);\n }\n return;\n }\n if (isRecord(left) && isRecord(right)) {\n for (const key of new Set([\n ...Object.keys(left),\n ...Object.keys(right),\n ])) {\n walk(left[key], right[key], path === \"\" ? key : `${path}.${key}`);\n }\n return;\n }\n if (JSON.stringify(left) !== JSON.stringify(right)) {\n differences.push(\n `${path}: stored ${JSON.stringify(left)}, converted ${JSON.stringify(right)}`,\n );\n }\n };\n walk(canonical(stored), canonical(converted), \"\");\n return differences;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The records of a list, or none when it is not one. */\nfunction records(value: unknown): Record<string, unknown>[] {\n return Array.isArray(value) ? value.filter(isRecord) : [];\n}\n\n/** Empty text and null both mean \"none\" in a stored model. */\nconst text = (value: unknown): unknown => (value === \"\" ? null : value);\n\n/** Members whose empty text means none, as the stored format writes it. */\nconst TEXT_KEYS = new Set([\"description\", \"deprecated\", \"template\"]);\n\n/** `value` with empty text read as none, and without `keys`, at any depth. */\nfunction normalized(value: unknown, keys: readonly string[] = []): unknown {\n if (Array.isArray(value)) return value.map((item) => normalized(item, keys));\n if (!isRecord(value)) return value;\n return Object.fromEntries(\n Object.entries(value)\n .filter(([key]) => !keys.includes(key))\n .map(([key, entry]) => [\n key,\n TEXT_KEYS.has(key) ? text(entry) : normalized(entry, keys),\n ]),\n );\n}\n\n/**\n * How one member of a definition is compared: `ignore` leaves it out, a\n * function maps it to what is compared. The tables are exhaustive over the\n * definition types, so a member added to them must be classified here; a\n * member the loaded definition has and a table lacks is compared as is.\n */\ntype Rule = \"ignore\" | ((value: unknown) => unknown);\ntype Rules<T> = { readonly [Key in keyof Required<T>]: Rule };\n\nconst same = (value: unknown) => normalized(value);\nconst exampleValues = (value: unknown) =>\n records(value).map((example) => example.value);\n\nfunction compared<T>(value: unknown, rules: Rules<T>): unknown {\n if (!isRecord(value)) return value;\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const rule = (rules as Readonly<Record<string, Rule | undefined>>)[key];\n if (rule === \"ignore\") continue;\n result[key] = (rule ?? same)(entry);\n }\n return result;\n}\n\nconst STATE_RULES: Rules<StateDefinition> = {\n root: same,\n initialValue: (value) => value ?? {},\n examples: exampleValues,\n unknownKeys: same,\n // The GraphQL and JSON text the state is materialized from.\n materialized: \"ignore\",\n};\n\nconst OPERATION_RULES: Rules<DocumentModelOperationDefinition> = {\n id: \"ignore\",\n // The stored operation name; the key and action type derive from it.\n name: \"ignore\",\n key: same,\n description: text,\n actionType: same,\n creatorKey: same,\n scope: same,\n // Compared among the specification's types.\n input: (value) => (isRecord(value) ? value.name : null),\n errors: (value) => normalized(value, [\"id\", \"key\"]),\n examples: exampleValues,\n template: \"ignore\",\n reducer: \"ignore\",\n};\n\nconst MODULE_RULES: Rules<DocumentModelModuleDefinition> = {\n id: \"ignore\",\n // The stored module name; the key derives from it.\n name: \"ignore\",\n key: same,\n description: text,\n operations: (value) =>\n records(value).map((operation) => compared(operation, OPERATION_RULES)),\n};\n\n/** The named types of a specification, operation inputs included, by name. */\nfunction namedTypes(specification: Record<string, unknown>): unknown {\n const types = new Map<string, unknown>();\n const add = (type: unknown) => {\n if (isRecord(type) && typeof type.name === \"string\") {\n types.set(type.name, normalized(type, [\"key\"]));\n }\n };\n for (const type of records(specification.types)) add(type);\n for (const module of records(specification.modules)) {\n for (const operation of records(module.operations)) add(operation.input);\n }\n return Object.fromEntries(\n [...types].sort(([left], [right]) => left.localeCompare(right)),\n );\n}\n\nconst SPECIFICATION_RULES: Rules<DocumentModelSpecificationDefinition> = {\n version: same,\n changeLog: same,\n scalars: same,\n // The GraphQL text a schema-first model keeps.\n graphQLCompatibility: \"ignore\",\n types: \"ignore\",\n state: (value) =>\n isRecord(value)\n ? {\n global: compared(value.global, STATE_RULES),\n local: compared(value.local, STATE_RULES),\n }\n : value,\n modules: (value) =>\n records(value).map((module) => compared(module, MODULE_RULES)),\n};\n\nconst DEFINITION_RULES: Rules<DocumentModelDefinition> = {\n kind: same,\n formatVersion: same,\n // How identities and serialization derive differs by authoring style.\n compatibility: (value) =>\n isRecord(value) ? { scalarCoercion: value.scalarCoercion } : value,\n model: same,\n specifications: (value) =>\n records(value).map((specification) => {\n const result = compared(specification, SPECIFICATION_RULES);\n return isRecord(result)\n ? { ...result, types: namedTypes(specification) }\n : result;\n }),\n};\n\n/** The parts of a definition both authoring styles must agree on. */\nfunction canonical(definition: unknown): unknown {\n return compared(definition, DEFINITION_RULES);\n}\n\nfunction fileDiff(file: DocumentModelMigrationFile): string {\n if (file.after === null)\n return `--- a/${file.path}\\n+++ /dev/null\\n(deleted)\\n`;\n return unifiedDiff({\n path: file.path,\n before: file.before,\n after: file.after,\n });\n}\n\nfunction refusalText(\n migration: Extract<DocumentModelMigration, { kind: \"refused\" }>,\n): string {\n return `not converted\\n${migration.refusals\n .map(\n ({ file, line, reason, repair }) =>\n ` ${file}${line === undefined ? \"\" : `:${line}`}: ${reason}\\n ${repair}`,\n )\n .join(\"\\n\")}`;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAoCA,MAAM,cAAc;;;;;;;;;AAqBpB,eAAsB,sBACpB,SACgB;CAChB,MAAM,MACJ,QAAQ,SAAS,SAAiB,KAAK,QAAQ,OAAO,MAAM,IAAI;CAClE,MAAM,EAAE,eAAe;CACvB,IAAI;CACJ,IAAI;EACF,WAAW,oBAAoB,UAAU;CAC3C,SAAS,OAAO;EACd,IAAI,GAAG,UAAU,KAAK,EAAE,GAAG;EAC3B,OAAO;CACT;CACA,MAAM,YAAY,QAAQ,SAAS,YAAY,SAAS,IAAI,CAAC;CAC7D,MAAM,cAAc,IAAI,IACtB,iCAAiC,YAAY,SAAS,IAAI,CAAC,CAAC,YAAY,KACrE,cAAc,CAAC,UAAU,MAAM,UAAU,IAAI,CAChD,CACF;CACA,IAAI,SAAS;CACb,MAAM,YAAsB,CAAC;CAC7B,IAAI,QAAQ,KAAK,WAAW,GACrB;OAAA,MAAM,CAAC,MAAM,SAAS,aACzB,IAAI,SAAS,UAAU,UAAU,KAAK,IAAI;CAAA;CAG9C,KAAK,MAAM,OAAO,QAAQ,MAAM;EAC9B,MAAM,OAAO,SAAS,IAAI,QAAQ,WAAW,EAAE,CAAC;EAEhD,IACE,QAAQ,KAAK,IAAI,QAAQ,WAAW,EAAE,CAAC,KACvC,QAAQ,YAAY,KAAK,IAAI,MAAM,SAAS,MAC5C;GACA,IACE,GAAG,IAAI,uBAAuB,UAAU,qCAAqC,UAAU,GAAG,KAAK,IACjG;GACA,SAAS;GACT;EACF;EACA,IAAI,CAAC,UAAU,SAAS,IAAI,GAAG,UAAU,KAAK,IAAI;CACpD;CACA,IAAI,UAAU,WAA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
|
|
1
|
+
{"version":3,"file":"migrate-document-models-X_mVTljj.mjs","sources":["../src/services/migrate-document-models.ts"],"sourcesContent":["import {\n assertDocumentModelBarrelsWritable,\n type DocumentModelMigration,\n type DocumentModelMigrationFile,\n type DocumentModelMigrationReference,\n migrateDocumentModel,\n regenerateDocumentModelBarrels,\n} from \"@powerhousedao/codegen\";\nimport { documentModelsDirOf } from \"@powerhousedao/codegen/utils\";\nimport type {\n DocumentModelDefinition,\n DocumentModelModuleDefinition,\n DocumentModelOperationDefinition,\n DocumentModelSpecificationDefinition,\n StateDefinition,\n} from \"@powerhousedao/shared/document-model\";\nimport {\n discoverDocumentModelDirectories,\n inspectProjectDefinitions,\n} from \"document-model/tooling\";\nimport { statSync } from \"node:fs\";\nimport { basename, relative, resolve } from \"node:path\";\nimport { outdatedDependency } from \"./installed-version.js\";\nimport { unifiedDiff } from \"./migrate-subgraphs.js\";\nimport { readProjectDefinitions } from \"./model/project.js\";\nimport { projectModuleReferences } from \"./project-module-references.js\";\nimport {\n assertChangesWritable,\n errorText,\n type FileBackup,\n readProjectFiles,\n restoreChanges,\n toPosix,\n writeChanges,\n} from \"./project-files.js\";\n\nconst SOURCE_FILE = /\\.(?:[cm]?[jt]sx?|json|graphql)$/;\nexport type MigrateDocumentModelsOptions = {\n readonly projectDir: string;\n /** Model directories to convert; empty converts every schema-first one. */\n readonly dirs: readonly string[];\n readonly dryRun: boolean;\n /** Renames a type named like a scalar instead of refusing its model. */\n readonly renameConflictingTypes?: boolean;\n readonly out?: (text: string) => void;\n};\n\ntype Definitions = ReadonlyMap<number, unknown>;\n\n/**\n * `ph migrate --document-models`: converts schema-first document models into\n * code-first ones. Each converted model is loaded again as `ph model inspect`\n * loads it, and every version must keep the definition it had: the same\n * state, operations, inputs and errors. Otherwise its files are restored.\n * Returns the exit code: 0 when every requested model converted or was\n * already code-first, 1 otherwise.\n */\nexport async function migrateDocumentModels(\n options: MigrateDocumentModelsOptions,\n): Promise<0 | 1> {\n const out =\n options.out ?? ((text: string) => void process.stdout.write(text));\n const { projectDir } = options;\n let resolved: { readonly path: string };\n try {\n resolved = documentModelsDirOf(projectDir);\n } catch (error) {\n out(`${errorText(error)}\\n`);\n return 1;\n }\n const modelsDir = toPosix(relative(projectDir, resolved.path));\n const directories = new Map(\n discoverDocumentModelDirectories(projectDir, resolved.path).directories.map(\n (directory) => [directory.name, directory.kind] as const,\n ),\n );\n let failed = false;\n const requested: string[] = [];\n if (options.dirs.length === 0) {\n for (const [name, kind] of directories) {\n if (kind === \"stored\") requested.push(name);\n }\n }\n for (const dir of options.dirs) {\n const name = basename(dir.replace(/[\\\\/]+$/, \"\"));\n // A path names a directory of the models directory, not any directory.\n if (\n /[\\\\/]/.test(dir.replace(/[\\\\/]+$/, \"\")) &&\n resolve(projectDir, dir, \"..\") !== resolved.path\n ) {\n out(\n `${dir}: not a directory of ${modelsDir}/. Name a model directory, such as ${modelsDir}/${name}.\\n`,\n );\n failed = true;\n continue;\n }\n if (!requested.includes(name)) requested.push(name);\n }\n if (requested.length === 0 && !failed) {\n out(\"No schema-first document models to convert.\\n\");\n return 0;\n }\n\n const pending: string[] = [];\n for (const dirName of requested) {\n const label = `${modelsDir}/${dirName}`;\n const kind = directories.get(dirName);\n if (kind === undefined || kind === \"none\" || kind === \"invalid\") {\n out(\n `${label}: not found. Name a directory of ${modelsDir}/ that holds a document model.\\n`,\n );\n failed = true;\n } else if (kind === \"module\") {\n out(`${label}: already code-first\\n`);\n } else if (kind === \"generated\") {\n out(\n `${label}: not converted. It has generated code but no ${dirName}.json, so its specification cannot be read. Restore ${dirName}.json, then migrate again.\\n`,\n );\n failed = true;\n } else {\n pending.push(dirName);\n }\n }\n if (pending.length === 0) return failed ? 1 : 0;\n // The barrels are regenerated after the models are written, so a barrel\n // codegen would refuse to rewrite stops the run before anything changes.\n try {\n assertChangesWritable(projectDir, [\n { path: \"document-models/index.ts\" },\n { path: \"document-models/document-models.ts\" },\n { path: \"document-models/upgrade-manifests.ts\" },\n { path: \"powerhouse.manifest.json\" },\n ]);\n assertDocumentModelBarrelsWritable(projectDir);\n } catch (error) {\n out(`No document model was converted. ${errorText(error)}\\n`);\n return 1;\n }\n\n let moduleReferences: readonly DocumentModelMigrationReference[];\n try {\n moduleReferences = projectModuleReferences(projectDir).map((reference) => ({\n file: reference.file,\n specifier: reference.specifier,\n targets: reference.targets\n .filter((target) =>\n statSync(resolve(projectDir, target.path), {\n throwIfNoEntry: false,\n })?.isFile(),\n )\n .map((target) => target.path),\n }));\n } catch (error) {\n out(`No document model was converted. ${errorText(error)}\\n`);\n return 1;\n }\n const outdated = outdatedDependency(projectDir, \"document-model\");\n const run: ModelRun = {\n projectDir,\n modelsDir,\n pending,\n renameConflictingTypes: options.renameConflictingTypes ?? false,\n moduleReferences,\n out,\n };\n if (options.dryRun) {\n if (outdated !== undefined) {\n out(`Note: ${outdated} Until then, a real run converts nothing.\\n`);\n }\n return (await previewModels(run)) || failed ? 1 : 0;\n }\n if (outdated !== undefined) {\n out(`No document model was converted. ${outdated}\\n`);\n return 1;\n }\n return (await convertModels(run)) || failed ? 1 : 0;\n}\n\ntype ModelRun = {\n readonly moduleReferences: readonly DocumentModelMigrationReference[];\n readonly projectDir: string;\n readonly modelsDir: string;\n readonly pending: readonly string[];\n readonly renameConflictingTypes: boolean;\n readonly out: (text: string) => void;\n};\n\n/** `--dry-run`: prints what each conversion would write. Returns whether one was refused. */\nasync function previewModels(run: ModelRun): Promise<boolean> {\n const { out } = run;\n let files = readSourceTexts(run.projectDir);\n let refused = false;\n const notes = new Set<string>();\n for (const dirName of run.pending) {\n const label = `${run.modelsDir}/${dirName}`;\n let migration: DocumentModelMigration;\n try {\n migration = await migrateDocumentModel({\n documentModelsDir: run.modelsDir,\n dirName,\n files,\n moduleReferences: run.moduleReferences,\n renameConflictingTypes: run.renameConflictingTypes,\n });\n if (migration.kind === \"converted\") {\n assertChangesWritable(run.projectDir, migration.files);\n }\n } catch (error) {\n out(\n `${label}: would not convert. The conversion failed unexpectedly: ${errorText(error)}\\n`,\n );\n refused = true;\n continue;\n }\n if (migration.kind !== \"converted\") {\n out(`${label}: ${refusalText(migration)}\\n`);\n refused = true;\n continue;\n }\n out(\n `${label}: would convert ${migration.documentType} (versions ${migration.versions.join(\", \")}) to code-first, if the converted model keeps its definition when loaded\\n`,\n );\n for (const file of migration.files) out(fileDiff(file));\n for (const note of migration.notes) notes.add(note);\n files = applied(files, migration.files);\n }\n for (const note of notes) out(`Note: ${note}\\n`);\n return refused;\n}\n\n/**\n * Converts each model, writes it, loads it again and keeps it only when every\n * version has its stored definition; then regenerates the barrels. Returns\n * whether a model was not converted.\n */\nasync function convertModels(run: ModelRun): Promise<boolean> {\n const { projectDir, out } = run;\n let files = readSourceTexts(projectDir);\n const before = await storedDefinitions(\n projectDir,\n run.modelsDir,\n run.pending,\n files,\n );\n let failed = false;\n const converted = new Set<string>();\n const notes = new Set<string>();\n for (const dirName of run.pending) {\n const label = `${run.modelsDir}/${dirName}`;\n let outcome: ModelOutcome;\n try {\n outcome = await convertModel(run, dirName, files, before);\n } catch (error) {\n outcome = {\n ok: false,\n text: `not converted; its files are unchanged. The conversion failed unexpectedly: ${errorText(error)}`,\n };\n }\n if (!outcome.ok) {\n out(`${label}: ${outcome.text}\\n`);\n failed = true;\n continue;\n }\n const { migration } = outcome;\n files = applied(files, migration.files);\n out(\n `${label}: converted ${migration.documentType} (versions ${migration.versions.join(\", \")}) to code-first; every version keeps its definition\\n`,\n );\n for (const note of migration.notes) notes.add(note);\n converted.add(dirName);\n }\n for (const note of notes) out(`Note: ${note}\\n`);\n if (converted.size > 0) {\n try {\n const changed = await regenerateDocumentModelBarrels(\n projectDir,\n converted,\n );\n if (changed.length > 0) {\n out(`Regenerated ${changed.join(\", \")}.\\n`);\n }\n } catch (error) {\n out(\n `The converted models are written, but the document-models barrels could not be regenerated: ${errorText(error)}\\nFix that, then run ph generate.\\n`,\n );\n failed = true;\n }\n }\n return failed;\n}\n\ntype ModelOutcome =\n | {\n readonly ok: true;\n readonly migration: Extract<\n DocumentModelMigration,\n { kind: \"converted\" }\n >;\n }\n | { readonly ok: false; readonly text: string };\n\n/** Converts, writes and verifies one model, restoring its files when it fails. */\nasync function convertModel(\n run: ModelRun,\n dirName: string,\n files: ReadonlyMap<string, string>,\n before: StoredDefinitions,\n): Promise<ModelOutcome> {\n const migration = await migrateDocumentModel({\n documentModelsDir: run.modelsDir,\n dirName,\n files,\n moduleReferences: run.moduleReferences,\n renameConflictingTypes: run.renameConflictingTypes,\n });\n if (migration.kind !== \"converted\") {\n return { ok: false, text: refusalText(migration) };\n }\n const stored = before.definitions.get(dirName);\n const unread = migration.versions.filter(\n (version) => stored?.has(version) !== true,\n );\n if (stored === undefined || unread.length > 0) {\n return {\n ok: false,\n text: `not converted. Version ${unread.join(\", \")} of its stored definition could not be read, so the conversion could not be checked. Run ph model check to see why.`,\n };\n }\n let backup: FileBackup;\n try {\n backup = writeChanges(run.projectDir, migration.files);\n } catch (error) {\n return {\n ok: false,\n text: `not converted; its files are restored. Writing them failed: ${errorText(error)}`,\n };\n }\n let verification: Awaited<ReturnType<typeof verify>>;\n try {\n verification = await verify(\n run.projectDir,\n migration.documentType,\n renameTypes(stored, migration.renamedTypes),\n before.known,\n );\n } catch (error) {\n verification = {\n ok: false,\n reason: `Checking the converted model failed: ${errorText(error)}`,\n };\n }\n if (!verification.ok) {\n restoreChanges(run.projectDir, backup);\n return {\n ok: false,\n text: `not converted; its files are restored. ${verification.reason}`,\n };\n }\n return { ok: true, migration };\n}\n\n/** The package's source files as text, by project-relative POSIX path. */\nfunction readSourceTexts(projectDir: string): Map<string, string> {\n return new Map(\n [...readProjectFiles(projectDir, SOURCE_FILE)].map(([path, bytes]) => [\n path,\n bytes.toString(\"utf8\"),\n ]),\n );\n}\n\nfunction applied(\n files: ReadonlyMap<string, string>,\n changes: readonly DocumentModelMigrationFile[],\n): Map<string, string> {\n const next = new Map(files);\n for (const file of changes) {\n if (file.after === null) next.delete(file.path);\n else next.set(file.path, file.after);\n }\n return next;\n}\n\ntype StoredDefinitions = {\n readonly definitions: ReadonlyMap<string, Definitions>;\n /** The errors the project reported before anything was written. */\n readonly known: ReadonlySet<string>;\n};\n\n/** The stored versions of each model, read before anything is written. */\nasync function storedDefinitions(\n projectDir: string,\n modelsDir: string,\n dirNames: readonly string[],\n files: ReadonlyMap<string, string>,\n): Promise<StoredDefinitions> {\n const wanted = dirNames.flatMap((dirName) => {\n const text = files.get(`${modelsDir}/${dirName}/${dirName}.json`);\n if (text === undefined) return [];\n try {\n const stored = JSON.parse(text) as {\n id: string;\n specifications: { version: number }[];\n };\n return [\n {\n dirName,\n documentType: stored.id,\n versions: stored.specifications.map(({ version }) => version),\n },\n ];\n } catch {\n // The migration refuses a specification that is not JSON, and says why.\n return [];\n }\n });\n return await readProjectDefinitions(projectDir, (project) => {\n const result = new Map<string, Definitions>();\n const known = new Set<string>();\n for (const { dirName, documentType, versions } of wanted) {\n const definitions = new Map<number, unknown>();\n for (const version of versions) {\n const report = inspectProjectDefinitions(project, {\n selection: { documentType, version },\n });\n if (\"definition\" in report) definitions.set(version, report.definition);\n for (const message of errorMessages(report.diagnostics)) {\n known.add(message);\n }\n }\n result.set(dirName, definitions);\n }\n return { definitions: result, known };\n });\n}\n\nfunction errorMessages(\n diagnostics: readonly {\n readonly severity: string;\n readonly message: string;\n readonly repair?: string;\n }[],\n): string[] {\n return diagnostics\n .filter(({ severity }) => severity === \"error\")\n .map(({ message, repair }) => `${message} ${repair ?? \"\"}`.trim());\n}\n\ntype Verification =\n | { readonly ok: true }\n | { readonly ok: false; readonly reason: string };\n\n/**\n * The stored definitions with the types the conversion renamed off a\n * scalar's name renamed too, so the comparison expects the new names. The\n * stored definition also lists the scalar the type's name collided with,\n * which the converted model no longer names.\n */\nfunction renameTypes(\n definitions: Definitions,\n renamed: readonly { version: number; from: string; to: string }[],\n): Definitions {\n if (renamed.length === 0) return definitions;\n const result = new Map<number, unknown>();\n for (const [version, definition] of definitions) {\n const names = new Map(\n renamed\n .filter((entry) => entry.version === version)\n .map(({ from, to }) => [from, to] as const),\n );\n // A type is named by `name` in its definition and in every reference;\n // unions and interfaces list members and implemented types by name.\n const walk = (value: unknown, key?: string): unknown => {\n if (key === \"scalars\" && Array.isArray(value)) {\n return value.filter(\n (scalar) =>\n !(\n isRecord(scalar) &&\n typeof scalar.name === \"string\" &&\n names.has(scalar.name)\n ),\n );\n }\n if (Array.isArray(value)) {\n return value.map((item) =>\n (key === \"members\" || key === \"implements\") &&\n typeof item === \"string\"\n ? (names.get(item) ?? item)\n : walk(item),\n );\n }\n if (!isRecord(value)) return value;\n return Object.fromEntries(\n Object.entries(value).map(([entryKey, entry]) => [\n entryKey,\n entryKey === \"name\" &&\n typeof entry === \"string\" &&\n typeof value.kind === \"string\"\n ? (names.get(entry) ?? entry)\n : walk(entry, entryKey),\n ]),\n );\n };\n result.set(version, walk(definition));\n }\n return result;\n}\n\n/** Loads the converted model and compares each version with its stored definition. */\nasync function verify(\n projectDir: string,\n documentType: string,\n expected: Definitions,\n known: ReadonlySet<string>,\n): Promise<Verification> {\n let actual: ReadonlyMap<number, unknown>;\n let problems: readonly string[];\n try {\n [actual, problems] = await readProjectDefinitions(projectDir, (project) => {\n const definitions = new Map<number, unknown>();\n const errors: string[] = [];\n for (const version of expected.keys()) {\n const report = inspectProjectDefinitions(project, {\n selection: { documentType, version },\n });\n if (\"definition\" in report) definitions.set(version, report.definition);\n for (const message of errorMessages(report.diagnostics)) {\n // Errors the project had before, such as another model's, are not this conversion's.\n if (!known.has(message)) errors.push(message);\n }\n }\n return [definitions, errors] as const;\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n ok: false,\n reason: `The converted model does not load: ${message.replaceAll(projectDir, \".\")}`,\n };\n }\n if (problems.length > 0) {\n return {\n ok: false,\n reason: `The converted model does not pass ph model check:\\n${[...new Set(problems)].map((problem) => ` ${problem}`).join(\"\\n\")}`,\n };\n }\n for (const [version, stored] of expected) {\n const converted = actual.get(version);\n if (converted === undefined) {\n return {\n ok: false,\n reason: `The converted model exports no version ${version} of ${documentType}.`,\n };\n }\n const differences = definitionDifferences(stored, converted);\n if (differences.length > 0) {\n return {\n ok: false,\n reason: `Version ${version} of the converted model has a different definition:\\n${differences\n .slice(0, 20)\n .map((line) => ` ${line}`)\n .join(\"\\n\")}`,\n };\n }\n }\n return { ok: true };\n}\n\n/**\n * What a stored definition and the code-first one differ in. IDs, the\n * stored names of modules and operations, the reducer and template text, and\n * the GraphQL text a schema-first model keeps derive from the authoring\n * style, so they are not compared. The model, every named type (operation\n * inputs included), the state roots and initial values, and each operation's\n * key, action type, scope, input and errors are.\n */\nexport function definitionDifferences(\n stored: unknown,\n converted: unknown,\n): string[] {\n const differences: string[] = [];\n const walk = (left: unknown, right: unknown, path: string) => {\n if (differences.length >= 50) return;\n if (Array.isArray(left) && Array.isArray(right)) {\n if (left.length !== right.length) {\n differences.push(\n `${path}: ${left.length} entries stored, ${right.length} converted`,\n );\n }\n for (\n let index = 0;\n index < Math.min(left.length, right.length);\n index++\n ) {\n walk(left[index], right[index], `${path}[${index}]`);\n }\n return;\n }\n if (isRecord(left) && isRecord(right)) {\n for (const key of new Set([\n ...Object.keys(left),\n ...Object.keys(right),\n ])) {\n walk(left[key], right[key], path === \"\" ? key : `${path}.${key}`);\n }\n return;\n }\n if (JSON.stringify(left) !== JSON.stringify(right)) {\n differences.push(\n `${path}: stored ${JSON.stringify(left)}, converted ${JSON.stringify(right)}`,\n );\n }\n };\n walk(canonical(stored), canonical(converted), \"\");\n return differences;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The records of a list, or none when it is not one. */\nfunction records(value: unknown): Record<string, unknown>[] {\n return Array.isArray(value) ? value.filter(isRecord) : [];\n}\n\n/** Empty text and null both mean \"none\" in a stored model. */\nconst text = (value: unknown): unknown => (value === \"\" ? null : value);\n\n/** Members whose empty text means none, as the stored format writes it. */\nconst TEXT_KEYS = new Set([\"description\", \"deprecated\", \"template\"]);\n\n/** `value` with empty text read as none, and without `keys`, at any depth. */\nfunction normalized(value: unknown, keys: readonly string[] = []): unknown {\n if (Array.isArray(value)) return value.map((item) => normalized(item, keys));\n if (!isRecord(value)) return value;\n return Object.fromEntries(\n Object.entries(value)\n .filter(([key]) => !keys.includes(key))\n .map(([key, entry]) => [\n key,\n TEXT_KEYS.has(key) ? text(entry) : normalized(entry, keys),\n ]),\n );\n}\n\n/**\n * How one member of a definition is compared: `ignore` leaves it out, a\n * function maps it to what is compared. The tables are exhaustive over the\n * definition types, so a member added to them must be classified here; a\n * member the loaded definition has and a table lacks is compared as is.\n */\ntype Rule = \"ignore\" | ((value: unknown) => unknown);\ntype Rules<T> = { readonly [Key in keyof Required<T>]: Rule };\n\nconst same = (value: unknown) => normalized(value);\nconst exampleValues = (value: unknown) =>\n records(value).map((example) => example.value);\n\nfunction compared<T>(value: unknown, rules: Rules<T>): unknown {\n if (!isRecord(value)) return value;\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const rule = (rules as Readonly<Record<string, Rule | undefined>>)[key];\n if (rule === \"ignore\") continue;\n result[key] = (rule ?? same)(entry);\n }\n return result;\n}\n\nconst STATE_RULES: Rules<StateDefinition> = {\n root: same,\n initialValue: (value) => value ?? {},\n examples: exampleValues,\n unknownKeys: same,\n // The GraphQL and JSON text the state is materialized from.\n materialized: \"ignore\",\n};\n\nconst OPERATION_RULES: Rules<DocumentModelOperationDefinition> = {\n id: \"ignore\",\n // The stored operation name; the key and action type derive from it.\n name: \"ignore\",\n key: same,\n description: text,\n actionType: same,\n creatorKey: same,\n scope: same,\n // Compared among the specification's types.\n input: (value) => (isRecord(value) ? value.name : null),\n errors: (value) => normalized(value, [\"id\", \"key\"]),\n examples: exampleValues,\n template: \"ignore\",\n reducer: \"ignore\",\n};\n\nconst MODULE_RULES: Rules<DocumentModelModuleDefinition> = {\n id: \"ignore\",\n // The stored module name; the key derives from it.\n name: \"ignore\",\n key: same,\n description: text,\n operations: (value) =>\n records(value).map((operation) => compared(operation, OPERATION_RULES)),\n};\n\n/** The named types of a specification, operation inputs included, by name. */\nfunction namedTypes(specification: Record<string, unknown>): unknown {\n const types = new Map<string, unknown>();\n const add = (type: unknown) => {\n if (isRecord(type) && typeof type.name === \"string\") {\n types.set(type.name, normalized(type, [\"key\"]));\n }\n };\n for (const type of records(specification.types)) add(type);\n for (const module of records(specification.modules)) {\n for (const operation of records(module.operations)) add(operation.input);\n }\n return Object.fromEntries(\n [...types].sort(([left], [right]) => left.localeCompare(right)),\n );\n}\n\nconst SPECIFICATION_RULES: Rules<DocumentModelSpecificationDefinition> = {\n version: same,\n changeLog: same,\n scalars: same,\n // The GraphQL text a schema-first model keeps.\n graphQLCompatibility: \"ignore\",\n types: \"ignore\",\n state: (value) =>\n isRecord(value)\n ? {\n global: compared(value.global, STATE_RULES),\n local: compared(value.local, STATE_RULES),\n }\n : value,\n modules: (value) =>\n records(value).map((module) => compared(module, MODULE_RULES)),\n};\n\nconst DEFINITION_RULES: Rules<DocumentModelDefinition> = {\n kind: same,\n formatVersion: same,\n // How identities and serialization derive differs by authoring style.\n compatibility: (value) =>\n isRecord(value) ? { scalarCoercion: value.scalarCoercion } : value,\n model: same,\n specifications: (value) =>\n records(value).map((specification) => {\n const result = compared(specification, SPECIFICATION_RULES);\n return isRecord(result)\n ? { ...result, types: namedTypes(specification) }\n : result;\n }),\n};\n\n/** The parts of a definition both authoring styles must agree on. */\nfunction canonical(definition: unknown): unknown {\n return compared(definition, DEFINITION_RULES);\n}\n\nfunction fileDiff(file: DocumentModelMigrationFile): string {\n if (file.after === null)\n return `--- a/${file.path}\\n+++ /dev/null\\n(deleted)\\n`;\n return unifiedDiff({\n path: file.path,\n before: file.before,\n after: file.after,\n });\n}\n\nfunction refusalText(\n migration: Extract<DocumentModelMigration, { kind: \"refused\" }>,\n): string {\n return `not converted\\n${migration.refusals\n .map(\n ({ file, line, reason, repair }) =>\n ` ${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(){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]="4f68f50c-fc0e-5a47-bcfd-21263292763d")}catch(e){}}();
|
|
4
|
+
//# debugId=4f68f50c-fc0e-5a47-bcfd-21263292763d
|
|
@@ -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 getVersion } from "./get-version-
|
|
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]="7d3651a1-27f8-570b-8ac0-dbff72986a16")}catch(e){}}();
|
|
3
|
+
import { t as getVersion } from "./get-version-7oKMD8Gt.mjs";
|
|
4
4
|
import { i as readProjectDefinitions } from "./run--de_-WAz.mjs";
|
|
5
|
-
import { t as definitionChecks } from "./check-
|
|
5
|
+
import { t as definitionChecks } from "./check-DM7UdFTK.mjs";
|
|
6
6
|
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, rmdirSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { basename, dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
8
8
|
import { castResolverTypeErrors, migrateSubgraph, projectTypeErrors, resolverCallErrors, sortedSchemaText, typeErrorMessage } from "@powerhousedao/codegen";
|
|
@@ -746,5 +746,5 @@ function unifiedDiff(file) {
|
|
|
746
746
|
//#endregion
|
|
747
747
|
export { errorText as a, toPosix as c, assertChangesWritable as i, writeChanges as l, unifiedDiff as n, readProjectFiles as o, projectModuleReferences as r, restoreChanges as s, migrateSubgraphs as t, outdatedDependency as u };
|
|
748
748
|
|
|
749
|
-
//# sourceMappingURL=migrate-subgraphs-
|
|
750
|
-
//# debugId=
|
|
749
|
+
//# sourceMappingURL=migrate-subgraphs-Ffwwm7Oy.mjs.map
|
|
750
|
+
//# debugId=7d3651a1-27f8-570b-8ac0-dbff72986a16
|