@powerhousedao/ph-cli 0.30.0 → 0.31.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 (53) hide show
  1. package/dist/chunk-27FF7J6K.js +45 -0
  2. package/dist/chunk-6O6TUXJK.js +90 -0
  3. package/dist/chunk-CWUXPR5K.js +109 -0
  4. package/dist/chunk-E3EWRF5U.js +97 -0
  5. package/dist/chunk-FDMMJENR.js +132 -0
  6. package/dist/chunk-KPMNRIJU.js +10 -0
  7. package/dist/chunk-OH5NZOCQ.js +85 -0
  8. package/dist/chunk-PUQARXW2.js +44 -0
  9. package/dist/chunk-X2RNXISI.js +98 -0
  10. package/dist/chunk-ZN4M6TJ2.js +119 -0
  11. package/dist/cli.js +15 -5
  12. package/dist/commands/connect.js +8 -42
  13. package/dist/commands/dev.js +8 -97
  14. package/dist/commands/generate.js +7 -69
  15. package/dist/commands/help.js +6 -9
  16. package/dist/commands/index.js +57 -28
  17. package/dist/commands/install.js +10 -193
  18. package/dist/commands/service.js +7 -117
  19. package/dist/commands/switchboard.js +10 -0
  20. package/dist/commands/uninstall.js +11 -0
  21. package/dist/index.js +84 -4
  22. package/dist/scripts/setup.sh +18 -6
  23. package/dist/types.js +0 -3
  24. package/dist/utils.js +28 -3
  25. package/package.json +12 -19
  26. package/dist/cli.d.ts +0 -2
  27. package/dist/cli.js.map +0 -1
  28. package/dist/commands/connect.d.ts +0 -8
  29. package/dist/commands/connect.js.map +0 -1
  30. package/dist/commands/dev.d.ts +0 -14
  31. package/dist/commands/dev.js.map +0 -1
  32. package/dist/commands/generate.d.ts +0 -22
  33. package/dist/commands/generate.js.map +0 -1
  34. package/dist/commands/help.d.ts +0 -5
  35. package/dist/commands/help.js.map +0 -1
  36. package/dist/commands/index.d.ts +0 -16
  37. package/dist/commands/index.js.map +0 -1
  38. package/dist/commands/init.d.ts +0 -17
  39. package/dist/commands/init.js +0 -28
  40. package/dist/commands/init.js.map +0 -1
  41. package/dist/commands/install.d.ts +0 -29
  42. package/dist/commands/install.js.map +0 -1
  43. package/dist/commands/reactor.d.ts +0 -36
  44. package/dist/commands/reactor.js +0 -79
  45. package/dist/commands/reactor.js.map +0 -1
  46. package/dist/commands/service.d.ts +0 -7
  47. package/dist/commands/service.js.map +0 -1
  48. package/dist/index.d.ts +0 -11
  49. package/dist/index.js.map +0 -1
  50. package/dist/types.d.ts +0 -3
  51. package/dist/types.js.map +0 -1
  52. package/dist/utils.d.ts +0 -1
  53. package/dist/utils.js.map +0 -1
