@powerhousedao/ph-cli 0.5.2 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +1 -0
- package/dist/commands/dev.d.ts +2 -0
- package/dist/commands/dev.js +37 -10
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/index.d.ts +3 -1
- package/dist/commands/reactor.d.ts +26 -4
- package/dist/commands/reactor.js +48 -44
- package/dist/commands/reactor.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +3 -0
- package/dist/utils.js.map +1 -0
- package/package.json +9 -4
package/dist/cli.d.ts
CHANGED
package/dist/commands/dev.d.ts
CHANGED
package/dist/commands/dev.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path, { dirname } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
4
5
|
import { fork, spawn } from 'node:child_process';
|
|
5
6
|
import { blue, red, green } from 'colorette';
|
|
7
|
+
import { DefaultReactorOptions } from './reactor.js';
|
|
8
|
+
import { getConfig } from '../utils.js';
|
|
6
9
|
|
|
7
10
|
const CONNECT_BIN_PATH = "node_modules/.bin/connect";
|
|
8
11
|
const __dirname = import.meta.dirname || dirname(fileURLToPath(import.meta.url));
|
|
@@ -13,11 +16,15 @@ function spawnLocalReactor(options) {
|
|
|
13
16
|
{ silent: true }
|
|
14
17
|
);
|
|
15
18
|
return new Promise((resolve) => {
|
|
19
|
+
child.on("message", (message) => {
|
|
20
|
+
const text = message.toString();
|
|
21
|
+
if (text.startsWith("driveUrl:")) {
|
|
22
|
+
const driveUrl = text.substring("driveUrl:".length);
|
|
23
|
+
resolve({ driveUrl });
|
|
24
|
+
}
|
|
25
|
+
});
|
|
16
26
|
child.stdout.on("data", (data) => {
|
|
17
27
|
const message = data.toString();
|
|
18
|
-
if (message.includes("All subgraphs started.")) {
|
|
19
|
-
resolve();
|
|
20
|
-
}
|
|
21
28
|
const lines = message.split("\n").filter((line) => line.trim().length);
|
|
22
29
|
for (const line of lines) {
|
|
23
30
|
process.stdout.write(blue(`[Reactor]: ${line}
|
|
@@ -35,10 +42,11 @@ function spawnLocalReactor(options) {
|
|
|
35
42
|
});
|
|
36
43
|
});
|
|
37
44
|
}
|
|
38
|
-
async function spawnConnect(projectPath) {
|
|
45
|
+
async function spawnConnect(projectPath, options) {
|
|
39
46
|
let binPath = path.join(projectPath || ".", "node_modules/.bin/connect");
|
|
40
47
|
if (!fs.existsSync(binPath)) {
|
|
41
|
-
const
|
|
48
|
+
const require2 = createRequire(import.meta.url);
|
|
49
|
+
const packagePath = require2.resolve("@powerhousedao/connect/package.json");
|
|
42
50
|
const packageDir = path.dirname(packagePath);
|
|
43
51
|
binPath = path.join(packageDir, CONNECT_BIN_PATH);
|
|
44
52
|
}
|
|
@@ -47,7 +55,9 @@ async function spawnConnect(projectPath) {
|
|
|
47
55
|
env: {
|
|
48
56
|
...process.env,
|
|
49
57
|
// TODO add studio variables?
|
|
50
|
-
|
|
58
|
+
LOCAL_DOCUMENT_MODELS: options?.localDocumentModels,
|
|
59
|
+
LOCAL_DOCUMENT_EDITORS: options?.localEditors,
|
|
60
|
+
PH_CONNECT_DEFAULT_DRIVES_URL: options?.localReactorUrl
|
|
51
61
|
}
|
|
52
62
|
});
|
|
53
63
|
child.stdout.on("data", (data) => {
|
|
@@ -62,16 +72,33 @@ async function spawnConnect(projectPath) {
|
|
|
62
72
|
});
|
|
63
73
|
});
|
|
64
74
|
}
|
|
65
|
-
const dev = async ({
|
|
75
|
+
const dev = async ({
|
|
76
|
+
projectPath,
|
|
77
|
+
generate,
|
|
78
|
+
watch,
|
|
79
|
+
reactorPort = DefaultReactorOptions.port
|
|
80
|
+
}) => {
|
|
66
81
|
try {
|
|
67
|
-
|
|
68
|
-
await
|
|
82
|
+
const config = getConfig();
|
|
83
|
+
const { driveUrl } = await spawnLocalReactor({
|
|
84
|
+
generate,
|
|
85
|
+
port: reactorPort,
|
|
86
|
+
watch
|
|
87
|
+
});
|
|
88
|
+
await spawnConnect(projectPath, {
|
|
89
|
+
localDocumentModels: config.documentModelsDir,
|
|
90
|
+
localEditors: config.editorsDir,
|
|
91
|
+
localReactorUrl: driveUrl
|
|
92
|
+
});
|
|
69
93
|
} catch (error) {
|
|
70
94
|
console.error(error);
|
|
71
95
|
}
|
|
72
96
|
};
|
|
73
97
|
function devCommand(program) {
|
|
74
|
-
program.command("dev").description("Starts dev environment").option("--project-path <type>", "path to the project").option("--generate", "generate code when document model is updated").
|
|
98
|
+
program.command("dev").description("Starts dev environment").option("--project-path <type>", "path to the project").option("--generate", "generate code when document model is updated").option("--reactor-port <port>", "port to use for the reactor").option(
|
|
99
|
+
"-w, --watch",
|
|
100
|
+
"if the reactor should watch for local changes to document models and processors"
|
|
101
|
+
).action(dev);
|
|
75
102
|
}
|
|
76
103
|
|
|
77
104
|
export { dev, devCommand };
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/dev.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/commands/dev.ts"],"names":["require"],"mappings":";;;;;;;;;AAeA,MAAM,gBAAmB,GAAA,2BAAA;AACzB,MAAM,YACJ,MAAY,CAAA,IAAA,CAAA,OAAA,IAAW,QAAQ,aAAc,CAAA,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAE/D,SAAS,kBAAkB,OAA0B,EAAA;AACnD,EAAA,MAAM,KAAQ,GAAA,IAAA;AAAA,IACZ,IAAA,CAAK,IAAK,CAAA,SAAA,EAAW,YAAY,CAAA;AAAA,IACjC,CAAC,OAAA,EAAS,IAAK,CAAA,SAAA,CAAU,OAAO,CAAC,CAAA;AAAA,IACjC,EAAE,QAAQ,IAAK;AAAA,GACjB;AAE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js","sourcesContent":["import fs from \"node:fs\";\nimport path, { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { createRequire } from \"node:module\";\nimport {\n spawn,\n fork,\n ChildProcessWithoutNullStreams,\n} 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 { getConfig } from \"../utils.js\";\n\nconst CONNECT_BIN_PATH = \"node_modules/.bin/connect\";\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 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(\"close\", (code) => {\n console.log(`Reactor process exited with code ${code}`);\n });\n });\n}\n\nasync function spawnConnect(\n projectPath?: string,\n options?: {\n localDocumentModels?: string;\n localEditors?: string;\n localReactorUrl?: string;\n },\n) {\n let binPath = path.join(projectPath || \".\", \"node_modules/.bin/connect\");\n if (!fs.existsSync(binPath)) {\n const require = createRequire(import.meta.url);\n const packagePath = require.resolve(\"@powerhousedao/connect/package.json\");\n const packageDir = path.dirname(packagePath);\n\n binPath = path.join(packageDir, CONNECT_BIN_PATH);\n }\n\n return new Promise<void>((resolve) => {\n const child = spawn(binPath, {\n env: {\n ...process.env,\n // TODO add studio variables?\n LOCAL_DOCUMENT_MODELS: options?.localDocumentModels,\n LOCAL_DOCUMENT_EDITORS: options?.localEditors,\n PH_CONNECT_DEFAULT_DRIVES_URL: options?.localReactorUrl,\n },\n });\n\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 projectPath?: string;\n generate?: boolean;\n watch?: boolean;\n reactorPort?: number;\n },\n ]\n> = async ({\n projectPath,\n generate,\n watch,\n reactorPort = DefaultReactorOptions.port,\n}) => {\n try {\n const config = getConfig();\n const { driveUrl } = await spawnLocalReactor({\n generate,\n port: reactorPort,\n watch,\n });\n await spawnConnect(projectPath, {\n localDocumentModels: config.documentModelsDir,\n localEditors: config.editorsDir,\n localReactorUrl: driveUrl,\n });\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(\"--project-path <type>\", \"path to the project\")\n .option(\"--generate\", \"generate code when document model is updated\")\n .option(\"--reactor-port <port>\", \"port to use for the reactor\")\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"]}
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ export { init } from './init.js';
|
|
|
4
4
|
export { dev, devCommand } from './dev.js';
|
|
5
5
|
export { helpCommand } from './help.js';
|
|
6
6
|
export { generate, generateCommand } from './generate.js';
|
|
7
|
-
export { ReactorOptions, reactor, reactorCommand } from './reactor.js';
|
|
7
|
+
export { DefaultReactorOptions, ReactorOptions, reactor, reactorCommand } from './reactor.js';
|
|
8
|
+
import '@powerhousedao/codegen';
|
|
8
9
|
import '../types.js';
|
|
10
|
+
import '@powerhousedao/reactor-local';
|
|
9
11
|
|
|
10
12
|
declare const commands: (typeof initCommand)[];
|
|
11
13
|
declare function registerCommands(program: Command): void;
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { StartServerOptions, LocalReactor } from '@powerhousedao/reactor-local';
|
|
2
3
|
import { CommandActionType } from '../types.js';
|
|
3
4
|
|
|
4
|
-
type ReactorOptions = {
|
|
5
|
-
port?: number;
|
|
5
|
+
type ReactorOptions = StartServerOptions & {
|
|
6
6
|
generate?: boolean;
|
|
7
|
+
watch?: boolean;
|
|
7
8
|
};
|
|
8
|
-
declare const
|
|
9
|
+
declare const DefaultReactorOptions: {
|
|
10
|
+
dev: boolean;
|
|
11
|
+
port: number;
|
|
12
|
+
storagePath: string;
|
|
13
|
+
drive: {
|
|
14
|
+
global: {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
icon: string;
|
|
18
|
+
slug: string;
|
|
19
|
+
};
|
|
20
|
+
local: {
|
|
21
|
+
availableOffline: true;
|
|
22
|
+
listeners: never[];
|
|
23
|
+
sharingType: string;
|
|
24
|
+
triggers: never[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
declare const reactor: CommandActionType<[
|
|
29
|
+
ReactorOptions
|
|
30
|
+
], Promise<LocalReactor>>;
|
|
9
31
|
declare function reactorCommand(program: Command): void;
|
|
10
32
|
|
|
11
|
-
export { type ReactorOptions, reactor, reactorCommand };
|
|
33
|
+
export { DefaultReactorOptions, type ReactorOptions, reactor, reactorCommand };
|
package/dist/commands/reactor.js
CHANGED
|
@@ -1,64 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { startServer } from '@powerhousedao/reactor-local';
|
|
1
|
+
import { DefaultStartServerOptions, startServer } from '@powerhousedao/reactor-local';
|
|
4
2
|
import { getConfig, generateFromFile } from '@powerhousedao/codegen';
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
generate: false
|
|
4
|
+
const DefaultReactorOptions = {
|
|
5
|
+
...DefaultStartServerOptions,
|
|
6
|
+
dev: true
|
|
10
7
|
};
|
|
11
|
-
async function startLocalReactor(
|
|
12
|
-
const { port, generate } = options;
|
|
8
|
+
async function startLocalReactor(reactorOptions) {
|
|
13
9
|
const baseConfig = getConfig();
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
disconnect: () => Promise.resolve()
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
filter: {
|
|
37
|
-
documentType: ["powerhouse/document-model"],
|
|
38
|
-
scope: ["global"],
|
|
39
|
-
branch: ["*"],
|
|
40
|
-
documentId: ["*"]
|
|
10
|
+
const options = { ...DefaultReactorOptions, ...reactorOptions };
|
|
11
|
+
const reactor2 = await startServer(options);
|
|
12
|
+
if (options.generate) {
|
|
13
|
+
await reactor2.addListener(
|
|
14
|
+
"powerhouse",
|
|
15
|
+
{
|
|
16
|
+
transmit: async function(strands) {
|
|
17
|
+
const documentPaths = /* @__PURE__ */ new Set();
|
|
18
|
+
for (const strand of strands) {
|
|
19
|
+
documentPaths.add(
|
|
20
|
+
reactor2.getDocumentPath(strand.driveId, strand.documentId)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
for (const path of documentPaths) {
|
|
24
|
+
await generateFromFile(path, baseConfig);
|
|
25
|
+
}
|
|
26
|
+
return Promise.resolve();
|
|
27
|
+
},
|
|
28
|
+
disconnect: () => Promise.resolve()
|
|
41
29
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
{
|
|
31
|
+
filter: {
|
|
32
|
+
documentType: ["powerhouse/document-model"],
|
|
33
|
+
scope: ["global"],
|
|
34
|
+
branch: ["*"],
|
|
35
|
+
documentId: ["*"]
|
|
36
|
+
},
|
|
37
|
+
block: false,
|
|
38
|
+
listenerId: "reactor-local-document-model-generator",
|
|
39
|
+
label: "reactor-local-document-model-generator"
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return reactor2;
|
|
47
44
|
}
|
|
48
45
|
const reactor = (options) => {
|
|
49
46
|
return startLocalReactor(options);
|
|
50
47
|
};
|
|
51
48
|
function reactorCommand(program) {
|
|
52
|
-
program.command("reactor").description("Starts local reactor").option("--port <PORT>", "port to host the api", "4001").option("--generate", "generate code when document model is updated").
|
|
49
|
+
program.command("reactor").description("Starts local reactor").option("--port <PORT>", "port to host the api", "4001").option("--generate", "generate code when document model is updated").option(
|
|
50
|
+
"-w, --watch",
|
|
51
|
+
"if the reactor should watch for local changes to document models and processors"
|
|
52
|
+
).action(async (...args) => {
|
|
53
|
+
await reactor(...args);
|
|
54
|
+
});
|
|
53
55
|
}
|
|
54
56
|
if (process.argv.at(2) === "spawn") {
|
|
55
57
|
const optionsArg = process.argv.at(3);
|
|
56
58
|
const options = optionsArg ? JSON.parse(optionsArg) : {};
|
|
57
|
-
startLocalReactor(options).
|
|
59
|
+
startLocalReactor(options).then((reactor2) => {
|
|
60
|
+
process.send?.(`driveUrl:${reactor2.driveUrl}`);
|
|
61
|
+
}).catch((e) => {
|
|
58
62
|
throw e;
|
|
59
63
|
});
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
export { reactor, reactorCommand };
|
|
66
|
+
export { DefaultReactorOptions, reactor, reactorCommand };
|
|
63
67
|
//# sourceMappingURL=reactor.js.map
|
|
64
68
|
//# sourceMappingURL=reactor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/reactor.ts"],"names":["reactor"
|
|
1
|
+
{"version":3,"sources":["../../src/commands/reactor.ts"],"names":["reactor"],"mappings":";;;AAeO,MAAM,qBAAwB,GAAA;AAAA,EACnC,GAAG,yBAAA;AAAA,EACH,GAAK,EAAA;AACP;AAEA,eAAe,kBAAkB,cAAgC,EAAA;AAC/D,EAAA,MAAM,aAAa,SAAU,EAAA;AAC7B,EAAA,MAAM,OAAU,GAAA,EAAE,GAAG,qBAAA,EAAuB,GAAG,cAAe,EAAA;AAC9D,EAAMA,MAAAA,QAAAA,GAAU,MAAM,WAAA,CAAY,OAAO,CAAA;AAEzC,EAAA,IAAI,QAAQ,QAAU,EAAA;AACpB,IAA4B,MAAMA,QAAQ,CAAA,WAAA;AAAA,MACxC,YAAA;AAAA,MACA;AAAA,QACE,QAAA,EAAU,eAAgB,OAAS,EAAA;AACjC,UAAM,MAAA,aAAA,uBAAoB,GAAY,EAAA;AACtC,UAAA,KAAA,MAAW,UAAU,OAAS,EAAA;AAC5B,YAAc,aAAA,CAAA,GAAA;AAAA,cACZA,QAAQ,CAAA,eAAA,CAAgB,MAAO,CAAA,OAAA,EAAS,OAAO,UAAU;AAAA,aAC3D;AAAA;AAEF,UAAA,KAAA,MAAW,QAAQ,aAAe,EAAA;AAChC,YAAM,MAAA,gBAAA,CAAiB,MAAM,UAAU,CAAA;AAAA;AAEzC,UAAA,OAAO,QAAQ,OAAQ,EAAA;AAAA,SACzB;AAAA,QACA,UAAA,EAAY,MAAM,OAAA,CAAQ,OAAQ;AAAA,OACpC;AAAA,MACA;AAAA,QACE,MAAQ,EAAA;AAAA,UACN,YAAA,EAAc,CAAC,2BAA2B,CAAA;AAAA,UAC1C,KAAA,EAAO,CAAC,QAAQ,CAAA;AAAA,UAChB,MAAA,EAAQ,CAAC,GAAG,CAAA;AAAA,UACZ,UAAA,EAAY,CAAC,GAAG;AAAA,SAClB;AAAA,QACA,KAAO,EAAA,KAAA;AAAA,QACP,UAAY,EAAA,wCAAA;AAAA,QACZ,KAAO,EAAA;AAAA;AACT;AACF;AAEF,EAAOA,OAAAA,QAAAA;AACT;AAEa,MAAA,OAAA,GAGT,CAAC,OAAY,KAAA;AACf,EAAA,OAAO,kBAAkB,OAAO,CAAA;AAClC;AAEO,SAAS,eAAe,OAAkB,EAAA;AAC/C,EAAA,OAAA,CACG,OAAQ,CAAA,SAAS,CACjB,CAAA,WAAA,CAAY,sBAAsB,CAClC,CAAA,MAAA,CAAO,eAAiB,EAAA,sBAAA,EAAwB,MAAM,CAAA,CACtD,MAAO,CAAA,YAAA,EAAc,8CAA8C,CACnE,CAAA,MAAA;AAAA,IACC,aAAA;AAAA,IACA;AAAA,GACF,CACC,MAAO,CAAA,OAAA,GAAU,IAA2B,KAAA;AAC3C,IAAM,MAAA,OAAA,CAAQ,GAAG,IAAI,CAAA;AAAA,GACtB,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,iBAAA,CAAkB,OAAO,CAAA,CACtB,IAAK,CAAA,CAACA,QAAY,KAAA;AACjB,IAAA,OAAA,CAAQ,IAAO,GAAA,CAAA,SAAA,EAAYA,QAAQ,CAAA,QAAQ,CAAE,CAAA,CAAA;AAAA,GAC9C,CAAA,CACA,KAAM,CAAA,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 { getConfig, generateFromFile } from \"@powerhousedao/codegen\";\nimport { CommandActionType } from \"../types.js\";\n\nexport type ReactorOptions = StartServerOptions & {\n generate?: boolean;\n watch?: boolean;\n};\n\nexport const DefaultReactorOptions = {\n ...DefaultStartServerOptions,\n dev: true,\n};\n\nasync function startLocalReactor(reactorOptions: ReactorOptions) {\n const baseConfig = getConfig();\n const options = { ...DefaultReactorOptions, ...reactorOptions };\n const reactor = await startServer(options);\n\n if (options.generate) {\n const generateTransmitter = await reactor.addListener(\n \"powerhouse\",\n {\n transmit: 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, baseConfig);\n }\n return Promise.resolve();\n },\n disconnect: () => 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 return reactor;\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(\"--generate\", \"generate code when document model is updated\")\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/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { commands } from './commands/index.js';
|
|
2
|
+
export { getConfig } from '@powerhousedao/codegen';
|
|
2
3
|
export { dev, devCommand } from './commands/dev.js';
|
|
3
4
|
export { helpCommand } from './commands/help.js';
|
|
4
5
|
export { init, initCommand } from './commands/init.js';
|
|
5
6
|
export { generate, generateCommand } from './commands/generate.js';
|
|
6
|
-
export { ReactorOptions, reactor, reactorCommand } from './commands/reactor.js';
|
|
7
|
+
export { DefaultReactorOptions, ReactorOptions, reactor, reactorCommand } from './commands/reactor.js';
|
|
7
8
|
import 'commander';
|
|
8
9
|
import './types.js';
|
|
10
|
+
import '@powerhousedao/reactor-local';
|
package/dist/index.js
CHANGED
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getConfig } from '@powerhousedao/codegen';
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils.js","sourcesContent":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/ph-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"bin": {
|
|
13
13
|
"ph": "dist/cli.js"
|
|
14
14
|
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./dist/index.js",
|
|
17
|
+
"./cli": "./dist/cli.js",
|
|
18
|
+
"./utils": "./dist/utils.js"
|
|
19
|
+
},
|
|
15
20
|
"files": [
|
|
16
21
|
"dist"
|
|
17
22
|
],
|
|
@@ -25,12 +30,12 @@
|
|
|
25
30
|
"dependencies": {
|
|
26
31
|
"@powerhousedao/codegen": "0.14.1",
|
|
27
32
|
"@powerhousedao/connect": "develop",
|
|
28
|
-
"@powerhousedao/design-system": "^1.
|
|
29
|
-
"@powerhousedao/reactor-local": "^1.
|
|
33
|
+
"@powerhousedao/design-system": "^1.9.0",
|
|
34
|
+
"@powerhousedao/reactor-local": "^1.5.1",
|
|
30
35
|
"@powerhousedao/scalars": "^1.9.0",
|
|
31
36
|
"colorette": "^2.0.20",
|
|
32
37
|
"commander": "^12.1.0",
|
|
33
|
-
"document-model-libs": "^1.
|
|
38
|
+
"document-model-libs": "^1.114.0",
|
|
34
39
|
"graphql": "^16.8.1",
|
|
35
40
|
"react": "^18.3.1",
|
|
36
41
|
"react-dom": "^18.3.1"
|