@powerhousedao/ph-cli 6.2.3-dev.6 → 6.2.3-dev.61
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/{auth-AR3VxAIk.mjs → auth-BFUq7CvE.mjs} +3 -3
- package/dist/{auth-AR3VxAIk.mjs.map → auth-BFUq7CvE.mjs.map} +1 -1
- package/dist/auth-CNhbN5UM.mjs +4 -0
- package/dist/build-DmqwT-PR.mjs +4 -0
- package/dist/build-skPHsKkL.mjs +210 -0
- package/dist/build-skPHsKkL.mjs.map +1 -0
- package/dist/{cli-connect-override-D3hh4aH_.mjs → cli-connect-override-CuheCf3N.mjs} +38 -26
- package/dist/cli-connect-override-CuheCf3N.mjs.map +1 -0
- package/dist/cli.d.mts +2 -1
- package/dist/cli.mjs +31 -1175
- package/dist/cli.mjs.map +1 -1
- package/dist/connect-build-CyNALLxq.mjs +218 -0
- package/dist/connect-build-CyNALLxq.mjs.map +1 -0
- package/dist/{connect-config-BWGiW3IB.mjs → connect-config-B0WoJoZv.mjs} +19 -12
- package/dist/connect-config-B0WoJoZv.mjs.map +1 -0
- package/dist/connect-preview-Clue7SVp.mjs +122 -0
- package/dist/connect-preview-Clue7SVp.mjs.map +1 -0
- package/dist/{connect-studio-D6rfWCNB.mjs → connect-studio-B-HTpgG2.mjs} +15 -10
- package/dist/{connect-studio-D6rfWCNB.mjs.map → connect-studio-B-HTpgG2.mjs.map} +1 -1
- package/dist/connect-studio-ClS1PdVV.mjs +4 -0
- package/dist/dist-BsyiY0Fw.mjs +223 -0
- package/dist/dist-BsyiY0Fw.mjs.map +1 -0
- package/dist/explain-j11Vgf0Z.mjs +27 -0
- package/dist/explain-j11Vgf0Z.mjs.map +1 -0
- package/dist/feature-flags-xwqcHEWC.mjs +4 -0
- package/dist/{generate-all-DrT4ZxHX.mjs → generate-all-CRfVwLJ9.mjs} +5 -3
- package/dist/generate-all-CRfVwLJ9.mjs.map +1 -0
- package/dist/{generate-app-DNNqA-H3.mjs → generate-app-BTs1u-9l.mjs} +7 -5
- package/dist/{generate-app-DNNqA-H3.mjs.map → generate-app-BTs1u-9l.mjs.map} +1 -1
- package/dist/generate-desktop-shell-DFOsRPgq.mjs +212 -0
- package/dist/generate-desktop-shell-DFOsRPgq.mjs.map +1 -0
- package/dist/{generate-document-model-BJXyODfm.mjs → generate-document-model-ChkXjM1s.mjs} +19 -7
- package/dist/generate-document-model-ChkXjM1s.mjs.map +1 -0
- package/dist/{generate-editor-BejvaVVT.mjs → generate-editor-CW7Do69u.mjs} +7 -5
- package/dist/{generate-editor-BejvaVVT.mjs.map → generate-editor-CW7Do69u.mjs.map} +1 -1
- package/dist/generate-piece-QTt-ddt2.mjs +65 -0
- package/dist/generate-piece-QTt-ddt2.mjs.map +1 -0
- package/dist/generate-piece-action-DbxrzfKY.mjs +29 -0
- package/dist/generate-piece-action-DbxrzfKY.mjs.map +1 -0
- package/dist/generate-piece-trigger-CqVOcL9g.mjs +30 -0
- package/dist/generate-piece-trigger-CqVOcL9g.mjs.map +1 -0
- package/dist/{generate-processor-_WOx-mMe.mjs → generate-processor-DBtTkgo5.mjs} +15 -8
- package/dist/generate-processor-DBtTkgo5.mjs.map +1 -0
- package/dist/{generate-subgraph-BsHUstpl.mjs → generate-subgraph-DmcQWVbd.mjs} +12 -6
- package/dist/generate-subgraph-DmcQWVbd.mjs.map +1 -0
- package/dist/host-schemas-CL_wFpY7-BDyTA_z_.mjs +479 -0
- package/dist/host-schemas-CL_wFpY7-BDyTA_z_.mjs.map +1 -0
- package/dist/index-CApW1xbO.d.mts +3752 -0
- package/dist/index-CApW1xbO.d.mts.map +1 -0
- package/dist/{init-BZP6gvYd.mjs → init-ScuT3z7P.mjs} +7 -5
- package/dist/init-ScuT3z7P.mjs.map +1 -0
- package/dist/{inspect-DXjbQEV_.mjs → inspect-BpCB0TPo.mjs} +11 -4
- package/dist/inspect-BpCB0TPo.mjs.map +1 -0
- package/dist/install-added-dependencies-DVSbzler.mjs +33 -0
- package/dist/install-added-dependencies-DVSbzler.mjs.map +1 -0
- package/dist/{migrate-jGKfE02L.mjs → migrate-DK4HK7Dn.mjs} +4 -4
- package/dist/{migrate-jGKfE02L.mjs.map → migrate-DK4HK7Dn.mjs.map} +1 -1
- package/dist/ph-cli-commands-ByuH-lXH.mjs +1484 -0
- package/dist/ph-cli-commands-ByuH-lXH.mjs.map +1 -0
- package/dist/ph-cli-commands-sgvuh-kj.mjs +4 -0
- package/dist/plugins-PTnPaBIG.mjs +91 -0
- package/dist/plugins-PTnPaBIG.mjs.map +1 -0
- package/dist/reactor-env-BgyzjfYc.mjs +4 -0
- package/dist/reactor-env-Dx0Hxi5I.mjs +29 -0
- package/dist/reactor-env-Dx0Hxi5I.mjs.map +1 -0
- package/dist/{registry-auth-DxEWCJu2.mjs → registry-auth-Bm5AR-fB.mjs} +4 -4
- package/dist/{registry-auth-DxEWCJu2.mjs.map → registry-auth-Bm5AR-fB.mjs.map} +1 -1
- package/dist/run-sugar-D3C0Ptvv.mjs +39 -0
- package/dist/run-sugar-D3C0Ptvv.mjs.map +1 -0
- package/dist/runners/compound.d.mts +127 -0
- package/dist/runners/compound.d.mts.map +1 -0
- package/dist/runners/compound.mjs +72 -0
- package/dist/runners/compound.mjs.map +1 -0
- package/dist/runners/connect.d.mts +144 -0
- package/dist/runners/connect.d.mts.map +1 -0
- package/dist/runners/connect.mjs +185 -0
- package/dist/runners/connect.mjs.map +1 -0
- package/dist/runners/switchboard.d.mts +139 -0
- package/dist/runners/switchboard.d.mts.map +1 -0
- package/dist/runners/switchboard.mjs +142 -0
- package/dist/runners/switchboard.mjs.map +1 -0
- package/dist/schemas-BZZWQ72W.mjs +3962 -0
- package/dist/schemas-BZZWQ72W.mjs.map +1 -0
- package/dist/scripts/generate-commands-docs.ts +8 -0
- package/dist/scripts/manage-environment +0 -0
- package/dist/scripts/setup.sh +0 -0
- package/dist/start-run-1mjFpX7H.mjs +36 -0
- package/dist/start-run-1mjFpX7H.mjs.map +1 -0
- package/dist/superseded-config-9D7BdLvd.mjs +53 -0
- package/dist/superseded-config-9D7BdLvd.mjs.map +1 -0
- package/dist/switchboard-BUMqobK4.mjs +4 -0
- package/dist/{switchboard-migrate-NQ7LHWSi.mjs → switchboard-migrate-7JQZM7-5.mjs} +5 -4
- package/dist/{switchboard-migrate-NQ7LHWSi.mjs.map → switchboard-migrate-7JQZM7-5.mjs.map} +1 -1
- package/dist/{switchboard-reset-BcQXlcVf.mjs → switchboard-reset-CX_Lzw3O.mjs} +4 -4
- package/dist/{switchboard-reset-BcQXlcVf.mjs.map → switchboard-reset-CX_Lzw3O.mjs.map} +1 -1
- package/dist/switchboard-tQS3fhqa.mjs +132 -0
- package/dist/switchboard-tQS3fhqa.mjs.map +1 -0
- package/dist/{utils-BzwczAW-.mjs → utils-C3c5YG6v.mjs} +3 -3
- package/dist/{utils-C4isxXSO.mjs → utils-CvmDmCVd.mjs} +3 -3
- package/dist/{utils-C4isxXSO.mjs.map → utils-CvmDmCVd.mjs.map} +1 -1
- package/dist/{vetra-DkF6EJMY.mjs → vetra-BBcDGKgI.mjs} +66 -31
- package/dist/vetra-BBcDGKgI.mjs.map +1 -0
- package/dist/warn-subgraph-type-conflicts-Jd6SeN-M.mjs +19 -0
- package/dist/warn-subgraph-type-conflicts-Jd6SeN-M.mjs.map +1 -0
- package/package.json +42 -17
- package/dist/auth-BNkN6kS9.mjs +0 -4
- package/dist/build-C-A5-ipO.mjs +0 -4
- package/dist/build-uQXq6_HU.mjs +0 -71
- package/dist/build-uQXq6_HU.mjs.map +0 -1
- package/dist/cli-connect-override-D3hh4aH_.mjs.map +0 -1
- package/dist/connect-build-WL4axo4z.mjs +0 -43
- package/dist/connect-build-WL4axo4z.mjs.map +0 -1
- package/dist/connect-config-BWGiW3IB.mjs.map +0 -1
- package/dist/connect-preview-D7ypzFDc.mjs +0 -28
- package/dist/connect-preview-D7ypzFDc.mjs.map +0 -1
- package/dist/connect-studio-BIQzyq5B.mjs +0 -5
- package/dist/generate-all-DrT4ZxHX.mjs.map +0 -1
- package/dist/generate-document-model-BJXyODfm.mjs.map +0 -1
- package/dist/generate-processor-_WOx-mMe.mjs.map +0 -1
- package/dist/generate-subgraph-BsHUstpl.mjs.map +0 -1
- package/dist/init-BZP6gvYd.mjs.map +0 -1
- package/dist/inspect-DXjbQEV_.mjs.map +0 -1
- package/dist/switchboard-CJMoMzWx.mjs +0 -75
- package/dist/switchboard-CJMoMzWx.mjs.map +0 -1
- package/dist/switchboard-iRFugh8I.mjs +0 -4
- package/dist/vetra-DkF6EJMY.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-app-
|
|
1
|
+
{"version":3,"file":"generate-app-BTs1u-9l.mjs","sources":["../src/services/generate-app.ts"],"sourcesContent":["import { generateAllApps, generateApp } from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n getAppMetadata,\n} from \"@powerhousedao/codegen/utils\";\nimport {\n extractAppDocuments,\n generateAppFromDocument,\n getDocument,\n saveSpec,\n} from \"@powerhousedao/vetra/codegen\";\nimport type { AppModuleDocument } from \"@powerhousedao/vetra/document-models/app-module\";\nimport { dirname } from \"node:path\";\nimport type { GenerateAppArgs } from \"../types.js\";\n\nexport async function startGenerateApp(\n args: GenerateAppArgs,\n projectDir: string,\n) {\n const {\n name,\n allowedDocumentTypes = [],\n disableDragAndDrop,\n document,\n dir,\n all,\n extract,\n debug,\n } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n if (extract) {\n const docs = extractAppDocuments(project);\n for (const doc of docs) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n if (all) {\n await generateAllApps(project);\n } else if (document) {\n const doc = (await getDocument(document)) as AppModuleDocument;\n await generateAppFromDocument(doc, project);\n } else if (name) {\n await generateApp(\n {\n appName: name,\n allowedDocumentTypes,\n isDragAndDropEnabled: !disableDragAndDrop,\n },\n project,\n );\n } else if (dir) {\n const appMetadata = getAppMetadata(project, dirname(dir));\n if (!appMetadata) {\n throw new Error(`Failed to get data for app in dir \"${dir}\"`);\n }\n const {\n name: appName,\n id: appId,\n dirName: appDirName,\n allowedDocumentTypes,\n isDragAndDropEnabled,\n } = appMetadata;\n\n await generateApp(\n {\n appName,\n appId,\n appDirName,\n allowedDocumentTypes,\n isDragAndDropEnabled,\n },\n project,\n );\n } else {\n console.log(\n \"Please specify one of `name`, `document`, `dir`, `all`, or `extract`.\",\n );\n return;\n }\n await project.save();\n}\n"],"names":[],"mappings":";;;;;;;AAeA,eAAsB,iBACpB,MACA,YACA;CACA,MAAM,EACJ,MACA,uBAAuB,CAAC,GACxB,oBACA,UACA,KACA,KACA,SACA,UACE;CACJ,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,SAAS;EACX,MAAM,OAAO,oBAAoB,OAAO;EACxC,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,OAAO,MAAM,SAAS,KAAK,UAAU;GAC3C,QAAQ,IAAI,SAAS,MAAM;EAC7B;EACA;CACF;CACA,IAAI,KACF,MAAM,gBAAgB,OAAO;MACxB,IAAI,UAAU;EACnB,MAAM,MAAO,MAAM,YAAY,QAAQ;EACvC,MAAM,wBAAwB,KAAK,OAAO;CAC5C,OAAO,IAAI,MACT,MAAM,YACJ;EACE,SAAS;EACT;EACA,sBAAsB,CAAC;CACzB,GACA,OACF;MACK,IAAI,KAAK;EACd,MAAM,cAAc,eAAe,SAAS,QAAQ,GAAG,CAAC;EACxD,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;EAE9D,MAAM,EACJ,MAAM,SACN,IAAI,OACJ,SAAS,YACT,sBACA,yBACE;EAEJ,MAAM,YACJ;GACE;GACA;GACA;GACA;GACA;EACF,GACA,OACF;CACF,OAAO;EACL,QAAQ,IACN,uEACF;EACA;CACF;CACA,MAAM,QAAQ,KAAK;AACrB","debug_id":"613319d0-0df7-5cc6-87c6-4630f1ae1bd6"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a9adde06-479d-5808-8d89-1e0461f76642")}catch(e){}}();
|
|
3
|
+
import { c as strictObject, l as string, n as array, o as number, r as boolean } from "./schemas-BZZWQ72W.mjs";
|
|
4
|
+
import "node:module";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import "node:child_process";
|
|
8
|
+
import "node:url";
|
|
9
|
+
import { deflateSync } from "node:zlib";
|
|
10
|
+
//#region ../../packages/desktop/dist/shell-BL61-fyi.mjs
|
|
11
|
+
/**
|
|
12
|
+
* `hosts/desktop/app.json` — the builder's desktop identity (phase 7, mode 1:
|
|
13
|
+
* the builder ships under THEIR identity without writing Rust). It is the ONE
|
|
14
|
+
* file a builder edits; `shell-project.ts` projects it into a generated
|
|
15
|
+
* `tauri-shell/` that depends on the published `ph-desktop-shell` crate. Every
|
|
16
|
+
* field validates strictly so a typo fails with the field named, not silently.
|
|
17
|
+
*/
|
|
18
|
+
const identifierSchema = string().min(1).regex(/^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$/, "identifier must be reverse-DNS (e.g. com.acme.app): dot-separated alphanumeric segments");
|
|
19
|
+
const windowSchema = strictObject({
|
|
20
|
+
title: string().min(1).optional(),
|
|
21
|
+
width: number().int().positive().optional(),
|
|
22
|
+
height: number().int().positive().optional(),
|
|
23
|
+
resizable: boolean().optional()
|
|
24
|
+
}).optional();
|
|
25
|
+
const fileAssociationSchema = strictObject({
|
|
26
|
+
/** Extensions WITHOUT the leading dot ("phd", not ".phd"). */
|
|
27
|
+
ext: array(string().min(1).regex(/^[^.]/, "drop the leading dot")).min(1),
|
|
28
|
+
name: string().min(1),
|
|
29
|
+
description: string().optional(),
|
|
30
|
+
mimeType: string().optional()
|
|
31
|
+
});
|
|
32
|
+
/** Where the generated Cargo.toml resolves `ph-desktop-shell` from. Default
|
|
33
|
+
* (omitted) = the published crates.io version. */
|
|
34
|
+
const shellSourceSchema = strictObject({
|
|
35
|
+
/** Local checkout for shell development (the lab points here). */
|
|
36
|
+
path: string().min(1).optional(),
|
|
37
|
+
/** Git source, pinned to a tag/rev, for pre-publication consumption. */
|
|
38
|
+
git: string().min(1).optional(),
|
|
39
|
+
tag: string().min(1).optional(),
|
|
40
|
+
rev: string().min(1).optional(),
|
|
41
|
+
/** crates.io version requirement (default DEFAULT_SHELL_CRATE_VERSION). */
|
|
42
|
+
version: string().min(1).optional()
|
|
43
|
+
}).refine((s) => !(s.path && s.git), { message: "shell.source: set path OR git, not both" }).optional();
|
|
44
|
+
const appJsonSchema = strictObject({
|
|
45
|
+
identifier: identifierSchema,
|
|
46
|
+
productName: string().min(1),
|
|
47
|
+
/** Single source image (square PNG, 1024×1024 recommended); the icon set
|
|
48
|
+
* for every platform is generated from it via `tauri icon`. */
|
|
49
|
+
icon: string().min(1),
|
|
50
|
+
window: windowSchema,
|
|
51
|
+
fileAssociations: array(fileAssociationSchema).optional(),
|
|
52
|
+
shell: shellSourceSchema
|
|
53
|
+
});
|
|
54
|
+
const APP_JSON_FILE = "app.json";
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region ../../packages/desktop/dist/index.mjs
|
|
57
|
+
/** Minimal PNG encoder — a solid square so `tauri icon` always has a valid
|
|
58
|
+
* source. Pure Node (zlib); no binary asset ships in the package. The builder
|
|
59
|
+
* replaces it with their real 1024×1024 artwork. */
|
|
60
|
+
function solidPng(size, rgba) {
|
|
61
|
+
const [r, g, b, a] = rgba;
|
|
62
|
+
const row = Buffer.alloc(1 + size * 4);
|
|
63
|
+
for (let x = 0; x < size; x++) {
|
|
64
|
+
const o = 1 + x * 4;
|
|
65
|
+
row[o] = r;
|
|
66
|
+
row[o + 1] = g;
|
|
67
|
+
row[o + 2] = b;
|
|
68
|
+
row[o + 3] = a;
|
|
69
|
+
}
|
|
70
|
+
const raw = Buffer.concat(Array.from({ length: size }, () => row));
|
|
71
|
+
const idat = deflateSync(raw);
|
|
72
|
+
const chunk = (type, data) => {
|
|
73
|
+
const len = Buffer.alloc(4);
|
|
74
|
+
len.writeUInt32BE(data.length, 0);
|
|
75
|
+
const typeBuf = Buffer.from(type, "ascii");
|
|
76
|
+
const body = Buffer.concat([typeBuf, data]);
|
|
77
|
+
const crc = Buffer.alloc(4);
|
|
78
|
+
crc.writeUInt32BE(crc32(body) >>> 0, 0);
|
|
79
|
+
return Buffer.concat([
|
|
80
|
+
len,
|
|
81
|
+
body,
|
|
82
|
+
crc
|
|
83
|
+
]);
|
|
84
|
+
};
|
|
85
|
+
const ihdr = Buffer.alloc(13);
|
|
86
|
+
ihdr.writeUInt32BE(size, 0);
|
|
87
|
+
ihdr.writeUInt32BE(size, 4);
|
|
88
|
+
ihdr[8] = 8;
|
|
89
|
+
ihdr[9] = 6;
|
|
90
|
+
ihdr[10] = 0;
|
|
91
|
+
ihdr[11] = 0;
|
|
92
|
+
ihdr[12] = 0;
|
|
93
|
+
return Buffer.concat([
|
|
94
|
+
Buffer.from([
|
|
95
|
+
137,
|
|
96
|
+
80,
|
|
97
|
+
78,
|
|
98
|
+
71,
|
|
99
|
+
13,
|
|
100
|
+
10,
|
|
101
|
+
26,
|
|
102
|
+
10
|
|
103
|
+
]),
|
|
104
|
+
chunk("IHDR", ihdr),
|
|
105
|
+
chunk("IDAT", idat),
|
|
106
|
+
chunk("IEND", Buffer.alloc(0))
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
let crcTable;
|
|
110
|
+
function crc32(buf) {
|
|
111
|
+
if (!crcTable) {
|
|
112
|
+
crcTable = [];
|
|
113
|
+
for (let n = 0; n < 256; n++) {
|
|
114
|
+
let c = n;
|
|
115
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
116
|
+
crcTable[n] = c;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
let crc = 4294967295;
|
|
120
|
+
for (let i = 0; i < buf.length; i++) crc = crcTable[(crc ^ buf[i]) & 255] ^ crc >>> 8;
|
|
121
|
+
return crc ^ 4294967295;
|
|
122
|
+
}
|
|
123
|
+
const GITIGNORE = `# Generated tauri shell — only Cargo.lock and app-icon.png are tracked.
|
|
124
|
+
/tauri-shell/target
|
|
125
|
+
/tauri-shell/gen
|
|
126
|
+
/tauri-shell/icons
|
|
127
|
+
/tauri-shell/dist-stack
|
|
128
|
+
/tauri-shell/binaries
|
|
129
|
+
`;
|
|
130
|
+
function scaffoldDesktopShell(hostDir, options) {
|
|
131
|
+
const created = [];
|
|
132
|
+
const skipped = [];
|
|
133
|
+
fs.mkdirSync(hostDir, { recursive: true });
|
|
134
|
+
const iconFile = "icon.png";
|
|
135
|
+
const app = {
|
|
136
|
+
identifier: options.identifier,
|
|
137
|
+
productName: options.productName,
|
|
138
|
+
icon: `./${iconFile}`,
|
|
139
|
+
window: {
|
|
140
|
+
title: options.productName,
|
|
141
|
+
width: 1440,
|
|
142
|
+
height: 900
|
|
143
|
+
},
|
|
144
|
+
fileAssociations: [{
|
|
145
|
+
ext: ["phd"],
|
|
146
|
+
name: "Powerhouse Document",
|
|
147
|
+
mimeType: "application/vnd.powerhouse.document+zip"
|
|
148
|
+
}]
|
|
149
|
+
};
|
|
150
|
+
appJsonSchema.parse(app);
|
|
151
|
+
const appJsonPath = path.join(hostDir, APP_JSON_FILE);
|
|
152
|
+
if (fs.existsSync(appJsonPath) && !options.force) skipped.push(appJsonPath);
|
|
153
|
+
else {
|
|
154
|
+
fs.writeFileSync(appJsonPath, `${JSON.stringify(app, null, 2)}\n`);
|
|
155
|
+
created.push(appJsonPath);
|
|
156
|
+
}
|
|
157
|
+
const iconPath = path.join(hostDir, iconFile);
|
|
158
|
+
if (fs.existsSync(iconPath)) skipped.push(iconPath);
|
|
159
|
+
else {
|
|
160
|
+
fs.writeFileSync(iconPath, solidPng(1024, [
|
|
161
|
+
79,
|
|
162
|
+
70,
|
|
163
|
+
229,
|
|
164
|
+
255
|
|
165
|
+
]));
|
|
166
|
+
created.push(iconPath);
|
|
167
|
+
}
|
|
168
|
+
const gitignorePath = path.join(hostDir, ".gitignore");
|
|
169
|
+
if (fs.existsSync(gitignorePath)) skipped.push(gitignorePath);
|
|
170
|
+
else {
|
|
171
|
+
fs.writeFileSync(gitignorePath, GITIGNORE);
|
|
172
|
+
created.push(gitignorePath);
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
hostDir,
|
|
176
|
+
created,
|
|
177
|
+
skipped
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/services/generate-desktop-shell.ts
|
|
182
|
+
/** A reverse-DNS-safe segment from the project name (drop scope, slugify). */
|
|
183
|
+
function projectSlug(pkgName) {
|
|
184
|
+
return (pkgName ?? "app").replace(/^@[^/]+\//, "").toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "app";
|
|
185
|
+
}
|
|
186
|
+
/** `ph generate desktop-shell`: write hosts/desktop/app.json + a placeholder
|
|
187
|
+
* icon + .gitignore. Defaults product name / identifier from the project. */
|
|
188
|
+
function startGenerateDesktopShell(args, cwd) {
|
|
189
|
+
let pkgName;
|
|
190
|
+
try {
|
|
191
|
+
pkgName = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf8")).name;
|
|
192
|
+
} catch {}
|
|
193
|
+
const slug = projectSlug(pkgName);
|
|
194
|
+
const productName = args.name ?? pkgName?.replace(/^@[^/]+\//, "") ?? "App";
|
|
195
|
+
const identifier = args.identifier ?? `inc.powerhouse.desktop.${slug}`;
|
|
196
|
+
const hostDir = path.join(cwd, "hosts", "desktop");
|
|
197
|
+
const result = scaffoldDesktopShell(hostDir, {
|
|
198
|
+
identifier,
|
|
199
|
+
productName,
|
|
200
|
+
force: args.force
|
|
201
|
+
});
|
|
202
|
+
const rel = (p) => path.relative(cwd, p).replace(/\\/g, "/");
|
|
203
|
+
for (const f of result.created) console.log(` created ${rel(f)}`);
|
|
204
|
+
for (const f of result.skipped) console.log(` skipped ${rel(f)} (exists — pass --force to overwrite)`);
|
|
205
|
+
if (!fs.existsSync(path.join(hostDir, "host.js"))) console.log("\nNote: hosts/desktop/host.js not found. Add a desktop host (see the desktop topology from `ph init`) so `ph run desktop` can supervise the stack; app.json then gives it a native window.");
|
|
206
|
+
console.log(`\nIdentity: ${productName} (${identifier}).\n• Replace hosts/desktop/icon.png with your 1024×1024 icon.\n• \`ph run desktop dev\` opens the native window (needs Rust + the Tauri CLI).\n• \`ph run desktop build\` produces installers for this OS.`);
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
export { startGenerateDesktopShell };
|
|
210
|
+
|
|
211
|
+
//# sourceMappingURL=generate-desktop-shell-DFOsRPgq.mjs.map
|
|
212
|
+
//# debugId=a9adde06-479d-5808-8d89-1e0461f76642
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-desktop-shell-DFOsRPgq.mjs","sources":["../../../packages/desktop/dist/shell-BL61-fyi.mjs","../../../packages/desktop/dist/index.mjs","../src/services/generate-desktop-shell.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\nimport { execSync, spawn, spawnSync } from \"node:child_process\";\nimport { pathToFileURL } from \"node:url\";\n//#region src/app-json.ts\n/**\n* `hosts/desktop/app.json` — the builder's desktop identity (phase 7, mode 1:\n* the builder ships under THEIR identity without writing Rust). It is the ONE\n* file a builder edits; `shell-project.ts` projects it into a generated\n* `tauri-shell/` that depends on the published `ph-desktop-shell` crate. Every\n* field validates strictly so a typo fails with the field named, not silently.\n*/\nconst identifierSchema = z.string().min(1).regex(/^[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)+$/, \"identifier must be reverse-DNS (e.g. com.acme.app): dot-separated alphanumeric segments\");\nconst windowSchema = z.strictObject({\n\ttitle: z.string().min(1).optional(),\n\twidth: z.number().int().positive().optional(),\n\theight: z.number().int().positive().optional(),\n\tresizable: z.boolean().optional()\n}).optional();\nconst fileAssociationSchema = z.strictObject({\n\t/** Extensions WITHOUT the leading dot (\"phd\", not \".phd\"). */\n\text: z.array(z.string().min(1).regex(/^[^.]/, \"drop the leading dot\")).min(1),\n\tname: z.string().min(1),\n\tdescription: z.string().optional(),\n\tmimeType: z.string().optional()\n});\n/** Where the generated Cargo.toml resolves `ph-desktop-shell` from. Default\n* (omitted) = the published crates.io version. */\nconst shellSourceSchema = z.strictObject({\n\t/** Local checkout for shell development (the lab points here). */\n\tpath: z.string().min(1).optional(),\n\t/** Git source, pinned to a tag/rev, for pre-publication consumption. */\n\tgit: z.string().min(1).optional(),\n\ttag: z.string().min(1).optional(),\n\trev: z.string().min(1).optional(),\n\t/** crates.io version requirement (default DEFAULT_SHELL_CRATE_VERSION). */\n\tversion: z.string().min(1).optional()\n}).refine((s) => !(s.path && s.git), { message: \"shell.source: set path OR git, not both\" }).optional();\nconst appJsonSchema = z.strictObject({\n\tidentifier: identifierSchema,\n\tproductName: z.string().min(1),\n\t/** Single source image (square PNG, 1024×1024 recommended); the icon set\n\t* for every platform is generated from it via `tauri icon`. */\n\ticon: z.string().min(1),\n\twindow: windowSchema,\n\tfileAssociations: z.array(fileAssociationSchema).optional(),\n\tshell: shellSourceSchema\n});\n/** Default crates.io version requirement for the shell crate (D7.b: the flip\n* to crates.io default once published — the crate is live). */\nconst DEFAULT_SHELL_CRATE_VERSION = \"0.1\";\nconst APP_JSON_FILE = \"app.json\";\n/** Read + validate hosts/<host>/app.json. Throws with the field named on a\n* bad value, and a clear message when the file is absent. */\nfunction loadAppJson(hostDir) {\n\tconst file = path.join(hostDir, APP_JSON_FILE);\n\tif (!fs.existsSync(file)) throw new Error(`No ${APP_JSON_FILE} in ${hostDir} — run \\`ph generate desktop-shell\\` to scaffold the builder identity, or set runner.shell.project to a prebuilt shell.`);\n\tlet raw;\n\ttry {\n\t\traw = JSON.parse(fs.readFileSync(file, \"utf8\"));\n\t} catch (error) {\n\t\tthrow new Error(`${file}: not valid JSON — ${String(error)}`, { cause: error });\n\t}\n\tconst result = appJsonSchema.safeParse(raw);\n\tif (!result.success) {\n\t\tconst issues = result.error.issues.map((i) => ` ${i.path.join(\".\") || \"(root)\"}: ${i.message}`).join(\"\\n\");\n\t\tthrow new Error(`${file} is invalid:\\n${issues}`);\n\t}\n\treturn result.data;\n}\n/** A filesystem/crate-safe slug of the product name — the generated binary\n* and Cargo package name. Falls back to the identifier's last segment. */\nfunction appSlug(app) {\n\tconst fromName = app.productName.toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-+|-+$/g, \"\");\n\tif (fromName) return fromName;\n\treturn (app.identifier.split(\".\").pop() ?? \"app\").toLowerCase().replace(/[^a-z0-9]+/g, \"-\");\n}\n//#endregion\n//#region src/bundle-stack.ts\nfunction copyIfExists(from, to) {\n\tif (!fs.existsSync(from)) return false;\n\tfs.cpSync(from, to, { recursive: true });\n\treturn true;\n}\n/**\n* Recursively copy `src` → `dest`, skipping any path in `excludes`. Unlike\n* fs.cpSync this tolerates `dest` living INSIDE `src`: in mode 1 the generated\n* shell (and its `dist-stack`) sits under `hosts/<desktop>/`, so staging the\n* project's `hosts/` straight into the shell would be a copy-into-self that\n* cpSync rejects outright. Excluding the shell subtree both avoids that and\n* keeps the crate + node sidecar out of the shippable stack.\n*/\nfunction copyDirFiltered(src, dest, excludes) {\n\tif (!fs.existsSync(src)) return false;\n\tconst skip = new Set(excludes.map((e) => path.resolve(e)));\n\tconst walk = (s, d) => {\n\t\tif (skip.has(path.resolve(s))) return;\n\t\tif (fs.statSync(s).isDirectory()) {\n\t\t\tfs.mkdirSync(d, { recursive: true });\n\t\t\tfor (const entry of fs.readdirSync(s)) walk(path.join(s, entry), path.join(d, entry));\n\t\t} else fs.copyFileSync(s, d);\n\t};\n\twalk(src, dest);\n\treturn true;\n}\nfunction bundleStack(options) {\n\tconst log = options.logger ?? console.log;\n\tconst stackDir = path.join(options.shellProjectDir, \"dist-stack\");\n\tfor (const entry of [\n\t\t\"hosts\",\n\t\t\"agents\",\n\t\t\"dist\",\n\t\t\"powerhouse.config.json\",\n\t\t\"package.json\"\n\t]) fs.rmSync(path.join(stackDir, entry), {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tfs.mkdirSync(stackDir, { recursive: true });\n\tlog(` hosts/ ${copyDirFiltered(path.join(options.projectRoot, \"hosts\"), path.join(stackDir, \"hosts\"), options.excludeDirs ?? []) ? \"staged\" : \"absent — skipped\"}`);\n\tfor (const dir of [\"agents\", \"dist\"]) log(` ${dir}/ ${copyIfExists(path.join(options.projectRoot, dir), path.join(stackDir, dir)) ? \"staged\" : \"absent — skipped\"}`);\n\tconst stagedDesktopHost = path.join(stackDir, \"hosts\", \"desktop\", \"host.js\");\n\tif (fs.existsSync(stagedDesktopHost)) {\n\t\tconst source = fs.readFileSync(stagedDesktopHost, \"utf8\");\n\t\tif (source.includes(\"@powerhousedao/desktop/runner\")) {\n\t\t\tfs.writeFileSync(stagedDesktopHost, \"// STAGED COPY (bundle-stack): runner.module rewritten to the generic\\n// compound — the packaged shell is the window; there is no nested shell.\\n\" + source.replace(/@powerhousedao\\/desktop\\/runner/g, \"@powerhousedao/host-core/runners/compound\"));\n\t\t\tlog(\" hosts/desktop/host.js: runner rewritten to the generic compound (staged copy)\");\n\t\t}\n\t}\n\tcopyIfExists(path.join(options.projectRoot, \"powerhouse.config.json\"), path.join(stackDir, \"powerhouse.config.json\"));\n\tif (typeof options.connectPort === \"number\") {\n\t\tfs.writeFileSync(path.join(stackDir, \"shell.json\"), `${JSON.stringify({ connectPort: options.connectPort }, null, 2)}\\n`);\n\t\tlog(` shell.json: connectPort ${options.connectPort}`);\n\t}\n\tconst sourcePkg = JSON.parse(fs.readFileSync(path.join(options.projectRoot, \"package.json\"), \"utf8\"));\n\tconst version = options.phCliVersion ?? \"dev\";\n\tfs.writeFileSync(path.join(stackDir, \"package.json\"), `${JSON.stringify({\n\t\tname: sourcePkg.name ?? \"powerhouse-desktop-stack\",\n\t\tprivate: true,\n\t\ttype: \"module\",\n\t\tdependencies: { \"@powerhousedao/ph-cli\": version }\n\t}, null, 2)}\\n`);\n\tlet vendored = false;\n\tif (options.vendor !== false) {\n\t\tconst specs = `\"${options.phCliSpec ?? `@powerhousedao/ph-cli@${version}`}\" \"@powerhousedao/host-core@${version}\"`;\n\t\tlog(` vendoring ${specs} (hoisted, real files)…`);\n\t\tconst result = spawnSync(`npm install ${specs} --install-strategy=hoisted --omit=dev --no-audit --no-fund`, {\n\t\t\tcwd: stackDir,\n\t\t\tstdio: \"pipe\",\n\t\t\tshell: true,\n\t\t\twindowsHide: true\n\t\t});\n\t\tif (result.status !== 0) throw new Error(`bundle-stack: vendoring failed (${result.status}):\\n${result.stderr.toString().slice(-800)}`);\n\t\tvendored = true;\n\t} else log(\" vendoring skipped (vendor: false) — existing tree left in place\");\n\treturn {\n\t\tstackDir,\n\t\tvendored\n\t};\n}\n//#endregion\n//#region src/shell-project.ts\n/**\n* P7.3 — project `hosts/desktop/app.json` into a generated `tauri-shell/`:\n* a STANDALONE tauri crate that depends on the published `ph-desktop-shell`\n* library, carries the builder's identity, and is built/run by the desktop\n* runner's dev/build verbs. The builder never writes Rust.\n*\n* Everything here mirrors the known-good reference app\n* (ph-desktop-shell/apps/powerhouse-desktop): the tauri plumbing (main.rs,\n* build.rs, capabilities, the loading page, externalBin + icon mechanics) is\n* copied verbatim; only identity/port fields are projected from app.json. The\n* projection is idempotent and stale-detected — a file is rewritten only when\n* its content changes, so Cargo.lock, the generated icon set, and tauri-build\n* output are never disturbed by a regen with an unchanged app.json.\n*/\nconst SHELL_DIR = \"tauri-shell\";\n/** The icon source the runner feeds to `tauri icon` (copied from app.icon). */\nconst ICON_SOURCE = \"app-icon.png\";\n/** `ph-desktop-shell` dependency line for the generated Cargo.toml, from\n* app.json's shell.source (path > git > crates.io version). */\nfunction shellDependency(source) {\n\tif (source?.path) {\n\t\tconst p = source.path.replace(/\\\\/g, \"/\");\n\t\treturn `ph-desktop-shell = { path = ${JSON.stringify(p)} }`;\n\t}\n\tif (source?.git) {\n\t\tconst parts = [`git = ${JSON.stringify(source.git)}`];\n\t\tif (source.tag) parts.push(`tag = ${JSON.stringify(source.tag)}`);\n\t\tif (source.rev) parts.push(`rev = ${JSON.stringify(source.rev)}`);\n\t\treturn `ph-desktop-shell = { ${parts.join(\", \")} }`;\n\t}\n\tconst version = source?.version ?? \"0.1\";\n\treturn `ph-desktop-shell = ${JSON.stringify(version)}`;\n}\nfunction cargoToml(app, binName) {\n\treturn `# GENERATED from ../app.json by @powerhousedao/desktop — do not edit by\n# hand; edit app.json and re-run \\`ph run desktop dev|build\\`. Cargo.lock is\n# preserved across regens.\n[package]\nname = ${JSON.stringify(binName)}\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[build-dependencies]\ntauri-build = { version = \"2\", features = [] }\n\n[dependencies]\ntauri = { version = \"2\", features = [\"tray-icon\", \"devtools\"] }\n# Plugins must be DIRECT deps of the app crate: tauri-build only sees\n# permission manifests (shell:allow-spawn etc.) from direct dependencies.\ntauri-plugin-shell = \"2\"\ntauri-plugin-single-instance = \"2\"\n${shellDependency(app.shell)}\n\n[[bin]]\nname = ${JSON.stringify(binName)}\npath = \"src/main.rs\"\n\n[profile.release]\ncodegen-units = 1\nlto = true\n`;\n}\nconst MAIN_RS = `// GENERATED — identity bakes from tauri.conf.json via generate_context!;\n// behavior is the shared ph-desktop-shell library. Edit ../app.json, not this.\n#![cfg_attr(not(debug_assertions), windows_subsystem = \"windows\")]\n\nfn main() {\n ph_desktop_shell::run(tauri::generate_context!(), Default::default());\n}\n`;\nconst BUILD_RS = `// GENERATED — mirrors the reference shell. Connect is served over\n// http://127.0.0.1 (a remote origin to Tauri), so the launch-queue commands\n// need an explicit ACL; declaring the command manifest here generates the\n// allow-<command> permissions that capabilities/*.json grant.\nfn main() {\n tauri_build::try_build(tauri_build::Attributes::new().app_manifest(\n tauri_build::AppManifest::new().commands(&[\n \"take_launch_files\",\n \"read_launch_file\",\n \"log_from_webview\",\n ]),\n ))\n .expect(\"failed to run tauri-build\");\n}\n`;\nfunction loadingHtml(productName) {\n\tconst name = productName.replace(/[<&]/g, (c) => c === \"<\" ? \"<\" : \"&\");\n\treturn `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <title>${name}</title>\n <style>\n :root { color-scheme: light dark; }\n body {\n margin: 0; height: 100vh;\n display: flex; align-items: center; justify-content: center;\n font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif;\n background: #0f1115; color: #e6e8eb;\n }\n .box { text-align: center; }\n .dot {\n width: 10px; height: 10px; border-radius: 50%;\n background: #4ade80; display: inline-block; margin-right: 8px;\n animation: pulse 1.2s ease-in-out infinite;\n }\n @keyframes pulse { 0%,100% { opacity: .35 } 50% { opacity: 1 } }\n </style>\n </head>\n <body>\n <div class=\"box\"><span class=\"dot\"></span>Starting ${name}…</div>\n </body>\n</html>\n`;\n}\nfunction tauriConf(input) {\n\tconst { app } = input;\n\tconst win = app.window ?? {};\n\tconst fileAssociations = app.fileAssociations && app.fileAssociations.length > 0 ? app.fileAssociations.map((fa) => ({\n\t\text: fa.ext,\n\t\tname: fa.name,\n\t\t...fa.description ? { description: fa.description } : {},\n\t\t...fa.mimeType ? { mimeType: fa.mimeType } : {}\n\t})) : void 0;\n\tconst conf = {\n\t\t$schema: \"https://schema.tauri.app/config/2\",\n\t\tproductName: app.productName,\n\t\tversion: \"0.1.0\",\n\t\tidentifier: app.identifier,\n\t\tbuild: { frontendDist: \"./ui\" },\n\t\tapp: {\n\t\t\twindows: [{\n\t\t\t\ttitle: win.title ?? app.productName,\n\t\t\t\twidth: win.width ?? 1440,\n\t\t\t\theight: win.height ?? 900,\n\t\t\t\tresizable: win.resizable ?? true,\n\t\t\t\tvisible: true,\n\t\t\t\tdragDropEnabled: false,\n\t\t\t\tcreate: false\n\t\t\t}],\n\t\t\tsecurity: { csp: null }\n\t\t},\n\t\tbundle: {\n\t\t\tactive: true,\n\t\t\ttargets: [\n\t\t\t\t\"nsis\",\n\t\t\t\t\"app\",\n\t\t\t\t\"dmg\"\n\t\t\t],\n\t\t\ticon: [\n\t\t\t\t\"icons/32x32.png\",\n\t\t\t\t\"icons/128x128.png\",\n\t\t\t\t\"icons/128x128@2x.png\",\n\t\t\t\t\"icons/icon.icns\",\n\t\t\t\t\"icons/icon.ico\"\n\t\t\t],\n\t\t\t...fileAssociations ? { fileAssociations } : {},\n\t\t\texternalBin: [\"binaries/node\"],\n\t\t\tresources: { \"./dist-stack\": \"stack\" }\n\t\t}\n\t};\n\treturn JSON.stringify(conf, null, 2) + \"\\n\";\n}\nfunction defaultCapability() {\n\treturn JSON.stringify({\n\t\t$schema: \"../gen/schemas/desktop-schema.json\",\n\t\tidentifier: \"default\",\n\t\tdescription: \"Lets the shell spawn the bundled node sidecar.\",\n\t\twindows: [\"main\"],\n\t\tpermissions: [\n\t\t\t\"core:default\",\n\t\t\t\"allow-take-launch-files\",\n\t\t\t\"allow-read-launch-file\",\n\t\t\t\"allow-log-from-webview\",\n\t\t\t{\n\t\t\t\tidentifier: \"shell:allow-spawn\",\n\t\t\t\tallow: [{\n\t\t\t\t\tname: \"binaries/node\",\n\t\t\t\t\tsidecar: true,\n\t\t\t\t\targs: true\n\t\t\t\t}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tidentifier: \"shell:allow-execute\",\n\t\t\t\tallow: [{\n\t\t\t\t\tname: \"binaries/node\",\n\t\t\t\t\tsidecar: true,\n\t\t\t\t\targs: true\n\t\t\t\t}]\n\t\t\t}\n\t\t]\n\t}, null, 2) + \"\\n\";\n}\nfunction connectCapability(connectPort) {\n\tconst origin = `http://127.0.0.1:${connectPort}`;\n\treturn JSON.stringify({\n\t\t$schema: \"../gen/schemas/desktop-schema.json\",\n\t\tidentifier: \"connect\",\n\t\tdescription: \"Connect is served over http://127.0.0.1 (a remote origin to Tauri); without this the launch-queue commands are rejected before they run.\",\n\t\twindows: [\"main\"],\n\t\tremote: { urls: [origin, `${origin}/*`] },\n\t\tpermissions: [\n\t\t\t\"allow-take-launch-files\",\n\t\t\t\"allow-read-launch-file\",\n\t\t\t\"allow-log-from-webview\"\n\t\t]\n\t}, null, 2) + \"\\n\";\n}\nconst GITIGNORE = `# Generated tauri shell — only Cargo.lock and app-icon.png are tracked.\n/target\n/gen\n/icons\n/dist-stack\n/binaries\n`;\nconst DIST_STACK_README = `This directory is replaced at \\`ph run desktop build\\` with the shippable\nstack (hosts + powerhouse.config.json + built Connect + vendored ph-cli). It\nis bundled as the app's \\`stack\\` resource so the installed app runs with no\nenvironment. Kept as a placeholder so tauri's resource glob resolves in dev.\n`;\n/** Write a file only when its content differs; returns whether it changed. */\nfunction writeIfChanged(file, content) {\n\tif (fs.existsSync(file) && fs.readFileSync(file, \"utf8\") === content) return false;\n\tfs.mkdirSync(path.dirname(file), { recursive: true });\n\tfs.writeFileSync(file, content);\n\treturn true;\n}\n/**\n* Materialize/refresh `<hostDir>/tauri-shell/` from app.json. Idempotent:\n* unchanged app.json rewrites nothing. Does NOT run `tauri icon` or fetch the\n* node binary — those are toolchain steps the runner performs at dev/build.\n*/\nfunction projectShell(input) {\n\tconst { hostDir, app, connectPort } = input;\n\tconst binName = appSlug(app);\n\tconst shellDir = path.join(hostDir, SHELL_DIR);\n\tconst files = [\n\t\t[\"Cargo.toml\", cargoToml(app, binName)],\n\t\t[\"src/main.rs\", MAIN_RS],\n\t\t[\"build.rs\", BUILD_RS],\n\t\t[\"tauri.conf.json\", tauriConf(input)],\n\t\t[\"ui/index.html\", loadingHtml(app.productName)],\n\t\t[\"capabilities/default.json\", defaultCapability()],\n\t\t[\"capabilities/connect.json\", connectCapability(connectPort)],\n\t\t[\".gitignore\", GITIGNORE],\n\t\t[\"dist-stack/README.md\", DIST_STACK_README]\n\t];\n\tlet changed = false;\n\tfor (const [rel, content] of files) if (writeIfChanged(path.join(shellDir, rel), content)) changed = true;\n\tconst iconSrc = path.resolve(hostDir, app.icon);\n\tconst iconDest = path.join(shellDir, ICON_SOURCE);\n\tif (fs.existsSync(iconSrc)) {\n\t\tconst bytes = fs.readFileSync(iconSrc);\n\t\tif (!fs.existsSync(iconDest) || !fs.readFileSync(iconDest).equals(bytes)) {\n\t\t\tfs.mkdirSync(shellDir, { recursive: true });\n\t\t\tfs.writeFileSync(iconDest, bytes);\n\t\t\tchanged = true;\n\t\t}\n\t}\n\treturn {\n\t\tshellDir,\n\t\tbinName,\n\t\tchanged\n\t};\n}\n//#endregion\n//#region src/shell-toolchain.ts\n/** The Node release triple for a build host — the sidecar filename tauri\n* resolves (`node-<triple>`). Pure, so the mapping is unit-tested. */\nfunction nodeSidecarTarget(platform, arch) {\n\tconst target = {\n\t\t\"win32 x64\": {\n\t\t\ttriple: \"x86_64-pc-windows-msvc\",\n\t\t\tdist: \"win-x64\",\n\t\t\tbin: \"node.exe\",\n\t\t\text: \".exe\"\n\t\t},\n\t\t\"darwin arm64\": {\n\t\t\ttriple: \"aarch64-apple-darwin\",\n\t\t\tdist: \"darwin-arm64\",\n\t\t\tbin: \"bin/node\",\n\t\t\text: \"\"\n\t\t},\n\t\t\"darwin x64\": {\n\t\t\ttriple: \"x86_64-apple-darwin\",\n\t\t\tdist: \"darwin-x64\",\n\t\t\tbin: \"bin/node\",\n\t\t\text: \"\"\n\t\t},\n\t\t\"linux x64\": {\n\t\t\ttriple: \"x86_64-unknown-linux-gnu\",\n\t\t\tdist: \"linux-x64\",\n\t\t\tbin: \"bin/node\",\n\t\t\text: \"\"\n\t\t}\n\t}[`${platform} ${arch}`];\n\tif (!target) throw new Error(`No Node sidecar mapping for ${platform} ${arch} — the desktop shell supports win32/x64, darwin/arm64, darwin/x64, linux/x64.`);\n\treturn target;\n}\n/** Fetch the stock Node the shell ships as its sidecar into `<shellDir>/\n* binaries`, named per target triple. No-op when already present. Ported from\n* the reference repo's fetch-node.mjs (the builder has no such script). */\nfunction fetchNodeSidecar(shellDir, version = process.versions.node, platform = process.platform, arch = process.arch) {\n\tconst target = nodeSidecarTarget(platform, arch);\n\tconst binariesDir = path.join(shellDir, \"binaries\");\n\tfs.mkdirSync(binariesDir, { recursive: true });\n\tconst dest = path.join(binariesDir, `node-${target.triple}${target.ext}`);\n\tif (fs.existsSync(dest)) return dest;\n\tif (platform === \"win32\") {\n\t\tconst url = `https://nodejs.org/dist/v${version}/win-x64/node.exe`;\n\t\texecSync(`curl -fsSL -o \"${dest}\" \"${url}\"`, { stdio: \"inherit\" });\n\t} else {\n\t\tconst name = `node-v${version}-${target.dist}`;\n\t\tconst url = `https://nodejs.org/dist/v${version}/${name}.tar.gz`;\n\t\texecSync(`curl -fsSL \"${url}\" | tar -xz -C \"${binariesDir}\" --strip-components=2 ${name}/${target.bin}`, {\n\t\t\tstdio: \"inherit\",\n\t\t\tshell: \"/bin/sh\"\n\t\t});\n\t\tfs.renameSync(path.join(binariesDir, \"node\"), dest);\n\t\tfs.chmodSync(dest, 493);\n\t}\n\treturn dest;\n}\n/** Default bundle targets for the build host (`cargo tauri build --bundles`).\n* macOS gets app+dmg, Windows nsis, Linux deb+appimage — a host only builds\n* installers it can produce. */\nfunction tauriBundlesForHost(platform = process.platform) {\n\tswitch (platform) {\n\t\tcase \"darwin\": return [\"app\", \"dmg\"];\n\t\tcase \"win32\": return [\"nsis\"];\n\t\tdefault: return [\"deb\", \"appimage\"];\n\t}\n}\n/** Spawn parameters that avoid DEP0190 (args array + shell:true): cargo on\n* Windows needs the shell for PATH/.exe + subcommand resolution — pass ONE\n* string, empty args; everything else runs argv directly (shell:false). The\n* joined tokens here are our own constants/paths, never user input. */\nfunction tauriSpawn(tauri, subcommand) {\n\tconst argv = [...tauri.prefix, ...subcommand];\n\tif (tauri.cmd === \"cargo\" && process.platform === \"win32\") return {\n\t\tcommand: [\"cargo\", ...argv].join(\" \"),\n\t\targs: [],\n\t\tshell: true\n\t};\n\treturn {\n\t\tcommand: tauri.cmd,\n\t\targs: argv,\n\t\tshell: false\n\t};\n}\nfunction probe(cmd, args) {\n\tconst onWin = process.platform === \"win32\";\n\ttry {\n\t\treturn spawnSync(onWin ? [cmd, ...args].join(\" \") : cmd, onWin ? [] : args, {\n\t\t\tstdio: \"ignore\",\n\t\t\tshell: onWin\n\t\t}).status === 0;\n\t} catch {\n\t\treturn false;\n\t}\n}\n/** Is a Rust `cargo` on PATH? (needed to compile the shell crate). */\nfunction hasCargo() {\n\treturn probe(\"cargo\", [\"--version\"]);\n}\n/** Resolve a Tauri CLI: a global `cargo tauri`, else a `@tauri-apps/cli`\n* resolvable from the project. Returns null when neither is available. */\nfunction resolveTauriCommand(projectRoot) {\n\tif (probe(\"cargo\", [\"tauri\", \"--version\"])) return {\n\t\tcmd: \"cargo\",\n\t\tprefix: [\"tauri\"],\n\t\tvia: \"cargo-tauri\"\n\t};\n\ttry {\n\t\tconst pkgJson = createRequire(pathToFileURL(path.join(projectRoot, \"package.json\")).href).resolve(\"@tauri-apps/cli/package.json\");\n\t\tconst pkgDir = path.dirname(pkgJson);\n\t\tconst bin = JSON.parse(fs.readFileSync(pkgJson, \"utf8\")).bin;\n\t\tconst rel = typeof bin === \"string\" ? bin : bin?.tauri;\n\t\tif (rel) return {\n\t\t\tcmd: process.execPath,\n\t\t\tprefix: [path.join(pkgDir, rel)],\n\t\t\tvia: \"node-cli\"\n\t\t};\n\t} catch {}\n\treturn null;\n}\nfunction detectToolchain(projectRoot) {\n\treturn {\n\t\tcargo: hasCargo(),\n\t\ttauri: resolveTauriCommand(projectRoot)\n\t};\n}\n/** Throw a clear, actionable error when the native toolchain is incomplete —\n* the desktop verbs call this before any cargo work so a missing executable\n* is an instruction, not a stack trace. */\nfunction preflightOrThrow(tc, hostName) {\n\tconst missing = [];\n\tif (!tc.cargo) missing.push(\" • Rust/cargo — install from https://rustup.rs (then restart your shell)\");\n\tif (!tc.tauri) missing.push(\" • Tauri CLI — `cargo install tauri-cli --version \\\"^2\\\"` (or add @tauri-apps/cli@^2 to your project's devDependencies)\");\n\tif (missing.length > 0 || !tc.tauri) throw new Error(`hosts/${hostName}: the desktop shell needs a native toolchain that is not installed:\\n${missing.join(\"\\n\")}\\nInstall the above, then re-run \\`ph run ${hostName} dev\\` / \\`ph run ${hostName} build\\`. (The headless stack — \\`ph run ${hostName}\\` — needs none of this.)`);\n\treturn tc.tauri;\n}\n/** `<tauri> icon <source>` — generates the per-platform icon set (icon.ico +\n* icon.icns + pngs) the bundle references and tauri-build requires. */\nfunction runTauriIcon(tauri, shellDir, iconSource) {\n\tconst { command, args, shell } = tauriSpawn(tauri, [\"icon\", iconSource]);\n\tconst r = spawnSync(command, args, {\n\t\tcwd: shellDir,\n\t\tstdio: \"inherit\",\n\t\tshell\n\t});\n\tif (r.status !== 0) throw new Error(`\\`tauri icon ${iconSource}\\` failed (exit ${r.status ?? \"?\"}) in ${shellDir} — check that app.icon is a square PNG.`);\n}\n//#endregion\n//#region src/shell.ts\nfunction resolveShell(projectRoot, options, env) {\n\tconst configured = options?.project ?? env.PH_DESKTOP_SHELL;\n\tif (!configured) throw new Error(\"No desktop shell configured: set runner.shell.project in the host file (path to a ph-win-desktop checkout) or the PH_DESKTOP_SHELL environment variable. `ph run desktop` (headless stack) needs neither.\");\n\tconst projectDir = path.resolve(projectRoot, configured);\n\tif (!fs.existsSync(path.join(projectDir, \"src-tauri\"))) throw new Error(`Desktop shell not found at ${projectDir} (no src-tauri/) — check runner.shell.project / PH_DESKTOP_SHELL.`);\n\treturn {\n\t\tprojectDir,\n\t\texe: [\n\t\t\tpath.join(projectDir, \"src-tauri\", \"target\", \"debug\", \"ph-win.exe\"),\n\t\t\tpath.join(projectDir, \"src-tauri\", \"target\", \"release\", \"ph-win.exe\"),\n\t\t\tpath.join(projectDir, \"src-tauri\", \"target\", \"debug\", \"ph-win\"),\n\t\t\tpath.join(projectDir, \"src-tauri\", \"target\", \"release\", \"ph-win\")\n\t\t].find((c) => fs.existsSync(c))\n\t};\n}\n/** Resolve the project's ph-cli entry from ITS dependency tree — the same\n* resolution `ph run` itself uses. */\nfunction resolvePhCliEntry(projectRoot) {\n\tconst pkgPath = createRequire(pathToFileURL(path.join(projectRoot, \"package.json\")).href).resolve(\"@powerhousedao/ph-cli/package.json\");\n\treturn path.join(path.dirname(pkgPath), \"dist\", \"cli.mjs\");\n}\n/** The env trio (plus flag and userData) the shell's uniform-runners mode\n* reads — wired by the RUNNER so nobody exports variables by hand. */\nfunction shellEnv(projectRoot, connectPort, env) {\n\treturn {\n\t\tFEATURE_UNIFORM_RUNNERS_ENABLED: \"1\",\n\t\tPH_RUN_PROJECT: projectRoot,\n\t\tPH_RUN_CLI: resolvePhCliEntry(projectRoot),\n\t\tPH_WIN_CONNECT_PORT: String(connectPort),\n\t\t...env.PH_USER_DATA_DIR ? { PH_USER_DATA_DIR: env.PH_USER_DATA_DIR } : {}\n\t};\n}\n/** Project host shell options onto a tauri `--config` merge patch (D6.d) —\n* the host file stays the single source for app identity on tauri-cli\n* invocations; a built exe has these baked. */\nfunction tauriConfigPatch(options) {\n\tif (!options) return void 0;\n\tconst patch = {};\n\tif (options.window) patch.app = { windows: [{\n\t\t...options.window.title ? { title: options.window.title } : {},\n\t\t...options.window.width ? { width: options.window.width } : {},\n\t\t...options.window.height ? { height: options.window.height } : {}\n\t}] };\n\tif (options.fileAssociations?.length) patch.bundle = { fileAssociations: [{\n\t\text: options.fileAssociations.map((e) => e.replace(/^\\./, \"\")),\n\t\tname: \"Powerhouse Document\"\n\t}] };\n\treturn Object.keys(patch).length > 0 ? patch : void 0;\n}\nfunction launchShell(shell, envVars, options) {\n\tif (shell.exe) return spawn(shell.exe, [], {\n\t\tcwd: shell.projectDir,\n\t\tenv: {\n\t\t\t...process.env,\n\t\t\t...envVars\n\t\t},\n\t\tstdio: \"inherit\",\n\t\twindowsHide: true\n\t});\n\tconst patch = tauriConfigPatch(options);\n\tconst args = [\"tauri\", \"dev\"];\n\tif (patch) args.push(\"--config\", JSON.stringify(patch));\n\treturn spawn(\"pnpm\", args, {\n\t\tcwd: shell.projectDir,\n\t\tenv: {\n\t\t\t...process.env,\n\t\t\t...envVars\n\t\t},\n\t\tstdio: \"inherit\",\n\t\tshell: true,\n\t\twindowsHide: true\n\t});\n}\n//#endregion\nexport { loadAppJson as S, bundleStack as _, tauriConfigPatch as a, appJsonSchema as b, nodeSidecarTarget as c, runTauriIcon as d, tauriBundlesForHost as f, projectShell as g, SHELL_DIR as h, shellEnv as i, preflightOrThrow as l, ICON_SOURCE as m, resolvePhCliEntry as n, detectToolchain as o, tauriSpawn as p, resolveShell as r, fetchNodeSidecar as s, launchShell as t, resolveTauriCommand as u, APP_JSON_FILE as v, appSlug as x, DEFAULT_SHELL_CRATE_VERSION as y };\n\n//# sourceMappingURL=shell-BL61-fyi.mjs.map","import { S as loadAppJson, _ as bundleStack, a as tauriConfigPatch, b as appJsonSchema, c as nodeSidecarTarget, d as runTauriIcon, f as tauriBundlesForHost, g as projectShell, h as SHELL_DIR, i as shellEnv, l as preflightOrThrow, m as ICON_SOURCE, n as resolvePhCliEntry, o as detectToolchain, r as resolveShell, s as fetchNodeSidecar, t as launchShell, u as resolveTauriCommand, v as APP_JSON_FILE, x as appSlug, y as DEFAULT_SHELL_CRATE_VERSION } from \"./shell-BL61-fyi.mjs\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { deflateSync } from \"node:zlib\";\n//#region src/scaffold.ts\n/** Minimal PNG encoder — a solid square so `tauri icon` always has a valid\n* source. Pure Node (zlib); no binary asset ships in the package. The builder\n* replaces it with their real 1024×1024 artwork. */\nfunction solidPng(size, rgba) {\n\tconst [r, g, b, a] = rgba;\n\tconst row = Buffer.alloc(1 + size * 4);\n\tfor (let x = 0; x < size; x++) {\n\t\tconst o = 1 + x * 4;\n\t\trow[o] = r;\n\t\trow[o + 1] = g;\n\t\trow[o + 2] = b;\n\t\trow[o + 3] = a;\n\t}\n\tconst raw = Buffer.concat(Array.from({ length: size }, () => row));\n\tconst idat = deflateSync(raw);\n\tconst chunk = (type, data) => {\n\t\tconst len = Buffer.alloc(4);\n\t\tlen.writeUInt32BE(data.length, 0);\n\t\tconst typeBuf = Buffer.from(type, \"ascii\");\n\t\tconst body = Buffer.concat([typeBuf, data]);\n\t\tconst crc = Buffer.alloc(4);\n\t\tcrc.writeUInt32BE(crc32(body) >>> 0, 0);\n\t\treturn Buffer.concat([\n\t\t\tlen,\n\t\t\tbody,\n\t\t\tcrc\n\t\t]);\n\t};\n\tconst ihdr = Buffer.alloc(13);\n\tihdr.writeUInt32BE(size, 0);\n\tihdr.writeUInt32BE(size, 4);\n\tihdr[8] = 8;\n\tihdr[9] = 6;\n\tihdr[10] = 0;\n\tihdr[11] = 0;\n\tihdr[12] = 0;\n\treturn Buffer.concat([\n\t\tBuffer.from([\n\t\t\t137,\n\t\t\t80,\n\t\t\t78,\n\t\t\t71,\n\t\t\t13,\n\t\t\t10,\n\t\t\t26,\n\t\t\t10\n\t\t]),\n\t\tchunk(\"IHDR\", ihdr),\n\t\tchunk(\"IDAT\", idat),\n\t\tchunk(\"IEND\", Buffer.alloc(0))\n\t]);\n}\nlet crcTable;\nfunction crc32(buf) {\n\tif (!crcTable) {\n\t\tcrcTable = [];\n\t\tfor (let n = 0; n < 256; n++) {\n\t\t\tlet c = n;\n\t\t\tfor (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n\t\t\tcrcTable[n] = c;\n\t\t}\n\t}\n\tlet crc = 4294967295;\n\tfor (let i = 0; i < buf.length; i++) crc = crcTable[(crc ^ buf[i]) & 255] ^ crc >>> 8;\n\treturn crc ^ 4294967295;\n}\nconst GITIGNORE = `# Generated tauri shell — only Cargo.lock and app-icon.png are tracked.\n/tauri-shell/target\n/tauri-shell/gen\n/tauri-shell/icons\n/tauri-shell/dist-stack\n/tauri-shell/binaries\n`;\nfunction scaffoldDesktopShell(hostDir, options) {\n\tconst created = [];\n\tconst skipped = [];\n\tfs.mkdirSync(hostDir, { recursive: true });\n\tconst iconFile = \"icon.png\";\n\tconst app = {\n\t\tidentifier: options.identifier,\n\t\tproductName: options.productName,\n\t\ticon: `./${iconFile}`,\n\t\twindow: {\n\t\t\ttitle: options.productName,\n\t\t\twidth: 1440,\n\t\t\theight: 900\n\t\t},\n\t\tfileAssociations: [{\n\t\t\text: [\"phd\"],\n\t\t\tname: \"Powerhouse Document\",\n\t\t\tmimeType: \"application/vnd.powerhouse.document+zip\"\n\t\t}]\n\t};\n\tappJsonSchema.parse(app);\n\tconst appJsonPath = path.join(hostDir, APP_JSON_FILE);\n\tif (fs.existsSync(appJsonPath) && !options.force) skipped.push(appJsonPath);\n\telse {\n\t\tfs.writeFileSync(appJsonPath, `${JSON.stringify(app, null, 2)}\\n`);\n\t\tcreated.push(appJsonPath);\n\t}\n\tconst iconPath = path.join(hostDir, iconFile);\n\tif (fs.existsSync(iconPath)) skipped.push(iconPath);\n\telse {\n\t\tfs.writeFileSync(iconPath, solidPng(1024, [\n\t\t\t79,\n\t\t\t70,\n\t\t\t229,\n\t\t\t255\n\t\t]));\n\t\tcreated.push(iconPath);\n\t}\n\tconst gitignorePath = path.join(hostDir, \".gitignore\");\n\tif (fs.existsSync(gitignorePath)) skipped.push(gitignorePath);\n\telse {\n\t\tfs.writeFileSync(gitignorePath, GITIGNORE);\n\t\tcreated.push(gitignorePath);\n\t}\n\treturn {\n\t\thostDir,\n\t\tcreated,\n\t\tskipped\n\t};\n}\n//#endregion\nexport { APP_JSON_FILE, DEFAULT_SHELL_CRATE_VERSION, ICON_SOURCE, SHELL_DIR, appJsonSchema, appSlug, bundleStack, detectToolchain, fetchNodeSidecar, launchShell, loadAppJson, nodeSidecarTarget, preflightOrThrow, projectShell, resolvePhCliEntry, resolveShell, resolveTauriCommand, runTauriIcon, scaffoldDesktopShell, shellEnv, solidPng, tauriBundlesForHost, tauriConfigPatch };\n\n//# sourceMappingURL=index.mjs.map","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { scaffoldDesktopShell } from \"@powerhousedao/desktop\";\n\nexport interface GenerateDesktopShellArgs {\n name?: string;\n identifier?: string;\n force?: boolean;\n}\n\n/** A reverse-DNS-safe segment from the project name (drop scope, slugify). */\nfunction projectSlug(pkgName: string | undefined): string {\n const bare = (pkgName ?? \"app\").replace(/^@[^/]+\\//, \"\");\n const seg = bare\n .toLowerCase()\n .replace(/[^a-z0-9-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n return seg || \"app\";\n}\n\n/** `ph generate desktop-shell`: write hosts/desktop/app.json + a placeholder\n * icon + .gitignore. Defaults product name / identifier from the project. */\nexport function startGenerateDesktopShell(\n args: GenerateDesktopShellArgs,\n cwd: string,\n): void {\n let pkgName: string | undefined;\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(cwd, \"package.json\"), \"utf8\"),\n ) as { name?: string };\n pkgName = pkg.name;\n } catch {\n // no package.json — fall back to defaults below\n }\n const slug = projectSlug(pkgName);\n const productName = args.name ?? pkgName?.replace(/^@[^/]+\\//, \"\") ?? \"App\";\n const identifier = args.identifier ?? `inc.powerhouse.desktop.${slug}`;\n\n const hostDir = path.join(cwd, \"hosts\", \"desktop\");\n const result = scaffoldDesktopShell(hostDir, {\n identifier,\n productName,\n force: args.force,\n });\n\n const rel = (p: string) => path.relative(cwd, p).replace(/\\\\/g, \"/\");\n for (const f of result.created) console.log(` created ${rel(f)}`);\n for (const f of result.skipped) {\n console.log(` skipped ${rel(f)} (exists — pass --force to overwrite)`);\n }\n if (!fs.existsSync(path.join(hostDir, \"host.js\"))) {\n console.log(\n `\\nNote: hosts/desktop/host.js not found. Add a desktop host (see the ` +\n `desktop topology from \\`ph init\\`) so \\`ph run desktop\\` can supervise ` +\n `the stack; app.json then gives it a native window.`,\n );\n }\n console.log(\n `\\nIdentity: ${productName} (${identifier}).\\n` +\n `• Replace hosts/desktop/icon.png with your 1024×1024 icon.\\n` +\n `• \\`ph run desktop dev\\` opens the native window (needs Rust + the Tauri CLI).\\n` +\n `• \\`ph run desktop build\\` produces installers for this OS.`,\n );\n}\n"],"names":["z.string","z.strictObject","z.number","z.boolean","z.array"],"mappings":"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","debug_id":"a9adde06-479d-5808-8d89-1e0461f76642"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="49439419-5f64-5ecf-a840-c46e50265dc2")}catch(e){}}();
|
|
3
|
+
import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-Jd6SeN-M.mjs";
|
|
3
4
|
import { dirname, join } from "node:path";
|
|
4
5
|
import { generateAllDocumentModels, generateDocumentModel, loadDocumentModel } from "@powerhousedao/codegen";
|
|
5
6
|
import { buildTsMorphProject } from "@powerhousedao/codegen/utils";
|
|
@@ -18,17 +19,28 @@ async function startGenerateDocumentModel(args, projectDir) {
|
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
21
|
if (all) await generateAllDocumentModels(project);
|
|
21
|
-
else if (document)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
else if (document) {
|
|
23
|
+
if (document.endsWith(".phd")) {
|
|
24
|
+
const doc = await getDocument(document);
|
|
25
|
+
await generateDocumentModelFromDocument(doc, project);
|
|
26
|
+
} else {
|
|
27
|
+
const state = await loadDocumentModel(document);
|
|
28
|
+
await generateDocumentModel(state, project);
|
|
29
|
+
}
|
|
30
|
+
} else if (dir) {
|
|
31
|
+
const documentModelFileName = `${dirname(dir)}.json`;
|
|
32
|
+
const documentModelFilePath = join(dir, documentModelFileName);
|
|
33
|
+
const state = await loadDocumentModel(documentModelFilePath);
|
|
34
|
+
await generateDocumentModel(state, project);
|
|
35
|
+
} else {
|
|
25
36
|
console.log("Please specify one of `document`, `dir`, `all`, or `extract`.");
|
|
26
37
|
return;
|
|
27
38
|
}
|
|
28
39
|
await project.save();
|
|
40
|
+
warnSubgraphTypeConflicts(projectDir);
|
|
29
41
|
}
|
|
30
42
|
//#endregion
|
|
31
43
|
export { startGenerateDocumentModel };
|
|
32
44
|
|
|
33
|
-
//# sourceMappingURL=generate-document-model-
|
|
34
|
-
//# debugId=
|
|
45
|
+
//# sourceMappingURL=generate-document-model-ChkXjM1s.mjs.map
|
|
46
|
+
//# debugId=49439419-5f64-5ecf-a840-c46e50265dc2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-document-model-ChkXjM1s.mjs","sources":["../src/services/generate-document-model.ts"],"sourcesContent":["import {\n generateAllDocumentModels,\n generateDocumentModel,\n loadDocumentModel,\n} from \"@powerhousedao/codegen\";\nimport { buildTsMorphProject } from \"@powerhousedao/codegen/utils\";\nimport {\n extractDocumentModelDocuments,\n generateDocumentModelFromDocument,\n getDocument,\n saveSpec,\n} from \"@powerhousedao/vetra/codegen\";\nimport type { DocumentModelDocument } from \"@powerhousedao/shared/document-model\";\nimport { dirname, join } from \"node:path\";\nimport type { GenerateDocumentModelArgs } from \"../types.js\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\n\nexport async function startGenerateDocumentModel(\n args: GenerateDocumentModelArgs,\n projectDir: string,\n) {\n const { document, dir, all, extract, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n if (extract) {\n const docs = extractDocumentModelDocuments(project);\n for (const doc of docs) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n if (all) {\n await generateAllDocumentModels(project);\n } else if (document) {\n if (document.endsWith(\".phd\")) {\n const doc = (await getDocument(document)) as DocumentModelDocument;\n await generateDocumentModelFromDocument(doc, project);\n } else {\n const state = await loadDocumentModel(document);\n await generateDocumentModel(state, project);\n }\n } else if (dir) {\n const documentModelDirName = dirname(dir);\n const documentModelFileName = `${documentModelDirName}.json`;\n const documentModelFilePath = join(dir, documentModelFileName);\n const state = await loadDocumentModel(documentModelFilePath);\n await generateDocumentModel(state, project);\n } else {\n console.log(\n \"Please specify one of `document`, `dir`, `all`, or `extract`.\",\n );\n return;\n }\n await project.save();\n warnSubgraphTypeConflicts(projectDir);\n}\n"],"names":[],"mappings":";;;;;;;;AAiBA,eAAsB,2BACpB,MACA,YACA;CACA,MAAM,EAAE,UAAU,KAAK,KAAK,SAAS,UAAU;CAC/C,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,SAAS;EACX,MAAM,OAAO,8BAA8B,OAAO;EAClD,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,OAAO,MAAM,SAAS,KAAK,UAAU;GAC3C,QAAQ,IAAI,SAAS,MAAM;EAC7B;EACA;CACF;CACA,IAAI,KACF,MAAM,0BAA0B,OAAO;MAClC,IAAI,UAAU;EACnB,IAAI,SAAS,SAAS,MAAM,GAAG;GAC7B,MAAM,MAAO,MAAM,YAAY,QAAQ;GACvC,MAAM,kCAAkC,KAAK,OAAO;EACtD,OAAO;GACL,MAAM,QAAQ,MAAM,kBAAkB,QAAQ;GAC9C,MAAM,sBAAsB,OAAO,OAAO;EAC5C;CACF,OAAO,IAAI,KAAK;EAEd,MAAM,wBAAwB,GADD,QAAQ,GACe,EAAE;EACtD,MAAM,wBAAwB,KAAK,KAAK,qBAAqB;EAC7D,MAAM,QAAQ,MAAM,kBAAkB,qBAAqB;EAC3D,MAAM,sBAAsB,OAAO,OAAO;CAC5C,OAAO;EACL,QAAQ,IACN,+DACF;EACA;CACF;CACA,MAAM,QAAQ,KAAK;CACnB,0BAA0B,UAAU;AACtC","debug_id":"49439419-5f64-5ecf-a840-c46e50265dc2"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b204b504-9786-5632-91d5-eaabb22de195")}catch(e){}}();
|
|
3
3
|
import { dirname } from "node:path";
|
|
4
4
|
import { generateAllEditors, generateEditor } from "@powerhousedao/codegen";
|
|
5
5
|
import { buildTsMorphProject, getEditorMetadata } from "@powerhousedao/codegen/utils";
|
|
@@ -18,8 +18,10 @@ async function startGenerateEditor(args, projectDir) {
|
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
if (all) await generateAllEditors(project);
|
|
21
|
-
else if (document)
|
|
22
|
-
|
|
21
|
+
else if (document) {
|
|
22
|
+
const doc = await getDocument(document);
|
|
23
|
+
await generateEditorFromDocument(doc, project);
|
|
24
|
+
} else if (name) {
|
|
23
25
|
if (!documentType) throw new Error("Please specify a document type for the new editor to generate.");
|
|
24
26
|
await generateEditor({
|
|
25
27
|
editorName: name,
|
|
@@ -44,5 +46,5 @@ async function startGenerateEditor(args, projectDir) {
|
|
|
44
46
|
//#endregion
|
|
45
47
|
export { startGenerateEditor };
|
|
46
48
|
|
|
47
|
-
//# sourceMappingURL=generate-editor-
|
|
48
|
-
//# debugId=
|
|
49
|
+
//# sourceMappingURL=generate-editor-CW7Do69u.mjs.map
|
|
50
|
+
//# debugId=b204b504-9786-5632-91d5-eaabb22de195
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-editor-
|
|
1
|
+
{"version":3,"file":"generate-editor-CW7Do69u.mjs","sources":["../src/services/generate-editor.ts"],"sourcesContent":["import { generateAllEditors, generateEditor } from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n getEditorMetadata,\n} from \"@powerhousedao/codegen/utils\";\nimport {\n extractEditorDocuments,\n generateEditorFromDocument,\n getDocument,\n saveSpec,\n} from \"@powerhousedao/vetra/codegen\";\nimport type { DocumentEditorDocument } from \"@powerhousedao/vetra/document-models/document-editor\";\nimport { dirname } from \"node:path\";\nimport type { GenerateEditorArgs } from \"../types.js\";\n\nexport async function startGenerateEditor(\n args: GenerateEditorArgs,\n projectDir: string,\n) {\n const { name, documentType, document, dir, all, extract, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n if (extract) {\n const docs = extractEditorDocuments(project);\n for (const doc of docs) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n if (all) {\n await generateAllEditors(project);\n } else if (document) {\n const doc = (await getDocument(document)) as DocumentEditorDocument;\n await generateEditorFromDocument(doc, project);\n } else if (name) {\n if (!documentType) {\n throw new Error(\n \"Please specify a document type for the new editor to generate.\",\n );\n }\n await generateEditor(\n { editorName: name, documentTypes: [documentType] },\n project,\n );\n } else if (dir) {\n const editorArgs = getEditorMetadata(project, dirname(dir));\n if (!editorArgs) {\n throw new Error(`Failed to get data for editor in dir \"${dir}\"`);\n }\n const {\n name: editorName,\n id: editorId,\n dirName: editorDirName,\n documentTypes,\n } = editorArgs;\n await generateEditor(\n {\n editorName,\n editorId,\n editorDirName,\n documentTypes,\n },\n project,\n );\n } else {\n console.log(\n \"Please specify one of `name`, `document`, `dir`, `all`, or `extract`.\",\n );\n return;\n }\n await project.save();\n}\n"],"names":[],"mappings":";;;;;;;AAeA,eAAsB,oBACpB,MACA,YACA;CACA,MAAM,EAAE,MAAM,cAAc,UAAU,KAAK,KAAK,SAAS,UAAU;CACnE,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,SAAS;EACX,MAAM,OAAO,uBAAuB,OAAO;EAC3C,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,OAAO,MAAM,SAAS,KAAK,UAAU;GAC3C,QAAQ,IAAI,SAAS,MAAM;EAC7B;EACA;CACF;CACA,IAAI,KACF,MAAM,mBAAmB,OAAO;MAC3B,IAAI,UAAU;EACnB,MAAM,MAAO,MAAM,YAAY,QAAQ;EACvC,MAAM,2BAA2B,KAAK,OAAO;CAC/C,OAAO,IAAI,MAAM;EACf,IAAI,CAAC,cACH,MAAM,IAAI,MACR,gEACF;EAEF,MAAM,eACJ;GAAE,YAAY;GAAM,eAAe,CAAC,YAAY;EAAE,GAClD,OACF;CACF,OAAO,IAAI,KAAK;EACd,MAAM,aAAa,kBAAkB,SAAS,QAAQ,GAAG,CAAC;EAC1D,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,yCAAyC,IAAI,EAAE;EAEjE,MAAM,EACJ,MAAM,YACN,IAAI,UACJ,SAAS,eACT,kBACE;EACJ,MAAM,eACJ;GACE;GACA;GACA;GACA;EACF,GACA,OACF;CACF,OAAO;EACL,QAAQ,IACN,uEACF;EACA;CACF;CACA,MAAM,QAAQ,KAAK;AACrB","debug_id":"b204b504-9786-5632-91d5-eaabb22de195"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8b015725-4996-50bb-890c-e6cf4750fe5e")}catch(e){}}();
|
|
3
|
+
import { t as installAddedDependencies } from "./install-added-dependencies-DVSbzler.mjs";
|
|
4
|
+
import { basename } from "node:path";
|
|
5
|
+
import { readPackage } from "read-pkg";
|
|
6
|
+
import { detectFeatures, generateAllPieces, generatePiece, syncFeatureDependencies } from "@powerhousedao/codegen";
|
|
7
|
+
import { buildTsMorphProject, readPiecesList } from "@powerhousedao/codegen/utils";
|
|
8
|
+
import { derivePieceId } from "@powerhousedao/codegen/name-builders";
|
|
9
|
+
import { kebabCase } from "change-case";
|
|
10
|
+
import enquirer from "enquirer";
|
|
11
|
+
//#region src/services/generate-piece.ts
|
|
12
|
+
async function resolvePieceId(v) {
|
|
13
|
+
if (v.id) return v.id;
|
|
14
|
+
const pkg = await readPackage({
|
|
15
|
+
cwd: v.projectDir,
|
|
16
|
+
normalize: false
|
|
17
|
+
});
|
|
18
|
+
const { id, needsConfirmation } = derivePieceId({
|
|
19
|
+
packageName: pkg.name ?? "",
|
|
20
|
+
slug: kebabCase(v.pieceName),
|
|
21
|
+
hasOtherPieces: readPiecesList(v.project).length > 0
|
|
22
|
+
});
|
|
23
|
+
if (!needsConfirmation || !process.stdin.isTTY) return id;
|
|
24
|
+
const { prompt } = enquirer;
|
|
25
|
+
return (await prompt([{
|
|
26
|
+
type: "input",
|
|
27
|
+
name: "pieceId",
|
|
28
|
+
message: "What id should this piece have? A workflow step names it as its pieceName.",
|
|
29
|
+
initial: id,
|
|
30
|
+
required: true
|
|
31
|
+
}])).pieceId || id;
|
|
32
|
+
}
|
|
33
|
+
async function startGeneratePiece(args, projectDir) {
|
|
34
|
+
const { namePositional, name: nameOption, id, auth, description, dir, all, debug } = args;
|
|
35
|
+
if (debug) console.log({ args });
|
|
36
|
+
const project = buildTsMorphProject(projectDir);
|
|
37
|
+
const name = namePositional ?? nameOption;
|
|
38
|
+
if (all) await generateAllPieces(project);
|
|
39
|
+
else if (dir) await generateAllPieces(project, basename(dir.replace(/\/+$/, "")));
|
|
40
|
+
else if (name) {
|
|
41
|
+
const pieceId = await resolvePieceId({
|
|
42
|
+
project,
|
|
43
|
+
projectDir,
|
|
44
|
+
pieceName: name,
|
|
45
|
+
id
|
|
46
|
+
});
|
|
47
|
+
await generatePiece({
|
|
48
|
+
pieceName: name,
|
|
49
|
+
pieceId,
|
|
50
|
+
auth,
|
|
51
|
+
description
|
|
52
|
+
}, project);
|
|
53
|
+
} else {
|
|
54
|
+
console.log("Please specify one of `name`, `dir`, or `all`.");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
await project.save();
|
|
58
|
+
const added = await syncFeatureDependencies(detectFeatures(projectDir), projectDir);
|
|
59
|
+
await installAddedDependencies(added, projectDir, args.skipInstall);
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { startGeneratePiece };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=generate-piece-QTt-ddt2.mjs.map
|
|
65
|
+
//# debugId=8b015725-4996-50bb-890c-e6cf4750fe5e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-piece-QTt-ddt2.mjs","sources":["../src/services/generate-piece.ts"],"sourcesContent":["import {\n detectFeatures,\n generateAllPieces,\n generatePiece,\n syncFeatureDependencies,\n} from \"@powerhousedao/codegen\";\nimport { derivePieceId } from \"@powerhousedao/codegen/name-builders\";\nimport {\n buildTsMorphProject,\n readPiecesList,\n} from \"@powerhousedao/codegen/utils\";\nimport { kebabCase } from \"change-case\";\nimport enquirer from \"enquirer\";\nimport { basename } from \"node:path\";\nimport { readPackage } from \"read-pkg\";\nimport type { Project } from \"ts-morph\";\nimport type { GeneratePieceArgs } from \"../types.js\";\nimport { installAddedDependencies } from \"../utils/install-added-dependencies.js\";\n\n// The id a block type will name, asked for only where deriving one would claim\n// a namespace nobody owns; CI, with no TTY, takes the derived value.\nasync function resolvePieceId(v: {\n project: Project;\n projectDir: string;\n pieceName: string;\n id?: string;\n}): Promise<string> {\n if (v.id) return v.id;\n const pkg = await readPackage({ cwd: v.projectDir, normalize: false });\n const { id, needsConfirmation } = derivePieceId({\n packageName: pkg.name ?? \"\",\n slug: kebabCase(v.pieceName),\n hasOtherPieces: readPiecesList(v.project).length > 0,\n });\n if (!needsConfirmation || !process.stdin.isTTY) return id;\n const { prompt } = enquirer;\n const result = await prompt<{ pieceId: string }>([\n {\n type: \"input\",\n name: \"pieceId\",\n message:\n \"What id should this piece have? A workflow step names it as its pieceName.\",\n initial: id,\n required: true,\n },\n ]);\n return result.pieceId || id;\n}\n\nexport async function startGeneratePiece(\n args: GeneratePieceArgs,\n projectDir: string,\n) {\n const {\n namePositional,\n name: nameOption,\n id,\n auth,\n description,\n dir,\n all,\n debug,\n } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n const name = namePositional ?? nameOption;\n if (all) {\n await generateAllPieces(project);\n } else if (dir) {\n await generateAllPieces(project, basename(dir.replace(/\\/+$/, \"\")));\n } else if (name) {\n const pieceId = await resolvePieceId({\n project,\n projectDir,\n pieceName: name,\n id,\n });\n await generatePiece(\n { pieceName: name, pieceId, auth, description },\n project,\n );\n } else {\n console.log(\"Please specify one of `name`, `dir`, or `all`.\");\n return;\n }\n await project.save();\n const added = await syncFeatureDependencies(\n detectFeatures(projectDir),\n projectDir,\n );\n await installAddedDependencies(added, projectDir, args.skipInstall);\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqBA,eAAe,eAAe,GAKV;CAClB,IAAI,EAAE,IAAI,OAAO,EAAE;CACnB,MAAM,MAAM,MAAM,YAAY;EAAE,KAAK,EAAE;EAAY,WAAW;CAAM,CAAC;CACrE,MAAM,EAAE,IAAI,sBAAsB,cAAc;EAC9C,aAAa,IAAI,QAAQ;EACzB,MAAM,UAAU,EAAE,SAAS;EAC3B,gBAAgB,eAAe,EAAE,OAAO,CAAC,CAAC,SAAS;CACrD,CAAC;CACD,IAAI,CAAC,qBAAqB,CAAC,QAAQ,MAAM,OAAO,OAAO;CACvD,MAAM,EAAE,WAAW;CAWnB,QAAO,MAVc,OAA4B,CAC/C;EACE,MAAM;EACN,MAAM;EACN,SACE;EACF,SAAS;EACT,UAAU;CACZ,CACF,CAAC,EAAA,CACa,WAAW;AAC3B;AAEA,eAAsB,mBACpB,MACA,YACA;CACA,MAAM,EACJ,gBACA,MAAM,YACN,IACA,MACA,aACA,KACA,KACA,UACE;CACJ,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,MAAM,OAAO,kBAAkB;CAC/B,IAAI,KACF,MAAM,kBAAkB,OAAO;MAC1B,IAAI,KACT,MAAM,kBAAkB,SAAS,SAAS,IAAI,QAAQ,QAAQ,EAAE,CAAC,CAAC;MAC7D,IAAI,MAAM;EACf,MAAM,UAAU,MAAM,eAAe;GACnC;GACA;GACA,WAAW;GACX;EACF,CAAC;EACD,MAAM,cACJ;GAAE,WAAW;GAAM;GAAS;GAAM;EAAY,GAC9C,OACF;CACF,OAAO;EACL,QAAQ,IAAI,gDAAgD;EAC5D;CACF;CACA,MAAM,QAAQ,KAAK;CACnB,MAAM,QAAQ,MAAM,wBAClB,eAAe,UAAU,GACzB,UACF;CACA,MAAM,yBAAyB,OAAO,YAAY,KAAK,WAAW;AACpE","debug_id":"8b015725-4996-50bb-890c-e6cf4750fe5e"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f49d0352-90e3-5961-b001-c9dfb74af954")}catch(e){}}();
|
|
3
|
+
import { t as installAddedDependencies } from "./install-added-dependencies-DVSbzler.mjs";
|
|
4
|
+
import { detectFeatures, generatePieceAction, syncFeatureDependencies } from "@powerhousedao/codegen";
|
|
5
|
+
import { buildTsMorphProject } from "@powerhousedao/codegen/utils";
|
|
6
|
+
//#region src/services/generate-piece-action.ts
|
|
7
|
+
async function startGeneratePieceAction(args, projectDir) {
|
|
8
|
+
const { namePositional, name: nameOption, piece, requireReactor, debug } = args;
|
|
9
|
+
if (debug) console.log({ args });
|
|
10
|
+
const actionName = namePositional ?? nameOption;
|
|
11
|
+
if (!actionName) {
|
|
12
|
+
console.log("Please specify the name of the action to generate.");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const project = buildTsMorphProject(projectDir);
|
|
16
|
+
await generatePieceAction({
|
|
17
|
+
pieceDir: piece,
|
|
18
|
+
actionName,
|
|
19
|
+
requireReactor
|
|
20
|
+
}, project);
|
|
21
|
+
await project.save();
|
|
22
|
+
const added = await syncFeatureDependencies(detectFeatures(projectDir), projectDir);
|
|
23
|
+
await installAddedDependencies(added, projectDir, args.skipInstall);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { startGeneratePieceAction };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=generate-piece-action-DbxrzfKY.mjs.map
|
|
29
|
+
//# debugId=f49d0352-90e3-5961-b001-c9dfb74af954
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-piece-action-DbxrzfKY.mjs","sources":["../src/services/generate-piece-action.ts"],"sourcesContent":["import {\n detectFeatures,\n generatePieceAction,\n syncFeatureDependencies,\n} from \"@powerhousedao/codegen\";\nimport { buildTsMorphProject } from \"@powerhousedao/codegen/utils\";\nimport type { GeneratePieceActionArgs } from \"../types.js\";\nimport { installAddedDependencies } from \"../utils/install-added-dependencies.js\";\n\nexport async function startGeneratePieceAction(\n args: GeneratePieceActionArgs,\n projectDir: string,\n) {\n const {\n namePositional,\n name: nameOption,\n piece,\n requireReactor,\n debug,\n } = args;\n if (debug) {\n console.log({ args });\n }\n const actionName = namePositional ?? nameOption;\n if (!actionName) {\n console.log(\"Please specify the name of the action to generate.\");\n return;\n }\n const project = buildTsMorphProject(projectDir);\n await generatePieceAction(\n { pieceDir: piece, actionName, requireReactor },\n project,\n );\n await project.save();\n const added = await syncFeatureDependencies(\n detectFeatures(projectDir),\n projectDir,\n );\n await installAddedDependencies(added, projectDir, args.skipInstall);\n}\n"],"names":[],"mappings":";;;;;;AASA,eAAsB,yBACpB,MACA,YACA;CACA,MAAM,EACJ,gBACA,MAAM,YACN,OACA,gBACA,UACE;CACJ,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,aAAa,kBAAkB;CACrC,IAAI,CAAC,YAAY;EACf,QAAQ,IAAI,oDAAoD;EAChE;CACF;CACA,MAAM,UAAU,oBAAoB,UAAU;CAC9C,MAAM,oBACJ;EAAE,UAAU;EAAO;EAAY;CAAe,GAC9C,OACF;CACA,MAAM,QAAQ,KAAK;CACnB,MAAM,QAAQ,MAAM,wBAClB,eAAe,UAAU,GACzB,UACF;CACA,MAAM,yBAAyB,OAAO,YAAY,KAAK,WAAW;AACpE","debug_id":"f49d0352-90e3-5961-b001-c9dfb74af954"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="94b307ac-d424-5f25-b521-b085d75090f1")}catch(e){}}();
|
|
3
|
+
import { t as installAddedDependencies } from "./install-added-dependencies-DVSbzler.mjs";
|
|
4
|
+
import { detectFeatures, generatePieceTrigger, syncFeatureDependencies } from "@powerhousedao/codegen";
|
|
5
|
+
import { buildTsMorphProject } from "@powerhousedao/codegen/utils";
|
|
6
|
+
//#region src/services/generate-piece-trigger.ts
|
|
7
|
+
async function startGeneratePieceTrigger(args, projectDir) {
|
|
8
|
+
const { namePositional, name: nameOption, piece, strategy, requireReactor, debug } = args;
|
|
9
|
+
if (debug) console.log({ args });
|
|
10
|
+
const triggerName = namePositional ?? nameOption;
|
|
11
|
+
if (!triggerName) {
|
|
12
|
+
console.log("Please specify the name of the trigger to generate.");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const project = buildTsMorphProject(projectDir);
|
|
16
|
+
await generatePieceTrigger({
|
|
17
|
+
pieceDir: piece,
|
|
18
|
+
triggerName,
|
|
19
|
+
strategy,
|
|
20
|
+
requireReactor
|
|
21
|
+
}, project);
|
|
22
|
+
await project.save();
|
|
23
|
+
const added = await syncFeatureDependencies(detectFeatures(projectDir), projectDir);
|
|
24
|
+
await installAddedDependencies(added, projectDir, args.skipInstall);
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { startGeneratePieceTrigger };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=generate-piece-trigger-CqVOcL9g.mjs.map
|
|
30
|
+
//# debugId=94b307ac-d424-5f25-b521-b085d75090f1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-piece-trigger-CqVOcL9g.mjs","sources":["../src/services/generate-piece-trigger.ts"],"sourcesContent":["import {\n detectFeatures,\n generatePieceTrigger,\n syncFeatureDependencies,\n} from \"@powerhousedao/codegen\";\nimport { buildTsMorphProject } from \"@powerhousedao/codegen/utils\";\nimport type { GeneratePieceTriggerArgs } from \"../types.js\";\nimport { installAddedDependencies } from \"../utils/install-added-dependencies.js\";\n\nexport async function startGeneratePieceTrigger(\n args: GeneratePieceTriggerArgs,\n projectDir: string,\n) {\n const {\n namePositional,\n name: nameOption,\n piece,\n strategy,\n requireReactor,\n debug,\n } = args;\n if (debug) {\n console.log({ args });\n }\n const triggerName = namePositional ?? nameOption;\n if (!triggerName) {\n console.log(\"Please specify the name of the trigger to generate.\");\n return;\n }\n const project = buildTsMorphProject(projectDir);\n await generatePieceTrigger(\n { pieceDir: piece, triggerName, strategy, requireReactor },\n project,\n );\n await project.save();\n const added = await syncFeatureDependencies(\n detectFeatures(projectDir),\n projectDir,\n );\n await installAddedDependencies(added, projectDir, args.skipInstall);\n}\n"],"names":[],"mappings":";;;;;;AASA,eAAsB,0BACpB,MACA,YACA;CACA,MAAM,EACJ,gBACA,MAAM,YACN,OACA,UACA,gBACA,UACE;CACJ,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,cAAc,kBAAkB;CACtC,IAAI,CAAC,aAAa;EAChB,QAAQ,IAAI,qDAAqD;EACjE;CACF;CACA,MAAM,UAAU,oBAAoB,UAAU;CAC9C,MAAM,qBACJ;EAAE,UAAU;EAAO;EAAa;EAAU;CAAe,GACzD,OACF;CACA,MAAM,QAAQ,KAAK;CACnB,MAAM,QAAQ,MAAM,wBAClB,eAAe,UAAU,GACzB,UACF;CACA,MAAM,yBAAyB,OAAO,YAAY,KAAK,WAAW;AACpE","debug_id":"94b307ac-d424-5f25-b521-b085d75090f1"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4c9267c1-f9f5-5d39-a420-380970da035c")}catch(e){}}();
|
|
3
|
+
import { t as installAddedDependencies } from "./install-added-dependencies-DVSbzler.mjs";
|
|
3
4
|
import { dirname } from "node:path";
|
|
4
5
|
import { detectFeatures, generateAllProcessors, generateProcessor, syncFeatureDependencies } from "@powerhousedao/codegen";
|
|
5
6
|
import { buildTsMorphProject, getProcessorMetadata } from "@powerhousedao/codegen/utils";
|
|
@@ -18,23 +19,29 @@ async function startGenerateProcessor(args, projectDir) {
|
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
21
|
if (all) await generateAllProcessors(project);
|
|
21
|
-
else if (document)
|
|
22
|
-
|
|
22
|
+
else if (document) {
|
|
23
|
+
const doc = await getDocument(document);
|
|
24
|
+
await generateProcessorFromDocument(doc, project);
|
|
25
|
+
} else if (processorName) await generateProcessor({
|
|
23
26
|
processorName,
|
|
24
27
|
processorApps,
|
|
25
28
|
processorType,
|
|
26
29
|
documentTypes
|
|
27
30
|
}, project);
|
|
28
|
-
else if (dir)
|
|
29
|
-
|
|
31
|
+
else if (dir) {
|
|
32
|
+
const processorDirName = dirname(dir);
|
|
33
|
+
const processorArgs = getProcessorMetadata(project, processorDirName);
|
|
34
|
+
await generateProcessor(processorArgs, project);
|
|
35
|
+
} else {
|
|
30
36
|
console.log("Please specify one of `name`, `document`, `dir`, `all`, or `extract`.");
|
|
31
37
|
return;
|
|
32
38
|
}
|
|
33
39
|
await project.save();
|
|
34
|
-
await syncFeatureDependencies(detectFeatures(projectDir), projectDir);
|
|
40
|
+
const added = await syncFeatureDependencies(detectFeatures(projectDir), projectDir);
|
|
41
|
+
await installAddedDependencies(added, projectDir, args.skipInstall);
|
|
35
42
|
}
|
|
36
43
|
//#endregion
|
|
37
44
|
export { startGenerateProcessor };
|
|
38
45
|
|
|
39
|
-
//# sourceMappingURL=generate-processor-
|
|
40
|
-
//# debugId=
|
|
46
|
+
//# sourceMappingURL=generate-processor-DBtTkgo5.mjs.map
|
|
47
|
+
//# debugId=4c9267c1-f9f5-5d39-a420-380970da035c
|