@powerhousedao/ph-cli 0.29.0 → 0.30.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/commands/reactor.js
CHANGED
|
@@ -7,47 +7,57 @@ const DefaultReactorOptions = {
|
|
|
7
7
|
dev: true
|
|
8
8
|
};
|
|
9
9
|
async function startLocalReactor(reactorOptions) {
|
|
10
|
-
const baseConfig = getConfig();
|
|
11
|
-
const options = {
|
|
10
|
+
const baseConfig = getConfig(reactorOptions.configFile);
|
|
11
|
+
const options = {
|
|
12
|
+
...DefaultReactorOptions,
|
|
13
|
+
packages: baseConfig.packages,
|
|
14
|
+
...reactorOptions
|
|
15
|
+
};
|
|
12
16
|
const reactor2 = await startServer(options);
|
|
13
17
|
if (options.generate) {
|
|
14
|
-
await reactor2
|
|
15
|
-
"powerhouse",
|
|
16
|
-
{
|
|
17
|
-
onStrands: async function(strands) {
|
|
18
|
-
const documentPaths = /* @__PURE__ */ new Set();
|
|
19
|
-
for (const strand of strands) {
|
|
20
|
-
documentPaths.add(
|
|
21
|
-
reactor2.getDocumentPath(strand.driveId, strand.documentId)
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
for (const path of documentPaths) {
|
|
25
|
-
await generateFromFile(path, baseConfig);
|
|
26
|
-
}
|
|
27
|
-
return Promise.resolve();
|
|
28
|
-
},
|
|
29
|
-
onDisconnect: () => Promise.resolve()
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
filter: {
|
|
33
|
-
documentType: ["powerhouse/document-model"],
|
|
34
|
-
scope: ["global"],
|
|
35
|
-
branch: ["*"],
|
|
36
|
-
documentId: ["*"]
|
|
37
|
-
},
|
|
38
|
-
block: false,
|
|
39
|
-
listenerId: "reactor-local-document-model-generator",
|
|
40
|
-
label: "reactor-local-document-model-generator"
|
|
41
|
-
}
|
|
42
|
-
);
|
|
18
|
+
await addGenerateTransmitter(reactor2, baseConfig);
|
|
43
19
|
}
|
|
44
20
|
return reactor2;
|
|
45
21
|
}
|
|
22
|
+
async function addGenerateTransmitter(reactor2, config) {
|
|
23
|
+
return reactor2.addListener(
|
|
24
|
+
"powerhouse",
|
|
25
|
+
{
|
|
26
|
+
onStrands: async function(strands) {
|
|
27
|
+
const documentPaths = /* @__PURE__ */ new Set();
|
|
28
|
+
for (const strand of strands) {
|
|
29
|
+
documentPaths.add(
|
|
30
|
+
reactor2.getDocumentPath(strand.driveId, strand.documentId)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
for (const path of documentPaths) {
|
|
34
|
+
await generateFromFile(path, config);
|
|
35
|
+
}
|
|
36
|
+
return Promise.resolve();
|
|
37
|
+
},
|
|
38
|
+
onDisconnect: () => Promise.resolve()
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
filter: {
|
|
42
|
+
documentType: ["powerhouse/document-model"],
|
|
43
|
+
scope: ["global"],
|
|
44
|
+
branch: ["*"],
|
|
45
|
+
documentId: ["*"]
|
|
46
|
+
},
|
|
47
|
+
block: false,
|
|
48
|
+
listenerId: "reactor-local-document-model-generator",
|
|
49
|
+
label: "reactor-local-document-model-generator"
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
46
53
|
const reactor = (options) => {
|
|
47
54
|
return startLocalReactor(options);
|
|
48
55
|
};
|
|
49
56
|
function reactorCommand(program) {
|
|
50
|
-
program.command("reactor").description("Starts local reactor").option("--port <PORT>", "port to host the api", "4001").option(
|
|
57
|
+
program.command("reactor").description("Starts local reactor").option("--port <PORT>", "port to host the api", "4001").option(
|
|
58
|
+
"--config-file <configFile>",
|
|
59
|
+
"Path to the powerhouse.config.js file"
|
|
60
|
+
).option("--generate", "generate code when document model is updated").option("--db-path <DB_PATH>", "path to the database").option(
|
|
51
61
|
"-w, --watch",
|
|
52
62
|
"if the reactor should watch for local changes to document models and processors"
|
|
53
63
|
).action(async (...args) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/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AA,CAAC,CAAe,KAAA;AACrB,IAAM,MAAA,CAAA;AAAA,GACP,CAAA;AACL","file":"reactor.js","sourcesContent":["import { Command } from \"commander\";\nimport {\n DefaultStartServerOptions,\n startServer,\n StartServerOptions,\n LocalReactor,\n} from \"@powerhousedao/reactor-local\";\nimport { generateFromFile } from \"@powerhousedao/codegen\";\nimport { CommandActionType } from \"../types.js\";\nimport { getConfig, PowerhouseConfig } from \"@powerhousedao/config/powerhouse\";\n\nexport type ReactorOptions = StartServerOptions & {\n configFile?: string;\n generate?: boolean;\n watch?: boolean;\n dbPath?: string;\n};\n\nexport const DefaultReactorOptions = {\n ...DefaultStartServerOptions,\n dev: true,\n};\n\nasync function startLocalReactor(reactorOptions: ReactorOptions) {\n const baseConfig = getConfig(reactorOptions.configFile);\n const options = {\n ...DefaultReactorOptions,\n packages: baseConfig.packages,\n ...reactorOptions,\n };\n\n const reactor = await startServer(options);\n\n if (options.generate) {\n await addGenerateTransmitter(reactor, baseConfig);\n }\n return reactor;\n}\n\nasync function addGenerateTransmitter(\n reactor: LocalReactor,\n config: PowerhouseConfig,\n) {\n return reactor.addListener(\n \"powerhouse\",\n {\n onStrands: async function (strands) {\n const documentPaths = new Set<string>();\n for (const strand of strands) {\n documentPaths.add(\n reactor.getDocumentPath(strand.driveId, strand.documentId),\n );\n }\n for (const path of documentPaths) {\n await generateFromFile(path, config);\n }\n return Promise.resolve();\n },\n onDisconnect: () => Promise.resolve(),\n },\n {\n filter: {\n documentType: [\"powerhouse/document-model\"],\n scope: [\"global\"],\n branch: [\"*\"],\n documentId: [\"*\"],\n },\n block: false,\n listenerId: \"reactor-local-document-model-generator\",\n label: \"reactor-local-document-model-generator\",\n },\n );\n}\n\nexport const reactor: CommandActionType<\n [ReactorOptions],\n Promise<LocalReactor>\n> = (options) => {\n return startLocalReactor(options);\n};\n\nexport function reactorCommand(program: Command) {\n program\n .command(\"reactor\")\n .description(\"Starts local reactor\")\n .option(\"--port <PORT>\", \"port to host the api\", \"4001\")\n .option(\n \"--config-file <configFile>\",\n \"Path to the powerhouse.config.js file\",\n )\n .option(\"--generate\", \"generate code when document model is updated\")\n .option(\"--db-path <DB_PATH>\", \"path to the database\")\n .option(\n \"-w, --watch\",\n \"if the reactor should watch for local changes to document models and processors\",\n )\n .action(async (...args: [ReactorOptions]) => {\n await reactor(...args);\n });\n}\n\nif (process.argv.at(2) === \"spawn\") {\n const optionsArg = process.argv.at(3);\n const options = optionsArg ? (JSON.parse(optionsArg) as ReactorOptions) : {};\n startLocalReactor(options)\n .then((reactor) => {\n process.send?.(`driveUrl:${reactor.driveUrl}`);\n })\n .catch((e: unknown) => {\n throw e;\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/ph-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -29,22 +29,22 @@
|
|
|
29
29
|
"graphql-tag": "^2.12.6",
|
|
30
30
|
"knex": "^3.1.0",
|
|
31
31
|
"luxon": "^3.5.0",
|
|
32
|
-
"document-drive": "1.16.
|
|
32
|
+
"document-drive": "1.16.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@powerhousedao/connect": "1.0.0-dev.
|
|
35
|
+
"@powerhousedao/connect": "1.0.0-dev.195",
|
|
36
36
|
"colorette": "^2.0.20",
|
|
37
37
|
"commander": "^12.1.0",
|
|
38
38
|
"graphql": "^16.9.0",
|
|
39
39
|
"pm2": "^5.4.3",
|
|
40
40
|
"react": "^18.3.1",
|
|
41
41
|
"react-dom": "^18.3.1",
|
|
42
|
-
"@powerhousedao/codegen": "0.32.
|
|
43
|
-
"@powerhousedao/
|
|
44
|
-
"@powerhousedao/
|
|
45
|
-
"@powerhousedao/
|
|
46
|
-
"@powerhousedao/
|
|
47
|
-
"document-model-libs": "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"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsup",
|