@powerhousedao/ph-cli 6.1.0 → 6.2.0-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cli-connect-override-DHpuwyEn.mjs +274 -0
  2. package/dist/cli-connect-override-DHpuwyEn.mjs.map +1 -0
  3. package/dist/cli.mjs +59 -28
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/{connect-build-DA5QOP5h.mjs → connect-build-DDWHr6nw.mjs} +9 -6
  6. package/dist/connect-build-DDWHr6nw.mjs.map +1 -0
  7. package/dist/connect-config-DQcIDdtP.mjs +187 -0
  8. package/dist/connect-config-DQcIDdtP.mjs.map +1 -0
  9. package/dist/{connect-preview-DQnzviwA.mjs → connect-preview-D7ypzFDc.mjs} +4 -6
  10. package/dist/connect-preview-D7ypzFDc.mjs.map +1 -0
  11. package/dist/{connect-studio-DTdSFftL.mjs → connect-studio-BbxxxUZ9.mjs} +7 -7
  12. package/dist/connect-studio-BbxxxUZ9.mjs.map +1 -0
  13. package/dist/connect-studio-YDVQ49D6.mjs +5 -0
  14. package/dist/{generate-all-WiQQo-Nz.mjs → generate-all-DrT4ZxHX.mjs} +3 -3
  15. package/dist/{generate-all-WiQQo-Nz.mjs.map → generate-all-DrT4ZxHX.mjs.map} +1 -1
  16. package/dist/{generate-app-DdmOt6ID.mjs → generate-app-DNNqA-H3.mjs} +3 -3
  17. package/dist/{generate-app-DdmOt6ID.mjs.map → generate-app-DNNqA-H3.mjs.map} +1 -1
  18. package/dist/{generate-document-model-DQ5PVeIH.mjs → generate-document-model-BJXyODfm.mjs} +3 -3
  19. package/dist/{generate-document-model-DQ5PVeIH.mjs.map → generate-document-model-BJXyODfm.mjs.map} +1 -1
  20. package/dist/{generate-editor-DtzVAs6x.mjs → generate-editor-BejvaVVT.mjs} +3 -3
  21. package/dist/{generate-editor-DtzVAs6x.mjs.map → generate-editor-BejvaVVT.mjs.map} +1 -1
  22. package/dist/{generate-processor-FGtN6BVY.mjs → generate-processor-_WOx-mMe.mjs} +3 -3
  23. package/dist/{generate-processor-FGtN6BVY.mjs.map → generate-processor-_WOx-mMe.mjs.map} +1 -1
  24. package/dist/{generate-subgraph-BrzmW_sj.mjs → generate-subgraph-BsHUstpl.mjs} +3 -3
  25. package/dist/{generate-subgraph-BrzmW_sj.mjs.map → generate-subgraph-BsHUstpl.mjs.map} +1 -1
  26. package/dist/{init-Cu3_NRHL.mjs → init-D3toc_qO.mjs} +3 -3
  27. package/dist/{init-Cu3_NRHL.mjs.map → init-D3toc_qO.mjs.map} +1 -1
  28. package/dist/{inspect-BwuBW_zW.mjs → inspect-CKdafPbC.mjs} +4 -4
  29. package/dist/{inspect-BwuBW_zW.mjs.map → inspect-CKdafPbC.mjs.map} +1 -1
  30. package/dist/{migrate-CfgiCNQo.mjs → migrate-BJQvY88v.mjs} +3 -3
  31. package/dist/{migrate-CfgiCNQo.mjs.map → migrate-BJQvY88v.mjs.map} +1 -1
  32. package/dist/{registry-auth-CNH84uo4.mjs → registry-auth-DxEWCJu2.mjs} +3 -3
  33. package/dist/{registry-auth-CNH84uo4.mjs.map → registry-auth-DxEWCJu2.mjs.map} +1 -1
  34. package/dist/{switchboard-CERuSM8r.mjs → switchboard-CJMoMzWx.mjs} +3 -3
  35. package/dist/{switchboard-CERuSM8r.mjs.map → switchboard-CJMoMzWx.mjs.map} +1 -1
  36. package/dist/switchboard-iRFugh8I.mjs +4 -0
  37. package/dist/{switchboard-migrate-BumRp7rC.mjs → switchboard-migrate-NQ7LHWSi.mjs} +3 -3
  38. package/dist/{switchboard-migrate-BumRp7rC.mjs.map → switchboard-migrate-NQ7LHWSi.mjs.map} +1 -1
  39. package/dist/{switchboard-reset-1YcJEVqc.mjs → switchboard-reset-BcQXlcVf.mjs} +3 -3
  40. package/dist/{switchboard-reset-1YcJEVqc.mjs.map → switchboard-reset-BcQXlcVf.mjs.map} +1 -1
  41. package/dist/{utils-mth8NsDA.mjs → utils-BaTZlyL3.mjs} +5 -5
  42. package/dist/utils-BaTZlyL3.mjs.map +1 -0
  43. package/dist/{utils-C6581aex.mjs → utils-DPGwKNam.mjs} +3 -3
  44. package/dist/{vetra-BgmlqLmN.mjs → vetra-DjsGCr0t.mjs} +12 -10
  45. package/dist/vetra-DjsGCr0t.mjs.map +1 -0
  46. package/package.json +13 -11
  47. package/dist/assign-env-vars-W-lZmdMi.mjs +0 -18
  48. package/dist/assign-env-vars-W-lZmdMi.mjs.map +0 -1
  49. package/dist/connect-build-DA5QOP5h.mjs.map +0 -1
  50. package/dist/connect-preview-DQnzviwA.mjs.map +0 -1
  51. package/dist/connect-studio-DTdSFftL.mjs.map +0 -1
  52. package/dist/connect-studio-DySbZFEc.mjs +0 -5
  53. package/dist/switchboard-ChH1PMaE.mjs +0 -4
  54. package/dist/utils-mth8NsDA.mjs.map +0 -1
  55. package/dist/vetra-BgmlqLmN.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b5fd9f68-512b-5441-8970-6d676ff10349")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5cc924ff-7015-5b6b-ac8d-a2c87fcac122")}catch(e){}}();
3
3
  import { execSync } from "node:child_process";
4
4
  import { dirname, join } from "node:path";
5
5
  import { detect, resolveCommand } from "package-manager-detector";
