@powerhousedao/ph-cli 6.3.0-dev.9 → 6.4.0-next.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 (115) hide show
  1. package/dist/{build-DuNe06I0.mjs → build-D8_USaRh.mjs} +88 -16
  2. package/dist/build-D8_USaRh.mjs.map +1 -0
  3. package/dist/build-FVWjguYr.mjs +4 -0
  4. package/dist/{check-VOIkykDt.mjs → check-CVRb-CJD.mjs} +3 -3
  5. package/dist/{check-B8oqVMg7.mjs → check-EpzhIKt1.mjs} +4 -4
  6. package/dist/{check-B8oqVMg7.mjs.map → check-EpzhIKt1.mjs.map} +1 -1
  7. package/dist/{check-EzkmRLx6.mjs → check-_K6EAsag.mjs} +4 -4
  8. package/dist/{check-EzkmRLx6.mjs.map → check-_K6EAsag.mjs.map} +1 -1
  9. package/dist/{cli-connect-override-D22yFWlC.mjs → cli-connect-override-DwlViDdp.mjs} +5 -5
  10. package/dist/{cli-connect-override-D22yFWlC.mjs.map → cli-connect-override-DwlViDdp.mjs.map} +1 -1
  11. package/dist/cli.mjs +15 -31
  12. package/dist/cli.mjs.map +1 -1
  13. package/dist/{compound-DKi56SSx-CXQHhS6t.mjs → compound-n-bO0qKh-Dx7fgKWx.mjs} +658 -275
  14. package/dist/compound-n-bO0qKh-Dx7fgKWx.mjs.map +1 -0
  15. package/dist/{connect-build-Be8C4skj.mjs → connect-build-BIkm5fcG.mjs} +6 -6
  16. package/dist/{connect-build-Be8C4skj.mjs.map → connect-build-BIkm5fcG.mjs.map} +1 -1
  17. package/dist/{connect-config-CVU4xhti.mjs → connect-config-CH0KQqyU.mjs} +4 -4
  18. package/dist/{connect-config-CVU4xhti.mjs.map → connect-config-CH0KQqyU.mjs.map} +1 -1
  19. package/dist/{connect-preview-CdFvlANO.mjs → connect-preview-BvxXGo_W.mjs} +7 -6
  20. package/dist/connect-preview-BvxXGo_W.mjs.map +1 -0
  21. package/dist/{connect-studio-BnfhpIv8.mjs → connect-studio-C-9WE2Bg.mjs} +16 -7
  22. package/dist/connect-studio-C-9WE2Bg.mjs.map +1 -0
  23. package/dist/definitions-worker.mjs +1 -1
  24. package/dist/{dist-DXcB8fAF.mjs → dist-Dbvm_SmC.mjs} +51 -104
  25. package/dist/dist-Dbvm_SmC.mjs.map +1 -0
  26. package/dist/{explain-8OEXF2Dy.mjs → explain-DB7uoJkY.mjs} +67 -21
  27. package/dist/explain-DB7uoJkY.mjs.map +1 -0
  28. package/dist/{export-DqbcbFU5.mjs → export-DuYGBuQZ.mjs} +4 -4
  29. package/dist/{export-DqbcbFU5.mjs.map → export-DuYGBuQZ.mjs.map} +1 -1
  30. package/dist/{generate-all-0YOnlZM0.mjs → generate-all-Mj_xGZZN.mjs} +4 -4
  31. package/dist/{generate-all-0YOnlZM0.mjs.map → generate-all-Mj_xGZZN.mjs.map} +1 -1
  32. package/dist/{generate-desktop-shell-BovoRsR6.mjs → generate-desktop-shell-DD9o4Rcl.mjs} +7 -17
  33. package/dist/generate-desktop-shell-DD9o4Rcl.mjs.map +1 -0
  34. package/dist/{get-version-JkZQOcO1.mjs → get-version-DXnnvS_S.mjs} +4 -4
  35. package/dist/{get-version-JkZQOcO1.mjs.map → get-version-DXnnvS_S.mjs.map} +1 -1
  36. package/dist/{index-H3AYe65i.d.mts → index-V7TKBh-y.d.mts} +57 -3
  37. package/dist/index-V7TKBh-y.d.mts.map +1 -0
  38. package/dist/{inspect-zWJnBDMJ.mjs → inspect-Bxa9y7zM.mjs} +4 -4
  39. package/dist/{inspect-zWJnBDMJ.mjs.map → inspect-Bxa9y7zM.mjs.map} +1 -1
  40. package/dist/{mcp-vSCc5KHI.mjs → mcp-DKqOFZlX.mjs} +7 -7
  41. package/dist/mcp-DKqOFZlX.mjs.map +1 -0
  42. package/dist/{migrate-C27-tFFC.mjs → migrate-CQpwBF1l.mjs} +5 -5
  43. package/dist/{migrate-C27-tFFC.mjs.map → migrate-CQpwBF1l.mjs.map} +1 -1
  44. package/dist/{migrate-document-models-CKnqQnRh.mjs → migrate-document-models-DpXzLDuu.mjs} +4 -4
  45. package/dist/{migrate-document-models-CKnqQnRh.mjs.map → migrate-document-models-DpXzLDuu.mjs.map} +1 -1
  46. package/dist/{migrate-subgraphs-B2nTiJ-j.mjs → migrate-subgraphs-CdfkO6l9.mjs} +54 -14
  47. package/dist/migrate-subgraphs-CdfkO6l9.mjs.map +1 -0
  48. package/dist/migrate-subgraphs-CoUuwzmR.mjs +4 -0
  49. package/dist/ph-cli-commands-Daeqh5Me.mjs +4 -0
  50. package/dist/{ph-cli-commands-DhoNXWGf.mjs → ph-cli-commands-Dq-tIYhy.mjs} +30 -182
  51. package/dist/ph-cli-commands-Dq-tIYhy.mjs.map +1 -0
  52. package/dist/run-sugar-Bnab2Z3f.mjs +4 -0
  53. package/dist/run-sugar-DsG2RRgx.mjs +89 -0
  54. package/dist/run-sugar-DsG2RRgx.mjs.map +1 -0
  55. package/dist/runners/connect.d.mts +2 -2
  56. package/dist/runners/connect.d.mts.map +1 -1
  57. package/dist/runners/connect.mjs +30 -18
  58. package/dist/runners/connect.mjs.map +1 -1
  59. package/dist/runners/switchboard.d.mts +3 -3
  60. package/dist/runners/switchboard.mjs +11 -11
  61. package/dist/runners/switchboard.mjs.map +1 -1
  62. package/dist/scripts/generate-commands-docs.ts +2 -8
  63. package/dist/service-args-D6y3L0bm.mjs +49 -0
  64. package/dist/service-args-D6y3L0bm.mjs.map +1 -0
  65. package/dist/sugar-checks-DBk5q_uJ.mjs +175 -0
  66. package/dist/sugar-checks-DBk5q_uJ.mjs.map +1 -0
  67. package/dist/{switchboard-reset-MtTB_GAI.mjs → switchboard-reset-CY6J0lWO.mjs} +4 -4
  68. package/dist/switchboard-reset-CY6J0lWO.mjs.map +1 -0
  69. package/dist/utils-BU25LHRE.mjs +4 -0
  70. package/dist/{utils-9KyRM0mf.mjs → utils-D5VlY5AZ.mjs} +4 -15
  71. package/dist/utils-D5VlY5AZ.mjs.map +1 -0
  72. package/dist/{verify-DCf_nRt8.mjs → verify-C_fL8YsF.mjs} +4 -4
  73. package/dist/{verify-DCf_nRt8.mjs.map → verify-C_fL8YsF.mjs.map} +1 -1
  74. package/dist/{vetra-host-ChTpJiBJ.mjs → vetra-host-CDfny6E8.mjs} +24 -9
  75. package/dist/vetra-host-CDfny6E8.mjs.map +1 -0
  76. package/dist/{vetra-instance-CzhYIjxL.mjs → vetra-instance-DlXAeiU7.mjs} +8 -16
  77. package/dist/{vetra-instance-CzhYIjxL.mjs.map → vetra-instance-DlXAeiU7.mjs.map} +1 -1
  78. package/dist/{vetra-launch-qi10Unax.mjs → vetra-launcher-CYX10K2m.mjs} +14 -32
  79. package/dist/vetra-launcher-CYX10K2m.mjs.map +1 -0
  80. package/dist/vetra-launcher-TDLXj0tY.mjs +4 -0
  81. package/dist/{vetra-switchboard-tzdc14KA.mjs → vetra-switchboard-Ctje6iR1.mjs} +4 -4
  82. package/dist/{vetra-switchboard-tzdc14KA.mjs.map → vetra-switchboard-Ctje6iR1.mjs.map} +1 -1
  83. package/package.json +16 -16
  84. package/dist/build-CnTFRBft.mjs +0 -4
  85. package/dist/build-DuNe06I0.mjs.map +0 -1
  86. package/dist/classic-args-mH_DVsgC.mjs +0 -48
  87. package/dist/classic-args-mH_DVsgC.mjs.map +0 -1
  88. package/dist/classic-warnings-BR0S6lr5.mjs +0 -179
  89. package/dist/classic-warnings-BR0S6lr5.mjs.map +0 -1
  90. package/dist/compound-DKi56SSx-CXQHhS6t.mjs.map +0 -1
  91. package/dist/connect-preview-CdFvlANO.mjs.map +0 -1
  92. package/dist/connect-studio-BnfhpIv8.mjs.map +0 -1
  93. package/dist/connect-studio-D58ByAAn.mjs +0 -4
  94. package/dist/dist-DXcB8fAF.mjs.map +0 -1
  95. package/dist/explain-8OEXF2Dy.mjs.map +0 -1
  96. package/dist/generate-desktop-shell-BovoRsR6.mjs.map +0 -1
  97. package/dist/index-H3AYe65i.d.mts.map +0 -1
  98. package/dist/mcp-vSCc5KHI.mjs.map +0 -1
  99. package/dist/migrate-subgraphs-B1_NRwV7.mjs +0 -4
  100. package/dist/migrate-subgraphs-B2nTiJ-j.mjs.map +0 -1
  101. package/dist/ph-cli-commands-DhoNXWGf.mjs.map +0 -1
  102. package/dist/ph-cli-commands-LIME9alJ.mjs +0 -4
  103. package/dist/run-sugar-DpznOP1e.mjs +0 -56
  104. package/dist/run-sugar-DpznOP1e.mjs.map +0 -1
  105. package/dist/scripts/manage-environment +0 -199
  106. package/dist/scripts/setup-environment +0 -423
  107. package/dist/scripts/setup-environment.ps1 +0 -313
  108. package/dist/switchboard-reset-MtTB_GAI.mjs.map +0 -1
  109. package/dist/utils-9KyRM0mf.mjs.map +0 -1
  110. package/dist/utils-TO9lB8Xs.mjs +0 -4
  111. package/dist/vetra-CVNZ46pK.mjs +0 -352
  112. package/dist/vetra-CVNZ46pK.mjs.map +0 -1
  113. package/dist/vetra-host-ChTpJiBJ.mjs.map +0 -1
  114. package/dist/vetra-launch-qi10Unax.mjs.map +0 -1
  115. package/dist/vetra-switchboard-BrkozIm7.mjs +0 -4
