@powerhousedao/ph-cli 6.2.3 → 6.3.0-dev.10
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 +21 -0
- package/dist/build-CD_KQkCH.mjs +4 -0
- package/dist/build-DDG00Wbj.mjs +3067 -0
- package/dist/build-DDG00Wbj.mjs.map +1 -0
- package/dist/check-B8oqVMg7.mjs +65 -0
- package/dist/check-B8oqVMg7.mjs.map +1 -0
- package/dist/check-CpzjVXHj.mjs +4 -0
- package/dist/check-Weu9n8OQ.mjs +81 -0
- package/dist/check-Weu9n8OQ.mjs.map +1 -0
- package/dist/classic-args-mH_DVsgC.mjs +48 -0
- package/dist/classic-args-mH_DVsgC.mjs.map +1 -0
- package/dist/classic-warnings-BR0S6lr5.mjs +179 -0
- package/dist/classic-warnings-BR0S6lr5.mjs.map +1 -0
- package/dist/{cli-connect-override-b4kKqgOZ.mjs → cli-connect-override-D22yFWlC.mjs} +6 -29
- package/dist/cli-connect-override-D22yFWlC.mjs.map +1 -0
- package/dist/cli.mjs +46 -1341
- package/dist/cli.mjs.map +1 -1
- package/dist/compound-DKi56SSx-CXQHhS6t.mjs +2911 -0
- package/dist/compound-DKi56SSx-CXQHhS6t.mjs.map +1 -0
- package/dist/connect-build-Bd6sSVwp.mjs +322 -0
- package/dist/connect-build-Bd6sSVwp.mjs.map +1 -0
- package/dist/{connect-config-_kiSMsbG.mjs → connect-config-CVU4xhti.mjs} +5 -5
- package/dist/{connect-config-_kiSMsbG.mjs.map → connect-config-CVU4xhti.mjs.map} +1 -1
- package/dist/connect-preview-CdFvlANO.mjs +49 -0
- package/dist/connect-preview-CdFvlANO.mjs.map +1 -0
- package/dist/connect-studio-BnfhpIv8.mjs +97 -0
- package/dist/connect-studio-BnfhpIv8.mjs.map +1 -0
- package/dist/{connect-studio-f3K1qPWd.mjs → connect-studio-D58ByAAn.mjs} +3 -3
- package/dist/definitions-worker.d.mts +98 -0
- package/dist/definitions-worker.d.mts.map +1 -0
- package/dist/definitions-worker.mjs +28 -0
- package/dist/definitions-worker.mjs.map +1 -0
- package/dist/dist-DXcB8fAF.mjs +542 -0
- package/dist/dist-DXcB8fAF.mjs.map +1 -0
- package/dist/evidence-CavwC5YV.mjs +134 -0
- package/dist/evidence-CavwC5YV.mjs.map +1 -0
- package/dist/explain-8OEXF2Dy.mjs +230 -0
- package/dist/explain-8OEXF2Dy.mjs.map +1 -0
- package/dist/export-DqbcbFU5.mjs +42 -0
- package/dist/export-DqbcbFU5.mjs.map +1 -0
- package/dist/external-M25AgDIE.d.mts +4277 -0
- package/dist/external-M25AgDIE.d.mts.map +1 -0
- package/dist/files-D6_euBBn.mjs +457 -0
- package/dist/files-D6_euBBn.mjs.map +1 -0
- package/dist/{generate-all-CIwP-3aa.mjs → generate-all-0YOnlZM0.mjs} +10 -5
- package/dist/generate-all-0YOnlZM0.mjs.map +1 -0
- package/dist/generate-app-hm6CJ_4O.mjs +72 -0
- package/dist/generate-app-hm6CJ_4O.mjs.map +1 -0
- package/dist/generate-desktop-shell-BovoRsR6.mjs +372 -0
- package/dist/generate-desktop-shell-BovoRsR6.mjs.map +1 -0
- package/dist/generate-document-model-BiD6ovXc.mjs +118 -0
- package/dist/generate-document-model-BiD6ovXc.mjs.map +1 -0
- package/dist/generate-editor-DBj_Pxwa.mjs +64 -0
- package/dist/generate-editor-DBj_Pxwa.mjs.map +1 -0
- package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
- package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
- package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
- package/dist/generate-migration-file-yK8uA70U.mjs +20 -0
- package/dist/generate-migration-file-yK8uA70U.mjs.map +1 -0
- package/dist/{generate-piece-QTt-ddt2.mjs → generate-piece-5Nyr2UZj.mjs} +18 -10
- package/dist/generate-piece-5Nyr2UZj.mjs.map +1 -0
- package/dist/{generate-piece-action-C5WTHsqu.mjs → generate-piece-action-DqR8BcoO.mjs} +10 -7
- package/dist/generate-piece-action-DqR8BcoO.mjs.map +1 -0
- package/dist/{generate-piece-trigger-DR10CPOG.mjs → generate-piece-trigger-CZaDD-cc.mjs} +8 -7
- package/dist/generate-piece-trigger-CZaDD-cc.mjs.map +1 -0
- package/dist/{generate-processor-DBtTkgo5.mjs → generate-processor-BVjOsfjJ.mjs} +20 -9
- package/dist/generate-processor-BVjOsfjJ.mjs.map +1 -0
- package/dist/generate-subgraph-DJZCr0Tk.mjs +86 -0
- package/dist/generate-subgraph-DJZCr0Tk.mjs.map +1 -0
- package/dist/get-version-ByaMbjqz.mjs +11 -0
- package/dist/get-version-ByaMbjqz.mjs.map +1 -0
- package/dist/index-H3AYe65i.d.mts +193 -0
- package/dist/index-H3AYe65i.d.mts.map +1 -0
- package/dist/{init-CIEMyAug.mjs → init-Ltg4cJzm.mjs} +29 -17
- package/dist/init-Ltg4cJzm.mjs.map +1 -0
- package/dist/inspect-CulIpVsF.mjs +52 -0
- package/dist/inspect-CulIpVsF.mjs.map +1 -0
- package/dist/{inspect-BpCB0TPo.mjs → inspect-zWJnBDMJ.mjs} +4 -4
- package/dist/{inspect-BpCB0TPo.mjs.map → inspect-zWJnBDMJ.mjs.map} +1 -1
- package/dist/install-added-dependencies-DnZFR3aE.mjs +18 -0
- package/dist/install-added-dependencies-DnZFR3aE.mjs.map +1 -0
- package/dist/keyframes-bFo9iDhT.mjs +201 -0
- package/dist/keyframes-bFo9iDhT.mjs.map +1 -0
- package/dist/mcp-VRTEA0Ib.mjs +263 -0
- package/dist/mcp-VRTEA0Ib.mjs.map +1 -0
- package/dist/migrate-BGFxHRgP.mjs +209 -0
- package/dist/migrate-BGFxHRgP.mjs.map +1 -0
- package/dist/migrate-document-models-CFNqYAgo.mjs +489 -0
- package/dist/migrate-document-models-CFNqYAgo.mjs.map +1 -0
- package/dist/migrate-subgraphs-BG-4KEzt.mjs +4 -0
- package/dist/migrate-subgraphs-CIksXwT7.mjs +710 -0
- package/dist/migrate-subgraphs-CIksXwT7.mjs.map +1 -0
- package/dist/module-dir-1avCXsBi.mjs +17 -0
- package/dist/module-dir-1avCXsBi.mjs.map +1 -0
- package/dist/npm-args-g1Tgel4s.mjs +78 -0
- package/dist/npm-args-g1Tgel4s.mjs.map +1 -0
- package/dist/offered-routes-imports-CQInWI6y.mjs +4 -0
- package/dist/offered-routes-imports-CalXK9dh.mjs +96 -0
- package/dist/offered-routes-imports-CalXK9dh.mjs.map +1 -0
- package/dist/ph-cli-commands-CcMT6rdd.mjs +4 -0
- package/dist/ph-cli-commands-Dy4vWwUm.mjs +1821 -0
- package/dist/ph-cli-commands-Dy4vWwUm.mjs.map +1 -0
- package/dist/render-3M3DwFzO.mjs +4 -0
- package/dist/render-SVfj3m8A.mjs +77 -0
- package/dist/render-SVfj3m8A.mjs.map +1 -0
- package/dist/run--de_-WAz.mjs +112 -0
- package/dist/run--de_-WAz.mjs.map +1 -0
- package/dist/run-LRGy7zGo.mjs +4 -0
- package/dist/run-sugar-DpznOP1e.mjs +56 -0
- package/dist/run-sugar-DpznOP1e.mjs.map +1 -0
- package/dist/runners/connect.d.mts +17 -0
- package/dist/runners/connect.d.mts.map +1 -0
- package/dist/runners/connect.mjs +83 -0
- package/dist/runners/connect.mjs.map +1 -0
- package/dist/runners/switchboard.d.mts +24 -0
- package/dist/runners/switchboard.d.mts.map +1 -0
- package/dist/runners/switchboard.mjs +178 -0
- package/dist/runners/switchboard.mjs.map +1 -0
- package/dist/schemas-DzgKfQIx.mjs +6024 -0
- package/dist/schemas-DzgKfQIx.mjs.map +1 -0
- package/dist/scripts/emit-runner-schemas.ts +24 -0
- package/dist/scripts/generate-commands-docs.ts +19 -0
- package/dist/scripts/manage-environment +0 -0
- package/dist/scripts/setup.sh +0 -0
- package/dist/subgraph-gate-BJ2PWXVY.mjs +26 -0
- package/dist/subgraph-gate-BJ2PWXVY.mjs.map +1 -0
- package/dist/subgraph-gate-j9ywj6KA.mjs +4 -0
- package/dist/subgraphs-7OYWwP-C.mjs +134 -0
- package/dist/subgraphs-7OYWwP-C.mjs.map +1 -0
- package/dist/{switchboard-migrate-7JQZM7-5.mjs → switchboard-migrate-BqSdKJ7u.mjs} +4 -5
- package/dist/switchboard-migrate-BqSdKJ7u.mjs.map +1 -0
- package/dist/switchboard-proxy-CGfMtENM.mjs +37 -0
- package/dist/switchboard-proxy-CGfMtENM.mjs.map +1 -0
- package/dist/{switchboard-reset-Ctegiqdm.mjs → switchboard-reset-MtTB_GAI.mjs} +8 -6
- package/dist/switchboard-reset-MtTB_GAI.mjs.map +1 -0
- package/dist/sync-connect-routes-BtAsFPXN.mjs +4 -0
- package/dist/sync-connect-routes-t0Slg-P6.mjs +25 -0
- package/dist/sync-connect-routes-t0Slg-P6.mjs.map +1 -0
- package/dist/{utils-CvmDmCVd.mjs → utils-9KyRM0mf.mjs} +6 -34
- package/dist/{utils-CvmDmCVd.mjs.map → utils-9KyRM0mf.mjs.map} +1 -1
- package/dist/utils-TO9lB8Xs.mjs +4 -0
- package/dist/verify-D4V5VLnG.mjs +71 -0
- package/dist/verify-D4V5VLnG.mjs.map +1 -0
- package/dist/vetra-CVNZ46pK.mjs +352 -0
- package/dist/vetra-CVNZ46pK.mjs.map +1 -0
- package/dist/vetra-host-ChTpJiBJ.mjs +79 -0
- package/dist/vetra-host-ChTpJiBJ.mjs.map +1 -0
- package/dist/vetra-instance-CzhYIjxL.mjs +201 -0
- package/dist/vetra-instance-CzhYIjxL.mjs.map +1 -0
- package/dist/vetra-launch-qi10Unax.mjs +237 -0
- package/dist/vetra-launch-qi10Unax.mjs.map +1 -0
- package/dist/vetra-switchboard-BrkozIm7.mjs +4 -0
- package/dist/vetra-switchboard-tzdc14KA.mjs +230 -0
- package/dist/vetra-switchboard-tzdc14KA.mjs.map +1 -0
- package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +19 -0
- package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +1 -0
- package/package.json +41 -15
- package/dist/build-CTvPQFMi.mjs +0 -4
- package/dist/build-sO3PcZxl.mjs +0 -166
- package/dist/build-sO3PcZxl.mjs.map +0 -1
- package/dist/cli-connect-override-b4kKqgOZ.mjs.map +0 -1
- package/dist/connect-build-BMaR9w4G.mjs +0 -153
- package/dist/connect-build-BMaR9w4G.mjs.map +0 -1
- package/dist/connect-preview-CzDqR-JN.mjs +0 -32
- package/dist/connect-preview-CzDqR-JN.mjs.map +0 -1
- package/dist/connect-studio-_-O1-oef.mjs +0 -36
- package/dist/connect-studio-_-O1-oef.mjs.map +0 -1
- package/dist/generate-all-CIwP-3aa.mjs.map +0 -1
- package/dist/generate-app-BTs1u-9l.mjs +0 -50
- package/dist/generate-app-BTs1u-9l.mjs.map +0 -1
- package/dist/generate-document-model-DhDQ_06X.mjs +0 -44
- package/dist/generate-document-model-DhDQ_06X.mjs.map +0 -1
- package/dist/generate-editor-CW7Do69u.mjs +0 -50
- package/dist/generate-editor-CW7Do69u.mjs.map +0 -1
- package/dist/generate-piece-QTt-ddt2.mjs.map +0 -1
- package/dist/generate-piece-action-C5WTHsqu.mjs.map +0 -1
- package/dist/generate-piece-trigger-DR10CPOG.mjs.map +0 -1
- package/dist/generate-processor-DBtTkgo5.mjs.map +0 -1
- package/dist/generate-subgraph-Dm27O59o.mjs +0 -42
- package/dist/generate-subgraph-Dm27O59o.mjs.map +0 -1
- package/dist/init-CIEMyAug.mjs.map +0 -1
- package/dist/install-added-dependencies-DVSbzler.mjs +0 -33
- package/dist/install-added-dependencies-DVSbzler.mjs.map +0 -1
- package/dist/migrate-B6QBYDNX.mjs +0 -83
- package/dist/migrate-B6QBYDNX.mjs.map +0 -1
- package/dist/switchboard-CgVB4U76.mjs +0 -87
- package/dist/switchboard-CgVB4U76.mjs.map +0 -1
- package/dist/switchboard-migrate-7JQZM7-5.mjs.map +0 -1
- package/dist/switchboard-nHCI3pha.mjs +0 -4
- package/dist/switchboard-reset-Ctegiqdm.mjs.map +0 -1
- package/dist/utils-C3c5YG6v.mjs +0 -4
- package/dist/vetra-s8gWslse.mjs +0 -627
- package/dist/vetra-s8gWslse.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-subgraphs-CIksXwT7.mjs","sources":["../src/services/installed-version.ts","../src/services/project-files.ts","../src/services/package-module-targets.ts","../src/services/project-module-references.ts","../src/services/subgraph-readers.ts","../src/services/migrate-subgraphs.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { lt, valid } from \"semver\";\nimport { getVersion } from \"../get-version.js\";\n\n/** The version of `packageName` that Node resolves from `projectDir`. */\nfunction installedVersion(\n projectDir: string,\n packageName: string,\n): string | undefined {\n for (let dir = projectDir; ; dir = dirname(dir)) {\n const manifest = join(dir, \"node_modules\", packageName, \"package.json\");\n if (existsSync(manifest)) {\n const { version } = JSON.parse(readFileSync(manifest, \"utf8\")) as {\n version?: unknown;\n };\n return typeof version === \"string\" ? version : undefined;\n }\n if (dirname(dir) === dir) return undefined;\n }\n}\n\n/**\n * Why the code `ph migrate` writes cannot run against the project's\n * `packageName`, or undefined when it can: the project must have the package\n * at this ph-cli's version or later. Unknown versions are not checked.\n */\nexport function outdatedDependency(\n projectDir: string,\n packageName: string,\n): string | undefined {\n const required = getVersion();\n if (valid(required) === null) return undefined;\n const installed = installedVersion(projectDir, packageName);\n if (installed === undefined) {\n return `${packageName} is not installed in this project. Install the project's dependencies, then migrate again.`;\n }\n if (valid(installed) === null || !lt(installed, required)) return undefined;\n return `This project has ${packageName} ${installed}, and what this ph migrate converts to code-first needs ${required} or later. Run ph migrate ${required} to upgrade the Powerhouse packages, then convert again.`;\n}\n","import {\n chmodSync,\n existsSync,\n lstatSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n rmdirSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\n\n/** Directories that never hold the package's own sources. */\nconst SKIPPED_DIRS = new Set([\n \"node_modules\",\n \"dist\",\n \"build\",\n \".ph\",\n \".git\",\n \".turbo\",\n \".vite\",\n \".tsbuild\",\n \"coverage\",\n]);\n\nexport const toPosix = (path: string) => path.split(sep).join(\"/\");\n\nexport const errorText = (error: unknown) =>\n error instanceof Error ? error.message : String(error);\n\n/** The package's files whose names match `pattern`, by project-relative POSIX path. */\nexport function readProjectFiles(\n projectDir: string,\n pattern: RegExp,\n): Map<string, Buffer> {\n const files = new Map<string, Buffer>();\n const visit = (dir: string) => {\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n if (!SKIPPED_DIRS.has(entry.name)) visit(join(dir, entry.name));\n } else if (entry.isFile() && pattern.test(entry.name)) {\n const path = join(dir, entry.name);\n files.set(toPosix(relative(projectDir, path)), readFileSync(path));\n }\n }\n };\n visit(projectDir);\n return files;\n}\n\n/** A file a migration writes, or deletes when `after` is null. */\nexport type FileChange = {\n readonly path: string;\n readonly after: string | null;\n};\n\n/** Each original file's contents and permissions, or null when it does not exist. */\nexport type FileBackup = ReadonlyMap<\n string,\n { readonly bytes: Buffer; readonly mode: number } | null\n>;\n\n/** Refuses links the source inventory cannot represent without following them. */\nexport function assertChangesWritable(\n projectDir: string,\n changes: readonly { readonly path: string }[],\n): void {\n const root = resolve(projectDir);\n for (const { path } of changes) {\n let current = resolve(root, path);\n const local = relative(root, current);\n if (\n local === \"\" ||\n local === \"..\" ||\n local.startsWith(`..${sep}`) ||\n isAbsolute(local)\n ) {\n throw new Error(`${path} is not a file inside this project.`);\n }\n while (current !== root) {\n if (lstatSync(current, { throwIfNoEntry: false })?.isSymbolicLink()) {\n throw new Error(\n `${toPosix(relative(root, current))} is a symbolic link. Replace it with a regular project file or directory before migrating; its target was not changed.`,\n );\n }\n current = dirname(current);\n }\n }\n}\n\n/**\n * Writes `changes` and returns the bytes they replaced. When a write fails,\n * everything already written is restored before the error is rethrown.\n */\nexport function writeChanges(\n projectDir: string,\n changes: readonly FileChange[],\n): FileBackup {\n assertChangesWritable(projectDir, changes);\n const backup = new Map<\n string,\n { readonly bytes: Buffer; readonly mode: number } | null\n >();\n for (const { path } of changes) {\n const absolute = join(projectDir, path);\n backup.set(\n path,\n existsSync(absolute)\n ? {\n bytes: readFileSync(absolute),\n mode: lstatSync(absolute).mode & 0o7777,\n }\n : null,\n );\n }\n try {\n for (const change of changes) put(projectDir, change.path, change.after);\n } catch (error) {\n restoreChanges(projectDir, backup);\n throw error;\n }\n return backup;\n}\n\n/** Restores the contents and permissions `writeChanges` replaced. */\nexport function restoreChanges(projectDir: string, backup: FileBackup) {\n for (const [path, file] of backup) {\n put(projectDir, path, file?.bytes ?? null);\n if (file !== null) chmodSync(join(projectDir, path), file.mode);\n }\n}\n\nfunction put(projectDir: string, path: string, bytes: string | Buffer | null) {\n const absolute = join(projectDir, path);\n if (bytes === null) {\n rmSync(absolute, { force: true });\n removeEmptyParents(projectDir, dirname(absolute));\n } else {\n mkdirSync(dirname(absolute), { recursive: true });\n writeFileSync(absolute, bytes);\n }\n}\n\n/** Removes `dir` and its parents while they are empty, up to the project. */\nfunction removeEmptyParents(projectDir: string, dir: string) {\n let current = dir;\n while (current.startsWith(projectDir) && current !== projectDir) {\n if (!existsSync(current) || readdirSync(current).length > 0) return;\n rmdirSync(current);\n current = dirname(current);\n }\n}\n","import { existsSync, realpathSync } from \"node:fs\";\nimport { dirname, join, relative, resolve, sep } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { type PackageJson, readPackageSync } from \"read-pkg\";\nimport { toPosix } from \"./project-files.js\";\n\n/** Every static alternative, without assuming which runtime conditions apply. */\nfunction alternatives(value: unknown): string[] {\n if (typeof value === \"string\") return [value];\n if (value === null || typeof value !== \"object\") return [];\n return Object.values(value).flatMap(alternatives);\n}\n\n/** Extra matching patterns are safe here: targets are protected, never rewritten. */\nfunction matchingTargets(\n mapping: unknown,\n specifier: string,\n): { pattern: string; targets: string[] }[] {\n if (mapping === null || typeof mapping !== \"object\") return [];\n return Object.entries(mapping).flatMap(([pattern, value]) => {\n if (pattern === specifier)\n return [{ pattern, targets: alternatives(value) }];\n const star = pattern.indexOf(\"*\");\n if (star === -1) return [];\n const prefix = pattern.slice(0, star);\n const suffix = pattern.slice(star + 1);\n if (\n !specifier.startsWith(prefix) ||\n !specifier.endsWith(suffix) ||\n specifier.length < prefix.length + suffix.length\n )\n return [];\n const matched = specifier.slice(\n prefix.length,\n specifier.length - suffix.length,\n );\n return [\n {\n pattern,\n targets: alternatives(value).map((target) =>\n target.replaceAll(\"*\", matched),\n ),\n },\n ];\n });\n}\n\n/** Static local targets of observed imports/self-exports in each file's package scope. */\nexport function packageModuleTargets(projectDir: string) {\n const root = resolve(projectDir);\n const packages = new Map<string, PackageJson | undefined>();\n const imports = (from: string, specifier: string) => {\n const redirects: { from: string; specifier: string }[] = [];\n let dir = dirname(join(root, from));\n for (;;) {\n if (!packages.has(dir)) {\n packages.set(\n dir,\n existsSync(join(dir, \"package.json\"))\n ? readPackageSync({ cwd: dir, normalize: false })\n : undefined,\n );\n }\n const metadata = packages.get(dir);\n if (metadata !== undefined) {\n const visit = (name: string, active: ReadonlySet<string>): string[] => {\n let matches: ReturnType<typeof matchingTargets> = [];\n if (name.startsWith(\"#\")) {\n matches = matchingTargets(metadata.imports, name);\n } else if (\n typeof metadata.name === \"string\" &&\n (name === metadata.name || name.startsWith(`${metadata.name}/`))\n ) {\n const subpath = `.${name.slice(metadata.name.length)}`;\n const exports = metadata.exports;\n const subpaths =\n exports !== null &&\n typeof exports === \"object\" &&\n Object.keys(exports).some((key) => key.startsWith(\".\"));\n matches =\n subpath === \".\" && !subpaths\n ? [{ pattern: \".\", targets: alternatives(exports) }]\n : matchingTargets(exports, subpath);\n }\n return matches.flatMap(({ pattern, targets }) => {\n const key = `${name.startsWith(\"#\") ? \"imports\" : \"exports\"}:${pattern}`;\n if (active.has(key)) {\n throw new Error(\n `Package mapping ${pattern} redirects recursively. Remove that redirect before migrating subgraphs.`,\n );\n }\n const next = new Set(active).add(key);\n return targets.flatMap((target) => {\n if (!target.startsWith(\"./\")) {\n if (\n target.startsWith(\"#\") ||\n (typeof metadata.name === \"string\" &&\n (target === metadata.name ||\n target.startsWith(`${metadata.name}/`)))\n ) {\n return visit(target, next);\n }\n redirects.push({\n from: toPosix(relative(root, join(dir, \"package.json\"))),\n specifier: target,\n });\n return [];\n }\n const file = fileURLToPath(\n new URL(target, pathToFileURL(dir + sep)),\n );\n return [toPosix(relative(root, file))];\n });\n });\n };\n return { targets: visit(specifier, new Set()), redirects };\n }\n if (dir === root) return { targets: [], redirects };\n dir = dirname(dir);\n }\n };\n const entries = (file: string, specifier: string): readonly string[] => {\n const targets = new Set<string>();\n for (const dir of new Set([dirname(file), dirname(realpathSync(file))])) {\n if (!packages.has(dir)) {\n packages.set(dir, readPackageSync({ cwd: dir, normalize: false }));\n }\n const metadata = packages.get(dir);\n if (metadata === undefined) continue;\n const paths = [\n \"./index.js\",\n ...alternatives(metadata.main),\n ...alternatives(metadata[\"module\"]),\n ...alternatives(metadata[\"browser\"]),\n ...alternatives(metadata[\"jsnext:main\"]),\n ...alternatives(metadata[\"jsnext\"]),\n ];\n const exports = metadata.exports;\n const subpaths =\n exports !== null &&\n typeof exports === \"object\" &&\n Object.keys(exports).some((key) => key.startsWith(\".\"));\n if (!subpaths) paths.push(...alternatives(exports));\n else {\n const parts = specifier.split(\"/\");\n const subpath = parts\n .slice(specifier.startsWith(\"@\") ? 2 : 1)\n .join(\"/\");\n for (const key of new Set([\n \".\",\n ...(subpath ? [`./${subpath}`] : []),\n ])) {\n paths.push(\n ...matchingTargets(exports, key).flatMap(({ targets }) => targets),\n );\n }\n }\n for (const target of paths) {\n // Legacy main fields are filesystem paths; URL-based loaders also decode them.\n targets.add(toPosix(relative(root, resolve(dir, target))));\n try {\n const url = new URL(target, pathToFileURL(dir + sep));\n if (url.protocol === \"file:\") {\n targets.add(toPosix(relative(root, fileURLToPath(url))));\n }\n } catch {\n // A literal filename need not be a valid URL.\n }\n }\n }\n return [...targets];\n };\n return { imports, entries };\n}\n","import { realpathSync } from \"node:fs\";\nimport { basename, join, posix, relative } from \"node:path\";\nimport { ts } from \"ts-morph\";\nimport { packageModuleTargets } from \"./package-module-targets.js\";\nimport { readProjectFiles, toPosix } from \"./project-files.js\";\n\nconst CODE_FILE = /\\.[cm]?[jt]sx?$/;\n\nexport type ProjectModuleReference = {\n readonly file: string;\n readonly specifier: string;\n /**\n * Some use of the specifier reads the module whole: a namespace import,\n * `export *`, or any use outside an import or export declaration, such as\n * a dynamic import.\n */\n readonly whole: boolean;\n readonly targets: readonly {\n readonly path: string;\n readonly throughPackage: boolean;\n }[];\n};\n\n/** Static module targets, including every package condition and redirected subpath. */\nexport function projectModuleReferences(\n projectDir: string,\n): readonly ProjectModuleReference[] {\n const root = realpathSync(projectDir);\n const configPath = ts.findConfigFile(root, (file) => ts.sys.fileExists(file));\n const configured =\n configPath === undefined\n ? undefined\n : ts.getParsedCommandLineOfConfigFile(\n configPath,\n {},\n {\n ...ts.sys,\n onUnRecoverableConfigFileDiagnostic: (diagnostic) => {\n throw new Error(\n ts.flattenDiagnosticMessageText(diagnostic.messageText, \"\\n\"),\n );\n },\n },\n );\n const options: ts.CompilerOptions = {\n ...configured?.options,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n resolvePackageJsonImports: true,\n resolvePackageJsonExports: true,\n };\n const resolutions = new Map<\n string,\n {\n file: string | undefined;\n packages: readonly string[];\n }\n >();\n const contents = new Map<string, string | undefined>();\n const packageTargets = packageModuleTargets(root);\n const references: ProjectModuleReference[] = [];\n for (const [sourcePath, bytes] of readProjectFiles(root, CODE_FILE)) {\n const source = ts.createSourceFile(\n sourcePath,\n bytes.toString(\"utf8\"),\n ts.ScriptTarget.Latest,\n true,\n );\n /** Each literal, and whether some use of it reads the module whole. */\n const literals = new Map<string, boolean>();\n const visit = (node: ts.Node) => {\n if (ts.isStringLiteralLike(node)) {\n literals.set(\n node.text,\n (literals.get(node.text) ?? false) || readsWhole(node),\n );\n }\n ts.forEachChild(node, visit);\n };\n visit(source);\n for (const [literal, whole] of literals) {\n const targets = new Map<string, boolean>();\n const requests = new Map<string, { from: string; named: string }>();\n const enqueue = (from: string, literal: string) => {\n const unqualified =\n literal.slice(0, 1) + literal.slice(1).split(/[?#]/, 1)[0];\n for (const named of new Set([literal, unqualified])) {\n requests.set(JSON.stringify([from, named]), { from, named });\n try {\n const decoded = decodeURIComponent(named);\n requests.set(JSON.stringify([from, decoded]), {\n from,\n named: decoded,\n });\n } catch {\n // Preserve literals that are not valid URL encodings as written.\n }\n }\n };\n enqueue(sourcePath, literal);\n for (const { from, named } of requests.values()) {\n const isRelative = /^\\.{1,2}\\//.test(named);\n const protect = (target: string, throughPackage = false) => {\n targets.set(target, throughPackage || targets.get(target) === true);\n };\n const protectPackageTarget = (target: string) => {\n protect(target, true);\n const stem = target.replace(CODE_FILE, \"\");\n for (const extension of [\n \"ts\",\n \"tsx\",\n \"mts\",\n \"cts\",\n \"js\",\n \"jsx\",\n \"mjs\",\n \"cjs\",\n ]) {\n protect(`${stem}.${extension}`, true);\n protect(`${stem}/index.${extension}`, true);\n }\n };\n const mapping = packageTargets.imports(from, named);\n for (const redirect of mapping.redirects) {\n enqueue(redirect.from, redirect.specifier);\n }\n for (const target of mapping.targets) {\n protectPackageTarget(target);\n }\n for (const mode of [\n ts.ModuleKind.ESNext,\n ts.ModuleKind.CommonJS,\n ] as const) {\n const key = JSON.stringify([posix.dirname(from), named, mode]);\n let resolution = resolutions.get(key);\n if (resolution === undefined) {\n const consulted = new Set<string>();\n const resolved = ts.resolveModuleName(\n named,\n join(root, from),\n options,\n {\n ...ts.sys,\n readFile: (file) => {\n if (!contents.has(file))\n contents.set(file, ts.sys.readFile(file));\n const text = contents.get(file);\n if (text !== undefined && basename(file) === \"package.json\")\n consulted.add(file);\n return text;\n },\n },\n undefined,\n undefined,\n mode,\n ).resolvedModule;\n resolution = {\n file: resolved?.resolvedFileName,\n packages: [...consulted],\n };\n resolutions.set(key, resolution);\n }\n if (resolution.file !== undefined) {\n protect(toPosix(relative(root, resolution.file)));\n }\n for (const file of resolution.packages) {\n for (const target of packageTargets.entries(file, named))\n protectPackageTarget(target);\n }\n }\n // Keep complete paths even when the project's resolver cannot load them.\n const paths = isRelative\n ? [posix.join(posix.dirname(from), named)]\n : [...named.matchAll(/subgraphs\\//g)].map((match) =>\n named.slice(match.index),\n );\n for (const path of paths) {\n const target = path.replace(CODE_FILE, \"\");\n protect(`${target}.ts`);\n protect(`${target}/index.ts`);\n }\n }\n if (targets.size > 0) {\n references.push({\n file: sourcePath,\n specifier: literal,\n whole,\n targets: [...targets].map(([path, throughPackage]) => ({\n path,\n throughPackage,\n })),\n });\n }\n }\n }\n return references;\n}\n\n/** Whether `literal` reads its module whole, rather than by named bindings. */\nfunction readsWhole(literal: ts.StringLiteralLike): boolean {\n const parent = literal.parent;\n if (ts.isImportDeclaration(parent)) {\n const bindings = parent.importClause?.namedBindings;\n return bindings !== undefined && ts.isNamespaceImport(bindings);\n }\n if (ts.isExportDeclaration(parent)) {\n return (\n parent.exportClause === undefined ||\n ts.isNamespaceExport(parent.exportClause)\n );\n }\n return true;\n}\n","import { projectModuleReferences } from \"./project-module-references.js\";\n\n/** Readers outside the relative import graph that codegen can rewrite. */\nexport function subgraphReaders(projectDir: string): {\n /** Subgraph files read from outside their directory. */\n readonly imported: ReadonlySet<string>;\n /** Those of them some outside reader reads whole. */\n readonly readWhole: ReadonlySet<string>;\n} {\n const found = new Set<string>();\n const whole = new Set<string>();\n for (const reference of projectModuleReferences(projectDir)) {\n const isRelative = /^\\.{1,2}\\//.test(reference.specifier);\n for (const target of reference.targets) {\n const parts = target.path.split(\"/\");\n const [top, name] = parts;\n if (top !== \"subgraphs\" || parts.length < 2) continue;\n if (\n !target.throughPackage &&\n isRelative &&\n reference.file.startsWith(`subgraphs/${name}/`)\n )\n continue;\n found.add(target.path);\n if (reference.whole) whole.add(target.path);\n }\n }\n return { imported: found, readWhole: whole };\n}\n","import {\n castResolverTypeErrors,\n migrateSubgraph,\n type ProjectTypeCheck,\n type ProjectTypeError,\n projectTypeErrors,\n resolverCallErrors,\n type ResolverTypeError,\n typeErrorMessage,\n sortedSchemaText,\n type SubgraphMigration,\n} from \"@powerhousedao/codegen\";\nimport {\n subgraphDirStyles,\n uncachedDefinitionSourceRevision,\n ViteTypeScriptSourceImportAdapter,\n} from \"@powerhousedao/codegen/utils\";\nimport { projectSubgraphGraphQL } from \"document-model\";\nimport { readSubgraphDefinitions } from \"document-model/tooling\";\nimport type { DocumentNode } from \"graphql\";\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { outdatedDependency } from \"./installed-version.js\";\nimport { definitionChecks } from \"./model/check.js\";\nimport { readProjectDefinitions } from \"./model/project.js\";\nimport {\n assertChangesWritable,\n errorText,\n type FileBackup,\n restoreChanges,\n writeChanges,\n} from \"./project-files.js\";\nimport { subgraphReaders } from \"./subgraph-readers.js\";\n\n/** A module that hangs on a top-level await must not hang `ph migrate`. */\nconst IMPORT_TIMEOUT_MS = 60_000;\nconst SCALARS_ENTRY = \"scalars/index.ts\";\nconst SOURCE_FILE = /\\.(?:[cm]?[jt]sx?|graphql)$/;\n\nexport type MigrateSubgraphsOptions = {\n readonly projectDir: string;\n /** The `subgraphs/` directories to convert; empty converts every schema-first one. */\n readonly dirs: readonly string[];\n readonly dryRun: boolean;\n /** Leave the resolver calls tsc rejects without a cast. */\n readonly strictResolvers?: boolean;\n readonly out?: (text: string) => void;\n};\n\ntype Verification =\n | { readonly ok: true }\n | { readonly ok: false; readonly reason: string };\n\n/**\n * `ph migrate --subgraphs`: converts schema-first subgraphs into code-first\n * ones. Each written directory is loaded as `ph model check` loads it and\n * must serve the schema it served before; otherwise its files are restored.\n * Without named directories, a directory whose `index.ts` holds no class is\n * skipped. Returns the exit code: 0 when every requested subgraph converted\n * or was already code-first, 1 otherwise.\n */\nexport async function migrateSubgraphs(\n options: MigrateSubgraphsOptions,\n): Promise<0 | 1> {\n const out =\n options.out ?? ((text: string) => void process.stdout.write(text));\n const { projectDir, dryRun } = options;\n let outdated = outdatedDependency(projectDir, \"@powerhousedao/reactor-api\");\n /** The composition errors `ph model check` reported before this run converted anything. */\n let composition: ReadonlySet<string> | undefined;\n /** What the project's tsc reported in the subgraphs before this run wrote anything. */\n let typeBaseline: ProjectTypeCheck | undefined;\n const outsideReaders = subgraphReaders(projectDir);\n const styles = new Map(\n subgraphDirStyles(join(projectDir, \"subgraphs\")).map(\n ({ dirName, style }) => [dirName, style] as const,\n ),\n );\n let failed = false;\n let schemaFirst = 0;\n const named = options.dirs.length > 0;\n const requested = named ? options.dirs : [...styles.keys()];\n const converted: string[] = [];\n const importer = new ViteTypeScriptSourceImportAdapter();\n const revision = uncachedDefinitionSourceRevision();\n try {\n for (const dirName of requested) {\n const label = `subgraphs/${dirName}`;\n const style = styles.get(dirName);\n if (style === undefined) {\n out(\n `${label}: not found. Name a directory of subgraphs/ that has an index.ts.\\n`,\n );\n failed = true;\n continue;\n }\n if (style === \"code-first\") {\n out(`${label}: already code-first\\n`);\n continue;\n }\n const originals = readDirectory(projectDir, dirName);\n let written: FileBackup | undefined;\n try {\n const migration = await migrateSubgraph({\n dirName,\n files: new Map(\n [...originals].map(([path, bytes]) => [\n path,\n bytes.toString(\"utf8\"),\n ]),\n ),\n importedFromOutside: outsideReaders.imported,\n readWholeFromOutside: outsideReaders.readWhole,\n });\n if (migration.kind === \"no-subgraph-class\" && !named) {\n out(`${label}: no subgraph class, skipped\\n`);\n continue;\n }\n schemaFirst++;\n if (migration.kind !== \"converted\") {\n out(refusalText(label, migration));\n failed = true;\n continue;\n }\n if (dryRun) {\n assertChangesWritable(projectDir, migration.files);\n out(`${label}: would convert ${migration.className} to code-first\\n`);\n for (const file of migration.files) out(unifiedDiff(file));\n continue;\n }\n if (outdated !== undefined) {\n out(`${label}: not converted. ${outdated}\\n`);\n outdated = \"@powerhousedao/reactor-api is too old, as above.\";\n failed = true;\n continue;\n }\n // What the host already refuses, read before this run writes anything.\n composition ??= await compositionErrors(projectDir, new Set());\n typeBaseline ??= projectTypeErrors(\n projectDir,\n requested.map((name) => `subgraphs/${name}`),\n [],\n );\n try {\n written = writeChanges(projectDir, migration.files);\n } catch (error) {\n out(\n `${label}: not converted; its files are restored. Writing them failed: ${errorText(error)}\\n`,\n );\n failed = true;\n continue;\n }\n let verification = await verify(\n projectDir,\n migration,\n importer,\n revision,\n );\n if (verification.ok) {\n const added = await compositionErrors(projectDir, composition);\n if (added.size > 0) {\n verification = {\n ok: false,\n reason: `The host would not serve the package's code-first subgraphs together:\\n${[...added].map((error) => ` ${error}`).join(\"\\n\")}\\nRename the conflicting types in one of the subgraphs, then migrate again.`,\n };\n }\n }\n if (!verification.ok) {\n restoreChanges(projectDir, written);\n out(\n `${label}: not converted; its files are restored. ${verification.reason}\\n`,\n );\n failed = true;\n continue;\n }\n converted.push(dirName);\n out(\n `${label}: converted ${migration.className} to code-first; it serves the same schema\\n`,\n );\n for (const note of migration.notes) out(`Note: ${note}\\n`);\n if (migration.sdlFile.endsWith(\"/schema.graphql\")) {\n out(\n `${migration.sdlFile} is no longer used; the schema is now in ${label}/schema.ts. It was kept, and you can delete it.\\n`,\n );\n }\n } catch (error) {\n if (written !== undefined) restoreChanges(projectDir, written);\n out(\n `${label}: not converted; its files are ${written === undefined ? \"unchanged\" : \"restored\"}. The conversion failed unexpectedly: ${errorText(error)}\\n`,\n );\n failed = true;\n }\n }\n } finally {\n await importer.disposeRevision();\n }\n if (converted.length > 0) {\n out(\n await typeReport(\n projectDir,\n converted,\n options.strictResolvers ?? false,\n typeBaseline,\n ),\n );\n }\n if (!named && schemaFirst === 0) {\n out(\"No schema-first subgraphs to convert.\\n\");\n }\n return failed ? 1 : 0;\n}\n\n/**\n * The converted resolvers TypeScript rejects. The schema-first resolver map\n * never checked a resolver's types against the schema; each converted entry\n * calls its resolver with the schema's types, so a disagreement is now a\n * type error. Unless `strict`, each rejected call is cast where it fails, so\n * it runs as before and the project compiles. Any other error the\n * conversion added to the subgraphs, against `baseline`, is reported too.\n */\nasync function typeReport(\n projectDir: string,\n converted: readonly string[],\n strict: boolean,\n baseline: ProjectTypeCheck | undefined,\n): Promise<string> {\n const dirs = converted.map((dirName) => `subgraphs/${dirName}`);\n const indexPaths = dirs.map((dir) => `${dir}/index.ts`);\n const check = () => projectTypeErrors(projectDir, dirs, indexPaths);\n const first = check();\n if (first.kind === \"untyped\") return \"\";\n if (first.kind === \"skipped\") {\n return `Note: the converted resolvers were not type-checked: ${first.reason}.\\n`;\n }\n const list = (shown: readonly ResolverTypeError[]) =>\n shown\n .map(\n ({ file, line, coordinate, message }) =>\n ` ${file}:${line} ${coordinate}: ${message}\\n`,\n )\n .join(\"\");\n const calls = resolverCallErrors(projectDir, indexPaths, first.errors);\n let report = \"\";\n let final = first;\n if (calls.length > 0) {\n const count = `${calls.length === 1 ? \"1 resolver call disagrees\" : `${calls.length} resolver calls disagree`} with the schema the subgraph serves`;\n if (strict) {\n report += `Note: ${count}, so TypeScript rejects ${calls.length === 1 ? \"it\" : \"them\"}. The schema-first map never checked them; fix each resolver's types:\\n${list(calls)}`;\n } else {\n writeChanges(projectDir, await castResolverTypeErrors(projectDir, calls));\n let after = check();\n if (\n after.kind === \"checked\" &&\n calls.some(({ message }) =>\n /^Expected (?:\\d+-)?\\d+ arguments?, but got \\d+\\./.test(message),\n )\n ) {\n const exposed = resolverCallErrors(\n projectDir,\n indexPaths,\n after.errors,\n );\n if (exposed.length > 0) {\n writeChanges(\n projectDir,\n await castResolverTypeErrors(projectDir, exposed),\n );\n calls.push(...exposed);\n after = check();\n }\n }\n if (after.kind === \"checked\") final = after;\n const left = resolverCallErrors(projectDir, indexPaths, final.errors);\n report += `Note: ${count}. The schema-first map never checked them; each call is cast where TypeScript rejects it, under a \"ph migrate:\" comment, so it runs as before and the project compiles. Fix each resolver's types, then remove its cast:\\n${list(calls)}`;\n if (left.length > 0) {\n report += `Note: ${left.length === 1 ? \"1 resolver call is\" : `${left.length} resolver calls are`} still rejected after the casts; fix ${left.length === 1 ? \"it\" : \"them\"} by hand:\\n${list(left)}`;\n }\n }\n }\n // Errors besides the resolver calls that were not there before.\n if (baseline?.kind === \"checked\") {\n const key = (error: ProjectTypeError) =>\n `${error.file.split(\"/\").slice(0, 2).join(\"/\")}|${error.lines.join(\"|\")}`;\n const before = new Map<string, number>();\n for (const error of baseline.errors) {\n before.set(key(error), (before.get(key(error)) ?? 0) + 1);\n }\n const inSchema = new Set(\n resolverCallErrors(projectDir, indexPaths, final.errors).map(\n ({ file, line, column }) => `${file}:${line}:${column}`,\n ),\n );\n const introduced = final.errors.filter((error) => {\n if (inSchema.has(`${error.file}:${error.line}:${error.column}`)) {\n return false;\n }\n const remaining = before.get(key(error)) ?? 0;\n if (remaining > 0) {\n before.set(key(error), remaining - 1);\n return false;\n }\n return true;\n });\n if (introduced.length > 0) {\n report += `Note: the conversion added ${introduced.length === 1 ? \"1 type error\" : `${introduced.length} type errors`} besides the resolver calls. That is a bug in ph migrate; please report it, and fix ${introduced.length === 1 ? \"it\" : \"them\"} by hand:\\n${introduced\n .map(\n (error) =>\n ` ${error.file}:${error.line}: ${typeErrorMessage(error)}\\n`,\n )\n .join(\"\")}`;\n }\n }\n return report;\n}\n\n/** The directory's files and `scalars/index.ts`, by project-relative path. */\nfunction readDirectory(\n projectDir: string,\n dirName: string,\n): ReadonlyMap<string, Buffer> {\n const files = new Map<string, Buffer>();\n const dir = join(projectDir, \"subgraphs\", dirName);\n for (const entry of readdirSync(dir, {\n recursive: true,\n withFileTypes: true,\n })) {\n if (!entry.isFile() || !SOURCE_FILE.test(entry.name)) continue;\n const path = join(entry.parentPath, entry.name);\n files.set(\n path.slice(projectDir.length + 1).replaceAll(\"\\\\\", \"/\"),\n readFileSync(path),\n );\n }\n const scalars = join(projectDir, SCALARS_ENTRY);\n if (existsSync(scalars)) files.set(SCALARS_ENTRY, readFileSync(scalars));\n return files;\n}\n\nasync function withTimeout<T>(work: Promise<T>, timeoutMs: number): Promise<T> {\n let timer: NodeJS.Timeout | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(\n () =>\n reject(\n new Error(\n `it did not finish loading within ${timeoutMs / 1000} seconds`,\n ),\n ),\n timeoutMs,\n );\n timer.unref();\n });\n try {\n return await Promise.race([work, timeout]);\n } finally {\n clearTimeout(timer);\n }\n}\n\n/**\n * The subgraph composition errors `ph model check` reports for the project,\n * leaving out those in `known`. Converted subgraphs are composed with each\n * other: a type two of them declare differently keeps one out of the host.\n */\nasync function compositionErrors(\n projectDir: string,\n known: ReadonlySet<string>,\n): Promise<Set<string>> {\n const report = await readProjectDefinitions(projectDir, (project, modules) =>\n definitionChecks.edit(project, modules),\n );\n return new Set(\n report.diagnostics\n .filter(\n ({ severity, phase }) =>\n severity === \"error\" && phase === \"composition\",\n )\n .map(({ message }) => message)\n .filter((message) => !known.has(message)),\n );\n}\n\n/** Loads the written class without constructing it and compares the schema it serves. */\nasync function verify(\n projectDir: string,\n migration: Extract<SubgraphMigration, { kind: \"converted\" }>,\n importer: ViteTypeScriptSourceImportAdapter,\n revision: ReturnType<typeof uncachedDefinitionSourceRevision>,\n): Promise<Verification> {\n const specifier = `./subgraphs/${migration.dirName}/index.ts` as const;\n let namespace: Readonly<Record<string, unknown>>;\n try {\n namespace = await withTimeout(\n importer.importModule({\n packageRoot: projectDir,\n specifier,\n packageRevision: revision,\n }),\n IMPORT_TIMEOUT_MS,\n );\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n ok: false,\n reason: `The converted module does not load: ${message.replaceAll(projectDir, \".\")}`,\n };\n }\n const { subgraphs, diagnostics } = readSubgraphDefinitions(namespace, {\n specifier,\n });\n const errors = diagnostics.filter(({ severity }) => severity === \"error\");\n if (errors.length > 0) {\n return {\n ok: false,\n reason: `The converted subgraph does not compile:\\n${errors.map(({ message, repair }) => ` ${message} ${repair}`).join(\"\\n\")}`,\n };\n }\n const subgraph = subgraphs.find(\n ({ name }) => name === migration.subgraphName,\n );\n if (subgraph === undefined) {\n return {\n ok: false,\n reason: `${specifier} exports no code-first subgraph named ${migration.subgraphName}.`,\n };\n }\n const served = sortedSchemaText(\n projectSubgraphGraphQL(subgraph.definition) as unknown as DocumentNode,\n );\n if (served === migration.sdl) return { ok: true };\n return {\n ok: false,\n reason: `The converted subgraph serves a different schema:\\n${unifiedDiff({\n path: \"schema\",\n before: migration.sdl,\n after: served,\n })}`,\n };\n}\n\nfunction refusalText(\n label: string,\n migration: Extract<\n SubgraphMigration,\n { kind: \"refused\" | \"no-subgraph-class\" }\n >,\n): string {\n return `${label}: not converted\\n${migration.refusals\n .map(\n ({ file, line, reason, repair }) =>\n ` ${file}:${line}: ${reason}\\n ${repair}\\n`,\n )\n .join(\"\")}`;\n}\n\ntype Line = { readonly kind: \" \" | \"-\" | \"+\"; readonly text: string };\n\n/** The line edits from `before` to `after`, by longest common subsequence. */\nfunction lineEdits(\n before: readonly string[],\n after: readonly string[],\n): Line[] {\n const common: number[][] = Array.from({ length: before.length + 1 }, () =>\n new Array<number>(after.length + 1).fill(0),\n );\n for (let i = before.length - 1; i >= 0; i--) {\n for (let j = after.length - 1; j >= 0; j--) {\n common[i][j] =\n before[i] === after[j]\n ? common[i + 1][j + 1] + 1\n : Math.max(common[i + 1][j], common[i][j + 1]);\n }\n }\n const lines: Line[] = [];\n let i = 0;\n let j = 0;\n while (i < before.length || j < after.length) {\n if (i < before.length && j < after.length && before[i] === after[j]) {\n lines.push({ kind: \" \", text: before[i++] });\n j++;\n } else if (\n i < before.length &&\n (j === after.length || common[i + 1][j] >= common[i][j + 1])\n ) {\n lines.push({ kind: \"-\", text: before[i++] });\n } else {\n lines.push({ kind: \"+\", text: after[j++] });\n }\n }\n return lines;\n}\n\nconst CONTEXT = 3;\n\n/** A unified diff of one file; a new file diffs against /dev/null. */\nexport function unifiedDiff(file: {\n readonly path: string;\n readonly before: string | null;\n readonly after: string | null;\n}): string {\n const split = (text: string) =>\n text === \"\" ? [] : text.replace(/\\n$/, \"\").split(\"\\n\");\n const lines = lineEdits(split(file.before ?? \"\"), split(file.after ?? \"\"));\n const changed = lines.flatMap((line, index) =>\n line.kind === \" \" ? [] : [index],\n );\n if (changed.length === 0) return \"\";\n const hunks: [number, number][] = [];\n for (const index of changed) {\n const start = Math.max(0, index - CONTEXT);\n const end = Math.min(lines.length, index + CONTEXT + 1);\n const last = hunks.at(-1);\n if (last !== undefined && start <= last[1]) last[1] = end;\n else hunks.push([start, end]);\n }\n const header = `--- ${file.before === null ? \"/dev/null\" : `a/${file.path}`}\\n+++ ${file.after === null ? \"/dev/null\" : `b/${file.path}`}\\n`;\n return (\n header +\n hunks\n .map(([start, end]) => {\n const lineBefore = (kind: Line[\"kind\"]) =>\n lines.slice(0, start).filter((line) => line.kind !== kind).length;\n const slice = lines.slice(start, end);\n const count = (kind: Line[\"kind\"]) =>\n slice.filter((line) => line.kind !== kind).length;\n const oldCount = count(\"+\");\n const newCount = count(\"-\");\n const oldStart = oldCount === 0 ? lineBefore(\"+\") : lineBefore(\"+\") + 1;\n const newStart = newCount === 0 ? lineBefore(\"-\") : lineBefore(\"-\") + 1;\n return `@@ -${oldStart},${oldCount} +${newStart},${newCount} @@\\n${slice\n .map((line) => `${line.kind}${line.text}`)\n .join(\"\\n\")}\\n`;\n })\n .join(\"\")\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAMA,SAAS,iBACP,YACA,aACoB;CACpB,KAAK,IAAI,MAAM,aAAc,MAAM,QAAQ,GAAG,GAAG;EAC/C,MAAM,WAAW,KAAK,KAAK,gBAAgB,aAAa,cAAc;EACtE,IAAI,WAAW,QAAQ,GAAG;GACxB,MAAM,EAAE,YAAY,KAAK,MAAM,aAAa,UAAU,MAAM,CAAC;GAG7D,OAAO,OAAO,YAAY,WAAW,UAAU,KAAA;EACjD;EACA,IAAI,QAAQ,GAAG,MAAM,KAAK,OAAO,KAAA;CACnC;AACF;;;;;;AAOA,SAAg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,MAAM,QAAQ,SAAS,KAAK,SAAS,IAAI,CAAC,CAAC;EAC7C,MAAM,WAAW,MAAM,GAAG;EAC1B,MAAM,WAAW,MAAM,GAAG;EAG1B,OAAO,OAFU,aAAa,IAAI,WAAW,GAAG,IAAI,WAAW,GAAG,IAAI,EAE/C,GAAG,SAAS,IADlB,aAAa,IAAI,WAAW,GAAG,IAAI,WAAW,GAAG,IAAI,EACtB,GAAG,SAAS,OAAO,MAChE,KAAK,SAAS,GAAG,KAAK,OAAO,KAAK,MAAM,CAAC,CACzC,KAAK,IAAI,EAAE;CAChB,CAAC,CAAC,CACD,KAAK,EAAE;AAEd","debug_id":"7ec551a1-d98b-58d5-ad62-cf4f906f2f8a"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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]="72241c79-c8a9-5678-bb08-4b16f4fb3810")}catch(e){}}();
|
|
3
|
+
import { existsSync, statSync } from "node:fs";
|
|
4
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
5
|
+
//#region src/utils/module-dir.ts
|
|
6
|
+
/** The directory in `<modulesDir>/` that `--dir` names, by name or by a path to it or a file in it */
|
|
7
|
+
function resolveModuleDirName(projectDir, modulesDir, dir, example) {
|
|
8
|
+
const modulesPath = join(projectDir, modulesDir);
|
|
9
|
+
const moduleDir = [resolve(projectDir, dir), join(modulesPath, dir)].filter((candidate) => existsSync(candidate)).map((candidate) => statSync(candidate).isDirectory() ? candidate : dirname(candidate)).find((candidate) => dirname(candidate) === modulesPath);
|
|
10
|
+
if (!moduleDir) throw new Error(`No directory in ${modulesDir}/ for --dir "${dir}": expected its name ("${example}") or its path ("${modulesDir}/${example}").`);
|
|
11
|
+
return basename(moduleDir);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { resolveModuleDirName as t };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=module-dir-1avCXsBi.mjs.map
|
|
17
|
+
//# debugId=72241c79-c8a9-5678-bb08-4b16f4fb3810
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-dir-1avCXsBi.mjs","sources":["../src/utils/module-dir.ts"],"sourcesContent":["import { existsSync, statSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\n\n/** The directory in `<modulesDir>/` that `--dir` names, by name or by a path to it or a file in it */\nexport function resolveModuleDirName(\n projectDir: string,\n /** Package-relative, such as \"editors\" or the configured documentModelsDir. */\n modulesDir: string,\n dir: string,\n example: string,\n) {\n const modulesPath = join(projectDir, modulesDir);\n const moduleDir = [resolve(projectDir, dir), join(modulesPath, dir)]\n .filter((candidate) => existsSync(candidate))\n .map((candidate) =>\n statSync(candidate).isDirectory() ? candidate : dirname(candidate),\n )\n .find((candidate) => dirname(candidate) === modulesPath);\n if (!moduleDir) {\n throw new Error(\n `No directory in ${modulesDir}/ for --dir \"${dir}\": expected its name (\"${example}\") or its path (\"${modulesDir}/${example}\").`,\n );\n }\n return basename(moduleDir);\n}\n"],"names":[],"mappings":";;;;;;AAIA,SAAgB,qBACd,YAEA,YACA,KACA,SACA;CACA,MAAM,cAAc,KAAK,YAAY,UAAU;CAC/C,MAAM,YAAY,CAAC,QAAQ,YAAY,GAAG,GAAG,KAAK,aAAa,GAAG,CAAC,CAAC,CACjE,QAAQ,cAAc,WAAW,SAAS,CAAC,CAAC,CAC5C,KAAK,cACJ,SAAS,SAAS,CAAC,CAAC,YAAY,IAAI,YAAY,QAAQ,SAAS,CACnE,CAAC,CACA,MAAM,cAAc,QAAQ,SAAS,MAAM,WAAW;CACzD,IAAI,CAAC,WACH,MAAM,IAAI,MACR,mBAAmB,WAAW,eAAe,IAAI,yBAAyB,QAAQ,mBAAmB,WAAW,GAAG,QAAQ,IAC7H;CAEF,OAAO,SAAS,SAAS;AAC3B","debug_id":"72241c79-c8a9-5678-bb08-4b16f4fb3810"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
//#region src/services/release/npm-args.ts
|
|
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]="4d229bd5-840c-5aab-b381-23f1227969be")}catch(e){}}();
|
|
4
|
+
const LOG_LEVELS = /* @__PURE__ */ new Set([
|
|
5
|
+
"silent",
|
|
6
|
+
"error",
|
|
7
|
+
"warn",
|
|
8
|
+
"notice",
|
|
9
|
+
"http",
|
|
10
|
+
"info",
|
|
11
|
+
"verbose",
|
|
12
|
+
"silly"
|
|
13
|
+
]);
|
|
14
|
+
const FLAGS = /* @__PURE__ */ new Set([
|
|
15
|
+
"--dry-run",
|
|
16
|
+
"--provenance",
|
|
17
|
+
"--json"
|
|
18
|
+
]);
|
|
19
|
+
const VALUED = /* @__PURE__ */ new Map([
|
|
20
|
+
["--tag", () => true],
|
|
21
|
+
["--access", (value) => value === "public" || value === "restricted"],
|
|
22
|
+
["--otp", () => true],
|
|
23
|
+
["--loglevel", (value) => LOG_LEVELS.has(value)]
|
|
24
|
+
]);
|
|
25
|
+
/** The npm arguments a publish that requires an approval forwards. */
|
|
26
|
+
const ALLOWED_NPM_ARGUMENTS = "--tag <tag>, --access <public|restricted>, --otp <code>, --dry-run, --provenance, --json, --loglevel <level>";
|
|
27
|
+
/**
|
|
28
|
+
* The forwarded npm arguments outside `ALLOWED_NPM_ARGUMENTS`, as given. A
|
|
29
|
+
* value option takes the next argument as its value only when it does not
|
|
30
|
+
* start with `-`; one left without a value is refused. Any other spelling,
|
|
31
|
+
* abbreviation or alias npm would accept is refused too, since it could
|
|
32
|
+
* select another package to publish.
|
|
33
|
+
*/
|
|
34
|
+
function refusedNpmArguments(args) {
|
|
35
|
+
const refused = [];
|
|
36
|
+
for (let index = 0; index < args.length; index++) {
|
|
37
|
+
const arg = args[index];
|
|
38
|
+
if (FLAGS.has(arg)) continue;
|
|
39
|
+
const equals = arg.indexOf("=");
|
|
40
|
+
const accepts = VALUED.get(equals === -1 ? arg : arg.slice(0, equals));
|
|
41
|
+
if (accepts === void 0) refused.push(arg);
|
|
42
|
+
else if (equals !== -1) {
|
|
43
|
+
const value = arg.slice(equals + 1);
|
|
44
|
+
if (value === "" || !accepts(value)) refused.push(arg);
|
|
45
|
+
} else {
|
|
46
|
+
const value = args[index + 1];
|
|
47
|
+
if (value === void 0 || value.startsWith("-")) refused.push(arg);
|
|
48
|
+
else {
|
|
49
|
+
index++;
|
|
50
|
+
if (!accepts(value)) refused.push(`${arg} ${value}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return refused;
|
|
55
|
+
}
|
|
56
|
+
const TARGET_SELECTING = /* @__PURE__ */ new Set([
|
|
57
|
+
"workspace",
|
|
58
|
+
"workspaces",
|
|
59
|
+
"include_workspace_root"
|
|
60
|
+
]);
|
|
61
|
+
/**
|
|
62
|
+
* The environment variables that set npm configuration selecting another
|
|
63
|
+
* package to publish, sorted. npm reads `npm_config_*` in any case and with
|
|
64
|
+
* `-` or `_`. `npm_config_prefix` is not one: npm takes the package
|
|
65
|
+
* directory from a prefix given on its command line only, and `npm run`
|
|
66
|
+
* sets it to the global prefix.
|
|
67
|
+
*/
|
|
68
|
+
function targetSelectingNpmEnvironment(env) {
|
|
69
|
+
return Object.keys(env).filter((name) => {
|
|
70
|
+
const key = name.toLowerCase().replaceAll("-", "_");
|
|
71
|
+
return key.startsWith("npm_config_") && TARGET_SELECTING.has(key.slice(11)) && Boolean(env[name]);
|
|
72
|
+
}).sort();
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { ALLOWED_NPM_ARGUMENTS, refusedNpmArguments, targetSelectingNpmEnvironment };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=npm-args-g1Tgel4s.mjs.map
|
|
78
|
+
//# debugId=4d229bd5-840c-5aab-b381-23f1227969be
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-args-g1Tgel4s.mjs","sources":["../src/services/release/npm-args.ts"],"sourcesContent":["const LOG_LEVELS = new Set([\n \"silent\",\n \"error\",\n \"warn\",\n \"notice\",\n \"http\",\n \"info\",\n \"verbose\",\n \"silly\",\n]);\n\nconst FLAGS = new Set([\"--dry-run\", \"--provenance\", \"--json\"]);\n\n// npm publish options allowed with a value, and the values each accepts.\nconst VALUED = new Map<string, (value: string) => boolean>([\n [\"--tag\", () => true],\n [\"--access\", (value) => value === \"public\" || value === \"restricted\"],\n [\"--otp\", () => true],\n [\"--loglevel\", (value) => LOG_LEVELS.has(value)],\n]);\n\n/** The npm arguments a publish that requires an approval forwards. */\nexport const ALLOWED_NPM_ARGUMENTS =\n \"--tag <tag>, --access <public|restricted>, --otp <code>, --dry-run, --provenance, --json, --loglevel <level>\";\n\n/**\n * The forwarded npm arguments outside `ALLOWED_NPM_ARGUMENTS`, as given. A\n * value option takes the next argument as its value only when it does not\n * start with `-`; one left without a value is refused. Any other spelling,\n * abbreviation or alias npm would accept is refused too, since it could\n * select another package to publish.\n */\nexport function refusedNpmArguments(args: readonly string[]): string[] {\n const refused: string[] = [];\n for (let index = 0; index < args.length; index++) {\n const arg = args[index];\n if (FLAGS.has(arg)) continue;\n const equals = arg.indexOf(\"=\");\n const accepts = VALUED.get(equals === -1 ? arg : arg.slice(0, equals));\n if (accepts === undefined) {\n refused.push(arg);\n } else if (equals !== -1) {\n const value = arg.slice(equals + 1);\n if (value === \"\" || !accepts(value)) refused.push(arg);\n } else {\n const value = args[index + 1] as string | undefined;\n if (value === undefined || value.startsWith(\"-\")) {\n refused.push(arg);\n } else {\n index++;\n if (!accepts(value)) refused.push(`${arg} ${value}`);\n }\n }\n }\n return refused;\n}\n\n// npm configuration that makes npm pack or publish act on a workspace rather\n// than the package in its directory.\nconst TARGET_SELECTING = new Set([\n \"workspace\",\n \"workspaces\",\n \"include_workspace_root\",\n]);\n\n/**\n * The environment variables that set npm configuration selecting another\n * package to publish, sorted. npm reads `npm_config_*` in any case and with\n * `-` or `_`. `npm_config_prefix` is not one: npm takes the package\n * directory from a prefix given on its command line only, and `npm run`\n * sets it to the global prefix.\n */\nexport function targetSelectingNpmEnvironment(\n env: Readonly<Record<string, string | undefined>>,\n): string[] {\n return Object.keys(env)\n .filter((name) => {\n const key = name.toLowerCase().replaceAll(\"-\", \"_\");\n return (\n key.startsWith(\"npm_config_\") &&\n TARGET_SELECTING.has(key.slice(\"npm_config_\".length)) &&\n Boolean(env[name])\n );\n })\n .sort();\n}\n"],"names":[],"mappings":";;;AAAA,MAAM,6BAAa,IAAI,IAAI;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,wBAAQ,IAAI,IAAI;CAAC;CAAa;CAAgB;AAAQ,CAAC;AAG7D,MAAM,yBAAS,IAAI,IAAwC;CACzD,CAAC,eAAe,IAAI;CACpB,CAAC,aAAa,UAAU,UAAU,YAAY,UAAU,YAAY;CACpE,CAAC,eAAe,IAAI;CACpB,CAAC,eAAe,UAAU,WAAW,IAAI,KAAK,CAAC;AACjD,CAAC;;AAGD,MAAa,wBACX;;;;;;;;AASF,SAAgB,oBAAoB,MAAmC;CACrE,MAAM,UAAoB,CAAC;CAC3B,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;EAChD,MAAM,MAAM,KAAK;EACjB,IAAI,MAAM,IAAI,GAAG,GAAG;EACpB,MAAM,SAAS,IAAI,QAAQ,GAAG;EAC9B,MAAM,UAAU,OAAO,IAAI,WAAW,KAAK,MAAM,IAAI,MAAM,GAAG,MAAM,CAAC;EACrE,IAAI,YAAY,KAAA,GACd,QAAQ,KAAK,GAAG;OACX,IAAI,WAAW,IAAI;GACxB,MAAM,QAAQ,IAAI,MAAM,SAAS,CAAC;GAClC,IAAI,UAAU,MAAM,CAAC,QAAQ,KAAK,GAAG,QAAQ,KAAK,GAAG;EACvD,OAAO;GACL,MAAM,QAAQ,KAAK,QAAQ;GAC3B,IAAI,UAAU,KAAA,KAAa,MAAM,WAAW,GAAG,GAC7C,QAAQ,KAAK,GAAG;QACX;IACL;IACA,IAAI,CAAC,QAAQ,KAAK,GAAG,QAAQ,KAAK,GAAG,IAAI,GAAG,OAAO;GACrD;EACF;CACF;CACA,OAAO;AACT;AAIA,MAAM,mCAAmB,IAAI,IAAI;CAC/B;CACA;CACA;AACF,CAAC;;;;;;;;AASD,SAAgB,8BACd,KACU;CACV,OAAO,OAAO,KAAK,GAAG,CAAC,CACpB,QAAQ,SAAS;EAChB,MAAM,MAAM,KAAK,YAAY,CAAC,CAAC,WAAW,KAAK,GAAG;EAClD,OACE,IAAI,WAAW,aAAa,KAC5B,iBAAiB,IAAI,IAAI,MAAM,EAAoB,CAAC,KACpD,QAAQ,IAAI,KAAK;CAErB,CAAC,CAAC,CACD,KAAK;AACV","debug_id":"4d229bd5-840c-5aab-b381-23f1227969be"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { n as checkOfferedRoutesImports } from "./offered-routes-imports-CalXK9dh.mjs";
|
|
2
|
+
export { checkOfferedRoutesImports };
|
|
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]="98fd0401-72de-5587-ae2a-f8145c1170c8")}catch(e){}}();
|
|
4
|
+
//# debugId=98fd0401-72de-5587-ae2a-f8145c1170c8
|
|
@@ -0,0 +1,96 @@
|
|
|
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]="a3aeccc2-72fd-5986-9fd9-071f527658da")}catch(e){}}();
|
|
3
|
+
import { n as OFFERED_ROUTES_MODULE, t as HOST_ROUTES_DIR } from "./sync-connect-routes-t0Slg-P6.mjs";
|
|
4
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
//#region src/utils/offered-routes-imports.ts
|
|
7
|
+
const CONNECT_IMPORT = /^@powerhousedao\/connect(\/|$)/;
|
|
8
|
+
const GUARD = "ph-offered-routes-imports";
|
|
9
|
+
const CONNECT_IMPORT_HINT = "Routes a package offers other Connects import @powerhousedao/connect-core instead (ContentOutlet, ModalDialog, useConnectChrome, useDriveRouteData, useNavRoutes and useSidebarMode from @powerhousedao/connect-core/router, SidebarItem from @powerhousedao/design-system/connect); only its own host's _app.tsx and overrides may use @powerhousedao/connect.";
|
|
10
|
+
function reachableFrom(graph, entry) {
|
|
11
|
+
const reached = /* @__PURE__ */ new Set();
|
|
12
|
+
const pending = [entry];
|
|
13
|
+
for (let id = pending.pop(); id !== void 0; id = pending.pop()) {
|
|
14
|
+
if (reached.has(id)) continue;
|
|
15
|
+
reached.add(id);
|
|
16
|
+
const info = graph.getModuleInfo(id);
|
|
17
|
+
if (info) pending.push(...info.importedIds, ...info.dynamicallyImportedIds);
|
|
18
|
+
}
|
|
19
|
+
return reached;
|
|
20
|
+
}
|
|
21
|
+
/** Fails the build on an import of Connect that the offered routes reach, as
|
|
22
|
+
* other Connects don't share Connect with the package; warns on one from the
|
|
23
|
+
* rest of the package, which bundles a copy of the Connect modules it uses. */
|
|
24
|
+
function noConnectImports(routesEntry, routesDir) {
|
|
25
|
+
const imports = /* @__PURE__ */ new Map();
|
|
26
|
+
const slash = (path) => path.replaceAll("\\", "/");
|
|
27
|
+
const isRoute = (id) => slash(id) === slash(routesEntry) || slash(id).startsWith(`${slash(routesDir)}/`);
|
|
28
|
+
return {
|
|
29
|
+
name: GUARD,
|
|
30
|
+
resolveId(source, importer) {
|
|
31
|
+
if (!importer || !CONNECT_IMPORT.test(source)) return null;
|
|
32
|
+
if (isRoute(importer)) throw new Error(`${importer} imports "${source}". ${CONNECT_IMPORT_HINT}`);
|
|
33
|
+
const sources = imports.get(importer) ?? /* @__PURE__ */ new Set();
|
|
34
|
+
imports.set(importer, sources.add(source));
|
|
35
|
+
return null;
|
|
36
|
+
},
|
|
37
|
+
buildEnd(error) {
|
|
38
|
+
if (error || !imports.size) return;
|
|
39
|
+
const entry = this.getModuleInfo(routesEntry) ? routesEntry : slash(routesEntry);
|
|
40
|
+
const reached = reachableFrom(this, entry);
|
|
41
|
+
const described = ([importer, sources]) => `${importer} imports ${[...sources].map((s) => `"${s}"`).join(", ")}`;
|
|
42
|
+
const offered = [...imports].filter(([id]) => reached.has(id));
|
|
43
|
+
if (offered.length) this.error(`${offered.map(described).join("\n")}\n${CONNECT_IMPORT_HINT}`);
|
|
44
|
+
console.warn(`⚠ ${[...imports].map(described).join("\n")}\nConnect isn't shared with the packages it loads, so the build bundles a copy of these modules, apart from the app's state. Import @powerhousedao/connect-core instead; a later version fails the build.`);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const IN_NODE_MODULES = /[\\/]node_modules[\\/]/;
|
|
49
|
+
const SCRIPT = /\.[cm]?[jt]sx?$/;
|
|
50
|
+
const projectModulesOnly = {
|
|
51
|
+
name: "ph-offered-routes-project-modules",
|
|
52
|
+
async resolveId(source, importer, options) {
|
|
53
|
+
if (!importer) return null;
|
|
54
|
+
const resolved = await this.resolve(source, importer, {
|
|
55
|
+
...options,
|
|
56
|
+
skipSelf: true
|
|
57
|
+
});
|
|
58
|
+
if (!resolved || resolved.external) return {
|
|
59
|
+
id: source,
|
|
60
|
+
external: true
|
|
61
|
+
};
|
|
62
|
+
if (IN_NODE_MODULES.test(resolved.id) || !SCRIPT.test(resolved.id)) return {
|
|
63
|
+
id: resolved.id,
|
|
64
|
+
external: true
|
|
65
|
+
};
|
|
66
|
+
return resolved;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
/** Fails as `ph build` does when the routes the package offers reach an
|
|
70
|
+
* import of Connect; bundles the project's modules in memory, writing nothing. */
|
|
71
|
+
async function checkOfferedRoutesImports(projectDir) {
|
|
72
|
+
const projectRoot = realpathSync(projectDir);
|
|
73
|
+
const entry = join(projectRoot, OFFERED_ROUTES_MODULE);
|
|
74
|
+
if (!existsSync(entry)) return;
|
|
75
|
+
const { rolldown } = await import("rolldown");
|
|
76
|
+
const bundle = await rolldown({
|
|
77
|
+
input: entry,
|
|
78
|
+
cwd: projectRoot,
|
|
79
|
+
tsconfig: true,
|
|
80
|
+
logLevel: "silent",
|
|
81
|
+
plugins: [noConnectImports(entry, join(projectRoot, HOST_ROUTES_DIR)), projectModulesOnly]
|
|
82
|
+
});
|
|
83
|
+
try {
|
|
84
|
+
await bundle.generate({});
|
|
85
|
+
} catch (error) {
|
|
86
|
+
const found = (error.errors ?? []).filter((e) => e.plugin === GUARD);
|
|
87
|
+
if (found.length) throw new Error(found.map((e) => e.message).join("\n"), { cause: error });
|
|
88
|
+
} finally {
|
|
89
|
+
await bundle.close();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
export { checkOfferedRoutesImports as n, noConnectImports as r, CONNECT_IMPORT_HINT as t };
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=offered-routes-imports-CalXK9dh.mjs.map
|
|
96
|
+
//# debugId=a3aeccc2-72fd-5986-9fd9-071f527658da
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offered-routes-imports-CalXK9dh.mjs","sources":["../src/utils/offered-routes-imports.ts"],"sourcesContent":["import { existsSync, realpathSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { Plugin } from \"rolldown\";\nimport {\n HOST_ROUTES_DIR,\n OFFERED_ROUTES_MODULE,\n} from \"./sync-connect-routes.js\";\n\nconst CONNECT_IMPORT = /^@powerhousedao\\/connect(\\/|$)/;\n\nconst GUARD = \"ph-offered-routes-imports\";\n\nexport const CONNECT_IMPORT_HINT =\n \"Routes a package offers other Connects import @powerhousedao/connect-core instead (ContentOutlet, ModalDialog, useConnectChrome, useDriveRouteData, useNavRoutes and useSidebarMode from @powerhousedao/connect-core/router, SidebarItem from @powerhousedao/design-system/connect); only its own host's _app.tsx and overrides may use @powerhousedao/connect.\";\n\ntype ModuleGraph = {\n getModuleInfo(id: string): {\n importedIds: readonly string[];\n dynamicallyImportedIds: readonly string[];\n } | null;\n error(message: string): never;\n};\n\nfunction reachableFrom(graph: ModuleGraph, entry: string) {\n const reached = new Set<string>();\n const pending = [entry];\n for (let id = pending.pop(); id !== undefined; id = pending.pop()) {\n if (reached.has(id)) continue;\n reached.add(id);\n const info = graph.getModuleInfo(id);\n if (info) pending.push(...info.importedIds, ...info.dynamicallyImportedIds);\n }\n return reached;\n}\n\n/** Fails the build on an import of Connect that the offered routes reach, as\n * other Connects don't share Connect with the package; warns on one from the\n * rest of the package, which bundles a copy of the Connect modules it uses. */\nexport function noConnectImports(routesEntry: string, routesDir: string) {\n const imports = new Map<string, Set<string>>();\n // Module ids may spell a Windows path with either separator.\n const slash = (path: string) => path.replaceAll(\"\\\\\", \"/\");\n const isRoute = (id: string) =>\n slash(id) === slash(routesEntry) ||\n slash(id).startsWith(`${slash(routesDir)}/`);\n return {\n name: GUARD,\n resolveId(source: string, importer: string | undefined) {\n if (!importer || !CONNECT_IMPORT.test(source)) return null;\n // Before resolving it: a route file's import fails even unresolved.\n if (isRoute(importer)) {\n throw new Error(\n `${importer} imports \"${source}\". ${CONNECT_IMPORT_HINT}`,\n );\n }\n const sources = imports.get(importer) ?? new Set<string>();\n imports.set(importer, sources.add(source));\n return null;\n },\n buildEnd(this: ModuleGraph, error?: Error) {\n if (error || !imports.size) return;\n const entry = this.getModuleInfo(routesEntry)\n ? routesEntry\n : slash(routesEntry);\n const reached = reachableFrom(this, entry);\n const described = ([importer, sources]: [string, Set<string>]) =>\n `${importer} imports ${[...sources].map((s) => `\"${s}\"`).join(\", \")}`;\n const offered = [...imports].filter(([id]) => reached.has(id));\n if (offered.length) {\n this.error(\n `${offered.map(described).join(\"\\n\")}\\n${CONNECT_IMPORT_HINT}`,\n );\n }\n console.warn(\n `⚠ ${[...imports].map(described).join(\"\\n\")}\\nConnect isn't shared with the packages it loads, so the build bundles a copy of these modules, apart from the app's state. Import @powerhousedao/connect-core instead; a later version fails the build.`,\n );\n },\n };\n}\n\ntype PluginError = Error & { plugin?: string };\n\nconst IN_NODE_MODULES = /[\\\\/]node_modules[\\\\/]/;\nconst SCRIPT = /\\.[cm]?[jt]sx?$/;\n\n// The project's own modules only: dependencies, styles and assets stay out.\nconst projectModulesOnly: Plugin = {\n name: \"ph-offered-routes-project-modules\",\n async resolveId(source, importer, options) {\n if (!importer) return null;\n const resolved = await this.resolve(source, importer, {\n ...options,\n skipSelf: true,\n });\n if (!resolved || resolved.external) return { id: source, external: true };\n if (IN_NODE_MODULES.test(resolved.id) || !SCRIPT.test(resolved.id)) {\n return { id: resolved.id, external: true };\n }\n return resolved;\n },\n};\n\n/** Fails as `ph build` does when the routes the package offers reach an\n * import of Connect; bundles the project's modules in memory, writing nothing. */\nexport async function checkOfferedRoutesImports(projectDir: string) {\n // Module ids are real paths; the routes are matched against them.\n const projectRoot = realpathSync(projectDir);\n const entry = join(projectRoot, OFFERED_ROUTES_MODULE);\n if (!existsSync(entry)) return;\n const { rolldown } = await import(\"rolldown\");\n const bundle = await rolldown({\n input: entry,\n cwd: projectRoot,\n tsconfig: true,\n logLevel: \"silent\",\n plugins: [\n noConnectImports(entry, join(projectRoot, HOST_ROUTES_DIR)),\n projectModulesOnly,\n ],\n });\n try {\n // Rolldown resolves the graph on generate.\n await bundle.generate({});\n } catch (error) {\n // Only the import rule fails here; tsc and lint report a file that won't parse.\n const found = ((error as { errors?: PluginError[] }).errors ?? []).filter(\n (e) => e.plugin === GUARD,\n );\n if (found.length) {\n throw new Error(found.map((e) => e.message).join(\"\\n\"), {\n cause: error,\n });\n }\n } finally {\n await bundle.close();\n }\n}\n"],"names":[],"mappings":";;;;;;AAQA,MAAM,iBAAiB;AAEvB,MAAM,QAAQ;AAEd,MAAa,sBACX;AAUF,SAAS,cAAc,OAAoB,OAAe;CACxD,MAAM,0BAAU,IAAI,IAAY;CAChC,MAAM,UAAU,CAAC,KAAK;CACtB,KAAK,IAAI,KAAK,QAAQ,IAAI,GAAG,OAAO,KAAA,GAAW,KAAK,QAAQ,IAAI,GAAG;EACjE,IAAI,QAAQ,IAAI,EAAE,GAAG;EACrB,QAAQ,IAAI,EAAE;EACd,MAAM,OAAO,MAAM,cAAc,EAAE;EACnC,IAAI,MAAM,QAAQ,KAAK,GAAG,KAAK,aAAa,GAAG,KAAK,sBAAsB;CAC5E;CACA,OAAO;AACT;;;;AAKA,SAAgB,iBAAiB,aAAqB,WAAmB;CACvE,MAAM,0BAAU,IAAI,IAAyB;CAE7C,MAAM,SAAS,SAAiB,KAAK,WAAW,MAAM,GAAG;CACzD,MAAM,WAAW,OACf,MAAM,EAAE,MAAM,MAAM,WAAW,KAC/B,MAAM,EAAE,CAAC,CAAC,WAAW,GAAG,MAAM,SAAS,EAAE,EAAE;CAC7C,OAAO;EACL,MAAM;EACN,UAAU,QAAgB,UAA8B;GACtD,IAAI,CAAC,YAAY,CAAC,eAAe,KAAK,MAAM,GAAG,OAAO;GAEtD,IAAI,QAAQ,QAAQ,GAClB,MAAM,IAAI,MACR,GAAG,SAAS,YAAY,OAAO,KAAK,qBACtC;GAEF,MAAM,UAAU,QAAQ,IAAI,QAAQ,qBAAK,IAAI,IAAY;GACzD,QAAQ,IAAI,UAAU,QAAQ,IAAI,MAAM,CAAC;GACzC,OAAO;EACT;EACA,SAA4B,OAAe;GACzC,IAAI,SAAS,CAAC,QAAQ,MAAM;GAC5B,MAAM,QAAQ,KAAK,cAAc,WAAW,IACxC,cACA,MAAM,WAAW;G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,CAAC,GAC1D,kBACF;CACF,CAAC;CACD,IAAI;EAEF,MAAM,OAAO,SAAS,CAAC,CAAC;CAC1B,SAAS,OAAO;EAEd,MAAM,SAAU,MAAqC,UAAU,CAAC,EAAA,CAAG,QAChE,MAAM,EAAE,WAAW,KACtB;EACA,IAAI,MAAM,QACR,MAAM,IAAI,MAAM,MAAM,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,GAAG,EACtD,OAAO,MACT,CAAC;CAEL,UAAU;EACR,MAAM,OAAO,MAAM;CACrB;AACF","debug_id":"a3aeccc2-72fd-5986-9fd9-071f527658da"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { t as phCliCommands } from "./ph-cli-commands-Dy4vWwUm.mjs";
|
|
2
|
+
export { phCliCommands };
|
|
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]="9c0edc70-40b1-5f2b-afd2-ae4a447392a2")}catch(e){}}();
|
|
4
|
+
//# debugId=9c0edc70-40b1-5f2b-afd2-ae4a447392a2
|