@@ -79,5 +79,5 @@ async function startMigrate({ versionPositional, version, force, debug }) {
79
79
  //#endregion
80
80
  export { startMigrate };
81
81
 
82
- //# sourceMappingURL=migrate-CfgiCNQo.mjs.map
83
- //# debugId=b5fd9f68-512b-5441-8970-6d676ff10349
82
+ //# sourceMappingURL=migrate-BJQvY88v.mjs.map
83
+ //# debugId=5cc924ff-7015-5b6b-ac8d-a2c87fcac122
@@ -1 +1 @@
1
- {"version":3,"file":"migrate-CfgiCNQo.mjs","sources":["../src/services/migrate.ts"],"sourcesContent":["import {\n fetchPackageVersionFromNpmRegistry,\n injectPnpmAllowBuilds,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { detect, resolveCommand } from \"package-manager-detector\";\nimport type { MigrateArgs } from \"../types.js\";\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\nexport async function startMigrate({\n versionPositional,\n version,\n force,\n debug,\n}: MigrateArgs) {\n const requested = versionPositional ?? version;\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 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 await codegenMod.migrate(targetVersion ?? requested);\n return;\n }\n\n const agent = (await detect())?.agent ?? \"npm\";\n const resolved = resolveCommand(agent, \"execute\", [\n `@powerhousedao/ph-cli@${targetVersion}`,\n \"migrate\",\n \"--version\",\n targetVersion,\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, { stdio: \"inherit\" });\n}\n"],"names":[],"mappings":";;;;;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/D,MAAI,MAAO,SAAQ,IAAI,iDAAiD;EACxE,MAAM,aAAa,MAAM,OAAO;EAChC,MAAM,iBAAiB,sBACrB,WACD;AACD,8BAA4B;GAC1B;GACA;GACA,OAAO,QAAQ,MAAM;GACtB,CAAC;AACF,UAAQ,IACN,+CAA+C,kBAAkB,YAClE;AACD,QAAM,WAAW,QAAQ,iBAAiB,UAAU;AACpD;;CAGF,MAAM,SAAS,MAAM,QAAQ,GAAG,SAAS;CACzC,MAAM,WAAW,eAAe,OAAO,WAAW;EAChD,yBAAyB;EACzB;EACA;EACA;EACA,GAAI,QAAQ,CAAC,UAAU,GAAG,EAAE;EAC7B,CAAC;AACF,KAAI,CAAC,SACH,OAAM,IAAI,MACR,0DAA0D,MAAM,IACjE;AAGH,uBAAsB,OAAO,SAAS;CAEtC,MAAM,UAAU,GAAG,SAAS,QAAQ,GAAG,SAAS,KAAK,KAAK,IAAI;AAC9D,KAAI,OAAO;AACT,UAAQ,IAAI,uCAAuC,QAAQ;AAC3D,UAAQ,IAAI,2BAA2B,UAAU;;AAEnD,UAAS,SAAS,EAAE,OAAO,WAAW,CAAC","debug_id":"b5fd9f68-512b-5441-8970-6d676ff10349"}
1
+ {"version":3,"file":"migrate-BJQvY88v.mjs","sources":["../src/services/migrate.ts"],"sourcesContent":["import {\n fetchPackageVersionFromNpmRegistry,\n injectPnpmAllowBuilds,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { detect, resolveCommand } from \"package-manager-detector\";\nimport type { MigrateArgs } from \"../types.js\";\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\nexport async function startMigrate({\n versionPositional,\n version,\n force,\n debug,\n}: MigrateArgs) {\n const requested = versionPositional ?? version;\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 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 await codegenMod.migrate(targetVersion ?? requested);\n return;\n }\n\n const agent = (await detect())?.agent ?? \"npm\";\n const resolved = resolveCommand(agent, \"execute\", [\n `@powerhousedao/ph-cli@${targetVersion}`,\n \"migrate\",\n \"--version\",\n targetVersion,\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, { stdio: \"inherit\" });\n}\n"],"names":[],"mappings":";;;;;;;;;AAWA,SAAS,yBAA6C;CACpD,IAAI,MAAM,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AACjD,MAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,MAAI;GACF,MAAM,MAAM,KAAK,MACf,aAAa,KAAK,KAAK,eAAe,EAAE,OAAO,CAChD;AACD,OAAI,IAAI,SAAS,wBAAyB,QAAO,IAAI;UAC/C;AAGR,QAAM,QAAQ,IAAI;;;AAItB,SAAgB,sBACd,YACoB;CACpB,MAAM,SAAS,WAAW;AAC1B,KAAI,OAAO,WAAW,YAAY;EAChC,MAAM,IAAK,QAA0B;AACrC,MAAI,OAAO,MAAM,SAAU,QAAO;;;AAKtC,SAAgB,4BAA4B,MAInC;CACP,MAAM,EAAE,gBAAgB,gBAAgB,UAAU;AAClD,KAAI,MAAO;AACX,KAAI,CAAC,eACH,OAAM,IAAI,MACR,sJAED;AAEH,KAAI,kBAAkB,mBAAmB,eACvC,OAAM,IAAI,MACR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;AAC3D,UAAQ,IAAI,2BAA2B,UAAU;;AAEnD,UAAS,SAAS,EAAE,OAAO,WAAW,CAAC","debug_id":"5cc924ff-7015-5b6b-ac8d-a2c87fcac122"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2e430ad3-fb2c-5578-8c85-ccce5c5a369e")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="10e21342-67f2-5661-889a-e6e77c2b13f6")}catch(e){}}();
3
3
  import { t as getRenown } from "./auth-AR3VxAIk.mjs";
4
4
  import { generateAccessToken } from "@renown/sdk/node";
5
5
  //#region src/services/registry-auth.ts
@@ -21,5 +21,5 @@ async function mintRegistryAuthToken(registryUrl, expiresInSeconds) {
21
21
  //#endregion
22
22
  export { mintRegistryAuthToken };
23
23
 
24
- //# sourceMappingURL=registry-auth-CNH84uo4.mjs.map
25
- //# debugId=2e430ad3-fb2c-5578-8c85-ccce5c5a369e
24
+ //# sourceMappingURL=registry-auth-DxEWCJu2.mjs.map
25
+ //# debugId=10e21342-67f2-5661-889a-e6e77c2b13f6
@@ -1 +1 @@
1
- {"version":3,"file":"registry-auth-CNH84uo4.mjs","sources":["../src/services/registry-auth.ts"],"sourcesContent":["import { generateAccessToken } from \"@renown/sdk/node\";\nimport { getRenown } from \"./auth.js\";\n\n/**\n * Mint a Renown bearer token bound to the given registry URL via the JWT\n * `aud` claim. Throws if the user is not authenticated (`ph login` first).\n *\n * The audience binding is what lets the registry distinguish a token minted\n * for it from one minted for a different service or registry.\n */\nexport async function mintRegistryAuthToken(\n registryUrl: string,\n expiresInSeconds: number,\n): Promise<string> {\n const renown = await getRenown();\n if (!renown.user) {\n throw new Error(\"Not authenticated with Renown. Run 'ph login' first.\");\n }\n const result = await generateAccessToken(renown, {\n expiresIn: expiresInSeconds,\n aud: registryUrl,\n });\n return result.token;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAUA,eAAsB,sBACpB,aACA,kBACiB;CACjB,MAAM,SAAS,MAAM,WAAW;AAChC,KAAI,CAAC,OAAO,KACV,OAAM,IAAI,MAAM,uDAAuD;AAMzE,SAJe,MAAM,oBAAoB,QAAQ;EAC/C,WAAW;EACX,KAAK;EACN,CAAC,EACY","debug_id":"2e430ad3-fb2c-5578-8c85-ccce5c5a369e"}
1
+ {"version":3,"file":"registry-auth-DxEWCJu2.mjs","sources":["../src/services/registry-auth.ts"],"sourcesContent":["import { generateAccessToken } from \"@renown/sdk/node\";\nimport { getRenown } from \"./auth.js\";\n\n/**\n * Mint a Renown bearer token bound to the given registry URL via the JWT\n * `aud` claim. Throws if the user is not authenticated (`ph login` first).\n *\n * The audience binding is what lets the registry distinguish a token minted\n * for it from one minted for a different service or registry.\n */\nexport async function mintRegistryAuthToken(\n registryUrl: string,\n expiresInSeconds: number,\n): Promise<string> {\n const renown = await getRenown();\n if (!renown.user) {\n throw new Error(\"Not authenticated with Renown. Run 'ph login' first.\");\n }\n const result = await generateAccessToken(renown, {\n expiresIn: expiresInSeconds,\n aud: registryUrl,\n });\n return result.token;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAUA,eAAsB,sBACpB,aACA,kBACiB;CACjB,MAAM,SAAS,MAAM,WAAW;AAChC,KAAI,CAAC,OAAO,KACV,OAAM,IAAI,MAAM,uDAAuD;AAMzE,SAJe,MAAM,oBAAoB,QAAQ;EAC/C,WAAW;EACX,KAAK;EACN,CAAC,EACY","debug_id":"10e21342-67f2-5661-889a-e6e77c2b13f6"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2b112076-440d-59d6-ac2e-84dc0ffb3cfd")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="78c61fe0-c1e9-5213-8e08-1cbfad29b4af")}catch(e){}}();
3
3
  import path from "node:path";
4
4
  import { startSwitchboard } from "@powerhousedao/switchboard/server";
5
5
  //#region src/services/switchboard.ts
@@ -71,5 +71,5 @@ async function startSwitchboard$1(options, logger) {
71
71
  //#endregion
72
72
  export { startSwitchboard$1 as n, defaultSwitchboardOptions as t };
73
73
 
74
- //# sourceMappingURL=switchboard-CERuSM8r.mjs.map
75
- //# debugId=2b112076-440d-59d6-ac2e-84dc0ffb3cfd
74
+ //# sourceMappingURL=switchboard-CJMoMzWx.mjs.map
75
+ //# debugId=78c61fe0-c1e9-5213-8e08-1cbfad29b4af
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard-CERuSM8r.mjs","sources":["../src/services/switchboard.ts"],"sourcesContent":["import type {\n IdentityOptions,\n StartServerOptions,\n} from \"@powerhousedao/switchboard/server\";\nimport { startSwitchboard as startSwitchboardServer } from \"@powerhousedao/switchboard/server\";\nimport type { ILogger } from \"document-model\";\nimport path from \"node:path\";\nimport type { SwitchboardArgs } from \"../types.js\";\n\nexport const defaultSwitchboardOptions = {\n port: 4001,\n dbPath: path.join(process.cwd(), \".ph/read-model.db\"),\n drive: {\n id: \"powerhouse\",\n slug: \"powerhouse\",\n global: {\n name: \"Powerhouse\",\n icon: \"https://ipfs.io/ipfs/QmcaTDBYn8X2psGaXe7iQ6qd8q6oqHLgxvMX9yXf7f9uP7\",\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\",\n triggers: [],\n },\n },\n mcp: true,\n} satisfies StartServerOptions;\n\nfunction getDefaultVetraSwitchboardOptions(\n vetraDriveId: string,\n): Partial<StartServerOptions> {\n return {\n port: 4001,\n dbPath: path.join(process.cwd(), \".ph/read-model.db\"),\n drive: {\n id: vetraDriveId,\n slug: vetraDriveId,\n global: {\n name: \"Vetra\",\n icon: \"https://azure-elderly-tortoise-212.mypinata.cloud/ipfs/bafkreibf2xokjqqtomqjd2w2xxmmhvogq4262csevclxh6sbrjgmjfre5u\",\n },\n preferredEditor: \"vetra-drive-app\",\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\",\n triggers: [],\n },\n },\n };\n}\n\nexport async function startSwitchboard(\n options: SwitchboardArgs & {\n strictPort?: boolean;\n processorConfig?: Map<string, unknown>;\n },\n logger?: ILogger,\n) {\n const {\n packages: packagesString,\n remoteDrives,\n useVetraDrive,\n vetraDriveId,\n useIdentity,\n keypairPath,\n requireIdentity,\n ...serverOptions\n } = options;\n\n // Choose the appropriate default configuration\n const defaultOptions = useVetraDrive\n ? getDefaultVetraSwitchboardOptions(vetraDriveId)\n : defaultSwitchboardOptions;\n\n // Build identity options if enabled\n const identity: IdentityOptions | undefined =\n useIdentity || keypairPath || requireIdentity\n ? {\n keypairPath,\n requireExisting: requireIdentity,\n }\n : undefined;\n\n const packages = packagesString?.split(\",\");\n\n // Only include the default drive if no remote drives are provided\n const finalOptions =\n remoteDrives.length > 0\n ? {\n ...defaultOptions,\n drive: undefined, // Don't create default drive when syncing with remote\n ...serverOptions,\n remoteDrives,\n identity,\n packages,\n logger,\n }\n : {\n ...defaultOptions,\n ...serverOptions,\n remoteDrives,\n identity,\n packages,\n logger,\n };\n\n const reactor = await startSwitchboardServer(finalOptions);\n\n return reactor;\n}\n"],"names":["startSwitchboard","startSwitchboardServer"],"mappings":";;;;;AASA,MAAa,4BAA4B;CACvC,MAAM;CACN,QAAQ,KAAK,KAAK,QAAQ,KAAK,EAAE,oBAAoB;CACrD,OAAO;EACL,IAAI;EACJ,MAAM;EACN,QAAQ;GACN,MAAM;GACN,MAAM;GACP;EACD,OAAO;GACL,kBAAkB;GAClB,WAAW,EAAE;GACb,aAAa;GACb,UAAU,EAAE;GACb;EACF;CACD,KAAK;CACN;AAED,SAAS,kCACP,cAC6B;AAC7B,QAAO;EACL,MAAM;EACN,QAAQ,KAAK,KAAK,QAAQ,KAAK,EAAE,oBAAoB;EACrD,OAAO;GACL,IAAI;GACJ,MAAM;GACN,QAAQ;IACN,MAAM;IACN,MAAM;IACP;GACD,iBAAiB;GACjB,OAAO;IACL,kBAAkB;IAClB,WAAW,EAAE;IACb,aAAa;IACb,UAAU,EAAE;IACb;GACF;EACF;;AAGH,eAAsBA,mBACpB,SAIA,QACA;CACA,MAAM,EACJ,UAAU,gBACV,cACA,eACA,cACA,aACA,aACA,iBACA,GAAG,kBACD;CAGJ,MAAM,iBAAiB,gBACnB,kCAAkC,aAAa,GAC/C;CAGJ,MAAM,WACJ,eAAe,eAAe,kBAC1B;EACE;EACA,iBAAiB;EAClB,GACD,KAAA;CAEN,MAAM,WAAW,gBAAgB,MAAM,IAAI;AAyB3C,QAFgB,MAAMC,iBAnBpB,aAAa,SAAS,IAClB;EACE,GAAG;EACH,OAAO,KAAA;EACP,GAAG;EACH;EACA;EACA;EACA;EACD,GACD;EACE,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA;EACD,CAEmD","debug_id":"2b112076-440d-59d6-ac2e-84dc0ffb3cfd"}
1
+ {"version":3,"file":"switchboard-CJMoMzWx.mjs","sources":["../src/services/switchboard.ts"],"sourcesContent":["import type {\n IdentityOptions,\n StartServerOptions,\n} from \"@powerhousedao/switchboard/server\";\nimport { startSwitchboard as startSwitchboardServer } from \"@powerhousedao/switchboard/server\";\nimport type { ILogger } from \"document-model\";\nimport path from \"node:path\";\nimport type { SwitchboardArgs } from \"../types.js\";\n\nexport const defaultSwitchboardOptions = {\n port: 4001,\n dbPath: path.join(process.cwd(), \".ph/read-model.db\"),\n drive: {\n id: \"powerhouse\",\n slug: \"powerhouse\",\n global: {\n name: \"Powerhouse\",\n icon: \"https://ipfs.io/ipfs/QmcaTDBYn8X2psGaXe7iQ6qd8q6oqHLgxvMX9yXf7f9uP7\",\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\",\n triggers: [],\n },\n },\n mcp: true,\n} satisfies StartServerOptions;\n\nfunction getDefaultVetraSwitchboardOptions(\n vetraDriveId: string,\n): Partial<StartServerOptions> {\n return {\n port: 4001,\n dbPath: path.join(process.cwd(), \".ph/read-model.db\"),\n drive: {\n id: vetraDriveId,\n slug: vetraDriveId,\n global: {\n name: \"Vetra\",\n icon: \"https://azure-elderly-tortoise-212.mypinata.cloud/ipfs/bafkreibf2xokjqqtomqjd2w2xxmmhvogq4262csevclxh6sbrjgmjfre5u\",\n },\n preferredEditor: \"vetra-drive-app\",\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\",\n triggers: [],\n },\n },\n };\n}\n\nexport async function startSwitchboard(\n options: SwitchboardArgs & {\n strictPort?: boolean;\n processorConfig?: Map<string, unknown>;\n },\n logger?: ILogger,\n) {\n const {\n packages: packagesString,\n remoteDrives,\n useVetraDrive,\n vetraDriveId,\n useIdentity,\n keypairPath,\n requireIdentity,\n ...serverOptions\n } = options;\n\n // Choose the appropriate default configuration\n const defaultOptions = useVetraDrive\n ? getDefaultVetraSwitchboardOptions(vetraDriveId)\n : defaultSwitchboardOptions;\n\n // Build identity options if enabled\n const identity: IdentityOptions | undefined =\n useIdentity || keypairPath || requireIdentity\n ? {\n keypairPath,\n requireExisting: requireIdentity,\n }\n : undefined;\n\n const packages = packagesString?.split(\",\");\n\n // Only include the default drive if no remote drives are provided\n const finalOptions =\n remoteDrives.length > 0\n ? {\n ...defaultOptions,\n drive: undefined, // Don't create default drive when syncing with remote\n ...serverOptions,\n remoteDrives,\n identity,\n packages,\n logger,\n }\n : {\n ...defaultOptions,\n ...serverOptions,\n remoteDrives,\n identity,\n packages,\n logger,\n };\n\n const reactor = await startSwitchboardServer(finalOptions);\n\n return reactor;\n}\n"],"names":["startSwitchboard","startSwitchboardServer"],"mappings":";;;;;AASA,MAAa,4BAA4B;CACvC,MAAM;CACN,QAAQ,KAAK,KAAK,QAAQ,KAAK,EAAE,oBAAoB;CACrD,OAAO;EACL,IAAI;EACJ,MAAM;EACN,QAAQ;GACN,MAAM;GACN,MAAM;GACP;EACD,OAAO;GACL,kBAAkB;GAClB,WAAW,EAAE;GACb,aAAa;GACb,UAAU,EAAE;GACb;EACF;CACD,KAAK;CACN;AAED,SAAS,kCACP,cAC6B;AAC7B,QAAO;EACL,MAAM;EACN,QAAQ,KAAK,KAAK,QAAQ,KAAK,EAAE,oBAAoB;EACrD,OAAO;GACL,IAAI;GACJ,MAAM;GACN,QAAQ;IACN,MAAM;IACN,MAAM;IACP;GACD,iBAAiB;GACjB,OAAO;IACL,kBAAkB;IAClB,WAAW,EAAE;IACb,aAAa;IACb,UAAU,EAAE;IACb;GACF;EACF;;AAGH,eAAsBA,mBACpB,SAIA,QACA;CACA,MAAM,EACJ,UAAU,gBACV,cACA,eACA,cACA,aACA,aACA,iBACA,GAAG,kBACD;CAGJ,MAAM,iBAAiB,gBACnB,kCAAkC,aAAa,GAC/C;CAGJ,MAAM,WACJ,eAAe,eAAe,kBAC1B;EACE;EACA,iBAAiB;EAClB,GACD,KAAA;CAEN,MAAM,WAAW,gBAAgB,MAAM,IAAI;AAyB3C,QAFgB,MAAMC,iBAnBpB,aAAa,SAAS,IAClB;EACE,GAAG;EACH,OAAO,KAAA;EACP,GAAG;EACH;EACA;EACA;EACA;EACD,GACD;EACE,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA;EACD,CAEmD","debug_id":"78c61fe0-c1e9-5213-8e08-1cbfad29b4af"}
@@ -0,0 +1,4 @@
1
+ import { n as startSwitchboard } from "./switchboard-CJMoMzWx.mjs";
2
+ export { startSwitchboard };
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]="cff2a381-7480-5ec2-80aa-ed51509c3265")}catch(e){}}();
4
+ //# debugId=cff2a381-7480-5ec2-80aa-ed51509c3265
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4ec454c2-51e0-5620-85cc-296ec21997cd")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9ca57982-bee9-5f08-aa81-5fb5a7ca8324")}catch(e){}}();
3
3
  import { Kysely, PostgresDialect } from "kysely";
