@powerhousedao/ph-cli 0.33.2-dev.0 → 0.34.2-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/package.json +51 -0
  2. package/dist/src/cli.d.ts +3 -0
  3. package/dist/src/cli.d.ts.map +1 -0
  4. package/dist/src/cli.js +10 -0
  5. package/dist/src/commands/connect.d.ts +6 -0
  6. package/dist/src/commands/connect.d.ts.map +1 -0
  7. package/dist/src/commands/connect.js +44 -0
  8. package/dist/src/commands/dev.d.ts +14 -0
  9. package/dist/src/commands/dev.d.ts.map +1 -0
  10. package/dist/src/commands/dev.js +88 -0
  11. package/dist/src/commands/generate.d.ts +21 -0
  12. package/dist/src/commands/generate.d.ts.map +1 -0
  13. package/dist/src/commands/generate.js +74 -0
  14. package/dist/src/commands/help.d.ts +3 -0
  15. package/dist/src/commands/help.d.ts.map +1 -0
  16. package/dist/src/commands/help.js +8 -0
  17. package/dist/src/commands/index.d.ts +14 -0
  18. package/dist/src/commands/index.d.ts.map +1 -0
  19. package/dist/src/commands/index.js +34 -0
  20. package/dist/src/commands/inspect.d.ts +10 -0
  21. package/dist/src/commands/inspect.d.ts.map +1 -0
  22. package/dist/src/commands/inspect.js +57 -0
  23. package/dist/src/commands/install.d.ts +15 -0
  24. package/dist/src/commands/install.d.ts.map +1 -0
  25. package/dist/src/commands/install.js +80 -0
  26. package/dist/src/commands/list.d.ts +9 -0
  27. package/dist/src/commands/list.d.ts.map +1 -0
  28. package/dist/src/commands/list.js +33 -0
  29. package/dist/src/commands/service.d.ts +5 -0
  30. package/dist/src/commands/service.d.ts.map +1 -0
  31. package/dist/src/commands/service.js +141 -0
  32. package/dist/src/commands/switchboard.d.ts +34 -0
  33. package/dist/src/commands/switchboard.d.ts.map +1 -0
  34. package/dist/src/commands/switchboard.js +82 -0
  35. package/dist/src/commands/uninstall.d.ts +15 -0
  36. package/dist/src/commands/uninstall.d.ts.map +1 -0
  37. package/dist/src/commands/uninstall.js +80 -0
  38. package/dist/src/index.d.ts +3 -0
  39. package/dist/src/index.d.ts.map +1 -0
  40. package/dist/src/index.js +2 -0
  41. package/dist/src/types.d.ts +2 -0
  42. package/dist/src/types.d.ts.map +1 -0
  43. package/dist/src/types.js +1 -0
  44. package/dist/src/utils.d.ts +47 -0
  45. package/dist/src/utils.d.ts.map +1 -0
  46. package/dist/src/utils.js +114 -0
  47. package/dist/tsconfig.tsbuildinfo +1 -0
  48. package/package.json +15 -15
  49. package/dist/chunk-3LA6D2BV.js +0 -109
  50. package/dist/chunk-4CHMELTF.js +0 -51
  51. package/dist/chunk-6VK3FH3G.js +0 -36
  52. package/dist/chunk-7FTFL36R.js +0 -52
  53. package/dist/chunk-ACKSBZXF.js +0 -85
  54. package/dist/chunk-D42NLWCH.js +0 -98
  55. package/dist/chunk-FEGQ7JEJ.js +0 -97
  56. package/dist/chunk-FFVIBNX6.js +0 -147
  57. package/dist/chunk-IFV5NKI4.js +0 -57
  58. package/dist/chunk-KPMNRIJU.js +0 -10
  59. package/dist/chunk-RRSG7FV6.js +0 -52
  60. package/dist/chunk-V725N3UP.js +0 -132
  61. package/dist/chunk-WUBXHLKE.js +0 -51
  62. package/dist/chunk-ZZ3KNXW6.js +0 -91
  63. package/dist/cli.js +0 -22
  64. package/dist/commands/connect.js +0 -8
  65. package/dist/commands/dev.js +0 -9
  66. package/dist/commands/generate.js +0 -8
  67. package/dist/commands/help.js +0 -6
  68. package/dist/commands/index.js +0 -68
  69. package/dist/commands/inspect.js +0 -9
  70. package/dist/commands/install.js +0 -11
  71. package/dist/commands/list.js +0 -9
  72. package/dist/commands/service.js +0 -8
  73. package/dist/commands/switchboard.js +0 -10
  74. package/dist/commands/uninstall.js +0 -11
  75. package/dist/index.js +0 -91
  76. package/dist/scripts/service-startup.sh +0 -7
  77. package/dist/scripts/service-unstartup.sh +0 -6
  78. package/dist/scripts/setup.sh +0 -24
  79. package/dist/types.js +0 -0
  80. package/dist/utils.js +0 -28
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@powerhousedao/ph-cli",
3
+ "version": "0.34.2-dev.0",
4
+ "description": "",
5
+ "license": "AGPL-3.0-only",
6
+ "type": "module",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "bin": {
11
+ "ph-cli": "dist/src/cli.js"
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc --build",
18
+ "dev": "concurrently -P 'pnpm -w run build:tsc --watch' 'nodemon --watch \"../..\" -e ts,tsx,js,json dist/src/cli.js -- {@}' --",
19
+ "prepublishOnly": "npm run build",
20
+ "lint": "eslint .",
21
+ "lint:nx": "eslint . --fix --quiet",
22
+ "lint:fix": "eslint --fix"
23
+ },
24
+ "keywords": [],
25
+ "author": "",
26
+ "devDependencies": {
27
+ "@powerhousedao/analytics-engine-core": "^0.3.2",
28
+ "@powerhousedao/analytics-engine-graphql": "^0.2.2",
29
+ "@powerhousedao/analytics-engine-pg": "^0.4.0",
30
+ "concurrently": "^9.1.2",
31
+ "document-drive": "workspace:*",
32
+ "graphql-tag": "^2.12.6",
33
+ "knex": "^3.1.0",
34
+ "luxon": "^3.5.0",
35
+ "nodemon": "^3.1.9"
36
+ },
37
+ "dependencies": {
38
+ "@powerhousedao/builder-tools": "workspace:*",
39
+ "@powerhousedao/codegen": "workspace:*",
40
+ "@powerhousedao/config": "workspace:*",
41
+ "@powerhousedao/connect": "workspace:*",
42
+ "@powerhousedao/design-system": "workspace:*",
43
+ "@powerhousedao/reactor-local": "workspace:*",
44
+ "@powerhousedao/scalars": "workspace:*",
45
+ "colorette": "^2.0.20",
46
+ "commander": "^12.1.0",
47
+ "document-model": "workspace:*",
48
+ "graphql": "^16.9.0",
49
+ "pm2": "^5.4.3"
50
+ }
51
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import registerCommands from "./commands/index.js";
4
+ const program = new Command();
5
+ program
6
+ .name("ph-cli")
7
+ .description("CLI tool for Powerhouse DAO")
8
+ .version("1.0.0");
9
+ registerCommands(program);
10
+ program.parse(process.argv);
@@ -0,0 +1,6 @@
1
+ import { ConnectStudioOptions } from "@powerhousedao/builder-tools/connect-studio";
2
+ import { Command } from "commander";
3
+ export type ConnectOptions = ConnectStudioOptions;
4
+ export declare function startConnect(connectOptions: ConnectOptions): Promise<void | undefined>;
5
+ export declare function connectCommand(program: Command): void;
6
+ //# sourceMappingURL=connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../../src/commands/connect.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAErB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAElD,wBAAsB,YAAY,CAAC,cAAc,EAAE,cAAc,6BAIhE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAmC9C"}
@@ -0,0 +1,44 @@
1
+ import { startConnectStudio, } from "@powerhousedao/builder-tools/connect-studio";
2
+ import { getConfig } from "@powerhousedao/config/powerhouse";
3
+ import packageJson from "../../package.json" with { type: "json" };
4
+ const version = packageJson.version;
5
+ export async function startConnect(connectOptions) {
6
+ const { documentModelsDir, editorsDir } = getConfig();
7
+ const options = { documentModelsDir, editorsDir, ...connectOptions };
8
+ return await startConnectStudio(options);
9
+ }
10
+ export function connectCommand(program) {
11
+ program
12
+ .command("connect")
13
+ .description("Starts Connect Studio")
14
+ .option("-p, --port <port>", "Port to run the server on", "3000")
15
+ .option("-h, --host", "Expose the server to the network")
16
+ .option("--https", "Enable HTTPS")
17
+ .option("--open", "Open the browser")
18
+ .option("--config-file <configFile>", "Path to the powerhouse.config.js file")
19
+ .option("-le, --local-editors <localEditors>", "Link local document editors path")
20
+ .option("-ld, --local-documents <localDocuments>", "Link local documents path")
21
+ .action(async (...args) => {
22
+ const connectOptions = args.at(0) || {};
23
+ const { documentModelsDir, editorsDir, packages, studio, logLevel } = getConfig();
24
+ await startConnectStudio({
25
+ port: studio?.port?.toString() || undefined,
26
+ packages,
27
+ phCliVersion: typeof version === "string" ? version : undefined,
28
+ localDocuments: documentModelsDir || undefined,
29
+ localEditors: editorsDir || undefined,
30
+ open: studio?.openBrowser,
31
+ logLevel: logLevel,
32
+ ...connectOptions,
33
+ });
34
+ });
35
+ }
36
+ if (process.argv.at(2) === "spawn") {
37
+ const optionsArg = process.argv.at(3);
38
+ const options = optionsArg
39
+ ? JSON.parse(optionsArg)
40
+ : {};
41
+ startConnect(options).catch((e) => {
42
+ throw e;
43
+ });
44
+ }
@@ -0,0 +1,14 @@
1
+ import { Command } from "commander";
2
+ import { CommandActionType } from "../types.js";
3
+ export declare const dev: CommandActionType<[
4
+ {
5
+ generate?: boolean;
6
+ watch?: boolean;
7
+ switchboardPort?: number;
8
+ configFile?: string;
9
+ httpsKeyFile?: string;
10
+ httpsCertFile?: string;
11
+ }
12
+ ]>;
13
+ export declare function devCommand(program: Command): void;
14
+ //# sourceMappingURL=dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/commands/dev.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAoFhD,eAAO,MAAM,GAAG,EAAE,iBAAiB,CACjC;IACE;QACE,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB;CACF,CAoBF,CAAC;AAEF,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,QAiB1C"}
@@ -0,0 +1,88 @@
1
+ import { blue, green, red } from "colorette";
2
+ import { fork } from "node:child_process";
3
+ import path, { dirname } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { getConfig } from "../utils.js";
6
+ import { DefaultSwitchboardOptions, } from "./switchboard.js";
7
+ const __dirname = import.meta.dirname || dirname(fileURLToPath(import.meta.url));
8
+ function spawnLocalSwitchboard(options) {
9
+ const child = fork(path.join(__dirname, "switchboard.js"), ["spawn", JSON.stringify(options)], { silent: true });
10
+ return new Promise((resolve) => {
11
+ child.on("message", (message) => {
12
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
13
+ const text = message.toString();
14
+ if (text.startsWith("driveUrl:")) {
15
+ const driveUrl = text.substring("driveUrl:".length);
16
+ resolve({ driveUrl });
17
+ }
18
+ });
19
+ child.stdout.on("data", (data) => {
20
+ const message = data.toString();
21
+ const lines = message.split("\n").filter((line) => line.trim().length);
22
+ for (const line of lines) {
23
+ process.stdout.write(blue(`[Switchboard]: ${line}\n`));
24
+ }
25
+ });
26
+ child.stderr.on("error", (data) => {
27
+ process.stderr.write(red(`[Switchboard]: ${data.toString()}`));
28
+ });
29
+ child.on("error", (err) => {
30
+ process.stderr.write(red(`[Switchboard]: ${err}`));
31
+ });
32
+ child.on("exit", (code) => {
33
+ console.log(`Switchboard process exited with code ${code}`);
34
+ });
35
+ });
36
+ }
37
+ async function spawnConnect(options, localReactorUrl) {
38
+ const child = fork(path.join(__dirname, "connect.js"), ["spawn", JSON.stringify(options ?? {})], {
39
+ silent: true,
40
+ env: {
41
+ ...process.env,
42
+ // TODO add studio variables?
43
+ LOCAL_DOCUMENT_MODELS: options?.localDocuments,
44
+ LOCAL_DOCUMENT_EDITORS: options?.localEditors,
45
+ PH_CONNECT_DEFAULT_DRIVES_URL: localReactorUrl,
46
+ },
47
+ });
48
+ return new Promise((resolve) => {
49
+ child.stdout.on("data", (data) => {
50
+ resolve();
51
+ process.stdout.write(green(`[Connect]: ${data.toString()}`));
52
+ });
53
+ child.stderr.on("data", (data) => {
54
+ process.stderr.write(red(`[Connect]: ${data.toString()}`));
55
+ });
56
+ child.on("close", (code) => {
57
+ console.log(`Connect process exited with code ${code}`);
58
+ });
59
+ });
60
+ }
61
+ export const dev = async ({ generate, watch, switchboardPort = DefaultSwitchboardOptions.port, configFile, }) => {
62
+ try {
63
+ const baseConfig = getConfig(configFile);
64
+ const https = baseConfig.reactor?.https;
65
+ const { driveUrl } = await spawnLocalSwitchboard({
66
+ generate,
67
+ port: switchboardPort,
68
+ watch,
69
+ https,
70
+ });
71
+ await spawnConnect({ configFile }, driveUrl);
72
+ }
73
+ catch (error) {
74
+ console.error(error);
75
+ }
76
+ };
77
+ export function devCommand(program) {
78
+ program
79
+ .command("dev")
80
+ .description("Starts dev environment")
81
+ .option("--generate", "generate code when document model is updated")
82
+ .option("--switchboard-port <port>", "port to use for the switchboard")
83
+ .option("--https-key-file <HTTPS_KEY_FILE>", "path to the ssl key file")
84
+ .option("--https-cert-file <HTTPS_CERT_FILE>", "path to the ssl cert file")
85
+ .option("--config-file <configFile>", "Path to the powerhouse.config.js file")
86
+ .option("-w, --watch", "if the switchboard should watch for local changes to document models and processors")
87
+ .action(dev);
88
+ }
@@ -0,0 +1,21 @@
1
+ import { Command } from "commander";
2
+ import { CommandActionType } from "../types.js";
3
+ export declare const generate: CommandActionType<[
4
+ string | undefined,
5
+ {
6
+ interactive?: boolean;
7
+ editors?: string;
8
+ processors?: string;
9
+ documentModels?: string;
10
+ skipFormat?: boolean;
11
+ watch?: boolean;
12
+ editor?: string;
13
+ processor?: string;
14
+ documentTypes?: string;
15
+ processorType?: "analytics" | "operational";
16
+ subgraph?: string;
17
+ importScript?: string;
18
+ }
19
+ ]>;
20
+ export declare function generateCommand(program: Command): void;
21
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/commands/generate.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CACtC;IACE,MAAM,GAAG,SAAS;IAClB;QACE,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,aAAa,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC;QAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB;CACF,CAwEF,CAAC;AAEF,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,QAkB/C"}
@@ -0,0 +1,74 @@
1
+ import { generate as generateCode, generateEditor, generateFromFile, generateImportScript, generateProcessor, generateSubgraph, } from "@powerhousedao/codegen";
2
+ import { getConfig } from "@powerhousedao/config/powerhouse";
3
+ export const generate = async (filePath, options) => {
4
+ const baseConfig = getConfig();
5
+ const config = {
6
+ ...baseConfig,
7
+ ...{
8
+ ...(options.editors && { editorsDir: options.editors }),
9
+ ...(options.processors && { processorsDir: options.processors }),
10
+ ...(options.documentModels && {
11
+ documentModelsDir: options.documentModels,
12
+ }),
13
+ ...(options.skipFormat && { skipFormat: options.skipFormat }),
14
+ ...(options.interactive && { interactive: options.interactive }),
15
+ ...(options.watch && { watch: options.watch }),
16
+ },
17
+ };
18
+ const command = {
19
+ editor: !!options.editor,
20
+ editorName: options.editor,
21
+ documentTypes: options.documentTypes,
22
+ processor: !!options.processor,
23
+ processorName: options.processor,
24
+ processorType: options.processorType,
25
+ subgraph: !!options.subgraph,
26
+ subgraphName: options.subgraph,
27
+ importScript: !!options.importScript,
28
+ importScriptName: options.importScript,
29
+ };
30
+ if (command.editor) {
31
+ if (!command.editorName) {
32
+ throw new Error("Editor name is required (--editor or -e)");
33
+ }
34
+ await generateEditor(command.editorName, command.documentTypes?.split(/[|,;]/g) ?? [], config);
35
+ return;
36
+ }
37
+ if (command.processor && options.processor) {
38
+ const processorType = options.processorType === "operational" ? "operational" : "analytics";
39
+ await generateProcessor(options.processor, processorType, options.documentTypes?.split(",") ?? [], config);
40
+ return;
41
+ }
42
+ if (command.subgraph && command.subgraphName) {
43
+ await generateSubgraph(command.subgraphName, null, config);
44
+ return;
45
+ }
46
+ if (command.importScript && command.importScriptName) {
47
+ await generateImportScript(command.importScriptName, config);
48
+ return;
49
+ }
50
+ if (filePath) {
51
+ await generateFromFile(filePath, config);
52
+ return;
53
+ }
54
+ await generateCode(config);
55
+ };
56
+ export function generateCommand(program) {
57
+ program
58
+ .command("generate")
59
+ .description("Generate code from the document models")
60
+ .argument("[document-model-file]", "Path to the document model file")
61
+ .option("-i, --interactive", "Run the command in interactive mode")
62
+ .option("--editors <type>", "Path to the editors directory")
63
+ .option("-e, --editor <type>", "Editor Name")
64
+ .option("--processors <type>", "Path to the processors directory")
65
+ .option("-p, --processor <type>", "Processor Name")
66
+ .option("--processor-type <type>", "Processor Type")
67
+ .option("-s, --subgraph <type>", "Subgraph Name")
68
+ .option("--document-models <type>", "Path to the document models directory")
69
+ .option("--document-types <type>", "Supported document types by the editor")
70
+ .option("-is, --import-script <type>", "Import Script Name")
71
+ .option("-sf, --skip-format", "Skip formatting the generated code")
72
+ .option("-w, --watch", "Watch the generated code")
73
+ .action(generate);
74
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function helpCommand(program: Command): void;
3
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,QAO3C"}
@@ -0,0 +1,8 @@
1
+ export function helpCommand(program) {
2
+ program
3
+ .command("help")
4
+ .description("Display help information")
5
+ .action(() => {
6
+ program.help();
7
+ });
8
+ }
@@ -0,0 +1,14 @@
1
+ import { Command } from "commander";
2
+ import { devCommand } from "./dev.js";
3
+ export declare const commands: (typeof devCommand)[];
4
+ export default function registerCommands(program: Command): void;
5
+ export * from "./connect.js";
6
+ export * from "./dev.js";
7
+ export * from "./generate.js";
8
+ export * from "./help.js";
9
+ export * from "./install.js";
10
+ export * from "./list.js";
11
+ export * from "./service.js";
12
+ export * from "./switchboard.js";
13
+ export * from "./uninstall.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAUtC,eAAO,MAAM,QAAQ,uBAWpB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAO,EAAE,OAAO,QAExD;AAED,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { connectCommand } from "./connect.js";
2
+ import { devCommand } from "./dev.js";
3
+ import { generateCommand } from "./generate.js";
4
+ import { helpCommand } from "./help.js";
5
+ import { inspectCommand } from "./inspect.js";
6
+ import { installCommand } from "./install.js";
7
+ import { listCommand } from "./list.js";
8
+ import { serviceCommand } from "./service.js";
9
+ import { reactorCommand } from "./switchboard.js";
10
+ import { uninstallCommand } from "./uninstall.js";
11
+ export const commands = [
12
+ devCommand,
13
+ connectCommand,
14
+ generateCommand,
15
+ reactorCommand,
16
+ helpCommand,
17
+ installCommand,
18
+ uninstallCommand,
19
+ serviceCommand,
20
+ listCommand,
21
+ inspectCommand,
22
+ ];
23
+ export default function registerCommands(program) {
24
+ commands.forEach((command) => command(program));
25
+ }
26
+ export * from "./connect.js";
27
+ export * from "./dev.js";
28
+ export * from "./generate.js";
29
+ export * from "./help.js";
30
+ export * from "./install.js";
31
+ export * from "./list.js";
32
+ export * from "./service.js";
33
+ export * from "./switchboard.js";
34
+ export * from "./uninstall.js";
@@ -0,0 +1,10 @@
1
+ import { Command } from "commander";
2
+ import { CommandActionType } from "../types.js";
3
+ export declare const inspect: CommandActionType<[
4
+ string,
5
+ {
6
+ debug?: boolean;
7
+ }
8
+ ]>;
9
+ export declare function inspectCommand(program: Command): void;
10
+ //# sourceMappingURL=inspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../../src/commands/inspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,OAAO,EAAE,iBAAiB,CACrC;IACE,MAAM;IACN;QACE,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CACF,CAyDF,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAQ9C"}
@@ -0,0 +1,57 @@
1
+ // import { Manifest } from "document-model";
2
+ import path from "node:path";
3
+ import { getProjectInfo } from "../utils.js";
4
+ export const inspect = async (packageName, options) => {
5
+ if (options.debug) {
6
+ console.log(">>> command arguments", { options });
7
+ }
8
+ const projectInfo = getProjectInfo(options.debug);
9
+ if (options.debug) {
10
+ console.log("\n>>> projectInfo", projectInfo);
11
+ }
12
+ try {
13
+ const manifest = (await import(path.join(packageName, "manifest")));
14
+ console.log(manifest.name);
15
+ if (manifest.documentModels) {
16
+ console.log("\nDocument Models:");
17
+ manifest.documentModels.forEach((model) => {
18
+ console.log(`- ${model.name} (${model.id})`);
19
+ });
20
+ }
21
+ if (manifest.editors) {
22
+ console.log("\nEditors:");
23
+ manifest.editors.forEach((editor) => {
24
+ console.log(`- ${editor.name} (${editor.id})`);
25
+ });
26
+ }
27
+ if (manifest.processors) {
28
+ console.log("\nProcessors:");
29
+ manifest.processors.forEach((processor) => {
30
+ console.log(`- ${processor.name} (${processor.id})`);
31
+ });
32
+ }
33
+ if (manifest.subgraphs) {
34
+ console.log("\nSubgraphs:");
35
+ manifest.subgraphs.forEach((subgraph) => {
36
+ console.log(`- ${subgraph.name} (${subgraph.id})`);
37
+ });
38
+ }
39
+ }
40
+ catch (e) {
41
+ if (options.debug) {
42
+ console.error(e);
43
+ }
44
+ else {
45
+ console.log("No manifest found in the package");
46
+ }
47
+ }
48
+ };
49
+ export function inspectCommand(program) {
50
+ program
51
+ .command("inspect")
52
+ .alias("is")
53
+ .description("Inspect a package")
54
+ .option("--debug", "Show additional logs")
55
+ .argument("<packageName>", "The name of the package to inspect")
56
+ .action(inspect);
57
+ }
@@ -0,0 +1,15 @@
1
+ import { Command } from "commander";
2
+ import { CommandActionType } from "../types.js";
3
+ import { PackageManager } from "../utils.js";
4
+ export declare function installDependency(packageManager: PackageManager, dependencies: string[], projectPath: string, workspace?: boolean): void;
5
+ export declare const install: CommandActionType<[
6
+ string[] | undefined,
7
+ {
8
+ debug?: boolean;
9
+ global?: boolean;
10
+ workspace?: boolean;
11
+ packageManager?: string;
12
+ }
13
+ ]>;
14
+ export declare function installCommand(program: Command): void;
15
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAGL,cAAc,EAIf,MAAM,aAAa,CAAC;AAErB,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,MAAM,EAAE,EACtB,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,OAAO,QAuBpB;AAED,eAAO,MAAM,OAAO,EAAE,iBAAiB,CACrC;IACE,MAAM,EAAE,GAAG,SAAS;IACpB;QACE,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;CACF,CAkEF,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAkB9C"}
@@ -0,0 +1,80 @@
1
+ import { execSync } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import { getPackageManagerFromLockfile, getProjectInfo, packageManagers, SUPPORTED_PACKAGE_MANAGERS, updateConfigFile, } from "../utils.js";
4
+ export function installDependency(packageManager, dependencies, projectPath, workspace) {
5
+ if (!fs.existsSync(projectPath)) {
6
+ throw new Error(`Project path not found: ${projectPath}`);
7
+ }
8
+ const manager = packageManagers[packageManager];
9
+ let installCommand = manager.installCommand.replace("{{dependency}}", dependencies.join(" "));
10
+ if (workspace) {
11
+ installCommand += ` ${manager.workspaceOption}`;
12
+ }
13
+ const commandOptions = { cwd: projectPath };
14
+ execSync(installCommand, {
15
+ stdio: "inherit",
16
+ ...commandOptions,
17
+ });
18
+ }
19
+ export const install = (dependencies, options) => {
20
+ if (options.debug) {
21
+ console.log(">>> command arguments", { dependencies, options });
22
+ }
23
+ if (!dependencies || dependencies.length === 0) {
24
+ throw new Error("❌ Dependency name is required");
25
+ }
26
+ if (options.packageManager &&
27
+ !SUPPORTED_PACKAGE_MANAGERS.includes(options.packageManager)) {
28
+ throw new Error("❌ Unsupported package manager. Supported package managers: npm, yarn, pnpm, bun");
29
+ }
30
+ const projectInfo = getProjectInfo(options.debug);
31
+ if (options.debug) {
32
+ console.log("\n>>> projectInfo", projectInfo);
33
+ }
34
+ const isGlobal = options.global || projectInfo.isGlobal;
35
+ const packageManager = options.packageManager || getPackageManagerFromLockfile(projectInfo.path);
36
+ if (options.debug) {
37
+ console.log("\n>>> installDependency arguments:");
38
+ console.log(">>> packageManager", packageManager);
39
+ console.log(">>> dependencies", dependencies);
40
+ console.log(">>> isGlobal", isGlobal);
41
+ console.log(">>> projectPath", projectInfo.path);
42
+ console.log(">>> workspace", options.workspace);
43
+ }
44
+ try {
45
+ console.log("installing dependencies 📦 ...");
46
+ installDependency(packageManager, dependencies, projectInfo.path, options.workspace);
47
+ console.log("Dependency installed successfully 🎉");
48
+ }
49
+ catch (error) {
50
+ console.error("❌ Failed to install dependencies");
51
+ throw error;
52
+ }
53
+ if (options.debug) {
54
+ console.log("\n>>> updateConfigFile arguments:");
55
+ console.log(">>> dependencies", dependencies);
56
+ console.log(">>> projectPath", projectInfo.path);
57
+ }
58
+ try {
59
+ console.log("⚙️ Updating powerhouse config file...");
60
+ updateConfigFile(dependencies, projectInfo.path, "install");
61
+ console.log("Config file updated successfully 🎉");
62
+ }
63
+ catch (error) {
64
+ console.error("❌ Failed to update config file");
65
+ throw error;
66
+ }
67
+ };
68
+ export function installCommand(program) {
69
+ program
70
+ .command("install")
71
+ .alias("add")
72
+ .alias("i")
73
+ .description("Install a powerhouse dependency")
74
+ .argument("[dependencies...]", "Names of the dependencies to install")
75
+ .option("-g, --global", "Install the dependency globally")
76
+ .option("--debug", "Show additional logs")
77
+ .option("-w, --workspace", "Install the dependency in the workspace (use this option for monorepos)")
78
+ .option("--package-manager <packageManager>", "force package manager to use")
79
+ .action(install);
80
+ }
@@ -0,0 +1,9 @@
1
+ import { Command } from "commander";
2
+ import { CommandActionType } from "../types.js";
3
+ export declare const list: CommandActionType<[
4
+ {
5
+ debug?: boolean;
6
+ }
7
+ ]>;
8
+ export declare function listCommand(program: Command): void;
9
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,eAAO,MAAM,IAAI,EAAE,iBAAiB,CAClC;IACE;QACE,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CACF,CA6BF,CAAC;AAEF,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,QAO3C"}
@@ -0,0 +1,33 @@
1
+ import path from "node:path";
2
+ import { getProjectInfo } from "../utils.js";
3
+ export const list = async (options) => {
4
+ if (options.debug) {
5
+ console.log(">>> command arguments", { options });
6
+ }
7
+ const projectInfo = getProjectInfo(options.debug);
8
+ if (options.debug) {
9
+ console.log("\n>>> projectInfo", projectInfo);
10
+ }
11
+ try {
12
+ const phConfig = (await import(path.join(projectInfo.path, "powerhouse.config.json")));
13
+ if (!phConfig.packages || phConfig.packages.length === 0) {
14
+ console.log("No packages found in the project");
15
+ return;
16
+ }
17
+ console.log("Installed Packages:\n");
18
+ phConfig.packages.forEach((pkg) => {
19
+ console.log(pkg.packageName);
20
+ });
21
+ }
22
+ catch (e) {
23
+ console.log("No packages found in the project");
24
+ }
25
+ };
26
+ export function listCommand(program) {
27
+ program
28
+ .command("list")
29
+ .alias("l")
30
+ .description("List installed packages")
31
+ .option("--debug", "Show additional logs")
32
+ .action(list);
33
+ }
@@ -0,0 +1,5 @@
1
+ import { Command } from "commander";
2
+ import { CommandActionType } from "../types.js";
3
+ export declare const manageService: CommandActionType<[string, string]>;
4
+ export declare function serviceCommand(program: Command): void;
5
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/commands/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,OAAO,EAAE,MAAM,WAAW,CAAC;AAK9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAOhD,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAmC7D,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAS9C"}