ph-cmd 6.2.3-dev.97 → 6.2.3-dev.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +3 -3
- package/dist/delegate-init-DAfxbQ9U.mjs +4 -0
- package/dist/{delegate-init-D1fb4-sj.mjs → delegate-init-XVkwNFVF.mjs} +47 -6
- package/dist/delegate-init-XVkwNFVF.mjs.map +1 -0
- package/dist/{get-version-DrBcBa9F.mjs → get-version-CT-1CzvF.mjs} +4 -4
- package/dist/{get-version-DrBcBa9F.mjs.map → get-version-CT-1CzvF.mjs.map} +1 -1
- package/dist/{ph-cli-CbbzvI-Z.mjs → ph-cli-BPJ6fFsB.mjs} +4 -4
- package/dist/{ph-cli-CbbzvI-Z.mjs.map → ph-cli-BPJ6fFsB.mjs.map} +1 -1
- package/dist/{run-CWQ__mHD.mjs → run-BK8ClRWp.mjs} +9 -165
- package/dist/run-BK8ClRWp.mjs.map +1 -0
- package/dist/self-update-CUR2SdGf.mjs +4 -0
- package/dist/self-update-D4a3o9wb.mjs +174 -0
- package/dist/self-update-D4a3o9wb.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/delegate-init-CUXvo-V7.mjs +0 -4
- package/dist/delegate-init-D1fb4-sj.mjs.map +0 -1
- package/dist/run-CWQ__mHD.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
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]="40e5c8a7-9e6a-59bf-ba55-66821c9eb08a")}catch(e){}}();
|
|
4
|
-
import { t as getVersion } from "./get-version-
|
|
4
|
+
import { t as getVersion } from "./get-version-CT-1CzvF.mjs";
|
|
5
5
|
import { r as maybeNotifyOutdated } from "./version-check-D9Yeup9S.mjs";
|
|
6
6
|
import { initCliTelemetry } from "@powerhousedao/shared/clis/telemetry";
|
|
7
7
|
import { assertNodeVersion } from "@powerhousedao/shared/clis/utils";
|
|
@@ -31,11 +31,11 @@ function detectPackageManager() {
|
|
|
31
31
|
* any code is parsed to avoid errors on startup due to unsupported dependencies.
|
|
32
32
|
*/
|
|
33
33
|
async function runPhCliCommand(phCliCommand) {
|
|
34
|
-
const { executePhCliCommand } = await import("./ph-cli-
|
|
34
|
+
const { executePhCliCommand } = await import("./ph-cli-BPJ6fFsB.mjs");
|
|
35
35
|
return await executePhCliCommand(phCliCommand);
|
|
36
36
|
}
|
|
37
37
|
async function runPhCmdCommand(args) {
|
|
38
|
-
const { run } = await import("./run-
|
|
38
|
+
const { run } = await import("./run-BK8ClRWp.mjs");
|
|
39
39
|
return await run(args);
|
|
40
40
|
}
|
|
41
41
|
let sentryClient = void 0;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { t as delegateInit } from "./delegate-init-XVkwNFVF.mjs";
|
|
2
|
+
export { delegateInit };
|
|
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]="75342a3e-cd24-562a-813b-0d8b6434242e")}catch(e){}}();
|
|
4
|
+
//# debugId=75342a3e-cd24-562a-813b-0d8b6434242e
|
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b6152fb3-d1b7-5fce-9f15-a5f1d1ab644f")}catch(e){}}();
|
|
3
3
|
import { execSync } from "node:child_process";
|
|
4
|
+
//#region src/utils/init-package-manager.ts
|
|
5
|
+
/**
|
|
6
|
+
* Decides which package manager `ph init` runs ph-cli with, and which flag
|
|
7
|
+
* to forward so ph-cli installs the project's dependencies with the same one.
|
|
8
|
+
*
|
|
9
|
+
* An explicit flag wins and nothing is forwarded (the user's own flag already
|
|
10
|
+
* reaches ph-cli). With none, the detected manager is forwarded as `--<pm>`.
|
|
11
|
+
* `--clone` only works with pnpm or npm, so detection is limited to those.
|
|
12
|
+
*/
|
|
13
|
+
function resolveInitPackageManager(args, detect) {
|
|
14
|
+
const { npm, pnpm, yarn, bun, packageManager } = args;
|
|
15
|
+
const explicit = npm ? "npm" : pnpm ? "pnpm" : yarn ? "yarn" : bun ? "bun" : packageManager;
|
|
16
|
+
if (explicit) return {
|
|
17
|
+
pm: explicit,
|
|
18
|
+
forwardedFlags: [],
|
|
19
|
+
detectedFrom: void 0
|
|
20
|
+
};
|
|
21
|
+
const detected = detect(args.clone ? { allowed: ["pnpm", "npm"] } : {});
|
|
22
|
+
const userSetAnyKey = [
|
|
23
|
+
npm,
|
|
24
|
+
pnpm,
|
|
25
|
+
yarn,
|
|
26
|
+
bun
|
|
27
|
+
].some((v) => v !== void 0);
|
|
28
|
+
return {
|
|
29
|
+
pm: detected.pm,
|
|
30
|
+
forwardedFlags: userSetAnyKey ? [] : [`--${detected.pm}`],
|
|
31
|
+
detectedFrom: detected.source === "fallback" ? void 0 : detected.source
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
4
35
|
//#region src/utils/delegate-init.ts
|
|
5
36
|
const PH_CLI_PACKAGE = "@powerhousedao/ph-cli";
|
|
6
37
|
const MIN_PH_CLI_MAJOR = 6;
|
|
@@ -14,7 +45,7 @@ const MIN_PH_CLI_MAJOR = 6;
|
|
|
14
45
|
* fix-up + exit.
|
|
15
46
|
*/
|
|
16
47
|
async function delegateInit(args, extraForwardedArgs = []) {
|
|
17
|
-
const { fetchNpmVersionFromRegistryForTag, handleMutuallyExclusiveOptions,
|
|
48
|
+
const { detectPackageManager, fetchNpmVersionFromRegistryForTag, handleMutuallyExclusiveOptions, parseTag } = await import("@powerhousedao/shared/clis");
|
|
18
49
|
handleMutuallyExclusiveOptions({
|
|
19
50
|
tag: args.tag,
|
|
20
51
|
version: args.version,
|
|
@@ -31,8 +62,18 @@ async function delegateInit(args, extraForwardedArgs = []) {
|
|
|
31
62
|
}, "package manager");
|
|
32
63
|
const tag = parseTag(args);
|
|
33
64
|
const phCliVersionOrTag = args.version ?? tag;
|
|
34
|
-
const
|
|
35
|
-
const
|
|
65
|
+
const { detectGlobalInstall, runningEntryRealPath } = await import("./self-update-CUR2SdGf.mjs");
|
|
66
|
+
const installedWith = detectGlobalInstall(await runningEntryRealPath()).pm ?? void 0;
|
|
67
|
+
const { pm, forwardedFlags, detectedFrom } = resolveInitPackageManager(args, (options) => detectPackageManager({
|
|
68
|
+
...options,
|
|
69
|
+
installedWith
|
|
70
|
+
}));
|
|
71
|
+
if (detectedFrom) console.log(`Using ${pm} (detected). Pass --npm, --pnpm, --yarn or --bun to choose another.`);
|
|
72
|
+
const forwardedArgs = [
|
|
73
|
+
...extraForwardedArgs,
|
|
74
|
+
...forwardedFlags,
|
|
75
|
+
...process.argv.slice(3)
|
|
76
|
+
];
|
|
36
77
|
let resolvedVersion = args.version;
|
|
37
78
|
try {
|
|
38
79
|
if (!resolvedVersion) resolvedVersion = await fetchNpmVersionFromRegistryForTag(PH_CLI_PACKAGE, tag);
|
|
@@ -69,5 +110,5 @@ async function delegateInit(args, extraForwardedArgs = []) {
|
|
|
69
110
|
//#endregion
|
|
70
111
|
export { delegateInit as t };
|
|
71
112
|
|
|
72
|
-
//# sourceMappingURL=delegate-init-
|
|
73
|
-
//# debugId=
|
|
113
|
+
//# sourceMappingURL=delegate-init-XVkwNFVF.mjs.map
|
|
114
|
+
//# debugId=b6152fb3-d1b7-5fce-9f15-a5f1d1ab644f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate-init-XVkwNFVF.mjs","sources":["../src/utils/init-package-manager.ts","../src/utils/delegate-init.ts"],"sourcesContent":["import type { Agent } from \"package-manager-detector\";\n\nexport type DetectFn = (options: { allowed?: readonly Agent[] }) => {\n pm: Agent;\n source: \"user-agent\" | \"install\" | \"path\" | \"fallback\";\n};\n\nexport interface InitPackageManagerArgs {\n packageManager?: Agent;\n npm?: boolean;\n pnpm?: boolean;\n yarn?: boolean;\n bun?: boolean;\n clone?: string;\n}\n\n/**\n * Decides which package manager `ph init` runs ph-cli with, and which flag\n * to forward so ph-cli installs the project's dependencies with the same one.\n *\n * An explicit flag wins and nothing is forwarded (the user's own flag already\n * reaches ph-cli). With none, the detected manager is forwarded as `--<pm>`.\n * `--clone` only works with pnpm or npm, so detection is limited to those.\n */\nexport function resolveInitPackageManager(\n args: InitPackageManagerArgs,\n detect: DetectFn,\n): {\n pm: Agent;\n forwardedFlags: string[];\n detectedFrom?: \"user-agent\" | \"install\" | \"path\";\n} {\n const { npm, pnpm, yarn, bun, packageManager } = args;\n const explicit: Agent | undefined = npm\n ? \"npm\"\n : pnpm\n ? \"pnpm\"\n : yarn\n ? \"yarn\"\n : bun\n ? \"bun\"\n : packageManager;\n if (explicit) {\n return { pm: explicit, forwardedFlags: [], detectedFrom: undefined };\n }\n\n const detected = detect(args.clone ? { allowed: [\"pnpm\", \"npm\"] } : {});\n // ph-cli rejects two package-manager keys, and `--npm=false` counts as one.\n const userSetAnyKey = [npm, pnpm, yarn, bun].some((v) => v !== undefined);\n return {\n pm: detected.pm,\n forwardedFlags: userSetAnyKey ? [] : [`--${detected.pm}`],\n detectedFrom: detected.source === \"fallback\" ? undefined : detected.source,\n };\n}\n","import type { Agent } from \"package-manager-detector\";\nimport { execSync } from \"node:child_process\";\nimport { resolveInitPackageManager } from \"./init-package-manager.js\";\n\nconst PH_CLI_PACKAGE = \"@powerhousedao/ph-cli\";\n// `init` was added to ph-cli in the 6.x rewrite. Older versions (still on\n// the `latest` tag at time of writing) shell out via commander and bail with\n// a confusing \"unknown command 'init'\" error after a 90-second dlx install.\n// This floor lets us fail fast with an actionable message instead.\nconst MIN_PH_CLI_MAJOR = 6;\n\n/**\n * Subset of `initArgs` the delegator actually inspects. Keeping this loose\n * lets `setup-globals` reuse the helper without an extra type import dance.\n */\nexport interface DelegateInitArgs {\n packageManager?: Agent;\n npm?: boolean;\n pnpm?: boolean;\n yarn?: boolean;\n bun?: boolean;\n tag?: string;\n version?: string;\n dev?: boolean;\n staging?: boolean;\n rc?: boolean;\n debug?: boolean;\n clone?: string;\n}\n\n/**\n * Resolves a concrete `@powerhousedao/ph-cli` version, verifies it's >= 6.x,\n * and shells out via the user's package manager (npx / pnpm dlx / etc.) to\n * run `ph-cli init`. Used by both `ph init` (forwards verbatim) and\n * `ph setup-globals` (forwards with `--name .ph` injected after chdir to ~).\n *\n * Does NOT call `process.exit`: callers are responsible for any post-init\n * fix-up + exit.\n */\nexport async function delegateInit(\n args: DelegateInitArgs,\n extraForwardedArgs: string[] = [],\n): Promise<void> {\n const {\n detectPackageManager,\n fetchNpmVersionFromRegistryForTag,\n handleMutuallyExclusiveOptions,\n parseTag,\n } = await import(\"@powerhousedao/shared/clis\");\n\n handleMutuallyExclusiveOptions(\n {\n tag: args.tag,\n version: args.version,\n dev: args.dev,\n staging: args.staging,\n rc: args.rc,\n },\n \"versioning strategy\",\n );\n\n handleMutuallyExclusiveOptions(\n {\n npm: args.npm,\n pnpm: args.pnpm,\n yarn: args.yarn,\n bun: args.bun,\n packageManager: args.packageManager,\n },\n \"package manager\",\n );\n\n const tag = parseTag(args);\n const phCliVersionOrTag = args.version ?? tag;\n // How ph itself was installed globally (null for a source checkout).\n const { detectGlobalInstall, runningEntryRealPath } =\n await import(\"./self-update.js\");\n const installedWith =\n detectGlobalInstall(await runningEntryRealPath()).pm ?? undefined;\n const { pm, forwardedFlags, detectedFrom } = resolveInitPackageManager(\n args,\n (options) => detectPackageManager({ ...options, installedWith }),\n );\n if (detectedFrom) {\n console.log(\n `Using ${pm} (detected). Pass --npm, --pnpm, --yarn or --bun to choose another.`,\n );\n }\n // `process.argv` here is `[node, ph-cmd-bin, <subcommand>, ...userArgs]`.\n // Forward everything from the user, prepending caller-supplied flags and\n // the detected package manager, so ph-cli installs the project's\n // dependencies with the same manager that ran it.\n const forwardedArgs = [\n ...extraForwardedArgs,\n ...forwardedFlags,\n ...process.argv.slice(3),\n ];\n\n // Resolve the tag to a concrete version up front and verify it's >= 6.x.\n // `--version` is user-supplied so we trust it and only resolve when a tag\n // (latest/staging/dev) is in play.\n let resolvedVersion = args.version;\n try {\n if (!resolvedVersion) {\n resolvedVersion = await fetchNpmVersionFromRegistryForTag(\n PH_CLI_PACKAGE,\n tag,\n );\n }\n } catch (err) {\n // Network/registry hiccup — fall through to the dlx so a flaky\n // connection doesn't block the user. The dlx will surface its own\n // error if the version genuinely can't be installed.\n if (args.debug) {\n console.error(\">>> ph-cli version resolution skipped:\", err);\n }\n }\n const { coerce } = await import(\"semver\");\n const parsed = resolvedVersion ? coerce(resolvedVersion) : null;\n if (parsed && parsed.major < MIN_PH_CLI_MAJOR) {\n // Print + exit (rather than throw) to avoid the cli.ts catch handler\n // shipping this expected user-input error to Sentry.\n console.error(\n `${PH_CLI_PACKAGE}@${phCliVersionOrTag} resolves to ${resolvedVersion}, ` +\n `which doesn't support 'init' (requires >= ${MIN_PH_CLI_MAJOR}.0.0).\\n` +\n `Try: ph init --dev <args> or ph init --version <${MIN_PH_CLI_MAJOR}.x.x> <args>`,\n );\n process.exit(1);\n }\n\n const phCliPackage = `${PH_CLI_PACKAGE}@${resolvedVersion ?? phCliVersionOrTag}`;\n const { resolveCommand } = await import(\"package-manager-detector\");\n const resolved = resolveCommand(pm, \"execute\", [\n phCliPackage,\n \"init\",\n ...forwardedArgs,\n ]);\n\n if (!resolved) {\n throw new Error(\n `Could not resolve execute command for package manager \"${pm}\".`,\n );\n }\n\n const { injectPnpmAllowBuilds } = await import(\"@powerhousedao/shared/clis\");\n injectPnpmAllowBuilds(pm, resolved);\n\n const { command: cmd, args: cmdArgs } = resolved;\n const fullCmd = `${cmd} ${cmdArgs.join(\" \")}`;\n\n if (args.debug) {\n console.log(\">>> Delegating to ph-cli:\", fullCmd);\n }\n\n try {\n execSync(fullCmd, { stdio: \"inherit\" });\n } catch (err) {\n // Propagate normal non-zero exits but throw on abnormal exits to ensure\n // the error is reported.\n const e = err as {\n status?: number | null;\n signal?: NodeJS.Signals | null;\n };\n if (typeof e.status === \"number\" && !e.signal) {\n process.exit(e.status);\n }\n throw err;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAwBA,SAAgB,0BACd,MACA,QAKA;CACA,MAAM,EAAE,KAAK,MAAM,MAAM,KAAK,mBAAmB;CACjD,MAAM,WAA8B,MAChC,QACA,OACE,SACA,OACE,SACA,MACE,QACA;CACV,IAAI,UACF,OAAO;EAAE,IAAI;EAAU,gBAAgB,CAAC;EAAG,cAAc,KAAA;CAAU;CAGrE,MAAM,WAAW,OAAO,KAAK,QAAQ,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC;CAEtE,MAAM,gBAAgB;EAAC;EAAK;EAAM;EAAM;CAAG,CAAC,CAAC,MAAM,MAAM,MAAM,KAAA,CAAS;CACxE,OAAO;EACL,IAAI,SAAS;EACb,gBAAgB,gBAAgB,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI;EACxD,cAAc,SAAS,WAAW,aAAa,KAAA,IAAY,SAAS;CACtE;AACF;;;AClDA,MAAM,iBAAiB;AAKvB,MAAM,mBAAmB;;;;;;;;;;AA8BzB,eAAsB,aACpB,MACA,qBAA+B,CAAC,GACjB;CACf,MAAM,EACJ,sBACA,mCACA,gCACA,aACE,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C;CAED,IAAI,CAAC,UACH,MAAM,IAAI,MACR,0DAA0D,GAAG,GAC/D;CAGF,MAAM,EAAE,0BAA0B,MAAM,OAAO;CAC/C,sBAAsB,IAAI,QAAQ;CAElC,MAAM,EAAE,SAAS,KAAK,MAAM,YAAY;CACxC,MAAM,UAAU,GAAG,IAAI,GAAG,QAAQ,KAAK,GAAG;CAE1C,IAAI,KAAK,OACP,QAAQ,IAAI,6BAA6B,OAAO;CAGlD,IAAI;EACF,SAAS,SAAS,EAAE,OAAO,UAAU,CAAC;CACxC,SAAS,KAAK;EAGZ,MAAM,IAAI;EAIV,IAAI,OAAO,EAAE,WAAW,YAAY,CAAC,EAAE,QACrC,QAAQ,KAAK,EAAE,MAAM;EAEvB,MAAM;CACR;AACF","debug_id":"b6152fb3-d1b7-5fce-9f15-a5f1d1ab644f"}
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* `bun run scripts/generate-commands-docs.ts` or `bun run src/cli.ts`).
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
!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]="
|
|
8
|
+
!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]="c6bcecc2-ea4f-5094-81c4-8a84a475bd5c")}catch(e){}}();
|
|
9
9
|
function getVersion() {
|
|
10
|
-
return "6.2.3-dev.
|
|
10
|
+
return "6.2.3-dev.98";
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
13
13
|
export { getVersion as t };
|
|
14
14
|
|
|
15
|
-
//# sourceMappingURL=get-version-
|
|
16
|
-
//# debugId=
|
|
15
|
+
//# sourceMappingURL=get-version-CT-1CzvF.mjs.map
|
|
16
|
+
//# debugId=c6bcecc2-ea4f-5094-81c4-8a84a475bd5c
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-version-
|
|
1
|
+
{"version":3,"file":"get-version-CT-1CzvF.mjs","sources":["../src/get-version.ts"],"sourcesContent":["declare const CLI_VERSION: string | undefined;\ndeclare const CLI_GIT_SHA: string | undefined;\n\n/**\n * Returns the CLI version string. Replaced inline by tsdown's `define` at\n * build time; falls back to env vars when running un-bundled (e.g. via\n * `bun run scripts/generate-commands-docs.ts` or `bun run src/cli.ts`).\n */\nexport function getVersion() {\n if (typeof CLI_VERSION !== \"undefined\") return CLI_VERSION;\n return (\n process.env.WORKSPACE_VERSION ||\n process.env.npm_package_version ||\n \"unknown\"\n );\n}\n\nexport function getGitHash() {\n if (typeof CLI_GIT_SHA !== \"undefined\") return CLI_GIT_SHA;\n return process.env.WORKSPACE_GIT_SHA || \"unknown\";\n}\n"],"names":[],"mappings":";;;;;;;;AAQA,SAAgB,aAAa;CACa,OAAA;AAM1C","debug_id":"c6bcecc2-ea4f-5094-81c4-8a84a475bd5c"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { t as getVersion } from "./get-version-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c8bf0d59-5c2d-5646-9c92-e08dd9425d4f")}catch(e){}}();
|
|
3
|
+
import { t as getVersion } from "./get-version-CT-1CzvF.mjs";
|
|
4
4
|
import { CALLER_CWD_ENV } from "@powerhousedao/shared/clis/command-names";
|
|
5
5
|
import { getPowerhouseProjectInfo } from "@powerhousedao/shared/clis";
|
|
6
6
|
import spawn from "cross-spawn";
|
|
@@ -45,5 +45,5 @@ async function executePhCliCommand(phCliCommand) {
|
|
|
45
45
|
//#endregion
|
|
46
46
|
export { executePhCliCommand };
|
|
47
47
|
|
|
48
|
-
//# sourceMappingURL=ph-cli-
|
|
49
|
-
//# debugId=
|
|
48
|
+
//# sourceMappingURL=ph-cli-BPJ6fFsB.mjs.map
|
|
49
|
+
//# debugId=c8bf0d59-5c2d-5646-9c92-e08dd9425d4f
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ph-cli-
|
|
1
|
+
{"version":3,"file":"ph-cli-BPJ6fFsB.mjs","sources":["../src/ph-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { getPowerhouseProjectInfo } from \"@powerhousedao/shared/clis\";\nimport { CALLER_CWD_ENV } from \"@powerhousedao/shared/clis/command-names\";\nimport spawn from \"cross-spawn\";\nimport { resolveCommand } from \"package-manager-detector\";\nimport { getVersion } from \"./get-version.js\";\n\nconst PH_CLI_PACKAGE = \"@powerhousedao/ph-cli\";\n\n// Auth/identity commands write global state (~/.renown.json, ~/.npmrc), not a\n// project, so they run outside a project via dlx when no ph-cli is installed.\nconst PROJECT_OPTIONAL_COMMANDS = new Set([\n \"login\",\n \"logout\",\n \"registry-login\",\n]);\n\nexport async function executePhCliCommand(phCliCommand: string) {\n const forwardedArgs = process.argv.slice(3);\n const { projectPath, packageManager } = await getPowerhouseProjectInfo(\n undefined,\n { silent: true },\n );\n\n if (!projectPath && !PROJECT_OPTIONAL_COMMANDS.has(phCliCommand)) {\n throw new Error(\n `No Powerhouse project directory found, cannot run \\`ph ${phCliCommand}\\`.\\nTo create a local project, run \\`ph init\\`.\\nTo create a global project, run \\`ph setup-globals\\`.`,\n );\n }\n\n // In a project run the installed binary; otherwise dlx ph-cli pinned to this\n // ph-cmd version, falling back to `latest` when the version is unknown.\n const version = getVersion();\n const phCliTarget = projectPath\n ? \"ph-cli\"\n : `${PH_CLI_PACKAGE}@${version === \"unknown\" ? \"latest\" : version}`;\n const action = projectPath ? \"execute-local\" : \"execute\";\n\n const resolved = resolveCommand(packageManager, action, [\n phCliTarget,\n phCliCommand,\n ...forwardedArgs,\n ]);\n if (!resolved) {\n throw new Error(\n `Could not resolve a \"${action}\" command for package manager \"${packageManager}\" to run ph-cli. Supported package managers: npm, pnpm, yarn, bun.`,\n );\n }\n\n if (!projectPath) {\n const { injectPnpmAllowBuilds } =\n await import(\"@powerhousedao/shared/clis\");\n injectPnpmAllowBuilds(packageManager, resolved);\n }\n\n const { command, args } = resolved;\n // spawn (not a shell-joined string) so args with shell metacharacters — e.g.\n // `connect build --json '{\"a\":\"b\"}'` — survive intact. cross-spawn keeps that\n // guarantee on Windows too: `command` here is an npx/pnpm/yarn `.cmd` shim,\n // which node:child_process refuses to run without `shell: true` (spawn\n // EINVAL), and `shell: true` is exactly what would break those arguments.\n const result = spawn.sync(command, args, {\n stdio: \"inherit\",\n cwd: projectPath ?? process.cwd(),\n // Relative path arguments mean the caller's cwd, not the project root.\n env: {\n ...process.env,\n [CALLER_CWD_ENV]: process.env[CALLER_CWD_ENV] ?? process.cwd(),\n },\n });\n if (result.error) throw result.error;\n if (result.signal) {\n throw new Error(`${command} terminated by signal ${result.signal}`);\n }\n if (typeof result.status === \"number\" && result.status !== 0) {\n process.exit(result.status);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAOA,MAAM,iBAAiB;AAIvB,MAAM,4CAA4B,IAAI,IAAI;CACxC;CACA;CACA;AACF,CAAC;AAED,eAAsB,oBAAoB,cAAsB;CAC9D,MAAM,gBAAgB,QAAQ,KAAK,MAAM,CAAC;CAC1C,MAAM,EAAE,aAAa,mBAAmB,MAAM,yBAC5C,KAAA,GACA,EAAE,QAAQ,KAAK,CACjB;CAEA,IAAI,CAAC,eAAe,CAAC,0BAA0B,IAAI,YAAY,GAC7D,MAAM,IAAI,MACR,0DAA0D,aAAa,wGACzE;CAKF,MAAM,UAAU,WAAW;CAC3B,MAAM,cAAc,cAChB,WACA,GAAG,eAAe,GAAG,YAAY,YAAY,WAAW;CAC5D,MAAM,SAAS,cAAc,kBAAkB;CAE/C,MAAM,WAAW,eAAe,gBAAgB,QAAQ;EACtD;EACA;EACA,GAAG;CACL,CAAC;CACD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,wBAAwB,OAAO,iCAAiC,eAAe,mEACjF;CAGF,IAAI,CAAC,aAAa;EAChB,MAAM,EAAE,0BACN,MAAM,OAAO;EACf,sBAAsB,gBAAgB,QAAQ;CAChD;CAEA,MAAM,EAAE,SAAS,SAAS;CAM1B,MAAM,SAAS,MAAM,KAAK,SAAS,MAAM;EACvC,OAAO;EACP,KAAK,eAAe,QAAQ,IAAI;EAEhC,KAAK;GACH,GAAG,QAAQ;IACV,iBAAiB,QAAQ,IAAI,mBAAmB,QAAQ,IAAI;EAC/D;CACF,CAAC;CACD,IAAI,OAAO,OAAO,MAAM,OAAO;CAC/B,IAAI,OAAO,QACT,MAAM,IAAI,MAAM,GAAG,QAAQ,wBAAwB,OAAO,QAAQ;CAEpE,IAAI,OAAO,OAAO,WAAW,YAAY,OAAO,WAAW,GACzD,QAAQ,KAAK,OAAO,MAAM;AAE9B","debug_id":"c8bf0d59-5c2d-5646-9c92-e08dd9425d4f"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { t as getVersion } from "./get-version-
|
|
4
|
-
import { i as setCacheCurrent,
|
|
5
|
-
import { t as delegateInit } from "./delegate-init-
|
|
6
|
-
import {
|
|
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]="a12f3f68-d2dc-55b7-92ca-b4206a2da27b")}catch(e){}}();
|
|
3
|
+
import { t as getVersion } from "./get-version-CT-1CzvF.mjs";
|
|
4
|
+
import { i as setCacheCurrent, t as PH_CMD_STREAMS } from "./version-check-D9Yeup9S.mjs";
|
|
5
|
+
import { t as delegateInit } from "./delegate-init-XVkwNFVF.mjs";
|
|
6
|
+
import { n as runSelfUpdate, r as runningEntryRealPath } from "./self-update-D4a3o9wb.mjs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
9
|
-
import { spawn as spawn$1 } from "cross-spawn";
|
|
10
9
|
import { boolean, command, flag, oneOf, option, optional, positional, run as run$1, string, subcommands } from "cmd-ts";
|
|
11
10
|
import { debugArgs, initArgs, phCliHelpCommands } from "@powerhousedao/shared/clis/args";
|
|
12
11
|
import { ALL_POWERHOUSE_DEPENDENCIES } from "@powerhousedao/shared/constants";
|
|
@@ -27,160 +26,6 @@ const init = command({
|
|
|
27
26
|
}
|
|
28
27
|
});
|
|
29
28
|
//#endregion
|
|
30
|
-
//#region src/utils/self-update.ts
|
|
31
|
-
const PACKAGE_NAME = "ph-cmd";
|
|
32
|
-
function normalizePath(p) {
|
|
33
|
-
return p.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Which package manager owns the running global install, resolved from the
|
|
37
|
-
* real path of the running bundle (the bin entry is a symlink; the ESM
|
|
38
|
-
* loader resolves it). Path signatures:
|
|
39
|
-
* pnpm: <global>/node_modules/.pnpm/ph-cmd@<v>/node_modules/ph-cmd/...
|
|
40
|
-
* bun: <home>/.bun/install/global/node_modules/ph-cmd/...
|
|
41
|
-
* yarn: <global>/yarn/global/node_modules/ph-cmd/... (yarn classic)
|
|
42
|
-
* npm: <prefix>/lib/node_modules/ph-cmd/... (any plain node_modules)
|
|
43
|
-
* A source checkout (<repo>/clis/ph-cmd/dist/cli.mjs) and any unrecognized
|
|
44
|
-
* layout are refused with a reason instead of guessing.
|
|
45
|
-
*/
|
|
46
|
-
function detectGlobalInstall(rawPath) {
|
|
47
|
-
const real = normalizePath(rawPath);
|
|
48
|
-
if (real.includes("/clis/ph-cmd/")) return {
|
|
49
|
-
pm: null,
|
|
50
|
-
reason: "source-checkout"
|
|
51
|
-
};
|
|
52
|
-
const pkgDir = real.endsWith(`/dist/cli.mjs`) ? real.slice(0, -13) : null;
|
|
53
|
-
if (!pkgDir || !pkgDir.endsWith(`/${PACKAGE_NAME}`)) return {
|
|
54
|
-
pm: null,
|
|
55
|
-
reason: "unknown"
|
|
56
|
-
};
|
|
57
|
-
if (real.includes(`/node_modules/.pnpm/${PACKAGE_NAME}@`)) return {
|
|
58
|
-
pm: "pnpm",
|
|
59
|
-
pkgRoot: pkgDir
|
|
60
|
-
};
|
|
61
|
-
if (real.includes("/.bun/install/global/node_modules/")) return {
|
|
62
|
-
pm: "bun",
|
|
63
|
-
pkgRoot: pkgDir
|
|
64
|
-
};
|
|
65
|
-
if (real.includes("/yarn/global/node_modules/")) return {
|
|
66
|
-
pm: "yarn",
|
|
67
|
-
pkgRoot: pkgDir
|
|
68
|
-
};
|
|
69
|
-
if (real.includes("/node_modules/")) return {
|
|
70
|
-
pm: "npm",
|
|
71
|
-
pkgRoot: pkgDir
|
|
72
|
-
};
|
|
73
|
-
return {
|
|
74
|
-
pm: null,
|
|
75
|
-
reason: "unknown"
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
const UPDATE_COMMANDS = {
|
|
79
|
-
npm: {
|
|
80
|
-
command: (spec) => `npm install -g ${spec}`,
|
|
81
|
-
argv: (spec) => [
|
|
82
|
-
"npm",
|
|
83
|
-
"install",
|
|
84
|
-
"-g",
|
|
85
|
-
spec
|
|
86
|
-
]
|
|
87
|
-
},
|
|
88
|
-
pnpm: {
|
|
89
|
-
command: (spec) => `pnpm add -g ${spec}`,
|
|
90
|
-
argv: (spec) => [
|
|
91
|
-
"pnpm",
|
|
92
|
-
"add",
|
|
93
|
-
"-g",
|
|
94
|
-
spec
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
bun: {
|
|
98
|
-
command: (spec) => `bun add -g ${spec}`,
|
|
99
|
-
argv: (spec) => [
|
|
100
|
-
"bun",
|
|
101
|
-
"add",
|
|
102
|
-
"-g",
|
|
103
|
-
spec
|
|
104
|
-
]
|
|
105
|
-
},
|
|
106
|
-
yarn: {
|
|
107
|
-
command: (spec) => `yarn global add ${spec}`,
|
|
108
|
-
argv: (spec) => [
|
|
109
|
-
"yarn",
|
|
110
|
-
"global",
|
|
111
|
-
"add",
|
|
112
|
-
spec
|
|
113
|
-
]
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
/** Human-readable update command (for error hints). */
|
|
117
|
-
function updateCommand(pm, tag) {
|
|
118
|
-
return UPDATE_COMMANDS[pm].command(`${PACKAGE_NAME}@${tag}`);
|
|
119
|
-
}
|
|
120
|
-
/** Exact argv used to spawn the package manager. */
|
|
121
|
-
function updateArgv(pm, tag) {
|
|
122
|
-
return UPDATE_COMMANDS[pm].argv(`${PACKAGE_NAME}@${tag}`);
|
|
123
|
-
}
|
|
124
|
-
function defaultSpawner(argv, opts) {
|
|
125
|
-
const { promise, resolve, reject } = Promise.withResolvers();
|
|
126
|
-
const child = spawn$1(argv[0], argv.slice(1), opts);
|
|
127
|
-
child.on("close", (code) => code === 0 ? resolve() : reject(/* @__PURE__ */ new Error(`${argv[0]} exited with code ${code}`)));
|
|
128
|
-
child.on("error", reject);
|
|
129
|
-
return promise;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Upgrade the global ph-cmd install to `tag` (default: the running build's
|
|
133
|
-
* stream) using the owning package manager, then report the new version.
|
|
134
|
-
* Never throws: refusals and failures come back as `{ ok: false }` so the
|
|
135
|
-
* command layer owns the exit code.
|
|
136
|
-
*/
|
|
137
|
-
async function runSelfUpdate(opts) {
|
|
138
|
-
const { spawner = defaultSpawner, readFile: readFile$1 = (p) => readFile(p, "utf-8"), stdout = (line) => console.log(line), stderr = (line) => console.error(line), refreshCache } = opts.deps ?? {};
|
|
139
|
-
const detection = detectGlobalInstall(opts.realPath);
|
|
140
|
-
if (detection.pm === null) {
|
|
141
|
-
if (detection.reason === "source-checkout") {
|
|
142
|
-
const message = "ph is running from a source checkout; self-update only applies to global installs.";
|
|
143
|
-
stderr(message);
|
|
144
|
-
return {
|
|
145
|
-
ok: false,
|
|
146
|
-
message
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
const manual = Object.keys(UPDATE_COMMANDS).map((pm) => ` ${updateCommand(pm, "latest")}`).join("\n");
|
|
150
|
-
const message = `Couldn't determine how ph was installed (${opts.realPath}). Update manually:\n${manual}`;
|
|
151
|
-
stderr(message);
|
|
152
|
-
return {
|
|
153
|
-
ok: false,
|
|
154
|
-
message
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
const tag = opts.tag ?? getStream(opts.currentVersion);
|
|
158
|
-
stdout(`Updating ph-cmd via ${detection.pm} (${updateCommand(detection.pm, tag)})...`);
|
|
159
|
-
try {
|
|
160
|
-
await spawner(updateArgv(detection.pm, tag), { stdio: "inherit" });
|
|
161
|
-
} catch (error) {
|
|
162
|
-
const message = `ph-cmd update failed via ${detection.pm}. Try manually: ${updateCommand(detection.pm, tag)}`;
|
|
163
|
-
stderr(message);
|
|
164
|
-
if (error instanceof Error) stderr(error.message);
|
|
165
|
-
return {
|
|
166
|
-
ok: false,
|
|
167
|
-
message
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
let to = "unknown";
|
|
171
|
-
try {
|
|
172
|
-
const pkg = JSON.parse(await readFile$1(`${detection.pkgRoot}/package.json`));
|
|
173
|
-
if (typeof pkg.version === "string") to = pkg.version;
|
|
174
|
-
} catch {}
|
|
175
|
-
stdout(`Updated ph-cmd from ${opts.currentVersion} to ${to}. The new version takes effect on your next 'ph' run.`);
|
|
176
|
-
await refreshCache?.(to).catch(() => {});
|
|
177
|
-
return {
|
|
178
|
-
ok: true,
|
|
179
|
-
from: opts.currentVersion,
|
|
180
|
-
to
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
//#endregion
|
|
184
29
|
//#region src/commands/self-update.ts
|
|
185
30
|
const selfUpdate = command({
|
|
186
31
|
name: "self-update",
|
|
@@ -196,8 +41,7 @@ const selfUpdate = command({
|
|
|
196
41
|
},
|
|
197
42
|
handler: async (args) => {
|
|
198
43
|
if (args.debug) console.log({ args });
|
|
199
|
-
const
|
|
200
|
-
const realPath = entry ? await realpath(entry) : import.meta.url.replace(/^file:\/\//, "");
|
|
44
|
+
const realPath = await runningEntryRealPath();
|
|
201
45
|
const result = await runSelfUpdate({
|
|
202
46
|
currentVersion: getVersion(),
|
|
203
47
|
tag: args.tag,
|
|
@@ -249,7 +93,7 @@ const setupGlobals = command({
|
|
|
249
93
|
}
|
|
250
94
|
console.log("📦 Initializing global project...");
|
|
251
95
|
process.chdir(HOME_DIR);
|
|
252
|
-
const { delegateInit } = await import("./delegate-init-
|
|
96
|
+
const { delegateInit } = await import("./delegate-init-DAfxbQ9U.mjs");
|
|
253
97
|
await delegateInit(args, ["--name", PH_GLOBAL_DIR_NAME]);
|
|
254
98
|
fixGlobalPackageName();
|
|
255
99
|
console.log(`🚀 Global project initialized successfully: ${POWERHOUSE_GLOBAL_DIR}`);
|
|
@@ -553,5 +397,5 @@ async function run(args) {
|
|
|
553
397
|
//#endregion
|
|
554
398
|
export { run };
|
|
555
399
|
|
|
556
|
-
//# sourceMappingURL=run-
|
|
557
|
-
//# debugId=
|
|
400
|
+
//# sourceMappingURL=run-BK8ClRWp.mjs.map
|
|
401
|
+
//# debugId=a12f3f68-d2dc-55b7-92ca-b4206a2da27b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-BK8ClRWp.mjs","sources":["../src/commands/init.ts","../src/commands/self-update.ts","../src/commands/setup-globals.ts","../src/commands/update.ts","../src/commands/use-local.ts","../src/commands/use.ts","../src/commands/ph.ts","../src/run.ts"],"sourcesContent":["import { initArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\nimport { delegateInit } from \"../utils/delegate-init.js\";\n\n/**\n * Delegates `ph init` to the appropriate version of `@powerhousedao/ph-cli`.\n * This ensures the init logic (boilerplate, codegen) always matches the\n * ph-cli version being installed in the new project.\n */\nexport const init = command({\n name: \"init\",\n description: \"Initialize a new project\",\n args: initArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log({ args });\n }\n await delegateInit(args);\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, optional, option, string } from \"cmd-ts\";\nimport { PH_CMD_STREAMS, setCacheCurrent } from \"../utils/version-check.js\";\nimport { runSelfUpdate, runningEntryRealPath } from \"../utils/self-update.js\";\nimport { getVersion } from \"../get-version.js\";\n\nexport const selfUpdate = command({\n name: \"self-update\",\n description:\n \"Update the globally installed ph to the newest version of its release stream\",\n args: {\n tag: option({\n type: optional(string),\n long: \"tag\",\n short: \"t\",\n description: `dist-tag to install (defaults to the running build's stream; e.g. ${PH_CMD_STREAMS.join(\n \", \",\n )})`,\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n if (args.debug) {\n console.log({ args });\n }\n const realPath = await runningEntryRealPath();\n const result = await runSelfUpdate({\n currentVersion: getVersion(),\n tag: args.tag,\n realPath,\n });\n if (!result.ok) {\n process.exit(1);\n }\n // Quiet the notice on the next run: the new version is now current.\n await setCacheCurrent(result.to);\n process.exit(0);\n },\n});\n","import { initArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nconst PH_GLOBAL_PACKAGE_NAME = \"ph-global\";\n\n/**\n * `ph setup-globals` bootstraps the `~/.ph` project. It's the same flow as\n * `ph init` with `--name .ph` from the user's home directory, plus a\n * post-step that renames the package.json to `ph-global` (since `.ph` is\n * an invalid npm name).\n */\nexport const setupGlobals = command({\n name: \"setup-globals\",\n description: \"Initialize a new global project\",\n args: initArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log({ args });\n }\n\n const { HOME_DIR, PH_GLOBAL_DIR_NAME, POWERHOUSE_GLOBAL_DIR } =\n await import(\"@powerhousedao/shared/clis\");\n\n /**\n * Fix the package.json `name` field for the global project — `.ph` is a\n * valid directory name but not a valid npm package name (vite + npm\n * reject names starting with a dot). We let `ph init` create the project\n * as `.ph` and then rename it here to `ph-global`.\n */\n const fixGlobalPackageName = (): void => {\n const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, \"package.json\");\n if (!existsSync(packageJsonPath)) return;\n try {\n const packageJson = JSON.parse(\n readFileSync(packageJsonPath, \"utf-8\"),\n ) as { name?: string };\n if (packageJson.name?.startsWith(\".\")) {\n packageJson.name = PH_GLOBAL_PACKAGE_NAME;\n writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n }\n } catch {\n // Ignore parse/write failures — leaves the file untouched.\n }\n };\n\n // The directory itself can exist without the project being bootstrapped —\n // telemetry writes `~/.ph/telemetry.json` early on. Use the presence of\n // `package.json` as the real \"is initialized\" signal.\n const globalPackageJson = path.join(POWERHOUSE_GLOBAL_DIR, \"package.json\");\n if (existsSync(globalPackageJson)) {\n // Repair-in-place: an older bootstrap may have left `name: \".ph\"` in\n // package.json, which breaks vite/npm. Fix it on every invocation.\n fixGlobalPackageName();\n console.log(`📦 Using global project: ${POWERHOUSE_GLOBAL_DIR}`);\n process.exit(0);\n }\n\n console.log(\"📦 Initializing global project...\");\n process.chdir(HOME_DIR);\n const { delegateInit } = await import(\"../utils/delegate-init.js\");\n await delegateInit(args, [\"--name\", PH_GLOBAL_DIR_NAME]);\n fixGlobalPackageName();\n console.log(\n `🚀 Global project initialized successfully: ${POWERHOUSE_GLOBAL_DIR}`,\n );\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { ALL_POWERHOUSE_DEPENDENCIES } from \"@powerhousedao/shared/constants\";\nimport { boolean, command, flag, optional } from \"cmd-ts\";\n\nexport const update = command({\n name: \"update\",\n description:\n \"Update your Powerhouse dependencies and installed packages to their latest versions\",\n args: {\n skipInstall: flag({\n type: optional(boolean),\n long: \"skip-install\",\n short: \"s\",\n description: \"Skip running `install` with your package manager\",\n }),\n updatePackages: flag({\n type: optional(boolean),\n long: \"update-packages\",\n description:\n \"Auto-update installed packages (powerhouse.config.json) to their newest same-major version\",\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n const { skipInstall, updatePackages, debug } = args;\n if (debug) {\n console.log({ args });\n }\n console.log(`\\n▶️ Updating Powerhouse dependencies...\\n`);\n const [\n { default: chalk },\n { readPackage },\n { writePackage },\n { getTagFromVersion, logVersionUpdate, parsePackageVersion, runCmd },\n { resolveRegistryUrl },\n { updateInstalledPackages },\n ] = await Promise.all([\n import(\"chalk\"),\n import(\"read-pkg\"),\n import(\"write-package\"),\n import(\"@powerhousedao/shared/clis\"),\n import(\"@powerhousedao/shared/registry\"),\n import(\"./update-packages.js\"),\n ]);\n const registryUrl = resolveRegistryUrl({ projectPath: process.cwd() });\n const packageJson = await readPackage();\n\n if (packageJson.dependencies) {\n for (const [name, version] of Object.entries(packageJson.dependencies)) {\n if (version && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const tag = getTagFromVersion(version);\n const newVersion = await parsePackageVersion({ name, tag });\n packageJson.dependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.devDependencies) {\n for (const [name, version] of Object.entries(\n packageJson.devDependencies,\n )) {\n if (version && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const tag = getTagFromVersion(version);\n const newVersion = await parsePackageVersion({ name, tag });\n packageJson.devDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.optionalDependencies) {\n for (const [name, version] of Object.entries(\n packageJson.optionalDependencies,\n )) {\n if (version && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const tag = getTagFromVersion(version);\n const newVersion = await parsePackageVersion({ name, tag });\n packageJson.optionalDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.peerDependencies) {\n for (const [name, version] of Object.entries(\n packageJson.peerDependencies,\n )) {\n if (version && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const tag = getTagFromVersion(version);\n const newVersion = await parsePackageVersion({ name, tag });\n packageJson.peerDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version,\n newVersion,\n });\n }\n }\n }\n\n await writePackage(packageJson);\n\n console.log(chalk.green(`\\n✅ Project updated successfully\\n`));\n\n // Detect the package manager once; it backs the install below and the\n // update of `local` (node_modules) installed packages.\n const { detect } = await import(\"package-manager-detector/detect\");\n const packageManager = await detect();\n\n await updateInstalledPackages({\n registryUrl,\n auto: updatePackages ?? false,\n skipInstall: skipInstall ?? false,\n packageManager,\n });\n\n if (skipInstall) return;\n\n if (!packageManager) {\n throw new Error(\n `❌ Failed to detect your package manager. Run install manually.`,\n );\n }\n console.log(\n `▶️ Installing updated dependencies with \\`${packageManager.agent}\\`\\n`,\n );\n runCmd(`${packageManager.agent} install`);\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport {\n boolean,\n command,\n flag,\n option,\n optional,\n positional,\n string,\n} from \"cmd-ts\";\n\nexport const useLocal = command({\n name: \"use-local\",\n description:\n \"Use your local `powerhouse` monorepo dependencies the current project.\",\n args: {\n monorepoPathPositional: positional({\n type: optional(string),\n displayName: \"monorepo path\",\n description:\n \"Path to your local powerhouse monorepo relative to this project\",\n }),\n monorepoPathOption: option({\n type: optional(string),\n long: \"path\",\n short: \"p\",\n description:\n \"Path to your local powerhouse monorepo relative to this project\",\n }),\n skipInstall: flag({\n type: optional(boolean),\n long: \"skip-install\",\n short: \"s\",\n description: \"Skip running `install` with `pnpm`\",\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n const { monorepoPathPositional, monorepoPathOption, skipInstall, debug } =\n args;\n if (debug) {\n console.log({ args });\n }\n const monorepoPath = monorepoPathPositional ?? monorepoPathOption;\n\n if (!monorepoPath) {\n throw new Error(\n \"❌ Please provide the path to your local powerhouse monorepo.\",\n );\n }\n\n const { runUseLocal } = await import(\"@powerhousedao/shared/clis\");\n await runUseLocal(monorepoPath, skipInstall);\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { ALL_POWERHOUSE_DEPENDENCIES } from \"@powerhousedao/shared/constants\";\nimport {\n boolean,\n command,\n flag,\n oneOf,\n option,\n optional,\n positional,\n run,\n string,\n} from \"cmd-ts\";\n\nexport const use = command({\n name: \"use\",\n description: \"Specify the release version of Powerhouse dependencies to use.\",\n args: {\n tagPositional: positional({\n type: optional(oneOf([\"latest\", \"staging\", \"dev\", \"rc\"])),\n displayName: \"tag\",\n description: `Specify the release tag to use for your project. Can be one of: \"latest\", \"staging\", \"dev\", or \"rc\".`,\n }),\n tagOption: option({\n type: optional(oneOf([\"latest\", \"staging\", \"dev\", \"rc\"])),\n long: \"tag\",\n short: \"t\",\n description: `Specify the release tag to use for your project. Can be one of: \"latest\", \"staging\", \"dev\", or \"rc\".`,\n }),\n version: option({\n type: optional(string),\n long: \"version\",\n short: \"v\",\n description:\n \"Specify the exact semver release version to use for your project.\",\n }),\n skipInstall: flag({\n type: optional(boolean),\n long: \"skip-install\",\n short: \"s\",\n description: \"Skip running `install` with your package manager\",\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n const { tagPositional, tagOption, version, skipInstall, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const tag = tagPositional ?? tagOption;\n const {\n handleMutuallyExclusiveOptions,\n logVersionUpdate,\n parsePackageVersion,\n runCmd,\n } = await import(\"@powerhousedao/shared/clis\");\n handleMutuallyExclusiveOptions({ tag, version }, \"versioning strategy\");\n\n if (!tag && !version) {\n throw new Error(\n \"Please specify either a release tag or a version to use.\",\n );\n }\n\n const [\n { default: chalk },\n { readPackage },\n { writePackage },\n { clean, valid },\n ] = await Promise.all([\n import(\"chalk\"),\n import(\"read-pkg\"),\n import(\"write-package\"),\n import(\"semver\"),\n ]);\n\n if (version && !valid(clean(version))) {\n throw new Error(`❌ Invalid version: ${chalk.bold(version)}`);\n }\n\n console.log(\n `▶️ Updating project to use ${chalk.bold(version ?? tag)}...\\n`,\n );\n\n const packageJson = await readPackage();\n\n if (packageJson.dependencies) {\n for (const [name, existingVersion] of Object.entries(\n packageJson.dependencies,\n )) {\n if (existingVersion && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const newVersion = await parsePackageVersion({ name, tag, version });\n packageJson.dependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version: existingVersion,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.devDependencies) {\n for (const [name, existingVersion] of Object.entries(\n packageJson.devDependencies,\n )) {\n if (existingVersion && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const newVersion = await parsePackageVersion({ name, tag, version });\n packageJson.devDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version: existingVersion,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.optionalDependencies) {\n for (const [name, existingVersion] of Object.entries(\n packageJson.optionalDependencies,\n )) {\n if (existingVersion && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const newVersion = await parsePackageVersion({ name, tag, version });\n packageJson.optionalDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version: existingVersion,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.peerDependencies) {\n for (const [name, existingVersion] of Object.entries(\n packageJson.peerDependencies,\n )) {\n if (existingVersion && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const newVersion = await parsePackageVersion({ name, tag, version });\n packageJson.peerDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version: existingVersion,\n newVersion,\n });\n }\n }\n }\n\n await writePackage(packageJson);\n\n console.log(\n chalk.green(\n `\\n✅ Project updated to use ${chalk.bold(version ?? tag)}\\n`,\n ),\n );\n\n if (!skipInstall) {\n const { detect } = await import(\"package-manager-detector/detect\");\n const packageManager = await detect();\n if (!packageManager) {\n throw new Error(\n `❌ Failed to detect your package manager. Run install manually.`,\n );\n }\n console.log(\n `▶️ Installing updated dependencies with \\`${packageManager.agent}\\`\\n`,\n );\n runCmd(`${packageManager.agent} install`);\n }\n\n process.exit(0);\n },\n});\n\nexport async function runUse(args: string[]) {\n await run(use, args);\n}\n","import { phCliHelpCommands } from \"@powerhousedao/shared/clis/args\";\nimport { subcommands } from \"cmd-ts\";\nimport { getVersion } from \"../get-version.js\";\nimport { init } from \"./init.js\";\nimport { selfUpdate } from \"./self-update.js\";\nimport { setupGlobals } from \"./setup-globals.js\";\nimport { update } from \"./update.js\";\nimport { useLocal } from \"./use-local.js\";\nimport { use } from \"./use.js\";\n\n// `--version` is intercepted in cli.ts before the subcommand tree is\n// constructed, so cmd-ts only needs the bare version string here. The\n// rich version output (with project info, package manager, etc.) is\n// produced by `getPhCmdVersionInfo` along that short-circuit path.\nexport const ph = subcommands({\n name: \"ph\",\n version: getVersion(),\n description:\n \"The Powerhouse CLI (ph-cmd) is a command-line interface tool that provides essential commands for managing Powerhouse projects.\\nThe tool and it's commands are fundamental for creating, building, and running Document Models as a builder in studio mode.\",\n cmds: {\n init,\n use,\n update,\n \"self-update\": selfUpdate,\n \"setup-globals\": setupGlobals,\n \"use-local\": useLocal,\n ...phCliHelpCommands,\n },\n});\n","import { run as runCmdTs } from \"cmd-ts\";\nimport { ph } from \"./commands/ph.js\";\n\nexport async function run(args: string[]) {\n return await runCmdTs(ph, args);\n}\n"],"names":["runCmdTs"],"mappings":";;;;;;;;;;;;;;;;;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,4 @@
|
|
|
1
|
+
import { r as runningEntryRealPath, t as detectGlobalInstall } from "./self-update-D4a3o9wb.mjs";
|
|
2
|
+
export { detectGlobalInstall, runningEntryRealPath };
|
|
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]="bc9956c6-4005-51fc-a2d9-2f4a1ecd708c")}catch(e){}}();
|
|
4
|
+
//# debugId=bc9956c6-4005-51fc-a2d9-2f4a1ecd708c
|
|
@@ -0,0 +1,174 @@
|
|
|
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]="89bc32d9-f7a9-5879-a5fb-09e5d2ce22ee")}catch(e){}}();
|
|
3
|
+
import { n as getStream } from "./version-check-D9Yeup9S.mjs";
|
|
4
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
5
|
+
import { spawn as spawn$1 } from "cross-spawn";
|
|
6
|
+
//#region src/utils/self-update.ts
|
|
7
|
+
const PACKAGE_NAME = "ph-cmd";
|
|
8
|
+
const PNPM_STORE_LINK = new RegExp(`/v\\d+/links/@/${PACKAGE_NAME}/[^/]+/[^/]+/node_modules/${PACKAGE_NAME}$`);
|
|
9
|
+
/**
|
|
10
|
+
* Real path of the running bundle, which identifies the global install (and
|
|
11
|
+
* its package manager). argv[1] is the entry script; the ESM loader already
|
|
12
|
+
* resolved symlinks, realpath is belt-and-braces.
|
|
13
|
+
*/
|
|
14
|
+
async function runningEntryRealPath() {
|
|
15
|
+
const entry = process.argv[1];
|
|
16
|
+
return entry ? await realpath(entry) : import.meta.url.replace(/^file:\/\//, "");
|
|
17
|
+
}
|
|
18
|
+
function normalizePath(p) {
|
|
19
|
+
return p.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Which package manager owns the running global install, resolved from the
|
|
23
|
+
* real path of the running bundle (the bin entry is a symlink; the ESM
|
|
24
|
+
* loader resolves it). Path signatures:
|
|
25
|
+
* pnpm: <global>/node_modules/.pnpm/ph-cmd@<v>/node_modules/ph-cmd/...
|
|
26
|
+
* pnpm 11: <store>/v11/links/@/ph-cmd/<v>/<hash>/node_modules/ph-cmd/...
|
|
27
|
+
* bun: <home>/.bun/install/global/node_modules/ph-cmd/...
|
|
28
|
+
* yarn: <global>/yarn/global/node_modules/ph-cmd/... (yarn classic)
|
|
29
|
+
* npm: <prefix>/lib/node_modules/ph-cmd/... (any plain node_modules)
|
|
30
|
+
* A source checkout (<repo>/clis/ph-cmd/dist/cli.mjs) and any unrecognized
|
|
31
|
+
* layout are refused with a reason instead of guessing.
|
|
32
|
+
*/
|
|
33
|
+
function detectGlobalInstall(rawPath) {
|
|
34
|
+
const real = normalizePath(rawPath);
|
|
35
|
+
if (real.includes("/clis/ph-cmd/")) return {
|
|
36
|
+
pm: null,
|
|
37
|
+
reason: "source-checkout"
|
|
38
|
+
};
|
|
39
|
+
const pkgDir = real.endsWith(`/dist/cli.mjs`) ? real.slice(0, -13) : null;
|
|
40
|
+
if (!pkgDir || !pkgDir.endsWith(`/${PACKAGE_NAME}`)) return {
|
|
41
|
+
pm: null,
|
|
42
|
+
reason: "unknown"
|
|
43
|
+
};
|
|
44
|
+
if (real.includes(`/node_modules/.pnpm/${PACKAGE_NAME}@`) || PNPM_STORE_LINK.test(pkgDir)) return {
|
|
45
|
+
pm: "pnpm",
|
|
46
|
+
pkgRoot: pkgDir
|
|
47
|
+
};
|
|
48
|
+
if (real.includes("/.bun/install/global/node_modules/")) return {
|
|
49
|
+
pm: "bun",
|
|
50
|
+
pkgRoot: pkgDir
|
|
51
|
+
};
|
|
52
|
+
if (real.includes("/yarn/global/node_modules/")) return {
|
|
53
|
+
pm: "yarn",
|
|
54
|
+
pkgRoot: pkgDir
|
|
55
|
+
};
|
|
56
|
+
if (real.includes("/node_modules/")) return {
|
|
57
|
+
pm: "npm",
|
|
58
|
+
pkgRoot: pkgDir
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
pm: null,
|
|
62
|
+
reason: "unknown"
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const UPDATE_COMMANDS = {
|
|
66
|
+
npm: {
|
|
67
|
+
command: (spec) => `npm install -g ${spec}`,
|
|
68
|
+
argv: (spec) => [
|
|
69
|
+
"npm",
|
|
70
|
+
"install",
|
|
71
|
+
"-g",
|
|
72
|
+
spec
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
pnpm: {
|
|
76
|
+
command: (spec) => `pnpm add -g ${spec}`,
|
|
77
|
+
argv: (spec) => [
|
|
78
|
+
"pnpm",
|
|
79
|
+
"add",
|
|
80
|
+
"-g",
|
|
81
|
+
spec
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
bun: {
|
|
85
|
+
command: (spec) => `bun add -g ${spec}`,
|
|
86
|
+
argv: (spec) => [
|
|
87
|
+
"bun",
|
|
88
|
+
"add",
|
|
89
|
+
"-g",
|
|
90
|
+
spec
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
yarn: {
|
|
94
|
+
command: (spec) => `yarn global add ${spec}`,
|
|
95
|
+
argv: (spec) => [
|
|
96
|
+
"yarn",
|
|
97
|
+
"global",
|
|
98
|
+
"add",
|
|
99
|
+
spec
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
/** Human-readable update command (for error hints). */
|
|
104
|
+
function updateCommand(pm, tag) {
|
|
105
|
+
return UPDATE_COMMANDS[pm].command(`${PACKAGE_NAME}@${tag}`);
|
|
106
|
+
}
|
|
107
|
+
/** Exact argv used to spawn the package manager. */
|
|
108
|
+
function updateArgv(pm, tag) {
|
|
109
|
+
return UPDATE_COMMANDS[pm].argv(`${PACKAGE_NAME}@${tag}`);
|
|
110
|
+
}
|
|
111
|
+
function defaultSpawner(argv, opts) {
|
|
112
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
113
|
+
const child = spawn$1(argv[0], argv.slice(1), opts);
|
|
114
|
+
child.on("close", (code) => code === 0 ? resolve() : reject(/* @__PURE__ */ new Error(`${argv[0]} exited with code ${code}`)));
|
|
115
|
+
child.on("error", reject);
|
|
116
|
+
return promise;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Upgrade the global ph-cmd install to `tag` (default: the running build's
|
|
120
|
+
* stream) using the owning package manager, then report the new version.
|
|
121
|
+
* Never throws: refusals and failures come back as `{ ok: false }` so the
|
|
122
|
+
* command layer owns the exit code.
|
|
123
|
+
*/
|
|
124
|
+
async function runSelfUpdate(opts) {
|
|
125
|
+
const { spawner = defaultSpawner, readFile: readFile$1 = (p) => readFile(p, "utf-8"), stdout = (line) => console.log(line), stderr = (line) => console.error(line), refreshCache } = opts.deps ?? {};
|
|
126
|
+
const detection = detectGlobalInstall(opts.realPath);
|
|
127
|
+
if (detection.pm === null) {
|
|
128
|
+
if (detection.reason === "source-checkout") {
|
|
129
|
+
const message = "ph is running from a source checkout; self-update only applies to global installs.";
|
|
130
|
+
stderr(message);
|
|
131
|
+
return {
|
|
132
|
+
ok: false,
|
|
133
|
+
message
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const manual = Object.keys(UPDATE_COMMANDS).map((pm) => ` ${updateCommand(pm, "latest")}`).join("\n");
|
|
137
|
+
const message = `Couldn't determine how ph was installed (${opts.realPath}). Update manually:\n${manual}`;
|
|
138
|
+
stderr(message);
|
|
139
|
+
return {
|
|
140
|
+
ok: false,
|
|
141
|
+
message
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const tag = opts.tag ?? getStream(opts.currentVersion);
|
|
145
|
+
stdout(`Updating ph-cmd via ${detection.pm} (${updateCommand(detection.pm, tag)})...`);
|
|
146
|
+
try {
|
|
147
|
+
await spawner(updateArgv(detection.pm, tag), { stdio: "inherit" });
|
|
148
|
+
} catch (error) {
|
|
149
|
+
const message = `ph-cmd update failed via ${detection.pm}. Try manually: ${updateCommand(detection.pm, tag)}`;
|
|
150
|
+
stderr(message);
|
|
151
|
+
if (error instanceof Error) stderr(error.message);
|
|
152
|
+
return {
|
|
153
|
+
ok: false,
|
|
154
|
+
message
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
let to = "unknown";
|
|
158
|
+
try {
|
|
159
|
+
const pkg = JSON.parse(await readFile$1(`${detection.pkgRoot}/package.json`));
|
|
160
|
+
if (typeof pkg.version === "string") to = pkg.version;
|
|
161
|
+
} catch {}
|
|
162
|
+
stdout(`Updated ph-cmd from ${opts.currentVersion} to ${to}. The new version takes effect on your next 'ph' run.`);
|
|
163
|
+
await refreshCache?.(to).catch(() => {});
|
|
164
|
+
return {
|
|
165
|
+
ok: true,
|
|
166
|
+
from: opts.currentVersion,
|
|
167
|
+
to
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
export { updateCommand as a, updateArgv as i, runSelfUpdate as n, runningEntryRealPath as r, detectGlobalInstall as t };
|
|
172
|
+
|
|
173
|
+
//# sourceMappingURL=self-update-D4a3o9wb.mjs.map
|
|
174
|
+
//# debugId=89bc32d9-f7a9-5879-a5fb-09e5d2ce22ee
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-update-D4a3o9wb.mjs","sources":["../src/utils/self-update.ts"],"sourcesContent":["import { spawn as spawnChild } from \"cross-spawn\";\nimport { readFile as readFileAsync, realpath } from \"node:fs/promises\";\n\nimport { getStream } from \"./version-check.js\";\n\nexport type GlobalPackageManager = \"npm\" | \"pnpm\" | \"bun\" | \"yarn\";\n\nexport type InstallDetection =\n | { pm: GlobalPackageManager; pkgRoot: string }\n | { pm: null; reason: \"source-checkout\" | \"unknown\" };\n\nconst PACKAGE_NAME = \"ph-cmd\";\n\n// pnpm 11 links global packages from the store, wherever store-dir points:\n// <store>/v11/links/@/ph-cmd/<version>/<hash>/node_modules/ph-cmd\nconst PNPM_STORE_LINK = new RegExp(\n `/v\\\\d+/links/@/${PACKAGE_NAME}/[^/]+/[^/]+/node_modules/${PACKAGE_NAME}$`,\n);\n\n/**\n * Real path of the running bundle, which identifies the global install (and\n * its package manager). argv[1] is the entry script; the ESM loader already\n * resolved symlinks, realpath is belt-and-braces.\n */\nexport async function runningEntryRealPath(): Promise<string> {\n const entry = process.argv[1];\n return entry\n ? await realpath(entry)\n : import.meta.url.replace(/^file:\\/\\//, \"\");\n}\n\nfunction normalizePath(p: string): string {\n return p.replace(/\\\\/g, \"/\").replace(/\\/+$/, \"\");\n}\n\n/**\n * Which package manager owns the running global install, resolved from the\n * real path of the running bundle (the bin entry is a symlink; the ESM\n * loader resolves it). Path signatures:\n * pnpm: <global>/node_modules/.pnpm/ph-cmd@<v>/node_modules/ph-cmd/...\n * pnpm 11: <store>/v11/links/@/ph-cmd/<v>/<hash>/node_modules/ph-cmd/...\n * bun: <home>/.bun/install/global/node_modules/ph-cmd/...\n * yarn: <global>/yarn/global/node_modules/ph-cmd/... (yarn classic)\n * npm: <prefix>/lib/node_modules/ph-cmd/... (any plain node_modules)\n * A source checkout (<repo>/clis/ph-cmd/dist/cli.mjs) and any unrecognized\n * layout are refused with a reason instead of guessing.\n */\nexport function detectGlobalInstall(rawPath: string): InstallDetection {\n const real = normalizePath(rawPath);\n if (real.includes(\"/clis/ph-cmd/\")) {\n return { pm: null, reason: \"source-checkout\" };\n }\n const pkgDir = real.endsWith(`/dist/cli.mjs`)\n ? real.slice(0, -\"/dist/cli.mjs\".length)\n : null;\n if (!pkgDir || !pkgDir.endsWith(`/${PACKAGE_NAME}`)) {\n return { pm: null, reason: \"unknown\" };\n }\n if (\n real.includes(`/node_modules/.pnpm/${PACKAGE_NAME}@`) ||\n PNPM_STORE_LINK.test(pkgDir)\n ) {\n return { pm: \"pnpm\", pkgRoot: pkgDir };\n }\n if (real.includes(\"/.bun/install/global/node_modules/\")) {\n return { pm: \"bun\", pkgRoot: pkgDir };\n }\n if (real.includes(\"/yarn/global/node_modules/\")) {\n return { pm: \"yarn\", pkgRoot: pkgDir };\n }\n if (real.includes(\"/node_modules/\")) {\n return { pm: \"npm\", pkgRoot: pkgDir };\n }\n return { pm: null, reason: \"unknown\" };\n}\n\nconst UPDATE_COMMANDS: Record<\n GlobalPackageManager,\n { command: (spec: string) => string; argv: (spec: string) => string[] }\n> = {\n npm: {\n command: (spec) => `npm install -g ${spec}`,\n argv: (spec) => [\"npm\", \"install\", \"-g\", spec],\n },\n pnpm: {\n command: (spec) => `pnpm add -g ${spec}`,\n argv: (spec) => [\"pnpm\", \"add\", \"-g\", spec],\n },\n bun: {\n command: (spec) => `bun add -g ${spec}`,\n argv: (spec) => [\"bun\", \"add\", \"-g\", spec],\n },\n yarn: {\n command: (spec) => `yarn global add ${spec}`,\n argv: (spec) => [\"yarn\", \"global\", \"add\", spec],\n },\n};\n\n/** Human-readable update command (for error hints). */\nexport function updateCommand(pm: GlobalPackageManager, tag: string): string {\n return UPDATE_COMMANDS[pm].command(`${PACKAGE_NAME}@${tag}`);\n}\n\n/** Exact argv used to spawn the package manager. */\nexport function updateArgv(pm: GlobalPackageManager, tag: string): string[] {\n return UPDATE_COMMANDS[pm].argv(`${PACKAGE_NAME}@${tag}`);\n}\n\nexport type SelfUpdateDeps = {\n /** Runs a full argv (program first); rejects on non-zero exit. */\n spawner?: (argv: string[], opts: { stdio: \"inherit\" }) => Promise<void>;\n readFile?: (path: string) => Promise<string>;\n stdout?: (line: string) => void;\n stderr?: (line: string) => void;\n /** called with the new version after a successful update (clears the notice). */\n refreshCache?: (newVersion: string) => Promise<void>;\n};\n\nexport type SelfUpdateResult =\n | { ok: true; from: string; to: string }\n | { ok: false; message: string };\n\nfunction defaultSpawner(\n argv: string[],\n opts: { stdio: \"inherit\" },\n): Promise<void> {\n const { promise, resolve, reject } = Promise.withResolvers<void>();\n const child = spawnChild(argv[0], argv.slice(1), opts);\n child.on(\"close\", (code) =>\n code === 0\n ? resolve()\n : reject(new Error(`${argv[0]} exited with code ${code}`)),\n );\n child.on(\"error\", reject);\n return promise;\n}\n\n/**\n * Upgrade the global ph-cmd install to `tag` (default: the running build's\n * stream) using the owning package manager, then report the new version.\n * Never throws: refusals and failures come back as `{ ok: false }` so the\n * command layer owns the exit code.\n */\nexport async function runSelfUpdate(opts: {\n currentVersion: string;\n tag?: string;\n realPath: string;\n deps?: SelfUpdateDeps;\n}): Promise<SelfUpdateResult> {\n const {\n spawner = defaultSpawner,\n readFile = (p: string) => readFileAsync(p, \"utf-8\"),\n stdout = (line: string) => console.log(line),\n stderr = (line: string) => console.error(line),\n refreshCache,\n } = opts.deps ?? {};\n\n const detection = detectGlobalInstall(opts.realPath);\n if (detection.pm === null) {\n if (detection.reason === \"source-checkout\") {\n const message =\n \"ph is running from a source checkout; self-update only applies to global installs.\";\n stderr(message);\n return { ok: false, message };\n }\n const manual = (Object.keys(UPDATE_COMMANDS) as GlobalPackageManager[])\n .map((pm) => ` ${updateCommand(pm, \"latest\")}`)\n .join(\"\\n\");\n const message = `Couldn't determine how ph was installed (${opts.realPath}). Update manually:\\n${manual}`;\n stderr(message);\n return { ok: false, message };\n }\n\n const tag = opts.tag ?? getStream(opts.currentVersion);\n stdout(\n `Updating ph-cmd via ${detection.pm} (${updateCommand(detection.pm, tag)})...`,\n );\n try {\n await spawner(updateArgv(detection.pm, tag), { stdio: \"inherit\" });\n } catch (error: unknown) {\n const message = `ph-cmd update failed via ${detection.pm}. Try manually: ${updateCommand(detection.pm, tag)}`;\n stderr(message);\n if (error instanceof Error) stderr(error.message);\n return { ok: false, message };\n }\n\n let to = \"unknown\";\n try {\n const pkg = JSON.parse(\n await readFile(`${detection.pkgRoot}/package.json`),\n ) as { version?: unknown };\n if (typeof pkg.version === \"string\") to = pkg.version;\n } catch {\n // leave \"unknown\" — the PM already printed its own result\n }\n stdout(\n `Updated ph-cmd from ${opts.currentVersion} to ${to}. The new version takes effect on your next 'ph' run.`,\n );\n await refreshCache?.(to).catch(() => {});\n return { ok: true, from: opts.currentVersion, to };\n}\n"],"names":["spawnChild","readFileAsync","readFile"],"mappings":";;;;;;AAWA,MAAM,eAAe;AAIrB,MAAM,kBAAkB,IAAI,OAC1B,kBAAkB,aAAa,4BAA4B,aAAa,EAC1E;;;;;;AAOA,eAAsB,uBAAwC;CAC5D,MAAM,QAAQ,QAAQ,KAAK;CAC3B,OAAO,QACH,MAAM,SAAS,KAAK,IACpB,YAAY,IAAI,QAAQ,cAAc,EAAE;AAC9C;AAEA,SAAS,cAAc,GAAmB;CACxC,OAAO,EAAE,QAAQ,OAAO,GAAG,CAAC,CAAC,QAAQ,QAAQ,EAAE;AACjD;;;;;;;;;;;;;AAcA,SAAgB,oBAAoB,SAAmC;CACrE,MAAM,OAAO,cAAc,OAAO;CAClC,IAAI,KAAK,SAAS,eAAe,GAC/B,OAAO;EAAE,IAAI;EAAM,QAAQ;CAAkB;CAE/C,MAAM,SAAS,KAAK,SAAS,eAAe,IACxC,KAAK,MAAM,GAAG,GAAuB,IACrC;CACJ,IAAI,CAAC,UAAU,CAAC,OAAO,SAAS,IAAI,cAAc,GAChD,OAAO;EAAE,IAAI;EAAM,QAAQ;CAAU;CAEvC,IACE,KAAK,SAAS,uBAAuB,aAAa,EAAE,KACpD,gBAAgB,KAAK,MAAM,GAE3B,OAAO;EAAE,IAAI;EAAQ,SAAS;CAAO;CAEvC,IAAI,KAAK,SAAS,oCAAoC,GACpD,OAAO;EAAE,IAAI;EAAO,SAAS;CAAO;CAEtC,IAAI,KAAK,SAAS,4BAA4B,GAC5C,OAAO;EAAE,IAAI;EAAQ,SAAS;CAAO;CAEvC,IAAI,KAAK,SAAS,gBAAgB,GAChC,OAAO;EAAE,IAAI;EAAO,SAAS;CAAO;CAEtC,OAAO;EAAE,IAAI;EAAM,QAAQ;CAAU;AACvC;AAEA,MA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CLI — create Vetra projects, generate document models and editors, run local dev environments, and publish packages.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"author": "",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"cross-spawn": "7.0.6",
|
|
38
|
-
"@powerhousedao/shared": "6.2.3-dev.
|
|
38
|
+
"@powerhousedao/shared": "6.2.3-dev.98",
|
|
39
39
|
"@sentry/node-core": "^10.52.0",
|
|
40
40
|
"chalk": "5.6.2",
|
|
41
41
|
"cmd-ts": "0.15.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/cross-spawn": "6.0.6",
|
|
49
|
-
"@powerhousedao/codegen": "6.2.3-dev.
|
|
49
|
+
"@powerhousedao/codegen": "6.2.3-dev.98",
|
|
50
50
|
"tsdown": "0.23.0",
|
|
51
51
|
"vitest": "5.0.3"
|
|
52
52
|
},
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { t as delegateInit } from "./delegate-init-D1fb4-sj.mjs";
|
|
2
|
-
export { delegateInit };
|
|
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]="7641aba7-6785-5896-9cd8-04af2a6a91fd")}catch(e){}}();
|
|
4
|
-
//# debugId=7641aba7-6785-5896-9cd8-04af2a6a91fd
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delegate-init-D1fb4-sj.mjs","sources":["../src/utils/delegate-init.ts"],"sourcesContent":["import type { Agent } from \"package-manager-detector\";\nimport { execSync } from \"node:child_process\";\n\nconst PH_CLI_PACKAGE = \"@powerhousedao/ph-cli\";\n// `init` was added to ph-cli in the 6.x rewrite. Older versions (still on\n// the `latest` tag at time of writing) shell out via commander and bail with\n// a confusing \"unknown command 'init'\" error after a 90-second dlx install.\n// This floor lets us fail fast with an actionable message instead.\nconst MIN_PH_CLI_MAJOR = 6;\n\n/**\n * Subset of `initArgs` the delegator actually inspects. Keeping this loose\n * lets `setup-globals` reuse the helper without an extra type import dance.\n */\nexport interface DelegateInitArgs {\n packageManager?: Agent;\n npm?: boolean;\n pnpm?: boolean;\n yarn?: boolean;\n bun?: boolean;\n tag?: string;\n version?: string;\n dev?: boolean;\n staging?: boolean;\n rc?: boolean;\n debug?: boolean;\n}\n\n/**\n * Resolves a concrete `@powerhousedao/ph-cli` version, verifies it's >= 6.x,\n * and shells out via the user's package manager (npx / pnpm dlx / etc.) to\n * run `ph-cli init`. Used by both `ph init` (forwards verbatim) and\n * `ph setup-globals` (forwards with `--name .ph` injected after chdir to ~).\n *\n * Does NOT call `process.exit`: callers are responsible for any post-init\n * fix-up + exit.\n */\nexport async function delegateInit(\n args: DelegateInitArgs,\n extraForwardedArgs: string[] = [],\n): Promise<void> {\n const {\n fetchNpmVersionFromRegistryForTag,\n handleMutuallyExclusiveOptions,\n parsePackageManager,\n parseTag,\n } = await import(\"@powerhousedao/shared/clis\");\n\n handleMutuallyExclusiveOptions(\n {\n tag: args.tag,\n version: args.version,\n dev: args.dev,\n staging: args.staging,\n rc: args.rc,\n },\n \"versioning strategy\",\n );\n\n handleMutuallyExclusiveOptions(\n {\n npm: args.npm,\n pnpm: args.pnpm,\n yarn: args.yarn,\n bun: args.bun,\n packageManager: args.packageManager,\n },\n \"package manager\",\n );\n\n const tag = parseTag(args);\n const phCliVersionOrTag = args.version ?? tag;\n const pm = parsePackageManager(args) ?? \"npm\";\n // `process.argv` here is `[node, ph-cmd-bin, <subcommand>, ...userArgs]`.\n // Forward everything from the user, prepending caller-supplied flags.\n const forwardedArgs = [...extraForwardedArgs, ...process.argv.slice(3)];\n\n // Resolve the tag to a concrete version up front and verify it's >= 6.x.\n // `--version` is user-supplied so we trust it and only resolve when a tag\n // (latest/staging/dev) is in play.\n let resolvedVersion = args.version;\n try {\n if (!resolvedVersion) {\n resolvedVersion = await fetchNpmVersionFromRegistryForTag(\n PH_CLI_PACKAGE,\n tag,\n );\n }\n } catch (err) {\n // Network/registry hiccup — fall through to the dlx so a flaky\n // connection doesn't block the user. The dlx will surface its own\n // error if the version genuinely can't be installed.\n if (args.debug) {\n console.error(\">>> ph-cli version resolution skipped:\", err);\n }\n }\n const { coerce } = await import(\"semver\");\n const parsed = resolvedVersion ? coerce(resolvedVersion) : null;\n if (parsed && parsed.major < MIN_PH_CLI_MAJOR) {\n // Print + exit (rather than throw) to avoid the cli.ts catch handler\n // shipping this expected user-input error to Sentry.\n console.error(\n `${PH_CLI_PACKAGE}@${phCliVersionOrTag} resolves to ${resolvedVersion}, ` +\n `which doesn't support 'init' (requires >= ${MIN_PH_CLI_MAJOR}.0.0).\\n` +\n `Try: ph init --dev <args> or ph init --version <${MIN_PH_CLI_MAJOR}.x.x> <args>`,\n );\n process.exit(1);\n }\n\n const phCliPackage = `${PH_CLI_PACKAGE}@${resolvedVersion ?? phCliVersionOrTag}`;\n const { resolveCommand } = await import(\"package-manager-detector\");\n const resolved = resolveCommand(pm, \"execute\", [\n phCliPackage,\n \"init\",\n ...forwardedArgs,\n ]);\n\n if (!resolved) {\n throw new Error(\n `Could not resolve execute command for package manager \"${pm}\".`,\n );\n }\n\n const { injectPnpmAllowBuilds } = await import(\"@powerhousedao/shared/clis\");\n injectPnpmAllowBuilds(pm, resolved);\n\n const { command: cmd, args: cmdArgs } = resolved;\n const fullCmd = `${cmd} ${cmdArgs.join(\" \")}`;\n\n if (args.debug) {\n console.log(\">>> Delegating to ph-cli:\", fullCmd);\n }\n\n try {\n execSync(fullCmd, { stdio: \"inherit\" });\n } catch (err) {\n // Propagate normal non-zero exits but throw on abnormal exits to ensure\n // the error is reported.\n const e = err as {\n status?: number | null;\n signal?: NodeJS.Signals | null;\n };\n if (typeof e.status === \"number\" && !e.signal) {\n process.exit(e.status);\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C/D;CAGF,MAAM,EAAE,0BAA0B,MAAM,OAAO;CAC/C,sBAAsB,IAAI,QAAQ;CAElC,MAAM,EAAE,SAAS,KAAK,MAAM,YAAY;CACxC,MAAM,UAAU,GAAG,IAAI,GAAG,QAAQ,KAAK,GAAG;CAE1C,IAAI,KAAK,OACP,QAAQ,IAAI,6BAA6B,OAAO;CAGlD,IAAI;EACF,SAAS,SAAS,EAAE,OAAO,UAAU,CAAC;CACxC,SAAS,KAAK;EAGZ,MAAM,IAAI;EAIV,IAAI,OAAO,EAAE,WAAW,YAAY,CAAC,EAAE,QACrC,QAAQ,KAAK,EAAE,MAAM;EAEvB,MAAM;CACR;AACF","debug_id":"18cb0507-547a-5f87-ae25-30150a7853e2"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-CWQ__mHD.mjs","sources":["../src/commands/init.ts","../src/utils/self-update.ts","../src/commands/self-update.ts","../src/commands/setup-globals.ts","../src/commands/update.ts","../src/commands/use-local.ts","../src/commands/use.ts","../src/commands/ph.ts","../src/run.ts"],"sourcesContent":["import { initArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\nimport { delegateInit } from \"../utils/delegate-init.js\";\n\n/**\n * Delegates `ph init` to the appropriate version of `@powerhousedao/ph-cli`.\n * This ensures the init logic (boilerplate, codegen) always matches the\n * ph-cli version being installed in the new project.\n */\nexport const init = command({\n name: \"init\",\n description: \"Initialize a new project\",\n args: initArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log({ args });\n }\n await delegateInit(args);\n process.exit(0);\n },\n});\n","import { spawn as spawnChild } from \"cross-spawn\";\nimport { readFile as readFileAsync } from \"node:fs/promises\";\n\nimport { getStream } from \"./version-check.js\";\n\nexport type GlobalPackageManager = \"npm\" | \"pnpm\" | \"bun\" | \"yarn\";\n\nexport type InstallDetection =\n | { pm: GlobalPackageManager; pkgRoot: string }\n | { pm: null; reason: \"source-checkout\" | \"unknown\" };\n\nconst PACKAGE_NAME = \"ph-cmd\";\n\nfunction normalizePath(p: string): string {\n return p.replace(/\\\\/g, \"/\").replace(/\\/+$/, \"\");\n}\n\n/**\n * Which package manager owns the running global install, resolved from the\n * real path of the running bundle (the bin entry is a symlink; the ESM\n * loader resolves it). Path signatures:\n * pnpm: <global>/node_modules/.pnpm/ph-cmd@<v>/node_modules/ph-cmd/...\n * bun: <home>/.bun/install/global/node_modules/ph-cmd/...\n * yarn: <global>/yarn/global/node_modules/ph-cmd/... (yarn classic)\n * npm: <prefix>/lib/node_modules/ph-cmd/... (any plain node_modules)\n * A source checkout (<repo>/clis/ph-cmd/dist/cli.mjs) and any unrecognized\n * layout are refused with a reason instead of guessing.\n */\nexport function detectGlobalInstall(rawPath: string): InstallDetection {\n const real = normalizePath(rawPath);\n if (real.includes(\"/clis/ph-cmd/\")) {\n return { pm: null, reason: \"source-checkout\" };\n }\n const pkgDir = real.endsWith(`/dist/cli.mjs`)\n ? real.slice(0, -\"/dist/cli.mjs\".length)\n : null;\n if (!pkgDir || !pkgDir.endsWith(`/${PACKAGE_NAME}`)) {\n return { pm: null, reason: \"unknown\" };\n }\n if (real.includes(`/node_modules/.pnpm/${PACKAGE_NAME}@`)) {\n return { pm: \"pnpm\", pkgRoot: pkgDir };\n }\n if (real.includes(\"/.bun/install/global/node_modules/\")) {\n return { pm: \"bun\", pkgRoot: pkgDir };\n }\n if (real.includes(\"/yarn/global/node_modules/\")) {\n return { pm: \"yarn\", pkgRoot: pkgDir };\n }\n if (real.includes(\"/node_modules/\")) {\n return { pm: \"npm\", pkgRoot: pkgDir };\n }\n return { pm: null, reason: \"unknown\" };\n}\n\nconst UPDATE_COMMANDS: Record<\n GlobalPackageManager,\n { command: (spec: string) => string; argv: (spec: string) => string[] }\n> = {\n npm: {\n command: (spec) => `npm install -g ${spec}`,\n argv: (spec) => [\"npm\", \"install\", \"-g\", spec],\n },\n pnpm: {\n command: (spec) => `pnpm add -g ${spec}`,\n argv: (spec) => [\"pnpm\", \"add\", \"-g\", spec],\n },\n bun: {\n command: (spec) => `bun add -g ${spec}`,\n argv: (spec) => [\"bun\", \"add\", \"-g\", spec],\n },\n yarn: {\n command: (spec) => `yarn global add ${spec}`,\n argv: (spec) => [\"yarn\", \"global\", \"add\", spec],\n },\n};\n\n/** Human-readable update command (for error hints). */\nexport function updateCommand(pm: GlobalPackageManager, tag: string): string {\n return UPDATE_COMMANDS[pm].command(`${PACKAGE_NAME}@${tag}`);\n}\n\n/** Exact argv used to spawn the package manager. */\nexport function updateArgv(pm: GlobalPackageManager, tag: string): string[] {\n return UPDATE_COMMANDS[pm].argv(`${PACKAGE_NAME}@${tag}`);\n}\n\nexport type SelfUpdateDeps = {\n /** Runs a full argv (program first); rejects on non-zero exit. */\n spawner?: (argv: string[], opts: { stdio: \"inherit\" }) => Promise<void>;\n readFile?: (path: string) => Promise<string>;\n stdout?: (line: string) => void;\n stderr?: (line: string) => void;\n /** called with the new version after a successful update (clears the notice). */\n refreshCache?: (newVersion: string) => Promise<void>;\n};\n\nexport type SelfUpdateResult =\n | { ok: true; from: string; to: string }\n | { ok: false; message: string };\n\nfunction defaultSpawner(\n argv: string[],\n opts: { stdio: \"inherit\" },\n): Promise<void> {\n const { promise, resolve, reject } = Promise.withResolvers<void>();\n const child = spawnChild(argv[0], argv.slice(1), opts);\n child.on(\"close\", (code) =>\n code === 0\n ? resolve()\n : reject(new Error(`${argv[0]} exited with code ${code}`)),\n );\n child.on(\"error\", reject);\n return promise;\n}\n\n/**\n * Upgrade the global ph-cmd install to `tag` (default: the running build's\n * stream) using the owning package manager, then report the new version.\n * Never throws: refusals and failures come back as `{ ok: false }` so the\n * command layer owns the exit code.\n */\nexport async function runSelfUpdate(opts: {\n currentVersion: string;\n tag?: string;\n realPath: string;\n deps?: SelfUpdateDeps;\n}): Promise<SelfUpdateResult> {\n const {\n spawner = defaultSpawner,\n readFile = (p: string) => readFileAsync(p, \"utf-8\"),\n stdout = (line: string) => console.log(line),\n stderr = (line: string) => console.error(line),\n refreshCache,\n } = opts.deps ?? {};\n\n const detection = detectGlobalInstall(opts.realPath);\n if (detection.pm === null) {\n if (detection.reason === \"source-checkout\") {\n const message =\n \"ph is running from a source checkout; self-update only applies to global installs.\";\n stderr(message);\n return { ok: false, message };\n }\n const manual = (Object.keys(UPDATE_COMMANDS) as GlobalPackageManager[])\n .map((pm) => ` ${updateCommand(pm, \"latest\")}`)\n .join(\"\\n\");\n const message = `Couldn't determine how ph was installed (${opts.realPath}). Update manually:\\n${manual}`;\n stderr(message);\n return { ok: false, message };\n }\n\n const tag = opts.tag ?? getStream(opts.currentVersion);\n stdout(\n `Updating ph-cmd via ${detection.pm} (${updateCommand(detection.pm, tag)})...`,\n );\n try {\n await spawner(updateArgv(detection.pm, tag), { stdio: \"inherit\" });\n } catch (error: unknown) {\n const message = `ph-cmd update failed via ${detection.pm}. Try manually: ${updateCommand(detection.pm, tag)}`;\n stderr(message);\n if (error instanceof Error) stderr(error.message);\n return { ok: false, message };\n }\n\n let to = \"unknown\";\n try {\n const pkg = JSON.parse(\n await readFile(`${detection.pkgRoot}/package.json`),\n ) as { version?: unknown };\n if (typeof pkg.version === \"string\") to = pkg.version;\n } catch {\n // leave \"unknown\" — the PM already printed its own result\n }\n stdout(\n `Updated ph-cmd from ${opts.currentVersion} to ${to}. The new version takes effect on your next 'ph' run.`,\n );\n await refreshCache?.(to).catch(() => {});\n return { ok: true, from: opts.currentVersion, to };\n}\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, optional, option, string } from \"cmd-ts\";\nimport { realpath } from \"node:fs/promises\";\nimport { PH_CMD_STREAMS, setCacheCurrent } from \"../utils/version-check.js\";\nimport { runSelfUpdate } from \"../utils/self-update.js\";\nimport { getVersion } from \"../get-version.js\";\n\nexport const selfUpdate = command({\n name: \"self-update\",\n description:\n \"Update the globally installed ph to the newest version of its release stream\",\n args: {\n tag: option({\n type: optional(string),\n long: \"tag\",\n short: \"t\",\n description: `dist-tag to install (defaults to the running build's stream; e.g. ${PH_CMD_STREAMS.join(\n \", \",\n )})`,\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n if (args.debug) {\n console.log({ args });\n }\n // The real path of the running bundle identifies the global install\n // (and its package manager). argv[1] is the entry script; the ESM\n // loader already resolved symlinks, realpath is belt-and-braces.\n const entry = process.argv[1];\n const realPath = entry\n ? await realpath(entry)\n : import.meta.url.replace(/^file:\\/\\//, \"\");\n const result = await runSelfUpdate({\n currentVersion: getVersion(),\n tag: args.tag,\n realPath,\n });\n if (!result.ok) {\n process.exit(1);\n }\n // Quiet the notice on the next run: the new version is now current.\n await setCacheCurrent(result.to);\n process.exit(0);\n },\n});\n","import { initArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nconst PH_GLOBAL_PACKAGE_NAME = \"ph-global\";\n\n/**\n * `ph setup-globals` bootstraps the `~/.ph` project. It's the same flow as\n * `ph init` with `--name .ph` from the user's home directory, plus a\n * post-step that renames the package.json to `ph-global` (since `.ph` is\n * an invalid npm name).\n */\nexport const setupGlobals = command({\n name: \"setup-globals\",\n description: \"Initialize a new global project\",\n args: initArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log({ args });\n }\n\n const { HOME_DIR, PH_GLOBAL_DIR_NAME, POWERHOUSE_GLOBAL_DIR } =\n await import(\"@powerhousedao/shared/clis\");\n\n /**\n * Fix the package.json `name` field for the global project — `.ph` is a\n * valid directory name but not a valid npm package name (vite + npm\n * reject names starting with a dot). We let `ph init` create the project\n * as `.ph` and then rename it here to `ph-global`.\n */\n const fixGlobalPackageName = (): void => {\n const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, \"package.json\");\n if (!existsSync(packageJsonPath)) return;\n try {\n const packageJson = JSON.parse(\n readFileSync(packageJsonPath, \"utf-8\"),\n ) as { name?: string };\n if (packageJson.name?.startsWith(\".\")) {\n packageJson.name = PH_GLOBAL_PACKAGE_NAME;\n writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n }\n } catch {\n // Ignore parse/write failures — leaves the file untouched.\n }\n };\n\n // The directory itself can exist without the project being bootstrapped —\n // telemetry writes `~/.ph/telemetry.json` early on. Use the presence of\n // `package.json` as the real \"is initialized\" signal.\n const globalPackageJson = path.join(POWERHOUSE_GLOBAL_DIR, \"package.json\");\n if (existsSync(globalPackageJson)) {\n // Repair-in-place: an older bootstrap may have left `name: \".ph\"` in\n // package.json, which breaks vite/npm. Fix it on every invocation.\n fixGlobalPackageName();\n console.log(`📦 Using global project: ${POWERHOUSE_GLOBAL_DIR}`);\n process.exit(0);\n }\n\n console.log(\"📦 Initializing global project...\");\n process.chdir(HOME_DIR);\n const { delegateInit } = await import(\"../utils/delegate-init.js\");\n await delegateInit(args, [\"--name\", PH_GLOBAL_DIR_NAME]);\n fixGlobalPackageName();\n console.log(\n `🚀 Global project initialized successfully: ${POWERHOUSE_GLOBAL_DIR}`,\n );\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { ALL_POWERHOUSE_DEPENDENCIES } from \"@powerhousedao/shared/constants\";\nimport { boolean, command, flag, optional } from \"cmd-ts\";\n\nexport const update = command({\n name: \"update\",\n description:\n \"Update your Powerhouse dependencies and installed packages to their latest versions\",\n args: {\n skipInstall: flag({\n type: optional(boolean),\n long: \"skip-install\",\n short: \"s\",\n description: \"Skip running `install` with your package manager\",\n }),\n updatePackages: flag({\n type: optional(boolean),\n long: \"update-packages\",\n description:\n \"Auto-update installed packages (powerhouse.config.json) to their newest same-major version\",\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n const { skipInstall, updatePackages, debug } = args;\n if (debug) {\n console.log({ args });\n }\n console.log(`\\n▶️ Updating Powerhouse dependencies...\\n`);\n const [\n { default: chalk },\n { readPackage },\n { writePackage },\n { getTagFromVersion, logVersionUpdate, parsePackageVersion, runCmd },\n { resolveRegistryUrl },\n { updateInstalledPackages },\n ] = await Promise.all([\n import(\"chalk\"),\n import(\"read-pkg\"),\n import(\"write-package\"),\n import(\"@powerhousedao/shared/clis\"),\n import(\"@powerhousedao/shared/registry\"),\n import(\"./update-packages.js\"),\n ]);\n const registryUrl = resolveRegistryUrl({ projectPath: process.cwd() });\n const packageJson = await readPackage();\n\n if (packageJson.dependencies) {\n for (const [name, version] of Object.entries(packageJson.dependencies)) {\n if (version && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const tag = getTagFromVersion(version);\n const newVersion = await parsePackageVersion({ name, tag });\n packageJson.dependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.devDependencies) {\n for (const [name, version] of Object.entries(\n packageJson.devDependencies,\n )) {\n if (version && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const tag = getTagFromVersion(version);\n const newVersion = await parsePackageVersion({ name, tag });\n packageJson.devDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.optionalDependencies) {\n for (const [name, version] of Object.entries(\n packageJson.optionalDependencies,\n )) {\n if (version && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const tag = getTagFromVersion(version);\n const newVersion = await parsePackageVersion({ name, tag });\n packageJson.optionalDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.peerDependencies) {\n for (const [name, version] of Object.entries(\n packageJson.peerDependencies,\n )) {\n if (version && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const tag = getTagFromVersion(version);\n const newVersion = await parsePackageVersion({ name, tag });\n packageJson.peerDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version,\n newVersion,\n });\n }\n }\n }\n\n await writePackage(packageJson);\n\n console.log(chalk.green(`\\n✅ Project updated successfully\\n`));\n\n // Detect the package manager once; it backs the install below and the\n // update of `local` (node_modules) installed packages.\n const { detect } = await import(\"package-manager-detector/detect\");\n const packageManager = await detect();\n\n await updateInstalledPackages({\n registryUrl,\n auto: updatePackages ?? false,\n skipInstall: skipInstall ?? false,\n packageManager,\n });\n\n if (skipInstall) return;\n\n if (!packageManager) {\n throw new Error(\n `❌ Failed to detect your package manager. Run install manually.`,\n );\n }\n console.log(\n `▶️ Installing updated dependencies with \\`${packageManager.agent}\\`\\n`,\n );\n runCmd(`${packageManager.agent} install`);\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport {\n boolean,\n command,\n flag,\n option,\n optional,\n positional,\n string,\n} from \"cmd-ts\";\n\nexport const useLocal = command({\n name: \"use-local\",\n description:\n \"Use your local `powerhouse` monorepo dependencies the current project.\",\n args: {\n monorepoPathPositional: positional({\n type: optional(string),\n displayName: \"monorepo path\",\n description:\n \"Path to your local powerhouse monorepo relative to this project\",\n }),\n monorepoPathOption: option({\n type: optional(string),\n long: \"path\",\n short: \"p\",\n description:\n \"Path to your local powerhouse monorepo relative to this project\",\n }),\n skipInstall: flag({\n type: optional(boolean),\n long: \"skip-install\",\n short: \"s\",\n description: \"Skip running `install` with `pnpm`\",\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n const { monorepoPathPositional, monorepoPathOption, skipInstall, debug } =\n args;\n if (debug) {\n console.log({ args });\n }\n const monorepoPath = monorepoPathPositional ?? monorepoPathOption;\n\n if (!monorepoPath) {\n throw new Error(\n \"❌ Please provide the path to your local powerhouse monorepo.\",\n );\n }\n\n const { runUseLocal } = await import(\"@powerhousedao/shared/clis\");\n await runUseLocal(monorepoPath, skipInstall);\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { ALL_POWERHOUSE_DEPENDENCIES } from \"@powerhousedao/shared/constants\";\nimport {\n boolean,\n command,\n flag,\n oneOf,\n option,\n optional,\n positional,\n run,\n string,\n} from \"cmd-ts\";\n\nexport const use = command({\n name: \"use\",\n description: \"Specify the release version of Powerhouse dependencies to use.\",\n args: {\n tagPositional: positional({\n type: optional(oneOf([\"latest\", \"staging\", \"dev\", \"rc\"])),\n displayName: \"tag\",\n description: `Specify the release tag to use for your project. Can be one of: \"latest\", \"staging\", \"dev\", or \"rc\".`,\n }),\n tagOption: option({\n type: optional(oneOf([\"latest\", \"staging\", \"dev\", \"rc\"])),\n long: \"tag\",\n short: \"t\",\n description: `Specify the release tag to use for your project. Can be one of: \"latest\", \"staging\", \"dev\", or \"rc\".`,\n }),\n version: option({\n type: optional(string),\n long: \"version\",\n short: \"v\",\n description:\n \"Specify the exact semver release version to use for your project.\",\n }),\n skipInstall: flag({\n type: optional(boolean),\n long: \"skip-install\",\n short: \"s\",\n description: \"Skip running `install` with your package manager\",\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n const { tagPositional, tagOption, version, skipInstall, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const tag = tagPositional ?? tagOption;\n const {\n handleMutuallyExclusiveOptions,\n logVersionUpdate,\n parsePackageVersion,\n runCmd,\n } = await import(\"@powerhousedao/shared/clis\");\n handleMutuallyExclusiveOptions({ tag, version }, \"versioning strategy\");\n\n if (!tag && !version) {\n throw new Error(\n \"Please specify either a release tag or a version to use.\",\n );\n }\n\n const [\n { default: chalk },\n { readPackage },\n { writePackage },\n { clean, valid },\n ] = await Promise.all([\n import(\"chalk\"),\n import(\"read-pkg\"),\n import(\"write-package\"),\n import(\"semver\"),\n ]);\n\n if (version && !valid(clean(version))) {\n throw new Error(`❌ Invalid version: ${chalk.bold(version)}`);\n }\n\n console.log(\n `▶️ Updating project to use ${chalk.bold(version ?? tag)}...\\n`,\n );\n\n const packageJson = await readPackage();\n\n if (packageJson.dependencies) {\n for (const [name, existingVersion] of Object.entries(\n packageJson.dependencies,\n )) {\n if (existingVersion && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const newVersion = await parsePackageVersion({ name, tag, version });\n packageJson.dependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version: existingVersion,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.devDependencies) {\n for (const [name, existingVersion] of Object.entries(\n packageJson.devDependencies,\n )) {\n if (existingVersion && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const newVersion = await parsePackageVersion({ name, tag, version });\n packageJson.devDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version: existingVersion,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.optionalDependencies) {\n for (const [name, existingVersion] of Object.entries(\n packageJson.optionalDependencies,\n )) {\n if (existingVersion && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const newVersion = await parsePackageVersion({ name, tag, version });\n packageJson.optionalDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version: existingVersion,\n newVersion,\n });\n }\n }\n }\n\n if (packageJson.peerDependencies) {\n for (const [name, existingVersion] of Object.entries(\n packageJson.peerDependencies,\n )) {\n if (existingVersion && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {\n const newVersion = await parsePackageVersion({ name, tag, version });\n packageJson.peerDependencies[name] = newVersion;\n logVersionUpdate({\n name,\n version: existingVersion,\n newVersion,\n });\n }\n }\n }\n\n await writePackage(packageJson);\n\n console.log(\n chalk.green(\n `\\n✅ Project updated to use ${chalk.bold(version ?? tag)}\\n`,\n ),\n );\n\n if (!skipInstall) {\n const { detect } = await import(\"package-manager-detector/detect\");\n const packageManager = await detect();\n if (!packageManager) {\n throw new Error(\n `❌ Failed to detect your package manager. Run install manually.`,\n );\n }\n console.log(\n `▶️ Installing updated dependencies with \\`${packageManager.agent}\\`\\n`,\n );\n runCmd(`${packageManager.agent} install`);\n }\n\n process.exit(0);\n },\n});\n\nexport async function runUse(args: string[]) {\n await run(use, args);\n}\n","import { phCliHelpCommands } from \"@powerhousedao/shared/clis/args\";\nimport { subcommands } from \"cmd-ts\";\nimport { getVersion } from \"../get-version.js\";\nimport { init } from \"./init.js\";\nimport { selfUpdate } from \"./self-update.js\";\nimport { setupGlobals } from \"./setup-globals.js\";\nimport { update } from \"./update.js\";\nimport { useLocal } from \"./use-local.js\";\nimport { use } from \"./use.js\";\n\n// `--version` is intercepted in cli.ts before the subcommand tree is\n// constructed, so cmd-ts only needs the bare version string here. The\n// rich version output (with project info, package manager, etc.) is\n// produced by `getPhCmdVersionInfo` along that short-circuit path.\nexport const ph = subcommands({\n name: \"ph\",\n version: getVersion(),\n description:\n \"The Powerhouse CLI (ph-cmd) is a command-line interface tool that provides essential commands for managing Powerhouse projects.\\nThe tool and it's commands are fundamental for creating, building, and running Document Models as a builder in studio mode.\",\n cmds: {\n init,\n use,\n update,\n \"self-update\": selfUpdate,\n \"setup-globals\": setupGlobals,\n \"use-local\": useLocal,\n ...phCliHelpCommands,\n },\n});\n","import { run as runCmdTs } from \"cmd-ts\";\nimport { ph } from \"./commands/ph.js\";\n\nexport async function run(args: string[]) {\n return await runCmdTs(ph, args);\n}\n"],"names":["spawnChild","readFileAsync","readFile","runCmdTs"],"mappings":";;;;;;;;;;;;;;;;;;AASA,MAAa,OAAO,QAAQ;CAC1B,MAAM;CACN,aAAa;CACb,MAAM;CACN,SAAS,OAAO,SAAS;EACvB,IAAI,KAAK,OACP,QAAQ,IAAI,EAAE,KAAK,CAAC;EAEtB,MAAM,aAAa,IAAI;EACvB,QAAQ,KAAK,CAAC;CAChB;AACF,CAAC;;;ACTD,MAAM,eAAe;AAErB,SAAS,cAAc,GAAmB;CACxC,OAAO,EAAE,QAAQ,OAAO,GAAG,CAAC,CAAC,QAAQ,QAAQ,EAAE;AACjD;;;;;;;;;;;;AAaA,SAAgB,oBAAoB,SAAmC;CACrE,MAAM,OAAO,cAAc,OAAO;CAClC,IAAI,KAAK,SAAS,eAAe,GAC/B,OAAO;EAAE,IAAI;EAAM,QAAQ;CAAkB;CAE/C,MAAM,SAAS,KAAK,SAAS,eAAe,IACxC,KAAK,MAAM,GAAG,GAAuB,IACrC;CACJ,IAAI,CAAC,UAAU,CAAC,OAAO,SAAS,IAAI,cAAc,GAChD,OAAO;EAAE,IAAI;EAAM,QAAQ;CAAU;CAEv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