@powerhousedao/ph-cli 0.33.1-dev.0 → 0.34.1-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.
- package/dist/package.json +51 -0
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +10 -0
- package/dist/src/commands/connect.d.ts +6 -0
- package/dist/src/commands/connect.d.ts.map +1 -0
- package/dist/src/commands/connect.js +44 -0
- package/dist/src/commands/dev.d.ts +14 -0
- package/dist/src/commands/dev.d.ts.map +1 -0
- package/dist/src/commands/dev.js +88 -0
- package/dist/src/commands/generate.d.ts +21 -0
- package/dist/src/commands/generate.d.ts.map +1 -0
- package/dist/src/commands/generate.js +74 -0
- package/dist/src/commands/help.d.ts +3 -0
- package/dist/src/commands/help.d.ts.map +1 -0
- package/dist/src/commands/help.js +8 -0
- package/dist/src/commands/index.d.ts +14 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +34 -0
- package/dist/src/commands/inspect.d.ts +10 -0
- package/dist/src/commands/inspect.d.ts.map +1 -0
- package/dist/src/commands/inspect.js +57 -0
- package/dist/src/commands/install.d.ts +15 -0
- package/dist/src/commands/install.d.ts.map +1 -0
- package/dist/src/commands/install.js +80 -0
- package/dist/src/commands/list.d.ts +9 -0
- package/dist/src/commands/list.d.ts.map +1 -0
- package/dist/src/commands/list.js +33 -0
- package/dist/src/commands/service.d.ts +5 -0
- package/dist/src/commands/service.d.ts.map +1 -0
- package/dist/src/commands/service.js +141 -0
- package/dist/src/commands/switchboard.d.ts +34 -0
- package/dist/src/commands/switchboard.d.ts.map +1 -0
- package/dist/src/commands/switchboard.js +82 -0
- package/dist/src/commands/uninstall.d.ts +15 -0
- package/dist/src/commands/uninstall.d.ts.map +1 -0
- package/dist/src/commands/uninstall.js +80 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/types.d.ts +2 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +1 -0
- package/dist/src/utils.d.ts +47 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +114 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +15 -15
- package/dist/chunk-3LA6D2BV.js +0 -109
- package/dist/chunk-4CHMELTF.js +0 -51
- package/dist/chunk-6VK3FH3G.js +0 -36
- package/dist/chunk-7FTFL36R.js +0 -52
- package/dist/chunk-ACKSBZXF.js +0 -85
- package/dist/chunk-D42NLWCH.js +0 -98
- package/dist/chunk-DYKO5D3K.js +0 -52
- package/dist/chunk-FEGQ7JEJ.js +0 -97
- package/dist/chunk-FFVIBNX6.js +0 -147
- package/dist/chunk-IFV5NKI4.js +0 -57
- package/dist/chunk-KPMNRIJU.js +0 -10
- package/dist/chunk-V725N3UP.js +0 -132
- package/dist/chunk-XYNGLOOS.js +0 -51
- package/dist/chunk-ZZ3KNXW6.js +0 -91
- package/dist/cli.js +0 -22
- package/dist/commands/connect.js +0 -8
- package/dist/commands/dev.js +0 -9
- package/dist/commands/generate.js +0 -8
- package/dist/commands/help.js +0 -6
- package/dist/commands/index.js +0 -68
- package/dist/commands/inspect.js +0 -9
- package/dist/commands/install.js +0 -11
- package/dist/commands/list.js +0 -9
- package/dist/commands/service.js +0 -8
- package/dist/commands/switchboard.js +0 -10
- package/dist/commands/uninstall.js +0 -11
- package/dist/index.js +0 -91
- package/dist/scripts/service-startup.sh +0 -7
- package/dist/scripts/service-unstartup.sh +0 -6
- package/dist/scripts/setup.sh +0 -24
- package/dist/types.js +0 -0
- package/dist/utils.js +0 -28
package/dist/chunk-FFVIBNX6.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
// src/commands/service.ts
|
|
2
|
-
import { getConfig } from "@powerhousedao/config/powerhouse";
|
|
3
|
-
import { Argument } from "commander";
|
|
4
|
-
import { execSync } from "node:child_process";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
import pm2 from "pm2";
|
|
8
|
-
var actions = ["start", "stop", "status", "list", "startup", "unstartup"];
|
|
9
|
-
var services = ["switchboard", "connect", "all"];
|
|
10
|
-
var switchboardPort = 8442;
|
|
11
|
-
var connectPort = 8443;
|
|
12
|
-
var manageService = async (action, service) => {
|
|
13
|
-
try {
|
|
14
|
-
const config = getConfig();
|
|
15
|
-
if (config.switchboard?.port) {
|
|
16
|
-
switchboardPort = config.switchboard.port;
|
|
17
|
-
}
|
|
18
|
-
if (config.studio?.port) {
|
|
19
|
-
connectPort = config.studio.port;
|
|
20
|
-
}
|
|
21
|
-
pm2.connect((err) => {
|
|
22
|
-
switch (action) {
|
|
23
|
-
case "start":
|
|
24
|
-
startServices(service);
|
|
25
|
-
break;
|
|
26
|
-
case "stop":
|
|
27
|
-
stopServices(service);
|
|
28
|
-
break;
|
|
29
|
-
case "startup":
|
|
30
|
-
startupServices();
|
|
31
|
-
break;
|
|
32
|
-
case "unstartup":
|
|
33
|
-
unstartupServices();
|
|
34
|
-
break;
|
|
35
|
-
default:
|
|
36
|
-
statusServices();
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error(error);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
function serviceCommand(program) {
|
|
45
|
-
program.command("service").description("Manage services").addArgument(new Argument("action").choices(actions).default("list")).addArgument(
|
|
46
|
-
new Argument("service").choices(services).argOptional().default("all")
|
|
47
|
-
).action(manageService);
|
|
48
|
-
}
|
|
49
|
-
function startServices(service) {
|
|
50
|
-
if (service === "switchboard" || service === "all") {
|
|
51
|
-
const switchboardOptions = {
|
|
52
|
-
name: "switchboard",
|
|
53
|
-
script: "npx ph-cli switchboard"
|
|
54
|
-
};
|
|
55
|
-
console.log("Starting Switchboard...");
|
|
56
|
-
pm2.start(switchboardOptions, (err) => {
|
|
57
|
-
if (err) {
|
|
58
|
-
console.log(err.name);
|
|
59
|
-
}
|
|
60
|
-
dumpServices();
|
|
61
|
-
});
|
|
62
|
-
console.log("Switchboard started");
|
|
63
|
-
}
|
|
64
|
-
if (service === "connect" || service === "all") {
|
|
65
|
-
const connectOptions = {
|
|
66
|
-
name: "connect",
|
|
67
|
-
script: "npx ph-cli connect",
|
|
68
|
-
args: ["--port", connectPort.toString()]
|
|
69
|
-
};
|
|
70
|
-
console.log("Starting connect...");
|
|
71
|
-
pm2.start(connectOptions, (err) => {
|
|
72
|
-
if (err) {
|
|
73
|
-
throw new Error(err.message);
|
|
74
|
-
}
|
|
75
|
-
dumpServices();
|
|
76
|
-
});
|
|
77
|
-
console.log("Connect started");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function dumpServices() {
|
|
81
|
-
pm2.dump((err) => {
|
|
82
|
-
if (err) {
|
|
83
|
-
throw new Error(err.message);
|
|
84
|
-
}
|
|
85
|
-
statusServices();
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
function stopServices(service) {
|
|
89
|
-
if (service === "all" || service === "connect") {
|
|
90
|
-
pm2.stop("connect", (err) => {
|
|
91
|
-
if (err) {
|
|
92
|
-
throw new Error(err.message);
|
|
93
|
-
}
|
|
94
|
-
dumpServices();
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
if (service === "all" || service === "switchboard") {
|
|
98
|
-
pm2.stop("switchboard", (err) => {
|
|
99
|
-
if (err) {
|
|
100
|
-
throw new Error(err.message);
|
|
101
|
-
}
|
|
102
|
-
dumpServices();
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function statusServices() {
|
|
107
|
-
pm2.list((err, list) => {
|
|
108
|
-
const formattedList = list.map((item) => {
|
|
109
|
-
return {
|
|
110
|
-
id: item.pm_id,
|
|
111
|
-
name: item.name,
|
|
112
|
-
pid: item.pid,
|
|
113
|
-
uptime: item.pm2_env?.pm_uptime,
|
|
114
|
-
restarts: item.pm2_env?.unstable_restarts,
|
|
115
|
-
status: item.pm2_env?.status,
|
|
116
|
-
mem: item.monit?.memory,
|
|
117
|
-
cpu: item.monit?.cpu
|
|
118
|
-
};
|
|
119
|
-
});
|
|
120
|
-
console.table(formattedList);
|
|
121
|
-
process.exit(0);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function startupServices() {
|
|
125
|
-
const dirname = import.meta.dirname || path.dirname(fileURLToPath(import.meta.url));
|
|
126
|
-
const scriptPath = path.join(dirname, "..", "scripts", "service-startup.sh");
|
|
127
|
-
const result = execSync(`bash ${scriptPath}`).toString();
|
|
128
|
-
console.log(result);
|
|
129
|
-
process.exit(0);
|
|
130
|
-
}
|
|
131
|
-
function unstartupServices() {
|
|
132
|
-
const dirname = import.meta.dirname || path.dirname(fileURLToPath(import.meta.url));
|
|
133
|
-
const scriptPath = path.join(
|
|
134
|
-
dirname,
|
|
135
|
-
"..",
|
|
136
|
-
"scripts",
|
|
137
|
-
"service-unstartup.sh"
|
|
138
|
-
);
|
|
139
|
-
const result = execSync(`bash ${scriptPath}`).toString();
|
|
140
|
-
console.log(result);
|
|
141
|
-
process.exit(0);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export {
|
|
145
|
-
manageService,
|
|
146
|
-
serviceCommand
|
|
147
|
-
};
|
package/dist/chunk-IFV5NKI4.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getProjectInfo
|
|
3
|
-
} from "./chunk-V725N3UP.js";
|
|
4
|
-
|
|
5
|
-
// src/commands/inspect.ts
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
var inspect = async (packageName, options) => {
|
|
8
|
-
if (options.debug) {
|
|
9
|
-
console.log(">>> command arguments", { options });
|
|
10
|
-
}
|
|
11
|
-
const projectInfo = getProjectInfo(options.debug);
|
|
12
|
-
if (options.debug) {
|
|
13
|
-
console.log("\n>>> projectInfo", projectInfo);
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
const manifest = await import(path.join(packageName, "manifest"));
|
|
17
|
-
console.log(manifest.name);
|
|
18
|
-
if (manifest.documentModels) {
|
|
19
|
-
console.log("\nDocument Models:");
|
|
20
|
-
manifest.documentModels.forEach((model) => {
|
|
21
|
-
console.log(`- ${model.name} (${model.id})`);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
if (manifest.editors) {
|
|
25
|
-
console.log("\nEditors:");
|
|
26
|
-
manifest.editors.forEach((editor) => {
|
|
27
|
-
console.log(`- ${editor.name} (${editor.id})`);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (manifest.processors) {
|
|
31
|
-
console.log("\nProcessors:");
|
|
32
|
-
manifest.processors.forEach((processor) => {
|
|
33
|
-
console.log(`- ${processor.name} (${processor.id})`);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
if (manifest.subgraphs) {
|
|
37
|
-
console.log("\nSubgraphs:");
|
|
38
|
-
manifest.subgraphs.forEach((subgraph) => {
|
|
39
|
-
console.log(`- ${subgraph.name} (${subgraph.id})`);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
} catch (e) {
|
|
43
|
-
if (options.debug) {
|
|
44
|
-
console.error(e);
|
|
45
|
-
} else {
|
|
46
|
-
console.log("No manifest found in the package");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
function inspectCommand(program) {
|
|
51
|
-
program.command("inspect").alias("is").description("Inspect a package").option("--debug", "Show additional logs").argument("<packageName>", "The name of the package to inspect").action(inspect);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export {
|
|
55
|
-
inspect,
|
|
56
|
-
inspectCommand
|
|
57
|
-
};
|
package/dist/chunk-KPMNRIJU.js
DELETED
package/dist/chunk-V725N3UP.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// src/utils.ts
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import path, { dirname } from "node:path";
|
|
5
|
-
import { getConfig } from "@powerhousedao/config/powerhouse";
|
|
6
|
-
var POWERHOUSE_CONFIG_FILE = "powerhouse.config.json";
|
|
7
|
-
var POWERHOUSE_GLOBAL_DIR = path.join(homedir(), ".ph");
|
|
8
|
-
var SUPPORTED_PACKAGE_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
|
|
9
|
-
var packageManagers = {
|
|
10
|
-
bun: {
|
|
11
|
-
globalPathRegexp: /[\\/].bun[\\/]/,
|
|
12
|
-
installCommand: "bun add {{dependency}}",
|
|
13
|
-
uninstallCommand: "bun remove {{dependency}}",
|
|
14
|
-
workspaceOption: "",
|
|
15
|
-
lockfile: "bun.lock"
|
|
16
|
-
},
|
|
17
|
-
pnpm: {
|
|
18
|
-
globalPathRegexp: /[\\/]pnpm[\\/]/,
|
|
19
|
-
installCommand: "pnpm add {{dependency}}",
|
|
20
|
-
uninstallCommand: "pnpm remove {{dependency}}",
|
|
21
|
-
workspaceOption: "--workspace-root",
|
|
22
|
-
lockfile: "pnpm-lock.yaml"
|
|
23
|
-
},
|
|
24
|
-
yarn: {
|
|
25
|
-
globalPathRegexp: /[\\/]yarn[\\/]/,
|
|
26
|
-
installCommand: "yarn add {{dependency}}",
|
|
27
|
-
uninstallCommand: "yarn remove {{dependency}}",
|
|
28
|
-
workspaceOption: "-W",
|
|
29
|
-
lockfile: "yarn.lock"
|
|
30
|
-
},
|
|
31
|
-
npm: {
|
|
32
|
-
installCommand: "npm install {{dependency}}",
|
|
33
|
-
uninstallCommand: "npm uninstall {{dependency}}",
|
|
34
|
-
workspaceOption: "",
|
|
35
|
-
lockfile: "package-lock.json"
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
function defaultPathValidation() {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
function isPowerhouseProject(dir) {
|
|
42
|
-
const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);
|
|
43
|
-
return fs.existsSync(powerhouseConfigPath);
|
|
44
|
-
}
|
|
45
|
-
function findNodeProjectRoot(dir, pathValidation = defaultPathValidation) {
|
|
46
|
-
const packageJsonPath = path.join(dir, "package.json");
|
|
47
|
-
if (fs.existsSync(packageJsonPath) && pathValidation(dir)) {
|
|
48
|
-
return dir;
|
|
49
|
-
}
|
|
50
|
-
const parentDir = dirname(dir);
|
|
51
|
-
if (parentDir === dir) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
return findNodeProjectRoot(parentDir, pathValidation);
|
|
55
|
-
}
|
|
56
|
-
function getProjectInfo(debug) {
|
|
57
|
-
const currentPath = process.cwd();
|
|
58
|
-
if (debug) {
|
|
59
|
-
console.log(">>> currentPath", currentPath);
|
|
60
|
-
}
|
|
61
|
-
const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);
|
|
62
|
-
if (!projectPath) {
|
|
63
|
-
return {
|
|
64
|
-
isGlobal: true,
|
|
65
|
-
path: POWERHOUSE_GLOBAL_DIR
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
isGlobal: false,
|
|
70
|
-
path: projectPath
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function getPackageManagerFromLockfile(dir) {
|
|
74
|
-
if (fs.existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {
|
|
75
|
-
return "pnpm";
|
|
76
|
-
} else if (fs.existsSync(path.join(dir, packageManagers.yarn.lockfile))) {
|
|
77
|
-
return "yarn";
|
|
78
|
-
} else if (fs.existsSync(path.join(dir, packageManagers.bun.lockfile))) {
|
|
79
|
-
return "bun";
|
|
80
|
-
}
|
|
81
|
-
return "npm";
|
|
82
|
-
}
|
|
83
|
-
function getPackageManagerFromPath(dir) {
|
|
84
|
-
const lowerCasePath = dir.toLowerCase();
|
|
85
|
-
if (packageManagers.bun.globalPathRegexp.test(lowerCasePath)) {
|
|
86
|
-
return "bun";
|
|
87
|
-
} else if (packageManagers.pnpm.globalPathRegexp.test(lowerCasePath)) {
|
|
88
|
-
return "pnpm";
|
|
89
|
-
} else if (packageManagers.yarn.globalPathRegexp.test(lowerCasePath)) {
|
|
90
|
-
return "yarn";
|
|
91
|
-
}
|
|
92
|
-
return "npm";
|
|
93
|
-
}
|
|
94
|
-
function updateConfigFile(dependencies, projectPath, task = "install") {
|
|
95
|
-
const configPath = path.join(projectPath, POWERHOUSE_CONFIG_FILE);
|
|
96
|
-
const isInstall = task === "install";
|
|
97
|
-
if (!fs.existsSync(configPath)) {
|
|
98
|
-
throw new Error(
|
|
99
|
-
`powerhouse.config.json file not found. projectPath: ${projectPath}`
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
const config = JSON.parse(
|
|
103
|
-
fs.readFileSync(configPath, "utf-8")
|
|
104
|
-
);
|
|
105
|
-
const mappedPackages = dependencies.map(
|
|
106
|
-
(dep) => ({
|
|
107
|
-
packageName: dep
|
|
108
|
-
})
|
|
109
|
-
);
|
|
110
|
-
const updatedConfig = {
|
|
111
|
-
...config,
|
|
112
|
-
packages: isInstall ? [...config.packages || [], ...mappedPackages] : [...config.packages || []].filter(
|
|
113
|
-
(pkg) => !dependencies.includes(pkg.packageName)
|
|
114
|
-
)
|
|
115
|
-
};
|
|
116
|
-
fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export {
|
|
120
|
-
POWERHOUSE_CONFIG_FILE,
|
|
121
|
-
POWERHOUSE_GLOBAL_DIR,
|
|
122
|
-
SUPPORTED_PACKAGE_MANAGERS,
|
|
123
|
-
packageManagers,
|
|
124
|
-
defaultPathValidation,
|
|
125
|
-
isPowerhouseProject,
|
|
126
|
-
findNodeProjectRoot,
|
|
127
|
-
getProjectInfo,
|
|
128
|
-
getPackageManagerFromLockfile,
|
|
129
|
-
getPackageManagerFromPath,
|
|
130
|
-
updateConfigFile,
|
|
131
|
-
getConfig
|
|
132
|
-
};
|
package/dist/chunk-XYNGLOOS.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// src/commands/connect.ts
|
|
2
|
-
import { getConfig } from "@powerhousedao/config/powerhouse";
|
|
3
|
-
import {
|
|
4
|
-
startConnectStudio
|
|
5
|
-
} from "@powerhousedao/connect";
|
|
6
|
-
|
|
7
|
-
// package.json
|
|
8
|
-
var version = "0.32.1-dev.0";
|
|
9
|
-
|
|
10
|
-
// src/commands/connect.ts
|
|
11
|
-
async function startConnect(connectOptions) {
|
|
12
|
-
const { documentModelsDir, editorsDir } = getConfig();
|
|
13
|
-
const options = { documentModelsDir, editorsDir, ...connectOptions };
|
|
14
|
-
return await startConnectStudio(options);
|
|
15
|
-
}
|
|
16
|
-
function connectCommand(program) {
|
|
17
|
-
program.command("connect").description("Starts Connect Studio").option("-p, --port <port>", "Port to run the server on", "3000").option("-h, --host", "Expose the server to the network").option("--https", "Enable HTTPS").option("--open", "Open the browser").option(
|
|
18
|
-
"--config-file <configFile>",
|
|
19
|
-
"Path to the powerhouse.config.js file"
|
|
20
|
-
).option(
|
|
21
|
-
"-le, --local-editors <localEditors>",
|
|
22
|
-
"Link local document editors path"
|
|
23
|
-
).option(
|
|
24
|
-
"-ld, --local-documents <localDocuments>",
|
|
25
|
-
"Link local documents path"
|
|
26
|
-
).action(async (...args) => {
|
|
27
|
-
const connectOptions = args.at(0) || {};
|
|
28
|
-
const { documentModelsDir, editorsDir, packages, studio } = getConfig();
|
|
29
|
-
await startConnectStudio({
|
|
30
|
-
port: studio?.port?.toString() || void 0,
|
|
31
|
-
packages,
|
|
32
|
-
phCliVersion: typeof version === "string" ? version : void 0,
|
|
33
|
-
localDocuments: documentModelsDir || void 0,
|
|
34
|
-
localEditors: editorsDir || void 0,
|
|
35
|
-
open: studio?.openBrowser,
|
|
36
|
-
...connectOptions
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
if (process.argv.at(2) === "spawn") {
|
|
41
|
-
const optionsArg = process.argv.at(3);
|
|
42
|
-
const options = optionsArg ? JSON.parse(optionsArg) : {};
|
|
43
|
-
startConnect(options).catch((e) => {
|
|
44
|
-
throw e;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
startConnect,
|
|
50
|
-
connectCommand
|
|
51
|
-
};
|
package/dist/chunk-ZZ3KNXW6.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// src/commands/switchboard.ts
|
|
2
|
-
import { generateFromFile } from "@powerhousedao/codegen";
|
|
3
|
-
import { getConfig } from "@powerhousedao/config/powerhouse";
|
|
4
|
-
import {
|
|
5
|
-
DefaultStartServerOptions,
|
|
6
|
-
startServer
|
|
7
|
-
} from "@powerhousedao/reactor-local";
|
|
8
|
-
var DefaultSwitchboardOptions = {
|
|
9
|
-
...DefaultStartServerOptions,
|
|
10
|
-
dev: true
|
|
11
|
-
};
|
|
12
|
-
async function startLocalSwitchboard(switchboardOptions) {
|
|
13
|
-
const baseConfig = getConfig(switchboardOptions.configFile);
|
|
14
|
-
const options = {
|
|
15
|
-
...DefaultSwitchboardOptions,
|
|
16
|
-
...switchboardOptions
|
|
17
|
-
};
|
|
18
|
-
const https = switchboardOptions.httpsKeyFile && switchboardOptions.httpsCertFile ? {
|
|
19
|
-
keyPath: switchboardOptions.httpsKeyFile,
|
|
20
|
-
certPath: switchboardOptions.httpsCertFile
|
|
21
|
-
} : void 0;
|
|
22
|
-
const reactor = await startServer({ ...options, https });
|
|
23
|
-
if (options.generate) {
|
|
24
|
-
await addGenerateTransmitter(reactor, baseConfig);
|
|
25
|
-
}
|
|
26
|
-
return reactor;
|
|
27
|
-
}
|
|
28
|
-
async function addGenerateTransmitter(reactor, config) {
|
|
29
|
-
return reactor.addListener(
|
|
30
|
-
"powerhouse",
|
|
31
|
-
{
|
|
32
|
-
onStrands: async function(strands) {
|
|
33
|
-
const documentPaths = /* @__PURE__ */ new Set();
|
|
34
|
-
for (const strand of strands) {
|
|
35
|
-
documentPaths.add(
|
|
36
|
-
reactor.getDocumentPath(strand.driveId, strand.documentId)
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
for (const path of documentPaths) {
|
|
40
|
-
await generateFromFile(path, config);
|
|
41
|
-
}
|
|
42
|
-
return Promise.resolve();
|
|
43
|
-
},
|
|
44
|
-
onDisconnect: () => Promise.resolve()
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
filter: {
|
|
48
|
-
documentType: ["powerhouse/document-model"],
|
|
49
|
-
scope: ["global"],
|
|
50
|
-
branch: ["*"],
|
|
51
|
-
documentId: ["*"]
|
|
52
|
-
},
|
|
53
|
-
block: false,
|
|
54
|
-
listenerId: "reactor-local-document-model-generator",
|
|
55
|
-
label: "reactor-local-document-model-generator"
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
var switchboard = (options) => {
|
|
60
|
-
return startLocalSwitchboard(options);
|
|
61
|
-
};
|
|
62
|
-
function reactorCommand(program) {
|
|
63
|
-
program.command("switchboard").alias("reactor").description("Starts local switchboard").option("--port <PORT>", "port to host the api", "4001").option(
|
|
64
|
-
"--config-file <configFile>",
|
|
65
|
-
"Path to the powerhouse.config.js file",
|
|
66
|
-
"./powerhouse.config.json"
|
|
67
|
-
).option("--generate", "generate code when document model is updated").option("--db-path <DB_PATH>", "path to the database").option("--https-key-file <HTTPS_KEY_FILE>", "path to the ssl key file").option("--https-cert-file <HTTPS_CERT_FILE>", "path to the ssl cert file").option(
|
|
68
|
-
"-w, --watch",
|
|
69
|
-
"if the reactor should watch for local changes to document models and processors"
|
|
70
|
-
).option(
|
|
71
|
-
"--packages <packages...>",
|
|
72
|
-
"list of packages to be loaded, if defined then packages on config file are ignored"
|
|
73
|
-
).action(async (...args) => {
|
|
74
|
-
await switchboard(...args);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
if (process.argv.at(2) === "spawn") {
|
|
78
|
-
const optionsArg = process.argv.at(3);
|
|
79
|
-
const options = optionsArg ? JSON.parse(optionsArg) : {};
|
|
80
|
-
startLocalSwitchboard(options).then((switchboard2) => {
|
|
81
|
-
process.send?.(`driveUrl:${switchboard2.driveUrl}`);
|
|
82
|
-
}).catch((e) => {
|
|
83
|
-
throw e;
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export {
|
|
88
|
-
DefaultSwitchboardOptions,
|
|
89
|
-
switchboard,
|
|
90
|
-
reactorCommand
|
|
91
|
-
};
|
package/dist/cli.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
registerCommands
|
|
4
|
-
} from "./chunk-7FTFL36R.js";
|
|
5
|
-
import "./chunk-IFV5NKI4.js";
|
|
6
|
-
import "./chunk-FEGQ7JEJ.js";
|
|
7
|
-
import "./chunk-6VK3FH3G.js";
|
|
8
|
-
import "./chunk-FFVIBNX6.js";
|
|
9
|
-
import "./chunk-D42NLWCH.js";
|
|
10
|
-
import "./chunk-V725N3UP.js";
|
|
11
|
-
import "./chunk-4CHMELTF.js";
|
|
12
|
-
import "./chunk-3LA6D2BV.js";
|
|
13
|
-
import "./chunk-ZZ3KNXW6.js";
|
|
14
|
-
import "./chunk-ACKSBZXF.js";
|
|
15
|
-
import "./chunk-KPMNRIJU.js";
|
|
16
|
-
|
|
17
|
-
// src/cli.ts
|
|
18
|
-
import { Command } from "commander";
|
|
19
|
-
var program = new Command();
|
|
20
|
-
program.name("ph-cli").description("CLI tool for Powerhouse DAO").version("1.0.0");
|
|
21
|
-
registerCommands(program);
|
|
22
|
-
program.parse(process.argv);
|
package/dist/commands/connect.js
DELETED
package/dist/commands/dev.js
DELETED
package/dist/commands/help.js
DELETED
package/dist/commands/index.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
commands,
|
|
3
|
-
registerCommands
|
|
4
|
-
} from "../chunk-7FTFL36R.js";
|
|
5
|
-
import "../chunk-IFV5NKI4.js";
|
|
6
|
-
import {
|
|
7
|
-
install,
|
|
8
|
-
installCommand,
|
|
9
|
-
installDependency
|
|
10
|
-
} from "../chunk-FEGQ7JEJ.js";
|
|
11
|
-
import {
|
|
12
|
-
list,
|
|
13
|
-
listCommand
|
|
14
|
-
} from "../chunk-6VK3FH3G.js";
|
|
15
|
-
import {
|
|
16
|
-
manageService,
|
|
17
|
-
serviceCommand
|
|
18
|
-
} from "../chunk-FFVIBNX6.js";
|
|
19
|
-
import {
|
|
20
|
-
uninstall,
|
|
21
|
-
uninstallCommand,
|
|
22
|
-
uninstallDependency
|
|
23
|
-
} from "../chunk-D42NLWCH.js";
|
|
24
|
-
import "../chunk-V725N3UP.js";
|
|
25
|
-
import {
|
|
26
|
-
connectCommand,
|
|
27
|
-
startConnect
|
|
28
|
-
} from "../chunk-4CHMELTF.js";
|
|
29
|
-
import {
|
|
30
|
-
dev,
|
|
31
|
-
devCommand
|
|
32
|
-
} from "../chunk-3LA6D2BV.js";
|
|
33
|
-
import {
|
|
34
|
-
DefaultSwitchboardOptions,
|
|
35
|
-
reactorCommand,
|
|
36
|
-
switchboard
|
|
37
|
-
} from "../chunk-ZZ3KNXW6.js";
|
|
38
|
-
import {
|
|
39
|
-
generate,
|
|
40
|
-
generateCommand
|
|
41
|
-
} from "../chunk-ACKSBZXF.js";
|
|
42
|
-
import {
|
|
43
|
-
helpCommand
|
|
44
|
-
} from "../chunk-KPMNRIJU.js";
|
|
45
|
-
export {
|
|
46
|
-
DefaultSwitchboardOptions,
|
|
47
|
-
commands,
|
|
48
|
-
connectCommand,
|
|
49
|
-
registerCommands as default,
|
|
50
|
-
dev,
|
|
51
|
-
devCommand,
|
|
52
|
-
generate,
|
|
53
|
-
generateCommand,
|
|
54
|
-
helpCommand,
|
|
55
|
-
install,
|
|
56
|
-
installCommand,
|
|
57
|
-
installDependency,
|
|
58
|
-
list,
|
|
59
|
-
listCommand,
|
|
60
|
-
manageService,
|
|
61
|
-
reactorCommand,
|
|
62
|
-
serviceCommand,
|
|
63
|
-
startConnect,
|
|
64
|
-
switchboard,
|
|
65
|
-
uninstall,
|
|
66
|
-
uninstallCommand,
|
|
67
|
-
uninstallDependency
|
|
68
|
-
};
|
package/dist/commands/inspect.js
DELETED
package/dist/commands/install.js
DELETED
package/dist/commands/list.js
DELETED
package/dist/commands/service.js
DELETED