@powerhousedao/ph-cli 6.2.3-dev.5 → 6.2.3-dev.51
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-b4kKqgOZ.mjs} +62 -27
- package/dist/cli-connect-override-b4kKqgOZ.mjs.map +1 -0
- package/dist/cli.d.mts +2 -1
- package/dist/cli.mjs +326 -89
- package/dist/cli.mjs.map +1 -1
- package/dist/connect-build-BLxeFrSb.mjs +218 -0
- package/dist/connect-build-BLxeFrSb.mjs.map +1 -0
- package/dist/{connect-config-BWGiW3IB.mjs → connect-config-DGfPEeP8.mjs} +19 -12
- package/dist/connect-config-DGfPEeP8.mjs.map +1 -0
- package/dist/{connect-preview-D7ypzFDc.mjs → connect-preview-CzDqR-JN.mjs} +12 -8
- package/dist/{connect-preview-D7ypzFDc.mjs.map → connect-preview-CzDqR-JN.mjs.map} +1 -1
- package/dist/{connect-studio-D6rfWCNB.mjs → connect-studio-_-O1-oef.mjs} +15 -10
- package/dist/{connect-studio-D6rfWCNB.mjs.map → connect-studio-_-O1-oef.mjs.map} +1 -1
- package/dist/connect-studio-f3K1qPWd.mjs +4 -0
- package/dist/{generate-all-DrT4ZxHX.mjs → generate-all-CIwP-3aa.mjs} +3 -3
- package/dist/{generate-all-DrT4ZxHX.mjs.map → generate-all-CIwP-3aa.mjs.map} +1 -1
- 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-document-model-BJXyODfm.mjs → generate-document-model-DhDQ_06X.mjs} +17 -7
- package/dist/{generate-document-model-BJXyODfm.mjs.map → generate-document-model-DhDQ_06X.mjs.map} +1 -1
- 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-Dm27O59o.mjs} +10 -6
- package/dist/generate-subgraph-Dm27O59o.mjs.map +1 -0
- package/dist/{init-BZP6gvYd.mjs → init-CIEMyAug.mjs} +4 -4
- package/dist/{init-BZP6gvYd.mjs.map → init-CIEMyAug.mjs.map} +1 -1
- 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/{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/scripts/generate-commands-docs.ts +8 -0
- package/dist/switchboard-KQaBlAda.mjs +131 -0
- package/dist/switchboard-KQaBlAda.mjs.map +1 -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-yDRjakQT.mjs +4 -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-CPGUTtaF.mjs} +64 -16
- package/dist/vetra-CPGUTtaF.mjs.map +1 -0
- package/package.json +18 -16
- 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-studio-BIQzyq5B.mjs +0 -5
- package/dist/generate-processor-_WOx-mMe.mjs.map +0 -1
- package/dist/generate-subgraph-BsHUstpl.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":"registry-auth-
|
|
1
|
+
{"version":3,"file":"registry-auth-Bm5AR-fB.mjs","sources":["../src/services/registry-auth.ts"],"sourcesContent":["import { generateAccessToken } from \"@renown/sdk/node\";\nimport { getRenown } from \"./auth.js\";\n\n/**\n * Mint a Renown bearer token bound to the given registry URL via the JWT\n * `aud` claim. Throws if the user is not authenticated (`ph login` first).\n *\n * The audience binding is what lets the registry distinguish a token minted\n * for it from one minted for a different service or registry.\n */\nexport async function mintRegistryAuthToken(\n registryUrl: string,\n expiresInSeconds: number,\n): Promise<string> {\n const renown = await getRenown();\n if (!renown.user) {\n throw new Error(\"Not authenticated with Renown. Run 'ph login' first.\");\n }\n const result = await generateAccessToken(renown, {\n expiresIn: expiresInSeconds,\n aud: registryUrl,\n });\n return result.token;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAUA,eAAsB,sBACpB,aACA,kBACiB;CACjB,MAAM,SAAS,MAAM,UAAU;CAC/B,IAAI,CAAC,OAAO,MACV,MAAM,IAAI,MAAM,sDAAsD;CAMxE,QAAO,MAJc,oBAAoB,QAAQ;EAC/C,WAAW;EACX,KAAK;CACP,CAAC,EAAA,CACa;AAChB","debug_id":"d0d0a6bc-dc22-5a36-9c82-560310b04535"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { writeCliDocsMarkdownFile } from "@powerhousedao/codegen/file-builders";
|
|
2
2
|
import { accessToken } from "../src/commands/access-token.js";
|
|
3
|
+
import { build as buildCmd } from "../src/commands/build.js";
|
|
3
4
|
import { build, connect, preview, studio } from "../src/commands/connect.js";
|
|
4
5
|
import { generateAllCmd } from "../src/commands/generate-all.js";
|
|
5
6
|
import { generateAppCmd } from "../src/commands/generate-app.js";
|
|
6
7
|
import { generateDocumentModelCmd } from "../src/commands/generate-document-model.js";
|
|
7
8
|
import { generateEditorCmd } from "../src/commands/generate-editor.js";
|
|
8
9
|
import { generateMigrationFileCmd } from "../src/commands/generate-migration-file.js";
|
|
10
|
+
import { generatePieceActionCmd } from "../src/commands/generate-piece-action.js";
|
|
11
|
+
import { generatePieceTriggerCmd } from "../src/commands/generate-piece-trigger.js";
|
|
12
|
+
import { generatePieceCmd } from "../src/commands/generate-piece.js";
|
|
9
13
|
import { generateProcessorCmd } from "../src/commands/generate-processor.js";
|
|
10
14
|
import { generateSubgraphCmd } from "../src/commands/generate-subgraph.js";
|
|
11
15
|
import { generate } from "../src/commands/generate.js";
|
|
@@ -27,8 +31,12 @@ const commands = [
|
|
|
27
31
|
{ name: "app", command: generateAppCmd },
|
|
28
32
|
{ name: "processor", command: generateProcessorCmd },
|
|
29
33
|
{ name: "subgraph", command: generateSubgraphCmd },
|
|
34
|
+
{ name: "piece", command: generatePieceCmd },
|
|
35
|
+
{ name: "piece-action", command: generatePieceActionCmd },
|
|
36
|
+
{ name: "piece-trigger", command: generatePieceTriggerCmd },
|
|
30
37
|
{ name: "migration-file", command: generateMigrationFileCmd },
|
|
31
38
|
{ name: "vetra", command: vetra },
|
|
39
|
+
{ name: "build", command: buildCmd },
|
|
32
40
|
{ name: "connect", command: connect },
|
|
33
41
|
{ name: "connect studio", command: studio },
|
|
34
42
|
{ name: "connect build", command: build },
|
|
@@ -0,0 +1,131 @@
|
|
|
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]="066aa87f-d5aa-521b-a172-e762487529b4")}catch(e){}}();
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { startSwitchboard } from "@powerhousedao/switchboard/server";
|
|
5
|
+
//#region src/utils/drive-icons.ts
|
|
6
|
+
/**
|
|
7
|
+
* Icon for the drives ph-cli creates, inlined as a data URI.
|
|
8
|
+
*
|
|
9
|
+
* This used to be an IPFS URL on a private gateway, which now answers 403 -
|
|
10
|
+
* and a drive stores its icon as a plain URL in document state, so the moment
|
|
11
|
+
* that URL rots every client renders a broken image, for as long as the drive
|
|
12
|
+
* exists. A public gateway would only move the problem: IPFS gateways are
|
|
13
|
+
* frequently overloaded, and a drive icon must not depend on the network at
|
|
14
|
+
* all.
|
|
15
|
+
*
|
|
16
|
+
* A data URI keeps the asset inside this package and inside the drive: no
|
|
17
|
+
* fetch, no gateway, no deploy-base or cross-origin question, and nothing to
|
|
18
|
+
* 404. A few hundred bytes - the size of the string below is the entire cost,
|
|
19
|
+
* paid once in the drive's state.
|
|
20
|
+
*
|
|
21
|
+
* Kept URL-encoded rather than base64 so the markup stays readable and
|
|
22
|
+
* reviewable (`#` must be `%23`; `<`, `>`, `"` and the CSS braces are legal
|
|
23
|
+
* enough in a data URI but are encoded so the value is also safe to paste
|
|
24
|
+
* into markup).
|
|
25
|
+
*/
|
|
26
|
+
/** Encodes an SVG for use in a `data:` URI, smaller than base64 and readable. */
|
|
27
|
+
function svgDataUri(svg) {
|
|
28
|
+
return `data:image/svg+xml,${svg.replace(/\s+/g, " ").trim().replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/"/g, "%22").replace(/\{/g, "%7B").replace(/\}/g, "%7D")}`;
|
|
29
|
+
}
|
|
30
|
+
const PETALS = [
|
|
31
|
+
"M0 4.6C0 2.1 2.1 0 4.6 0h21.2c2.5 0 4.6 2.1 4.6 4.6v2.8c0 12.7-10.3 23-23 23H4.6C2.1 30.4 0 28.4 0 25.8V4.6Z",
|
|
32
|
+
"M33.6 56.6c0-12.7 10.3-23 23-23h2.8c2.5 0 4.6 2.1 4.6 4.6v21.2c0 2.5-2.1 4.6-4.6 4.6H38.2c-2.5 0-4.6-2.1-4.6-4.6v-2.8Z",
|
|
33
|
+
"M0 38.2c0-2.5 2.1-4.6 4.6-4.6h2.8c12.7 0 23 10.3 23 23v2.8c0 2.5-2.1 4.6-4.6 4.6H4.6C2.1 64 0 61.9 0 59.4V38.2Z",
|
|
34
|
+
"M33.6 4.6C33.6 2.1 35.6 0 38.2 0h21.2C61.9 0 64 2.1 64 4.6v21.2c0 2.5-2.1 4.6-4.6 4.6h-2.8c-12.7 0-23-10.3-23-23V4.6Z"
|
|
35
|
+
];
|
|
36
|
+
/** Icon for the drives ph-cli creates. */
|
|
37
|
+
const POWERHOUSE_DRIVE_ICON = svgDataUri(`
|
|
38
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="32" height="32">
|
|
39
|
+
<style>
|
|
40
|
+
path { fill: #404345 }
|
|
41
|
+
@media (prefers-color-scheme: dark) { path { fill: #F3F5F7 } }
|
|
42
|
+
</style>
|
|
43
|
+
<path d="${PETALS[0]}"/>
|
|
44
|
+
<path d="${PETALS[1]}"/>
|
|
45
|
+
<path d="${PETALS[2]}"/>
|
|
46
|
+
<path d="${PETALS[3]}"/>
|
|
47
|
+
</svg>`);
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/services/switchboard.ts
|
|
50
|
+
const EGRESS_ALLOW_ENV = "PH_WORKFLOWS_EGRESS_ALLOW_ADDRESSES";
|
|
51
|
+
const LOCALHOST_ADDRESSES = ["127.0.0.1/32", "::1/128"];
|
|
52
|
+
function allowLocalhostEgress(env = process.env) {
|
|
53
|
+
const current = (env[EGRESS_ALLOW_ENV] ?? "").split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
|
|
54
|
+
const missing = LOCALHOST_ADDRESSES.filter((address) => !current.includes(address));
|
|
55
|
+
if (missing.length > 0) env[EGRESS_ALLOW_ENV] = [...current, ...missing].join(",");
|
|
56
|
+
}
|
|
57
|
+
const defaultSwitchboardOptions = {
|
|
58
|
+
port: 4001,
|
|
59
|
+
dbPath: path.join(process.cwd(), ".ph/read-model.db"),
|
|
60
|
+
drive: {
|
|
61
|
+
id: "powerhouse",
|
|
62
|
+
slug: "powerhouse",
|
|
63
|
+
global: {
|
|
64
|
+
name: "Powerhouse",
|
|
65
|
+
icon: "https://ipfs.io/ipfs/QmcaTDBYn8X2psGaXe7iQ6qd8q6oqHLgxvMX9yXf7f9uP7"
|
|
66
|
+
},
|
|
67
|
+
local: {
|
|
68
|
+
availableOffline: true,
|
|
69
|
+
listeners: [],
|
|
70
|
+
sharingType: "public",
|
|
71
|
+
triggers: []
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
mcp: true
|
|
75
|
+
};
|
|
76
|
+
function getDefaultVetraSwitchboardOptions(vetraDriveId) {
|
|
77
|
+
return {
|
|
78
|
+
port: 4001,
|
|
79
|
+
dbPath: path.join(process.cwd(), ".ph/read-model.db"),
|
|
80
|
+
drive: {
|
|
81
|
+
id: vetraDriveId,
|
|
82
|
+
slug: vetraDriveId,
|
|
83
|
+
global: {
|
|
84
|
+
name: "Vetra",
|
|
85
|
+
icon: POWERHOUSE_DRIVE_ICON
|
|
86
|
+
},
|
|
87
|
+
preferredEditor: "vetra-drive-app",
|
|
88
|
+
local: {
|
|
89
|
+
availableOffline: true,
|
|
90
|
+
listeners: [],
|
|
91
|
+
sharingType: "public",
|
|
92
|
+
triggers: []
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async function startSwitchboard$1(options, logger) {
|
|
98
|
+
const { packages: packagesString, remoteDrives, useVetraDrive, vetraDriveId, useIdentity, keypairPath, requireIdentity, ...serverOptions } = options;
|
|
99
|
+
if (useVetraDrive || serverOptions.dev) allowLocalhostEgress();
|
|
100
|
+
const defaultOptions = useVetraDrive ? getDefaultVetraSwitchboardOptions(vetraDriveId) : defaultSwitchboardOptions;
|
|
101
|
+
const identity = useIdentity || keypairPath || requireIdentity ? {
|
|
102
|
+
keypairPath,
|
|
103
|
+
requireExisting: requireIdentity
|
|
104
|
+
} : void 0;
|
|
105
|
+
const packages = packagesString?.split(",");
|
|
106
|
+
const finalOptions = remoteDrives.length > 0 ? {
|
|
107
|
+
...defaultOptions,
|
|
108
|
+
drive: void 0,
|
|
109
|
+
...serverOptions,
|
|
110
|
+
remoteDrives,
|
|
111
|
+
identity,
|
|
112
|
+
packages,
|
|
113
|
+
logger
|
|
114
|
+
} : {
|
|
115
|
+
...defaultOptions,
|
|
116
|
+
...serverOptions,
|
|
117
|
+
remoteDrives,
|
|
118
|
+
identity,
|
|
119
|
+
packages,
|
|
120
|
+
logger
|
|
121
|
+
};
|
|
122
|
+
return await startSwitchboard({
|
|
123
|
+
...finalOptions,
|
|
124
|
+
fatalErrorShutdown: true
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { POWERHOUSE_DRIVE_ICON as i, defaultSwitchboardOptions as n, startSwitchboard$1 as r, allowLocalhostEgress as t };
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=switchboard-KQaBlAda.mjs.map
|
|
131
|
+
//# debugId=066aa87f-d5aa-521b-a172-e762487529b4
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switchboard-KQaBlAda.mjs","sources":["../src/utils/drive-icons.ts","../src/services/switchboard.ts"],"sourcesContent":["/**\n * Icon for the drives ph-cli creates, inlined as a data URI.\n *\n * This used to be an IPFS URL on a private gateway, which now answers 403 -\n * and a drive stores its icon as a plain URL in document state, so the moment\n * that URL rots every client renders a broken image, for as long as the drive\n * exists. A public gateway would only move the problem: IPFS gateways are\n * frequently overloaded, and a drive icon must not depend on the network at\n * all.\n *\n * A data URI keeps the asset inside this package and inside the drive: no\n * fetch, no gateway, no deploy-base or cross-origin question, and nothing to\n * 404. A few hundred bytes - the size of the string below is the entire cost,\n * paid once in the drive's state.\n *\n * Kept URL-encoded rather than base64 so the markup stays readable and\n * reviewable (`#` must be `%23`; `<`, `>`, `\"` and the CSS braces are legal\n * enough in a data URI but are encoded so the value is also safe to paste\n * into markup).\n */\n\n/** Encodes an SVG for use in a `data:` URI, smaller than base64 and readable. */\nfunction svgDataUri(svg: string): string {\n const compact = svg.replace(/\\s+/g, \" \").trim();\n return `data:image/svg+xml,${compact\n .replace(/%/g, \"%25\")\n .replace(/#/g, \"%23\")\n .replace(/</g, \"%3C\")\n .replace(/>/g, \"%3E\")\n .replace(/\"/g, \"%22\")\n .replace(/\\{/g, \"%7B\")\n .replace(/\\}/g, \"%7D\")}`;\n}\n\n// The Powerhouse mark: four petals on a 64 grid, each a square with one\n// quarter-circle bite taken out of its inner corner.\nconst PETALS = [\n \"M0 4.6C0 2.1 2.1 0 4.6 0h21.2c2.5 0 4.6 2.1 4.6 4.6v2.8c0 12.7-10.3 23-23 23H4.6C2.1 30.4 0 28.4 0 25.8V4.6Z\",\n \"M33.6 56.6c0-12.7 10.3-23 23-23h2.8c2.5 0 4.6 2.1 4.6 4.6v21.2c0 2.5-2.1 4.6-4.6 4.6H38.2c-2.5 0-4.6-2.1-4.6-4.6v-2.8Z\",\n \"M0 38.2c0-2.5 2.1-4.6 4.6-4.6h2.8c12.7 0 23 10.3 23 23v2.8c0 2.5-2.1 4.6-4.6 4.6H4.6C2.1 64 0 61.9 0 59.4V38.2Z\",\n \"M33.6 4.6C33.6 2.1 35.6 0 38.2 0h21.2C61.9 0 64 2.1 64 4.6v21.2c0 2.5-2.1 4.6-4.6 4.6h-2.8c-12.7 0-23-10.3-23-23V4.6Z\",\n];\n\n/** The mark in the light theme's grey. */\nconst LIGHT_FILL = \"#404345\";\n\n/** The mark in the dark theme's grey. */\nconst DARK_FILL = \"#F3F5F7\";\n\n// Drawn in one grey that follows the theme, so the icon sits in the sidebar\n// beside the single-tone `currentcolor` glyphs of the other drives instead of\n// competing with them.\n//\n// A data URI rendered through an `<img>` is its own document and cannot see\n// the host page's `.dark` class, so the theme is read from the embedded\n// document's own color scheme. That is the OS preference by default; the\n// renderer propagates an explicit in-app theme choice by setting\n// `color-scheme` on the `<img>`, which overrides it where the browser\n// supports the propagation.\nconst MARK_SVG = `\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" width=\"32\" height=\"32\">\n <style>\n path { fill: ${LIGHT_FILL} }\n @media (prefers-color-scheme: dark) { path { fill: ${DARK_FILL} } }\n </style>\n <path d=\"${PETALS[0]}\"/>\n <path d=\"${PETALS[1]}\"/>\n <path d=\"${PETALS[2]}\"/>\n <path d=\"${PETALS[3]}\"/>\n</svg>`;\n\n/** Icon for the drives ph-cli creates. */\nexport const POWERHOUSE_DRIVE_ICON = svgDataUri(MARK_SVG);\n","import type {\n IdentityOptions,\n StartServerOptions,\n} from \"@powerhousedao/switchboard/server\";\nimport { startSwitchboard as startSwitchboardServer } from \"@powerhousedao/switchboard/server\";\nimport type { ILogger } from \"document-model\";\nimport path from \"node:path\";\nimport type { SwitchboardArgs } from \"../types.js\";\nimport { POWERHOUSE_DRIVE_ICON } from \"../utils/drive-icons.js\";\n\nconst EGRESS_ALLOW_ENV = \"PH_WORKFLOWS_EGRESS_ALLOW_ADDRESSES\";\nconst LOCALHOST_ADDRESSES = [\"127.0.0.1/32\", \"::1/128\"];\n\n// Lets pieces reach services on this machine, keeping any addresses already set\nexport function allowLocalhostEgress(env: NodeJS.ProcessEnv = process.env) {\n const current = (env[EGRESS_ALLOW_ENV] ?? \"\")\n .split(\",\")\n .map((entry) => entry.trim())\n .filter((entry) => entry !== \"\");\n const missing = LOCALHOST_ADDRESSES.filter(\n (address) => !current.includes(address),\n );\n if (missing.length > 0)\n env[EGRESS_ALLOW_ENV] = [...current, ...missing].join(\",\");\n}\n\nexport const defaultSwitchboardOptions = {\n port: 4001,\n dbPath: path.join(process.cwd(), \".ph/read-model.db\"),\n drive: {\n id: \"powerhouse\",\n slug: \"powerhouse\",\n global: {\n name: \"Powerhouse\",\n icon: \"https://ipfs.io/ipfs/QmcaTDBYn8X2psGaXe7iQ6qd8q6oqHLgxvMX9yXf7f9uP7\",\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\",\n triggers: [],\n },\n },\n mcp: true,\n} satisfies StartServerOptions;\n\nfunction getDefaultVetraSwitchboardOptions(\n vetraDriveId: string,\n): Partial<StartServerOptions> {\n return {\n port: 4001,\n dbPath: path.join(process.cwd(), \".ph/read-model.db\"),\n drive: {\n id: vetraDriveId,\n slug: vetraDriveId,\n global: {\n name: \"Vetra\",\n icon: POWERHOUSE_DRIVE_ICON,\n },\n preferredEditor: \"vetra-drive-app\",\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\",\n triggers: [],\n },\n },\n };\n}\n\nexport async function startSwitchboard(\n options: SwitchboardArgs & {\n strictPort?: boolean;\n processorConfig?: Map<string, unknown>;\n },\n logger?: ILogger,\n) {\n const {\n packages: packagesString,\n remoteDrives,\n useVetraDrive,\n vetraDriveId,\n useIdentity,\n keypairPath,\n requireIdentity,\n ...serverOptions\n } = options;\n\n // Vetra and dev mode run against local services\n if (useVetraDrive || serverOptions.dev) allowLocalhostEgress();\n\n // Choose the appropriate default configuration\n const defaultOptions = useVetraDrive\n ? getDefaultVetraSwitchboardOptions(vetraDriveId)\n : defaultSwitchboardOptions;\n\n // Build identity options if enabled\n const identity: IdentityOptions | undefined =\n useIdentity || keypairPath || requireIdentity\n ? {\n keypairPath,\n requireExisting: requireIdentity,\n }\n : undefined;\n\n const packages = packagesString?.split(\",\");\n\n // Only include the default drive if no remote drives are provided\n const finalOptions =\n remoteDrives.length > 0\n ? {\n ...defaultOptions,\n drive: undefined, // Don't create default drive when syncing with remote\n ...serverOptions,\n remoteDrives,\n identity,\n packages,\n logger,\n }\n : {\n ...defaultOptions,\n ...serverOptions,\n remoteDrives,\n identity,\n packages,\n logger,\n };\n\n const reactor = await startSwitchboardServer({\n ...finalOptions,\n fatalErrorShutdown: true,\n });\n\n return reactor;\n}\n"],"names":["startSwitchboard","startSwitchboardServer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,WAAW,KAAqB;CAEvC,OAAO,sBADS,IAAI,QAAQ,QAAQ,GAAG,CAAC,CAAC,KACN,CAAC,CACjC,QAAQ,MAAM,KAAK,CAAC,CACpB,QAAQ,MAA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ACZ,aAAa;IACb,UAAU,CAAC;GACb;EACF;CACF;AACF;AAEA,eAAsBA,mBACpB,SAIA,QACA;CACA,MAAM,EACJ,UAAU,gBACV,cACA,eACA,cACA,aACA,aACA,iBACA,GAAG,kBACD;CAGJ,IAAI,iBAAiB,cAAc,KAAK,qBAAqB;CAG7D,MAAM,iBAAiB,gBACnB,kCAAkC,YAAY,IAC9C;CAGJ,MAAM,WACJ,eAAe,eAAe,kBAC1B;EACE;EACA,iBAAiB;CACnB,IACA,KAAA;CAEN,MAAM,WAAW,gBAAgB,MAAM,GAAG;CAG1C,MAAM,eACJ,aAAa,SAAS,IAClB;EACE,GAAG;EACH,OAAO,KAAA;EACP,GAAG;EACH;EACA;EACA;EACA;CACF,IACA;EACE,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA;CACF;CAON,OAAO,MALeC,iBAAuB;EAC3C,GAAG;EACH,oBAAoB;CACtB,CAAC;AAGH","debug_id":"066aa87f-d5aa-521b-a172-e762487529b4"}
|
|
@@ -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]="8ee54547-f686-5213-81f6-e06f7bd4b297")}catch(e){}}();
|
|
3
3
|
import { Kysely, PostgresDialect } from "kysely";
|
|
4
4
|
import { Pool } from "pg";
|
|
5
5
|
import { REACTOR_SCHEMA, getMigrationStatus, runMigrations } from "@powerhousedao/reactor";
|
|
@@ -15,7 +15,8 @@ async function runSwitchboardMigrations(options) {
|
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
console.log(`Database: ${dbPath}`);
|
|
18
|
-
const
|
|
18
|
+
const pool = new Pool({ connectionString: dbPath });
|
|
19
|
+
const db = new Kysely({ dialect: new PostgresDialect({ pool }) });
|
|
19
20
|
try {
|
|
20
21
|
if (options.statusOnly) {
|
|
21
22
|
console.log("\nChecking migration status...");
|
|
@@ -49,5 +50,5 @@ async function runSwitchboardMigrations(options) {
|
|
|
49
50
|
//#endregion
|
|
50
51
|
export { runSwitchboardMigrations };
|
|
51
52
|
|
|
52
|
-
//# sourceMappingURL=switchboard-migrate-
|
|
53
|
-
//# debugId=
|
|
53
|
+
//# sourceMappingURL=switchboard-migrate-7JQZM7-5.mjs.map
|
|
54
|
+
//# debugId=8ee54547-f686-5213-81f6-e06f7bd4b297
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchboard-migrate-
|
|
1
|
+
{"version":3,"file":"switchboard-migrate-7JQZM7-5.mjs","sources":["../src/services/switchboard-migrate.ts"],"sourcesContent":["import { Kysely, PostgresDialect } from \"kysely\";\nimport { Pool } from \"pg\";\nimport {\n runMigrations,\n getMigrationStatus,\n REACTOR_SCHEMA,\n} from \"@powerhousedao/reactor\";\n\ninterface MigrationOptions {\n dbPath?: string;\n statusOnly?: boolean;\n}\n\nfunction isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nexport async function runSwitchboardMigrations(\n options: MigrationOptions,\n): Promise<void> {\n const dbPath =\n options.dbPath ??\n process.env.PH_REACTOR_DATABASE_URL ??\n process.env.DATABASE_URL;\n\n if (!dbPath || !isPostgresUrl(dbPath)) {\n console.log(\"No PostgreSQL URL configured. Skipping migrations.\");\n console.log(\"(PGlite migrations are handled automatically on startup)\");\n return;\n }\n\n console.log(`Database: ${dbPath}`);\n\n const pool = new Pool({ connectionString: dbPath });\n\n const db = new Kysely<any>({\n dialect: new PostgresDialect({ pool }),\n });\n\n try {\n if (options.statusOnly) {\n console.log(\"\\nChecking migration status...\");\n const migrations = await getMigrationStatus(db, REACTOR_SCHEMA);\n\n console.log(\"\\nMigration Status:\");\n console.log(\"=================\");\n\n for (const migration of migrations) {\n const status = migration.executedAt\n ? `[OK] Executed at ${migration.executedAt.toISOString()}`\n : \"[--] Pending\";\n console.log(`${status} - ${migration.name}`);\n }\n } else {\n console.log(\"\\nRunning migrations...\");\n const result = await runMigrations(db, REACTOR_SCHEMA);\n\n if (!result.success) {\n console.error(\"Migration failed:\", result.error?.message);\n process.exit(1);\n }\n\n if (result.migrationsExecuted.length === 0) {\n console.log(\"No migrations to run - database is up to date\");\n } else {\n console.log(\n `Successfully executed ${result.migrationsExecuted.length} migration(s):`,\n );\n for (const name of result.migrationsExecuted) {\n console.log(` - ${name}`);\n }\n }\n }\n } catch (error) {\n console.error(\n \"Error:\",\n error instanceof Error ? error.message : String(error),\n );\n process.exit(1);\n } finally {\n await db.destroy();\n }\n}\n"],"names":[],"mappings":";;;;;;AAaA,SAAS,cAAc,KAAsB;CAC3C,OAAO,IAAI,WAAW,eAAe,KAAK,IAAI,WAAW,aAAa;AACxE;AAEA,eAAsB,yBACpB,SACe;CACf,MAAM,SACJ,QAAQ,UACR,QAAQ,IAAI,2BACZ,QAAQ,IAAI;CAEd,IAAI,CAAC,UAAU,CAAC,cAAc,MAAM,GAAG;EACrC,QAAQ,IAAI,oDAAoD;EAChE,QAAQ,IAAI,0DAA0D;EACtE;CACF;CAEA,QAAQ,IAAI,aAAa,QAAQ;CAEjC,MAAM,OAAO,IAAI,KAAK,EAAE,kBAAkB,OAAO,CAAC;CAElD,MAAM,KAAK,IAAI,OAAY,EACzB,SAAS,IAAI,gBAAgB,EAAE,KAAK,CAAC,EACvC,CAAC;CAED,IAAI;EACF,IAAI,QAAQ,YAAY;GACtB,QAAQ,IAAI,gCAAgC;GAC5C,MAAM,aAAa,MAAM,mBAAmB,IAAI,cAAc;GAE9D,QAAQ,IAAI,qBAAqB;GACjC,QAAQ,IAAI,mBAAmB;GAE/B,KAAK,MAAM,aAAa,YAAY;IAClC,MAAM,SAAS,UAAU,aACrB,oBAAoB,UAAU,WAAW,YAAY,MACrD;IACJ,QAAQ,IAAI,GAAG,OAAO,KAAK,UAAU,MAAM;GAC7C;EACF,OAAO;GACL,QAAQ,IAAI,yBAAyB;GACrC,MAAM,SAAS,MAAM,cAAc,IAAI,cAAc;GAErD,IAAI,CAAC,OAAO,SAAS;IACnB,QAAQ,MAAM,qBAAqB,OAAO,OAAO,OAAO;IACxD,QAAQ,KAAK,CAAC;GAChB;GAEA,IAAI,OAAO,mBAAmB,WAAW,GACvC,QAAQ,IAAI,+CAA+C;QACtD;IACL,QAAQ,IACN,yBAAyB,OAAO,mBAAmB,OAAO,eAC5D;IACA,KAAK,MAAM,QAAQ,OAAO,oBACxB,QAAQ,IAAI,OAAO,MAAM;GAE7B;EACF;CACF,SAAS,OAAO;EACd,QAAQ,MACN,UACA,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACvD;EACA,QAAQ,KAAK,CAAC;CAChB,UAAU;EACR,MAAM,GAAG,QAAQ;CACnB;AACF","debug_id":"8ee54547-f686-5213-81f6-e06f7bd4b297"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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]="
|
|
3
|
-
import { cyan, green, red, yellow } from "colorette";
|
|
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]="7ed66b10-4157-58df-9f3d-8a23c6950440")}catch(e){}}();
|
|
4
3
|
import { promises } from "node:fs";
|
|
4
|
+
import { cyan, green, red, yellow } from "colorette";
|
|
5
5
|
//#region src/services/switchboard-reset.ts
|
|
6
6
|
const CONFIRMATION_TOKEN = "reset";
|
|
7
7
|
function isPostgresUrl(url) {
|
|
@@ -83,5 +83,5 @@ async function resetSwitchboardDatabase(options) {
|
|
|
83
83
|
//#endregion
|
|
84
84
|
export { resetSwitchboardDatabase };
|
|
85
85
|
|
|
86
|
-
//# sourceMappingURL=switchboard-reset-
|
|
87
|
-
//# debugId=
|
|
86
|
+
//# sourceMappingURL=switchboard-reset-CX_Lzw3O.mjs.map
|
|
87
|
+
//# debugId=7ed66b10-4157-58df-9f3d-8a23c6950440
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchboard-reset-
|
|
1
|
+
{"version":3,"file":"switchboard-reset-CX_Lzw3O.mjs","sources":["../src/services/switchboard-reset.ts"],"sourcesContent":["import { yellow, red, green, cyan } from \"colorette\";\nimport { promises as fs } from \"node:fs\";\n\nexport interface ResetSwitchboardOptions {\n dbPath?: string;\n yes?: boolean;\n}\n\nexport interface ResolvedResetPaths {\n reactorDir: string | null;\n readModelDir: string | null;\n postgresUrl: string | null;\n}\n\nconst CONFIRMATION_TOKEN = \"reset\";\n\nexport function isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\n/**\n * Resolves the on-disk PGlite directories that `--reset` would delete.\n * Mirrors the resolution in apps/switchboard/src/server.mts so we touch the\n * same paths the running switchboard uses. When a Postgres URL is configured\n * the corresponding directory is null and `postgresUrl` is populated so the\n * caller can refuse.\n */\nexport function resolveResetPaths(\n options: ResetSwitchboardOptions,\n env: NodeJS.ProcessEnv = process.env,\n): ResolvedResetPaths {\n const readModelDbPath =\n options.dbPath ?? env.DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;\n const readModelPath = readModelDbPath || \".ph/read-storage\";\n const reactorDbUrl =\n options.dbPath ??\n env.PH_REACTOR_DATABASE_URL ??\n env.PH_SWITCHBOARD_DATABASE_URL;\n const reactorPath = reactorDbUrl || \"./.ph/reactor-storage\";\n\n const reactorIsPostgres = !!reactorDbUrl && isPostgresUrl(reactorDbUrl);\n const readModelIsPostgres =\n !!readModelDbPath && isPostgresUrl(readModelDbPath);\n\n let postgresUrl: string | null = null;\n if (reactorIsPostgres) postgresUrl = reactorDbUrl as string;\n else if (readModelIsPostgres) postgresUrl = readModelDbPath as string;\n\n return {\n reactorDir: reactorIsPostgres ? null : reactorPath,\n readModelDir: readModelIsPostgres ? null : readModelPath,\n postgresUrl,\n };\n}\n\nasync function promptForConfirmation(): Promise<boolean> {\n const enquirer = await import(\"enquirer\");\n try {\n const answer = await enquirer.default.prompt<{ confirmation: string }>({\n type: \"input\",\n name: \"confirmation\",\n message: `Type \"${CONFIRMATION_TOKEN}\" to confirm wiping the local switchboard databases:`,\n });\n return answer.confirmation.trim() === CONFIRMATION_TOKEN;\n } catch {\n return false;\n }\n}\n\nexport async function resetSwitchboardDatabase(\n options: ResetSwitchboardOptions,\n): Promise<void> {\n const paths = resolveResetPaths(options);\n\n if (paths.postgresUrl) {\n console.error(\n red(\n `Refusing to reset: a PostgreSQL URL is configured (${paths.postgresUrl}).`,\n ),\n );\n console.error(\n yellow(\n \"`ph switchboard --reset` only wipes the local PGlite stores. \" +\n \"To reset a Postgres-backed switchboard, drop/recreate the database manually.\",\n ),\n );\n process.exit(1);\n }\n\n const targets = [paths.reactorDir, paths.readModelDir].filter(\n (d): d is string => d !== null,\n );\n\n if (targets.length === 0) {\n console.error(red(\"No local PGlite directories resolved; nothing to do.\"));\n process.exit(1);\n }\n\n console.log(yellow(\"The following directories will be permanently deleted:\"));\n for (const dir of targets) {\n console.log(` - ${dir}`);\n }\n console.log(\n yellow(\n \"This will wipe all local switchboard state. Migrations will re-run on next `ph switchboard`.\",\n ),\n );\n\n let confirmed = false;\n if (options.yes) {\n confirmed = true;\n } else if (isInteractive()) {\n confirmed = await promptForConfirmation();\n } else {\n console.error(\n red(\n \"Refusing to reset in a non-interactive context without --yes. Re-run with --yes to confirm.\",\n ),\n );\n process.exit(1);\n }\n\n if (!confirmed) {\n console.error(red(\"Aborted: confirmation not provided.\"));\n process.exit(1);\n }\n\n for (const dir of targets) {\n await fs.rm(dir, { recursive: true, force: true });\n console.log(cyan(`Removed ${dir}`));\n }\n\n console.log(\n green(\n \"Switchboard local storage reset. Run `ph switchboard` to re-initialize.\",\n ),\n );\n}\n"],"names":["fs"],"mappings":";;;;;AAcA,MAAM,qBAAqB;AAE3B,SAAgB,cAAc,KAAsB;CAClD,OAAO,IAAI,WAAW,eAAe,KAAK,IAAI,WAAW,aAAa;AACxE;AAEA,SAAS,gBAAyB;CAChC,OAAO,QAAQ,QAAQ,MAAM,KAAK,KAAK,CAAC,QAAQ,IAAI;AACtD;;;;;;;;AASA,SAAgB,kBACd,SACA,MAAyB,QAAQ,KACb;CACpB,MAAM,kBACJ,QAAQ,UAAU,IAAI,gBAAgB,IAAI;CAC5C,MAAM,gBAAgB,mBAAmB;CACzC,MAAM,eACJ,QAAQ,UACR,IAAI,2BACJ,IAAI;CACN,MAAM,cAAc,gBAAgB;CAEpC,MAAM,oBAAoB,CAAC,CAAC,gBAAgB,cAAc,YAAY;CACtE,MAAM,sBACJ,CAAC,CAAC,mBAAmB,cAAc,eAAe;CAEpD,IAAI,cAA6B;CACjC,IAAI,mBAAmB,cAAc;MAChC,IAAI,qBAAqB,cAAc;CAE5C,OAAO;EACL,YAAY,oBAAoB,OAAO;EACvC,cAAc,sBAAsB,OAAO;EAC3C;CACF;AACF;AAEA,eAAe,wBAA0C;CACvD,MAAM,WAAW,MAAM,OAAO;CAC9B,IAAI;EAMF,QAAO,MALc,SAAS,QAAQ,OAAiC;GACrE,MAAM;GACN,MAAM;GACN,SAAS,SAAS,mBAAmB;EACvC,CAAC,EAAA,CACa,aAAa,KAAK,MAAM;CACxC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAsB,yBACpB,SACe;CACf,MAAM,QAAQ,kBAAkB,OAAO;CAEvC,IAAI,MAAM,aAAa;EACrB,QAAQ,MACN,IACE,sDAAsD,MAAM,YAAY,GAC1E,CACF;EACA,QAAQ,MACN,OACE,2IAEF,CACF;EACA,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,UAAU,CAAC,MAAM,YAAY,MAAM,YAAY,CAAC,CAAC,QACpD,MAAmB,MAAM,IAC5B;CAEA,IAAI,QAAQ,WAAW,GAAG;EACxB,QAAQ,MAAM,IAAI,sDAAsD,CAAC;EACzE,QAAQ,KAAK,CAAC;CAChB;CAEA,QAAQ,IAAI,OAAO,wDAAwD,CAAC;CAC5E,KAAK,MAAM,OAAO,SAChB,QAAQ,IAAI,OAAO,KAAK;CAE1B,QAAQ,IACN,OACE,8FACF,CACF;CAEA,IAAI,YAAY;CAChB,IAAI,QAAQ,KACV,YAAY;MACP,IAAI,cAAc,GACvB,YAAY,MAAM,sBAAsB;MACnC;EACL,QAAQ,MACN,IACE,6FACF,CACF;EACA,QAAQ,KAAK,CAAC;CAChB;CAEA,IAAI,CAAC,WAAW;EACd,QAAQ,MAAM,IAAI,qCAAqC,CAAC;EACxD,QAAQ,KAAK,CAAC;CAChB;CAEA,KAAK,MAAM,OAAO,SAAS;EACzB,MAAMA,SAAG,GAAG,KAAK;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACjD,QAAQ,IAAI,KAAK,WAAW,KAAK,CAAC;CACpC;CAEA,QAAQ,IACN,MACE,yEACF,CACF;AACF","debug_id":"7ed66b10-4157-58df-9f3d-8a23c6950440"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { r as startSwitchboard } from "./switchboard-KQaBlAda.mjs";
|
|
2
|
+
export { startSwitchboard };
|
|
3
|
+
!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]="d6e0fee8-f5cd-5c3d-b457-4f35778e7ced")}catch(e){}}();
|
|
4
|
+
//# debugId=d6e0fee8-f5cd-5c3d-b457-4f35778e7ced
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as updateConfigFile, p as updateStylesFile, u as removeStylesImports } from "./utils-
|
|
1
|
+
import { d as updateConfigFile, p as updateStylesFile, u as removeStylesImports } from "./utils-CvmDmCVd.mjs";
|
|
2
2
|
export { removeStylesImports, updateConfigFile, updateStylesFile };
|
|
3
|
-
!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]="
|
|
4
|
-
//# debugId=
|
|
3
|
+
!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]="8a927382-3953-53ce-9038-f76fc626e4b5")}catch(e){}}();
|
|
4
|
+
//# debugId=8a927382-3953-53ce-9038-f76fc626e4b5
|
|
@@ -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]="fa6f49e1-f268-5ae2-8e22-cc7adc8fbfba")}catch(e){}}();
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path, { dirname } from "node:path";
|
|
5
5
|
import crypto from "node:crypto";
|
|
@@ -161,5 +161,5 @@ function removeStylesImports(dependencies, projectPath) {
|
|
|
161
161
|
//#endregion
|
|
162
162
|
export { generateProjectDriveId as a, isPowerhouseProject as c, updateConfigFile as d, updatePackagesArray as f, findNodeProjectRoot as i, packageManagers as l, POWERHOUSE_GLOBAL_DIR as n, getPackageManagerFromLockfile as o, updateStylesFile as p, defaultPathValidation as r, getProjectInfo as s, POWERHOUSE_CONFIG_FILE as t, removeStylesImports as u };
|
|
163
163
|
|
|
164
|
-
//# sourceMappingURL=utils-
|
|
165
|
-
//# debugId=
|
|
164
|
+
//# sourceMappingURL=utils-CvmDmCVd.mjs.map
|
|
165
|
+
//# debugId=fa6f49e1-f268-5ae2-8e22-cc7adc8fbfba
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-C4isxXSO.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path, { dirname } from \"node:path\";\nexport const POWERHOUSE_CONFIG_FILE = \"powerhouse.config.json\";\nexport const POWERHOUSE_GLOBAL_DIR = path.join(homedir(), \".ph\");\nexport const SUPPORTED_PACKAGE_MANAGERS = [\"npm\", \"yarn\", \"pnpm\", \"bun\"];\n\nexport const packageManagers = {\n bun: {\n globalPathRegexp: /[\\\\/].bun[\\\\/]/,\n installCommand: \"bun add {{dependency}}\",\n uninstallCommand: \"bun remove {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"bun.lock\",\n updateCommand: \"bun update {{dependency}}\",\n buildAffected: \"bun run build:affected\",\n },\n pnpm: {\n globalPathRegexp: /[\\\\/]pnpm[\\\\/]/,\n installCommand: \"pnpm add {{dependency}}\",\n uninstallCommand: \"pnpm remove {{dependency}}\",\n workspaceOption: \"--workspace-root\",\n lockfile: \"pnpm-lock.yaml\",\n updateCommand: \"pnpm update {{dependency}}\",\n buildAffected: \"pnpm run build:affected\",\n },\n yarn: {\n globalPathRegexp: /[\\\\/]yarn[\\\\/]/,\n installCommand: \"yarn add {{dependency}}\",\n uninstallCommand: \"yarn remove {{dependency}}\",\n workspaceOption: \"-W\",\n lockfile: \"yarn.lock\",\n updateCommand: \"yarn upgrade {{dependency}}\",\n buildAffected: \"yarn run build:affected\",\n },\n npm: {\n installCommand: \"npm install {{dependency}}\",\n uninstallCommand: \"npm uninstall {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"package-lock.json\",\n updateCommand: \"npm update {{dependency}} --save\",\n buildAffected: \"npm run build:affected\",\n },\n};\n\ntype PathValidation = (dir: string) => boolean;\n\nexport type PackageManager = \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\nexport type ProjectInfo = {\n isGlobal: boolean;\n path: string;\n packageManager: PackageManager;\n};\n\nexport function defaultPathValidation() {\n return true;\n}\n\nexport function isPowerhouseProject(dir: string) {\n const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);\n\n return fs.existsSync(powerhouseConfigPath);\n}\n\nexport function findNodeProjectRoot(\n dir: string,\n pathValidation: PathValidation = defaultPathValidation,\n) {\n const packageJsonPath = path.join(dir, \"package.json\");\n\n if (fs.existsSync(packageJsonPath) && pathValidation(dir)) {\n return dir;\n }\n\n const parentDir = dirname(dir);\n\n if (parentDir === dir) {\n return null;\n }\n\n return findNodeProjectRoot(parentDir, pathValidation);\n}\n\nexport function getProjectInfo(debug?: boolean): ProjectInfo {\n const currentPath = process.cwd();\n\n if (debug) {\n console.log(\">>> currentPath\", currentPath);\n }\n\n const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);\n\n if (!projectPath) {\n return {\n isGlobal: true,\n path: POWERHOUSE_GLOBAL_DIR,\n packageManager: getPackageManagerFromLockfile(POWERHOUSE_GLOBAL_DIR),\n };\n }\n\n return {\n isGlobal: false,\n path: projectPath,\n packageManager: getPackageManagerFromLockfile(projectPath),\n };\n}\n\n/**\n * Generates a unique drive ID based on the project path.\n * The same project path will always generate the same ID.\n * @param name - The name prefix for the drive ID (e.g., \"vetra\", \"powerhouse\")\n * @returns A unique drive ID in the format \"{name}-{hash}\"\n */\nexport function generateProjectDriveId(name: string): string {\n const projectInfo = getProjectInfo();\n const hash = crypto\n .createHash(\"sha256\")\n .update(projectInfo.path)\n .digest(\"hex\");\n const shortHash = hash.substring(0, 8);\n return `${name}-${shortHash}`;\n}\n\nexport function getPackageManagerFromLockfile(dir: string): PackageManager {\n if (fs.existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {\n return \"pnpm\";\n } else if (fs.existsSync(path.join(dir, packageManagers.yarn.lockfile))) {\n return \"yarn\";\n } else if (fs.existsSync(path.join(dir, packageManagers.bun.lockfile))) {\n return \"bun\";\n }\n\n return \"npm\";\n}\n\nexport function updatePackagesArray(\n currentPackages: PowerhouseConfig[\"packages\"] = [],\n dependencies: { name: string; version: string | undefined }[],\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n): PowerhouseConfig[\"packages\"] {\n const isInstall = task === \"install\";\n const mappedPackages = dependencies.map((dep) => ({\n packageName: dep.name,\n version: dep.version,\n provider,\n }));\n\n if (isInstall) {\n // Overwrite existing package if version is different\n const filteredPackages = currentPackages.filter(\n (pkg) => !dependencies.find((dep) => dep.name === pkg.packageName),\n );\n return [...filteredPackages, ...mappedPackages];\n }\n\n return currentPackages.filter(\n (pkg) => !dependencies.map((dep) => dep.name).includes(pkg.packageName),\n );\n}\n\n// Modify updateConfigFile to use the new function\nexport function updateConfigFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n registryUrl?: string,\n registryUrlExplicit = false,\n) {\n const configPath = path.join(projectPath, POWERHOUSE_CONFIG_FILE);\n\n if (!fs.existsSync(configPath)) {\n throw new Error(\n `powerhouse.config.json file not found. projectPath: ${projectPath}`,\n );\n }\n\n const config = JSON.parse(\n fs.readFileSync(configPath, \"utf-8\"),\n ) as PowerhouseConfig;\n\n const updatedConfig: PowerhouseConfig = {\n ...config,\n packages: updatePackagesArray(\n config.packages,\n dependencies,\n task,\n provider,\n ),\n };\n\n if (\n task === \"install\" &&\n registryUrl &&\n (registryUrlExplicit || !config.packageRegistryUrl) &&\n dependencies.length > 0\n ) {\n updatedConfig.packageRegistryUrl = registryUrl;\n }\n\n fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));\n}\n\n/**\n * Recursively searches for a specific file by traversing up the directory tree.\n * Starting from the given path, it checks each parent directory until it finds\n * the target file or reaches the root directory.\n *\n * @param startPath - The absolute path of the directory to start searching from\n * @param targetFile - The name of the file to search for (e.g., 'package.json', 'pnpm-workspace.yaml')\n * @returns The absolute path of the directory containing the target file, or null if not found\n *\n * @example\n * // Find the workspace root directory\n * const workspaceRoot = findContainerDirectory('/path/to/project/src', 'pnpm-workspace.yaml');\n *\n * // Find the nearest package.json\n * const packageDir = findContainerDirectory('/path/to/project/src/components', 'package.json');\n */\nexport const findContainerDirectory = (\n startPath: string,\n targetFile: string,\n): string | null => {\n const filePath = path.join(startPath, targetFile);\n\n if (fs.existsSync(filePath)) {\n return startPath;\n }\n\n const parentDir = path.dirname(startPath);\n\n //reached the root directory and haven't found the file\n if (parentDir === startPath) {\n return null;\n }\n\n return findContainerDirectory(parentDir, targetFile);\n};\n\n/**\n * Updates the styles.css file to include imports for newly installed packages\n * @param dependencies - Array of dependencies that were installed\n * @param projectPath - Path to the project root\n */\nexport function updateStylesFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const fullCssPath = path.join(projectPath, cssPath);\n const importStatement = `@import '${cssPath}';`;\n\n // Check if the CSS file exists\n if (!fs.existsSync(fullCssPath)) {\n console.warn(`⚠️ Warning: CSS file not found at ${cssPath}`);\n continue;\n }\n\n // Check if import already exists\n if (currentStyles.includes(importStatement)) {\n continue;\n }\n\n // Find the last @import statement\n const importLines = currentStyles\n .split(\"\\n\")\n .filter((line) => line.trim().startsWith(\"@import\"));\n const lastImport = importLines[importLines.length - 1];\n\n if (lastImport) {\n // Insert new import after the last existing import\n updatedStyles = currentStyles.replace(\n lastImport,\n `${lastImport}\\n${importStatement}`,\n );\n } else {\n // If no imports exist, add at the top of the file\n updatedStyles = `${importStatement}\\n${currentStyles}`;\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n\n/**\n * Removes CSS imports for uninstalled packages from styles.css\n */\nexport function removeStylesImports(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const importStatement = `@import '${cssPath}';`;\n\n // Remove the import line if it exists\n const lines = updatedStyles.split(\"\\n\");\n const filteredLines = lines.filter(\n (line) => !line.trim().includes(importStatement),\n );\n\n if (filteredLines.length !== lines.length) {\n updatedStyles = filteredLines.join(\"\\n\");\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAKA,MAAa,yBAAyB;AACtC,MAAa,wBAAwB,KAAK,KAAK,SAAS,EAAE,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AS,gBAAgB,CACjD;AAED,MAAI,cAAc,WAAW,MAAM,OACjC,iBAAgB,cAAc,KAAK,KAAK;;AAK5C,KAAI,kBAAkB,cACpB,IAAG,cAAc,YAAY,cAAc","debug_id":"73159d3c-22a7-5dc6-8bd4-7b15f3b94c79"}
|
|
1
|
+
{"version":3,"file":"utils-CvmDmCVd.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path, { dirname } from \"node:path\";\nexport const POWERHOUSE_CONFIG_FILE = \"powerhouse.config.json\";\nexport const POWERHOUSE_GLOBAL_DIR = path.join(homedir(), \".ph\");\nexport const SUPPORTED_PACKAGE_MANAGERS = [\"npm\", \"yarn\", \"pnpm\", \"bun\"];\n\nexport const packageManagers = {\n bun: {\n globalPathRegexp: /[\\\\/].bun[\\\\/]/,\n installCommand: \"bun add {{dependency}}\",\n uninstallCommand: \"bun remove {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"bun.lock\",\n updateCommand: \"bun update {{dependency}}\",\n buildAffected: \"bun run build:affected\",\n },\n pnpm: {\n globalPathRegexp: /[\\\\/]pnpm[\\\\/]/,\n installCommand: \"pnpm add {{dependency}}\",\n uninstallCommand: \"pnpm remove {{dependency}}\",\n workspaceOption: \"--workspace-root\",\n lockfile: \"pnpm-lock.yaml\",\n updateCommand: \"pnpm update {{dependency}}\",\n buildAffected: \"pnpm run build:affected\",\n },\n yarn: {\n globalPathRegexp: /[\\\\/]yarn[\\\\/]/,\n installCommand: \"yarn add {{dependency}}\",\n uninstallCommand: \"yarn remove {{dependency}}\",\n workspaceOption: \"-W\",\n lockfile: \"yarn.lock\",\n updateCommand: \"yarn upgrade {{dependency}}\",\n buildAffected: \"yarn run build:affected\",\n },\n npm: {\n installCommand: \"npm install {{dependency}}\",\n uninstallCommand: \"npm uninstall {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"package-lock.json\",\n updateCommand: \"npm update {{dependency}} --save\",\n buildAffected: \"npm run build:affected\",\n },\n};\n\ntype PathValidation = (dir: string) => boolean;\n\nexport type PackageManager = \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\nexport type ProjectInfo = {\n isGlobal: boolean;\n path: string;\n packageManager: PackageManager;\n};\n\nexport function defaultPathValidation() {\n return true;\n}\n\nexport function isPowerhouseProject(dir: string) {\n const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);\n\n return fs.existsSync(powerhouseConfigPath);\n}\n\nexport function findNodeProjectRoot(\n dir: string,\n pathValidation: PathValidation = defaultPathValidation,\n) {\n const packageJsonPath = path.join(dir, \"package.json\");\n\n if (fs.existsSync(packageJsonPath) && pathValidation(dir)) {\n return dir;\n }\n\n const parentDir = dirname(dir);\n\n if (parentDir === dir) {\n return null;\n }\n\n return findNodeProjectRoot(parentDir, pathValidation);\n}\n\nexport function getProjectInfo(debug?: boolean): ProjectInfo {\n const currentPath = process.cwd();\n\n if (debug) {\n console.log(\">>> currentPath\", currentPath);\n }\n\n const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);\n\n if (!projectPath) {\n return {\n isGlobal: true,\n path: POWERHOUSE_GLOBAL_DIR,\n packageManager: getPackageManagerFromLockfile(POWERHOUSE_GLOBAL_DIR),\n };\n }\n\n return {\n isGlobal: false,\n path: projectPath,\n packageManager: getPackageManagerFromLockfile(projectPath),\n };\n}\n\n/**\n * Generates a unique drive ID based on the project path.\n * The same project path will always generate the same ID.\n * @param name - The name prefix for the drive ID (e.g., \"vetra\", \"powerhouse\")\n * @returns A unique drive ID in the format \"{name}-{hash}\"\n */\nexport function generateProjectDriveId(name: string): string {\n const projectInfo = getProjectInfo();\n const hash = crypto\n .createHash(\"sha256\")\n .update(projectInfo.path)\n .digest(\"hex\");\n const shortHash = hash.substring(0, 8);\n return `${name}-${shortHash}`;\n}\n\nexport function getPackageManagerFromLockfile(dir: string): PackageManager {\n if (fs.existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {\n return \"pnpm\";\n } else if (fs.existsSync(path.join(dir, packageManagers.yarn.lockfile))) {\n return \"yarn\";\n } else if (fs.existsSync(path.join(dir, packageManagers.bun.lockfile))) {\n return \"bun\";\n }\n\n return \"npm\";\n}\n\nexport function updatePackagesArray(\n currentPackages: PowerhouseConfig[\"packages\"] = [],\n dependencies: { name: string; version: string | undefined }[],\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n): PowerhouseConfig[\"packages\"] {\n const isInstall = task === \"install\";\n const mappedPackages = dependencies.map((dep) => ({\n packageName: dep.name,\n version: dep.version,\n provider,\n }));\n\n if (isInstall) {\n // Overwrite existing package if version is different\n const filteredPackages = currentPackages.filter(\n (pkg) => !dependencies.find((dep) => dep.name === pkg.packageName),\n );\n return [...filteredPackages, ...mappedPackages];\n }\n\n return currentPackages.filter(\n (pkg) => !dependencies.map((dep) => dep.name).includes(pkg.packageName),\n );\n}\n\n// Modify updateConfigFile to use the new function\nexport function updateConfigFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n registryUrl?: string,\n registryUrlExplicit = false,\n) {\n const configPath = path.join(projectPath, POWERHOUSE_CONFIG_FILE);\n\n if (!fs.existsSync(configPath)) {\n throw new Error(\n `powerhouse.config.json file not found. projectPath: ${projectPath}`,\n );\n }\n\n const config = JSON.parse(\n fs.readFileSync(configPath, \"utf-8\"),\n ) as PowerhouseConfig;\n\n const updatedConfig: PowerhouseConfig = {\n ...config,\n packages: updatePackagesArray(\n config.packages,\n dependencies,\n task,\n provider,\n ),\n };\n\n if (\n task === \"install\" &&\n registryUrl &&\n (registryUrlExplicit || !config.packageRegistryUrl) &&\n dependencies.length > 0\n ) {\n updatedConfig.packageRegistryUrl = registryUrl;\n }\n\n fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));\n}\n\n/**\n * Recursively searches for a specific file by traversing up the directory tree.\n * Starting from the given path, it checks each parent directory until it finds\n * the target file or reaches the root directory.\n *\n * @param startPath - The absolute path of the directory to start searching from\n * @param targetFile - The name of the file to search for (e.g., 'package.json', 'pnpm-workspace.yaml')\n * @returns The absolute path of the directory containing the target file, or null if not found\n *\n * @example\n * // Find the workspace root directory\n * const workspaceRoot = findContainerDirectory('/path/to/project/src', 'pnpm-workspace.yaml');\n *\n * // Find the nearest package.json\n * const packageDir = findContainerDirectory('/path/to/project/src/components', 'package.json');\n */\nexport const findContainerDirectory = (\n startPath: string,\n targetFile: string,\n): string | null => {\n const filePath = path.join(startPath, targetFile);\n\n if (fs.existsSync(filePath)) {\n return startPath;\n }\n\n const parentDir = path.dirname(startPath);\n\n //reached the root directory and haven't found the file\n if (parentDir === startPath) {\n return null;\n }\n\n return findContainerDirectory(parentDir, targetFile);\n};\n\n/**\n * Updates the styles.css file to include imports for newly installed packages\n * @param dependencies - Array of dependencies that were installed\n * @param projectPath - Path to the project root\n */\nexport function updateStylesFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const fullCssPath = path.join(projectPath, cssPath);\n const importStatement = `@import '${cssPath}';`;\n\n // Check if the CSS file exists\n if (!fs.existsSync(fullCssPath)) {\n console.warn(`⚠️ Warning: CSS file not found at ${cssPath}`);\n continue;\n }\n\n // Check if import already exists\n if (currentStyles.includes(importStatement)) {\n continue;\n }\n\n // Find the last @import statement\n const importLines = currentStyles\n .split(\"\\n\")\n .filter((line) => line.trim().startsWith(\"@import\"));\n const lastImport = importLines[importLines.length - 1];\n\n if (lastImport) {\n // Insert new import after the last existing import\n updatedStyles = currentStyles.replace(\n lastImport,\n `${lastImport}\\n${importStatement}`,\n );\n } else {\n // If no imports exist, add at the top of the file\n updatedStyles = `${importStatement}\\n${currentStyles}`;\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n\n/**\n * Removes CSS imports for uninstalled packages from styles.css\n */\nexport function removeStylesImports(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const importStatement = `@import '${cssPath}';`;\n\n // Remove the import line if it exists\n const lines = updatedStyles.split(\"\\n\");\n const filteredLines = lines.filter(\n (line) => !line.trim().includes(importStatement),\n );\n\n if (filteredLines.length !== lines.length) {\n updatedStyles = filteredLines.join(\"\\n\");\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAKA,MAAa,yBAAyB;AACtC,MAAa,wBAAwB,KAAK,KAAK,QAAQ,GAAG,KAAK;AAG/D,MAAa,kBAAkB;CAC7B,KAAK;EACH,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;CACjB;CACA,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;CACjB;CACA,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;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(){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]="
|
|
3
|
-
import { a as parseDefaultDrivesUrl } from "./cli-connect-override-
|
|
4
|
-
import { t as runConnectStudio } from "./connect-studio-
|
|
5
|
-
import { a as generateProjectDriveId } from "./utils-
|
|
6
|
-
import {
|
|
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]="2f3f4948-fb4f-582f-adbe-e14c16c249c3")}catch(e){}}();
|
|
3
|
+
import { a as parseDefaultDrivesUrl, i as wasFlagExplicitlyPassed, u as mergeDefaultDrives } from "./cli-connect-override-b4kKqgOZ.mjs";
|
|
4
|
+
import { t as runConnectStudio } from "./connect-studio-_-O1-oef.mjs";
|
|
5
|
+
import { a as generateProjectDriveId } from "./utils-CvmDmCVd.mjs";
|
|
6
|
+
import { i as POWERHOUSE_DRIVE_ICON, r as startSwitchboard$1 } from "./switchboard-KQaBlAda.mjs";
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path, { join } from "node:path";
|
|
7
9
|
import { execSync } from "node:child_process";
|
|
8
10
|
import { blue, green, red, yellow } from "colorette";
|
|
9
|
-
import
|
|
10
|
-
import path from "node:path";
|
|
11
|
+
import { getConfig } from "@powerhousedao/shared/clis";
|
|
11
12
|
import { createLogger } from "vite";
|
|
12
13
|
import { createVetraDocument, getVetraDocuments, setPackageGithubUrl } from "@powerhousedao/common/utils";
|
|
13
14
|
import { isPortAvailable } from "@powerhousedao/switchboard/server";
|
|
@@ -396,7 +397,7 @@ async function startVetraPreviewDrive(reactor, port, verbose) {
|
|
|
396
397
|
slug: previewDriveId,
|
|
397
398
|
global: {
|
|
398
399
|
name: "Vetra Preview",
|
|
399
|
-
icon:
|
|
400
|
+
icon: POWERHOUSE_DRIVE_ICON,
|
|
400
401
|
nodes: []
|
|
401
402
|
},
|
|
402
403
|
local: {
|
|
@@ -409,6 +410,23 @@ async function startVetraPreviewDrive(reactor, port, verbose) {
|
|
|
409
410
|
if (verbose) console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));
|
|
410
411
|
return driveUrl;
|
|
411
412
|
}
|
|
413
|
+
async function startVetraWorkflowsDrive(reactor, port, verbose) {
|
|
414
|
+
const workflowsDrive = {
|
|
415
|
+
id: generateProjectDriveId("workflows"),
|
|
416
|
+
slug: "workflows",
|
|
417
|
+
global: { name: "Workflows" },
|
|
418
|
+
preferredEditor: "workflow-studio",
|
|
419
|
+
local: {
|
|
420
|
+
availableOffline: true,
|
|
421
|
+
listeners: [],
|
|
422
|
+
sharingType: "public",
|
|
423
|
+
triggers: []
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
const driveUrl = await addDefaultDrive(reactor, workflowsDrive, port);
|
|
427
|
+
if (verbose) console.log(blue(`Vetra Switchboard: Workflows drive: ${driveUrl}`));
|
|
428
|
+
return driveUrl;
|
|
429
|
+
}
|
|
412
430
|
async function startLocalVetraSwitchboard(args, logger) {
|
|
413
431
|
const { connectPort, switchboardPort, dev, packages, disableLocalPackages, debug, httpsKeyFile, httpsCertFile, remoteDrive, interactive, watch, verbose } = args;
|
|
414
432
|
const remoteDrives = remoteDrive ? [remoteDrive] : [];
|
|
@@ -454,6 +472,12 @@ async function startLocalVetraSwitchboard(args, logger) {
|
|
|
454
472
|
} catch (error) {
|
|
455
473
|
console.error(error);
|
|
456
474
|
}
|
|
475
|
+
let workflowsDriveUrl = null;
|
|
476
|
+
if (switchboard.workflowsEnabled) try {
|
|
477
|
+
workflowsDriveUrl = await startVetraWorkflowsDrive(switchboard.reactor, actualSwitchboardPort, verbose);
|
|
478
|
+
} catch (error) {
|
|
479
|
+
console.error(error);
|
|
480
|
+
}
|
|
457
481
|
if (verbose) {
|
|
458
482
|
console.log(blue(`Vetra Switchboard: Started successfully`));
|
|
459
483
|
if (remoteDrive) console.log(blue(`Vetra Switchboard: Syncing with remote drive: ${remoteDrive}`));
|
|
@@ -462,10 +486,12 @@ async function startLocalVetraSwitchboard(args, logger) {
|
|
|
462
486
|
console.log(blue(`Vetra Switchboard: http://localhost:${actualSwitchboardPort}/graphql`));
|
|
463
487
|
console.log(blue(` ➜ Drive URL: ${switchboard.defaultDriveUrl}`));
|
|
464
488
|
if (previewDriveUrl) console.log(blue(` ➜ Preview Drive URL: ${previewDriveUrl}`));
|
|
489
|
+
if (workflowsDriveUrl) console.log(blue(` ➜ Workflows Drive URL: ${workflowsDriveUrl}`));
|
|
465
490
|
}
|
|
466
491
|
return {
|
|
467
492
|
driveUrl: switchboard.defaultDriveUrl || "",
|
|
468
493
|
previewDriveUrl,
|
|
494
|
+
workflowsDriveUrl,
|
|
469
495
|
switchboardPort: actualSwitchboardPort
|
|
470
496
|
};
|
|
471
497
|
} catch (error) {
|
|
@@ -511,6 +537,7 @@ async function startVetra(args) {
|
|
|
511
537
|
}, switchboardLogger);
|
|
512
538
|
const driveUrl = switchboardResult.driveUrl || remoteDrive || "";
|
|
513
539
|
const previewDriveUrl = switchboardResult.previewDriveUrl;
|
|
540
|
+
const workflowsDriveUrl = switchboardResult.workflowsDriveUrl;
|
|
514
541
|
const actualSwitchboardPort = switchboardResult.switchboardPort;
|
|
515
542
|
writeVetraRuntime(projectDir, {
|
|
516
543
|
pid: process.pid,
|
|
@@ -539,19 +566,40 @@ async function startVetra(args) {
|
|
|
539
566
|
}
|
|
540
567
|
if (verbose) console.log("Starting Codegen Reactor...");
|
|
541
568
|
if (!disableConnect) {
|
|
569
|
+
const publicBase = args.drivesPublicBase;
|
|
570
|
+
const browserDriveUrl = publicBase ? rebaseDriveUrl(driveUrl, publicBase) : driveUrl;
|
|
571
|
+
const browserPreviewDriveUrl = previewDriveUrl && publicBase ? rebaseDriveUrl(previewDriveUrl, publicBase) : previewDriveUrl;
|
|
572
|
+
const browserWorkflowsDriveUrl = workflowsDriveUrl && publicBase ? rebaseDriveUrl(workflowsDriveUrl, publicBase) : workflowsDriveUrl;
|
|
573
|
+
const vetraDriveEntries = [
|
|
574
|
+
...browserDriveUrl ? [{
|
|
575
|
+
url: browserDriveUrl,
|
|
576
|
+
name: null,
|
|
577
|
+
icon: null
|
|
578
|
+
}] : [],
|
|
579
|
+
...browserPreviewDriveUrl ? [{
|
|
580
|
+
url: browserPreviewDriveUrl,
|
|
581
|
+
name: null,
|
|
582
|
+
icon: null
|
|
583
|
+
}] : [],
|
|
584
|
+
...browserWorkflowsDriveUrl ? [{
|
|
585
|
+
url: browserWorkflowsDriveUrl,
|
|
586
|
+
name: null,
|
|
587
|
+
icon: null
|
|
588
|
+
}] : []
|
|
589
|
+
];
|
|
590
|
+
const configuredDefaultDrives = getConfig(join(projectDir, "powerhouse.config.json")).connect?.drives?.defaultDrives ?? [];
|
|
591
|
+
const resolvedDefaultDrives = mergeDefaultDrives(vetraDriveEntries, configuredDefaultDrives);
|
|
542
592
|
if (verbose) {
|
|
543
593
|
console.log("Starting Connect...");
|
|
544
|
-
const
|
|
545
|
-
|
|
594
|
+
const flagDefaultDrives = wasFlagExplicitlyPassed("default-drives-url") ? parseDefaultDrivesUrl(args.defaultDrivesUrl ?? "") : [];
|
|
595
|
+
const printedDefaultDrives = mergeDefaultDrives(resolvedDefaultDrives, flagDefaultDrives);
|
|
596
|
+
console.log(` ➜ Connect will use default drives: ${printedDefaultDrives.map((d) => "url" in d ? d.url : `local:${d.id}`).join(", ")}`);
|
|
546
597
|
}
|
|
547
598
|
console.log();
|
|
548
599
|
console.log(green(`Vetra Connect: http://localhost:${connectPort}`));
|
|
549
600
|
const customViteLogger = createViteLogger(green);
|
|
550
|
-
const publicBase = args.drivesPublicBase;
|
|
551
|
-
const browserDriveUrl = publicBase ? rebaseDriveUrl(driveUrl, publicBase) : driveUrl;
|
|
552
|
-
const browserPreviewDriveUrl = previewDriveUrl && publicBase ? rebaseDriveUrl(previewDriveUrl, publicBase) : previewDriveUrl;
|
|
553
601
|
const vetraDrivesOverride = { drives: {
|
|
554
|
-
defaultDrives:
|
|
602
|
+
defaultDrives: resolvedDefaultDrives,
|
|
555
603
|
preserveStrategy: "preserve-all"
|
|
556
604
|
} };
|
|
557
605
|
await runConnectStudio({
|
|
@@ -575,5 +623,5 @@ async function startVetra(args) {
|
|
|
575
623
|
//#endregion
|
|
576
624
|
export { startVetra };
|
|
577
625
|
|
|
578
|
-
//# sourceMappingURL=vetra-
|
|
579
|
-
//# debugId=
|
|
626
|
+
//# sourceMappingURL=vetra-CPGUTtaF.mjs.map
|
|
627
|
+
//# debugId=2f3f4948-fb4f-582f-adbe-e14c16c249c3
|