@@ -1,24 +1,25 @@
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]="db74ebe3-2afc-5d72-bac6-8ffa5a897aa0")}catch(e){}}();
3
- import { t as getVersion } from "./get-version-JkZQOcO1.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]="6ffae9e3-5dcc-59db-97a8-a784b03bb946")}catch(e){}}();
3
+ import { t as getVersion } from "./get-version-DXnnvS_S.mjs";
4
4
  import { d as object, f as record, g as union, i as boolean, l as looseObject, m as string, r as array, s as json } from "./schemas-DzgKfQIx.mjs";
5
5
  import { _ as pendingPrefix, a as writeReleaseApproval, c as PH_CLI_BINDING, d as listed, g as LOCK_FILE, h as BUILD_DIRECTORY, i as revisionFiles, l as RELEASE_APPROVAL_PATH, m as packageRevision, o as packRelease, p as changedPaths, s as packedDigests, t as packagePath, v as takeoverPrefix } from "./files-D6_euBBn.mjs";
6
6
  import { n as OFFERED_ROUTES_MODULE, r as syncProjectConnectRoutes, t as HOST_ROUTES_DIR } from "./sync-connect-routes-t0Slg-P6.mjs";
7
7
  import { r as noConnectImports } from "./offered-routes-imports-CalXK9dh.mjs";
