@powerhousedao/shared 6.2.3-dev.93 → 6.2.3-dev.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/clis/args/access-token.mjs +1 -1
  2. package/dist/clis/args/{common-CBLen_yt.mjs → common-DG_SF8fN.mjs} +9 -1
  3. package/dist/clis/args/{common-CBLen_yt.mjs.map → common-DG_SF8fN.mjs.map} +1 -1
  4. package/dist/clis/args/{common-BpLj4peE.d.mts → common-DmerPWXo.d.mts} +5 -1
  5. package/dist/clis/args/common-DmerPWXo.d.mts.map +1 -0
  6. package/dist/clis/args/common.d.mts +1 -1
  7. package/dist/clis/args/common.mjs +1 -1
  8. package/dist/clis/args/connect.mjs +1 -1
  9. package/dist/clis/args/{generate-a36SaAn4.mjs → generate-DoDfK_Wi.mjs} +2 -2
  10. package/dist/clis/args/{generate-a36SaAn4.mjs.map → generate-DoDfK_Wi.mjs.map} +1 -1
  11. package/dist/clis/args/generate.mjs +1 -1
  12. package/dist/clis/args/{help-D_wYe_Fx.mjs → help-DJCRTkC9.mjs} +4 -4
  13. package/dist/clis/args/{help-D_wYe_Fx.mjs.map → help-DJCRTkC9.mjs.map} +1 -1
  14. package/dist/clis/args/help.mjs +1 -1
  15. package/dist/clis/args/index.d.mts +2 -2
  16. package/dist/clis/args/index.mjs +4 -4
  17. package/dist/clis/args/init.mjs +1 -1
  18. package/dist/clis/args/inspect.mjs +1 -1
  19. package/dist/clis/args/install.mjs +1 -1
  20. package/dist/clis/args/keyframes.mjs +1 -1
  21. package/dist/clis/args/list.mjs +1 -1
  22. package/dist/clis/args/login.mjs +1 -1
  23. package/dist/clis/args/mcp.mjs +1 -1
  24. package/dist/clis/args/migrate.mjs +1 -1
  25. package/dist/clis/args/model.d.mts +8 -0
  26. package/dist/clis/args/model.d.mts.map +1 -1
  27. package/dist/clis/args/model.mjs +17 -1
  28. package/dist/clis/args/model.mjs.map +1 -1
  29. package/dist/clis/args/publish.d.mts +4 -0
  30. package/dist/clis/args/publish.mjs +10 -2
  31. package/dist/clis/args/publish.mjs.map +1 -1
  32. package/dist/clis/args/registry.mjs +1 -1
  33. package/dist/clis/args/{service-IZ0Aq58z.d.mts → service-CLCvH3kf.d.mts} +2 -2
  34. package/dist/clis/args/{service-IZ0Aq58z.d.mts.map → service-CLCvH3kf.d.mts.map} +1 -1
  35. package/dist/clis/args/service.d.mts +1 -1
  36. package/dist/clis/args/service.mjs +1 -1
  37. package/dist/clis/args/switchboard.mjs +1 -1
  38. package/dist/clis/args/uninstall.mjs +1 -1
  39. package/dist/clis/args/unpublish.mjs +1 -1
  40. package/dist/clis/args/{vetra-DlAEC_Mv.mjs → vetra-BqjDopAP.mjs} +2 -2
  41. package/dist/clis/args/{vetra-DlAEC_Mv.mjs.map → vetra-BqjDopAP.mjs.map} +1 -1
  42. package/dist/clis/args/vetra.mjs +1 -1
  43. package/dist/clis/build-pieces.d.mts +9 -2
  44. package/dist/clis/build-pieces.d.mts.map +1 -1
  45. package/dist/clis/build-pieces.mjs +61 -16
  46. package/dist/clis/build-pieces.mjs.map +1 -1
  47. package/dist/clis/constants.d.mts +1 -1
  48. package/dist/clis/index.d.mts +16 -0
  49. package/dist/clis/index.d.mts.map +1 -1
  50. package/dist/clis/index.mjs +39 -3
  51. package/dist/clis/index.mjs.map +1 -1
  52. package/dist/clis/{types-DNeGTpnB.d.mts → types-B-2NDvpx.d.mts} +9 -1
  53. package/dist/clis/{types-DNeGTpnB.d.mts.map → types-B-2NDvpx.d.mts.map} +1 -1
  54. package/dist/connect/config-loader.d.ts +1 -1
  55. package/dist/connect/connect-config-schema.d.ts +1 -1
  56. package/dist/connect/connect-config-schema.js +1 -0
  57. package/dist/connect/connect-config-schema.js.map +1 -1
  58. package/dist/connect/index.d.ts +2 -2
  59. package/dist/{connect-config-schema-UFEAoO5W.d.ts → connect-config-schema-cBfkNo1b.d.ts} +9 -1
  60. package/dist/{connect-config-schema-UFEAoO5W.d.ts.map → connect-config-schema-cBfkNo1b.d.ts.map} +1 -1
  61. package/dist/document-drive/index.d.ts +3 -3
  62. package/dist/document-model/dispatch.d.ts +1 -1
  63. package/dist/document-model/errors.d.ts +1 -1
  64. package/dist/document-model/index.d.ts +1 -1
  65. package/dist/document-model/utils.d.ts +1 -1
  66. package/dist/{index-DD0XMv4t.d.ts → index-C_lizUqn.d.ts} +2 -2
  67. package/dist/{index-DD0XMv4t.d.ts.map → index-C_lizUqn.d.ts.map} +1 -1
  68. package/dist/index.d.ts +3 -3
  69. package/dist/processors/index.d.ts +1 -1
  70. package/dist/processors/testing.d.ts +1 -1
  71. package/dist/registry/index.d.ts +2 -2
  72. package/dist/registry/manifest-slim.d.ts +2 -2
  73. package/dist/{types-Btd9TO_L.d.ts → types-BuEzD0jp.d.ts} +2 -2
  74. package/dist/{types-Btd9TO_L.d.ts.map → types-BuEzD0jp.d.ts.map} +1 -1
  75. package/dist/{types-Dp2OWq1-.d.ts → types-cIIv_Rsg.d.ts} +2 -2
  76. package/dist/{types-Dp2OWq1-.d.ts.map → types-cIIv_Rsg.d.ts.map} +1 -1
  77. package/package.json +1 -1
  78. package/dist/clis/args/common-BpLj4peE.d.mts.map +0 -1
@@ -1,5 +1,5 @@
1
- import { o as debugArgs } from "./common-CBLen_yt.mjs";
2
- import { option, optional, rest, string } from "cmd-ts";
1
+ import { o as debugArgs } from "./common-DG_SF8fN.mjs";
2
+ import { boolean, flag, option, optional, rest, string } from "cmd-ts";
3
3
  //#region clis/args/publish.ts
