@powerhousedao/ph-cli 0.6.3 → 0.7.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.
@@ -6,11 +6,14 @@ declare const generate: CommandActionType<[
6
6
  {
7
7
  interactive?: boolean;
8
8
  editors?: string;
9
+ processors?: string;
9
10
  documentModels?: string;
10
11
  skipFormat?: boolean;
11
12
  watch?: boolean;
12
13
  editor?: string;
14
+ processor?: string;
13
15
  documentTypes?: string;
16
+ processorType?: "analytics" | "operational";
14
17
  }
15
18
  ]>;
16
19
  declare function generateCommand(program: Command): void;
@@ -1,4 +1,4 @@
1
- import { getConfig, promptDirectories, generateEditor, generateFromFile, generate as generate$1 } from '@powerhousedao/codegen';
1
+ import { getConfig, promptDirectories, generateEditor, generateProcessor, generateFromFile, generate as generate$1 } from '@powerhousedao/codegen';
2
2
 
3
3
  const generate = async (filePath, options) => {
4
4
  const baseConfig = getConfig();
@@ -6,6 +6,7 @@ const generate = async (filePath, options) => {
6
6
  ...baseConfig,
7
7
  ...{
8
8
  ...options.editors && { editorsDir: options.editors },
9
+ ...options.processors && { processorsDir: options.processors },
9
10
  ...options.documentModels && {
10
11
  documentModelsDir: options.documentModels
11
12
  },
@@ -17,7 +18,10 @@ const generate = async (filePath, options) => {
17
18
  const command = {
18
19
  editor: !!options.editor,
19
20
  editorName: options.editor,
20
- documentTypes: options.documentTypes
21
+ documentTypes: options.documentTypes,
22
+ processor: !!options.processor,
23
+ processorName: options.processor,
24
+ processorType: options.processorType
21
25
  };
22
26
  if (config.interactive) {
23
27
  const result = await promptDirectories(config);
@@ -34,6 +38,16 @@ const generate = async (filePath, options) => {
34
38
  );
35
39
  return;
36
40
  }
41
+ if (command.processor && options.processor) {
42
+ const processorType = options.processorType === "operational" ? "operational" : "analytics";
43
+ await generateProcessor(
44
+ options.processor,
45
+ processorType,
46
+ options.documentTypes?.split(",") ?? [],
47
+ config
48
+ );
49
+ return;
50
+ }
37
51
  if (filePath) {
38
52
  await generateFromFile(filePath, config);
39
53
  return;
@@ -41,7 +55,7 @@ const generate = async (filePath, options) => {
41
55
  await generate$1(config);
42
56
  };
43
57
  function generateCommand(program) {
44
- program.command("generate").description("Generate code from the document models").argument("[document-model-file]", "Path to the document model file").option("-i, --interactive", "Run the command in interactive mode").option("--editors <type>", "Path to the editors directory").option("-e, --editor <type>", "Editor Name").option("--document-models <type>", "Path to the document models directory").option("--document-types <type>", "Supported document types by the editor").option("-sf, --skip-format", "Skip formatting the generated code").option("-w, --watch", "Watch the generated code").action(generate);
58
+ program.command("generate").description("Generate code from the document models").argument("[document-model-file]", "Path to the document model file").option("-i, --interactive", "Run the command in interactive mode").option("--editors <type>", "Path to the editors directory").option("-e, --editor <type>", "Editor Name").option("--processors <type>", "Path to the processors directory").option("-p, --processor <type>", "Processor Name").option("--processor-type <type>", "Processor Type").option("--document-models <type>", "Path to the document models directory").option("--document-types <type>", "Supported document types by the editor").option("-sf, --skip-format", "Skip formatting the generated code").option("-w, --watch", "Watch the generated code").action(generate);
45
59
  }
46
60
 
47
61
  export { generate, generateCommand };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/generate.ts"],"names":["generateCode"],"mappings":";;AAUa,MAAA,QAAA,GAaT,OAAO,QAAA,EAAU,OAAY,KAAA;AAC/B,EAAA,MAAM,aAAa,SAAU,EAAA;AAE7B,EAAA,MAAM,MAAS,GAAA;AAAA,IACb,GAAG,UAAA;AAAA,IACH,GAAG;AAAA,MACD,GAAI,OAAQ,CAAA,OAAA,IAAW,EAAE,UAAA,EAAY,QAAQ,OAAQ,EAAA;AAAA,MACrD,GAAI,QAAQ,cAAkB,IAAA;AAAA,QAC5B,mBAAmB,OAAQ,CAAA;AAAA,OAC7B;AAAA,MACA,GAAI,OAAQ,CAAA,UAAA,IAAc,EAAE,UAAA,EAAY,QAAQ,UAAW,EAAA;AAAA,MAC3D,GAAI,OAAQ,CAAA,WAAA,IAAe,EAAE,WAAA,EAAa,QAAQ,WAAY,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AC1E,MAAO,CAAA,oBAAA,EAAsB,oCAAoC,CACjE,CAAA,MAAA,CAAO,eAAe,0BAA0B,CAAA,CAChD,OAAO,QAAQ,CAAA;AACpB","file":"generate.js","sourcesContent":["import { Command } from \"commander\";\nimport {\n getConfig,\n generate as generateCode,\n generateEditor,\n generateFromFile,\n promptDirectories,\n} from \"@powerhousedao/codegen\";\nimport { CommandActionType } from \"../types.js\";\n\nexport const generate: CommandActionType<\n [\n string | undefined,\n {\n interactive?: boolean;\n editors?: string;\n documentModels?: string;\n skipFormat?: boolean;\n watch?: boolean;\n editor?: string;\n documentTypes?: string;\n },\n ]\n> = async (filePath, options) => {\n const baseConfig = getConfig();\n\n const config = {\n ...baseConfig,\n ...{\n ...(options.editors && { editorsDir: options.editors }),\n ...(options.documentModels && {\n documentModelsDir: options.documentModels,\n }),\n ...(options.skipFormat && { skipFormat: options.skipFormat }),\n ...(options.interactive && { interactive: options.interactive }),\n ...(options.watch && { watch: options.watch }),\n },\n };\n\n const command = {\n editor: !!options.editor,\n editorName: options.editor,\n documentTypes: options.documentTypes,\n };\n\n if (config.interactive) {\n const result = await promptDirectories(config);\n Object.assign(config, result);\n }\n\n if (command.editor) {\n if (!command.editorName) {\n throw new Error(\"Editor name is required (--editor or -e)\");\n }\n await generateEditor(\n command.editorName,\n command.documentTypes?.split(/[|,;]/g) ?? [],\n config,\n );\n\n return;\n }\n\n if (filePath) {\n await generateFromFile(filePath, config);\n return;\n }\n\n await generateCode(config);\n};\n\nexport function generateCommand(program: Command) {\n program\n .command(\"generate\")\n .description(\"Generate code from the document models\")\n .argument(\"[document-model-file]\", \"Path to the document model file\")\n .option(\"-i, --interactive\", \"Run the command in interactive mode\")\n .option(\"--editors <type>\", \"Path to the editors directory\")\n .option(\"-e, --editor <type>\", \"Editor Name\")\n .option(\"--document-models <type>\", \"Path to the document models directory\")\n .option(\"--document-types <type>\", \"Supported document types by the editor\")\n .option(\"-sf, --skip-format\", \"Skip formatting the generated code\")\n .option(\"-w,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uC,CAC1E,CAAA,MAAA,CAAO,2BAA2B,wCAAwC,CAAA,CAC1E,MAAO,CAAA,oBAAA,EAAsB,oCAAoC,CAAA,CACjE,OAAO,aAAe,EAAA,0BAA0B,CAChD,CAAA,MAAA,CAAO,QAAQ,CAAA;AACpB","file":"generate.js","sourcesContent":["import {\n generate as generateCode,\n generateEditor,\n generateFromFile,\n generateProcessor,\n getConfig,\n promptDirectories,\n} from \"@powerhousedao/codegen\";\nimport { Command } from \"commander\";\nimport { CommandActionType } from \"../types.js\";\n\nexport const generate: CommandActionType<\n [\n string | undefined,\n {\n interactive?: boolean;\n editors?: string;\n processors?: string;\n documentModels?: string;\n skipFormat?: boolean;\n watch?: boolean;\n editor?: string;\n processor?: string;\n documentTypes?: string;\n processorType?: \"analytics\" | \"operational\";\n },\n ]\n> = async (filePath, options) => {\n const baseConfig = getConfig();\n\n const config = {\n ...baseConfig,\n ...{\n ...(options.editors && { editorsDir: options.editors }),\n ...(options.processors && { processorsDir: options.processors }),\n ...(options.documentModels && {\n documentModelsDir: options.documentModels,\n }),\n ...(options.skipFormat && { skipFormat: options.skipFormat }),\n ...(options.interactive && { interactive: options.interactive }),\n ...(options.watch && { watch: options.watch }),\n },\n };\n\n const command = {\n editor: !!options.editor,\n editorName: options.editor,\n documentTypes: options.documentTypes,\n processor: !!options.processor,\n processorName: options.processor,\n processorType: options.processorType,\n };\n\n if (config.interactive) {\n const result = await promptDirectories(config);\n Object.assign(config, result);\n }\n\n if (command.editor) {\n if (!command.editorName) {\n throw new Error(\"Editor name is required (--editor or -e)\");\n }\n await generateEditor(\n command.editorName,\n command.documentTypes?.split(/[|,;]/g) ?? [],\n config,\n );\n\n return;\n }\n\n if (command.processor && options.processor) {\n const processorType =\n options.processorType === \"operational\" ? \"operational\" : \"analytics\";\n await generateProcessor(\n options.processor,\n processorType,\n options.documentTypes?.split(\",\") ?? [],\n config,\n );\n return;\n }\n\n if (filePath) {\n await generateFromFile(filePath, config);\n return;\n }\n\n await generateCode(config);\n};\n\nexport function generateCommand(program: Command) {\n program\n .command(\"generate\")\n .description(\"Generate code from the document models\")\n .argument(\"[document-model-file]\", \"Path to the document model file\")\n .option(\"-i, --interactive\", \"Run the command in interactive mode\")\n .option(\"--editors <type>\", \"Path to the editors directory\")\n .option(\"-e, --editor <type>\", \"Editor Name\")\n .option(\"--processors <type>\", \"Path to the processors directory\")\n .option(\"-p, --processor <type>\", \"Processor Name\")\n .option(\"--processor-type <type>\", \"Processor Type\")\n .option(\"--document-models <type>\", \"Path to the document models directory\")\n .option(\"--document-types <type>\", \"Supported document types by the editor\")\n .option(\"-sf, --skip-format\", \"Skip formatting the generated code\")\n .option(\"-w, --watch\", \"Watch the generated code\")\n .action(generate);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-cli",
3
- "version": "0.6.3",
3
+ "version": "0.7.1",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -23,26 +23,32 @@
23
23
  "keywords": [],
24
24
  "author": "",
25
25
  "devDependencies": {
26
- "document-drive": "1.4.2",
27
- "ts-node": "^10.9.2",
28
- "tsup": "^8.3.0"
26
+ "@powerhousedao/analytics-engine-core": "^0.3.0",
27
+ "@powerhousedao/analytics-engine-graphql": "^0.2.0",
28
+ "@powerhousedao/analytics-engine-pg": "^0.3.0",
29
+ "drizzle-kit": "^0.25.0",
30
+ "drizzle-orm": "^0.34.1",
31
+ "luxon": "^3.5.0",
32
+ "tsup": "^8.3.0",
33
+ "tsx": "^4.19.1",
34
+ "document-drive": "1.5.0"
29
35
  },
30
36
  "dependencies": {
31
- "@powerhousedao/codegen": "0.16.0",
32
37
  "@powerhousedao/connect": "develop",
33
- "@powerhousedao/design-system": "^1.9.2",
34
- "@powerhousedao/reactor-local": "^1.5.3",
35
- "@powerhousedao/scalars": "^1.9.0",
36
38
  "colorette": "^2.0.20",
37
39
  "commander": "^12.1.0",
38
- "document-model-libs": "^1.116.0",
39
40
  "graphql": "^16.8.1",
40
41
  "react": "^18.3.1",
41
- "react-dom": "^18.3.1"
42
+ "react-dom": "^18.3.1",
43
+ "@powerhousedao/codegen": "0.17.0",
44
+ "@powerhousedao/reactor-local": "1.6.1",
45
+ "@powerhousedao/scalars": "1.9.0",
46
+ "document-model-libs": "1.117.0",
47
+ "@powerhousedao/design-system": "1.10.0"
42
48
  },
43
49
  "scripts": {
44
50
  "build": "tsup",
45
- "dev": "ts-node src/cli.ts",
51
+ "dev": "tsx src/cli.ts",
46
52
  "lint": "eslint",
47
53
  "lint:fix": "eslint --fix",
48
54
  "test": "echo \"Error: no test specified\" && exit 1"