8
8
  import { createRequire } from "node:module";
9
+ import { CLINT_PACKAGE } from "@powerhousedao/shared/clis/constants";
9
10
  import { accessSync, chmodSync, constants, cpSync, existsSync, linkSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, rmdirSync, statSync, symlinkSync, utimesSync, writeFileSync } from "node:fs";
10
11
  import path, { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
11
12
  import { execFileSync, execSync, fork, spawn } from "node:child_process";
12
13
  import { SpawnError, spawnAsync } from "@powerhousedao/shared/clis";
14
+ import { EXTERNALIZABLE_SHARED_SPECIFIERS, findSharedImports } from "@powerhousedao/shared/connect";
13
15
  import { createHash, randomBytes } from "node:crypto";
14
- import { assertPiecesOutDir, buildPieces, createDetectionCache, expandEntryGlobs, externalDependencyVersions, externalDepsPlugin, pieceListPath, planPieces, projectPath, syncDistManifest, undeclaredExternalDependencies } from "@powerhousedao/shared/build-pieces";
16
+ import { assertPiecesOutDir, buildPieces, createDetectionCache, expandEntryGlobs, externalDependencyVersions, externalDepsPlugin, packageNameOf, pieceListPath, planPieces, projectPath, syncDistManifest, undeclaredExternalDependencies } from "@powerhousedao/shared/build-pieces";
15
17
  import { detect, resolveCommand } from "package-manager-detector";
16
18
  import { pathWithin, realPathThroughExistingParent } from "@powerhousedao/shared/clis/real-paths";
17
19
  import { hostname, tmpdir } from "node:os";
18
20
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
19
21
  import { satisfies } from "semver";
20
- import { browserEntry, buildBrowserBuildConfig, buildNodeBuildConfig, findBundledSharedDeps } from "@powerhousedao/shared/build-config";
21
- import { EXTERNALIZABLE_SHARED_SPECIFIERS, findSharedImports } from "@powerhousedao/shared/connect";
22
+ import { CLI_ENTRY, browserEntry, buildBrowserBuildConfig, buildCliBuildConfig, buildNodeBuildConfig, declaredPackages, findBundledSharedDeps } from "@powerhousedao/shared/build-config";
22
23
  import { readPackage } from "read-pkg";
23
24
  import { build, globalLogger } from "tsdown";
24
25
  import { localPackageNames, packageStyleEntry, packageStylesheet } from "@powerhousedao/shared/clis/package-style";
@@ -2026,11 +2027,11 @@ async function openBuildSession(options) {
2026
2027
  }
2027
2028
  //#endregion
2028
2029
  //#region src/utils/offered-routes-manifest.ts
2029
- function withOfferedRoutes(json, offers) {
2030
+ function withFlag(json, flag, on) {
2030
2031
  const manifest = JSON.parse(json);
2031
- if (offers ? manifest.connectRoutes === true : !("connectRoutes" in manifest)) return json;
2032
- if (offers) manifest.connectRoutes = true;
2033
- else delete manifest.connectRoutes;
2032
+ if (on ? manifest[flag] === true : !(flag in manifest)) return json;
2033
+ if (on) manifest[flag] = true;
2034
+ else delete manifest[flag];
2034
2035
  return `${JSON.stringify(manifest, null, 2)}\n`;
2035
2036
  }
2036
2037
  const slashes = (path) => path.replaceAll("\\", "/");
@@ -2043,18 +2044,25 @@ function offeredRoutesManifest(projectRoot, offers) {
2043
2044
  transform(code, id) {
2044
2045
  if (slashes(id) !== manifestPath) return null;
2045
2046
  return {
2046
- code: withOfferedRoutes(code, offers),
2047
+ code: withFlag(code, "connectRoutes", offers),
2047
2048
  map: null
2048
2049
  };
2049
2050
  }
2050
2051
  };
2051
2052
  }
2052
- /** Sets `connectRoutes` in the dist copy of the manifest. */
2053
- function markOfferedRoutes(dir, offers) {
2053
+ function markDistManifest(dir, flag, on) {
2054
2054
  const manifestPath = join(dir, "powerhouse.manifest.json");
2055
2055
  if (!existsSync(manifestPath)) return;
2056
2056
  const json = readFileSync(manifestPath, "utf-8");
2057
- writeFileSync(manifestPath, withOfferedRoutes(json, offers));
2057
+ writeFileSync(manifestPath, withFlag(json, flag, on));
2058
+ }
2059
+ /** Sets `connectRoutes` in the dist copy of the manifest. */
2060
+ function markOfferedRoutes(dir, offers) {
2061
+ markDistManifest(dir, "connectRoutes", offers);
2062
+ }
2063
+ /** Sets `cli` in the dist copy of the manifest: the package exports a Cli. */
2064
+ function markCliExport(dir, ships) {
2065
+ markDistManifest(dir, "cli", ships);
2058
2066
  }
2059
2067
  //#endregion
2060
2068
  //#region src/services/package-build/steps/stage-logger.ts
@@ -2185,11 +2193,72 @@ const nodeBundleStep = {
2185
2193
  assertExternalDependenciesDeclared(projectRoot, [...findings.external.values()], findings.pkg);
2186
2194
  }
2187
2195
  };
2196
+ /** Adds to `found` each of `declared` that the built chunks import. */
2197
+ function importedPackages(declared, found) {
2198
+ return {
2199
+ name: "ph:cli-declared-imports",
2200
+ generateBundle(_options, bundle) {
2201
+ for (const output of Object.values(bundle)) {
2202
+ if (output.type !== "chunk") continue;
2203
+ for (const specifier of [...output.imports, ...output.dynamicImports]) {
2204
+ const name = packageNameOf(specifier);
2205
+ if (name && declared.includes(name)) found.add(name);
2206
+ }
2207
+ }
2208
+ }
2209
+ };
2210
+ }
2211
+ const CLINT_PEER_MISSING = `a package with a Cli declares \`${CLINT_PACKAGE}\` as a peer: run \`ph migrate\`, or add it`;
2212
+ function assertClintDeclared(pkg, release) {
2213
+ if (pkg.peerDependencies?.[CLINT_PACKAGE] !== void 0 || pkg.dependencies?.[CLINT_PACKAGE] !== void 0) return;
2214
+ if (release) throw new BuildRefusal(`✘ ${CLINT_PEER_MISSING}`);
2215
+ console.warn(`⚠ ${CLINT_PEER_MISSING}`);
2216
+ }
2217
+ const cliBundleStep = {
2218
+ id: "cli-bundle",
2219
+ run: async (ctx) => {
2220
+ const { args, projectRoot, session, trace, detection, findings } = ctx;
2221
+ const entry = join(projectRoot, CLI_ENTRY);
2222
+ if (!existsSync(entry)) return;
2223
+ const pkg = findings.pkg ?? await readPackage({ cwd: projectRoot });
2224
+ assertClintDeclared(pkg, args.release);
2225
+ const declared = declaredPackages(pkg);
2226
+ const external = /* @__PURE__ */ new Map();
2227
+ const imported = /* @__PURE__ */ new Set();
2228
+ await build({
2229
+ ...buildCliBuildConfig({
2230
+ entry,
2231
+ outDir: join(session.stage(), "node", "cli"),
2232
+ declared,
2233
+ sharedDeps: !args.noSharedDeps,
2234
+ plugins: [externalDepsPlugin(trace, external, {
2235
+ root: projectRoot,
2236
+ ignoreDirs: ["editors"],
2237
+ forbidDirs: ["document-models", "scalars"],
2238
+ cache: detection
2239
+ }), importedPackages(declared, imported)]
2240
+ }),
2241
+ customLogger: stageLogger(ctx)
2242
+ });
2243
+ assertExternalDependenciesDeclared(projectRoot, [...external.values()], pkg);
2244
+ if (imported.size > 0) console.log(imported.size === 1 ? "cli: 1 declared package stays external, installed with the package" : `cli: ${imported.size} declared packages stay external, installed with the package`);
2245
+ }
2246
+ };
2188
2247
  /** The output entry each bundle step writes, which tsdown empties first. */
2189
2248
  const CLEANED_BY_STEP = /* @__PURE__ */ new Map([[browserBundleStep.id, "browser"], [nodeBundleStep.id, "node"]]);
2190
2249
  /** The output entries `steps` empty before they write them, by step id. */
2191
2250
  const entriesCleanedBy = (steps) => steps.flatMap(({ id }) => CLEANED_BY_STEP.get(id) ?? []);
2192
2251
  //#endregion
2252
+ //#region src/services/package-build/steps/cli-export.ts
2253
+ const cliExportStep = {
2254
+ id: "cli-export",
2255
+ run: ({ session }) => {
2256
+ const stage = session.stage();
2257
+ markCliExport(stage, existsSync(join(stage, "node", "cli", "index.mjs")));
2258
+ return Promise.resolve();
2259
+ }
2260
+ };
2261
+ //#endregion
2193
2262
  //#region src/services/package-build/steps/connect-routes.ts
2194
2263
  const connectRoutesStep = {
2195
2264
  id: "connect-routes",
@@ -2655,7 +2724,8 @@ const releaseStartStep = {
2655
2724
  /** Exports `ph init` declares whose entry the build skips when its source is absent. */
2656
2725
  const OPTIONAL_EXPORTS = {
2657
2726
  "./scalars": "scalars/index.ts",
2658
- "./pieces": "pieces/index.ts"
2727
+ "./pieces": "pieces/index.ts",
2728
+ "./cli": "cli/index.ts"
2659
2729
  };
2660
2730
  const unbuiltExports = (projectRoot, findings) => /* @__PURE__ */ new Set([...Object.entries(OPTIONAL_EXPORTS).filter(([, source]) => !existsSync(join(projectRoot, source))).map(([subpath]) => subpath), ...findings.offersRoutes ? [] : ["./connect-routes"]]);
2661
2731
  const notWritten = (why) => new BuildRefusal(`✘ No release approval was written: ${why}. The new output is in place; build again with --release to approve it.`);
@@ -2867,9 +2937,11 @@ const standardBuildSteps = [
2867
2937
  definitionsStep,
2868
2938
  browserBundleStep,
2869
2939
  nodeBundleStep,
2940
+ cliBundleStep,
2870
2941
  piecesStep,
2871
2942
  distManifestStep,
2872
2943
  offeredRoutesStep,
2944
+ cliExportStep,
2873
2945
  stylesheetStep,
2874
2946
  releaseApprovalStep
2875
2947
  ];
@@ -3063,5 +3135,5 @@ async function runBuild(args, options = {}) {
3063
3135
  //#endregion
3064
3136
  export { assertExternalDependenciesDeclared as i, createTraceFiles as n, assertManifestNameMatchesPackage as r, runBuild as t };
3065
3137
 
3066
- //# sourceMappingURL=build-DuNe06I0.mjs.map
3067
- //# debugId=db74ebe3-2afc-5d72-bac6-8ffa5a897aa0
3138
+ //# sourceMappingURL=build-D8_USaRh.mjs.map
3139
+ //# debugId=6ffae9e3-5dcc-59db-97a8-a784b03bb946