@@ -1,194 +1,11 @@
1
- import path, { dirname } from 'node:path';
2
- import fs from 'node:fs';
3
- import { execSync } from 'node:child_process';
4
- import { homedir } from 'node:os';
5
-
6
- const POWERHOUSE_CONFIG_FILE = "powerhouse.config.json";
7
- const SUPPORTED_PACKAGE_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
8
- const POWERHOUSE_GLOBAL_DIR = path.join(homedir(), ".ph");
9
- const packageManagers = {
10
- bun: {
11
- globalPathRegexp: /[\\/].bun[\\/]/,
12
- installCommand: "bun add {{dependency}}",
13
- workspaceOption: "",
14
- lockfile: "bun.lock"
15
- },
16
- pnpm: {
17
- globalPathRegexp: /[\\/]pnpm[\\/]/,
18
- installCommand: "pnpm add {{dependency}}",
19
- workspaceOption: "--workspace-root",
20
- lockfile: "pnpm-lock.yaml"
21
- },
22
- yarn: {
23
- globalPathRegexp: /[\\/]yarn[\\/]/,
24
- installCommand: "yarn add {{dependency}}",
25
- workspaceOption: "-W",
26
- lockfile: "yarn.lock"
27
- },
28
- npm: {
29
- installCommand: "npm install {{dependency}}",
30
- workspaceOption: "",
31
- lockfile: "package-lock.json"
32
- }
1
+ import {
2
+ install,
3
+ installCommand,
4
+ installDependency
5
+ } from "../chunk-E3EWRF5U.js";
6
+ import "../chunk-FDMMJENR.js";
7
+ export {
8
+ install,
9
+ installCommand,
10
+ installDependency
33
11
  };
34
- function defaultPathValidation() {
35
- return true;
36
- }
37
- function isPowerhouseProject(dir) {
38
- const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);
39
- return fs.existsSync(powerhouseConfigPath);
40
- }
41
- function findNodeProjectRoot(dir, pathValidation = defaultPathValidation) {
42
- const packageJsonPath = path.join(dir, "package.json");
43
- if (fs.existsSync(packageJsonPath) && pathValidation(dir)) {
44
- return dir;
45
- }
46
- const parentDir = dirname(dir);
47
- if (parentDir === dir) {
48
- return null;
49
- }
50
- return findNodeProjectRoot(parentDir, pathValidation);
51
- }
52
- function getPackageManagerFromPath(dir) {
53
- const lowerCasePath = dir.toLowerCase();
54
- if (packageManagers.bun.globalPathRegexp.test(lowerCasePath)) {
55
- return "bun";
56
- } else if (packageManagers.pnpm.globalPathRegexp.test(lowerCasePath)) {
57
- return "pnpm";
58
- } else if (packageManagers.yarn.globalPathRegexp.test(lowerCasePath)) {
59
- return "yarn";
60
- }
61
- return "npm";
62
- }
63
- function getPackageManagerFromLockfile(dir) {
64
- if (fs.existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {
65
- return "pnpm";
66
- } else if (fs.existsSync(path.join(dir, packageManagers.yarn.lockfile))) {
67
- return "yarn";
68
- } else if (fs.existsSync(path.join(dir, packageManagers.bun.lockfile))) {
69
- return "bun";
70
- }
71
- return "npm";
72
- }
73
- function getProjectInfo(debug) {
74
- const currentPath = process.cwd();
75
- if (debug) {
76
- console.log(">>> currentPath", currentPath);
77
- }
78
- const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);
79
- if (!projectPath) {
80
- return {
81
- isGlobal: true,
82
- path: POWERHOUSE_GLOBAL_DIR
83
- };
84
- }
85
- return {
86
- isGlobal: false,
87
- path: projectPath
88
- };
89
- }
90
- function installDependency(packageManager, dependencies, projectPath, workspace) {
91
- if (!fs.existsSync(projectPath)) {
92
- throw new Error(`Project path not found: ${projectPath}`);
93
- }
94
- const manager = packageManagers[packageManager];
95
- let installCommand2 = manager.installCommand.replace(
96
- "{{dependency}}",
97
- dependencies.join(" ")
98
- );
99
- if (workspace) {
100
- installCommand2 += ` ${manager.workspaceOption}`;
101
- }
102
- const commandOptions = { cwd: projectPath };
103
- execSync(installCommand2, {
104
- stdio: "inherit",
105
- ...commandOptions
106
- });
107
- }
108
- function updateConfigFile(dependencies, projectPath) {
109
- const configPath = path.join(projectPath, POWERHOUSE_CONFIG_FILE);
110
- if (!fs.existsSync(configPath)) {
111
- throw new Error(
112
- `powerhouse.config.json file not found. projectPath: ${projectPath}`
113
- );
114
- }
115
- const config = JSON.parse(
116
- fs.readFileSync(configPath, "utf-8")
117
- );
118
- const mappedPackages = dependencies.map(
119
- (dep) => ({
120
- packageName: dep
121
- })
122
- );
123
- const updatedConfig = {
124
- ...config,
125
- packages: [...config.packages || [], ...mappedPackages]
126
- };
127
- fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));
128
- }
129
- const install = (dependencies, options) => {
130
- if (options.debug) {
131
- console.log(">>> command arguments", { dependencies, options });
132
- }
133
- if (!dependencies || dependencies.length === 0) {
134
- throw new Error("\u274C Dependency name is required");
135
- }
136
- if (options.packageManager && !SUPPORTED_PACKAGE_MANAGERS.includes(options.packageManager)) {
137
- throw new Error(
138
- "\u274C Unsupported package manager. Supported package managers: npm, yarn, pnpm, bun"
139
- );
140
- }
141
- const projectInfo = getProjectInfo(options.debug);
142
- if (options.debug) {
143
- console.log("\n>>> projectInfo", projectInfo);
144
- }
145
- const isGlobal = options.global || projectInfo.isGlobal;
146
- const packageManager = options.packageManager || getPackageManagerFromLockfile(projectInfo.path);
147
- if (options.debug) {
148
- console.log("\n>>> installDependency arguments:");
149
- console.log(">>> packageManager", packageManager);
150
- console.log(">>> dependencies", dependencies);
151
- console.log(">>> isGlobal", isGlobal);
152
- console.log(">>> projectPath", projectInfo.path);
153
- console.log(">>> workspace", options.workspace);
154
- }
155
- try {
156
- console.log("installing dependencies \u{1F4E6} ...");
157
- installDependency(
158
- packageManager,
159
- dependencies,
160
- projectInfo.path,
161
- options.workspace
162
- );
163
- console.log("Dependency installed successfully \u{1F389}");
164
- } catch (error) {
165
- console.error("\u274C Failed to install dependencies");
166
- throw error;
167
- }
168
- if (options.debug) {
169
- console.log("\n>>> updateConfigFile arguments:");
170
- console.log(">>> dependencies", dependencies);
171
- console.log(">>> projectPath", projectInfo.path);
172
- }
173
- try {
174
- console.log("\u2699\uFE0F Updating powerhouse config file...");
175
- updateConfigFile(dependencies, projectInfo.path);
176
- console.log("Config file updated successfully \u{1F389}");
177
- } catch (error) {
178
- console.error("\u274C Failed to update config file");
179
- throw error;
180
- }
181
- };
182
- function installCommand(program) {
183
- program.command("install").description("Install a powerhouse dependency").argument("[dependencies...]", "Names of the dependencies to install").option("-g, --global", "Install the dependency globally").option("--debug", "Show additional logs").option(
184
- "-w, --workspace",
185
- "Install the dependency in the workspace (use this option for monorepos)"
186
- ).option(
187
- "--package-manager <packageManager>",
188
- "force package manager to use"
189
- ).action(install);
190
- }
191
-
192
- export { defaultPathValidation, findNodeProjectRoot, getPackageManagerFromLockfile, getPackageManagerFromPath, getProjectInfo, install, installCommand, installDependency, isPowerhouseProject, updateConfigFile };
193
- //# sourceMappingURL=install.js.map
194
- //# sourceMappingURL=install.js.map
@@ -1,118 +1,8 @@
1
- import { Argument } from 'commander';
2
- import pm2 from 'pm2';
3
- import { getConfig } from '@powerhousedao/config/powerhouse';
4
-
5
- const actions = ["start", "stop", "status", "list", "install", "save"];
6
- const services = ["reactor", "connect", "all"];
7
- let reactorPort = 8442;
8
- let connectPort = 8443;
9
- const manageService = async (action, service) => {
10
- try {
11
- const config = getConfig();
12
- if (config.reactor?.port) {
13
- reactorPort = config.reactor.port;
14
- }
15
- if (config.studio?.port) {
16
- connectPort = config.studio.port;
17
- }
18
- pm2.connect((err) => {
19
- switch (action) {
20
- case "start":
21
- startServices(service);
22
- break;
23
- case "stop":
24
- stopServices(service);
25
- break;
26
- case "status":
27
- statusServices();
28
- break;
29
- }
30
- });
31
- } catch (error) {
32
- console.error(error);
33
- }
1
+ import {
2
+ manageService,
3
+ serviceCommand
4
+ } from "../chunk-ZN4M6TJ2.js";
5
+ export {
6
+ manageService,
7
+ serviceCommand
34
8
  };
35
- function serviceCommand(program) {
36
- program.command("service").description("Manage services").addArgument(new Argument("action").choices(actions).default("list")).addArgument(
37
- new Argument("service").choices(services).argOptional().default("all")
38
- ).action(manageService);
39
- }
40
- function startServices(service) {
41
- if (service === "reactor" || service === "all") {
42
- const reactorOptions = {
43
- name: "reactor",
44
- script: "npx ph-cli reactor"
45
- };
46
- console.log("Starting reactor...");
47
- pm2.start(reactorOptions, (err) => {
48
- if (err) {
49
- console.log(err.name);
50
- }
51
- dumpServices();
52
- });
53
- console.log("Reactor started");
54
- }
55
- if (service === "connect" || service === "all") {
56
- const connectOptions = {
57
- name: "connect",
58
- script: "npx ph-cli connect",
59
- args: ["--port", connectPort.toString()]
60
- };
61
- console.log("Starting connect...");
62
- pm2.start(connectOptions, (err) => {
63
- if (err) {
64
- throw new Error(err.message);
65
- }
66
- dumpServices();
67
- });
68
- console.log("Connect started");
69
- }
70
- }
71
- function dumpServices() {
72
- pm2.dump((err) => {
73
- if (err) {
74
- throw new Error(err.message);
75
- }
76
- statusServices();
77
- });
78
- }
79
- function stopServices(service) {
80
- if (service === "all" || service === "connect") {
81
- pm2.stop("connect", (err) => {
82
- if (err) {
83
- throw new Error(err.message);
84
- }
85
- dumpServices();
86
- });
87
- }
88
- if (service === "all" || service === "reactor") {
89
- pm2.stop("reactor", (err) => {
90
- if (err) {
91
- throw new Error(err.message);
92
- }
93
- dumpServices();
94
- });
95
- }
96
- }
97
- function statusServices() {
98
- pm2.list((err, list) => {
99
- const formattedList = list.map((item) => {
100
- return {
101
- id: item.pm_id,
102
- name: item.name,
103
- pid: item.pid,
104
- uptime: item.pm2_env?.pm_uptime,
105
- restarts: item.pm2_env?.unstable_restarts,
106
- status: item.pm2_env?.status,
107
- mem: item.monit?.memory,
108
- cpu: item.monit?.cpu
109
- };
110
- });
111
- console.table(formattedList);
112
- process.exit(0);
113
- });
114
- }
115
-
116
- export { manageService, serviceCommand };
117
- //# sourceMappingURL=service.js.map
118
- //# sourceMappingURL=service.js.map
@@ -0,0 +1,10 @@
1
+ import {
2
+ DefaultSwitchboardOptions,
3
+ reactorCommand,
4
+ switchboard
5
+ } from "../chunk-6O6TUXJK.js";
6
+ export {
7
+ DefaultSwitchboardOptions,
8
+ reactorCommand,
9
+ switchboard
10
+ };
@@ -0,0 +1,11 @@
1
+ import {
2
+ uninstall,
3
+ uninstallCommand,
4
+ uninstallDependency
5
+ } from "../chunk-X2RNXISI.js";
6
+ import "../chunk-FDMMJENR.js";
7
+ export {
8
+ uninstall,
9
+ uninstallCommand,
10
+ uninstallDependency
11
+ };
package/dist/index.js CHANGED
@@ -1,4 +1,84 @@
1
- export * from './commands/index.js';
2
- export * from './utils.js';
3
- //# sourceMappingURL=index.js.map
4
- //# sourceMappingURL=index.js.map
1
+ import {
2
+ commands
3
+ } from "./chunk-PUQARXW2.js";
4
+ import {
5
+ install,
6
+ installCommand,
7
+ installDependency
8
+ } from "./chunk-E3EWRF5U.js";
9
+ import {
10
+ manageService,
11
+ serviceCommand
12
+ } from "./chunk-ZN4M6TJ2.js";
13
+ import {
14
+ uninstall,
15
+ uninstallCommand,
16
+ uninstallDependency
17
+ } from "./chunk-X2RNXISI.js";
18
+ import {
19
+ POWERHOUSE_CONFIG_FILE,
20
+ POWERHOUSE_GLOBAL_DIR,
21
+ SUPPORTED_PACKAGE_MANAGERS,
22
+ defaultPathValidation,
23
+ findNodeProjectRoot,
24
+ getConfig,
25
+ getPackageManagerFromLockfile,
26
+ getPackageManagerFromPath,
27
+ getProjectInfo,
28
+ isPowerhouseProject,
29
+ packageManagers,
30
+ updateConfigFile
31
+ } from "./chunk-FDMMJENR.js";
32
+ import {
33
+ connectCommand,
34
+ startConnect
35
+ } from "./chunk-27FF7J6K.js";
36
+ import {
37
+ dev,
38
+ devCommand
39
+ } from "./chunk-CWUXPR5K.js";
40
+ import {
41
+ DefaultSwitchboardOptions,
42
+ reactorCommand,
43
+ switchboard
44
+ } from "./chunk-6O6TUXJK.js";
45
+ import {
46
+ generate,
47
+ generateCommand
48
+ } from "./chunk-OH5NZOCQ.js";
49
+ import {
50
+ helpCommand
51
+ } from "./chunk-KPMNRIJU.js";
52
+ export {
53
+ DefaultSwitchboardOptions,
54
+ POWERHOUSE_CONFIG_FILE,
55
+ POWERHOUSE_GLOBAL_DIR,
56
+ SUPPORTED_PACKAGE_MANAGERS,
57
+ commands,
58
+ connectCommand,
59
+ defaultPathValidation,
60
+ dev,
61
+ devCommand,
62
+ findNodeProjectRoot,
63
+ generate,
64
+ generateCommand,
65
+ getConfig,
66
+ getPackageManagerFromLockfile,
67
+ getPackageManagerFromPath,
68
+ getProjectInfo,
69
+ helpCommand,
70
+ install,
71
+ installCommand,
72
+ installDependency,
73
+ isPowerhouseProject,
74
+ manageService,
75
+ packageManagers,
76
+ reactorCommand,
77
+ serviceCommand,
78
+ startConnect,
79
+ switchboard,
80
+ uninstall,
81
+ uninstallCommand,
82
+ uninstallDependency,
83
+ updateConfigFile
84
+ };
@@ -1,12 +1,24 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
3
- . ~/.nvm/nvm.sh
3
+ \. ~/.nvm/nvm.sh
4
4
  export NVM_DIR="$HOME/.nvm"
5
5
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
6
6
  [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
7
7
  nvm --version
8
- nvm install 20
9
- npm install -g pnpm
10
- pnpm setup
11
- source $HOME/.bashrc
8
+ nvm install 22
9
+ curl -fsSL https://get.pnpm.io/install.sh | sh -
10
+ export PNPM_HOME="/home/$USER/.local/share/pnpm"
11
+ export PATH="$PNPM_HOME:$PATH"
12
12
  pnpm install -g ph-cmd
13
+ echo ""
14
+ echo " 🎉 Setup Complete! 🎉"
15
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
16
+ echo " To complete installation:"
17
+ echo " 1. Restart your terminal"
18
+ echo " OR"
19
+ echo " Run: source ~/.bashrc"
20
+ echo ""
21
+ echo " 2. Start using Powerhouse by typing:"
22
+ echo " ph"
23
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
24
+ echo ""
package/dist/types.js CHANGED
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=types.js.map
3
- //# sourceMappingURL=types.js.map
package/dist/utils.js CHANGED
@@ -1,3 +1,28 @@
1
- export { getConfig } from '@powerhousedao/config/powerhouse';
2
- //# sourceMappingURL=utils.js.map
3
- //# sourceMappingURL=utils.js.map
1
+ import {
2
+ POWERHOUSE_CONFIG_FILE,
3
+ POWERHOUSE_GLOBAL_DIR,
4
+ SUPPORTED_PACKAGE_MANAGERS,
5
+ defaultPathValidation,
6
+ findNodeProjectRoot,
7
+ getConfig,
8
+ getPackageManagerFromLockfile,
9
+ getPackageManagerFromPath,
10
+ getProjectInfo,
11
+ isPowerhouseProject,
12
+ packageManagers,
13
+ updateConfigFile
14
+ } from "./chunk-FDMMJENR.js";
15
+ export {
16
+ POWERHOUSE_CONFIG_FILE,
17
+ POWERHOUSE_GLOBAL_DIR,
18
+ SUPPORTED_PACKAGE_MANAGERS,
19
+ defaultPathValidation,
20
+ findNodeProjectRoot,
21
+ getConfig,
22
+ getPackageManagerFromLockfile,
23
+ getPackageManagerFromPath,
24
+ getProjectInfo,
25
+ isPowerhouseProject,
26
+ packageManagers,
27
+ updateConfigFile
28
+ };
package/package.json CHANGED
@@ -1,50 +1,43 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-cli",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
7
- "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
7
  "publishConfig": {
10
8
  "access": "public"
11
9
  },
12
10
  "bin": {
13
11
  "ph-cli": "dist/cli.js"
14
12
  },
15
- "exports": {
16
- ".": "./dist/index.js",
17
- "./cli": "./dist/cli.js",
18
- "./utils": "./dist/utils.js"
19
- },
20
13
  "files": [
21
14
  "dist"
22
15
  ],
23
16
  "keywords": [],
24
17
  "author": "",
25
18
  "devDependencies": {
26
- "@powerhousedao/analytics-engine-core": "^0.3.0",
27
- "@powerhousedao/analytics-engine-graphql": "^0.2.1",
28
- "@powerhousedao/analytics-engine-pg": "^0.3.0",
19
+ "@powerhousedao/analytics-engine-core": "^0.3.2",
20
+ "@powerhousedao/analytics-engine-graphql": "^0.2.2",
21
+ "@powerhousedao/analytics-engine-pg": "^0.4.0",
29
22
  "graphql-tag": "^2.12.6",
30
23
  "knex": "^3.1.0",
31
24
  "luxon": "^3.5.0",
32
- "document-drive": "1.16.1"
25
+ "document-drive": "1.17.0"
33
26
  },
34
27
  "dependencies": {
35
- "@powerhousedao/connect": "1.0.0-dev.195",
36
28
  "colorette": "^2.0.20",
37
29
  "commander": "^12.1.0",
38
30
  "graphql": "^16.9.0",
39
31
  "pm2": "^5.4.3",
40
32
  "react": "^18.3.1",
41
33
  "react-dom": "^18.3.1",
42
- "@powerhousedao/codegen": "0.32.1",
43
- "@powerhousedao/config": "1.14.0",
44
- "@powerhousedao/design-system": "1.22.1",
45
- "@powerhousedao/scalars": "1.21.0",
46
- "@powerhousedao/reactor-local": "1.17.0",
47
- "document-model-libs": "1.129.0"
34
+ "@powerhousedao/codegen": "0.33.0",
35
+ "@powerhousedao/design-system": "1.23.0",
36
+ "@powerhousedao/connect": "1.0.0-dev.198",
37
+ "@powerhousedao/reactor-local": "1.19.0",
38
+ "@powerhousedao/config": "1.16.0",
39
+ "@powerhousedao/scalars": "1.22.0",
40
+ "document-model-libs": "1.131.0"
48
41
  },
49
42
  "scripts": {
50
43
  "build": "tsup",
package/dist/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import '@powerhousedao/config/powerhouse';
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli.ts"],"names":[],"mappings":";;;;AAIA,MAAM,OAAA,GAAU,IAAI,OAAQ,EAAA;AAE5B,OAAA,CACG,KAAK,QAAQ,CAAA,CACb,YAAY,6BAA6B,CAAA,CACzC,QAAQ,OAAO,CAAA;AAElB,gBAAA,CAAiB,OAAO,CAAA;AAExB,OAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA","file":"cli.js","sourcesContent":["#!/usr/bin/env node\nimport { Command } from \"commander\";\nimport registerCommands from \"./commands/index.js\";\n\nconst program = new Command();\n\nprogram\n .name(\"ph-cli\")\n .description(\"CLI tool for Powerhouse DAO\")\n .version(\"1.0.0\");\n\nregisterCommands(program);\n\nprogram.parse(process.argv);\n"]}
@@ -1,8 +0,0 @@
1
- import { ConnectStudioOptions } from '@powerhousedao/connect';
2
- import { Command } from 'commander';
3
-
4
- type ConnectOptions = ConnectStudioOptions;
5
- declare function startConnect(connectOptions: ConnectOptions): Promise<void | undefined>;
6
- declare function connectCommand(program: Command): void;
7
-
8
- export { type ConnectOptions, connectCommand, startConnect };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/commands/connect.ts"],"names":[],"mappings":";;;AASA,eAAsB,aAAa,cAAgC,EAAA;AACjE,EAAA,MAAM,EAAE,iBAAA,EAAmB,UAAW,EAAA,GAAI,SAAU,EAAA;AACpD,EAAA,MAAM,OAAU,GAAA,EAAE,iBAAmB,EAAA,UAAA,EAAY,GAAG,cAAe,EAAA;AACnE,EAAO,OAAA,MAAM,mBAAmB,OAAO,CAAA;AACzC;AAEO,SAAS,eAAe,OAAkB,EAAA;AAC/C,EACG,OAAA,CAAA,OAAA,CAAQ,SAAS,CACjB,CAAA,WAAA,CAAY,uBAAuB,CACnC,CAAA,MAAA,CAAO,mBAAqB,EAAA,2BAAA,EAA6B,MAAM,CAAA,CAC/D,OAAO,YAAc,EAAA,kCAAkC,EACvD,MAAO,CAAA,SAAA,EAAW,cAAc,CAChC,CAAA,MAAA,CAAO,QAAU,EAAA,kBAAkB,CACnC,CAAA,MAAA;AAAA,IACC,4BAAA;AAAA,IACA;AAAA,GAED,CAAA,MAAA;AAAA,IACC,qCAAA;AAAA,IACA;AAAA,GAED,CAAA,MAAA;AAAA,IACC,yCAAA;AAAA,IACA;AAAA,GACF,CACC,MAAO,CAAA,OAAA,GAAU,IAA2B,KAAA;AAC3C,IAAA,MAAM,cAAiB,GAAA,IAAA,CAAK,EAAG,CAAA,CAAC,KAAK,EAAC;AACtC,IAAA,MAAM,EAAE,iBAAmB,EAAA,UAAA,EAAY,QAAU,EAAA,MAAA,KAAW,SAAU,EAAA;AAEtE,IAAA,MAAM,kBAAmB,CAAA;AAAA,MACvB,IAAM,EAAA,MAAA,EAAQ,IAAM,EAAA,QAAA,EAAc,IAAA,KAAA,CAAA;AAAA,MAClC,QAAA;AAAA,MACA,gBAAgB,iBAAqB,IAAA,KAAA,CAAA;AAAA,MACrC,cAAc,UAAc,IAAA,KAAA,CAAA;AAAA,MAC5B,MAAM,MAAQ,EAAA,WAAA;AAAA,MACd,GAAG;AAAA,KACJ,CAAA;AAAA,GACF,CAAA;AACL;AAEA,IAAI,OAAQ,CAAA,IAAA,CAAK,EAAG,CAAA,CAAC,MAAM,OAAS,EAAA;AAClC,EAAA,MAAM,UAAa,GAAA,OAAA,CAAQ,IAAK,CAAA,EAAA,CAAG,CAAC,CAAA;AACpC,EAAA,MAAM,UAAU,UAAc,GAAA,IAAA,CAAK,KAAM,CAAA,UAAU,IAAuB,EAAC;AAC3E,EAAA,YAAA,CAAa,OAAO,CAAA,CAAE,KAAM,CAAA,CAAC,CAAe,KAAA;AAC1C,IAAM,MAAA,CAAA;AAAA,GACP,CAAA;AACH","file":"connect.js","sourcesContent":["import {\n startConnectStudio,\n ConnectStudioOptions,\n} from \"@powerhousedao/connect\";\nimport { getConfig } from \"@powerhousedao/config/powerhouse\";\nimport { Command } from \"commander\";\n\nexport type ConnectOptions = ConnectStudioOptions;\n\nexport async function startConnect(connectOptions: ConnectOptions) {\n const { documentModelsDir, editorsDir } = getConfig();\n const options = { documentModelsDir, editorsDir, ...connectOptions };\n return await startConnectStudio(options);\n}\n\nexport function connectCommand(program: Command) {\n program\n .command(\"connect\")\n .description(\"Starts Connect Studio\")\n .option(\"-p, --port <port>\", \"Port to run the server on\", \"3000\")\n .option(\"-h, --host\", \"Expose the server to the network\")\n .option(\"--https\", \"Enable HTTPS\")\n .option(\"--open\", \"Open the browser\")\n .option(\n \"--config-file <configFile>\",\n \"Path to the powerhouse.config.js file\",\n )\n .option(\n \"-le, --local-editors <localEditors>\",\n \"Link local document editors path\",\n )\n .option(\n \"-ld, --local-documents <localDocuments>\",\n \"Link local documents path\",\n )\n .action(async (...args: [ConnectOptions]) => {\n const connectOptions = args.at(0) || {};\n const { documentModelsDir, editorsDir, packages, studio } = getConfig();\n\n await startConnectStudio({\n port: studio?.port?.toString() || undefined,\n packages,\n localDocuments: documentModelsDir || undefined,\n localEditors: editorsDir || undefined,\n open: studio?.openBrowser,\n ...connectOptions,\n });\n });\n}\n\nif (process.argv.at(2) === \"spawn\") {\n const optionsArg = process.argv.at(3);\n const options = optionsArg ? (JSON.parse(optionsArg) as ConnectOptions) : {};\n startConnect(options).catch((e: unknown) => {\n throw e;\n });\n}\n"]}
@@ -1,14 +0,0 @@
1
- import { Command } from 'commander';
2
- import { CommandActionType } from '../types.js';
3
-
4
- declare const dev: CommandActionType<[
5
- {
6
- generate?: boolean;
7
- watch?: boolean;
8
- reactorPort?: number;
9
- configFile?: string;
10
- }
11
- ]>;
12
- declare function devCommand(program: Command): void;
13
-
14
- export { dev, devCommand };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/commands/dev.ts"],"names":[],"mappings":";;;;;;AASA,MAAM,YACJ,MAAY,CAAA,IAAA,CAAA,OAAA,IAAW,QAAQ,aAAc,CAAA,MAAA,CA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AAA,CAAC,IAAiB,KAAA;AACxC,MAAQ,OAAA,CAAA,MAAA,CAAO,MAAM,GAAI,CAAA,CAAA,WAAA,EAAc,KAAK,QAAS,EAAC,EAAE,CAAC,CAAA;AAAA,KAC1D,CAAA;AAED,IAAM,KAAA,CAAA,EAAA,CAAG,OAAS,EAAA,CAAC,IAAS,KAAA;AAC1B,MAAQ,OAAA,CAAA,GAAA,CAAI,CAAoC,iCAAA,EAAA,IAAI,CAAE,CAAA,CAAA;AAAA,KACvD,CAAA;AAAA,GACF,CAAA;AACH;AAEO,MAAM,MAST,OAAO;AAAA,EACT,QAAA;AAAA,EACA,KAAA;AAAA,EACA,cAAc,qBAAsB,CAAA,IAAA;AAAA,EACpC;AACF,CAAM,KAAA;AACJ,EAAI,IAAA;AACF,IAAA,MAAM,EAAE,QAAA,EAAa,GAAA,MAAM,iBAAkB,CAAA;AAAA,MAC3C,QAAA;AAAA,MACA,IAAM,EAAA,WAAA;AAAA,MACN;AAAA,KACD,CAAA;AACD,IAAA,MAAM,YAAa,CAAA,EAAE,UAAW,EAAA,EAAG,QAAQ,CAAA;AAAA,WACpC,KAAO,EAAA;AACd,IAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AAAA;AAEvB;AAEO,SAAS,WAAW,OAAkB,EAAA;AAC3C,EAAA,OAAA,CACG,OAAQ,CAAA,KAAK,CACb,CAAA,WAAA,CAAY,wBAAwB,CAAA,CACpC,MAAO,CAAA,YAAA,EAAc,8CAA8C,CAAA,CACnE,MAAO,CAAA,uBAAA,EAAyB,6BAA6B,CAC7D,CAAA,MAAA;AAAA,IACC,4BAAA;AAAA,IACA;AAAA,GAED,CAAA,MAAA;AAAA,IACC,aAAA;AAAA,IACA;AAAA,GACF,CACC,OAAO,GAAG,CAAA;AACf","file":"dev.js","sourcesContent":["import path, { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { fork, ChildProcessWithoutNullStreams } from \"node:child_process\";\nimport { Command } from \"commander\";\nimport { blue, green, red } from \"colorette\";\nimport { CommandActionType } from \"../types.js\";\nimport { DefaultReactorOptions, type ReactorOptions } from \"./reactor.js\";\nimport { type ConnectOptions } from \"./connect.js\";\n\nconst __dirname =\n import.meta.dirname || dirname(fileURLToPath(import.meta.url));\n\nfunction spawnLocalReactor(options?: ReactorOptions) {\n const child = fork(\n path.join(__dirname, \"reactor.js\"),\n [\"spawn\", JSON.stringify(options)],\n { silent: true },\n ) as ChildProcessWithoutNullStreams;\n\n return new Promise<{ driveUrl: string }>((resolve) => {\n child.on(\"message\", (message) => {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n const text = message.toString();\n\n if (text.startsWith(\"driveUrl:\")) {\n const driveUrl = text.substring(\"driveUrl:\".length);\n resolve({ driveUrl });\n }\n });\n\n child.stdout.on(\"data\", (data: Buffer) => {\n const message = data.toString();\n const lines = message.split(\"\\n\").filter((line) => line.trim().length);\n for (const line of lines) {\n process.stdout.write(blue(`[Reactor]: ${line}\\n`));\n }\n });\n\n child.stderr.on(\"error\", (data: Buffer) => {\n process.stderr.write(red(`[Reactor]: ${data.toString()}`));\n });\n child.on(\"error\", (err) => {\n process.stderr.write(red(`[Reactor]: ${err}`));\n });\n\n child.on(\"exit\", (code) => {\n console.log(`Reactor process exited with code ${code}`);\n });\n });\n}\n\nasync function spawnConnect(\n options?: ConnectOptions,\n localReactorUrl?: string,\n) {\n const child = fork(\n path.join(__dirname, \"connect.js\"),\n [\"spawn\", JSON.stringify(options ?? {})],\n {\n silent: true,\n env: {\n ...process.env,\n // TODO add studio variables?\n LOCAL_DOCUMENT_MODELS: options?.localDocuments,\n LOCAL_DOCUMENT_EDITORS: options?.localEditors,\n PH_CONNECT_DEFAULT_DRIVES_URL: localReactorUrl,\n },\n },\n ) as ChildProcessWithoutNullStreams;\n\n return new Promise<void>((resolve) => {\n child.stdout.on(\"data\", (data: Buffer) => {\n resolve();\n process.stdout.write(green(`[Connect]: ${data.toString()}`));\n });\n\n child.stderr.on(\"data\", (data: Buffer) => {\n process.stderr.write(red(`[Connect]: ${data.toString()}`));\n });\n\n child.on(\"close\", (code) => {\n console.log(`Connect process exited with code ${code}`);\n });\n });\n}\n\nexport const dev: CommandActionType<\n [\n {\n generate?: boolean;\n watch?: boolean;\n reactorPort?: number;\n configFile?: string;\n },\n ]\n> = async ({\n generate,\n watch,\n reactorPort = DefaultReactorOptions.port,\n configFile,\n}) => {\n try {\n const { driveUrl } = await spawnLocalReactor({\n generate,\n port: reactorPort,\n watch,\n });\n await spawnConnect({ configFile }, driveUrl);\n } catch (error) {\n console.error(error);\n }\n};\n\nexport function devCommand(program: Command) {\n program\n .command(\"dev\")\n .description(\"Starts dev environment\")\n .option(\"--generate\", \"generate code when document model is updated\")\n .option(\"--reactor-port <port>\", \"port to use for the reactor\")\n .option(\n \"--config-file <configFile>\",\n \"Path to the powerhouse.config.js file\",\n )\n .option(\n \"-w, --watch\",\n \"if the reactor should watch for local changes to document models and processors\",\n )\n .action(dev);\n}\n"]}
@@ -1,22 +0,0 @@
1
- import { Command } from 'commander';
2
- import { CommandActionType } from '../types.js';
3
-
4
- declare const generate: CommandActionType<[
5
- string | undefined,
6
- {
7
- interactive?: boolean;
8
- editors?: string;
9
- processors?: string;
10
- documentModels?: string;
11
- skipFormat?: boolean;
12
- watch?: boolean;
13
- editor?: string;
14
- processor?: string;
15
- documentTypes?: string;
16
- processorType?: "analytics" | "operational";
17
- subgraph?: string;
18
- }
19
- ]>;
20
- declare function generateCommand(program: Command): void;
21
-
22
- export { generate, generateCommand };