@powerhousedao/ph-cli 0.4.0 → 0.5.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/dev.d.ts +12 -0
- package/dist/commands/dev.js +63 -18
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/generate.d.ts +18 -0
- package/dist/commands/help.d.ts +5 -0
- package/dist/commands/index.d.ts +13 -0
- package/dist/commands/index.js +9 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.d.ts +12 -0
- package/dist/commands/reactor.d.ts +11 -0
- package/dist/commands/reactor.js +64 -0
- package/dist/commands/reactor.js.map +1 -0
- package/dist/index.d.ts +8 -36
- package/dist/types.d.ts +3 -0
- package/package.json +8 -6
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { CommandActionType } from '../types.js';
|
|
3
|
+
|
|
4
|
+
declare const dev: CommandActionType<[
|
|
5
|
+
{
|
|
6
|
+
projectPath?: string;
|
|
7
|
+
generate?: boolean;
|
|
8
|
+
}
|
|
9
|
+
]>;
|
|
10
|
+
declare function devCommand(program: Command): void;
|
|
11
|
+
|
|
12
|
+
export { dev, devCommand };
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,32 +1,77 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path, { dirname } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { fork, spawn } from 'node:child_process';
|
|
5
|
+
import { blue, red, green } from 'colorette';
|
|
5
6
|
|
|
6
7
|
const CONNECT_BIN_PATH = "node_modules/.bin/connect";
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const __dirname = import.meta.dirname || dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
function spawnLocalReactor(options) {
|
|
10
|
+
const child = fork(
|
|
11
|
+
path.join(__dirname, "reactor.js"),
|
|
12
|
+
["spawn", JSON.stringify(options)],
|
|
13
|
+
{ silent: true }
|
|
14
|
+
);
|
|
15
|
+
return new Promise((resolve) => {
|
|
16
|
+
child.stdout.on("data", (data) => {
|
|
17
|
+
const message = data.toString();
|
|
18
|
+
if (message.includes("All subgraphs started.")) {
|
|
19
|
+
resolve();
|
|
20
|
+
}
|
|
21
|
+
const lines = message.split("\n").filter((line) => line.trim().length);
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
process.stdout.write(blue(`[Reactor]: ${line}
|
|
24
|
+
`));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
child.stderr.on("error", (data) => {
|
|
28
|
+
process.stderr.write(red(`[Reactor]: ${data.toString()}`));
|
|
29
|
+
});
|
|
30
|
+
child.on("error", (err) => {
|
|
31
|
+
process.stderr.write(red(`[Reactor]: ${err}`));
|
|
32
|
+
});
|
|
33
|
+
child.on("close", (code) => {
|
|
34
|
+
console.log(`Reactor process exited with code ${code}`);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function spawnConnect(projectPath) {
|
|
10
39
|
let binPath = path.join(projectPath || ".", "node_modules/.bin/connect");
|
|
11
40
|
if (!fs.existsSync(binPath)) {
|
|
12
41
|
const packagePath = require.resolve("@powerhousedao/connect/package.json");
|
|
13
42
|
const packageDir = path.dirname(packagePath);
|
|
14
43
|
binPath = path.join(packageDir, CONNECT_BIN_PATH);
|
|
15
44
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
45
|
+
return new Promise((resolve) => {
|
|
46
|
+
const child = spawn(binPath, {
|
|
47
|
+
env: {
|
|
48
|
+
...process.env,
|
|
49
|
+
// TODO add studio variables?
|
|
50
|
+
PH_CONNECT_DEFAULT_DRIVES_URL: "http://localhost:4001/d/powerhouse"
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
child.stdout.on("data", (data) => {
|
|
54
|
+
resolve();
|
|
55
|
+
process.stdout.write(green(`[Connect]: ${data.toString()}`));
|
|
56
|
+
});
|
|
57
|
+
child.stderr.on("data", (data) => {
|
|
58
|
+
process.stderr.write(red(`[Connect]: ${data.toString()}`));
|
|
59
|
+
});
|
|
60
|
+
child.on("close", (code) => {
|
|
61
|
+
console.log(`Connect process exited with code ${code}`);
|
|
62
|
+
});
|
|
26
63
|
});
|
|
64
|
+
}
|
|
65
|
+
const dev = async ({ projectPath, generate }) => {
|
|
66
|
+
try {
|
|
67
|
+
await spawnLocalReactor({ generate });
|
|
68
|
+
await spawnConnect(projectPath);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error(error);
|
|
71
|
+
}
|
|
27
72
|
};
|
|
28
73
|
function devCommand(program) {
|
|
29
|
-
program.command("dev").description("Starts dev environment").option("--project-path <type>", "path to the project").action(dev);
|
|
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").action(dev);
|
|
30
75
|
}
|
|
31
76
|
|
|
32
77
|
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":[],"mappings":";;;;;;AAaA,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,SA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AA;AAAA,GACF,CAAA;AACH;AAEO,MAAM,GAET,GAAA,OAAO,EAAE,WAAA,EAAa,UAAe,KAAA;AACvC,EAAI,IAAA;AACF,IAAM,MAAA,iBAAA,CAAkB,EAAE,QAAA,EAAU,CAAA;AACpC,IAAA,MAAM,aAAa,WAAW,CAAA;AAAA,WACvB,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,CACpC,CAAA,MAAA,CAAO,uBAAyB,EAAA,qBAAqB,EACrD,MAAO,CAAA,YAAA,EAAc,8CAA8C,CAAA,CACnE,OAAO,GAAG,CAAA;AACf","file":"dev.js","sourcesContent":["import fs from \"node:fs\";\nimport path, { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\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 type { ReactorOptions } from \"./reactor.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<void>((resolve) => {\n child.stdout.on(\"data\", (data: Buffer) => {\n const message = data.toString();\n if (message.includes(\"All subgraphs started.\")) {\n resolve();\n }\n\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(projectPath?: string) {\n let binPath = path.join(projectPath || \".\", \"node_modules/.bin/connect\");\n\n if (!fs.existsSync(binPath)) {\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 PH_CONNECT_DEFAULT_DRIVES_URL: \"http://localhost:4001/d/powerhouse\",\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 [{ projectPath?: string; generate?: boolean }]\n> = async ({ projectPath, generate }) => {\n try {\n await spawnLocalReactor({ generate });\n await spawnConnect(projectPath);\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 .action(dev);\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
documentModels?: string;
|
|
10
|
+
skipFormat?: boolean;
|
|
11
|
+
watch?: boolean;
|
|
12
|
+
editor?: string;
|
|
13
|
+
documentTypes?: string;
|
|
14
|
+
}
|
|
15
|
+
]>;
|
|
16
|
+
declare function generateCommand(program: Command): void;
|
|
17
|
+
|
|
18
|
+
export { generate, generateCommand };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { initCommand } from './init.js';
|
|
3
|
+
export { init } from './init.js';
|
|
4
|
+
export { dev, devCommand } from './dev.js';
|
|
5
|
+
export { helpCommand } from './help.js';
|
|
6
|
+
export { generate, generateCommand } from './generate.js';
|
|
7
|
+
export { ReactorOptions, reactor, reactorCommand } from './reactor.js';
|
|
8
|
+
import '../types.js';
|
|
9
|
+
|
|
10
|
+
declare const commands: (typeof initCommand)[];
|
|
11
|
+
declare function registerCommands(program: Command): void;
|
|
12
|
+
|
|
13
|
+
export { commands, registerCommands as default, initCommand };
|
package/dist/commands/index.js
CHANGED
|
@@ -6,8 +6,16 @@ import { initCommand } from './init.js';
|
|
|
6
6
|
export * from './init.js';
|
|
7
7
|
import { generateCommand } from './generate.js';
|
|
8
8
|
export * from './generate.js';
|
|
9
|
+
import { reactorCommand } from './reactor.js';
|
|
10
|
+
export * from './reactor.js';
|
|
9
11
|
|
|
10
|
-
const commands = [
|
|
12
|
+
const commands = [
|
|
13
|
+
initCommand,
|
|
14
|
+
devCommand,
|
|
15
|
+
generateCommand,
|
|
16
|
+
reactorCommand,
|
|
17
|
+
helpCommand
|
|
18
|
+
];
|
|
11
19
|
function registerCommands(program) {
|
|
12
20
|
commands.forEach((command) => command(program));
|
|
13
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/commands/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAOO,MAAM,QAAW,GAAA;AAAA,EACtB,WAAA;AAAA,EACA,UAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF;AAEe,SAAR,iBAAkC,OAAkB,EAAA;AACzD,EAAA,QAAA,CAAS,OAAQ,CAAA,CAAC,OAAY,KAAA,OAAA,CAAQ,OAAO,CAAC,CAAA;AAChD","file":"index.js","sourcesContent":["import { Command } from \"commander\";\nimport { devCommand } from \"./dev.js\";\nimport { helpCommand } from \"./help.js\";\nimport { initCommand } from \"./init.js\";\nimport { generateCommand } from \"./generate.js\";\nimport { reactorCommand } from \"./reactor.js\";\n\nexport const commands = [\n initCommand,\n devCommand,\n generateCommand,\n reactorCommand,\n helpCommand,\n];\n\nexport default function registerCommands(program: Command) {\n commands.forEach((command) => command(program));\n}\n\nexport * from \"./dev.js\";\nexport * from \"./help.js\";\nexport * from \"./init.js\";\nexport * from \"./generate.js\";\nexport * from \"./reactor.js\";\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { CommandActionType } from '../types.js';
|
|
3
|
+
|
|
4
|
+
declare const init: CommandActionType<[
|
|
5
|
+
string | undefined,
|
|
6
|
+
{
|
|
7
|
+
interactive?: boolean;
|
|
8
|
+
}
|
|
9
|
+
]>;
|
|
10
|
+
declare function initCommand(program: Command): void;
|
|
11
|
+
|
|
12
|
+
export { init, initCommand };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { CommandActionType } from '../types.js';
|
|
3
|
+
|
|
4
|
+
type ReactorOptions = {
|
|
5
|
+
port?: number;
|
|
6
|
+
generate?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const reactor: CommandActionType<[ReactorOptions]>;
|
|
9
|
+
declare function reactorCommand(program: Command): void;
|
|
10
|
+
|
|
11
|
+
export { type ReactorOptions, reactor, reactorCommand };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { startServer } from '@powerhousedao/reactor-local';
|
|
4
|
+
import { getConfig, generateFromFile } from '@powerhousedao/codegen';
|
|
5
|
+
|
|
6
|
+
import.meta.dirname || path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const defaultReactorOptions = {
|
|
8
|
+
port: 4001,
|
|
9
|
+
generate: false
|
|
10
|
+
};
|
|
11
|
+
async function startLocalReactor(options = defaultReactorOptions) {
|
|
12
|
+
const { port, generate } = options;
|
|
13
|
+
const baseConfig = getConfig();
|
|
14
|
+
const reactor2 = await startServer({ connect: { port } });
|
|
15
|
+
if (!generate) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
await reactor2.addListener(
|
|
19
|
+
"powerhouse",
|
|
20
|
+
{
|
|
21
|
+
transmit: async function(strands) {
|
|
22
|
+
const documentPaths = /* @__PURE__ */ new Set();
|
|
23
|
+
for (const strand of strands) {
|
|
24
|
+
documentPaths.add(
|
|
25
|
+
reactor2.getDocumentPath(strand.driveId, strand.documentId)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
for (const path2 of documentPaths) {
|
|
29
|
+
await generateFromFile(path2, baseConfig);
|
|
30
|
+
}
|
|
31
|
+
return Promise.resolve();
|
|
32
|
+
},
|
|
33
|
+
disconnect: () => Promise.resolve()
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
filter: {
|
|
37
|
+
documentType: ["powerhouse/document-model"],
|
|
38
|
+
scope: ["global"],
|
|
39
|
+
branch: ["*"],
|
|
40
|
+
documentId: ["*"]
|
|
41
|
+
},
|
|
42
|
+
block: false,
|
|
43
|
+
listenerId: "reactor-local-document-model-generator",
|
|
44
|
+
label: "reactor-local-document-model-generator"
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
const reactor = (options) => {
|
|
49
|
+
return startLocalReactor(options);
|
|
50
|
+
};
|
|
51
|
+
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").action(reactor);
|
|
53
|
+
}
|
|
54
|
+
if (process.argv.at(2) === "spawn") {
|
|
55
|
+
const optionsArg = process.argv.at(3);
|
|
56
|
+
const options = optionsArg ? JSON.parse(optionsArg) : {};
|
|
57
|
+
startLocalReactor(options).catch((e) => {
|
|
58
|
+
throw e;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { reactor, reactorCommand };
|
|
63
|
+
//# sourceMappingURL=reactor.js.map
|
|
64
|
+
//# sourceMappingURL=reactor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/commands/reactor.ts"],"names":["reactor","path"],"mappings":";;;;;AAaE,YAAY,OAAW,IAAA,IAAA,CAAK,QAAQ,aAAc,CAAA,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC;AAEpE,MAAM,qBAAwC,GAAA;AAAA,EAC5C,IAAM,EAAA,IAAA;AAAA,EACN,QAAU,EAAA;AACZ,CAAA;AAEA,eAAe,iBAAA,CAAkB,UAAU,qBAAuB,EAAA;AAChE,EAAM,MAAA,EAAE,IAAM,EAAA,QAAA,EAAa,GAAA,OAAA;AAC3B,EAAA,MAAM,aAAa,SAAU,EAAA;AAC7B,EAAMA,MAAAA,QAAAA,GAAU,MAAM,WAAY,CAAA,EAAE,SAAS,EAAE,IAAA,IAAQ,CAAA;AAEvD,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAA;AAAA;AAGF,EAA4B,MAAMA,QAAQ,CAAA,WAAA;AAAA,IACxC,YAAA;AAAA,IACA;AAAA,MACE,QAAA,EAAU,eAAgB,OAAS,EAAA;AACjC,QAAM,MAAA,aAAA,uBAAoB,GAAY,EAAA;AACtC,QAAA,KAAA,MAAW,UAAU,OAAS,EAAA;AAC5B,UAAc,aAAA,CAAA,GAAA;AAAA,YACZA,QAAQ,CAAA,eAAA,CAAgB,MAAO,CAAA,OAAA,EAAS,OAAO,UAAU;AAAA,WAC3D;AAAA;AAEF,QAAA,KAAA,MAAWC,SAAQ,aAAe,EAAA;AAChC,UAAM,MAAA,gBAAA,CAAiBA,OAAM,UAAU,CAAA;AAAA;AAEzC,QAAA,OAAO,QAAQ,OAAQ,EAAA;AAAA,OACzB;AAAA,MACA,UAAA,EAAY,MAAM,OAAA,CAAQ,OAAQ;AAAA,KACpC;AAAA,IACA;AAAA,MACE,MAAQ,EAAA;AAAA,QACN,YAAA,EAAc,CAAC,2BAA2B,CAAA;AAAA,QAC1C,KAAA,EAAO,CAAC,QAAQ,CAAA;AAAA,QAChB,MAAA,EAAQ,CAAC,GAAG,CAAA;AAAA,QACZ,UAAA,EAAY,CAAC,GAAG;AAAA,OAClB;AAAA,MACA,KAAO,EAAA,KAAA;AAAA,MACP,UAAY,EAAA,wCAAA;AAAA,MACZ,KAAO,EAAA;AAAA;AACT;AAEJ;AAEa,MAAA,OAAA,GAA+C,CAAC,OAAY,KAAA;AACvE,EAAA,OAAO,kBAAkB,OAAO,CAAA;AAClC;AAEO,SAAS,eAAe,OAAkB,EAAA;AAC/C,EAAA,OAAA,CACG,QAAQ,SAAS,CAAA,CACjB,WAAY,CAAA,sBAAsB,EAClC,MAAO,CAAA,eAAA,EAAiB,sBAAwB,EAAA,MAAM,EACtD,MAAO,CAAA,YAAA,EAAc,8CAA8C,CAAA,CACnE,OAAO,OAAO,CAAA;AACnB;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,CAAE,KAAM,CAAA,CAAC,CAAM,KAAA;AACtC,IAAM,MAAA,CAAA;AAAA,GACP,CAAA;AACH","file":"reactor.js","sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport path from \"node:path\";\nimport { Command } from \"commander\";\nimport { startServer } from \"@powerhousedao/reactor-local\";\nimport { getConfig, generateFromFile } from \"@powerhousedao/codegen\";\nimport { CommandActionType } from \"../types.js\";\n\nexport type ReactorOptions = {\n port?: number;\n generate?: boolean;\n};\n\nconst __dirname =\n import.meta.dirname || path.dirname(fileURLToPath(import.meta.url));\n\nconst defaultReactorOptions: ReactorOptions = {\n port: 4001,\n generate: false,\n};\n\nasync function startLocalReactor(options = defaultReactorOptions) {\n const { port, generate } = options;\n const baseConfig = getConfig();\n const reactor = await startServer({ connect: { port } });\n\n if (!generate) {\n return;\n }\n\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\nexport const reactor: CommandActionType<[ReactorOptions]> = (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 .action(reactor);\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).catch((e) => {\n throw e;\n });\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
]>;
|
|
11
|
-
declare function initCommand(program: Command): void;
|
|
12
|
-
|
|
13
|
-
declare const dev: CommandActionType<[{
|
|
14
|
-
projectPath?: string;
|
|
15
|
-
}]>;
|
|
16
|
-
declare function devCommand(program: Command): void;
|
|
17
|
-
|
|
18
|
-
declare function helpCommand(program: Command): void;
|
|
19
|
-
|
|
20
|
-
declare const generate: CommandActionType<[
|
|
21
|
-
string | undefined,
|
|
22
|
-
{
|
|
23
|
-
interactive?: boolean;
|
|
24
|
-
editors?: string;
|
|
25
|
-
documentModels?: string;
|
|
26
|
-
skipFormat?: boolean;
|
|
27
|
-
watch?: boolean;
|
|
28
|
-
editor?: string;
|
|
29
|
-
documentTypes?: string;
|
|
30
|
-
}
|
|
31
|
-
]>;
|
|
32
|
-
declare function generateCommand(program: Command): void;
|
|
33
|
-
|
|
34
|
-
declare const commands: (typeof initCommand)[];
|
|
35
|
-
|
|
36
|
-
export { commands, dev, devCommand, generate, generateCommand, helpCommand, init, initCommand };
|
|
1
|
+
export { commands } from './commands/index.js';
|
|
2
|
+
export { dev, devCommand } from './commands/dev.js';
|
|
3
|
+
export { helpCommand } from './commands/help.js';
|
|
4
|
+
export { init, initCommand } from './commands/init.js';
|
|
5
|
+
export { generate, generateCommand } from './commands/generate.js';
|
|
6
|
+
export { ReactorOptions, reactor, reactorCommand } from './commands/reactor.js';
|
|
7
|
+
import 'commander';
|
|
8
|
+
import './types.js';
|
package/dist/types.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/ph-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
7
|
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
@@ -18,17 +18,19 @@
|
|
|
18
18
|
"keywords": [],
|
|
19
19
|
"author": "",
|
|
20
20
|
"devDependencies": {
|
|
21
|
+
"document-drive": "1.4.0",
|
|
21
22
|
"ts-node": "^10.9.2",
|
|
22
23
|
"tsup": "^8.3.0"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@powerhousedao/codegen": "0.14.
|
|
26
|
+
"@powerhousedao/codegen": "0.14.1",
|
|
26
27
|
"@powerhousedao/connect": "develop",
|
|
27
|
-
"@powerhousedao/design-system": "^1.7.
|
|
28
|
-
"@powerhousedao/
|
|
28
|
+
"@powerhousedao/design-system": "^1.7.2",
|
|
29
|
+
"@powerhousedao/reactor-local": "^1.4.0",
|
|
30
|
+
"@powerhousedao/scalars": "^1.9.0",
|
|
29
31
|
"colorette": "^2.0.20",
|
|
30
32
|
"commander": "^12.1.0",
|
|
31
|
-
"document-model-libs": "^1.110.
|
|
33
|
+
"document-model-libs": "^1.110.1",
|
|
32
34
|
"graphql": "^16.8.1",
|
|
33
35
|
"react": "^18.3.1",
|
|
34
36
|
"react-dom": "^18.3.1"
|