4
4
  const publishArgs = {
5
5
  registry: option({
@@ -7,6 +7,14 @@ const publishArgs = {
7
7
  long: "registry",
8
8
  description: "Registry URL to publish to (overrides config and environment)"
9
9
  }),
10
+ /** @experimental Refuses to publish a package without a current release approval. */
11
+ requireApproval: flag({
12
+ type: boolean,
13
+ long: "require-approval",
14
+ description: "Experimental: publish only when the release approval that ph build --release wrote matches this package; otherwise exit 1 before contacting the registry. Forwards only --tag, --access, --otp, --dry-run, --provenance, --json and --loglevel to npm, refuses npm configuration in the environment that selects another package (npm_config_workspace, npm_config_workspaces, npm_config_include_workspace_root), and publishes with --ignore-scripts so lifecycle scripts cannot change the files it checked",
15
+ defaultValue: () => false,
16
+ defaultValueIsSerializable: true
17
+ }),
10
18
  ...debugArgs,
11
19
  forwardedArgs: rest({
12
20
  displayName: "npm-args",
@@ -1 +1 @@
1
- {"version":3,"file":"publish.mjs","names":[],"sources":["../../../clis/args/publish.ts"],"sourcesContent":["import { option, optional, rest, string } from \"cmd-ts\";\nimport { debugArgs } from \"./common.js\";\n\nexport const publishArgs = {\n registry: option({\n type: optional(string),\n long: \"registry\",\n description:\n \"Registry URL to publish to (overrides config and environment)\",\n }),\n ...debugArgs,\n forwardedArgs: rest({\n displayName: \"npm-args\",\n description: \"Extra arguments forwarded to npm publish (e.g. --tag dev)\",\n }),\n};\n"],"mappings":";;;AAGA,MAAa,cAAc;CACzB,UAAU,OAAO;EACf,MAAM,SAAS,MAAM;EACrB,MAAM;EACN,aACE;CACJ,CAAC;CACD,GAAG;CACH,eAAe,KAAK;EAClB,aAAa;EACb,aAAa;CACf,CAAC;AACH"}
1
+ {"version":3,"file":"publish.mjs","names":[],"sources":["../../../clis/args/publish.ts"],"sourcesContent":["import { boolean, flag, option, optional, rest, string } from \"cmd-ts\";\nimport { debugArgs } from \"./common.js\";\n\nexport const publishArgs = {\n registry: option({\n type: optional(string),\n long: \"registry\",\n description:\n \"Registry URL to publish to (overrides config and environment)\",\n }),\n /** @experimental Refuses to publish a package without a current release approval. */\n requireApproval: flag({\n type: boolean,\n long: \"require-approval\",\n description:\n \"Experimental: publish only when the release approval that ph build --release wrote matches this package; otherwise exit 1 before contacting the registry. Forwards only --tag, --access, --otp, --dry-run, --provenance, --json and --loglevel to npm, refuses npm configuration in the environment that selects another package (npm_config_workspace, npm_config_workspaces, npm_config_include_workspace_root), and publishes with --ignore-scripts so lifecycle scripts cannot change the files it checked\",\n defaultValue: () => false as const,\n defaultValueIsSerializable: true,\n }),\n ...debugArgs,\n forwardedArgs: rest({\n displayName: \"npm-args\",\n description: \"Extra arguments forwarded to npm publish (e.g. --tag dev)\",\n }),\n};\n"],"mappings":";;;AAGA,MAAa,cAAc;CACzB,UAAU,OAAO;EACf,MAAM,SAAS,MAAM;EACrB,MAAM;EACN,aACE;CACJ,CAAC;;CAED,iBAAiB,KAAK;EACpB,MAAM;EACN,MAAM;EACN,aACE;EACF,oBAAoB;EACpB,4BAA4B;CAC9B,CAAC;CACD,GAAG;CACH,eAAe,KAAK;EAClB,aAAa;EACb,aAAa;CACf,CAAC;AACH"}
@@ -1,4 +1,4 @@
1
- import { o as debugArgs } from "./common-CBLen_yt.mjs";
1
+ import { o as debugArgs } from "./common-DG_SF8fN.mjs";
2
2
  import { option, optional, string } from "cmd-ts";
3
3
  //#region clis/args/registry.ts
4
4
  const DEFAULT_REGISTRY_LOGIN_EXPIRY = "30d";
@@ -1,4 +1,4 @@
1
- import "./common-BpLj4peE.mjs";
1
+ import "./common-DmerPWXo.mjs";
2
2
  import "kysely";
3
3
  import { Agent } from "package-manager-detector";
4
4
  import "cmd-ts/dist/cjs/argparser.js";
@@ -24,4 +24,4 @@ declare const serviceArgs: {
24
24
  //#endregion
25
25
  export { ServiceAction as n, serviceArgs as t };
26
26
  export {};
27
- //# sourceMappingURL=service-IZ0Aq58z.d.mts.map
27
+ //# sourceMappingURL=service-CLCvH3kf.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service-IZ0Aq58z.d.mts","names":[],"sources":["../../../clis/constants.ts","../../../clis/types.ts","../../../clis/args/service.ts"],"mappings":";;;;;;;;cAKa;;;KCMD,wBAAwB;KACxB,gBAAgB;;;cCNf"}
1
+ {"version":3,"file":"service-CLCvH3kf.d.mts","names":[],"sources":["../../../clis/constants.ts","../../../clis/types.ts","../../../clis/args/service.ts"],"mappings":";;;;;;;;cAKa;;;KCMD,wBAAwB;KACxB,gBAAgB;;;cCNf"}
@@ -1,3 +1,3 @@
1
- import { n as ServiceAction, t as serviceArgs } from "./service-IZ0Aq58z.mjs";
1
+ import { n as ServiceAction, t as serviceArgs } from "./service-CLCvH3kf.mjs";
2
2
  export { type ServiceAction, serviceArgs };
3
3
  export {};
@@ -1,4 +1,4 @@
1
- import { A as SERVICE_ACTIONS, o as debugArgs } from "./common-CBLen_yt.mjs";
1
+ import { A as SERVICE_ACTIONS, o as debugArgs } from "./common-DG_SF8fN.mjs";
2
2
  import { oneOf, optional, positional } from "cmd-ts";
3
3
  //#region clis/args/service.ts
4
4
  const serviceArgs = {
@@ -1,4 +1,4 @@
1
- import { D as DEFAULT_SWITCHBOARD_PORT, k as DEFAULT_VETRA_DRIVE_ID, v as packages, x as vetraSwitchboardArgs } from "./common-CBLen_yt.mjs";
1
+ import { D as DEFAULT_SWITCHBOARD_PORT, k as DEFAULT_VETRA_DRIVE_ID, v as packages, x as vetraSwitchboardArgs } from "./common-DG_SF8fN.mjs";
2
2
  import { boolean, flag, number, option, optional, string } from "cmd-ts";
3
3
  //#region clis/args/switchboard.ts
4
4
  const switchboardArgs = {
@@ -1,4 +1,4 @@
1
- import { _ as packageManagerArgs, o as debugArgs } from "./common-CBLen_yt.mjs";
1
+ import { _ as packageManagerArgs, o as debugArgs } from "./common-DG_SF8fN.mjs";
2
2
  import { restPositionals, string } from "cmd-ts";
3
3
  //#region clis/args/uninstall.ts
4
4
  const uninstallArgs = {
@@ -1,4 +1,4 @@
1
- import { o as debugArgs } from "./common-CBLen_yt.mjs";
1
+ import { o as debugArgs } from "./common-DG_SF8fN.mjs";
2
2
  import { boolean, flag, option, optional, positional, rest, string } from "cmd-ts";
3
3
  //#region clis/args/unpublish.ts
4
4
  const unpublishArgs = {
@@ -1,4 +1,4 @@
1
- import { S as getConfig, i as commonServerArgs, r as commonArgs, x as vetraSwitchboardArgs, y as renownNamespace } from "./common-CBLen_yt.mjs";
1
+ import { S as getConfig, i as commonServerArgs, r as commonArgs, x as vetraSwitchboardArgs, y as renownNamespace } from "./common-DG_SF8fN.mjs";
2
2
  import { boolean, flag, number, option, optional, string } from "cmd-ts";
3
3
  import { join } from "node:path";
4
4
  import dotenv from "dotenv";
@@ -139,4 +139,4 @@ const vetraArgs = {
139
139
  //#endregion
140
140
  export { resolveSwitchboardPortDefault as n, vetraArgs as r, resolveConnectPortDefault as t };
141
141
 
142
- //# sourceMappingURL=vetra-DlAEC_Mv.mjs.map
142
+ //# sourceMappingURL=vetra-BqjDopAP.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"vetra-DlAEC_Mv.mjs","names":[],"sources":["../../../clis/project-env.ts","../../../clis/args/vetra.ts"],"sourcesContent":["import dotenv from \"dotenv\";\nimport { join } from \"node:path\";\n\nlet loadedFor: string | undefined;\nlet namesBeforeLoad: ReadonlySet<string> | undefined;\n\n/** `PH_NO_DOTENV=1` (or `true`): no `.env` file is read, so a launcher's\n * explicit environment is the whole environment. */\nexport function isDotenvDisabled(\n env: Record<string, string | undefined> = process.env,\n): boolean {\n const value = env.PH_NO_DOTENV?.trim().toLowerCase();\n return value === \"1\" || value === \"true\";\n}\n\n/**\n * Load the project's `.env.local` and `.env` into `process.env`.\n *\n * `dotenv` never overwrites a variable that is already set, so loading\n * `.env.local` first and `.env` second produces the precedence the CLI\n * documents: a real `process.env` value beats `.env.local`, which beats\n * `.env`. One `process.env` lookup afterwards therefore covers all three\n * sources.\n *\n * Idempotent per directory — CLI argument defaults call it lazily and may\n * call it more than once per process.\n */\nexport function loadProjectEnv(cwd: string = process.cwd()): void {\n if (isDotenvDisabled()) return;\n if (loadedFor === cwd) return;\n loadedFor = cwd;\n namesBeforeLoad ??= new Set(Object.keys(process.env));\n // dotenv 16 logs nothing for a missing file, so no suppression option is\n // needed here (and none exists before dotenv 17).\n dotenv.config({ path: join(cwd, \".env.local\") });\n dotenv.config({ path: join(cwd, \".env\") });\n}\n\n/** The `process.env` names the shell set: those before the first\n * {@link loadProjectEnv}. Undefined while no project `.env` was loaded. */\nexport function envNamesBeforeProjectEnv(): ReadonlySet<string> | undefined {\n return namesBeforeLoad;\n}\n\n/** Test seam: forget which directory has already been loaded. */\nexport function resetProjectEnvForTests(): void {\n loadedFor = undefined;\n namesBeforeLoad = undefined;\n}\n\n/**\n * Read an environment variable as a TCP port.\n *\n * Anything that is not a plain integer in 1-65535 is ignored rather than\n * throwing: a typo in `.env` should fall through to the next source in the\n * precedence chain, not break the CLI.\n */\nexport function readPortEnv(name: string): number | undefined {\n const raw = process.env[name]?.trim();\n if (!raw || !/^\\d+$/.test(raw)) return undefined;\n const port = Number(raw);\n if (port < 1 || port > 65535) return undefined;\n return port;\n}\n","import { boolean, flag, number, option, optional, string } from \"cmd-ts\";\nimport {\n DEFAULT_SWITCHBOARD_PORT,\n DEFAULT_VETRA_CONNECT_PORT,\n} from \"../constants.js\";\nimport { getConfig } from \"../file-system/get-config.js\";\nimport { loadProjectEnv, readPortEnv } from \"../project-env.js\";\nimport {\n commonArgs,\n commonServerArgs,\n renownNamespace,\n vetraSwitchboardArgs,\n} from \"./common.js\";\n\n/**\n * Resolve the Vetra Switchboard port.\n *\n * Precedence: CLI flag (cmd-ts applies that above this function) →\n * `process.env` → `.env.local` → `.env` → `powerhouse.config.json` →\n * constant. `loadProjectEnv` folds the two files into `process.env` without\n * clobbering anything already set, so a single lookup covers the middle three.\n */\nexport function resolveSwitchboardPortDefault(): number {\n loadProjectEnv();\n return (\n readPortEnv(\"PH_SWITCHBOARD_PORT\") ??\n getConfig().reactor?.port ??\n DEFAULT_SWITCHBOARD_PORT\n );\n}\n\n/** Resolve the Vetra Connect port through the same chain. */\nexport function resolveConnectPortDefault(): number {\n loadProjectEnv();\n return (\n readPortEnv(\"PH_VETRA_CONNECT_PORT\") ??\n getConfig().vetra?.connectPort ??\n DEFAULT_VETRA_CONNECT_PORT\n );\n}\n\nexport const vetraArgs = {\n switchboardPort: option({\n type: number,\n long: \"switchboard-port\",\n description: \"port to use for the Vetra Switchboard\",\n defaultValue: resolveSwitchboardPortDefault,\n }),\n connectPort: option({\n type: number,\n long: \"connect-port\",\n // Deliberately not `defaultValueIsSerializable`: the value is now\n // per-project, and cmd-ts prints serializable defaults into `--help`,\n // which would bake one project's port into the help text.\n description: \"port to use for the Vetra Connect\",\n defaultValue: resolveConnectPortDefault,\n }),\n remoteDrive: option({\n type: optional(string),\n long: \"remote-drive\",\n description:\n \"URL of remote drive to connect to (skips switchboard initialization)\",\n defaultValue: () => {\n const baseConfig = getConfig();\n return baseConfig.vetra?.driveUrl;\n },\n }),\n watch: flag({\n type: boolean,\n long: \"watch\",\n short: \"w\",\n description:\n \"Enable dynamic loading for document-models and editors in connect-studio and switchboard\",\n defaultValue: () => false,\n defaultValueIsSerializable: true,\n }),\n verbose: flag({\n type: boolean,\n long: \"logs\",\n description: \"Show additional logs\",\n defaultValue: () => false,\n defaultValueIsSerializable: true,\n }),\n restart: flag({\n type: boolean,\n long: \"restart\",\n description:\n \"Stop this project's running Vetra first (the pid in .ph/vetra-runtime.json), then start\",\n defaultValue: () => false,\n defaultValueIsSerializable: true,\n }),\n disableConnect: flag({\n type: boolean,\n long: \"disable-connect\",\n description:\n \"Skip Connect initialization (only start switchboard and reactor)\",\n defaultValue: () => false,\n defaultValueIsSerializable: true,\n }),\n interactive: flag({\n type: boolean,\n long: \"interactive\",\n description:\n \"Enable interactive mode for code generation (requires user confirmation before generating code)\",\n defaultValue: () => false,\n defaultValueIsSerializable: true,\n }),\n drivesPublicBase: option({\n type: optional(string),\n long: \"drives-public-base\",\n description:\n \"public base URL for the drive URLs advertised to Connect; each drive is exposed as <base>/d/<slug> instead of http://localhost:<switchboard-port>/d/<slug>. Use when the switchboard is reachable through a reverse proxy.\",\n }),\n dbPath: option({\n type: optional(string),\n long: \"db-path\",\n description:\n \"Database path or connection string. Use a `postgres://` URL for Postgres; otherwise treated as a PGlite filesystem path. Leave unset for in-memory PGlite.\",\n }),\n renownNamespace,\n ...commonArgs,\n ...commonServerArgs,\n ...vetraSwitchboardArgs,\n};\n"],"mappings":";;;;;AAGA,IAAI;AACJ,IAAI;;;AAIJ,SAAgB,iBACd,MAA0C,QAAQ,KACzC;CACT,MAAM,QAAQ,IAAI,cAAc,KAAK,CAAC,CAAC,YAAY;CACnD,OAAO,UAAU,OAAO,UAAU;AACpC;;;;;;;;;;;;;AAcA,SAAgB,eAAe,MAAc,QAAQ,IAAI,GAAS;CAChE,IAAI,iBAAiB,GAAG;CACxB,IAAI,cAAc,KAAK;CACvB,YAAY;CACZ,oBAAoB,IAAI,IAAI,OAAO,KAAK,QAAQ,GAAG,CAAC;CAGpD,OAAO,OAAO,EAAE,MAAM,KAAK,KAAK,YAAY,EAAE,CAAC;CAC/C,OAAO,OAAO,EAAE,MAAM,KAAK,KAAK,MAAM,EAAE,CAAC;AAC3C;;;;;;;;AAqBA,SAAgB,YAAY,MAAkC;CAC5D,MAAM,MAAM,QAAQ,IAAI,KAAK,EAAE,KAAK;CACpC,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,GAAG,GAAG,OAAO,KAAA;CACvC,MAAM,OAAO,OAAO,GAAG;CACvB,IAAI,OAAO,KAAK,OAAO,OAAO,OAAO,KAAA;CACrC,OAAO;AACT;;;;;;;;;;;ACzCA,SAAgB,gCAAwC;CACtD,eAAe;CACf,OACE,YAAY,qBAAqB,KACjC,UAAU,CAAC,CAAC,SAAS,QAAA;AAGzB;;AAGA,SAAgB,4BAAoC;CAClD,eAAe;CACf,OACE,YAAY,uBAAuB,KACnC,UAAU,CAAC,CAAC,OAAO,eAAA;AAGvB;AAEA,MAAa,YAAY;CACvB,iBAAiB,OAAO;EACtB,MAAM;EACN,MAAM;EACN,aAAa;EACb,cAAc;CAChB,CAAC;CACD,aAAa,OAAO;EAClB,MAAM;EACN,MAAM;EAIN,aAAa;EACb,cAAc;CAChB,CAAC;CACD,aAAa,OAAO;EAClB,MAAM,SAAS,MAAM;EACrB,MAAM;EACN,aACE;EACF,oBAAoB;GAElB,OADmB,UACH,CAAC,CAAC,OAAO;EAC3B;CACF,CAAC;CACD,OAAO,KAAK;EACV,MAAM;EACN,MAAM;EACN,OAAO;EACP,aACE;EACF,oBAAoB;EACpB,4BAA4B;CAC9B,CAAC;CACD,SAAS,KAAK;EACZ,MAAM;EACN,MAAM;EACN,aAAa;EACb,oBAAoB;EACpB,4BAA4B;CAC9B,CAAC;CACD,SAAS,KAAK;EACZ,MAAM;EACN,MAAM;EACN,aACE;EACF,oBAAoB;EACpB,4BAA4B;CAC9B,CAAC;CACD,gBAAgB,KAAK;EACnB,MAAM;EACN,MAAM;EACN,aACE;EACF,oBAAoB;EACpB,4BAA4B;CAC9B,CAAC;CACD,aAAa,KAAK;EAChB,MAAM;EACN,MAAM;EACN,aACE;EACF,oBAAoB;EACpB,4BAA4B;CAC9B,CAAC;CACD,kBAAkB,OAAO;EACvB,MAAM,SAAS,MAAM;EACrB,MAAM;EACN,aACE;CACJ,CAAC;CACD,QAAQ,OAAO;EACb,MAAM,SAAS,MAAM;EACrB,MAAM;EACN,aACE;CACJ,CAAC;CACD;CACA,GAAG;CACH,GAAG;CACH,GAAG;AACL"}
1
+ {"version":3,"file":"vetra-BqjDopAP.mjs","names":[],"sources":["../../../clis/project-env.ts","../../../clis/args/vetra.ts"],"sourcesContent":["import dotenv from \"dotenv\";\nimport { join } from \"node:path\";\n\nlet loadedFor: string | undefined;\nlet namesBeforeLoad: ReadonlySet<string> | undefined;\n\n/** `PH_NO_DOTENV=1` (or `true`): no `.env` file is read, so a launcher's\n * explicit environment is the whole environment. */\nexport function isDotenvDisabled(\n env: Record<string, string | undefined> = process.env,\n): boolean {\n const value = env.PH_NO_DOTENV?.trim().toLowerCase();\n return value === \"1\" || value === \"true\";\n}\n\n/**\n * Load the project's `.env.local` and `.env` into `process.env`.\n *\n * `dotenv` never overwrites a variable that is already set, so loading\n * `.env.local` first and `.env` second produces the precedence the CLI\n * documents: a real `process.env` value beats `.env.local`, which beats\n * `.env`. One `process.env` lookup afterwards therefore covers all three\n * sources.\n *\n * Idempotent per directory — CLI argument defaults call it lazily and may\n * call it more than once per process.\n */\nexport function loadProjectEnv(cwd: string = process.cwd()): void {\n if (isDotenvDisabled()) return;\n if (loadedFor === cwd) return;\n loadedFor = cwd;\n namesBeforeLoad ??= new Set(Object.keys(process.env));\n // dotenv 16 logs nothing for a missing file, so no suppression option is\n // needed here (and none exists before dotenv 17).\n dotenv.config({ path: join(cwd, \".env.local\") });\n dotenv.config({ path: join(cwd, \".env\") });\n}\n\n/** The `process.env` names the shell set: those before the first\n * {@link loadProjectEnv}. Undefined while no project `.env` was loaded. */\nexport function envNamesBeforeProjectEnv(): ReadonlySet<string> | undefined {\n return namesBeforeLoad;\n}\n\n/** Test seam: forget which directory has already been loaded. */\nexport function resetProjectEnvForTests(): void {\n loadedFor = undefined;\n namesBeforeLoad = undefined;\n}\n\n/**\n * Read an environment variable as a TCP port.\n *\n * Anything that is not a plain integer in 1-65535 is ignored rather than\n * throwing: a typo in `.env` should fall through to the next source in the\n * precedence chain, not break the CLI.\n */\nexport function readPortEnv(name: string): number | undefined {\n const raw = process.env[name]?.trim();\n if (!raw || !/^\\d+$/.test(raw)) return undefined;\n const port = Number(raw);\n if (port < 1 || port > 65535) return undefined;\n return port;\n}\n","import { boolean, flag, number, option, optional, string } from \"cmd-ts\";\nimport {\n DEFAULT_SWITCHBOARD_PORT,\n DEFAULT_VETRA_CONNECT_PORT,\n} from \"../constants.js\";\nimport { getConfig } from \"../file-system/get-config.js\";\nimport { loadProjectEnv, readPortEnv } from \"../project-env.js\";\nimport {\n commonArgs,\n commonServerArgs,\n renownNamespace,\n vetraSwitchboardArgs,\n} from \"./common.js\";\n\n/**\n * Resolve the Vetra Switchboard port.\n *\n * Precedence: CLI flag (cmd-ts applies that above this function) →\n * `process.env` → `.env.local` → `.env` → `powerhouse.config.json` →\n * constant. `loadProjectEnv` folds the two files into `process.env` without\n * clobbering anything already set, so a single lookup covers the middle three.\n */\nexport function resolveSwitchboardPortDefault(): number {\n loadProjectEnv();\n return (\n readPortEnv(\"PH_SWITCHBOARD_PORT\") ??\n getConfig().reactor?.port ??\n DEFAULT_SWITCHBOARD_PORT\n );\n}\n\n/** Resolve the Vetra Connect port through the same chain. */\nexport function resolveConnectPortDefault(): number {\n loadProjectEnv();\n return (\n readPortEnv(\"PH_VETRA_CONNECT_PORT\") ??\n getConfig().vetra?.connectPort ??\n DEFAULT_VETRA_CONNECT_PORT\n );\n}\n\nexport const vetraArgs = {\n switchboardPort: option({\n type: number,\n long: \"switchboard-port\",\n description: \"port to use for the Vetra Switchboard\",\n defaultValue: resolveSwitchboardPortDefault,\n }),\n connectPort: option({\n type: number,\n long: \"connect-port\",\n // Deliberately not `defaultValueIsSerializable`: the value is now\n // per-project, and cmd-ts prints serializable defaults into `--help`,\n // which would bake one project's port into the help text.\n description: \"port to use for the Vetra Connect\",\n defaultValue: resolveConnectPortDefault,\n }),\n remoteDrive: option({\n type: optional(string),\n long: \"remote-drive\",\n description:\n \"URL of remote drive to connect to (skips switchboard initialization)\",\n defaultValue: () => {\n const baseConfig = getConfig();\n return baseConfig.vetra?.driveUrl;\n },\n }),\n watch: flag({\n type: boolean,\n long: \"watch\",\n short: \"w\",\n description:\n \"Enable dynamic loading for document-models and editors in connect-studio and switchboard\",\n defaultValue: () => false,\n defaultValueIsSerializable: true,\n }),\n verbose: flag({\n type: boolean,\n long: \"logs\",\n description: \"Show additional logs\",\n defaultValue: () => false,\n defaultValueIsSerializable: true,\n }),\n restart: flag({\n type: boolean,\n long: \"restart\",\n description:\n \"Stop this project's running Vetra first (the pid in .ph/vetra-runtime.json), then start\",\n defaultValue: () => false,\n defaultValueIsSerializable: true,\n }),\n disableConnect: flag({\n type: boolean,\n long: \"disable-connect\",\n description:\n \"Skip Connect initialization (only start switchboard and reactor)\",\n defaultValue: () => false,\n defaultValueIsSerializable: true,\n }),\n interactive: flag({\n type: boolean,\n long: \"interactive\",\n description:\n \"Enable interactive mode for code generation (requires user confirmation before generating code)\",\n defaultValue: () => false,\n defaultValueIsSerializable: true,\n }),\n drivesPublicBase: option({\n type: optional(string),\n long: \"drives-public-base\",\n description:\n \"public base URL for the drive URLs advertised to Connect; each drive is exposed as <base>/d/<slug> instead of http://localhost:<switchboard-port>/d/<slug>. Use when the switchboard is reachable through a reverse proxy.\",\n }),\n dbPath: option({\n type: optional(string),\n long: \"db-path\",\n description:\n \"Database path or connection string. Use a `postgres://` URL for Postgres; otherwise treated as a PGlite filesystem path. Leave unset for in-memory PGlite.\",\n }),\n renownNamespace,\n ...commonArgs,\n ...commonServerArgs,\n ...vetraSwitchboardArgs,\n};\n"],"mappings":";;;;;AAGA,IAAI;AACJ,IAAI;;;AAIJ,SAAgB,iBACd,MAA0C,QAAQ,KACzC;CACT,MAAM,QAAQ,IAAI,cAAc,KAAK,CAAC,CAAC,YAAY;CACnD,OAAO,UAAU,OAAO,UAAU;AACpC;;;;;;;;;;;;;AAcA,SAAgB,eAAe,MAAc,QAAQ,IAAI,GAAS;CAChE,IAAI,iBAAiB,GAAG;CACxB,IAAI,cAAc,KAAK;CACvB,YAAY;CACZ,oBAAoB,IAAI,IAAI,OAAO,KAAK,QAAQ,GAAG,CAAC;CAGpD,OAAO,OAAO,EAAE,MAAM,KAAK,KAAK,YAAY,EAAE,CAAC;CAC/C,OAAO,OAAO,EAAE,MAAM,KAAK,KAAK,MAAM,EAAE,CAAC;AAC3C;;;;;;;;AAqBA,SAAgB,YAAY,MAAkC;CAC5D,MAAM,MAAM,QAAQ,IAAI,KAAK,EAAE,KAAK;CACpC,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,GAAG,GAAG,OAAO,KAAA;CACvC,MAAM,OAAO,OAAO,GAAG;CACvB,IAAI,OAAO,KAAK,OAAO,OAAO,OAAO,KAAA;CACrC,OAAO;AACT;;;;;;;;;;;ACzCA,SAAgB,gCAAwC;CACtD,eAAe;CACf,OACE,YAAY,qBAAqB,KACjC,UAAU,CAAC,CAAC,SAAS,QAAA;AAGzB;;AAGA,SAAgB,4BAAoC;CAClD,eAAe;CACf,OACE,YAAY,uBAAuB,KACnC,UAAU,CAAC,CAAC,OAAO,eAAA;AAGvB;AAEA,MAAa,YAAY;CACvB,iBAAiB,OAAO;EACtB,MAAM;EACN,MAAM;EACN,aAAa;EACb,cAAc;CAChB,CAAC;CACD,aAAa,OAAO;EAClB,MAAM;EACN,MAAM;EAIN,aAAa;EACb,cAAc;CAChB,CAAC;CACD,aAAa,OAAO;EAClB,MAAM,SAAS,MAAM;EACrB,MAAM;EACN,aACE;EACF,oBAAoB;GAElB,OADmB,UACH,CAAC,CAAC,OAAO;EAC3B;CACF,CAAC;CACD,OAAO,KAAK;EACV,MAAM;EACN,MAAM;EACN,OAAO;EACP,aACE;EACF,oBAAoB;EACpB,4BAA4B;CAC9B,CAAC;CACD,SAAS,KAAK;EACZ,MAAM;EACN,MAAM;EACN,aAAa;EACb,oBAAoB;EACpB,4BAA4B;CAC9B,CAAC;CACD,SAAS,KAAK;EACZ,MAAM;EACN,MAAM;EACN,aACE;EACF,oBAAoB;EACpB,4BAA4B;CAC9B,CAAC;CACD,gBAAgB,KAAK;EACnB,MAAM;EACN,MAAM;EACN,aACE;EACF,oBAAoB;EACpB,4BAA4B;CAC9B,CAAC;CACD,aAAa,KAAK;EAChB,MAAM;EACN,MAAM;EACN,aACE;EACF,oBAAoB;EACpB,4BAA4B;CAC9B,CAAC;CACD,kBAAkB,OAAO;EACvB,MAAM,SAAS,MAAM;EACrB,MAAM;EACN,aACE;CACJ,CAAC;CACD,QAAQ,OAAO;EACb,MAAM,SAAS,MAAM;EACrB,MAAM;EACN,aACE;CACJ,CAAC;CACD;CACA,GAAG;CACH,GAAG;CACH,GAAG;AACL"}
@@ -1,2 +1,2 @@
1
- import { n as resolveSwitchboardPortDefault, r as vetraArgs, t as resolveConnectPortDefault } from "./vetra-DlAEC_Mv.mjs";
1
+ import { n as resolveSwitchboardPortDefault, r as vetraArgs, t as resolveConnectPortDefault } from "./vetra-BqjDopAP.mjs";
2
2
  export { resolveConnectPortDefault, resolveSwitchboardPortDefault, vetraArgs };
@@ -1,4 +1,4 @@
1
- import { t as Manifest } from "./types-DNeGTpnB.mjs";
1
+ import { t as Manifest } from "./types-B-2NDvpx.mjs";
2
2
  import { t as InlineConfig } from "./index-DnZYG-8g.mjs";
3
3
  //#region clis/external-deps.d.mts
4
4
  /** The files one module needs at run time, and why each was included. */
@@ -67,6 +67,13 @@ export type PiecePlan = {
67
67
  export type PieceBuildTarget = {
68
68
  projectRoot: string;
69
69
  outDir: string;
70
+ /**
71
+ * @experimental Absolute: the directory that stands in for
72
+ * `<projectRoot>/<outDir>` on disk during this build. Every path the build
73
+ * names stays under `outDir`. Experimental while staged builds are
74
+ * introduced.
75
+ */
76
+ writeTo?: string;
70
77
  pieces: PiecePlan[];
71
78
  };
72
79
  export type PackagePiece = {
@@ -119,7 +126,7 @@ export declare function expandEntryGlobs(root: string, globs: string[]): string[
119
126
  export declare function planPieces(projectRoot: string, outDir: string): PiecePlan[];
120
127
  export declare function createJsonReplacer(): (this: unknown, _key: string, value: unknown) => {} | null | undefined;
121
128
  export declare const DESCRIBE_HELPERS = "\nconst isRecord = (value) => typeof value === \"object\" && value !== null;\n\nfunction findPiece(mod) {\n const candidates = [\n ...Object.values(mod),\n ...(isRecord(mod.default) ? Object.values(mod.default) : []),\n mod.default,\n ];\n for (const candidate of candidates) {\n if (isRecord(candidate) && candidate.constructor?.name === \"Piece\") {\n return candidate;\n }\n }\n for (const candidate of candidates) {\n if (\n isRecord(candidate) &&\n typeof candidate.displayName === \"string\" &&\n (isRecord(candidate.actions) ||\n typeof candidate.actions === \"function\" ||\n typeof candidate.getAction === \"function\")\n ) {\n return candidate;\n }\n }\n return undefined;\n}\n\nfunction describePiece(piece) {\n if (typeof piece.metadata === \"function\") return piece.metadata();\n const call = (value) => (typeof value === \"function\" ? value.call(piece) : value);\n return {\n displayName: piece.displayName,\n logoUrl: piece.logoUrl,\n description: piece.description,\n authors: piece.authors,\n categories: piece.categories,\n auth: piece.auth,\n minimumSupportedRelease: piece.minimumSupportedRelease,\n maximumSupportedRelease: piece.maximumSupportedRelease,\n deprecated: piece.deprecated,\n actions: call(piece.actions) ?? {},\n triggers: call(piece.triggers) ?? {},\n };\n}\n\nfunction createJsonReplacer() {\n const ancestors = [];\n return function replace(_key, value) {\n if (typeof value === \"function\" || value === undefined) return undefined;\n if (typeof value === \"bigint\") return value.toString();\n if (typeof value !== \"object\" || value === null) return value;\n while (ancestors.length > 0 && ancestors.at(-1) !== this) ancestors.pop();\n if (ancestors.includes(value)) return undefined;\n ancestors.push(value);\n return value;\n };\n}\n";
122
- export declare const DESCRIBE_SCRIPT = "\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { isAbsolute, join } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nconst job = JSON.parse(readFileSync(process.argv[2], \"utf8\"));\n\nconst isRecord = (value) => typeof value === \"object\" && value !== null;\n\nfunction findPiece(mod) {\n const candidates = [\n ...Object.values(mod),\n ...(isRecord(mod.default) ? Object.values(mod.default) : []),\n mod.default,\n ];\n for (const candidate of candidates) {\n if (isRecord(candidate) && candidate.constructor?.name === \"Piece\") {\n return candidate;\n }\n }\n for (const candidate of candidates) {\n if (\n isRecord(candidate) &&\n typeof candidate.displayName === \"string\" &&\n (isRecord(candidate.actions) ||\n typeof candidate.actions === \"function\" ||\n typeof candidate.getAction === \"function\")\n ) {\n return candidate;\n }\n }\n return undefined;\n}\n\nfunction describePiece(piece) {\n if (typeof piece.metadata === \"function\") return piece.metadata();\n const call = (value) => (typeof value === \"function\" ? value.call(piece) : value);\n return {\n displayName: piece.displayName,\n logoUrl: piece.logoUrl,\n description: piece.description,\n authors: piece.authors,\n categories: piece.categories,\n auth: piece.auth,\n minimumSupportedRelease: piece.minimumSupportedRelease,\n maximumSupportedRelease: piece.maximumSupportedRelease,\n deprecated: piece.deprecated,\n actions: call(piece.actions) ?? {},\n triggers: call(piece.triggers) ?? {},\n };\n}\n\nfunction createJsonReplacer() {\n const ancestors = [];\n return function replace(_key, value) {\n if (typeof value === \"function\" || value === undefined) return undefined;\n if (typeof value === \"bigint\") return value.toString();\n if (typeof value !== \"object\" || value === null) return value;\n while (ancestors.length > 0 && ancestors.at(-1) !== this) ancestors.pop();\n if (ancestors.includes(value)) return undefined;\n ancestors.push(value);\n return value;\n };\n}\n\n// Says why the child gave up in the one place the parent always reads, so a\n// failure reports the cause and never the text of this script.\nfunction fail(message) {\n writeFileSync(job.outFile, JSON.stringify({ fatal: message }));\n process.exit(1);\n}\n\n// The module to load for a list entry; a bundle names its own main.\nfunction entryFile(piece) {\n const declared = piece.entry ?? piece.bundle;\n if (typeof declared !== \"string\") return undefined;\n const path = isAbsolute(declared) ? declared : join(job.projectRoot, declared);\n if (piece.entry) return path;\n const pkgFile = join(path, \"package.json\");\n if (!existsSync(pkgFile)) return undefined;\n const pkg = JSON.parse(readFileSync(pkgFile, \"utf8\"));\n return join(path, typeof pkg.main === \"string\" ? pkg.main : \"index.mjs\");\n}\n\nlet listModule;\ntry {\n listModule = await import(pathToFileURL(job.listPath).href);\n} catch (error) {\n fail(job.listPath + \" threw on import: \" + (error instanceof Error ? error.message : String(error)));\n}\nconst list = listModule.pieces ?? listModule.default;\nif (!Array.isArray(list)) {\n fail(job.listPath + ' exports no \"pieces\" array');\n}\n\nconst out = { list, pieces: [], errors: [] };\nfor (const piece of list) {\n const file = entryFile(piece);\n // A missing file is the parent's to report, with the message it owns.\n if (!file || !existsSync(file)) continue;\n try {\n const mod = await import(pathToFileURL(file).href);\n const found = findPiece(mod);\n if (!found) {\n throw new Error(\n \"no Piece export found in \" + file + \"; exports: \" + Object.keys(mod).join(\", \"),\n );\n }\n const metadata = JSON.parse(JSON.stringify(describePiece(found), createJsonReplacer()));\n out.pieces.push({ name: piece.name, metadata });\n } catch (error) {\n out.errors.push({\n name: piece.name,\n message: error instanceof Error ? error.message : String(error),\n });\n }\n}\nwriteFileSync(job.outFile, JSON.stringify(out, createJsonReplacer()));\n";
129
+ export declare const DESCRIBE_SCRIPT = "\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { isAbsolute, join, relative, sep } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nconst job = JSON.parse(readFileSync(process.argv[2], \"utf8\"));\n\nconst isRecord = (value) => typeof value === \"object\" && value !== null;\n\nfunction findPiece(mod) {\n const candidates = [\n ...Object.values(mod),\n ...(isRecord(mod.default) ? Object.values(mod.default) : []),\n mod.default,\n ];\n for (const candidate of candidates) {\n if (isRecord(candidate) && candidate.constructor?.name === \"Piece\") {\n return candidate;\n }\n }\n for (const candidate of candidates) {\n if (\n isRecord(candidate) &&\n typeof candidate.displayName === \"string\" &&\n (isRecord(candidate.actions) ||\n typeof candidate.actions === \"function\" ||\n typeof candidate.getAction === \"function\")\n ) {\n return candidate;\n }\n }\n return undefined;\n}\n\nfunction describePiece(piece) {\n if (typeof piece.metadata === \"function\") return piece.metadata();\n const call = (value) => (typeof value === \"function\" ? value.call(piece) : value);\n return {\n displayName: piece.displayName,\n logoUrl: piece.logoUrl,\n description: piece.description,\n authors: piece.authors,\n categories: piece.categories,\n auth: piece.auth,\n minimumSupportedRelease: piece.minimumSupportedRelease,\n maximumSupportedRelease: piece.maximumSupportedRelease,\n deprecated: piece.deprecated,\n actions: call(piece.actions) ?? {},\n triggers: call(piece.triggers) ?? {},\n };\n}\n\nfunction createJsonReplacer() {\n const ancestors = [];\n return function replace(_key, value) {\n if (typeof value === \"function\" || value === undefined) return undefined;\n if (typeof value === \"bigint\") return value.toString();\n if (typeof value !== \"object\" || value === null) return value;\n while (ancestors.length > 0 && ancestors.at(-1) !== this) ancestors.pop();\n if (ancestors.includes(value)) return undefined;\n ancestors.push(value);\n return value;\n };\n}\n\n// The parent's onDisk, for the paths a list names under the output directory.\nfunction onDisk(path) {\n if (!job.redirect) return path;\n const inside = relative(job.redirect.from, path);\n const leaves = inside === \"..\" || inside.startsWith(\"..\" + sep) || isAbsolute(inside);\n return leaves ? path : join(job.redirect.to, inside);\n}\n\n// Says why the child gave up in the one place the parent always reads, so a\n// failure reports the cause and never the text of this script.\nfunction fail(message) {\n writeFileSync(job.outFile, JSON.stringify({ fatal: message }));\n process.exit(1);\n}\n\n// The module to load for a list entry; a bundle names its own main.\nfunction entryFile(piece) {\n const declared = piece.entry ?? piece.bundle;\n if (typeof declared !== \"string\") return undefined;\n const path = isAbsolute(declared) ? declared : join(job.projectRoot, declared);\n if (piece.entry) return path;\n const pkgFile = join(onDisk(path), \"package.json\");\n if (!existsSync(pkgFile)) return undefined;\n const pkg = JSON.parse(readFileSync(pkgFile, \"utf8\"));\n return join(path, typeof pkg.main === \"string\" ? pkg.main : \"index.mjs\");\n}\n\nlet listModule;\ntry {\n listModule = await import(pathToFileURL(onDisk(job.listPath)).href);\n} catch (error) {\n fail(job.listPath + \" threw on import: \" + (error instanceof Error ? error.message : String(error)));\n}\nconst list = listModule.pieces ?? listModule.default;\nif (!Array.isArray(list)) {\n fail(job.listPath + ' exports no \"pieces\" array');\n}\n\nconst out = { list, pieces: [], errors: [] };\nfor (const piece of list) {\n const file = entryFile(piece);\n // A missing file is the parent's to report, with the message it owns.\n if (!file || !existsSync(onDisk(file))) continue;\n try {\n const mod = await import(pathToFileURL(onDisk(file)).href);\n const found = findPiece(mod);\n if (!found) {\n throw new Error(\n \"no Piece export found in \" + file + \"; exports: \" + Object.keys(mod).join(\", \"),\n );\n }\n const metadata = JSON.parse(JSON.stringify(describePiece(found), createJsonReplacer()));\n out.pieces.push({ name: piece.name, metadata });\n } catch (error) {\n out.errors.push({\n name: piece.name,\n message: error instanceof Error ? error.message : String(error),\n });\n }\n}\nwriteFileSync(job.outFile, JSON.stringify(out, createJsonReplacer()));\n";
123
130
  export declare function describePieces(projectRoot: string, listPath: string): DescribeResult;
124
131
  export type PieceLocation = {
125
132
  /** The piece directory, absolute. */
@@ -1 +1 @@
1
- {"version":3,"file":"build-pieces.d.mts","names":[],"sources":["../../clis/external-deps.mts","../../clis/build-pieces.mts"],"mappings":";;;;KAQY;;EAEV,UAAU;;EAEV,SAAS;IAAc,SAAS;;;;KAItB,cAAc,iBAAiB,QAAQ;;KAGvC;EAAiB;EAAc;;KAE/B,qBAAqB;EAC/B;EACA;;EAEA;;;KAIU;EACV,OAAO,YAAY,QAAQ;EAC3B,MAAM;;qBAGK,4BAA2B;KAK5B;;EAEV;;EAEA;;EAEA;;EAEA;EACA,QAAQ;;KAGL,SAAS,YAAY;;wBAaV,YAAY,cAAc;;wBAwEpB,iBACpB,eACA,OAAO,YACP,QAAQ,iBACP,QAAQ;;wBAmDK,mBACd,OAAO,YACP,OAAO,YAAY,qBACnB,UAAS,4BACR;;;;;wBA8Da,+BACd,OAAO,SAAS,qBAChB,KAAK,QACH,qEAEE,QAAQ,4BAGX;;wBAUa,2BACd,OAAO,SAAS,sBACf;;;YCjOS;;EAEV;;EAEA;;EAEA;;YAKU;EACV;EACA;EACA,QAAQ;;YAKE;EACV;EACA;EACA;;YAKU,gBAAgB;EAC1B;EACA;EACA,UAAU;EACV,WAAW;;YAGD;EACV;EACA,UAAU;;YAGA;EACV,MAAM;EACN,QAAQ;EACR;IAAU;IAAc;;;YAGd;EACV;EACA;EACA;EACA;;EAEA;;EAEA;;YAGU;EACV;EACA;EACA;;YAGU;;EAEV,SAAS,QAAQ,iBAAiB;;EAElC,QAAQ;EACR,QAAQ;;wBAKM,SAAS,8BAAS;wBAUlB,iBAAiB,cAAc;wBA4B/B,WAAW,qBAAqB,iBAAiB;wBAejD,uBAAkB,eAEK,cAAc;qBAiBxC;qBAiEA;wBAsFG,eACd,qBACA,mBACC;YA0BS;;EAEV;;EAEA;EACA;;wBAKc,qBACd,OAAO,cACP,qBACA,iBACC;wBAmCa,cAAc;EAC5B;EACA;;wBAac,mBAAmB;EACjC;EACA,QAAQ;;wBAWM,mBACd,OAAO,cACP,KAAK;wBAWS,iBAAiB;EAC/B;EACA;EACA;EACA;EACA;EACA,eAAe;IACb;wBAeY,kBACd,aACA,kBACC;wBASa,gBACd,OAAO,cACP,iBACA,UAAU,gBACT;wBAUa,qBACd,UAAU,UACV,OAAO;EACJ,UAAU;EAAU;;wBAkCH,YACpB,QAAQ,kBACR,KAAK,iBACL,SAAS,oBACR,QAAQ;wBAgIK,iBACd,QAAQ,kBACR,OAAO,cACP,uBAAsB"}
1
+ {"version":3,"file":"build-pieces.d.mts","names":[],"sources":["../../clis/external-deps.mts","../../clis/build-pieces.mts"],"mappings":";;;;KAQY;;EAEV,UAAU;;EAEV,SAAS;IAAc,SAAS;;;;KAItB,cAAc,iBAAiB,QAAQ;;KAGvC;EAAiB;EAAc;;KAE/B,qBAAqB;EAC/B;EACA;;EAEA;;;KAIU;EACV,OAAO,YAAY,QAAQ;EAC3B,MAAM;;qBAGK,4BAA2B;KAK5B;;EAEV;;EAEA;;EAEA;;EAEA;EACA,QAAQ;;KAGL,SAAS,YAAY;;wBAaV,YAAY,cAAc;;wBAwEpB,iBACpB,eACA,OAAO,YACP,QAAQ,iBACP,QAAQ;;wBAmDK,mBACd,OAAO,YACP,OAAO,YAAY,qBACnB,UAAS,4BACR;;;;;wBA8Da,+BACd,OAAO,SAAS,qBAChB,KAAK,QACH,qEAEE,QAAQ,4BAGX;;wBAUa,2BACd,OAAO,SAAS,sBACf;;;YChOS;;EAEV;;EAEA;;EAEA;;YAKU;EACV;EACA;;;;;;;EAOA;EACA,QAAQ;;YAKE;EACV;EACA;EACA;;YAKU,gBAAgB;EAC1B;EACA;EACA,UAAU;EACV,WAAW;;YAGD;EACV;EACA,UAAU;;YAGA;EACV,MAAM;EACN,QAAQ;EACR;IAAU;IAAc;;;YAGd;EACV;EACA;EACA;EACA;;EAEA;;EAEA;;YAGU;EACV;EACA;EACA;;YAGU;;EAEV,SAAS,QAAQ,iBAAiB;;EAElC,QAAQ;EACR,QAAQ;;wBAiCM,SAAS,8BAAS;wBAkBlB,iBAAiB,cAAc;wBA4B/B,WAAW,qBAAqB,iBAAiB;wBAejD,uBAAkB,eAEK,cAAc;qBAiBxC;qBAiEA;wBA8FG,eACd,qBACA,mBACC;YAqCS;;EAEV;;EAEA;EACA;;wBAKc,qBACd,OAAO,cACP,qBACA,iBACC;wBAgDa,cAAc;EAC5B;EACA;;wBAac,mBAAmB;EACjC;EACA,QAAQ;;wBAWM,mBACd,OAAO,cACP,KAAK;wBAWS,iBAAiB;EAC/B;EACA;EACA;EACA;EACA;EACA,eAAe;IACb;wBAeY,kBACd,aACA,kBACC;wBASa,gBACd,OAAO,cACP,iBACA,UAAU,gBACT;wBAUa,qBACd,UAAU,UACV,OAAO;EACJ,UAAU;EAAU;;wBAkCH,YACpB,QAAQ,kBACR,KAAK,iBACL,SAAS,oBACR,QAAQ;wBAwIK,iBACd,QAAQ,kBACR,OAAO,cACP,uBAAsB"}
@@ -163,6 +163,21 @@ function externalDependencyVersions(found) {
163
163
  //#endregion
164
164
  //#region clis/build-pieces.mts
165
165
  const toPosix = (p) => p.split(sep).join("/");
166
+ /** `relative(dir, path)` leaves `dir`: `..`, `../…`, or another root. */
167
+ const leaves = (inside) => inside === ".." || inside.startsWith(`..${sep}`) || isAbsolute(inside);
168
+ function onDisk(path, redirect) {
169
+ if (!redirect) return path;
170
+ const inside = relative(redirect.from, path);
171
+ return leaves(inside) ? path : join(redirect.to, inside);
172
+ }
173
+ function toLogical(path, redirect) {
174
+ if (!redirect) return path;
175
+ for (const dir of [redirect.to, redirect.toReal]) {
176
+ const inside = relative(dir, path);
177
+ if (!leaves(inside)) return join(redirect.from, inside);
178
+ }
179
+ return path;
180
+ }
166
181
  function statSafe(p) {
167
182
  try {
168
183
  return statSync(p);
@@ -170,6 +185,13 @@ function statSafe(p) {
170
185
  return null;
171
186
  }
172
187
  }
188
+ function realpathSafe(p) {
189
+ try {
190
+ return realpathSync(p);
191
+ } catch {
192
+ return p;
193
+ }
194
+ }
173
195
  function expandEntryGlobs(root, globs) {
174
196
  const files = /* @__PURE__ */ new Set();
175
197
  for (const pattern of globs) {
@@ -271,11 +293,19 @@ function createJsonReplacer() {
271
293
  `;
272
294
  const DESCRIBE_SCRIPT = `
273
295
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
274
- import { isAbsolute, join } from "node:path";
296
+ import { isAbsolute, join, relative, sep } from "node:path";
275
297
  import { pathToFileURL } from "node:url";
276
298
 
277
299
  const job = JSON.parse(readFileSync(process.argv[2], "utf8"));
278
300
  ${DESCRIBE_HELPERS}
301
+ // The parent's onDisk, for the paths a list names under the output directory.
302
+ function onDisk(path) {
303
+ if (!job.redirect) return path;
304
+ const inside = relative(job.redirect.from, path);
305
+ const leaves = inside === ".." || inside.startsWith(".." + sep) || isAbsolute(inside);
306
+ return leaves ? path : join(job.redirect.to, inside);
307
+ }
308
+
279
309
  // Says why the child gave up in the one place the parent always reads, so a
280
310
  // failure reports the cause and never the text of this script.
281
311
  function fail(message) {
@@ -289,7 +319,7 @@ function entryFile(piece) {
289
319
  if (typeof declared !== "string") return undefined;
290
320
  const path = isAbsolute(declared) ? declared : join(job.projectRoot, declared);
291
321
  if (piece.entry) return path;
292
- const pkgFile = join(path, "package.json");
322
+ const pkgFile = join(onDisk(path), "package.json");
293
323
  if (!existsSync(pkgFile)) return undefined;
294
324
  const pkg = JSON.parse(readFileSync(pkgFile, "utf8"));
295
325
  return join(path, typeof pkg.main === "string" ? pkg.main : "index.mjs");
@@ -297,7 +327,7 @@ function entryFile(piece) {
297
327
 
298
328
  let listModule;
299
329
  try {
300
- listModule = await import(pathToFileURL(job.listPath).href);
330
+ listModule = await import(pathToFileURL(onDisk(job.listPath)).href);
301
331
  } catch (error) {
302
332
  fail(job.listPath + " threw on import: " + (error instanceof Error ? error.message : String(error)));
303
333
  }
@@ -310,9 +340,9 @@ const out = { list, pieces: [], errors: [] };
310
340
  for (const piece of list) {
311
341
  const file = entryFile(piece);
312
342
  // A missing file is the parent's to report, with the message it owns.
313
- if (!file || !existsSync(file)) continue;
343
+ if (!file || !existsSync(onDisk(file))) continue;
314
344
  try {
315
- const mod = await import(pathToFileURL(file).href);
345
+ const mod = await import(pathToFileURL(onDisk(file)).href);
316
346
  const found = findPiece(mod);
317
347
  if (!found) {
318
348
  throw new Error(
@@ -340,6 +370,9 @@ function childFailure(error, outFile) {
340
370
  return `the describe child exited with code ${status ?? "unknown"}`;
341
371
  }
342
372
  function describePieces(projectRoot, listPath) {
373
+ return describePiecesThrough(projectRoot, listPath, void 0);
374
+ }
375
+ function describePiecesThrough(projectRoot, listPath, redirect) {
343
376
  const dir = mkdtempSync(join(tmpdir(), "ph-build-pieces-"));
344
377
  const rel = toPosix(relative(projectRoot, listPath));
345
378
  try {
@@ -350,7 +383,8 @@ function describePieces(projectRoot, listPath) {
350
383
  writeFileSync(jobFile, JSON.stringify({
351
384
  projectRoot,
352
385
  listPath,
353
- outFile
386
+ outFile,
387
+ redirect
354
388
  }));
355
389
  try {
356
390
  execFileSync(process.execPath, [scriptFile, jobFile], {
@@ -369,17 +403,22 @@ function describePieces(projectRoot, listPath) {
369
403
  }
370
404
  }
371
405
  function resolvePieceLocation(piece, projectRoot, outDir) {
406
+ return locatePieceThrough(piece, projectRoot, outDir, void 0);
407
+ }
408
+ function locatePieceThrough(piece, projectRoot, outDir, redirect) {
372
409
  const declared = piece.entry ?? piece.bundle;
373
410
  if (typeof declared !== "string" || declared === "") throw new Error(`pieces: "${piece.name}" declares neither an entry nor a bundle`);
374
- const path = isAbsolute(declared) ? declared : join(projectRoot, declared);
411
+ const shown = isAbsolute(declared) ? toLogical(declared, redirect) : declared;
412
+ const path = isAbsolute(declared) ? shown : join(projectRoot, declared);
375
413
  const form = piece.entry ? "entry" : "bundle";
376
- if (!(form === "entry" ? statSafe(path)?.isFile() : statSafe(join(path, "package.json"))?.isFile())) throw new Error(`pieces: "${piece.name}" declares ${declared}, which is missing`);
414
+ const disk = onDisk(path, redirect);
415
+ if (!(form === "entry" ? statSafe(disk)?.isFile() : statSafe(join(disk, "package.json"))?.isFile())) throw new Error(`pieces: "${piece.name}" declares ${shown}, which is missing`);
377
416
  const dir = form === "entry" ? dirname(path) : path;
378
417
  const piecesRoot = resolve(projectRoot, outDir, "node", "pieces");
379
418
  const inside = relative(piecesRoot, dir);
380
419
  if (inside === "" || inside.startsWith("..") || isAbsolute(inside)) {
381
420
  const expected = toPosix(join(outDir, "node", "pieces"));
382
- throw new Error(`pieces: "${piece.name}" declares ${declared}, which is outside ${expected}/; a piece is built to ${expected}/<dir>/index.mjs and its entry must point there`);
421
+ throw new Error(`pieces: "${piece.name}" declares ${shown}, which is outside ${expected}/; a piece is built to ${expected}/<dir>/index.mjs and its entry must point there`);
383
422
  }
384
423
  return form === "entry" ? {
385
424
  dir,
@@ -459,6 +498,11 @@ const count = (record) => typeof record === "object" && record !== null ? Object
459
498
  async function buildPieces(target, pkg, options) {
460
499
  const { projectRoot, outDir } = target;
461
500
  assertPiecesOutDir(target);
501
+ const redirect = target.writeTo ? {
502
+ from: resolve(projectRoot, outDir),
503
+ to: target.writeTo,
504
+ toReal: realpathSafe(target.writeTo)
505
+ } : void 0;
462
506
  const externalByDir = /* @__PURE__ */ new Map();
463
507
  for (const piece of target.pieces) {
464
508
  console.log(`\n▶ Building piece ${piece.dir}...`);
@@ -466,7 +510,7 @@ async function buildPieces(target, pkg, options) {
466
510
  const external = /* @__PURE__ */ new Map();
467
511
  await options.bundle(buildPieceBuildConfig({
468
512
  entry: resolve(projectRoot, piece.entry),
469
- outDir,
513
+ outDir: onDisk(outDir, redirect),
470
514
  ...options.trace ? { plugins: [externalDepsPlugin(options.trace, external, {
471
515
  root: projectRoot,
472
516
  ...options.cache ? { cache: options.cache } : {}
@@ -476,12 +520,13 @@ async function buildPieces(target, pkg, options) {
476
520
  externalByDir.set(outDir, external);
477
521
  }
478
522
  const listPath = pieceListPath(target);
479
- if (!existsSync(listPath)) throw new Error(`pieces: ${toPosix(relative(projectRoot, listPath))} was not built; pieces/index.ts must export the list of pieces this package ships`);
480
- const described = describePieces(projectRoot, listPath);
523
+ if (!existsSync(onDisk(listPath, redirect))) throw new Error(`pieces: ${toPosix(relative(projectRoot, listPath))} was not built; pieces/index.ts must export the list of pieces this package ships`);
524
+ const described = describePiecesThrough(projectRoot, listPath, redirect);
481
525
  const built = [];
482
526
  const listedDirs = /* @__PURE__ */ new Set();
483
527
  for (const piece of described.list) {
484
- const location = resolvePieceLocation(piece, projectRoot, outDir);
528
+ const location = locatePieceThrough(piece, projectRoot, outDir, redirect);
529
+ const dirOnDisk = onDisk(location.dir, redirect);
485
530
  assertPieceVersion(piece, pkg);
486
531
  const failure = described.errors.find((e) => e.name === piece.name);
487
532
  if (failure) throw new Error(`pieces: "${piece.name}" could not be described: ${failure.message}`);
@@ -490,7 +535,7 @@ async function buildPieces(target, pkg, options) {
490
535
  const metadata = found.metadata;
491
536
  const relDir = toPosix(relative(projectRoot, location.dir));
492
537
  listedDirs.add(relDir);
493
- writeFileSync(join(location.dir, "descriptor.json"), JSON.stringify(pieceDescriptor(piece, pkg.version, metadata), createJsonReplacer(), 2) + "\n");
538
+ writeFileSync(join(dirOnDisk, "descriptor.json"), JSON.stringify(pieceDescriptor(piece, pkg.version, metadata), createJsonReplacer(), 2) + "\n");
494
539
  const piecePackage = location.form === "entry" && location.entryFile ? piecePackageJson({
495
540
  name: piece.name,
496
541
  version: pkg.version,
@@ -498,8 +543,8 @@ async function buildPieces(target, pkg, options) {
498
543
  main: relative(location.dir, location.entryFile),
499
544
  license: pkg.license,
500
545
  dependencies: externalDependencyVersions(externalByDir.get(resolve(location.dir))?.values() ?? [])
501
- }) : bundlePackageJson(location.dir, pkg.version);
502
- writeFileSync(join(location.dir, "package.json"), JSON.stringify(piecePackage, null, 2) + "\n");
546
+ }) : bundlePackageJson(dirOnDisk, pkg.version);
547
+ writeFileSync(join(dirOnDisk, "package.json"), JSON.stringify(piecePackage, null, 2) + "\n");
503
548
  console.log(`piece: ${piece.name}@${pkg.version} -> ${relDir} (${count(metadata.actions)} actions, ${count(metadata.triggers)} triggers)`);
504
549
  built.push({
505
550
  name: piece.name,