4
4
  import { Pool } from "pg";
5
5
  import { REACTOR_SCHEMA, getMigrationStatus, runMigrations } from "@powerhousedao/reactor";
@@ -49,5 +49,5 @@ async function runSwitchboardMigrations(options) {
49
49
  //#endregion
50
50
  export { runSwitchboardMigrations };
51
51
 
52
- //# sourceMappingURL=switchboard-migrate-BumRp7rC.mjs.map
53
- //# debugId=4ec454c2-51e0-5620-85cc-296ec21997cd
52
+ //# sourceMappingURL=switchboard-migrate-NQ7LHWSi.mjs.map
53
+ //# debugId=9ca57982-bee9-5f08-aa81-5fb5a7ca8324
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard-migrate-BumRp7rC.mjs","sources":["../src/services/switchboard-migrate.ts"],"sourcesContent":["import { Kysely, PostgresDialect } from \"kysely\";\nimport { Pool } from \"pg\";\nimport {\n runMigrations,\n getMigrationStatus,\n REACTOR_SCHEMA,\n} from \"@powerhousedao/reactor\";\n\ninterface MigrationOptions {\n dbPath?: string;\n statusOnly?: boolean;\n}\n\nfunction isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nexport async function runSwitchboardMigrations(\n options: MigrationOptions,\n): Promise<void> {\n const dbPath =\n options.dbPath ??\n process.env.PH_REACTOR_DATABASE_URL ??\n process.env.DATABASE_URL;\n\n if (!dbPath || !isPostgresUrl(dbPath)) {\n console.log(\"No PostgreSQL URL configured. Skipping migrations.\");\n console.log(\"(PGlite migrations are handled automatically on startup)\");\n return;\n }\n\n console.log(`Database: ${dbPath}`);\n\n const pool = new Pool({ connectionString: dbPath });\n\n const db = new Kysely<any>({\n dialect: new PostgresDialect({ pool }),\n });\n\n try {\n if (options.statusOnly) {\n console.log(\"\\nChecking migration status...\");\n const migrations = await getMigrationStatus(db, REACTOR_SCHEMA);\n\n console.log(\"\\nMigration Status:\");\n console.log(\"=================\");\n\n for (const migration of migrations) {\n const status = migration.executedAt\n ? `[OK] Executed at ${migration.executedAt.toISOString()}`\n : \"[--] Pending\";\n console.log(`${status} - ${migration.name}`);\n }\n } else {\n console.log(\"\\nRunning migrations...\");\n const result = await runMigrations(db, REACTOR_SCHEMA);\n\n if (!result.success) {\n console.error(\"Migration failed:\", result.error?.message);\n process.exit(1);\n }\n\n if (result.migrationsExecuted.length === 0) {\n console.log(\"No migrations to run - database is up to date\");\n } else {\n console.log(\n `Successfully executed ${result.migrationsExecuted.length} migration(s):`,\n );\n for (const name of result.migrationsExecuted) {\n console.log(` - ${name}`);\n }\n }\n }\n } catch (error) {\n console.error(\n \"Error:\",\n error instanceof Error ? error.message : String(error),\n );\n process.exit(1);\n } finally {\n await db.destroy();\n }\n}\n"],"names":[],"mappings":";;;;;;AAaA,SAAS,cAAc,KAAsB;AAC3C,QAAO,IAAI,WAAW,gBAAgB,IAAI,IAAI,WAAW,cAAc;;AAGzE,eAAsB,yBACpB,SACe;CACf,MAAM,SACJ,QAAQ,UACR,QAAQ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esContent":["import { Kysely, PostgresDialect } from \"kysely\";\nimport { Pool } from \"pg\";\nimport {\n runMigrations,\n getMigrationStatus,\n REACTOR_SCHEMA,\n} from \"@powerhousedao/reactor\";\n\ninterface MigrationOptions {\n dbPath?: string;\n statusOnly?: boolean;\n}\n\nfunction isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nexport async function runSwitchboardMigrations(\n options: MigrationOptions,\n): Promise<void> {\n const dbPath =\n options.dbPath ??\n process.env.PH_REACTOR_DATABASE_URL ??\n process.env.DATABASE_URL;\n\n if (!dbPath || !isPostgresUrl(dbPath)) {\n console.log(\"No PostgreSQL URL configured. Skipping migrations.\");\n console.log(\"(PGlite migrations are handled automatically on startup)\");\n return;\n }\n\n console.log(`Database: ${dbPath}`);\n\n const pool = new Pool({ connectionString: dbPath });\n\n const db = new Kysely<any>({\n dialect: new PostgresDialect({ pool }),\n });\n\n try {\n if (options.statusOnly) {\n console.log(\"\\nChecking migration status...\");\n const migrations = await getMigrationStatus(db, REACTOR_SCHEMA);\n\n console.log(\"\\nMigration Status:\");\n console.log(\"=================\");\n\n for (const migration of migrations) {\n const status = migration.executedAt\n ? `[OK] Executed at ${migration.executedAt.toISOString()}`\n : \"[--] Pending\";\n console.log(`${status} - ${migration.name}`);\n }\n } else {\n console.log(\"\\nRunning migrations...\");\n const result = await runMigrations(db, REACTOR_SCHEMA);\n\n if (!result.success) {\n console.error(\"Migration failed:\", result.error?.message);\n process.exit(1);\n }\n\n if (result.migrationsExecuted.length === 0) {\n console.log(\"No migrations to run - database is up to date\");\n } else {\n console.log(\n `Successfully executed ${result.migrationsExecuted.length} migration(s):`,\n );\n for (const name of result.migrationsExecuted) {\n console.log(` - ${name}`);\n }\n }\n }\n } catch (error) {\n console.error(\n \"Error:\",\n error instanceof Error ? error.message : String(error),\n );\n process.exit(1);\n } finally {\n await db.destroy();\n }\n}\n"],"names":[],"mappings":";;;;;;AAaA,SAAS,cAAc,K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AG,SAAS","debug_id":"9ca57982-bee9-5f08-aa81-5fb5a7ca8324"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4438a63d-24ec-57f5-8ae6-4ae3a40a8c6f")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6dc443d3-91f6-5215-973e-7898511565eb")}catch(e){}}();
3
3
  import { cyan, green, red, yellow } from "colorette";
4
4
  import { promises } from "node:fs";
5
5
  //#region src/services/switchboard-reset.ts
