ph-cmd 6.0.0-dev.227 → 6.0.0-dev.229
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 +11 -4
- package/dist/cli.mjs.map +1 -1
- package/dist/create-global-project-Cf8BOmqR.mjs +99 -0
- package/dist/create-global-project-Cf8BOmqR.mjs.map +1 -0
- package/dist/generate-commands-docs.mjs +2 -2
- package/dist/{ph-Bi7CvLUU.mjs → ph-CYuEOx4_.mjs} +36 -106
- package/dist/ph-CYuEOx4_.mjs.map +1 -0
- package/dist/{ph-cli-B-WtTRVW.mjs → ph-cli-bUpVoHgn.mjs} +13 -6
- package/dist/{ph-cli-B-WtTRVW.mjs.map → ph-cli-bUpVoHgn.mjs.map} +1 -1
- package/dist/{run-vh1K535u.mjs → run-5mQ_EG2X.mjs} +2 -2
- package/dist/{run-vh1K535u.mjs.map → run-5mQ_EG2X.mjs.map} +1 -1
- package/package.json +4 -4
- package/dist/ph-Bi7CvLUU.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { phCliCommandNames } from "@powerhousedao/shared/clis/command-names";
|
|
3
|
+
import { captureCliError, initCliTelemetry } from "@powerhousedao/shared/clis/telemetry";
|
|
4
|
+
import { assertNodeVersion } from "@powerhousedao/shared/clis/utils";
|
|
3
5
|
//#region src/cli.ts
|
|
4
6
|
/**
|
|
5
7
|
* ph-cli and ph-cmd are loaded lazily so that the node version is checked before
|
|
6
8
|
* any code is parsed to avoid errors on startup due to unsupported dependencies.
|
|
7
9
|
*/
|
|
8
10
|
async function runPhCliCommand(phCliCommand) {
|
|
9
|
-
const { executePhCliCommand } = await import("./ph-cli-
|
|
11
|
+
const { executePhCliCommand } = await import("./ph-cli-bUpVoHgn.mjs");
|
|
10
12
|
return await executePhCliCommand(phCliCommand);
|
|
11
13
|
}
|
|
12
14
|
async function runPhCmdCommand(args) {
|
|
13
|
-
const { run } = await import("./run-
|
|
15
|
+
const { run } = await import("./run-5mQ_EG2X.mjs");
|
|
14
16
|
return await run(args);
|
|
15
17
|
}
|
|
16
18
|
async function main() {
|
|
17
19
|
assertNodeVersion();
|
|
18
20
|
await initCliTelemetry({
|
|
19
21
|
cliName: "ph-cmd",
|
|
20
|
-
release: "6.0.0-dev.
|
|
22
|
+
release: "6.0.0-dev.229"
|
|
21
23
|
});
|
|
22
24
|
const args = process.argv.slice(2);
|
|
23
25
|
const command = args[0];
|
|
26
|
+
if (args.length === 1 && (command === "--version" || command === "-v")) {
|
|
27
|
+
const { getPhCmdVersionInfo } = await import("@powerhousedao/shared/clis");
|
|
28
|
+
console.log(await getPhCmdVersionInfo("6.0.0-dev.229"));
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
24
31
|
if (command === "connect" && !args.some((arg) => [
|
|
25
32
|
"studio",
|
|
26
33
|
"build",
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport {\n
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { phCliCommandNames } from \"@powerhousedao/shared/clis/command-names\";\nimport {\n captureCliError,\n initCliTelemetry,\n} from \"@powerhousedao/shared/clis/telemetry\";\nimport { assertNodeVersion } from \"@powerhousedao/shared/clis/utils\";\n\n// Injected at build time by tsdown (see tsdown.config.ts `define`).\ndeclare const CLI_VERSION: string;\n\n/**\n * ph-cli and ph-cmd are loaded lazily so that the node version is checked before\n * any code is parsed to avoid errors on startup due to unsupported dependencies.\n */\n\nasync function runPhCliCommand(phCliCommand: string) {\n const { executePhCliCommand } = await import(\"./ph-cli.js\");\n return await executePhCliCommand(phCliCommand);\n}\nasync function runPhCmdCommand(args: string[]) {\n const { run } = await import(\"./run.js\");\n return await run(args);\n}\n\nasync function main() {\n assertNodeVersion();\n // Opt-out telemetry; asked once on first interactive run. No-op under\n // PH_NO_TELEMETRY / DO_NOT_TRACK / CI.\n await initCliTelemetry({ cliName: \"ph-cmd\", release: CLI_VERSION });\n const args = process.argv.slice(2);\n const command = args[0];\n\n // Short-circuit `ph --version` / `ph -v` so we don't pay for the full\n // cmd-ts subcommand tree (which dynamic-imports the heavy clis bundle\n // just to populate the `version` field). `ph use --version 1.2.3` and\n // similar are unaffected because they have a subcommand first.\n if (args.length === 1 && (command === \"--version\" || command === \"-v\")) {\n const { getPhCmdVersionInfo } = await import(\"@powerhousedao/shared/clis\");\n console.log(await getPhCmdVersionInfo(CLI_VERSION));\n process.exit(0);\n }\n\n // handle the special case where running `connect` with no positional argument\n // defaults to `connect studio`\n if (\n command === \"connect\" &&\n !args.some((arg) => [\"studio\", \"build\", \"preview\"].includes(arg)) &&\n // do not default to `connect studio` when help is present, instead show general help\n // for the `connect` command\n !args.some((arg) => [\"--help\", \"-h\"].includes(arg))\n ) {\n await runPhCliCommand(\"connect\");\n process.exit(0);\n }\n\n // forward command to the local ph-cli installation if it exists\n if (\n phCliCommandNames.includes(command as (typeof phCliCommandNames)[number])\n ) {\n await runPhCliCommand(command);\n process.exit(0);\n }\n\n await runPhCmdCommand(args);\n process.exit(0);\n}\n\nawait main().catch(async (error) => {\n const isDebug = process.argv.slice(2).includes(\"--debug\");\n // No-op when telemetry is disabled; flushes before we exit otherwise.\n await captureCliError(error);\n if (isDebug) {\n throw error;\n }\n if (error instanceof Error) {\n console.error(error.message);\n process.exit(1);\n } else {\n throw error;\n }\n});\n"],"mappings":";;;;;;;;;AAgBA,eAAe,gBAAgB,cAAsB;CACnD,MAAM,EAAE,wBAAwB,MAAM,OAAO;AAC7C,QAAO,MAAM,oBAAoB,aAAa;;AAEhD,eAAe,gBAAgB,MAAgB;CAC7C,MAAM,EAAE,QAAQ,MAAM,OAAO;AAC7B,QAAO,MAAM,IAAI,KAAK;;AAGxB,eAAe,OAAO;AACpB,oBAAmB;AAGnB,OAAM,iBAAiB;EAAE,SAAS;EAAU,SAAA;EAAsB,CAAC;CACnE,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE;CAClC,MAAM,UAAU,KAAK;AAMrB,KAAI,KAAK,WAAW,MAAM,YAAY,eAAe,YAAY,OAAO;EACtE,MAAM,EAAE,wBAAwB,MAAM,OAAO;AAC7C,UAAQ,IAAI,MAAM,oBAAA,gBAAgC,CAAC;AACnD,UAAQ,KAAK,EAAE;;AAKjB,KACE,YAAY,aACZ,CAAC,KAAK,MAAM,QAAQ;EAAC;EAAU;EAAS;EAAU,CAAC,SAAS,IAAI,CAAC,IAGjE,CAAC,KAAK,MAAM,QAAQ,CAAC,UAAU,KAAK,CAAC,SAAS,IAAI,CAAC,EACnD;AACA,QAAM,gBAAgB,UAAU;AAChC,UAAQ,KAAK,EAAE;;AAIjB,KACE,kBAAkB,SAAS,QAA8C,EACzE;AACA,QAAM,gBAAgB,QAAQ;AAC9B,UAAQ,KAAK,EAAE;;AAGjB,OAAM,gBAAgB,KAAK;AAC3B,SAAQ,KAAK,EAAE;;AAGjB,MAAM,MAAM,CAAC,MAAM,OAAO,UAAU;CAClC,MAAM,UAAU,QAAQ,KAAK,MAAM,EAAE,CAAC,SAAS,UAAU;AAEzD,OAAM,gBAAgB,MAAM;AAC5B,KAAI,QACF,OAAM;AAER,KAAI,iBAAiB,OAAO;AAC1B,UAAQ,MAAM,MAAM,QAAQ;AAC5B,UAAQ,KAAK,EAAE;OAEf,OAAM;EAER"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import "node:child_process";
|
|
2
|
+
import { HOME_DIR, PH_BIN, PH_GLOBAL_DIR_NAME, POWERHOUSE_GLOBAL_DIR, parsePackageManager, parseTag } from "@powerhousedao/shared/clis";
|
|
3
|
+
import { createProject } from "@powerhousedao/codegen";
|
|
4
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
//#region src/utils/constants.ts
|
|
7
|
+
const PH_BIN_PATH = process.argv[1];
|
|
8
|
+
const PH_GLOBAL_PACKAGE_NAME = "ph-global";
|
|
9
|
+
const packageManagers = {
|
|
10
|
+
bun: {
|
|
11
|
+
installCommand: "bun add {{dependency}}",
|
|
12
|
+
execCommand: `bun ${PH_BIN} {{arguments}}`,
|
|
13
|
+
execScript: `bun {{arguments}}`,
|
|
14
|
+
lockfile: "bun.lock",
|
|
15
|
+
globalPathRegexp: /[\\/].bun[\\/]/,
|
|
16
|
+
updateCommand: "bun update {{dependency}}",
|
|
17
|
+
buildAffected: "bun run build:affected",
|
|
18
|
+
workspaceOption: "",
|
|
19
|
+
installDepsCommand: "bun install"
|
|
20
|
+
},
|
|
21
|
+
pnpm: {
|
|
22
|
+
installCommand: "pnpm add {{dependency}}",
|
|
23
|
+
execCommand: `pnpm exec ${PH_BIN} {{arguments}}`,
|
|
24
|
+
execScript: `pnpm {{arguments}}`,
|
|
25
|
+
lockfile: "pnpm-lock.yaml",
|
|
26
|
+
globalPathRegexp: /[\\/]pnpm[\\/]/,
|
|
27
|
+
updateCommand: "pnpm update {{dependency}}",
|
|
28
|
+
buildAffected: "pnpm run build:affected",
|
|
29
|
+
workspaceOption: "--workspace-root",
|
|
30
|
+
installDepsCommand: "pnpm install"
|
|
31
|
+
},
|
|
32
|
+
yarn: {
|
|
33
|
+
installCommand: "yarn add {{dependency}}",
|
|
34
|
+
execCommand: `yarn ${PH_BIN} {{arguments}}`,
|
|
35
|
+
execScript: `yarn {{arguments}}`,
|
|
36
|
+
lockfile: "yarn.lock",
|
|
37
|
+
globalPathRegexp: /[\\/]yarn[\\/]/,
|
|
38
|
+
updateCommand: "yarn upgrade {{dependency}}",
|
|
39
|
+
buildAffected: "yarn run build:affected",
|
|
40
|
+
workspaceOption: "-W",
|
|
41
|
+
installDepsCommand: "yarn install"
|
|
42
|
+
},
|
|
43
|
+
npm: {
|
|
44
|
+
installCommand: "npm install {{dependency}}",
|
|
45
|
+
execCommand: `npx ${PH_BIN} {{arguments}}`,
|
|
46
|
+
execScript: `npm run {{arguments}}`,
|
|
47
|
+
lockfile: "package-lock.json",
|
|
48
|
+
updateCommand: "npm update {{dependency}} --save",
|
|
49
|
+
buildAffected: "npm run build:affected",
|
|
50
|
+
workspaceOption: "",
|
|
51
|
+
installDepsCommand: "npm install"
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/utils/package-manager.ts
|
|
56
|
+
function getPackageManagerFromPath(dir) {
|
|
57
|
+
const lowerCasePath = dir.toLowerCase();
|
|
58
|
+
if (packageManagers.bun.globalPathRegexp.test(lowerCasePath)) return "bun";
|
|
59
|
+
else if (packageManagers.pnpm.globalPathRegexp.test(lowerCasePath)) return "pnpm";
|
|
60
|
+
else if (packageManagers.yarn.globalPathRegexp.test(lowerCasePath)) return "yarn";
|
|
61
|
+
return "npm";
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/utils/create-global-project.ts
|
|
65
|
+
const createGlobalProject = async (projectName, options = {}) => {
|
|
66
|
+
if (existsSync(POWERHOUSE_GLOBAL_DIR)) {
|
|
67
|
+
const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, "package.json");
|
|
68
|
+
if (existsSync(packageJsonPath)) try {
|
|
69
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
70
|
+
if (packageJson.name?.startsWith(".")) {
|
|
71
|
+
console.log("📦 Fixing invalid package name in global project...");
|
|
72
|
+
packageJson.name = PH_GLOBAL_PACKAGE_NAME;
|
|
73
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
74
|
+
}
|
|
75
|
+
} catch {}
|
|
76
|
+
console.log(`📦 Using global project: ${POWERHOUSE_GLOBAL_DIR}`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
console.log("📦 Initializing global project...");
|
|
80
|
+
process.chdir(HOME_DIR);
|
|
81
|
+
try {
|
|
82
|
+
await createProject({
|
|
83
|
+
name: PH_GLOBAL_DIR_NAME,
|
|
84
|
+
tag: parseTag(options),
|
|
85
|
+
packageManager: parsePackageManager(options) ?? getPackageManagerFromPath(PH_BIN_PATH)
|
|
86
|
+
});
|
|
87
|
+
const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, "package.json");
|
|
88
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
89
|
+
packageJson.name = PH_GLOBAL_PACKAGE_NAME;
|
|
90
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
91
|
+
console.log(`🚀 Global project initialized successfully: ${POWERHOUSE_GLOBAL_DIR}`);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error("❌ Failed to initialize the global project", error);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
export { createGlobalProject };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=create-global-project-Cf8BOmqR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-global-project-Cf8BOmqR.mjs","names":[],"sources":["../src/utils/constants.ts","../src/utils/package-manager.ts","../src/utils/create-global-project.ts"],"sourcesContent":["import { PH_BIN } from \"@powerhousedao/shared/clis\";\n\nexport const PH_BIN_PATH = process.argv[1];\nexport const PH_CLI_COMMANDS = [\n \"init\",\n \"dev\",\n \"connect\",\n \"generate\",\n \"reactor\",\n \"switchboard\",\n \"help\",\n \"install\",\n \"add\",\n \"i\",\n \"remove\",\n \"uninstall\",\n \"service\",\n \"list\",\n \"inspect\",\n \"version\",\n \"login\",\n \"logout\",\n];\nexport const PH_GLOBAL_PACKAGE_NAME = \"ph-global\";\n\nexport const packageManagers = {\n bun: {\n installCommand: \"bun add {{dependency}}\",\n execCommand: `bun ${PH_BIN} {{arguments}}`,\n execScript: `bun {{arguments}}`,\n lockfile: \"bun.lock\",\n globalPathRegexp: /[\\\\/].bun[\\\\/]/,\n updateCommand: \"bun update {{dependency}}\",\n buildAffected: \"bun run build:affected\",\n workspaceOption: \"\",\n installDepsCommand: \"bun install\",\n },\n pnpm: {\n installCommand: \"pnpm add {{dependency}}\",\n execCommand: `pnpm exec ${PH_BIN} {{arguments}}`,\n execScript: `pnpm {{arguments}}`,\n lockfile: \"pnpm-lock.yaml\",\n globalPathRegexp: /[\\\\/]pnpm[\\\\/]/,\n updateCommand: \"pnpm update {{dependency}}\",\n buildAffected: \"pnpm run build:affected\",\n workspaceOption: \"--workspace-root\",\n installDepsCommand: \"pnpm install\",\n },\n yarn: {\n installCommand: \"yarn add {{dependency}}\",\n execCommand: `yarn ${PH_BIN} {{arguments}}`,\n execScript: `yarn {{arguments}}`,\n lockfile: \"yarn.lock\",\n globalPathRegexp: /[\\\\/]yarn[\\\\/]/,\n updateCommand: \"yarn upgrade {{dependency}}\",\n buildAffected: \"yarn run build:affected\",\n workspaceOption: \"-W\",\n installDepsCommand: \"yarn install\",\n },\n npm: {\n installCommand: \"npm install {{dependency}}\",\n execCommand: `npx ${PH_BIN} {{arguments}}`,\n execScript: `npm run {{arguments}}`,\n lockfile: \"package-lock.json\",\n updateCommand: \"npm update {{dependency}} --save\",\n buildAffected: \"npm run build:affected\",\n workspaceOption: \"\",\n installDepsCommand: \"npm install\",\n },\n} as const;\n","import {\n POWERHOUSE_CONFIG_FILE,\n POWERHOUSE_GLOBAL_DIR,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport path, { dirname } from \"node:path\";\nimport { packageManagers } from \"./constants.js\";\nimport { createGlobalProject } from \"./create-global-project.js\";\nimport type { PackageManager, PathValidation, ProjectInfo } from \"./types.js\";\n\nexport function defaultPathValidation() {\n return true;\n}\n\nexport function isPowerhouseProject(dir: string) {\n const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);\n\n return existsSync(powerhouseConfigPath);\n}\n\nexport function findNodeProjectRoot(\n dir: string,\n pathValidation: PathValidation = defaultPathValidation,\n) {\n const packageJsonPath = path.join(dir, \"package.json\");\n\n if (existsSync(packageJsonPath) && pathValidation(dir)) {\n return dir;\n }\n\n const parentDir = dirname(dir);\n\n if (parentDir === dir) {\n return null;\n }\n\n return findNodeProjectRoot(parentDir, pathValidation);\n}\n\nexport function getPackageManagerFromPath(dir: string): PackageManager {\n const lowerCasePath = dir.toLowerCase();\n\n if (packageManagers.bun.globalPathRegexp.test(lowerCasePath)) {\n return \"bun\";\n } else if (packageManagers.pnpm.globalPathRegexp.test(lowerCasePath)) {\n return \"pnpm\";\n } else if (packageManagers.yarn.globalPathRegexp.test(lowerCasePath)) {\n return \"yarn\";\n }\n\n return \"npm\";\n}\n\nexport function getPackageManagerFromLockfile(dir: string): PackageManager {\n if (existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {\n return \"pnpm\";\n } else if (existsSync(path.join(dir, packageManagers.yarn.lockfile))) {\n return \"yarn\";\n } else if (existsSync(path.join(dir, packageManagers.bun.lockfile))) {\n return \"bun\";\n }\n\n return \"npm\";\n}\n\nexport async function getProjectInfo(\n debug?: boolean,\n generateGlobalProject = true,\n): Promise<ProjectInfo> {\n const currentPath = process.cwd();\n\n if (debug) {\n console.log(\">>> currentPath:\", currentPath);\n }\n\n const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);\n\n if (!projectPath) {\n let available = existsSync(POWERHOUSE_GLOBAL_DIR);\n\n if (generateGlobalProject) {\n await createGlobalProject();\n available = true;\n }\n\n return {\n available,\n isGlobal: true,\n path: POWERHOUSE_GLOBAL_DIR,\n };\n }\n\n return {\n isGlobal: false,\n available: true,\n path: projectPath,\n };\n}\n\nexport function forwardPHCommand(\n packageManager: PackageManager,\n projectPath: string,\n args: string,\n debug?: boolean,\n captureOutput = false,\n) {\n const manager = packageManagers[packageManager];\n const command = manager.execCommand;\n const execCommand = command.replace(\"{{arguments}}\", args);\n\n const commandOptions = { cwd: projectPath };\n\n if (debug) {\n console.log(\">>> execCommand:\", execCommand);\n console.log(\">>> commandOptions:\", commandOptions);\n console.log(\">>> projectPath:\", projectPath);\n console.log(\">>> packageManager:\", packageManager);\n }\n\n if (captureOutput) {\n // Capture output and return it\n try {\n return execSync(execCommand, {\n stdio: \"pipe\",\n encoding: \"utf8\",\n ...commandOptions,\n });\n } catch (error) {\n throw new Error(\n `Failed to execute command: ${execCommand}\\nError: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n } else {\n // Original behavior - pipe directly to stdout/stderr\n execSync(execCommand, {\n stdio: \"inherit\",\n ...commandOptions,\n });\n return \"\";\n }\n}\n\n/**\n * Recursively searches for a specific file by traversing up the directory tree.\n * Starting from the given path, it checks each parent directory until it finds\n * the target file or reaches the root directory.\n *\n * @param startPath - The absolute path of the directory to start searching from\n * @param targetFile - The name of the file to search for (e.g., 'package.json', 'pnpm-workspace.yaml')\n * @returns The absolute path of the directory containing the target file, or null if not found\n *\n * @example\n * // Find the workspace root directory\n * const workspaceRoot = findContainerDirectory('/path/to/project/src', 'pnpm-workspace.yaml');\n *\n * // Find the nearest package.json\n * const packageDir = findContainerDirectory('/path/to/project/src/components', 'package.json');\n */\nexport const findContainerDirectory = (\n startPath: string,\n targetFile: string,\n): string | null => {\n const filePath = path.join(startPath, targetFile);\n\n if (existsSync(filePath)) {\n return startPath;\n }\n\n const parentDir = path.dirname(startPath);\n\n //reached the root directory and haven't found the file\n if (parentDir === startPath) {\n return null;\n }\n\n return findContainerDirectory(parentDir, targetFile);\n};\n","import { createProject } from \"@powerhousedao/codegen\";\nimport {\n HOME_DIR,\n PH_GLOBAL_DIR_NAME,\n POWERHOUSE_GLOBAL_DIR,\n parsePackageManager,\n parseTag,\n} from \"@powerhousedao/shared/clis\";\nimport { existsSync, readFileSync, writeFileSync } from \"fs\";\nimport path from \"path\";\nimport { PH_BIN_PATH, PH_GLOBAL_PACKAGE_NAME } from \"./constants.js\";\nimport { getPackageManagerFromPath } from \"./package-manager.js\";\nimport type { GlobalProjectOptions } from \"./types.js\";\n\nexport const createGlobalProject = async (\n projectName?: string,\n options: GlobalProjectOptions = {},\n) => {\n // check if the global project already exists\n const globalProjectExists = existsSync(POWERHOUSE_GLOBAL_DIR);\n\n if (globalProjectExists) {\n // Fix existing installations with invalid \".ph\" package name\n const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, \"package.json\");\n if (existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(\n readFileSync(packageJsonPath, \"utf-8\"),\n ) as { name?: string };\n if (packageJson.name?.startsWith(\".\")) {\n console.log(\"📦 Fixing invalid package name in global project...\");\n packageJson.name = PH_GLOBAL_PACKAGE_NAME;\n writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n }\n } catch {\n // Ignore errors reading/writing package.json\n }\n }\n console.log(`📦 Using global project: ${POWERHOUSE_GLOBAL_DIR}`);\n return;\n }\n\n console.log(\"📦 Initializing global project...\");\n process.chdir(HOME_DIR);\n\n try {\n await createProject({\n name: PH_GLOBAL_DIR_NAME,\n tag: parseTag(options),\n packageManager:\n parsePackageManager(options) ?? getPackageManagerFromPath(PH_BIN_PATH),\n });\n\n // Fix the package.json name - \".ph\" is invalid for npm/vite\n // The directory name can be \".ph\" but the package name must be valid\n const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, \"package.json\");\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n name?: string;\n };\n packageJson.name = PH_GLOBAL_PACKAGE_NAME;\n writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n\n console.log(\n `🚀 Global project initialized successfully: ${POWERHOUSE_GLOBAL_DIR}`,\n );\n } catch (error) {\n console.error(\"❌ Failed to initialize the global project\", error);\n }\n};\n"],"mappings":";;;;;;AAEA,MAAa,cAAc,QAAQ,KAAK;AAqBxC,MAAa,yBAAyB;AAEtC,MAAa,kBAAkB;CAC7B,KAAK;EACH,gBAAgB;EAChB,aAAa,OA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ChD,SAAQ,MAAM,SAAS;AAEvB,KAAI;AACF,QAAM,cAAc;GAClB,MAAM;GACN,KAAK,SAAS,QAAQ;GACtB,gBACE,oBAAoB,QAAQ,IAAI,0BAA0B,YAAY;GACzE,CAAC;EAIF,MAAM,kBAAkB,KAAK,KAAK,uBAAuB,eAAe;EACxE,MAAM,cAAc,KAAK,MAAM,aAAa,iBAAiB,QAAQ,CAAC;AAGtE,cAAY,OAAO;AACnB,gBAAc,iBAAiB,KAAK,UAAU,aAAa,MAAM,EAAE,CAAC;AAEpE,UAAQ,IACN,+CAA+C,wBAChD;UACM,OAAO;AACd,UAAQ,MAAM,6CAA6C,MAAM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as setupGlobals, i as update, n as use, o as init, r as useLocal, t as ph } from "./ph-
|
|
1
|
+
import { a as setupGlobals, i as update, n as use, o as init, r as useLocal, t as ph } from "./ph-CYuEOx4_.mjs";
|
|
2
2
|
import { writeCliDocsMarkdownFile } from "@powerhousedao/codegen/file-builders";
|
|
3
3
|
//#region src/generate-commands-docs.ts
|
|
4
4
|
const commands = [
|
|
@@ -27,7 +27,7 @@ const cliDescription = ph.description ?? "";
|
|
|
27
27
|
async function main() {
|
|
28
28
|
await writeCliDocsMarkdownFile({
|
|
29
29
|
filePath: "COMMANDS.md",
|
|
30
|
-
docsTitle: `PH-CMD CLI Commands (6.0.0-dev.
|
|
30
|
+
docsTitle: `PH-CMD CLI Commands (6.0.0-dev.229)`,
|
|
31
31
|
docsIntroduction: "This document provides detailed information about the available commands in the PH-CMD CLI. The CLI is published as `ph-cmd` and is invoked with the `ph` command.",
|
|
32
32
|
cliDescription,
|
|
33
33
|
entries: commands
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { debugArgs, initArgs, phCliHelpCommands } from "@powerhousedao/shared/clis/args";
|
|
2
2
|
import { boolean, command, flag, oneOf, option, optional, positional, string, subcommands } from "cmd-ts";
|
|
3
3
|
import { execSync } from "node:child_process";
|
|
4
|
-
import { resolveCommand } from "package-manager-detector";
|
|
5
|
-
import { clean, coerce, valid } from "semver";
|
|
6
|
-
import { createProject } from "@powerhousedao/codegen";
|
|
7
|
-
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
8
|
-
import path from "path";
|
|
9
4
|
import { ALL_POWERHOUSE_DEPENDENCIES } from "@powerhousedao/shared/constants";
|
|
10
|
-
import chalk from "chalk";
|
|
11
|
-
import { detect } from "package-manager-detector/detect";
|
|
12
|
-
import { readPackage } from "read-pkg";
|
|
13
|
-
import { writePackage } from "write-package";
|
|
14
5
|
//#region src/commands/init.ts
|
|
15
6
|
const PH_CLI_PACKAGE = "@powerhousedao/ph-cli";
|
|
16
7
|
const MIN_PH_CLI_MAJOR = 6;
|
|
@@ -25,6 +16,7 @@ const init = command({
|
|
|
25
16
|
args: initArgs,
|
|
26
17
|
handler: async (args) => {
|
|
27
18
|
if (args.debug) console.log({ args });
|
|
19
|
+
const { fetchNpmVersionFromRegistryForTag, handleMutuallyExclusiveOptions, parsePackageManager, parseTag } = await import("@powerhousedao/shared/clis");
|
|
28
20
|
handleMutuallyExclusiveOptions({
|
|
29
21
|
tag: args.tag,
|
|
30
22
|
version: args.version,
|
|
@@ -48,13 +40,16 @@ const init = command({
|
|
|
48
40
|
} catch (err) {
|
|
49
41
|
if (args.debug) console.error(">>> ph-cli version resolution skipped:", err);
|
|
50
42
|
}
|
|
43
|
+
const { coerce } = await import("semver");
|
|
51
44
|
const parsed = resolvedVersion ? coerce(resolvedVersion) : null;
|
|
52
45
|
if (parsed && parsed.major < MIN_PH_CLI_MAJOR) {
|
|
53
46
|
console.error(`${PH_CLI_PACKAGE}@${phCliVersionOrTag} resolves to ${resolvedVersion}, which doesn't support 'init' (requires >= ${MIN_PH_CLI_MAJOR}.0.0).\nTry: ph init --dev <args> or ph init --version <${MIN_PH_CLI_MAJOR}.x.x> <args>`);
|
|
54
47
|
process.exit(1);
|
|
55
48
|
}
|
|
49
|
+
const phCliPackage = `${PH_CLI_PACKAGE}@${resolvedVersion ?? phCliVersionOrTag}`;
|
|
50
|
+
const { resolveCommand } = await import("package-manager-detector");
|
|
56
51
|
const resolved = resolveCommand(pm, "execute", [
|
|
57
|
-
|
|
52
|
+
phCliPackage,
|
|
58
53
|
"init",
|
|
59
54
|
...forwardedArgs
|
|
60
55
|
]);
|
|
@@ -62,102 +57,17 @@ const init = command({
|
|
|
62
57
|
const { command: cmd, args: cmdArgs } = resolved;
|
|
63
58
|
const fullCmd = `${cmd} ${cmdArgs.join(" ")}`;
|
|
64
59
|
if (args.debug) console.log(">>> Delegating to ph-cli:", fullCmd);
|
|
65
|
-
|
|
60
|
+
try {
|
|
61
|
+
execSync(fullCmd, { stdio: "inherit" });
|
|
62
|
+
} catch (err) {
|
|
63
|
+
const e = err;
|
|
64
|
+
if (typeof e.status === "number" && !e.signal) process.exit(e.status);
|
|
65
|
+
throw err;
|
|
66
|
+
}
|
|
66
67
|
process.exit(0);
|
|
67
68
|
}
|
|
68
69
|
});
|
|
69
70
|
//#endregion
|
|
70
|
-
//#region src/utils/constants.ts
|
|
71
|
-
const PH_BIN_PATH = process.argv[1];
|
|
72
|
-
const PH_GLOBAL_PACKAGE_NAME = "ph-global";
|
|
73
|
-
const packageManagers = {
|
|
74
|
-
bun: {
|
|
75
|
-
installCommand: "bun add {{dependency}}",
|
|
76
|
-
execCommand: `bun ${PH_BIN} {{arguments}}`,
|
|
77
|
-
execScript: `bun {{arguments}}`,
|
|
78
|
-
lockfile: "bun.lock",
|
|
79
|
-
globalPathRegexp: /[\\/].bun[\\/]/,
|
|
80
|
-
updateCommand: "bun update {{dependency}}",
|
|
81
|
-
buildAffected: "bun run build:affected",
|
|
82
|
-
workspaceOption: "",
|
|
83
|
-
installDepsCommand: "bun install"
|
|
84
|
-
},
|
|
85
|
-
pnpm: {
|
|
86
|
-
installCommand: "pnpm add {{dependency}}",
|
|
87
|
-
execCommand: `pnpm exec ${PH_BIN} {{arguments}}`,
|
|
88
|
-
execScript: `pnpm {{arguments}}`,
|
|
89
|
-
lockfile: "pnpm-lock.yaml",
|
|
90
|
-
globalPathRegexp: /[\\/]pnpm[\\/]/,
|
|
91
|
-
updateCommand: "pnpm update {{dependency}}",
|
|
92
|
-
buildAffected: "pnpm run build:affected",
|
|
93
|
-
workspaceOption: "--workspace-root",
|
|
94
|
-
installDepsCommand: "pnpm install"
|
|
95
|
-
},
|
|
96
|
-
yarn: {
|
|
97
|
-
installCommand: "yarn add {{dependency}}",
|
|
98
|
-
execCommand: `yarn ${PH_BIN} {{arguments}}`,
|
|
99
|
-
execScript: `yarn {{arguments}}`,
|
|
100
|
-
lockfile: "yarn.lock",
|
|
101
|
-
globalPathRegexp: /[\\/]yarn[\\/]/,
|
|
102
|
-
updateCommand: "yarn upgrade {{dependency}}",
|
|
103
|
-
buildAffected: "yarn run build:affected",
|
|
104
|
-
workspaceOption: "-W",
|
|
105
|
-
installDepsCommand: "yarn install"
|
|
106
|
-
},
|
|
107
|
-
npm: {
|
|
108
|
-
installCommand: "npm install {{dependency}}",
|
|
109
|
-
execCommand: `npx ${PH_BIN} {{arguments}}`,
|
|
110
|
-
execScript: `npm run {{arguments}}`,
|
|
111
|
-
lockfile: "package-lock.json",
|
|
112
|
-
updateCommand: "npm update {{dependency}} --save",
|
|
113
|
-
buildAffected: "npm run build:affected",
|
|
114
|
-
workspaceOption: "",
|
|
115
|
-
installDepsCommand: "npm install"
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region src/utils/package-manager.ts
|
|
120
|
-
function getPackageManagerFromPath(dir) {
|
|
121
|
-
const lowerCasePath = dir.toLowerCase();
|
|
122
|
-
if (packageManagers.bun.globalPathRegexp.test(lowerCasePath)) return "bun";
|
|
123
|
-
else if (packageManagers.pnpm.globalPathRegexp.test(lowerCasePath)) return "pnpm";
|
|
124
|
-
else if (packageManagers.yarn.globalPathRegexp.test(lowerCasePath)) return "yarn";
|
|
125
|
-
return "npm";
|
|
126
|
-
}
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/utils/create-global-project.ts
|
|
129
|
-
const createGlobalProject = async (projectName, options = {}) => {
|
|
130
|
-
if (existsSync(POWERHOUSE_GLOBAL_DIR)) {
|
|
131
|
-
const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, "package.json");
|
|
132
|
-
if (existsSync(packageJsonPath)) try {
|
|
133
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
134
|
-
if (packageJson.name?.startsWith(".")) {
|
|
135
|
-
console.log("📦 Fixing invalid package name in global project...");
|
|
136
|
-
packageJson.name = PH_GLOBAL_PACKAGE_NAME;
|
|
137
|
-
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
138
|
-
}
|
|
139
|
-
} catch {}
|
|
140
|
-
console.log(`📦 Using global project: ${POWERHOUSE_GLOBAL_DIR}`);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
console.log("📦 Initializing global project...");
|
|
144
|
-
process.chdir(HOME_DIR);
|
|
145
|
-
try {
|
|
146
|
-
await createProject({
|
|
147
|
-
name: PH_GLOBAL_DIR_NAME,
|
|
148
|
-
tag: parseTag(options),
|
|
149
|
-
packageManager: parsePackageManager(options) ?? getPackageManagerFromPath(PH_BIN_PATH)
|
|
150
|
-
});
|
|
151
|
-
const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, "package.json");
|
|
152
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
153
|
-
packageJson.name = PH_GLOBAL_PACKAGE_NAME;
|
|
154
|
-
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
155
|
-
console.log(`🚀 Global project initialized successfully: ${POWERHOUSE_GLOBAL_DIR}`);
|
|
156
|
-
} catch (error) {
|
|
157
|
-
console.error("❌ Failed to initialize the global project", error);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
//#endregion
|
|
161
71
|
//#region src/commands/setup-globals.ts
|
|
162
72
|
const setupGlobals = command({
|
|
163
73
|
name: "setup-globals",
|
|
@@ -166,7 +76,9 @@ const setupGlobals = command({
|
|
|
166
76
|
handler: async (args) => {
|
|
167
77
|
const { namePositional, nameOption, debug, ...options } = args;
|
|
168
78
|
if (debug) console.log({ args });
|
|
169
|
-
|
|
79
|
+
const name = namePositional ?? nameOption;
|
|
80
|
+
const { createGlobalProject } = await import("./create-global-project-Cf8BOmqR.mjs");
|
|
81
|
+
await createGlobalProject(name, options);
|
|
170
82
|
process.exit(0);
|
|
171
83
|
}
|
|
172
84
|
});
|
|
@@ -188,6 +100,12 @@ const update = command({
|
|
|
188
100
|
const { skipInstall, debug } = args;
|
|
189
101
|
if (debug) console.log({ args });
|
|
190
102
|
console.log(`\n▶️ Updating Powerhouse dependencies...\n`);
|
|
103
|
+
const [{ default: chalk }, { readPackage }, { writePackage }, { getTagFromVersion, logVersionUpdate, parsePackageVersion, runCmd }] = await Promise.all([
|
|
104
|
+
import("chalk"),
|
|
105
|
+
import("read-pkg"),
|
|
106
|
+
import("write-package"),
|
|
107
|
+
import("@powerhousedao/shared/clis")
|
|
108
|
+
]);
|
|
191
109
|
const packageJson = await readPackage();
|
|
192
110
|
if (packageJson.dependencies) {
|
|
193
111
|
for (const [name, version] of Object.entries(packageJson.dependencies)) if (version && ALL_POWERHOUSE_DEPENDENCIES.includes(name)) {
|
|
@@ -248,6 +166,7 @@ const update = command({
|
|
|
248
166
|
await writePackage(packageJson);
|
|
249
167
|
console.log(chalk.green(`\n✅ Project updated successfully\n`));
|
|
250
168
|
if (skipInstall) return;
|
|
169
|
+
const { detect } = await import("package-manager-detector/detect");
|
|
251
170
|
const packageManager = await detect();
|
|
252
171
|
if (!packageManager) throw new Error(`❌ Failed to detect your package manager. Run install manually.`);
|
|
253
172
|
console.log(`▶️ Installing updated dependencies with \`${packageManager.agent}\`\n`);
|
|
@@ -285,6 +204,7 @@ const useLocal = command({
|
|
|
285
204
|
if (debug) console.log({ args });
|
|
286
205
|
const monorepoPath = monorepoPathPositional ?? monorepoPathOption;
|
|
287
206
|
if (!monorepoPath) throw new Error("❌ Please provide the path to your local powerhouse monorepo.");
|
|
207
|
+
const { runUseLocal } = await import("@powerhousedao/shared/clis");
|
|
288
208
|
await runUseLocal(monorepoPath, skipInstall);
|
|
289
209
|
process.exit(0);
|
|
290
210
|
}
|
|
@@ -332,11 +252,18 @@ const use = command({
|
|
|
332
252
|
const { tagPositional, tagOption, version, skipInstall, debug } = args;
|
|
333
253
|
if (debug) console.log({ args });
|
|
334
254
|
const tag = tagPositional ?? tagOption;
|
|
255
|
+
const { handleMutuallyExclusiveOptions, logVersionUpdate, parsePackageVersion, runCmd } = await import("@powerhousedao/shared/clis");
|
|
335
256
|
handleMutuallyExclusiveOptions({
|
|
336
257
|
tag,
|
|
337
258
|
version
|
|
338
259
|
}, "versioning strategy");
|
|
339
260
|
if (!tag && !version) throw new Error("Please specify either a release tag or a version to use.");
|
|
261
|
+
const [{ default: chalk }, { readPackage }, { writePackage }, { clean, valid }] = await Promise.all([
|
|
262
|
+
import("chalk"),
|
|
263
|
+
import("read-pkg"),
|
|
264
|
+
import("write-package"),
|
|
265
|
+
import("semver")
|
|
266
|
+
]);
|
|
340
267
|
if (version && !valid(clean(version))) throw new Error(`❌ Invalid version: ${chalk.bold(version)}`);
|
|
341
268
|
console.log(`▶️ Updating project to use ${chalk.bold(version ?? tag)}...\n`);
|
|
342
269
|
const packageJson = await readPackage();
|
|
@@ -403,6 +330,7 @@ const use = command({
|
|
|
403
330
|
await writePackage(packageJson);
|
|
404
331
|
console.log(chalk.green(`\n✅ Project updated to use ${chalk.bold(version ?? tag)}\n`));
|
|
405
332
|
if (!skipInstall) {
|
|
333
|
+
const { detect } = await import("package-manager-detector/detect");
|
|
406
334
|
const packageManager = await detect();
|
|
407
335
|
if (!packageManager) throw new Error(`❌ Failed to detect your package manager. Run install manually.`);
|
|
408
336
|
console.log(`▶️ Installing updated dependencies with \`${packageManager.agent}\`\n`);
|
|
@@ -411,9 +339,11 @@ const use = command({
|
|
|
411
339
|
process.exit(0);
|
|
412
340
|
}
|
|
413
341
|
});
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/commands/ph.ts
|
|
414
344
|
const ph = subcommands({
|
|
415
345
|
name: "ph",
|
|
416
|
-
version:
|
|
346
|
+
version: "6.0.0-dev.229",
|
|
417
347
|
description: "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.",
|
|
418
348
|
cmds: {
|
|
419
349
|
init,
|
|
@@ -427,4 +357,4 @@ const ph = subcommands({
|
|
|
427
357
|
//#endregion
|
|
428
358
|
export { setupGlobals as a, update as i, use as n, init as o, useLocal as r, ph as t };
|
|
429
359
|
|
|
430
|
-
//# sourceMappingURL=ph-
|
|
360
|
+
//# sourceMappingURL=ph-CYuEOx4_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ph-CYuEOx4_.mjs","names":[],"sources":["../src/commands/init.ts","../src/commands/setup-globals.ts","../src/commands/update.ts","../src/commands/use-local.ts","../src/commands/use.ts","../src/commands/ph.ts"],"sourcesContent":["import { initArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\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 * 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\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 },\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 const forwardedArgs = 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 { 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 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 process.exit(0);\n },\n});\n","import { initArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const setupGlobals = command({\n name: \"setup-globals\",\n description: \"Initialize a new global project\",\n args: initArgs,\n handler: async (args) => {\n const { namePositional, nameOption, debug, ...options } = args;\n if (debug) {\n console.log({ args });\n }\n const name = namePositional ?? nameOption;\n const { createGlobalProject } =\n await import(\"../utils/create-global-project.js\");\n await createGlobalProject(name, options);\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 to their latest tagged version\",\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 ...debugArgs,\n },\n handler: async (args) => {\n const { skipInstall, 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 ] = await Promise.all([\n import(\"chalk\"),\n import(\"read-pkg\"),\n import(\"write-package\"),\n import(\"@powerhousedao/shared/clis\"),\n ]);\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 if (skipInstall) return;\n\n const { detect } = await import(\"package-manager-detector/detect\");\n const packageManager = await detect();\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\"])),\n displayName: \"tag\",\n description: `Specify the release tag to use for your project. Can be one of: \"latest\", \"staging\", or \"dev\".`,\n }),\n tagOption: option({\n type: optional(oneOf([\"latest\", \"staging\", \"dev\"])),\n long: \"tag\",\n short: \"t\",\n description: `Specify the release tag to use for your project. Can be one of: \"latest\", \"staging\", or \"dev\".`,\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 { init } from \"./init.js\";\nimport { setupGlobals } from \"./setup-globals.js\";\nimport { update } from \"./update.js\";\nimport { useLocal } from \"./use-local.js\";\nimport { use } from \"./use.js\";\n\ndeclare const CLI_VERSION: string;\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: CLI_VERSION,\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 \"setup-globals\": setupGlobals,\n \"use-local\": useLocal,\n ...phCliHelpCommands,\n },\n});\n"],"mappings":";;;;;AAIA,MAAM,iBAAiB;AAKvB,MAAM,mBAAmB;;;;;;AAOzB,MAAa,OAAO,QAAQ;CAC1B,MAAM;CACN,aAAa;CACb,MAAM;CACN,SAAS,OAAO,SAAS;AACvB,MAAI,KAAK,MACP,SAAQ,IAAI,EAAE,MAAM,CAAC;EAGvB,MAAM,EACJ,mCACA,gCACA,qBACA,aACE,MAAM,OAAO;AAEjB,iCACE;GACE,KAAK,KAAK;GACV,SAAS,KAAK;GACd,KAAK,KAAK;GACV,SAAS,KAAK;GACf,EACD,sBACD;AAED,iCACE;GACE,KAAK,KAAK;GACV,MAAM,KAAK;GACX,MAAM,KAAK;GACX,KAAK,KAAK;GACV,gBAAgB,KAAK;GACtB,EACD,kBACD;EAED,MAAM,MAAM,SAAS,KAAK;EAC1B,MAAM,oBAAoB,KAAK,WAAW;EAC1C,MAAM,KAAK,oBAAoB,KAAK,IAAI;EACxC,MAAM,gBAAgB,QAAQ,KAAK,MAAM,EAAE;EAK3C,IAAI,kBAAkB,KAAK;AAC3B,MAAI;AACF,OAAI,CAAC,gBACH,mBAAkB,MAAM,kCACtB,gBACA,IACD;WAEI,KAAK;AAIZ,OAAI,KAAK,MACP,SAAQ,MAAM,0CAA0C,IAAI;;EAGhE,MAAM,EAAE,WAAW,MAAM,OAAO;EAChC,MAAM,SAAS,kBAAkB,OAAO,gBAAgB,GAAG;AAC3D,MAAI,UAAU,OAAO,QAAQ,kBAAkB;AAG7C,WAAQ,MACN,GAAG,eAAe,GAAG,kBAAkB,eAAe,gBAAgB,8CACvB,iBAAiB,+DACN,iBAAiB,cAC5E;AACD,WAAQ,KAAK,EAAE;;EAGjB,MAAM,eAAe,GAAG,eAAe,GAAG,mBAAmB;EAC7D,MAAM,EAAE,mBAAmB,MAAM,OAAO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Y,gBAAgB,QAAQ;AACpC,qBAAiB;KACf;KACA,SAAS;KACT;KACD,CAAC;;;AAKR,MAAI,YAAY;QACT,MAAM,CAAC,MAAM,oBAAoB,OAAO,QAC3C,YAAY,qBACb,CACC,KAAI,mBAAmB,4BAA4B,SAAS,KAAK,EAAE;IACjE,MAAM,aAAa,MAAM,oBAAoB;KAAE;KAAM;KAAK;KAAS,CAAC;AACpE,gBAAY,qBAAqB,QAAQ;AACzC,qBAAiB;KACf;KACA,SAAS;KACT;KACD,CAAC;;;AAKR,MAAI,YAAY;QACT,MAAM,CAAC,MAAM,oBAAoB,OAAO,QAC3C,YAAY,iBACb,CACC,KAAI,mBAAmB,4BAA4B,SAAS,KAAK,EAAE;IACjE,MAAM,aAAa,MAAM,oBAAoB;KAAE;KAAM;KAAK;KAAS,CAAC;AACpE,gBAAY,iBAAiB,QAAQ;AACrC,qBAAiB;KACf;KACA,SAAS;KACT;KACD,CAAC;;;AAKR,QAAM,aAAa,YAAY;AAE/B,UAAQ,IACN,MAAM,MACJ,8BAA8B,MAAM,KAAK,WAAW,IAAI,CAAC,IAC1D,CACF;AAED,MAAI,CAAC,aAAa;GAChB,MAAM,EAAE,WAAW,MAAM,OAAO;GAChC,MAAM,iBAAiB,MAAM,QAAQ;AACrC,OAAI,CAAC,eACH,OAAM,IAAI,MACR,iEACD;AAEH,WAAQ,IACN,6CAA6C,eAAe,MAAM,MACnE;AACD,UAAO,GAAG,eAAe,MAAM,UAAU;;AAG3C,UAAQ,KAAK,EAAE;;CAElB,CAAC;;;ACjKF,MAAa,KAAK,YAAY;CAC5B,MAAM;CACN,SAAA;CACA,aACE;CACF,MAAM;EACJ;EACA;EACA;EACA,iBAAiB;EACjB,aAAa;EACb,GAAG;EACJ;CACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getPowerhouseProjectInfo } from "@powerhousedao/shared/clis";
|
|
2
1
|
import { execSync } from "node:child_process";
|
|
2
|
+
import { getPowerhouseProjectInfo } from "@powerhousedao/shared/clis";
|
|
3
3
|
import { resolveCommand } from "package-manager-detector";
|
|
4
4
|
//#region src/ph-cli.ts
|
|
5
5
|
async function executePhCliCommand(phCliCommand) {
|
|
@@ -13,12 +13,19 @@ async function executePhCliCommand(phCliCommand) {
|
|
|
13
13
|
]);
|
|
14
14
|
if (!resolveExecuteLocalCommandResult) throw new Error(`Command ${phCliCommand} is not executable by package manager ${packageManager}. Either install "@powerhousedao/ph-cli" in your local package, or run \`ph setup-globals\` to globally install the "@powerhousedao/ph-cli" package.`);
|
|
15
15
|
const { command, args } = resolveExecuteLocalCommandResult;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const cmd = `${command} ${args.join(" ")}`;
|
|
17
|
+
try {
|
|
18
|
+
execSync(cmd, {
|
|
19
|
+
stdio: "inherit",
|
|
20
|
+
cwd: projectPath
|
|
21
|
+
});
|
|
22
|
+
} catch (err) {
|
|
23
|
+
const e = err;
|
|
24
|
+
if (typeof e.status === "number" && !e.signal) process.exit(e.status);
|
|
25
|
+
throw err;
|
|
26
|
+
}
|
|
20
27
|
}
|
|
21
28
|
//#endregion
|
|
22
29
|
export { executePhCliCommand };
|
|
23
30
|
|
|
24
|
-
//# sourceMappingURL=ph-cli-
|
|
31
|
+
//# sourceMappingURL=ph-cli-bUpVoHgn.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ph-cli-
|
|
1
|
+
{"version":3,"file":"ph-cli-bUpVoHgn.mjs","names":[],"sources":["../src/ph-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { getPowerhouseProjectInfo } from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"node:child_process\";\nimport { resolveCommand } from \"package-manager-detector\";\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 if (!projectPath) {\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 const resolveExecuteLocalCommandResult = resolveCommand(\n packageManager,\n \"execute-local\",\n [\"ph-cli\", phCliCommand, ...forwardedArgs],\n );\n if (!resolveExecuteLocalCommandResult) {\n throw new Error(\n `Command ${phCliCommand} is not executable by package manager ${packageManager}. Either install \"@powerhousedao/ph-cli\" in your local package, or run \\`ph setup-globals\\` to globally install the \"@powerhousedao/ph-cli\" package.`,\n );\n }\n const { command, args } = resolveExecuteLocalCommandResult;\n const cmd = `${command} ${args.join(\" \")}`;\n try {\n execSync(cmd, { stdio: \"inherit\", cwd: projectPath });\n } catch (err) {\n // propagate normal non-zero exits but throw on abnormal exits to ensure the error is reported\n const e = err as { status?: number | null; signal?: NodeJS.Signals | null };\n if (typeof e.status === \"number\" && !e.signal) {\n process.exit(e.status);\n }\n throw err;\n }\n}\n"],"mappings":";;;;AAKA,eAAsB,oBAAoB,cAAsB;CAC9D,MAAM,gBAAgB,QAAQ,KAAK,MAAM,EAAE;CAC3C,MAAM,EAAE,aAAa,mBAAmB,MAAM,yBAC5C,KAAA,GACA,EAAE,QAAQ,MAAM,CACjB;AACD,KAAI,CAAC,YACH,OAAM,IAAI,MACR,0DAA0D,aAAa,yGACxE;CAEH,MAAM,mCAAmC,eACvC,gBACA,iBACA;EAAC;EAAU;EAAc,GAAG;EAAc,CAC3C;AACD,KAAI,CAAC,iCACH,OAAM,IAAI,MACR,WAAW,aAAa,wCAAwC,eAAe,sJAChF;CAEH,MAAM,EAAE,SAAS,SAAS;CAC1B,MAAM,MAAM,GAAG,QAAQ,GAAG,KAAK,KAAK,IAAI;AACxC,KAAI;AACF,WAAS,KAAK;GAAE,OAAO;GAAW,KAAK;GAAa,CAAC;UAC9C,KAAK;EAEZ,MAAM,IAAI;AACV,MAAI,OAAO,EAAE,WAAW,YAAY,CAAC,EAAE,OACrC,SAAQ,KAAK,EAAE,OAAO;AAExB,QAAM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ph } from "./ph-
|
|
1
|
+
import { t as ph } from "./ph-CYuEOx4_.mjs";
|
|
2
2
|
import { run as run$1 } from "cmd-ts";
|
|
3
3
|
//#region src/run.ts
|
|
4
4
|
async function run(args) {
|
|
@@ -7,4 +7,4 @@ async function run(args) {
|
|
|
7
7
|
//#endregion
|
|
8
8
|
export { run };
|
|
9
9
|
|
|
10
|
-
//# sourceMappingURL=run-
|
|
10
|
+
//# sourceMappingURL=run-5mQ_EG2X.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-5mQ_EG2X.mjs","names":["runCmdTs"],"sources":["../src/run.ts"],"sourcesContent":["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"],"mappings":";;;AAGA,eAAsB,IAAI,MAAgB;AACxC,QAAO,MAAMA,MAAS,IAAI,KAAK"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ph-cmd",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.229",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"read-pkg": "10.1.0",
|
|
30
30
|
"write-package": "7.2.0",
|
|
31
31
|
"semver": "7.7.4",
|
|
32
|
-
"@powerhousedao/codegen": "6.0.0-dev.
|
|
33
|
-
"@powerhousedao/common": "6.0.0-dev.
|
|
34
|
-
"@powerhousedao/shared": "6.0.0-dev.
|
|
32
|
+
"@powerhousedao/codegen": "6.0.0-dev.229",
|
|
33
|
+
"@powerhousedao/common": "6.0.0-dev.229",
|
|
34
|
+
"@powerhousedao/shared": "6.0.0-dev.229"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"tsdown": "0.21.1",
|
package/dist/ph-Bi7CvLUU.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ph-Bi7CvLUU.mjs","names":[],"sources":["../src/commands/init.ts","../src/utils/constants.ts","../src/utils/package-manager.ts","../src/utils/create-global-project.ts","../src/commands/setup-globals.ts","../src/commands/update.ts","../src/commands/use-local.ts","../src/commands/use.ts","../src/commands/ph.ts"],"sourcesContent":["import {\n fetchNpmVersionFromRegistryForTag,\n handleMutuallyExclusiveOptions,\n initArgs,\n parsePackageManager,\n parseTag,\n} from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\nimport { execSync } from \"node:child_process\";\nimport { resolveCommand } from \"package-manager-detector\";\nimport { coerce } from \"semver\";\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 * 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\n handleMutuallyExclusiveOptions(\n {\n tag: args.tag,\n version: args.version,\n dev: args.dev,\n staging: args.staging,\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 const forwardedArgs = 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 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 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 { 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 execSync(fullCmd, { stdio: \"inherit\" });\n process.exit(0);\n },\n});\n","import { PH_BIN } from \"@powerhousedao/shared/clis\";\n\nexport const PH_BIN_PATH = process.argv[1];\nexport const PH_CLI_COMMANDS = [\n \"init\",\n \"dev\",\n \"connect\",\n \"generate\",\n \"reactor\",\n \"switchboard\",\n \"help\",\n \"install\",\n \"add\",\n \"i\",\n \"remove\",\n \"uninstall\",\n \"service\",\n \"list\",\n \"inspect\",\n \"version\",\n \"login\",\n \"logout\",\n];\nexport const PH_GLOBAL_PACKAGE_NAME = \"ph-global\";\n\nexport const packageManagers = {\n bun: {\n installCommand: \"bun add {{dependency}}\",\n execCommand: `bun ${PH_BIN} {{arguments}}`,\n execScript: `bun {{arguments}}`,\n lockfile: \"bun.lock\",\n globalPathRegexp: /[\\\\/].bun[\\\\/]/,\n updateCommand: \"bun update {{dependency}}\",\n buildAffected: \"bun run build:affected\",\n workspaceOption: \"\",\n installDepsCommand: \"bun install\",\n },\n pnpm: {\n installCommand: \"pnpm add {{dependency}}\",\n execCommand: `pnpm exec ${PH_BIN} {{arguments}}`,\n execScript: `pnpm {{arguments}}`,\n lockfile: \"pnpm-lock.yaml\",\n globalPathRegexp: /[\\\\/]pnpm[\\\\/]/,\n updateCommand: \"pnpm update {{dependency}}\",\n buildAffected: \"pnpm run build:affected\",\n workspaceOption: \"--workspace-root\",\n installDepsCommand: \"pnpm install\",\n },\n yarn: {\n installCommand: \"yarn add {{dependency}}\",\n execCommand: `yarn ${PH_BIN} {{arguments}}`,\n execScript: `yarn {{arguments}}`,\n lockfile: \"yarn.lock\",\n globalPathRegexp: /[\\\\/]yarn[\\\\/]/,\n updateCommand: \"yarn upgrade {{dependency}}\",\n buildAffected: \"yarn run build:affected\",\n workspaceOption: \"-W\",\n installDepsCommand: \"yarn install\",\n },\n npm: {\n installCommand: \"npm install {{dependency}}\",\n execCommand: `npx ${PH_BIN} {{arguments}}`,\n execScript: `npm run {{arguments}}`,\n lockfile: \"package-lock.json\",\n updateCommand: \"npm update {{dependency}} --save\",\n buildAffected: \"npm run build:affected\",\n workspaceOption: \"\",\n installDepsCommand: \"npm install\",\n },\n} as const;\n","import {\n POWERHOUSE_CONFIG_FILE,\n POWERHOUSE_GLOBAL_DIR,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport path, { dirname } from \"node:path\";\nimport { packageManagers } from \"./constants.js\";\nimport { createGlobalProject } from \"./create-global-project.js\";\nimport type { PackageManager, PathValidation, ProjectInfo } from \"./types.js\";\n\nexport function defaultPathValidation() {\n return true;\n}\n\nexport function isPowerhouseProject(dir: string) {\n const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);\n\n return existsSync(powerhouseConfigPath);\n}\n\nexport function findNodeProjectRoot(\n dir: string,\n pathValidation: PathValidation = defaultPathValidation,\n) {\n const packageJsonPath = path.join(dir, \"package.json\");\n\n if (existsSync(packageJsonPath) && pathValidation(dir)) {\n return dir;\n }\n\n const parentDir = dirname(dir);\n\n if (parentDir === dir) {\n return null;\n }\n\n return findNodeProjectRoot(parentDir, pathValidation);\n}\n\nexport function getPackageManagerFromPath(dir: string): PackageManager {\n const lowerCasePath = dir.toLowerCase();\n\n if (packageManagers.bun.globalPathRegexp.test(lowerCasePath)) {\n return \"bun\";\n } else if (packageManagers.pnpm.globalPathRegexp.test(lowerCasePath)) {\n return \"pnpm\";\n } else if (packageManagers.yarn.globalPathRegexp.test(lowerCasePath)) {\n return \"yarn\";\n }\n\n return \"npm\";\n}\n\nexport function getPackageManagerFromLockfile(dir: string): PackageManager {\n if (existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {\n return \"pnpm\";\n } else if (existsSync(path.join(dir, packageManagers.yarn.lockfile))) {\n return \"yarn\";\n } else if (existsSync(path.join(dir, packageManagers.bun.lockfile))) {\n return \"bun\";\n }\n\n return \"npm\";\n}\n\nexport async function getProjectInfo(\n debug?: boolean,\n generateGlobalProject = true,\n): Promise<ProjectInfo> {\n const currentPath = process.cwd();\n\n if (debug) {\n console.log(\">>> currentPath:\", currentPath);\n }\n\n const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);\n\n if (!projectPath) {\n let available = existsSync(POWERHOUSE_GLOBAL_DIR);\n\n if (generateGlobalProject) {\n await createGlobalProject();\n available = true;\n }\n\n return {\n available,\n isGlobal: true,\n path: POWERHOUSE_GLOBAL_DIR,\n };\n }\n\n return {\n isGlobal: false,\n available: true,\n path: projectPath,\n };\n}\n\nexport function forwardPHCommand(\n packageManager: PackageManager,\n projectPath: string,\n args: string,\n debug?: boolean,\n captureOutput = false,\n) {\n const manager = packageManagers[packageManager];\n const command = manager.execCommand;\n const execCommand = command.replace(\"{{arguments}}\", args);\n\n const commandOptions = { cwd: projectPath };\n\n if (debug) {\n console.log(\">>> execCommand:\", execCommand);\n console.log(\">>> commandOptions:\", commandOptions);\n console.log(\">>> projectPath:\", projectPath);\n console.log(\">>> packageManager:\", packageManager);\n }\n\n if (captureOutput) {\n // Capture output and return it\n try {\n return execSync(execCommand, {\n stdio: \"pipe\",\n encoding: \"utf8\",\n ...commandOptions,\n });\n } catch (error) {\n throw new Error(\n `Failed to execute command: ${execCommand}\\nError: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n } else {\n // Original behavior - pipe directly to stdout/stderr\n execSync(execCommand, {\n stdio: \"inherit\",\n ...commandOptions,\n });\n return \"\";\n }\n}\n\n/**\n * Recursively searches for a specific file by traversing up the directory tree.\n * Starting from the given path, it checks each parent directory until it finds\n * the target file or reaches the root directory.\n *\n * @param startPath - The absolute path of the directory to start searching from\n * @param targetFile - The name of the file to search for (e.g., 'package.json', 'pnpm-workspace.yaml')\n * @returns The absolute path of the directory containing the target file, or null if not found\n *\n * @example\n * // Find the workspace root directory\n * const workspaceRoot = findContainerDirectory('/path/to/project/src', 'pnpm-workspace.yaml');\n *\n * // Find the nearest package.json\n * const packageDir = findContainerDirectory('/path/to/project/src/components', 'package.json');\n */\nexport const findContainerDirectory = (\n startPath: string,\n targetFile: string,\n): string | null => {\n const filePath = path.join(startPath, targetFile);\n\n if (existsSync(filePath)) {\n return startPath;\n }\n\n const parentDir = path.dirname(startPath);\n\n //reached the root directory and haven't found the file\n if (parentDir === startPath) {\n return null;\n }\n\n return findContainerDirectory(parentDir, targetFile);\n};\n","import { createProject } from \"@powerhousedao/codegen\";\nimport {\n HOME_DIR,\n PH_GLOBAL_DIR_NAME,\n POWERHOUSE_GLOBAL_DIR,\n parsePackageManager,\n parseTag,\n} from \"@powerhousedao/shared/clis\";\nimport { existsSync, readFileSync, writeFileSync } from \"fs\";\nimport path from \"path\";\nimport { PH_BIN_PATH, PH_GLOBAL_PACKAGE_NAME } from \"./constants.js\";\nimport { getPackageManagerFromPath } from \"./package-manager.js\";\nimport type { GlobalProjectOptions } from \"./types.js\";\n\nexport const createGlobalProject = async (\n projectName?: string,\n options: GlobalProjectOptions = {},\n) => {\n // check if the global project already exists\n const globalProjectExists = existsSync(POWERHOUSE_GLOBAL_DIR);\n\n if (globalProjectExists) {\n // Fix existing installations with invalid \".ph\" package name\n const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, \"package.json\");\n if (existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(\n readFileSync(packageJsonPath, \"utf-8\"),\n ) as { name?: string };\n if (packageJson.name?.startsWith(\".\")) {\n console.log(\"📦 Fixing invalid package name in global project...\");\n packageJson.name = PH_GLOBAL_PACKAGE_NAME;\n writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n }\n } catch {\n // Ignore errors reading/writing package.json\n }\n }\n console.log(`📦 Using global project: ${POWERHOUSE_GLOBAL_DIR}`);\n return;\n }\n\n console.log(\"📦 Initializing global project...\");\n process.chdir(HOME_DIR);\n\n try {\n await createProject({\n name: PH_GLOBAL_DIR_NAME,\n tag: parseTag(options),\n packageManager:\n parsePackageManager(options) ?? getPackageManagerFromPath(PH_BIN_PATH),\n });\n\n // Fix the package.json name - \".ph\" is invalid for npm/vite\n // The directory name can be \".ph\" but the package name must be valid\n const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, \"package.json\");\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n name?: string;\n };\n packageJson.name = PH_GLOBAL_PACKAGE_NAME;\n writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n\n console.log(\n `🚀 Global project initialized successfully: ${POWERHOUSE_GLOBAL_DIR}`,\n );\n } catch (error) {\n console.error(\"❌ Failed to initialize the global project\", error);\n }\n};\n","import { initArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\nimport { createGlobalProject } from \"../utils/create-global-project.js\";\n\nexport const setupGlobals = command({\n name: \"setup-globals\",\n description: \"Initialize a new global project\",\n args: initArgs,\n handler: async (args) => {\n const { namePositional, nameOption, debug, ...options } = args;\n if (debug) {\n console.log({ args });\n }\n const name = namePositional ?? nameOption;\n await createGlobalProject(name, options);\n process.exit(0);\n },\n});\n","import {\n debugArgs,\n getTagFromVersion,\n logVersionUpdate,\n parsePackageVersion,\n runCmd,\n} from \"@powerhousedao/shared/clis\";\nimport { ALL_POWERHOUSE_DEPENDENCIES } from \"@powerhousedao/shared/constants\";\nimport chalk from \"chalk\";\nimport { boolean, command, flag, optional } from \"cmd-ts\";\nimport { detect } from \"package-manager-detector/detect\";\nimport { readPackage } from \"read-pkg\";\nimport { writePackage } from \"write-package\";\n\nexport const update = command({\n name: \"update\",\n description:\n \"Update your powerhouse dependencies to their latest tagged version\",\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 ...debugArgs,\n },\n handler: async (args) => {\n const { skipInstall, debug } = args;\n if (debug) {\n console.log({ args });\n }\n console.log(`\\n▶️ Updating Powerhouse dependencies...\\n`);\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 if (skipInstall) return;\n\n const packageManager = await detect();\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, runUseLocal } from \"@powerhousedao/shared/clis\";\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 await runUseLocal(monorepoPath, skipInstall);\n process.exit(0);\n },\n});\n","import {\n debugArgs,\n handleMutuallyExclusiveOptions,\n logVersionUpdate,\n parsePackageVersion,\n runCmd,\n} from \"@powerhousedao/shared/clis\";\nimport { ALL_POWERHOUSE_DEPENDENCIES } from \"@powerhousedao/shared/constants\";\nimport chalk from \"chalk\";\nimport {\n boolean,\n command,\n flag,\n oneOf,\n option,\n optional,\n positional,\n run,\n string,\n} from \"cmd-ts\";\nimport { detect } from \"package-manager-detector/detect\";\nimport { readPackage } from \"read-pkg\";\nimport { clean, valid } from \"semver\";\nimport { writePackage } from \"write-package\";\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\"])),\n displayName: \"tag\",\n description: `Specify the release tag to use for your project. Can be one of: \"latest\", \"staging\", or \"dev\".`,\n }),\n tagOption: option({\n type: optional(oneOf([\"latest\", \"staging\", \"dev\"])),\n long: \"tag\",\n short: \"t\",\n description: `Specify the release tag to use for your project. Can be one of: \"latest\", \"staging\", or \"dev\".`,\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 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 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 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 {\n getPhCmdVersionInfo,\n phCliHelpCommands,\n} from \"@powerhousedao/shared/clis\";\nimport { subcommands } from \"cmd-ts\";\nimport { init } from \"./init.js\";\nimport { setupGlobals } from \"./setup-globals.js\";\nimport { update } from \"./update.js\";\nimport { useLocal } from \"./use-local.js\";\nimport { use } from \"./use.js\";\n\ndeclare const CLI_VERSION: string;\nconst phCmdVersionInfo = await getPhCmdVersionInfo(CLI_VERSION);\nexport const ph = subcommands({\n name: \"ph\",\n version: phCmdVersionInfo,\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 \"setup-globals\": setupGlobals,\n \"use-local\": useLocal,\n ...phCliHelpCommands,\n },\n});\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAM,iBAAiB;AAKvB,MAAM,mBAAmB;;;;;;AAOzB,MAAa,OAAO,QAAQ;CAC1B,MAAM;CACN,aAAa;CACb,MAAM;CACN,SAAS,OAAO,SAAS;AACvB,MAAI,KAAK,MACP,SAAQ,IAAI,EAAE,MAAM,CAAC;AAGvB,iCACE;GACE,KAAK,KAAK;GACV,SAAS,KAAK;GACd,KAAK,KAAK;GACV,SAAS,KAAK;GACf,EACD,sBACD;AAED,iCACE;GACE,KAAK,KAAK;GACV,MAAM,KAAK;GACX,MAAM,KAAK;GACX,KAAK,KAAK;GACV,gBAAgB,KAAK;GACtB,EACD,kBACD;EA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