@@ -83,5 +83,5 @@ async function resetSwitchboardDatabase(options) {
83
83
  //#endregion
84
84
  export { resetSwitchboardDatabase };
85
85
 
86
- //# sourceMappingURL=switchboard-reset-1YcJEVqc.mjs.map
87
- //# debugId=4438a63d-24ec-57f5-8ae6-4ae3a40a8c6f
86
+ //# sourceMappingURL=switchboard-reset-BcQXlcVf.mjs.map
87
+ //# debugId=6dc443d3-91f6-5215-973e-7898511565eb
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard-reset-1YcJEVqc.mjs","sources":["../src/services/switchboard-reset.ts"],"sourcesContent":["import { yellow, red, green, cyan } from \"colorette\";\nimport { promises as fs } from \"node:fs\";\n\nexport interface ResetSwitchboardOptions {\n dbPath?: string;\n yes?: boolean;\n}\n\nexport interface ResolvedResetPaths {\n reactorDir: string | null;\n readModelDir: string | null;\n postgresUrl: string | null;\n}\n\nconst CONFIRMATION_TOKEN = \"reset\";\n\nexport function isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\n/**\n * Resolves the on-disk PGlite directories that `--reset` would delete.\n * Mirrors the resolution in apps/switchboard/src/server.mts so we touch the\n * same paths the running switchboard uses. When a Postgres URL is configured\n * the corresponding directory is null and `postgresUrl` is populated so the\n * caller can refuse.\n */\nexport function resolveResetPaths(\n options: ResetSwitchboardOptions,\n env: NodeJS.ProcessEnv = process.env,\n): ResolvedResetPaths {\n const readModelDbPath =\n options.dbPath ?? env.DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;\n const readModelPath = readModelDbPath || \".ph/read-storage\";\n const reactorDbUrl =\n options.dbPath ??\n env.PH_REACTOR_DATABASE_URL ??\n env.PH_SWITCHBOARD_DATABASE_URL;\n const reactorPath = reactorDbUrl || \"./.ph/reactor-storage\";\n\n const reactorIsPostgres = !!reactorDbUrl && isPostgresUrl(reactorDbUrl);\n const readModelIsPostgres =\n !!readModelDbPath && isPostgresUrl(readModelDbPath);\n\n let postgresUrl: string | null = null;\n if (reactorIsPostgres) postgresUrl = reactorDbUrl as string;\n else if (readModelIsPostgres) postgresUrl = readModelDbPath as string;\n\n return {\n reactorDir: reactorIsPostgres ? null : reactorPath,\n readModelDir: readModelIsPostgres ? null : readModelPath,\n postgresUrl,\n };\n}\n\nasync function promptForConfirmation(): Promise<boolean> {\n const enquirer = await import(\"enquirer\");\n try {\n const answer = await enquirer.default.prompt<{ confirmation: string }>({\n type: \"input\",\n name: \"confirmation\",\n message: `Type \"${CONFIRMATION_TOKEN}\" to confirm wiping the local switchboard databases:`,\n });\n return answer.confirmation.trim() === CONFIRMATION_TOKEN;\n } catch {\n return false;\n }\n}\n\nexport async function resetSwitchboardDatabase(\n options: ResetSwitchboardOptions,\n): Promise<void> {\n const paths = resolveResetPaths(options);\n\n if (paths.postgresUrl) {\n console.error(\n red(\n `Refusing to reset: a PostgreSQL URL is configured (${paths.postgresUrl}).`,\n ),\n );\n console.error(\n yellow(\n \"`ph switchboard --reset` only wipes the local PGlite stores. \" +\n \"To reset a Postgres-backed switchboard, drop/recreate the database manually.\",\n ),\n );\n process.exit(1);\n }\n\n const targets = [paths.reactorDir, paths.readModelDir].filter(\n (d): d is string => d !== null,\n );\n\n if (targets.length === 0) {\n console.error(red(\"No local PGlite directories resolved; nothing to do.\"));\n process.exit(1);\n }\n\n console.log(yellow(\"The following directories will be permanently deleted:\"));\n for (const dir of targets) {\n console.log(` - ${dir}`);\n }\n console.log(\n yellow(\n \"This will wipe all local switchboard state. Migrations will re-run on next `ph switchboard`.\",\n ),\n );\n\n let confirmed = false;\n if (options.yes) {\n confirmed = true;\n } else if (isInteractive()) {\n confirmed = await promptForConfirmation();\n } else {\n console.error(\n red(\n \"Refusing to reset in a non-interactive context without --yes. Re-run with --yes to confirm.\",\n ),\n );\n process.exit(1);\n }\n\n if (!confirmed) {\n console.error(red(\"Aborted: confirmation not provided.\"));\n process.exit(1);\n }\n\n for (const dir of targets) {\n await fs.rm(dir, { recursive: true, force: true });\n console.log(cyan(`Removed ${dir}`));\n }\n\n console.log(\n green(\n \"Switchboard local storage reset. Run `ph switchboard` to re-initialize.\",\n ),\n );\n}\n"],"names":["fs"],"mappings":";;;;;AAcA,MAAM,qBAAqB;AAE3B,SAAgB,cAAc,KAAsB;AAClD,QAAO,IAAI,WAAW,gBAAgB,IAAI,IAAI,WAAW,cAAc;;AAGzE,SAAS,gBAAyB;AAChC,QAAO,QAAQ,QAAQ,MAAM,MAAM,IAAI,CAAC,QAAQ,IAAI;;;;;;;;;AAUtD,SAAgB,kBACd,SACA,MAAyB,QAAQ,KACb;CACpB,MAAM,kBACJ,QAAQ,UAAU,IAAI,gBAAgB,IAAI;CAC5C,MAAM,gBAAgB,mBAAmB;CACzC,MAAM,eACJ,QAAQ,UACR,IAAI,2BACJ,IAAI;CACN,MAAM,cAAc,gBAAgB;CAEpC,MAAM,oBAAoB,CAAC,CAAC,gBAAgB,cAAc,aAAa;CACvE,MAAM,sBACJ,CAAC,CAAC,mBAAmB,cAAc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,MAAM,CAAC;;AAGrC,SAAQ,IACN,MACE,0EACD,CACF","debug_id":"4438a63d-24ec-57f5-8ae6-4ae3a40a8c6f"}
1
+ {"version":3,"file":"switchboard-reset-BcQXlcVf.mjs","sources":["../src/services/switchboard-reset.ts"],"sourcesContent":["import { yellow, red, green, cyan } from \"colorette\";\nimport { promises as fs } from \"node:fs\";\n\nexport interface ResetSwitchboardOptions {\n dbPath?: string;\n yes?: boolean;\n}\n\nexport interface ResolvedResetPaths {\n reactorDir: string | null;\n readModelDir: string | null;\n postgresUrl: string | null;\n}\n\nconst CONFIRMATION_TOKEN = \"reset\";\n\nexport function isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\n/**\n * Resolves the on-disk PGlite directories that `--reset` would delete.\n * Mirrors the resolution in apps/switchboard/src/server.mts so we touch the\n * same paths the running switchboard uses. When a Postgres URL is configured\n * the corresponding directory is null and `postgresUrl` is populated so the\n * caller can refuse.\n */\nexport function resolveResetPaths(\n options: ResetSwitchboardOptions,\n env: NodeJS.ProcessEnv = process.env,\n): ResolvedResetPaths {\n const readModelDbPath =\n options.dbPath ?? env.DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;\n const readModelPath = readModelDbPath || \".ph/read-storage\";\n const reactorDbUrl =\n options.dbPath ??\n env.PH_REACTOR_DATABASE_URL ??\n env.PH_SWITCHBOARD_DATABASE_URL;\n const reactorPath = reactorDbUrl || \"./.ph/reactor-storage\";\n\n const reactorIsPostgres = !!reactorDbUrl && isPostgresUrl(reactorDbUrl);\n const readModelIsPostgres =\n !!readModelDbPath && isPostgresUrl(readModelDbPath);\n\n let postgresUrl: string | null = null;\n if (reactorIsPostgres) postgresUrl = reactorDbUrl as string;\n else if (readModelIsPostgres) postgresUrl = readModelDbPath as string;\n\n return {\n reactorDir: reactorIsPostgres ? null : reactorPath,\n readModelDir: readModelIsPostgres ? null : readModelPath,\n postgresUrl,\n };\n}\n\nasync function promptForConfirmation(): Promise<boolean> {\n const enquirer = await import(\"enquirer\");\n try {\n const answer = await enquirer.default.prompt<{ confirmation: string }>({\n type: \"input\",\n name: \"confirmation\",\n message: `Type \"${CONFIRMATION_TOKEN}\" to confirm wiping the local switchboard databases:`,\n });\n return answer.confirmation.trim() === CONFIRMATION_TOKEN;\n } catch {\n return false;\n }\n}\n\nexport async function resetSwitchboardDatabase(\n options: ResetSwitchboardOptions,\n): Promise<void> {\n const paths = resolveResetPaths(options);\n\n if (paths.postgresUrl) {\n console.error(\n red(\n `Refusing to reset: a PostgreSQL URL is configured (${paths.postgresUrl}).`,\n ),\n );\n console.error(\n yellow(\n \"`ph switchboard --reset` only wipes the local PGlite stores. \" +\n \"To reset a Postgres-backed switchboard, drop/recreate the database manually.\",\n ),\n );\n process.exit(1);\n }\n\n const targets = [paths.reactorDir, paths.readModelDir].filter(\n (d): d is string => d !== null,\n );\n\n if (targets.length === 0) {\n console.error(red(\"No local PGlite directories resolved; nothing to do.\"));\n process.exit(1);\n }\n\n console.log(yellow(\"The following directories will be permanently deleted:\"));\n for (const dir of targets) {\n console.log(` - ${dir}`);\n }\n console.log(\n yellow(\n \"This will wipe all local switchboard state. Migrations will re-run on next `ph switchboard`.\",\n ),\n );\n\n let confirmed = false;\n if (options.yes) {\n confirmed = true;\n } else if (isInteractive()) {\n confirmed = await promptForConfirmation();\n } else {\n console.error(\n red(\n \"Refusing to reset in a non-interactive context without --yes. Re-run with --yes to confirm.\",\n ),\n );\n process.exit(1);\n }\n\n if (!confirmed) {\n console.error(red(\"Aborted: confirmation not provided.\"));\n process.exit(1);\n }\n\n for (const dir of targets) {\n await fs.rm(dir, { recursive: true, force: true });\n console.log(cyan(`Removed ${dir}`));\n }\n\n console.log(\n green(\n \"Switchboard local storage reset. Run `ph switchboard` to re-initialize.\",\n ),\n );\n}\n"],"names":["fs"],"mappings":";;;;;AAcA,MAAM,qBAA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IAAI,OAAO,yDAAyD,CAAC;AAC7E,MAAK,MAAM,OAAO,QAChB,SAAQ,IAAI,OAAO,MAAM;AAE3B,SAAQ,IACN,OACE,+FACD,CACF;CAED,IAAI,YAAY;AAChB,KAAI,QAAQ,IACV,aAAY;UACH,eAAe,CACxB,aAAY,MAAM,uBAAuB;MACpC;AACL,UAAQ,MACN,IACE,8FACD,CACF;AACD,UAAQ,KAAK,EAAE;;AAGjB,KAAI,CAAC,WAAW;AACd,UAAQ,MAAM,IAAI,sCAAsC,CAAC;AACzD,UAAQ,KAAK,EAAE;;AAGjB,MAAK,MAAM,OAAO,SAAS;AACzB,QAAMA,SAAG,GAAG,KAAK;GAAE,WAAW;GAAM,OAAO;GAAM,CAAC;AAClD,UAAQ,IAAI,KAAK,WAAW,MAAM,CAAC;;AAGrC,SAAQ,IACN,MACE,0EACD,CACF","debug_id":"6dc443d3-91f6-5215-973e-7898511565eb"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3669863c-cb61-5078-a06d-d6092bf6e05b")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="78c06d69-a52c-5bea-96c7-df0b42c3115e")}catch(e){}}();
3
3
  import path, { dirname } from "node:path";
4
4
  import fs from "node:fs";
5
5
  import crypto from "node:crypto";
@@ -99,7 +99,7 @@ function updatePackagesArray(currentPackages = [], dependencies, task = "install
99
99
  if (isInstall) return [...currentPackages.filter((pkg) => !dependencies.find((dep) => dep.name === pkg.packageName)), ...mappedPackages];
100
100
  return currentPackages.filter((pkg) => !dependencies.map((dep) => dep.name).includes(pkg.packageName));
101
101
  }
102
- function updateConfigFile(dependencies, projectPath, task = "install", provider = "registry", registryUrl) {
102
+ function updateConfigFile(dependencies, projectPath, task = "install", provider = "registry", registryUrl, registryUrlExplicit = false) {
103
103
  const configPath = path.join(projectPath, POWERHOUSE_CONFIG_FILE);
104
104
  if (!fs.existsSync(configPath)) throw new Error(`powerhouse.config.json file not found. projectPath: ${projectPath}`);
105
105
  const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
@@ -107,7 +107,7 @@ function updateConfigFile(dependencies, projectPath, task = "install", provider
107
107
  ...config,
108
108
  packages: updatePackagesArray(config.packages, dependencies, task, provider)
109
109
  };
110
- if (task === "install" && registryUrl && !config.packageRegistryUrl && dependencies.length > 0) updatedConfig.packageRegistryUrl = registryUrl;
110
+ if (task === "install" && registryUrl && (registryUrlExplicit || !config.packageRegistryUrl) && dependencies.length > 0) updatedConfig.packageRegistryUrl = registryUrl;
111
111
  fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));
112
112
  }
113
113
  /**
@@ -161,5 +161,5 @@ function removeStylesImports(dependencies, projectPath) {
161
161
  //#endregion
162
162
  export { generateProjectDriveId as a, isPowerhouseProject as c, updateConfigFile as d, updatePackagesArray as f, findNodeProjectRoot as i, packageManagers as l, POWERHOUSE_GLOBAL_DIR as n, getPackageManagerFromLockfile as o, updateStylesFile as p, defaultPathValidation as r, getProjectInfo as s, POWERHOUSE_CONFIG_FILE as t, removeStylesImports as u };
163
163
 
164
- //# sourceMappingURL=utils-mth8NsDA.mjs.map
165
- //# debugId=3669863c-cb61-5078-a06d-d6092bf6e05b
164
+ //# sourceMappingURL=utils-BaTZlyL3.mjs.map
165
+ //# debugId=78c06d69-a52c-5bea-96c7-df0b42c3115e
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-BaTZlyL3.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path, { dirname } from \"node:path\";\nexport const POWERHOUSE_CONFIG_FILE = \"powerhouse.config.json\";\nexport const POWERHOUSE_GLOBAL_DIR = path.join(homedir(), \".ph\");\nexport const SUPPORTED_PACKAGE_MANAGERS = [\"npm\", \"yarn\", \"pnpm\", \"bun\"];\n\nexport const packageManagers = {\n bun: {\n globalPathRegexp: /[\\\\/].bun[\\\\/]/,\n installCommand: \"bun add {{dependency}}\",\n uninstallCommand: \"bun remove {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"bun.lock\",\n updateCommand: \"bun update {{dependency}}\",\n buildAffected: \"bun run build:affected\",\n },\n pnpm: {\n globalPathRegexp: /[\\\\/]pnpm[\\\\/]/,\n installCommand: \"pnpm add {{dependency}}\",\n uninstallCommand: \"pnpm remove {{dependency}}\",\n workspaceOption: \"--workspace-root\",\n lockfile: \"pnpm-lock.yaml\",\n updateCommand: \"pnpm update {{dependency}}\",\n buildAffected: \"pnpm run build:affected\",\n },\n yarn: {\n globalPathRegexp: /[\\\\/]yarn[\\\\/]/,\n installCommand: \"yarn add {{dependency}}\",\n uninstallCommand: \"yarn remove {{dependency}}\",\n workspaceOption: \"-W\",\n lockfile: \"yarn.lock\",\n updateCommand: \"yarn upgrade {{dependency}}\",\n buildAffected: \"yarn run build:affected\",\n },\n npm: {\n installCommand: \"npm install {{dependency}}\",\n uninstallCommand: \"npm uninstall {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"package-lock.json\",\n updateCommand: \"npm update {{dependency}} --save\",\n buildAffected: \"npm run build:affected\",\n },\n};\n\ntype PathValidation = (dir: string) => boolean;\n\nexport type PackageManager = \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\nexport type ProjectInfo = {\n isGlobal: boolean;\n path: string;\n packageManager: PackageManager;\n};\n\nexport function defaultPathValidation() {\n return true;\n}\n\nexport function isPowerhouseProject(dir: string) {\n const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);\n\n return fs.existsSync(powerhouseConfigPath);\n}\n\nexport function findNodeProjectRoot(\n dir: string,\n pathValidation: PathValidation = defaultPathValidation,\n) {\n const packageJsonPath = path.join(dir, \"package.json\");\n\n if (fs.existsSync(packageJsonPath) && pathValidation(dir)) {\n return dir;\n }\n\n const parentDir = dirname(dir);\n\n if (parentDir === dir) {\n return null;\n }\n\n return findNodeProjectRoot(parentDir, pathValidation);\n}\n\nexport function getProjectInfo(debug?: boolean): ProjectInfo {\n const currentPath = process.cwd();\n\n if (debug) {\n console.log(\">>> currentPath\", currentPath);\n }\n\n const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);\n\n if (!projectPath) {\n return {\n isGlobal: true,\n path: POWERHOUSE_GLOBAL_DIR,\n packageManager: getPackageManagerFromLockfile(POWERHOUSE_GLOBAL_DIR),\n };\n }\n\n return {\n isGlobal: false,\n path: projectPath,\n packageManager: getPackageManagerFromLockfile(projectPath),\n };\n}\n\n/**\n * Generates a unique drive ID based on the project path.\n * The same project path will always generate the same ID.\n * @param name - The name prefix for the drive ID (e.g., \"vetra\", \"powerhouse\")\n * @returns A unique drive ID in the format \"{name}-{hash}\"\n */\nexport function generateProjectDriveId(name: string): string {\n const projectInfo = getProjectInfo();\n const hash = crypto\n .createHash(\"sha256\")\n .update(projectInfo.path)\n .digest(\"hex\");\n const shortHash = hash.substring(0, 8);\n return `${name}-${shortHash}`;\n}\n\nexport function getPackageManagerFromLockfile(dir: string): PackageManager {\n if (fs.existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {\n return \"pnpm\";\n } else if (fs.existsSync(path.join(dir, packageManagers.yarn.lockfile))) {\n return \"yarn\";\n } else if (fs.existsSync(path.join(dir, packageManagers.bun.lockfile))) {\n return \"bun\";\n }\n\n return \"npm\";\n}\n\nexport function updatePackagesArray(\n currentPackages: PowerhouseConfig[\"packages\"] = [],\n dependencies: { name: string; version: string | undefined }[],\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n): PowerhouseConfig[\"packages\"] {\n const isInstall = task === \"install\";\n const mappedPackages = dependencies.map((dep) => ({\n packageName: dep.name,\n version: dep.version,\n provider,\n }));\n\n if (isInstall) {\n // Overwrite existing package if version is different\n const filteredPackages = currentPackages.filter(\n (pkg) => !dependencies.find((dep) => dep.name === pkg.packageName),\n );\n return [...filteredPackages, ...mappedPackages];\n }\n\n return currentPackages.filter(\n (pkg) => !dependencies.map((dep) => dep.name).includes(pkg.packageName),\n );\n}\n\n// Modify updateConfigFile to use the new function\nexport function updateConfigFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n registryUrl?: string,\n registryUrlExplicit = false,\n) {\n const configPath = path.join(projectPath, POWERHOUSE_CONFIG_FILE);\n\n if (!fs.existsSync(configPath)) {\n throw new Error(\n `powerhouse.config.json file not found. projectPath: ${projectPath}`,\n );\n }\n\n const config = JSON.parse(\n fs.readFileSync(configPath, \"utf-8\"),\n ) as PowerhouseConfig;\n\n const updatedConfig: PowerhouseConfig = {\n ...config,\n packages: updatePackagesArray(\n config.packages,\n dependencies,\n task,\n provider,\n ),\n };\n\n if (\n task === \"install\" &&\n registryUrl &&\n (registryUrlExplicit || !config.packageRegistryUrl) &&\n dependencies.length > 0\n ) {\n updatedConfig.packageRegistryUrl = registryUrl;\n }\n\n fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));\n}\n\n/**\n * Recursively searches for a specific file by traversing up the directory tree.\n * Starting from the given path, it checks each parent directory until it finds\n * the target file or reaches the root directory.\n *\n * @param startPath - The absolute path of the directory to start searching from\n * @param targetFile - The name of the file to search for (e.g., 'package.json', 'pnpm-workspace.yaml')\n * @returns The absolute path of the directory containing the target file, or null if not found\n *\n * @example\n * // Find the workspace root directory\n * const workspaceRoot = findContainerDirectory('/path/to/project/src', 'pnpm-workspace.yaml');\n *\n * // Find the nearest package.json\n * const packageDir = findContainerDirectory('/path/to/project/src/components', 'package.json');\n */\nexport const findContainerDirectory = (\n startPath: string,\n targetFile: string,\n): string | null => {\n const filePath = path.join(startPath, targetFile);\n\n if (fs.existsSync(filePath)) {\n return startPath;\n }\n\n const parentDir = path.dirname(startPath);\n\n //reached the root directory and haven't found the file\n if (parentDir === startPath) {\n return null;\n }\n\n return findContainerDirectory(parentDir, targetFile);\n};\n\n/**\n * Updates the styles.css file to include imports for newly installed packages\n * @param dependencies - Array of dependencies that were installed\n * @param projectPath - Path to the project root\n */\nexport function updateStylesFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const fullCssPath = path.join(projectPath, cssPath);\n const importStatement = `@import '${cssPath}';`;\n\n // Check if the CSS file exists\n if (!fs.existsSync(fullCssPath)) {\n console.warn(`⚠️ Warning: CSS file not found at ${cssPath}`);\n continue;\n }\n\n // Check if import already exists\n if (currentStyles.includes(importStatement)) {\n continue;\n }\n\n // Find the last @import statement\n const importLines = currentStyles\n .split(\"\\n\")\n .filter((line) => line.trim().startsWith(\"@import\"));\n const lastImport = importLines[importLines.length - 1];\n\n if (lastImport) {\n // Insert new import after the last existing import\n updatedStyles = currentStyles.replace(\n lastImport,\n `${lastImport}\\n${importStatement}`,\n );\n } else {\n // If no imports exist, add at the top of the file\n updatedStyles = `${importStatement}\\n${currentStyles}`;\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n\n/**\n * Removes CSS imports for uninstalled packages from styles.css\n */\nexport function removeStylesImports(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const importStatement = `@import '${cssPath}';`;\n\n // Remove the import line if it exists\n const lines = updatedStyles.split(\"\\n\");\n const filteredLines = lines.filter(\n (line) => !line.trim().includes(importStatement),\n );\n\n if (filteredLines.length !== lines.length) {\n updatedStyles = filteredLines.join(\"\\n\");\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAKA,MAAa,yBAAyB;AACtC,MAAa,wBAAwB,KAAK,KAAK,SAAS,EAAE,MAAM;AAGhE,MAAa,kBAAkB;CAC7B,KAAK;EACH,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,KAAK;EACH,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACF;AAYD,SAAgB,wBAAwB;AACtC,QAAO;;AAGT,SAAgB,oBAAoB,KAAa;CAC/C,MAAM,uBAAuB,KAAK,KAAK,KAAK,uBAAuB;AAEnE,QAAO,GAAG,WAAW,qBAAqB;;AAG5C,SAAgB,oBACd,KACA,iBAAiC,uBACjC;CACA,MAAM,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Y,YAAY,SAAS;AAEpD,MAAI,WAEF,iBAAgB,cAAc,QAC5B,YACA,GAAG,WAAW,IAAI,kBACnB;MAGD,iBAAgB,GAAG,gBAAgB,IAAI;;AAK3C,KAAI,kBAAkB,cACpB,IAAG,cAAc,YAAY,cAAc;;;;;AAO/C,SAAgB,oBACd,cACA,aACA;CACA,MAAM,aAAa,KAAK,KAAK,aAAa,YAAY;AAGtD,KAAI,CAAC,GAAG,WAAW,WAAW,EAAE;AAC9B,UAAQ,KAAK,uDAAuD;AACpE;;CAGF,MAAM,gBAAgB,GAAG,aAAa,YAAY,QAAQ;CAC1D,IAAI,gBAAgB;AAEpB,MAAK,MAAM,OAAO,cAAc;EAE9B,MAAM,kBAAkB,YADR,kBAAkB,IAAI,KAAK,iBACC;EAG5C,MAAM,QAAQ,cAAc,MAAM,KAAK;EACvC,MAAM,gBAAgB,MAAM,QACzB,SAAS,CAAC,KAAK,MAAM,CAAC,SAAS,gBAAgB,CACjD;AAED,MAAI,cAAc,WAAW,MAAM,OACjC,iBAAgB,cAAc,KAAK,KAAK;;AAK5C,KAAI,kBAAkB,cACpB,IAAG,cAAc,YAAY,cAAc","debug_id":"78c06d69-a52c-5bea-96c7-df0b42c3115e"}
@@ -1,4 +1,4 @@
1
- import { d as updateConfigFile, p as updateStylesFile, u as removeStylesImports } from "./utils-mth8NsDA.mjs";
1
+ import { d as updateConfigFile, p as updateStylesFile, u as removeStylesImports } from "./utils-BaTZlyL3.mjs";
2
2
  export { removeStylesImports, updateConfigFile, updateStylesFile };
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]="3d7f3fa3-6649-5585-bcb4-e764a14abfbd")}catch(e){}}();
4
- //# debugId=3d7f3fa3-6649-5585-bcb4-e764a14abfbd
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]="08292df2-191b-515a-94a1-4ba124a2296c")}catch(e){}}();
4
+ //# debugId=08292df2-191b-515a-94a1-4ba124a2296c
@@ -1,9 +1,9 @@
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]="df0f8142-c3a0-519e-96b4-ba20ca0556da")}catch(e){}}();
3
- import "./assign-env-vars-W-lZmdMi.mjs";
4
- import { t as runConnectStudio } from "./connect-studio-DTdSFftL.mjs";
5
- import { a as generateProjectDriveId } from "./utils-mth8NsDA.mjs";
6
- import { n as startSwitchboard$1 } from "./switchboard-CERuSM8r.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cda752c2-96df-5599-bdff-a952ddefbf70")}catch(e){}}();
3
+ import { a as parseDefaultDrivesUrl } from "./cli-connect-override-DHpuwyEn.mjs";
4
+ import { t as runConnectStudio } from "./connect-studio-BbxxxUZ9.mjs";
5
+ import { a as generateProjectDriveId } from "./utils-BaTZlyL3.mjs";
6
+ import { n as startSwitchboard$1 } from "./switchboard-CJMoMzWx.mjs";
7
7
  import { execSync } from "node:child_process";
8
8
  import { blue, green, red, yellow } from "colorette";
9
9
  import { createLogger } from "vite";
@@ -398,10 +398,12 @@ async function startVetra(args) {
398
398
  console.log();
399
399
  console.log(green(`Vetra Connect: http://localhost:${connectPort}`));
400
400
  const customViteLogger = createViteLogger(green);
401
+ const vetraDrivesOverride = { drives: {
402
+ defaultDrives: parseDefaultDrivesUrl(previewDriveUrl ? [driveUrl, previewDriveUrl].join(",") : driveUrl),
403
+ preserveStrategy: "preserve-all"
404
+ } };
401
405
  await runConnectStudio({
402
406
  ...args,
403
- defaultDrivesUrl: previewDriveUrl ? [driveUrl, previewDriveUrl].join(",") : driveUrl,
404
- drivesPreserveStrategy: "preserve-all",
405
407
  port: connectPort,
406
408
  disableLocalPackages,
407
409
  debug,
@@ -412,7 +414,7 @@ async function startVetra(args) {
412
414
  printUrls,
413
415
  bindCLIShortcuts,
414
416
  watchTimeout
415
- }, customViteLogger);
417
+ }, customViteLogger, vetraDrivesOverride);
416
418
  }
417
419
  } catch (error) {
418
420
  console.error(error);
@@ -421,5 +423,5 @@ async function startVetra(args) {
421
423
  //#endregion
422
424
  export { startVetra };
423
425
 
424
- //# sourceMappingURL=vetra-BgmlqLmN.mjs.map
425
- //# debugId=df0f8142-c3a0-519e-96b4-ba20ca0556da
426
+ //# sourceMappingURL=vetra-DjsGCr0t.mjs.map
427
+ //# debugId=cda752c2-96df-5599-bdff-a952ddefbf70
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vetra-DjsGCr0t.mjs","sources":["../src/utils/configure-vetra-github-url.ts","../src/utils/resolve-switchboard-port.ts","../src/services/vetra.ts"],"sourcesContent":["import {\n createVetraDocument,\n getVetraDocuments,\n setPackageGithubUrl,\n} from \"@powerhousedao/common/utils\";\nimport { red } from \"colorette\";\nimport { execSync } from \"node:child_process\";\nimport { createInterface } from \"node:readline\";\n\n/**\n * Get git remote URL (origin)\n * @returns Git remote URL or null if not configured\n */\nfunction getGitRemoteUrl(): string | null {\n try {\n const url = execSync(\"git remote get-url origin\", {\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim();\n return url || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Prompt user to enter a custom GitHub URL\n */\nasync function promptForCustomUrl(): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(\"\\nEnter GitHub URL (or press Enter to skip): \");\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const url = answer.trim();\n resolve(url || null);\n });\n });\n}\n\n/**\n * Prompt yes/no question\n */\nasync function promptYesNo(question: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(`\\n${question} (y/n): `);\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const response = answer.trim().toLowerCase();\n resolve(response === \"y\" || response === \"yes\");\n });\n });\n}\n\n/**\n * Prompt user to select or enter GitHub URL\n * @param gitRemoteUrl - Git remote URL if available\n * @returns Selected URL or null if skipped\n */\nasync function promptForGithubUrl(\n gitRemoteUrl: string | null,\n): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n console.log(\"\\n\" + \"=\".repeat(50));\n console.log(\"🔍 Vetra Package Configuration\");\n console.log(\"=\".repeat(50));\n console.log(\n \"\\nWe detected a Vetra package document in your remote drive without a GitHub URL configured.\",\n );\n console.log(\"\\nWould you like to configure the GitHub URL now?\");\n\n if (gitRemoteUrl) {\n console.log(`\\nGit remote URL detected: ${gitRemoteUrl}`);\n console.log(\"\\nOptions:\");\n console.log(\"1. Use detected URL\");\n console.log(\"2. Enter a different URL\");\n console.log(\"3. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-3): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n resolve(gitRemoteUrl);\n } else if (choice === \"2\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"3\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-3): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n } else {\n console.log(\"\\nNo git remote URL detected.\");\n console.log(\"\\nOptions:\");\n console.log(\"1. Enter GitHub URL manually\");\n console.log(\"2. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-2): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"2\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-2): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n }\n });\n}\n\n/**\n * Set git remote URL (origin)\n */\nfunction setGitRemoteUrl(url: string): void {\n try {\n execSync(`git remote add origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin set to: ${url}`);\n } catch {\n try {\n execSync(`git remote set-url origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin updated to: ${url}`);\n } catch {\n console.error(red(`❌ Failed to set git remote URL`));\n }\n }\n}\n\n/**\n * Validates documents and returns the target document to use\n * Warns if multiple documents found\n */\nfunction validateAndSelectDocument<T>(documents: T[]): T | null {\n if (documents.length === 0) {\n return null;\n }\n\n if (documents.length > 1) {\n console.warn(\n `⚠️ Warning: Multiple Vetra documents found (${documents.length}). Using first document.`,\n );\n }\n\n return documents[0];\n}\n\nasync function applyGithubUrlConfiguration(\n graphqlEndpoint: string,\n vetraDriveId: string,\n documentId: string,\n selectedUrl: string,\n shouldSetRemote: boolean,\n): Promise<void> {\n // Set package GitHub URL\n await setPackageGithubUrl(\n graphqlEndpoint,\n vetraDriveId,\n documentId,\n selectedUrl,\n );\n\n console.log(`✅ GitHub URL configured: ${selectedUrl}`);\n\n // Set git remote URL if requested\n if (shouldSetRemote) {\n setGitRemoteUrl(selectedUrl);\n }\n}\n\nfunction logVerbose(message: string, verbose?: boolean): void {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sleep for a specified number of milliseconds\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Configure GitHub URL for Vetra documents\n * @param switchboardPort - Port where switchboard is running\n * @param vetraDriveUrl - Remote drive URL\n * @param verbose - Enable verbose logging\n */\nexport async function configureVetraGithubUrl(\n switchboardPort: number,\n vetraDriveUrl: string,\n verbose?: boolean,\n): Promise<void> {\n logVerbose(\"Checking GitHub URL configuration...\", verbose);\n\n try {\n const graphqlEndpoint = `http://localhost:${switchboardPort}/graphql`;\n const vetraDriveId = vetraDriveUrl.split(\"/\").pop();\n if (!vetraDriveId) {\n throw new Error(\"Invalid vetraDriveUrl: unable to extract drive ID\");\n }\n\n const documents = await getVetraDocuments(graphqlEndpoint, vetraDriveId);\n\n // Skip if already configured\n if (documents.some((doc) => doc.githubUrl)) {\n logVerbose(\"GitHub URL already configured, skipping setup\", verbose);\n return;\n }\n\n // Get or create target document\n let targetDocumentId: string;\n const targetDocument = validateAndSelectDocument(documents);\n\n // Collect user input\n const gitRemoteUrl = getGitRemoteUrl();\n const selectedUrl = await promptForGithubUrl(gitRemoteUrl);\n\n if (!selectedUrl) {\n logVerbose(\"GitHub URL configuration skipped\", verbose);\n return;\n }\n\n let shouldSetRemote = false;\n if (selectedUrl !== gitRemoteUrl && !gitRemoteUrl) {\n shouldSetRemote = await promptYesNo(\"Set this as your git remote URL?\");\n }\n\n if (!targetDocument) {\n logVerbose(\"No Vetra documents found, creating new document...\", verbose);\n\n targetDocumentId = await createVetraDocument(\n graphqlEndpoint,\n vetraDriveId,\n \"vetra-package\",\n );\n\n logVerbose(`Created new document: ${targetDocumentId}`, verbose);\n } else {\n targetDocumentId = targetDocument.id;\n }\n\n await applyGithubUrlConfiguration(\n graphqlEndpoint,\n vetraDriveId,\n targetDocumentId,\n selectedUrl,\n shouldSetRemote,\n );\n } catch (error) {\n console.error(\n red(\n `⚠️ GitHub URL configuration failed: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n logVerbose(String(error), verbose);\n }\n}\n","import { isPortAvailable } from \"@powerhousedao/switchboard/server\";\nimport { yellow } from \"colorette\";\n\nconst MAX_FALLBACK_ATTEMPTS = 20;\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\nasync function findFreePort(start: number): Promise<number | null> {\n for (let i = 0; i < MAX_FALLBACK_ATTEMPTS; i++) {\n const candidate = start + i;\n if (await isPortAvailable(candidate)) return candidate;\n }\n return null;\n}\n\n/**\n * Resolve the port switchboard should bind to. If the requested port is free,\n * returns it unchanged. If it's in use, walks forward for the next free port\n * and — in an interactive terminal — asks the user to confirm the fallback.\n * In CI / piped contexts the fallback is applied automatically so scripts\n * don't hang on an unanswered prompt.\n *\n * Throws a process.exit(1) when the user declines the prompt or when no free\n * port is available in the search window.\n */\nexport async function resolveSwitchboardPort(\n requested: number,\n): Promise<number> {\n if (await isPortAvailable(requested)) return requested;\n\n const candidate = await findFreePort(requested + 1);\n if (candidate === null) {\n console.error(\n `Port ${requested} is in use and no free port was found in the range ${requested}-${requested + MAX_FALLBACK_ATTEMPTS - 1}.`,\n );\n process.exit(1);\n }\n\n if (!isInteractive()) {\n console.log(\n yellow(\n `Port ${requested} is in use. Falling back to port ${candidate} (non-interactive; skipping confirmation).`,\n ),\n );\n return candidate;\n }\n\n const enquirer = await import(\"enquirer\");\n\n let confirmed: boolean;\n try {\n const answer = await enquirer.default.prompt<{ confirmed: boolean }>({\n type: \"confirm\",\n name: \"confirmed\",\n message: `Port ${requested} is in use. Use port ${candidate} instead?`,\n initial: true,\n });\n confirmed = answer.confirmed;\n } catch {\n // user aborted the prompt (Ctrl-C); treat as decline\n confirmed = false;\n }\n\n if (!confirmed) {\n console.error(\n `Aborted. Free port ${requested} or pass --switchboard-port <port> to choose a different port.`,\n );\n process.exit(1);\n }\n\n return candidate;\n}\n","import type { VetraProcessorConfigType } from \"@powerhousedao/config\";\nimport { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport type { IReactorClient } from \"@powerhousedao/reactor\";\nimport { addDefaultDrive } from \"@powerhousedao/switchboard/utils\";\nimport { blue, green, red, yellow, type Color } from \"colorette\";\nimport type { ILogger } from \"document-model\";\nimport { childLogger, setLogLevel } from \"document-model\";\nimport { createLogger } from \"vite\";\nimport type { VetraArgs } from \"../types.js\";\nimport { generateProjectDriveId } from \"../utils.js\";\nimport {\n configureVetraGithubUrl,\n sleep,\n} from \"../utils/configure-vetra-github-url.js\";\nimport { parseDefaultDrivesUrl } from \"../utils/parse-default-drives.js\";\nimport { resolveSwitchboardPort } from \"../utils/resolve-switchboard-port.js\";\nimport { runConnectStudio } from \"./connect-studio.js\";\nimport { startSwitchboard } from \"./switchboard.js\";\n\nconst VETRA_DRIVE_NAME = \"vetra\";\n\nconst getDefaultVetraUrl = (port: number) =>\n `http://localhost:${port}/d/${generateProjectDriveId(VETRA_DRIVE_NAME)}`;\n\nconst getDriveId = (driveUrl: string | undefined): string =>\n driveUrl?.split(\"/\").pop() ?? generateProjectDriveId(VETRA_DRIVE_NAME);\n\nfunction createViteLogger(color: Color) {\n const customLogger = createLogger(\"info\");\n const loggerInfo = customLogger.info.bind(customLogger);\n customLogger.info = (msg, options) => {\n loggerInfo(color(msg), options);\n };\n const loggerWarn = customLogger.warn.bind(customLogger);\n customLogger.warn = (msg, options) => {\n loggerWarn(yellow(msg), options);\n };\n const loggerError = customLogger.error.bind(customLogger);\n customLogger.error = (msg, options) => {\n loggerError(red(msg), options);\n };\n\n const loggerWarnOnce = customLogger.warnOnce.bind(customLogger);\n customLogger.warnOnce = (msg, options) => {\n loggerWarnOnce(yellow(msg), options);\n };\n return customLogger;\n}\n\nasync function startVetraPreviewDrive(\n reactor: IReactorClient,\n port: number,\n verbose?: boolean,\n): Promise<string> {\n const previewDriveId = generateProjectDriveId(\"preview\");\n\n const previewDrive = {\n id: previewDriveId,\n slug: previewDriveId,\n global: {\n name: \"Vetra Preview\",\n icon: \"https://azure-elderly-tortoise-212.mypinata.cloud/ipfs/bafkreifddkbopiyvcirf7vaqar74th424r5phlxkdxniirdyg3qgu2ajha\",\n nodes: [],\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\" as const,\n triggers: [],\n },\n };\n\n const driveUrl = await addDefaultDrive(reactor, previewDrive, port);\n\n if (verbose) {\n console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));\n }\n return driveUrl;\n}\nasync function startLocalVetraSwitchboard(args: VetraArgs, logger?: ILogger) {\n const {\n connectPort,\n switchboardPort,\n dev,\n packages,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n remoteDrive,\n interactive,\n watch,\n verbose,\n } = args;\n\n // Convert single remote drive to array if provided\n const remoteDrives = remoteDrive ? [remoteDrive] : [];\n\n const vetraProcessorConfig: VetraProcessorConfigType = {\n interactive,\n driveUrl: remoteDrive ?? getDefaultVetraUrl(connectPort),\n driveId: getDriveId(remoteDrive),\n };\n\n const processorConfig = new Map<string, unknown>();\n processorConfig.set(VETRA_PROCESSOR_CONFIG_KEY, vetraProcessorConfig);\n\n const vetraDriveId = generateProjectDriveId(VETRA_DRIVE_NAME);\n\n // When the user didn't opt into strict-port semantics, check for a port\n // conflict up front and ask for confirmation before binding a fallback.\n // Doing this in the CLI layer keeps the interactive prompt out of the\n // switchboard server package and aligns with the existing prerelease-tag\n // confirmation flow in `ph publish`.\n const resolvedSwitchboardPort = args.strictPort\n ? switchboardPort\n : await resolveSwitchboardPort(switchboardPort);\n\n try {\n const switchboard = await startSwitchboard(\n {\n ...args,\n useVetraDrive: true, // Use Vetra drive instead of Powerhouse drive\n mcp: true,\n port: resolvedSwitchboardPort,\n // We've already probed and (when interactive) confirmed the port with\n // the user, so keep the server from running its own fallback on top.\n strictPort: true,\n dev,\n packages,\n remoteDrives,\n vetraDriveId,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n processorConfig,\n basePath: undefined,\n keypairPath: undefined,\n dbPath: args.dbPath,\n useIdentity: undefined,\n migrate: undefined,\n migrateStatus: undefined,\n reset: undefined,\n yes: undefined,\n requireIdentity: undefined,\n },\n logger,\n );\n\n const actualSwitchboardPort = switchboard.port;\n\n // Add preview drive (only in watch mode)\n let previewDriveUrl: string | null = null;\n if (watch) {\n try {\n previewDriveUrl = await startVetraPreviewDrive(\n switchboard.reactor,\n actualSwitchboardPort,\n verbose,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n if (verbose) {\n console.log(blue(`Vetra Switchboard: Started successfully`));\n if (remoteDrive) {\n console.log(\n blue(`Vetra Switchboard: Syncing with remote drive: ${remoteDrive}`),\n );\n }\n } else {\n console.log();\n console.log(\n blue(\n `Vetra Switchboard: http://localhost:${actualSwitchboardPort}/graphql`,\n ),\n );\n console.log(blue(` ➜ Drive URL: ${switchboard.defaultDriveUrl}`));\n if (previewDriveUrl) {\n console.log(blue(` ➜ Preview Drive URL: ${previewDriveUrl}`));\n }\n }\n return {\n driveUrl: switchboard.defaultDriveUrl || \"\",\n previewDriveUrl: previewDriveUrl,\n switchboardPort: actualSwitchboardPort,\n };\n } catch (error) {\n console.error(\n red(\n `Vetra Switchboard: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n throw error instanceof Error ? error : new Error(String(error));\n }\n}\n\nexport async function startVetra(args: VetraArgs) {\n const {\n connectPort,\n verbose,\n remoteDrive,\n disableConnect,\n debug,\n httpsCertFile,\n httpsKeyFile,\n disableLocalPackages,\n host,\n open,\n cors,\n strictPort,\n printUrls,\n bindCLIShortcuts,\n watchTimeout,\n } = args;\n\n const switchboardLogger = childLogger([\"vetra\", \"switchboard\"]);\n\n try {\n // Set default log level to info if not already specified\n if (!process.env.LOG_LEVEL) {\n setLogLevel(\"info\");\n }\n\n if (verbose) {\n switchboardLogger.info(\"Starting Vetra Switchboard...\");\n if (remoteDrive) {\n const source = remoteDrive\n ? \"command line argument\"\n : \"powerhouse.config.json\";\n switchboardLogger.info(`Using vetraUrl from ${source}: ${remoteDrive}`);\n }\n }\n const switchboardResult = await startLocalVetraSwitchboard(\n {\n ...args,\n dev: true, // Vetra always runs in dev mode to load local packages\n httpsKeyFile,\n httpsCertFile,\n disableLocalPackages,\n debug,\n },\n switchboardLogger,\n );\n const driveUrl: string = switchboardResult.driveUrl || remoteDrive || \"\";\n const previewDriveUrl = switchboardResult.previewDriveUrl;\n const actualSwitchboardPort = switchboardResult.switchboardPort;\n\n // Configure GitHub URL if remote drive is set\n if (remoteDrive) {\n // give some time for the drive to process initial strands\n await sleep(3000);\n\n await configureVetraGithubUrl(\n actualSwitchboardPort,\n remoteDrive,\n verbose,\n );\n\n // give some time for the user to read log messages\n await sleep(2000);\n }\n\n if (verbose) {\n console.log(\"Starting Codegen Reactor...\");\n }\n\n // Start Connect pointing to the drive (unless disabled)\n if (!disableConnect) {\n if (verbose) {\n console.log(\"Starting Connect...\");\n const drives = previewDriveUrl\n ? `${driveUrl}, ${previewDriveUrl}`\n : driveUrl;\n console.log(` ➜ Connect will use drives: ${drives}`);\n }\n console.log();\n console.log(green(`Vetra Connect: http://localhost:${connectPort}`));\n\n const customViteLogger = createViteLogger(green);\n\n // Programmatic override forwarded to the Connect runtime config —\n // vetra always sets these regardless of what the user typed on the\n // command line. We pass it as the explicit third arg to\n // runConnectStudio so it survives the `wasFlagExplicitlyPassed`\n // gating (the user didn't pass --default-drives-url; vetra is setting\n // it itself).\n const vetraDrivesOverride = {\n drives: {\n defaultDrives: parseDefaultDrivesUrl(\n previewDriveUrl ? [driveUrl, previewDriveUrl].join(\",\") : driveUrl,\n ),\n preserveStrategy: \"preserve-all\" as const,\n },\n };\n\n await runConnectStudio(\n {\n ...args,\n port: connectPort,\n disableLocalPackages,\n debug,\n host: host,\n open: open,\n cors: cors,\n strictPort: strictPort,\n printUrls: printUrls,\n bindCLIShortcuts: bindCLIShortcuts,\n watchTimeout: watchTimeout,\n },\n customViteLogger,\n vetraDrivesOverride,\n );\n }\n } catch (error) {\n console.error(error);\n }\n}\n"],"names":["startSwitchboard"],"mappings":";;;;;;;;;;;;;;;;;;;;AAaA,SAAS,kBAAiC;AACxC,KAAI;AAKF,SAJY,SAAS,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ACf,MAAM,SAAS,cACX,0BACA;AACJ,sBAAkB,KAAK,uBAAuB,OAAO,IAAI,cAAc;;;EAG3E,MAAM,oBAAoB,MAAM,2BAC9B;GACE,GAAG;GACH,KAAK;GACL;GACA;GACA;GACA;GACD,EACD,kBACD;EACD,MAAM,WAAmB,kBAAkB,YAAY,eAAe;EACtE,MAAM,kBAAkB,kBAAkB;EAC1C,MAAM,wBAAwB,kBAAkB;AAGhD,MAAI,aAAa;AAEf,SAAM,MAAM,IAAK;AAEjB,SAAM,wBACJ,uBACA,aACA,QACD;AAGD,SAAM,MAAM,IAAK;;AAGnB,MAAI,QACF,SAAQ,IAAI,8BAA8B;AAI5C,MAAI,CAAC,gBAAgB;AACnB,OAAI,SAAS;AACX,YAAQ,IAAI,sBAAsB;IAClC,MAAM,SAAS,kBACX,GAAG,SAAS,IAAI,oBAChB;AACJ,YAAQ,IAAI,iCAAiC,SAAS;;AAExD,WAAQ,KAAK;AACb,WAAQ,IAAI,MAAM,mCAAmC,cAAc,CAAC;GAEpE,MAAM,mBAAmB,iBAAiB,MAAM;GAQhD,MAAM,sBAAsB,EAC1B,QAAQ;IACN,eAAe,sBACb,kBAAkB,CAAC,UAAU,gBAAgB,CAAC,KAAK,IAAI,GAAG,SAC3D;IACD,kBAAkB;IACnB,EACF;AAED,SAAM,iBACJ;IACE,GAAG;IACH,MAAM;IACN;IACA;IACM;IACA;IACA;IACM;IACD;IACO;IACJ;IACf,EACD,kBACA,oBACD;;UAEI,OAAO;AACd,UAAQ,MAAM,MAAM","debug_id":"cda752c2-96df-5599-bdff-a952ddefbf70"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-cli",
3
- "version": "6.1.0",
3
+ "version": "6.2.0-dev.0",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -25,6 +25,7 @@
25
25
  "dependencies": {
26
26
  "@sentry/node-core": "^10.52.0",
27
27
  "@tsdown/css": "0.21.1",
28
+ "ajv": "^8.18.0",
28
29
  "chalk": "5.6.2",
29
30
  "change-case": "5.4.4",
30
31
  "cmd-ts": "0.15.0",
@@ -34,20 +35,21 @@
34
35
  "package-manager-detector": "1.6.0",
35
36
  "pg": "8.18.0",
36
37
  "read-pkg": "10.1.0",
38
+ "remeda": "2.33.7",
37
39
  "rolldown": "1.0.0-rc.8",
38
40
  "semver": "7.7.4",
39
41
  "tsdown": "0.21.1",
40
42
  "vite": "8.0.8",
41
- "@powerhousedao/builder-tools": "6.1.0",
42
- "@powerhousedao/codegen": "6.1.0",
43
- "@powerhousedao/reactor": "6.1.0",
44
- "@powerhousedao/common": "6.1.0",
45
- "@powerhousedao/config": "6.1.0",
46
- "@powerhousedao/switchboard": "6.1.0",
47
- "@powerhousedao/vetra": "6.1.0",
48
- "@renown/sdk": "6.1.0",
49
- "document-model": "6.1.0",
50
- "@powerhousedao/shared": "6.1.0"
43
+ "@powerhousedao/builder-tools": "6.2.0-dev.0",
44
+ "@powerhousedao/codegen": "6.2.0-dev.0",
45
+ "@powerhousedao/reactor": "6.2.0-dev.0",
46
+ "@powerhousedao/common": "6.2.0-dev.0",
47
+ "@powerhousedao/config": "6.2.0-dev.0",
48
+ "@powerhousedao/shared": "6.2.0-dev.0",
49
+ "@powerhousedao/vetra": "6.2.0-dev.0",
50
+ "@powerhousedao/switchboard": "6.2.0-dev.0",
51
+ "document-model": "6.2.0-dev.0",
52
+ "@renown/sdk": "6.2.0-dev.0"
51
53
  },
52
54
  "devDependencies": {
53
55
  "@types/node": "25.2.3",
@@ -1,18 +0,0 @@
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]="e6c672ee-7a94-535f-b5ce-fb652d96e061")}catch(e){}}();
3
- import { setConnectEnv } from "@powerhousedao/shared/connect";
4
- //#region src/utils/assign-env-vars.ts
5
- function assignEnvVars(args) {
6
- const { connectBasePath, defaultDrivesUrl, drivesPreserveStrategy, disableLocalPackages } = args;
7
- setConnectEnv({
8
- PH_CONNECT_BASE_PATH: connectBasePath,
9
- PH_CONNECT_DEFAULT_DRIVES_URL: defaultDrivesUrl,
10
- PH_CONNECT_DRIVES_PRESERVE_STRATEGY: drivesPreserveStrategy,
11
- PH_DISABLE_LOCAL_PACKAGE: disableLocalPackages
12
- });
13
- }
14
- //#endregion
15
- export { assignEnvVars as t };
16
-
17
- //# sourceMappingURL=assign-env-vars-W-lZmdMi.mjs.map
18
- //# debugId=e6c672ee-7a94-535f-b5ce-fb652d96e061
@@ -1 +0,0 @@
1
- {"version":3,"file":"assign-env-vars-W-lZmdMi.mjs","sources":["../src/utils/assign-env-vars.ts"],"sourcesContent":["import type {\n ConnectBuildArgs,\n ConnectPreviewArgs,\n ConnectStudioArgs,\n} from \"../types.js\";\nimport { setConnectEnv } from \"@powerhousedao/shared/connect\";\n\nexport function assignEnvVars(\n args: ConnectBuildArgs | ConnectPreviewArgs | ConnectStudioArgs,\n) {\n const {\n connectBasePath,\n defaultDrivesUrl,\n drivesPreserveStrategy,\n disableLocalPackages,\n } = args;\n\n setConnectEnv({\n PH_CONNECT_BASE_PATH: connectBasePath,\n PH_CONNECT_DEFAULT_DRIVES_URL: defaultDrivesUrl,\n PH_CONNECT_DRIVES_PRESERVE_STRATEGY: drivesPreserveStrategy,\n PH_DISABLE_LOCAL_PACKAGE: disableLocalPackages,\n });\n}\n"],"names":[],"mappings":";;;;AAOA,SAAgB,cACd,MACA;CACA,MAAM,EACJ,iBACA,kBACA,wBACA,yBACE;AAEJ,eAAc;EACZ,sBAAsB;EACtB,+BAA+B;EAC/B,qCAAqC;EACrC,0BAA0B;EAC3B,CAAC","debug_id":"e6c672ee-7a94-535f-b5ce-fb652d96e061"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect-build-DA5QOP5h.mjs","sources":["../src/services/connect-build.ts"],"sourcesContent":["import { getConnectBaseViteConfig } from \"@powerhousedao/builder-tools\";\nimport { getConfig } from \"@powerhousedao/shared/clis\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { InlineConfig } from \"vite\";\nimport { build, mergeConfig } from \"vite\";\nimport type { ConnectBuildArgs } from \"../types.js\";\nimport { assignEnvVars } from \"../utils/assign-env-vars.js\";\nimport { runBuild } from \"./build.js\";\n\nexport async function runConnectBuild(args: ConnectBuildArgs) {\n const { outDir, debug } = args;\n assignEnvVars(args);\n\n const mode = \"production\";\n const dirname = process.cwd();\n\n // Fail fast if any package marked as provider: \"local\" is missing from\n // node_modules — the Vite plugin that bundles them needs them on disk.\n assertLocalPackagesInstalled(dirname);\n\n await runBuild({\n outDir: \"dist\",\n debug,\n });\n\n const baseConfig = getConnectBaseViteConfig({\n mode,\n dirname,\n });\n\n const buildConfig: InlineConfig = {\n build: {\n outDir,\n },\n };\n\n const config = mergeConfig(baseConfig, buildConfig);\n\n await build(config);\n}\n\nfunction assertLocalPackagesInstalled(projectPath: string) {\n const config = getConfig(join(projectPath, \"powerhouse.config.json\"));\n const localPackages = (config.packages ?? []).filter(\n (p) => p.provider === \"local\",\n );\n if (localPackages.length === 0) return;\n\n const missing = localPackages.filter(\n (p) =>\n !existsSync(\n join(projectPath, \"node_modules\", p.packageName, \"package.json\"),\n ),\n );\n if (missing.length === 0) return;\n\n const names = missing.map((p) => p.packageName);\n throw new Error(\n `ph connect build requires these packages to be installed in node_modules (they are declared with provider: \"local\" in powerhouse.config.json):\\n` +\n names.map((n) => ` - ${n}`).join(\"\\n\") +\n `\\n\\nInstall them with:\\n ph install --local ${names.join(\" \")}`,\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AAUA,eAAsB,gBAAgB,MAAwB;CAC5D,MAAM,EAAE,QAAQ,UAAU;AAC1B,eAAc,KAAK;CAEnB,MAAM,OAAO;CACb,MAAM,UAAU,QAAQ,KAAK;AAI7B,8BAA6B,QAAQ;AAErC,OAAM,SAAS;EACb,QAAQ;EACR;EACD,CAAC;AAeF,OAAM,MAFS,YAXI,yBAAyB;EAC1C;EACA;EACD,CAAC,EAEgC,EAChC,OAAO,EACL,QACD,EACF,CAEkD,CAEhC;;AAGrB,SAAS,6BAA6B,aAAqB;CAEzD,MAAM,iBADS,UAAU,KAAK,aAAa,yBAAyB,CAAC,CACvC,YAAY,EAAE,EAAE,QAC3C,MAAM,EAAE,aAAa,QACvB;AACD,KAAI,cAAc,WAAW,EAAG;CAEhC,MAAM,UAAU,cAAc,QAC3B,MACC,CAAC,WACC,KAAK,aAAa,gBAAgB,EAAE,aAAa,eAAe,CACjE,CACJ;AACD,KAAI,QAAQ,WAAW,EAAG;CAE1B,MAAM,QAAQ,QAAQ,KAAK,MAAM,EAAE,YAAY;AAC/C,OAAM,IAAI,MACR,qJACE,MAAM,KAAK,MAAM,OAAO,IAAI,CAAC,KAAK,KAAK,GACvC,gDAAgD,MAAM,KAAK,IAAI,GAClE","debug_id":"b932c8b6-b646-54f8-8bb1-445b95fc1b70"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect-preview-DQnzviwA.mjs","sources":["../src/services/connect-preview.ts"],"sourcesContent":["import { getConnectBaseViteConfig } from \"@powerhousedao/builder-tools\";\nimport type { InlineConfig } from \"vite\";\nimport { mergeConfig, preview } from \"vite\";\nimport type { ConnectPreviewArgs } from \"../types.js\";\nimport { assignEnvVars } from \"../utils/assign-env-vars.js\";\n\nexport async function runConnectPreview(args: ConnectPreviewArgs) {\n const {\n outDir,\n connectBasePath: _connectBasePath,\n port,\n host,\n open,\n cors,\n strictPort,\n printUrls,\n bindCLIShortcuts,\n } = args;\n\n assignEnvVars(args);\n\n const mode = \"production\";\n\n const dirname = process.cwd();\n\n const baseConfig = getConnectBaseViteConfig({\n mode,\n dirname,\n });\n\n const previewConfig: InlineConfig = {\n build: {\n outDir,\n },\n preview: {\n cors,\n port,\n strictPort,\n host,\n open,\n },\n };\n\n const config = mergeConfig(baseConfig, previewConfig);\n\n const server = await preview(config);\n\n if (printUrls) server.printUrls();\n if (bindCLIShortcuts) server.bindCLIShortcuts({ print: true });\n}\n"],"names":[],"mappings":";;;;;;AAMA,eAAsB,kBAAkB,MAA0B;CAChE,MAAM,EACJ,QACA,iBAAiB,kBACjB,MACA,MACA,MACA,MACA,YACA,WACA,qBACE;AAEJ,eAAc,KAAK;CA0BnB,MAAM,SAAS,MAAM,QAFN,YAlBI,yBAAyB;EAC1C,MALW;EAMX,SAJc,QAAQ,KAAK;EAK5B,CAAC,EAEkC;EAClC,OAAO,EACL,QACD;EACD,SAAS;GACP;GACA;GACA;GACA;GACA;GACD;EACF,CAEoD,CAEjB;AAEpC,KAAI,UAAW,QAAO,WAAW;AACjC,KAAI,iBAAkB,QAAO,iBAAiB,EAAE,OAAO,MAAM,CAAC","debug_id":"75e0429b-f227-584e-aca7-692626e058f1"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect-studio-DTdSFftL.mjs","sources":["../src/services/connect-studio.ts"],"sourcesContent":["import { getConnectBaseViteConfig } from \"@powerhousedao/builder-tools\";\nimport type { InlineConfig, Logger } from \"vite\";\nimport { createServer, mergeConfig } from \"vite\";\nimport type { ConnectStudioArgs } from \"../types.js\";\nimport { assignEnvVars } from \"../utils/assign-env-vars.js\";\n\nexport async function runConnectStudio(\n args: ConnectStudioArgs,\n customLogger?: Logger,\n) {\n const { port, host, open, cors, strictPort, printUrls, bindCLIShortcuts } =\n args;\n assignEnvVars(args);\n const mode = \"development\";\n\n const dirname = process.cwd();\n\n const baseConfig = getConnectBaseViteConfig({\n mode,\n dirname,\n });\n\n const devServerConfig: InlineConfig = {\n server: { port, host, open, cors, strictPort },\n customLogger,\n };\n\n const config = mergeConfig(baseConfig, devServerConfig);\n\n const server = await createServer(config);\n\n await server.listen();\n\n if (printUrls) server.printUrls();\n if (bindCLIShortcuts) server.bindCLIShortcuts({ print: true });\n}\n"],"names":[],"mappings":";;;;;;AAMA,eAAsB,iBACpB,MACA,cACA;CACA,MAAM,EAAE,MAAM,MAAM,MAAM,MAAM,YAAY,WAAW,qBACrD;AACF,eAAc,KAAK;CAiBnB,MAAM,SAAS,MAAM,aAFN,YAVI,yBAAyB;EAC1C,MALW;EAMX,SAJc,QAAQ,KAAK;EAK5B,CAAC,EAEoC;EACpC,QAAQ;GAAE;GAAM;GAAM;GAAM;GAAM;GAAY;EAC9C;EACD,CAEsD,CAEd;AAEzC,OAAM,OAAO,QAAQ;AAErB,KAAI,UAAW,QAAO,WAAW;AACjC,KAAI,iBAAkB,QAAO,iBAAiB,EAAE,OAAO,MAAM,CAAC","debug_id":"663fea9f-e95e-5ea2-86ee-4372f32e0325"}
@@ -1,5 +0,0 @@
1
- import "./assign-env-vars-W-lZmdMi.mjs";
2
- import { t as runConnectStudio } from "./connect-studio-DTdSFftL.mjs";
3
- export { runConnectStudio };
4
- !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]="ef02a042-027e-5a27-890a-366a5ebef4b8")}catch(e){}}();
5
- //# debugId=ef02a042-027e-5a27-890a-366a5ebef4b8
@@ -1,4 +0,0 @@
1
- import { n as startSwitchboard } from "./switchboard-CERuSM8r.mjs";
2
- export { startSwitchboard };
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]="af9813d0-a104-5bb7-8b08-a5926d55691e")}catch(e){}}();
4
- //# debugId=af9813d0-a104-5bb7-8b08-a5926d55691e
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-mth8NsDA.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path, { dirname } from \"node:path\";\nexport const POWERHOUSE_CONFIG_FILE = \"powerhouse.config.json\";\nexport const POWERHOUSE_GLOBAL_DIR = path.join(homedir(), \".ph\");\nexport const SUPPORTED_PACKAGE_MANAGERS = [\"npm\", \"yarn\", \"pnpm\", \"bun\"];\n\nexport const packageManagers = {\n bun: {\n globalPathRegexp: /[\\\\/].bun[\\\\/]/,\n installCommand: \"bun add {{dependency}}\",\n uninstallCommand: \"bun remove {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"bun.lock\",\n updateCommand: \"bun update {{dependency}}\",\n buildAffected: \"bun run build:affected\",\n },\n pnpm: {\n globalPathRegexp: /[\\\\/]pnpm[\\\\/]/,\n installCommand: \"pnpm add {{dependency}}\",\n uninstallCommand: \"pnpm remove {{dependency}}\",\n workspaceOption: \"--workspace-root\",\n lockfile: \"pnpm-lock.yaml\",\n updateCommand: \"pnpm update {{dependency}}\",\n buildAffected: \"pnpm run build:affected\",\n },\n yarn: {\n globalPathRegexp: /[\\\\/]yarn[\\\\/]/,\n installCommand: \"yarn add {{dependency}}\",\n uninstallCommand: \"yarn remove {{dependency}}\",\n workspaceOption: \"-W\",\n lockfile: \"yarn.lock\",\n updateCommand: \"yarn upgrade {{dependency}}\",\n buildAffected: \"yarn run build:affected\",\n },\n npm: {\n installCommand: \"npm install {{dependency}}\",\n uninstallCommand: \"npm uninstall {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"package-lock.json\",\n updateCommand: \"npm update {{dependency}} --save\",\n buildAffected: \"npm run build:affected\",\n },\n};\n\ntype PathValidation = (dir: string) => boolean;\n\nexport type PackageManager = \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\nexport type ProjectInfo = {\n isGlobal: boolean;\n path: string;\n packageManager: PackageManager;\n};\n\nexport function defaultPathValidation() {\n return true;\n}\n\nexport function isPowerhouseProject(dir: string) {\n const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);\n\n return fs.existsSync(powerhouseConfigPath);\n}\n\nexport function findNodeProjectRoot(\n dir: string,\n pathValidation: PathValidation = defaultPathValidation,\n) {\n const packageJsonPath = path.join(dir, \"package.json\");\n\n if (fs.existsSync(packageJsonPath) && pathValidation(dir)) {\n return dir;\n }\n\n const parentDir = dirname(dir);\n\n if (parentDir === dir) {\n return null;\n }\n\n return findNodeProjectRoot(parentDir, pathValidation);\n}\n\nexport function getProjectInfo(debug?: boolean): ProjectInfo {\n const currentPath = process.cwd();\n\n if (debug) {\n console.log(\">>> currentPath\", currentPath);\n }\n\n const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);\n\n if (!projectPath) {\n return {\n isGlobal: true,\n path: POWERHOUSE_GLOBAL_DIR,\n packageManager: getPackageManagerFromLockfile(POWERHOUSE_GLOBAL_DIR),\n };\n }\n\n return {\n isGlobal: false,\n path: projectPath,\n packageManager: getPackageManagerFromLockfile(projectPath),\n };\n}\n\n/**\n * Generates a unique drive ID based on the project path.\n * The same project path will always generate the same ID.\n * @param name - The name prefix for the drive ID (e.g., \"vetra\", \"powerhouse\")\n * @returns A unique drive ID in the format \"{name}-{hash}\"\n */\nexport function generateProjectDriveId(name: string): string {\n const projectInfo = getProjectInfo();\n const hash = crypto\n .createHash(\"sha256\")\n .update(projectInfo.path)\n .digest(\"hex\");\n const shortHash = hash.substring(0, 8);\n return `${name}-${shortHash}`;\n}\n\nexport function getPackageManagerFromLockfile(dir: string): PackageManager {\n if (fs.existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {\n return \"pnpm\";\n } else if (fs.existsSync(path.join(dir, packageManagers.yarn.lockfile))) {\n return \"yarn\";\n } else if (fs.existsSync(path.join(dir, packageManagers.bun.lockfile))) {\n return \"bun\";\n }\n\n return \"npm\";\n}\n\nexport function updatePackagesArray(\n currentPackages: PowerhouseConfig[\"packages\"] = [],\n dependencies: { name: string; version: string | undefined }[],\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n): PowerhouseConfig[\"packages\"] {\n const isInstall = task === \"install\";\n const mappedPackages = dependencies.map((dep) => ({\n packageName: dep.name,\n version: dep.version,\n provider,\n }));\n\n if (isInstall) {\n // Overwrite existing package if version is different\n const filteredPackages = currentPackages.filter(\n (pkg) => !dependencies.find((dep) => dep.name === pkg.packageName),\n );\n return [...filteredPackages, ...mappedPackages];\n }\n\n return currentPackages.filter(\n (pkg) => !dependencies.map((dep) => dep.name).includes(pkg.packageName),\n );\n}\n\n// Modify updateConfigFile to use the new function\nexport function updateConfigFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n registryUrl?: string,\n) {\n const configPath = path.join(projectPath, POWERHOUSE_CONFIG_FILE);\n\n if (!fs.existsSync(configPath)) {\n throw new Error(\n `powerhouse.config.json file not found. projectPath: ${projectPath}`,\n );\n }\n\n const config = JSON.parse(\n fs.readFileSync(configPath, \"utf-8\"),\n ) as PowerhouseConfig;\n\n const updatedConfig: PowerhouseConfig = {\n ...config,\n packages: updatePackagesArray(\n config.packages,\n dependencies,\n task,\n provider,\n ),\n };\n\n if (\n task === \"install\" &&\n registryUrl &&\n !config.packageRegistryUrl &&\n dependencies.length > 0\n ) {\n updatedConfig.packageRegistryUrl = registryUrl;\n }\n\n fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));\n}\n\n/**\n * Recursively searches for a specific file by traversing up the directory tree.\n * Starting from the given path, it checks each parent directory until it finds\n * the target file or reaches the root directory.\n *\n * @param startPath - The absolute path of the directory to start searching from\n * @param targetFile - The name of the file to search for (e.g., 'package.json', 'pnpm-workspace.yaml')\n * @returns The absolute path of the directory containing the target file, or null if not found\n *\n * @example\n * // Find the workspace root directory\n * const workspaceRoot = findContainerDirectory('/path/to/project/src', 'pnpm-workspace.yaml');\n *\n * // Find the nearest package.json\n * const packageDir = findContainerDirectory('/path/to/project/src/components', 'package.json');\n */\nexport const findContainerDirectory = (\n startPath: string,\n targetFile: string,\n): string | null => {\n const filePath = path.join(startPath, targetFile);\n\n if (fs.existsSync(filePath)) {\n return startPath;\n }\n\n const parentDir = path.dirname(startPath);\n\n //reached the root directory and haven't found the file\n if (parentDir === startPath) {\n return null;\n }\n\n return findContainerDirectory(parentDir, targetFile);\n};\n\n/**\n * Updates the styles.css file to include imports for newly installed packages\n * @param dependencies - Array of dependencies that were installed\n * @param projectPath - Path to the project root\n */\nexport function updateStylesFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const fullCssPath = path.join(projectPath, cssPath);\n const importStatement = `@import '${cssPath}';`;\n\n // Check if the CSS file exists\n if (!fs.existsSync(fullCssPath)) {\n console.warn(`⚠️ Warning: CSS file not found at ${cssPath}`);\n continue;\n }\n\n // Check if import already exists\n if (currentStyles.includes(importStatement)) {\n continue;\n }\n\n // Find the last @import statement\n const importLines = currentStyles\n .split(\"\\n\")\n .filter((line) => line.trim().startsWith(\"@import\"));\n const lastImport = importLines[importLines.length - 1];\n\n if (lastImport) {\n // Insert new import after the last existing import\n updatedStyles = currentStyles.replace(\n lastImport,\n `${lastImport}\\n${importStatement}`,\n );\n } else {\n // If no imports exist, add at the top of the file\n updatedStyles = `${importStatement}\\n${currentStyles}`;\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n\n/**\n * Removes CSS imports for uninstalled packages from styles.css\n */\nexport function removeStylesImports(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const importStatement = `@import '${cssPath}';`;\n\n // Remove the import line if it exists\n const lines = updatedStyles.split(\"\\n\");\n const filteredLines = lines.filter(\n (line) => !line.trim().includes(importStatement),\n );\n\n if (filteredLines.length !== lines.length) {\n updatedStyles = filteredLines.join(\"\\n\");\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAKA,MAAa,yBAAyB;AACtC,MAAa,wBAAwB,KAAK,KAAK,SAAS,EAAE,MAAM;AAGhE,MAAa,kBAAkB;CAC7B,KAAK;EACH,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,KAAK;EACH,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACF;AAYD,SAAgB,wBAAwB;AACtC,QAAO;;AAGT,SAAgB,oBAAoB,KAAa;CAC/C,MAAM,uBAAuB,KAAK,KAAK,KAAK,uBAAuB;AAEnE,QAAO,GAAG,WAAW,qBAAqB;;AAG5C,SAAgB,oBACd,KACA,iBAAiC,uBACjC;CACA,MAAM,kBAAkB,KAAK,KAAK,KAAK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