everything-dev 0.3.2 → 1.3.2
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/README.md +64 -0
- package/cli.js +10 -0
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/api-contract.cjs +172 -0
- package/dist/api-contract.cjs.map +1 -0
- package/dist/api-contract.mjs +171 -0
- package/dist/api-contract.mjs.map +1 -0
- package/dist/api.cjs +124 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +36 -0
- package/dist/api.d.cts.map +1 -0
- package/dist/api.d.mts +36 -0
- package/dist/api.d.mts.map +1 -0
- package/dist/api.mjs +119 -0
- package/dist/api.mjs.map +1 -0
- package/dist/app.cjs +156 -0
- package/dist/app.cjs.map +1 -0
- package/dist/app.mjs +153 -0
- package/dist/app.mjs.map +1 -0
- package/dist/cli/catalog.cjs +30 -0
- package/dist/cli/catalog.cjs.map +1 -0
- package/dist/cli/catalog.mjs +29 -0
- package/dist/cli/catalog.mjs.map +1 -0
- package/dist/cli/help.cjs +16 -0
- package/dist/cli/help.cjs.map +1 -0
- package/dist/cli/help.mjs +16 -0
- package/dist/cli/help.mjs.map +1 -0
- package/dist/cli/init.cjs +317 -0
- package/dist/cli/init.cjs.map +1 -0
- package/dist/cli/init.d.cts +36 -0
- package/dist/cli/init.d.cts.map +1 -0
- package/dist/cli/init.d.mts +36 -0
- package/dist/cli/init.d.mts.map +1 -0
- package/dist/cli/init.mjs +309 -0
- package/dist/cli/init.mjs.map +1 -0
- package/dist/cli/parse.cjs +96 -0
- package/dist/cli/parse.cjs.map +1 -0
- package/dist/cli/parse.mjs +95 -0
- package/dist/cli/parse.mjs.map +1 -0
- package/dist/cli/prompts.cjs +42 -0
- package/dist/cli/prompts.cjs.map +1 -0
- package/dist/cli/prompts.mjs +41 -0
- package/dist/cli/prompts.mjs.map +1 -0
- package/dist/cli.cjs +167 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +166 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/components/dev-view.cjs +307 -0
- package/dist/components/dev-view.cjs.map +1 -0
- package/dist/components/dev-view.mjs +306 -0
- package/dist/components/dev-view.mjs.map +1 -0
- package/dist/components/streaming-view.cjs +146 -0
- package/dist/components/streaming-view.cjs.map +1 -0
- package/dist/components/streaming-view.mjs +144 -0
- package/dist/components/streaming-view.mjs.map +1 -0
- package/dist/config.cjs +280 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +35 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +35 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +266 -0
- package/dist/config.mjs.map +1 -0
- package/dist/contract.cjs +209 -0
- package/dist/contract.cjs.map +1 -0
- package/dist/contract.d.cts +490 -0
- package/dist/contract.d.cts.map +1 -0
- package/dist/contract.d.mts +490 -0
- package/dist/contract.d.mts.map +1 -0
- package/dist/contract.meta.cjs +104 -0
- package/dist/contract.meta.cjs.map +1 -0
- package/dist/contract.meta.d.cts +141 -0
- package/dist/contract.meta.d.cts.map +1 -0
- package/dist/contract.meta.d.mts +141 -0
- package/dist/contract.meta.d.mts.map +1 -0
- package/dist/contract.meta.mjs +102 -0
- package/dist/contract.meta.mjs.map +1 -0
- package/dist/contract.mjs +186 -0
- package/dist/contract.mjs.map +1 -0
- package/dist/dev-logs.cjs +53 -0
- package/dist/dev-logs.cjs.map +1 -0
- package/dist/dev-logs.mjs +51 -0
- package/dist/dev-logs.mjs.map +1 -0
- package/dist/dev-session.cjs +195 -0
- package/dist/dev-session.cjs.map +1 -0
- package/dist/dev-session.mjs +194 -0
- package/dist/dev-session.mjs.map +1 -0
- package/dist/fastkv.cjs +89 -0
- package/dist/fastkv.cjs.map +1 -0
- package/dist/fastkv.d.cts +11 -0
- package/dist/fastkv.d.cts.map +1 -0
- package/dist/fastkv.d.mts +11 -0
- package/dist/fastkv.d.mts.map +1 -0
- package/dist/fastkv.mjs +82 -0
- package/dist/fastkv.mjs.map +1 -0
- package/dist/federation.server.cjs +27 -0
- package/dist/federation.server.cjs.map +1 -0
- package/dist/federation.server.mjs +27 -0
- package/dist/federation.server.mjs.map +1 -0
- package/dist/host.cjs +367 -0
- package/dist/host.cjs.map +1 -0
- package/dist/host.d.cts +22 -0
- package/dist/host.d.cts.map +1 -0
- package/dist/host.d.mts +22 -0
- package/dist/host.d.mts.map +1 -0
- package/dist/host.mjs +364 -0
- package/dist/host.mjs.map +1 -0
- package/dist/index.cjs +122 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +9 -0
- package/dist/integrity.cjs +39 -0
- package/dist/integrity.cjs.map +1 -0
- package/dist/integrity.d.cts +7 -0
- package/dist/integrity.d.cts.map +1 -0
- package/dist/integrity.d.mts +7 -0
- package/dist/integrity.d.mts.map +1 -0
- package/dist/integrity.mjs +35 -0
- package/dist/integrity.mjs.map +1 -0
- package/dist/mf.cjs +77 -0
- package/dist/mf.cjs.map +1 -0
- package/dist/mf.d.cts +19 -0
- package/dist/mf.d.cts.map +1 -0
- package/dist/mf.d.mts +19 -0
- package/dist/mf.d.mts.map +1 -0
- package/dist/mf.mjs +71 -0
- package/dist/mf.mjs.map +1 -0
- package/dist/near-cli.cjs +196 -0
- package/dist/near-cli.cjs.map +1 -0
- package/dist/near-cli.mjs +193 -0
- package/dist/near-cli.mjs.map +1 -0
- package/dist/network.cjs +9 -0
- package/dist/network.cjs.map +1 -0
- package/dist/network.mjs +8 -0
- package/dist/network.mjs.map +1 -0
- package/dist/orchestrator.cjs +441 -0
- package/dist/orchestrator.cjs.map +1 -0
- package/dist/orchestrator.d.cts +40 -0
- package/dist/orchestrator.d.cts.map +1 -0
- package/dist/orchestrator.d.mts +40 -0
- package/dist/orchestrator.d.mts.map +1 -0
- package/dist/orchestrator.mjs +436 -0
- package/dist/orchestrator.mjs.map +1 -0
- package/dist/plugin.cjs +825 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +347 -0
- package/dist/plugin.d.cts.map +1 -0
- package/dist/plugin.d.mts +348 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +822 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/process-registry.cjs +120 -0
- package/dist/process-registry.cjs.map +1 -0
- package/dist/process-registry.d.cts +25 -0
- package/dist/process-registry.d.cts.map +1 -0
- package/dist/process-registry.d.mts +25 -0
- package/dist/process-registry.d.mts.map +1 -0
- package/dist/process-registry.mjs +119 -0
- package/dist/process-registry.mjs.map +1 -0
- package/dist/sdk.cjs +61 -0
- package/dist/sdk.d.cts +5 -0
- package/dist/sdk.d.mts +5 -0
- package/dist/sdk.mjs +6 -0
- package/dist/shared.cjs +143 -0
- package/dist/shared.cjs.map +1 -0
- package/dist/shared.d.cts +33 -0
- package/dist/shared.d.cts.map +1 -0
- package/dist/shared.d.mts +33 -0
- package/dist/shared.d.mts.map +1 -0
- package/dist/shared.mjs +140 -0
- package/dist/shared.mjs.map +1 -0
- package/dist/types.cjs +160 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +269 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +269 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +144 -0
- package/dist/types.mjs.map +1 -0
- package/dist/ui/head.cjs +67 -0
- package/dist/ui/head.cjs.map +1 -0
- package/dist/ui/head.d.cts +19 -0
- package/dist/ui/head.d.cts.map +1 -0
- package/dist/ui/head.d.mts +19 -0
- package/dist/ui/head.d.mts.map +1 -0
- package/dist/ui/head.mjs +61 -0
- package/dist/ui/head.mjs.map +1 -0
- package/dist/ui/index.cjs +32 -0
- package/dist/ui/index.d.cts +7 -0
- package/dist/ui/index.d.mts +7 -0
- package/dist/ui/index.mjs +6 -0
- package/dist/ui/metadata.cjs +106 -0
- package/dist/ui/metadata.cjs.map +1 -0
- package/dist/ui/metadata.d.cts +35 -0
- package/dist/ui/metadata.d.cts.map +1 -0
- package/dist/ui/metadata.d.mts +35 -0
- package/dist/ui/metadata.d.mts.map +1 -0
- package/dist/ui/metadata.mjs +100 -0
- package/dist/ui/metadata.mjs.map +1 -0
- package/dist/ui/router.cjs +56 -0
- package/dist/ui/router.cjs.map +1 -0
- package/dist/ui/router.d.cts +11 -0
- package/dist/ui/router.d.cts.map +1 -0
- package/dist/ui/router.d.mts +11 -0
- package/dist/ui/router.d.mts.map +1 -0
- package/dist/ui/router.mjs +51 -0
- package/dist/ui/router.mjs.map +1 -0
- package/dist/ui/runtime.cjs +65 -0
- package/dist/ui/runtime.cjs.map +1 -0
- package/dist/ui/runtime.d.cts +29 -0
- package/dist/ui/runtime.d.cts.map +1 -0
- package/dist/ui/runtime.d.mts +29 -0
- package/dist/ui/runtime.d.mts.map +1 -0
- package/dist/ui/runtime.mjs +53 -0
- package/dist/ui/runtime.mjs.map +1 -0
- package/dist/ui/types.cjs +0 -0
- package/dist/ui/types.d.cts +52 -0
- package/dist/ui/types.d.cts.map +1 -0
- package/dist/ui/types.d.mts +52 -0
- package/dist/ui/types.d.mts.map +1 -0
- package/dist/ui/types.mjs +1 -0
- package/dist/utils/banner.cjs +24 -0
- package/dist/utils/banner.cjs.map +1 -0
- package/dist/utils/banner.mjs +23 -0
- package/dist/utils/banner.mjs.map +1 -0
- package/dist/utils/linkify.cjs +15 -0
- package/dist/utils/linkify.cjs.map +1 -0
- package/dist/utils/linkify.mjs +14 -0
- package/dist/utils/linkify.mjs.map +1 -0
- package/dist/utils/run.cjs +40 -0
- package/dist/utils/run.cjs.map +1 -0
- package/dist/utils/run.mjs +39 -0
- package/dist/utils/run.mjs.map +1 -0
- package/dist/utils/theme.cjs +44 -0
- package/dist/utils/theme.cjs.map +1 -0
- package/dist/utils/theme.mjs +37 -0
- package/dist/utils/theme.mjs.map +1 -0
- package/package.json +269 -80
- package/src/api-contract.ts +309 -0
- package/src/api.ts +181 -0
- package/src/app.ts +346 -0
- package/src/cli/catalog.ts +49 -0
- package/src/cli/help.ts +13 -0
- package/src/cli/init.ts +415 -0
- package/src/cli/parse.ts +130 -0
- package/src/cli/prompts.ts +64 -0
- package/src/cli.ts +203 -1507
- package/src/components/dev-view.tsx +104 -41
- package/src/components/streaming-view.ts +89 -22
- package/src/config.ts +462 -532
- package/src/contract.meta.ts +96 -0
- package/src/contract.ts +164 -561
- package/src/dev-logs.ts +85 -0
- package/src/dev-session.ts +318 -0
- package/src/fastkv.ts +153 -0
- package/src/federation.server.ts +43 -0
- package/src/host.ts +526 -0
- package/src/index.ts +6 -3
- package/src/integrity.ts +54 -0
- package/src/mf.ts +105 -0
- package/src/near-cli.ts +284 -0
- package/src/network.ts +3 -0
- package/src/orchestrator.ts +648 -0
- package/src/plugin.ts +1116 -2303
- package/src/process-registry.ts +154 -0
- package/src/scripts/sync-api-contract.ts +24 -0
- package/src/sdk.ts +14 -0
- package/src/shared.ts +206 -0
- package/src/types.ts +152 -206
- package/src/ui/head.ts +34 -27
- package/src/ui/index.ts +3 -3
- package/src/ui/metadata.ts +95 -0
- package/src/ui/router.ts +22 -6
- package/src/ui/runtime.ts +55 -6
- package/src/ui/types.ts +24 -11
- package/src/utils/banner.ts +10 -6
- package/src/utils/run.ts +26 -27
- package/src/utils/theme.ts +3 -66
- package/src/components/monitor-view.tsx +0 -475
- package/src/components/status-view.tsx +0 -173
- package/src/lib/env.ts +0 -109
- package/src/lib/near-cli.ts +0 -289
- package/src/lib/nova.ts +0 -266
- package/src/lib/orchestrator.ts +0 -276
- package/src/lib/process-registry.ts +0 -166
- package/src/lib/process.ts +0 -549
- package/src/lib/resource-monitor/assertions.ts +0 -234
- package/src/lib/resource-monitor/command.ts +0 -283
- package/src/lib/resource-monitor/diff.ts +0 -157
- package/src/lib/resource-monitor/errors.ts +0 -127
- package/src/lib/resource-monitor/index.ts +0 -305
- package/src/lib/resource-monitor/platform/darwin.ts +0 -306
- package/src/lib/resource-monitor/platform/index.ts +0 -35
- package/src/lib/resource-monitor/platform/linux.ts +0 -332
- package/src/lib/resource-monitor/platform/windows.ts +0 -298
- package/src/lib/resource-monitor/snapshot.ts +0 -217
- package/src/lib/resource-monitor/types.ts +0 -74
- package/src/lib/session-recorder/errors.ts +0 -102
- package/src/lib/session-recorder/flows/login.ts +0 -210
- package/src/lib/session-recorder/index.ts +0 -361
- package/src/lib/session-recorder/playwright.ts +0 -257
- package/src/lib/session-recorder/report.ts +0 -353
- package/src/lib/session-recorder/server.ts +0 -267
- package/src/lib/session-recorder/types.ts +0 -115
- package/src/lib/sync.ts +0 -1
- package/src/ui/files.ts +0 -134
package/dist/plugin.cjs
ADDED
|
@@ -0,0 +1,825 @@
|
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_fastkv = require('./fastkv.cjs');
|
|
3
|
+
const require_network = require('./network.cjs');
|
|
4
|
+
require('./sdk.cjs');
|
|
5
|
+
const require_config = require('./config.cjs');
|
|
6
|
+
const require_contract = require('./contract.cjs');
|
|
7
|
+
const require_api_contract = require('./api-contract.cjs');
|
|
8
|
+
const require_app = require('./app.cjs');
|
|
9
|
+
const require_cli_init = require('./cli/init.cjs');
|
|
10
|
+
const require_prompts = require('./cli/prompts.cjs');
|
|
11
|
+
const require_dev_session = require('./dev-session.cjs');
|
|
12
|
+
const require_near_cli = require('./near-cli.cjs');
|
|
13
|
+
const require_shared = require('./shared.cjs');
|
|
14
|
+
const require_run = require('./utils/run.cjs');
|
|
15
|
+
let node_fs = require("node:fs");
|
|
16
|
+
let node_path = require("node:path");
|
|
17
|
+
let effect = require("effect");
|
|
18
|
+
let every_plugin = require("every-plugin");
|
|
19
|
+
let every_plugin_zod = require("every-plugin/zod");
|
|
20
|
+
|
|
21
|
+
//#region src/plugin.ts
|
|
22
|
+
const DEFAULT_DEV_CONFIG = {
|
|
23
|
+
host: "local",
|
|
24
|
+
ui: "local",
|
|
25
|
+
api: "local",
|
|
26
|
+
ssr: false
|
|
27
|
+
};
|
|
28
|
+
const buildCommands = {
|
|
29
|
+
host: {
|
|
30
|
+
cmd: "bun",
|
|
31
|
+
args: ["run", "build"]
|
|
32
|
+
},
|
|
33
|
+
ui: {
|
|
34
|
+
cmd: "bun",
|
|
35
|
+
args: ["run", "build"]
|
|
36
|
+
},
|
|
37
|
+
api: {
|
|
38
|
+
cmd: "bun",
|
|
39
|
+
args: ["run", "build"]
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const PUBLISH_FUNCTION_NAMES = ["__fastdata_kv"];
|
|
43
|
+
function parseSourceMode(value, defaultValue) {
|
|
44
|
+
if (value === "local" || value === "remote") return value;
|
|
45
|
+
return defaultValue;
|
|
46
|
+
}
|
|
47
|
+
function buildAppConfig(options) {
|
|
48
|
+
return {
|
|
49
|
+
host: parseSourceMode(options.host, DEFAULT_DEV_CONFIG.host),
|
|
50
|
+
ui: parseSourceMode(options.ui, DEFAULT_DEV_CONFIG.ui),
|
|
51
|
+
api: parseSourceMode(options.api, DEFAULT_DEV_CONFIG.api),
|
|
52
|
+
proxy: options.proxy,
|
|
53
|
+
ssr: options.ssr ?? DEFAULT_DEV_CONFIG.ssr
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function buildDescription(config) {
|
|
57
|
+
if (config.host === "local" && config.ui === "local" && config.api === "local" && !config.proxy) return "Full Local Development";
|
|
58
|
+
const parts = [];
|
|
59
|
+
parts.push(config.host === "remote" ? "Remote Host" : "Local Host");
|
|
60
|
+
if (config.ui === "remote") parts.push("Remote UI");
|
|
61
|
+
if (config.proxy) parts.push("Proxy API → Production");
|
|
62
|
+
else if (config.api === "remote") parts.push("Remote API");
|
|
63
|
+
return parts.join(" + ");
|
|
64
|
+
}
|
|
65
|
+
function buildConfigResult(bosConfig) {
|
|
66
|
+
const packages = bosConfig ? Object.keys(bosConfig.app) : [];
|
|
67
|
+
return {
|
|
68
|
+
config: bosConfig,
|
|
69
|
+
packages,
|
|
70
|
+
remotes: packages.filter((name) => name !== "host")
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function resolveWorkspaceTarget(key, bosConfig, runtimeConfig, configDir) {
|
|
74
|
+
if (bosConfig?.app && key in bosConfig.app) return {
|
|
75
|
+
key,
|
|
76
|
+
kind: "app",
|
|
77
|
+
path: `${configDir}/${key}`
|
|
78
|
+
};
|
|
79
|
+
const pluginPath = (runtimeConfig?.plugins?.[key])?.localPath ?? require_config.resolveLocalDevelopmentPath(bosConfig?.plugins?.[key]?.development, configDir);
|
|
80
|
+
if (pluginPath) return {
|
|
81
|
+
key,
|
|
82
|
+
kind: "plugin",
|
|
83
|
+
path: pluginPath
|
|
84
|
+
};
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
function determineProcesses(config, localPackages, runtimeConfig) {
|
|
88
|
+
const processes = [];
|
|
89
|
+
if (config.ssr && config.ui === "local") processes.push("ui-ssr");
|
|
90
|
+
if (config.ui === "local") processes.push("ui");
|
|
91
|
+
if (config.api === "local" && !config.proxy) processes.push("api");
|
|
92
|
+
for (const pkg of localPackages) if (pkg.startsWith("plugin:")) {
|
|
93
|
+
const pluginId = pkg.slice(7);
|
|
94
|
+
if (runtimeConfig?.plugins?.[pluginId]?.source === "local") processes.push(pkg);
|
|
95
|
+
}
|
|
96
|
+
processes.push("host");
|
|
97
|
+
return processes;
|
|
98
|
+
}
|
|
99
|
+
function isValidProxyUrl(url) {
|
|
100
|
+
try {
|
|
101
|
+
const parsed = new URL(url);
|
|
102
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
103
|
+
} catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function resolveProxyUrl(bosConfig) {
|
|
108
|
+
if (!bosConfig) return null;
|
|
109
|
+
const apiConfig = bosConfig.app.api;
|
|
110
|
+
if (!apiConfig) return null;
|
|
111
|
+
if (apiConfig.proxy && isValidProxyUrl(apiConfig.proxy)) return apiConfig.proxy;
|
|
112
|
+
if (apiConfig.production && isValidProxyUrl(apiConfig.production)) return apiConfig.production;
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
function sanitizePluginKey(value) {
|
|
116
|
+
return value.replace(/[^A-Za-z0-9/_-]/g, "-").replace(/\/+/g, "/").split("/").filter(Boolean).map((segment) => segment.replace(/[^A-Za-z0-9_-]/g, "-")).join("/").replace(/^\/+|\/+$/g, "");
|
|
117
|
+
}
|
|
118
|
+
function defaultPluginKey(source) {
|
|
119
|
+
const normalized = source.replace(/^local:/, "").replace(/\/$/, "");
|
|
120
|
+
if (source.startsWith("local:")) return sanitizePluginKey((0, node_path.basename)(normalized)) || "plugin";
|
|
121
|
+
try {
|
|
122
|
+
const url = new URL(source);
|
|
123
|
+
return sanitizePluginKey((0, node_path.basename)(url.pathname) || url.hostname) || "plugin";
|
|
124
|
+
} catch {
|
|
125
|
+
return sanitizePluginKey(source) || "plugin";
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function pluginLocalPath(configDir, attachment) {
|
|
129
|
+
const source = attachment.development ?? attachment.production;
|
|
130
|
+
if (!source?.startsWith("local:")) return null;
|
|
131
|
+
return (0, node_path.join)(configDir, source.slice(6));
|
|
132
|
+
}
|
|
133
|
+
async function saveBosConfig(configDir, config) {
|
|
134
|
+
const filePath = (0, node_path.join)(configDir, "bos.config.json");
|
|
135
|
+
const next = `${JSON.stringify(config, null, 2)}\n`;
|
|
136
|
+
try {
|
|
137
|
+
if ((0, node_fs.readFileSync)(filePath, "utf8") === next) return;
|
|
138
|
+
} catch {}
|
|
139
|
+
(0, node_fs.writeFileSync)(filePath, next);
|
|
140
|
+
}
|
|
141
|
+
function listPluginAttachments(config) {
|
|
142
|
+
return Object.entries(config?.plugins ?? {}).map(([key, attachment]) => ({
|
|
143
|
+
key,
|
|
144
|
+
development: attachment.development,
|
|
145
|
+
production: attachment.production,
|
|
146
|
+
localPath: attachment.development?.startsWith("local:") ? attachment.development.slice(6) : void 0,
|
|
147
|
+
source: attachment.development?.startsWith("local:") ? "local" : "remote"
|
|
148
|
+
})).sort((a, b) => a.key.localeCompare(b.key));
|
|
149
|
+
}
|
|
150
|
+
async function refreshApiContractBridge(configDir) {
|
|
151
|
+
const refreshed = await require_config.loadConfig({
|
|
152
|
+
cwd: configDir,
|
|
153
|
+
env: "development"
|
|
154
|
+
});
|
|
155
|
+
if (!refreshed) return;
|
|
156
|
+
await require_api_contract.syncApiContractBridge({
|
|
157
|
+
configDir,
|
|
158
|
+
runtimeConfig: refreshed.runtime,
|
|
159
|
+
apiBaseUrl: refreshed.runtime.api.url
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function extractPublishedUrl(output) {
|
|
163
|
+
const match = output.match(/https?:\/\/[^\s"'<>]+/g);
|
|
164
|
+
if (!match || match.length === 0) return null;
|
|
165
|
+
return match[match.length - 1] ?? null;
|
|
166
|
+
}
|
|
167
|
+
async function buildEnvVars(config, bosConfig) {
|
|
168
|
+
const env = {
|
|
169
|
+
HOST_SOURCE: config.host,
|
|
170
|
+
UI_SOURCE: config.ui,
|
|
171
|
+
API_SOURCE: config.api
|
|
172
|
+
};
|
|
173
|
+
if (config.host === "remote") {
|
|
174
|
+
const remoteUrl = bosConfig?.app.host.production;
|
|
175
|
+
if (remoteUrl) env.HOST_REMOTE_URL = remoteUrl;
|
|
176
|
+
}
|
|
177
|
+
if (config.ui === "remote") {
|
|
178
|
+
const remoteUrl = bosConfig?.app.ui.production;
|
|
179
|
+
if (remoteUrl) env.UI_REMOTE_URL = remoteUrl;
|
|
180
|
+
}
|
|
181
|
+
if (config.api === "remote") {
|
|
182
|
+
const remoteUrl = bosConfig?.app.api.production;
|
|
183
|
+
if (remoteUrl) env.API_REMOTE_URL = remoteUrl;
|
|
184
|
+
}
|
|
185
|
+
if (config.proxy && bosConfig) {
|
|
186
|
+
const proxyUrl = resolveProxyUrl(bosConfig);
|
|
187
|
+
if (proxyUrl) env.API_PROXY = proxyUrl;
|
|
188
|
+
}
|
|
189
|
+
return env;
|
|
190
|
+
}
|
|
191
|
+
async function buildEveryPluginQuietly(cwd) {
|
|
192
|
+
const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;
|
|
193
|
+
if (await Bun.file(distPath).exists()) return;
|
|
194
|
+
const result = await require_run.run("bun", [
|
|
195
|
+
"run",
|
|
196
|
+
"--cwd",
|
|
197
|
+
"packages/every-plugin",
|
|
198
|
+
"build"
|
|
199
|
+
], {
|
|
200
|
+
cwd,
|
|
201
|
+
capture: true
|
|
202
|
+
});
|
|
203
|
+
if (result.exitCode === 0) {
|
|
204
|
+
console.log("[build:ssr] build succeeded");
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (result.stdout.trim()) process.stdout.write(result.stdout);
|
|
208
|
+
if (result.stderr.trim()) process.stderr.write(result.stderr);
|
|
209
|
+
throw new Error(`bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`);
|
|
210
|
+
}
|
|
211
|
+
async function buildEverythingDevQuietly(cwd) {
|
|
212
|
+
const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;
|
|
213
|
+
if (await Bun.file(distPath).exists()) return;
|
|
214
|
+
const result = await require_run.run("bun", [
|
|
215
|
+
"run",
|
|
216
|
+
"--cwd",
|
|
217
|
+
"packages/everything-dev",
|
|
218
|
+
"build"
|
|
219
|
+
], {
|
|
220
|
+
cwd,
|
|
221
|
+
capture: true
|
|
222
|
+
});
|
|
223
|
+
if (result.exitCode === 0) {
|
|
224
|
+
console.log("[everything-dev] build succeeded");
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (result.stdout.trim()) process.stdout.write(result.stdout);
|
|
228
|
+
if (result.stderr.trim()) process.stderr.write(result.stderr);
|
|
229
|
+
throw new Error(`bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`);
|
|
230
|
+
}
|
|
231
|
+
async function fetchPublishedConfig(accountId, gatewayId) {
|
|
232
|
+
try {
|
|
233
|
+
return await require_fastkv.fetchBosConfigFromFastKv(`bos://${accountId}/${gatewayId}`);
|
|
234
|
+
} catch {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function selectWorkspaceTargets(packages, bosConfig) {
|
|
239
|
+
const allPackages = [...Object.keys(bosConfig?.app ?? {}), ...Object.keys(bosConfig?.plugins ?? {})];
|
|
240
|
+
if (packages === "all") return allPackages;
|
|
241
|
+
return packages.split(",").map((pkg) => pkg.trim()).filter((pkg) => allPackages.includes(pkg));
|
|
242
|
+
}
|
|
243
|
+
async function buildWorkspaceTargets(opts) {
|
|
244
|
+
const existing = [];
|
|
245
|
+
const skipped = [];
|
|
246
|
+
for (const target of opts.targets) {
|
|
247
|
+
const resolved = resolveWorkspaceTarget(target, opts.bosConfig, opts.runtimeConfig, opts.configDir);
|
|
248
|
+
if (!resolved) {
|
|
249
|
+
skipped.push(target);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
if (await Bun.file(`${resolved.path}/package.json`).exists()) existing.push(resolved);
|
|
253
|
+
else skipped.push(target);
|
|
254
|
+
}
|
|
255
|
+
if (existing.length === 0) return {
|
|
256
|
+
built: [],
|
|
257
|
+
skipped
|
|
258
|
+
};
|
|
259
|
+
if ((await require_shared.syncAndGenerateSharedUi({
|
|
260
|
+
configDir: opts.configDir,
|
|
261
|
+
hostMode: "local",
|
|
262
|
+
bosConfig: opts.bosConfig ?? void 0
|
|
263
|
+
})).catalogChanged) await require_run.run("bun", ["install"], { cwd: opts.configDir });
|
|
264
|
+
if (existing.some((entry) => entry.key === "api")) await buildEveryPluginQuietly(opts.configDir);
|
|
265
|
+
await buildEverythingDevQuietly(opts.configDir);
|
|
266
|
+
const env = {
|
|
267
|
+
...process.env,
|
|
268
|
+
NODE_ENV: opts.deploy ? "production" : "development"
|
|
269
|
+
};
|
|
270
|
+
if (opts.deploy) env.DEPLOY = "true";
|
|
271
|
+
else delete env.DEPLOY;
|
|
272
|
+
const orderedExisting = opts.deploy ? [
|
|
273
|
+
...existing.filter((entry) => entry.kind === "app" && entry.key !== "host"),
|
|
274
|
+
...existing.filter((entry) => entry.kind === "plugin"),
|
|
275
|
+
...existing.filter((entry) => entry.kind === "app" && entry.key === "host")
|
|
276
|
+
] : existing;
|
|
277
|
+
const built = [];
|
|
278
|
+
for (const resolved of orderedExisting) {
|
|
279
|
+
const pkgJson = JSON.parse(await Bun.file(`${resolved.path}/package.json`).text());
|
|
280
|
+
const buildConfig = opts.deploy && pkgJson.scripts?.deploy ? {
|
|
281
|
+
cmd: "bun",
|
|
282
|
+
args: ["run", "deploy"]
|
|
283
|
+
} : buildCommands[resolved.key] ?? {
|
|
284
|
+
cmd: "bun",
|
|
285
|
+
args: ["run", "build"]
|
|
286
|
+
};
|
|
287
|
+
await require_run.run(buildConfig.cmd, buildConfig.args, {
|
|
288
|
+
cwd: resolved.path,
|
|
289
|
+
env
|
|
290
|
+
});
|
|
291
|
+
built.push(resolved.key);
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
built,
|
|
295
|
+
skipped
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
var plugin_default = (0, every_plugin.createPlugin)({
|
|
299
|
+
variables: every_plugin_zod.z.object({ configPath: every_plugin_zod.z.string().optional() }),
|
|
300
|
+
secrets: every_plugin_zod.z.object({}),
|
|
301
|
+
contract: require_contract.bosContract,
|
|
302
|
+
initialize: (config) => effect.Effect.promise(async () => {
|
|
303
|
+
const configResult = await require_config.loadConfig({ path: config.variables.configPath });
|
|
304
|
+
return {
|
|
305
|
+
bosConfig: configResult?.config ?? null,
|
|
306
|
+
runtimeConfig: configResult?.runtime ?? null,
|
|
307
|
+
configDir: require_config.getProjectRoot()
|
|
308
|
+
};
|
|
309
|
+
}),
|
|
310
|
+
shutdown: () => effect.Effect.void,
|
|
311
|
+
createRouter: (deps, builder) => ({
|
|
312
|
+
config: builder.config.handler(async () => buildConfigResult(deps.bosConfig)),
|
|
313
|
+
pluginAdd: builder.pluginAdd.handler(async ({ input }) => {
|
|
314
|
+
if (!deps.bosConfig) return {
|
|
315
|
+
status: "error",
|
|
316
|
+
key: "",
|
|
317
|
+
error: "No bos.config.json found"
|
|
318
|
+
};
|
|
319
|
+
const key = sanitizePluginKey(input.as ?? defaultPluginKey(input.source));
|
|
320
|
+
const existing = deps.bosConfig.plugins?.[key];
|
|
321
|
+
const nextPlugins = { ...deps.bosConfig.plugins ?? {} };
|
|
322
|
+
nextPlugins[key] = input.source.startsWith("local:") ? {
|
|
323
|
+
...existing ?? {},
|
|
324
|
+
development: input.source,
|
|
325
|
+
production: input.production ?? existing?.production
|
|
326
|
+
} : {
|
|
327
|
+
...existing ?? {},
|
|
328
|
+
production: input.production ?? input.source
|
|
329
|
+
};
|
|
330
|
+
deps.bosConfig = {
|
|
331
|
+
...deps.bosConfig,
|
|
332
|
+
plugins: nextPlugins
|
|
333
|
+
};
|
|
334
|
+
await saveBosConfig(deps.configDir, deps.bosConfig);
|
|
335
|
+
await refreshApiContractBridge(deps.configDir);
|
|
336
|
+
return {
|
|
337
|
+
status: "added",
|
|
338
|
+
key,
|
|
339
|
+
development: deps.bosConfig.plugins?.[key]?.development,
|
|
340
|
+
production: deps.bosConfig.plugins?.[key]?.production
|
|
341
|
+
};
|
|
342
|
+
}),
|
|
343
|
+
pluginRemove: builder.pluginRemove.handler(async ({ input }) => {
|
|
344
|
+
if (!deps.bosConfig) return {
|
|
345
|
+
status: "error",
|
|
346
|
+
key: input.key,
|
|
347
|
+
error: "No bos.config.json found"
|
|
348
|
+
};
|
|
349
|
+
if (!deps.bosConfig.plugins?.[input.key]) return {
|
|
350
|
+
status: "error",
|
|
351
|
+
key: input.key,
|
|
352
|
+
error: `Plugin '${input.key}' is not configured`
|
|
353
|
+
};
|
|
354
|
+
const nextPlugins = { ...deps.bosConfig.plugins ?? {} };
|
|
355
|
+
delete nextPlugins[input.key];
|
|
356
|
+
deps.bosConfig = {
|
|
357
|
+
...deps.bosConfig,
|
|
358
|
+
plugins: Object.keys(nextPlugins).length > 0 ? nextPlugins : void 0
|
|
359
|
+
};
|
|
360
|
+
await saveBosConfig(deps.configDir, deps.bosConfig);
|
|
361
|
+
await refreshApiContractBridge(deps.configDir);
|
|
362
|
+
return {
|
|
363
|
+
status: "removed",
|
|
364
|
+
key: input.key
|
|
365
|
+
};
|
|
366
|
+
}),
|
|
367
|
+
pluginList: builder.pluginList.handler(async () => {
|
|
368
|
+
return {
|
|
369
|
+
status: "listed",
|
|
370
|
+
plugins: listPluginAttachments(deps.bosConfig)
|
|
371
|
+
};
|
|
372
|
+
}),
|
|
373
|
+
pluginPublish: builder.pluginPublish.handler(async ({ input }) => {
|
|
374
|
+
if (!deps.bosConfig) return {
|
|
375
|
+
status: "error",
|
|
376
|
+
key: input.key,
|
|
377
|
+
error: "No bos.config.json found"
|
|
378
|
+
};
|
|
379
|
+
const attachment = deps.bosConfig.plugins?.[input.key];
|
|
380
|
+
if (!attachment) return {
|
|
381
|
+
status: "error",
|
|
382
|
+
key: input.key,
|
|
383
|
+
error: `Plugin '${input.key}' is not configured`
|
|
384
|
+
};
|
|
385
|
+
const localPath = pluginLocalPath(deps.configDir, attachment);
|
|
386
|
+
if (!localPath) return {
|
|
387
|
+
status: "error",
|
|
388
|
+
key: input.key,
|
|
389
|
+
error: `Plugin '${input.key}' does not have a local development path`
|
|
390
|
+
};
|
|
391
|
+
const pkgPath = (0, node_path.join)(localPath, "package.json");
|
|
392
|
+
if (!await Bun.file(pkgPath).exists()) return {
|
|
393
|
+
status: "error",
|
|
394
|
+
key: input.key,
|
|
395
|
+
error: `Missing package.json at ${localPath}`
|
|
396
|
+
};
|
|
397
|
+
const script = (await Bun.file(pkgPath).json()).scripts?.deploy ? "deploy" : "build";
|
|
398
|
+
const { stdout, stderr, exitCode } = await require_run.run("bun", ["run", script], {
|
|
399
|
+
cwd: localPath,
|
|
400
|
+
capture: true
|
|
401
|
+
});
|
|
402
|
+
if (exitCode !== 0) {
|
|
403
|
+
if (stdout.trim()) process.stdout.write(stdout);
|
|
404
|
+
if (stderr.trim()) process.stderr.write(stderr);
|
|
405
|
+
return {
|
|
406
|
+
status: "error",
|
|
407
|
+
key: input.key,
|
|
408
|
+
error: `Publish failed with exit code ${exitCode}`
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
if (stdout.trim()) process.stdout.write(stdout);
|
|
412
|
+
if (stderr.trim()) process.stderr.write(stderr);
|
|
413
|
+
const publishedUrl = extractPublishedUrl(`${stdout}\n${stderr}`);
|
|
414
|
+
if (publishedUrl) {
|
|
415
|
+
deps.bosConfig = {
|
|
416
|
+
...deps.bosConfig,
|
|
417
|
+
plugins: {
|
|
418
|
+
...deps.bosConfig.plugins ?? {},
|
|
419
|
+
[input.key]: {
|
|
420
|
+
...deps.bosConfig.plugins?.[input.key] ?? {},
|
|
421
|
+
production: publishedUrl
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
await saveBosConfig(deps.configDir, deps.bosConfig);
|
|
426
|
+
await refreshApiContractBridge(deps.configDir);
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
status: "published",
|
|
430
|
+
key: input.key,
|
|
431
|
+
path: localPath,
|
|
432
|
+
script,
|
|
433
|
+
production: publishedUrl ?? attachment.production
|
|
434
|
+
};
|
|
435
|
+
}),
|
|
436
|
+
dev: builder.dev.handler(async ({ input }) => {
|
|
437
|
+
const localPackages = require_app.detectLocalPackages(deps.bosConfig ?? void 0, deps.runtimeConfig ?? void 0);
|
|
438
|
+
const appConfig = buildAppConfig({
|
|
439
|
+
host: localPackages.includes("host") ? input.host : "remote",
|
|
440
|
+
ui: localPackages.includes("ui") ? input.ui : "remote",
|
|
441
|
+
api: localPackages.includes("api") ? input.api : "remote",
|
|
442
|
+
proxy: input.proxy,
|
|
443
|
+
ssr: input.ssr
|
|
444
|
+
});
|
|
445
|
+
if ((await require_shared.syncAndGenerateSharedUi({
|
|
446
|
+
configDir: deps.configDir,
|
|
447
|
+
hostMode: appConfig.host,
|
|
448
|
+
bosConfig: deps.bosConfig ?? void 0
|
|
449
|
+
})).catalogChanged) await require_run.run("bun", ["install"], { cwd: deps.configDir });
|
|
450
|
+
if (appConfig.api === "local" && !appConfig.proxy || localPackages.some((pkg) => pkg.startsWith("plugin:"))) await buildEveryPluginQuietly(deps.configDir);
|
|
451
|
+
await buildEverythingDevQuietly(deps.configDir);
|
|
452
|
+
const refreshed = await require_config.loadConfig({ cwd: deps.configDir });
|
|
453
|
+
deps.bosConfig = refreshed?.config ?? deps.bosConfig;
|
|
454
|
+
deps.runtimeConfig = refreshed?.runtime ?? deps.runtimeConfig;
|
|
455
|
+
if (!deps.bosConfig) return {
|
|
456
|
+
status: "error",
|
|
457
|
+
description: "No bos.config.json found",
|
|
458
|
+
processes: []
|
|
459
|
+
};
|
|
460
|
+
if (appConfig.proxy && !resolveProxyUrl(deps.bosConfig)) return {
|
|
461
|
+
status: "error",
|
|
462
|
+
description: "No valid proxy URL configured in bos.config.json",
|
|
463
|
+
processes: []
|
|
464
|
+
};
|
|
465
|
+
const processes = determineProcesses(appConfig, require_app.detectLocalPackages(deps.bosConfig ?? void 0, deps.runtimeConfig ?? void 0), deps.runtimeConfig);
|
|
466
|
+
const env = await buildEnvVars(appConfig, deps.bosConfig);
|
|
467
|
+
const hostPort = input.port ?? require_config.getHostDevelopmentPort(deps.bosConfig.app.host.development);
|
|
468
|
+
const runtimeConfig = await require_app.prepareDevelopmentRuntimeConfig(require_app.buildRuntimeConfig(deps.bosConfig, {
|
|
469
|
+
uiSource: appConfig.ui,
|
|
470
|
+
apiSource: appConfig.api,
|
|
471
|
+
hostUrl: `http://localhost:${hostPort}`,
|
|
472
|
+
proxy: env.API_PROXY,
|
|
473
|
+
env: "development",
|
|
474
|
+
plugins: deps.runtimeConfig?.plugins
|
|
475
|
+
}), {
|
|
476
|
+
hostPort,
|
|
477
|
+
ssr: appConfig.ssr
|
|
478
|
+
});
|
|
479
|
+
await require_api_contract.syncApiContractBridge({
|
|
480
|
+
configDir: deps.configDir,
|
|
481
|
+
runtimeConfig,
|
|
482
|
+
apiBaseUrl: runtimeConfig.api.url
|
|
483
|
+
});
|
|
484
|
+
const orchestrator = {
|
|
485
|
+
packages: processes,
|
|
486
|
+
env,
|
|
487
|
+
description: buildDescription(appConfig),
|
|
488
|
+
appConfig,
|
|
489
|
+
bosConfig: deps.bosConfig,
|
|
490
|
+
runtimeConfig,
|
|
491
|
+
port: require_config.parsePort(runtimeConfig.hostUrl),
|
|
492
|
+
interactive: input.interactive
|
|
493
|
+
};
|
|
494
|
+
require_dev_session.startApp(orchestrator);
|
|
495
|
+
return {
|
|
496
|
+
status: "started",
|
|
497
|
+
description: orchestrator.description,
|
|
498
|
+
processes
|
|
499
|
+
};
|
|
500
|
+
}),
|
|
501
|
+
start: builder.start.handler(async ({ input }) => {
|
|
502
|
+
let remoteConfig = null;
|
|
503
|
+
if (input.account && input.domain) {
|
|
504
|
+
remoteConfig = await fetchPublishedConfig(input.account, input.domain);
|
|
505
|
+
if (!remoteConfig) return {
|
|
506
|
+
status: "error",
|
|
507
|
+
url: ""
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
const config = remoteConfig || deps.bosConfig;
|
|
511
|
+
if (!config) return {
|
|
512
|
+
status: "error",
|
|
513
|
+
url: ""
|
|
514
|
+
};
|
|
515
|
+
const port = input.port ?? require_config.getHostDevelopmentPort(config.app.host.development);
|
|
516
|
+
const appConfig = {
|
|
517
|
+
host: "remote",
|
|
518
|
+
ui: "remote",
|
|
519
|
+
api: "remote"
|
|
520
|
+
};
|
|
521
|
+
const env = await buildEnvVars(appConfig, config);
|
|
522
|
+
const isStaging = input.env === "staging";
|
|
523
|
+
const runtimePlugins = remoteConfig ? await require_config.buildRuntimePluginsForConfig(config, deps.configDir, "production") : deps.runtimeConfig?.plugins;
|
|
524
|
+
const runtimeConfig = require_app.buildRuntimeConfig(config, {
|
|
525
|
+
uiSource: "remote",
|
|
526
|
+
apiSource: "remote",
|
|
527
|
+
hostUrl: `http://localhost:${port}`,
|
|
528
|
+
env: "production",
|
|
529
|
+
plugins: runtimePlugins
|
|
530
|
+
});
|
|
531
|
+
await require_api_contract.syncApiContractBridge({
|
|
532
|
+
configDir: deps.configDir,
|
|
533
|
+
runtimeConfig,
|
|
534
|
+
apiBaseUrl: runtimeConfig.api.url
|
|
535
|
+
});
|
|
536
|
+
const stagingEnvVars = isStaging ? { GATEWAY_DOMAIN: config.staging?.domain ?? config.domain ?? "" } : {};
|
|
537
|
+
require_dev_session.startApp({
|
|
538
|
+
packages: ["host"],
|
|
539
|
+
env: {
|
|
540
|
+
NODE_ENV: "production",
|
|
541
|
+
...env,
|
|
542
|
+
...stagingEnvVars
|
|
543
|
+
},
|
|
544
|
+
description: `${isStaging ? "Staging" : "Production"} Mode (${config.account})`,
|
|
545
|
+
appConfig,
|
|
546
|
+
bosConfig: config,
|
|
547
|
+
runtimeConfig,
|
|
548
|
+
port,
|
|
549
|
+
interactive: input.interactive,
|
|
550
|
+
noLogs: true
|
|
551
|
+
});
|
|
552
|
+
return {
|
|
553
|
+
status: "running",
|
|
554
|
+
url: `http://localhost:${port}`
|
|
555
|
+
};
|
|
556
|
+
}),
|
|
557
|
+
build: builder.build.handler(async ({ input }) => {
|
|
558
|
+
if (!deps.bosConfig) return {
|
|
559
|
+
status: "error",
|
|
560
|
+
built: [],
|
|
561
|
+
skipped: []
|
|
562
|
+
};
|
|
563
|
+
const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);
|
|
564
|
+
if (targets.length === 0) return {
|
|
565
|
+
status: "error",
|
|
566
|
+
built: [],
|
|
567
|
+
skipped: []
|
|
568
|
+
};
|
|
569
|
+
const runtimeConfig = require_app.buildRuntimeConfig(deps.bosConfig, {
|
|
570
|
+
uiSource: deps.bosConfig.app.ui?.development ? "local" : "remote",
|
|
571
|
+
apiSource: deps.bosConfig.app.api?.development ? "local" : "remote",
|
|
572
|
+
hostUrl: require_config.resolveDevelopmentHostUrl(deps.bosConfig.app.host.development),
|
|
573
|
+
env: "development",
|
|
574
|
+
plugins: deps.runtimeConfig?.plugins
|
|
575
|
+
});
|
|
576
|
+
await require_api_contract.syncApiContractBridge({
|
|
577
|
+
configDir: deps.configDir,
|
|
578
|
+
runtimeConfig,
|
|
579
|
+
apiBaseUrl: runtimeConfig.api.url
|
|
580
|
+
});
|
|
581
|
+
const { built, skipped } = await buildWorkspaceTargets({
|
|
582
|
+
configDir: deps.configDir,
|
|
583
|
+
bosConfig: deps.bosConfig,
|
|
584
|
+
runtimeConfig,
|
|
585
|
+
targets,
|
|
586
|
+
deploy: input.deploy
|
|
587
|
+
});
|
|
588
|
+
if (built.length === 0) return {
|
|
589
|
+
status: "error",
|
|
590
|
+
built: [],
|
|
591
|
+
skipped
|
|
592
|
+
};
|
|
593
|
+
return {
|
|
594
|
+
status: "success",
|
|
595
|
+
built,
|
|
596
|
+
skipped,
|
|
597
|
+
deployed: input.deploy
|
|
598
|
+
};
|
|
599
|
+
}),
|
|
600
|
+
publish: builder.publish.handler(async ({ input }) => {
|
|
601
|
+
if (!deps.bosConfig) return {
|
|
602
|
+
status: "error",
|
|
603
|
+
registryUrl: "",
|
|
604
|
+
error: "No bos.config.json found"
|
|
605
|
+
};
|
|
606
|
+
const account = deps.bosConfig.account;
|
|
607
|
+
const gateway = deps.bosConfig.domain;
|
|
608
|
+
if (!gateway) return {
|
|
609
|
+
status: "error",
|
|
610
|
+
registryUrl: "",
|
|
611
|
+
error: "bos.config.json must define domain to publish"
|
|
612
|
+
};
|
|
613
|
+
const network = input.network ?? require_network.getNetworkIdForAccount(account);
|
|
614
|
+
const bosUrl = `bos://${account}/${gateway}`;
|
|
615
|
+
const registryUrl = require_fastkv.buildRegistryConfigUrlForNetwork(network, account, gateway);
|
|
616
|
+
const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);
|
|
617
|
+
let publishConfig = deps.bosConfig;
|
|
618
|
+
let built;
|
|
619
|
+
let skipped;
|
|
620
|
+
if (input.dryRun) return {
|
|
621
|
+
status: "dry-run",
|
|
622
|
+
registryUrl,
|
|
623
|
+
built,
|
|
624
|
+
skipped
|
|
625
|
+
};
|
|
626
|
+
if (input.deploy) {
|
|
627
|
+
const result = await buildWorkspaceTargets({
|
|
628
|
+
configDir: deps.configDir,
|
|
629
|
+
bosConfig: deps.bosConfig,
|
|
630
|
+
runtimeConfig: deps.runtimeConfig,
|
|
631
|
+
targets,
|
|
632
|
+
deploy: true
|
|
633
|
+
});
|
|
634
|
+
built = result.built;
|
|
635
|
+
skipped = result.skipped;
|
|
636
|
+
const refreshed = await require_config.loadConfig({ cwd: deps.configDir });
|
|
637
|
+
if (refreshed?.config) {
|
|
638
|
+
deps.bosConfig = refreshed.config;
|
|
639
|
+
deps.runtimeConfig = refreshed.runtime;
|
|
640
|
+
publishConfig = refreshed.config;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const payload = JSON.stringify({ [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishConfig) });
|
|
644
|
+
const argsBase64 = Buffer.from(payload).toString("base64");
|
|
645
|
+
const privateKey = input.privateKey || process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;
|
|
646
|
+
try {
|
|
647
|
+
await effect.Effect.runPromise(require_near_cli.ensureNearCli);
|
|
648
|
+
let txHash;
|
|
649
|
+
try {
|
|
650
|
+
txHash = (await effect.Effect.runPromise(require_near_cli.executeTransaction({
|
|
651
|
+
account,
|
|
652
|
+
contract: require_fastkv.getRegistryNamespaceForNetwork(network),
|
|
653
|
+
method: "__fastdata_kv",
|
|
654
|
+
argsBase64,
|
|
655
|
+
network,
|
|
656
|
+
privateKey,
|
|
657
|
+
gas: "300Tgas",
|
|
658
|
+
deposit: "0NEAR"
|
|
659
|
+
}))).txHash;
|
|
660
|
+
} catch (error) {
|
|
661
|
+
txHash = extractTransactionHash(error);
|
|
662
|
+
if (!txHash) throw error;
|
|
663
|
+
const verifiedConfig = await require_fastkv.fetchBosConfigFromFastKv(bosUrl);
|
|
664
|
+
if (JSON.stringify(verifiedConfig) !== JSON.stringify(publishConfig)) throw error;
|
|
665
|
+
}
|
|
666
|
+
return {
|
|
667
|
+
status: "published",
|
|
668
|
+
registryUrl,
|
|
669
|
+
txHash,
|
|
670
|
+
built,
|
|
671
|
+
skipped
|
|
672
|
+
};
|
|
673
|
+
} catch (error) {
|
|
674
|
+
return {
|
|
675
|
+
status: "error",
|
|
676
|
+
registryUrl,
|
|
677
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
678
|
+
built,
|
|
679
|
+
skipped
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
}),
|
|
683
|
+
keyPublish: builder.keyPublish.handler(async ({ input }) => {
|
|
684
|
+
if (!deps.bosConfig) return {
|
|
685
|
+
status: "error",
|
|
686
|
+
account: "",
|
|
687
|
+
network: "mainnet",
|
|
688
|
+
contract: "",
|
|
689
|
+
allowance: input.allowance,
|
|
690
|
+
functionNames: PUBLISH_FUNCTION_NAMES,
|
|
691
|
+
error: "No bos.config.json found"
|
|
692
|
+
};
|
|
693
|
+
const account = deps.bosConfig.account;
|
|
694
|
+
const network = require_network.getNetworkIdForAccount(account);
|
|
695
|
+
const contract = require_fastkv.getRegistryNamespaceForAccount(account);
|
|
696
|
+
try {
|
|
697
|
+
await effect.Effect.runPromise(require_near_cli.ensureNearCli);
|
|
698
|
+
const keyPair = await require_near_cli.addFunctionCallAccessKey({
|
|
699
|
+
account,
|
|
700
|
+
contract,
|
|
701
|
+
allowance: input.allowance,
|
|
702
|
+
functionNames: PUBLISH_FUNCTION_NAMES,
|
|
703
|
+
network
|
|
704
|
+
});
|
|
705
|
+
return {
|
|
706
|
+
status: "published",
|
|
707
|
+
account,
|
|
708
|
+
network,
|
|
709
|
+
contract,
|
|
710
|
+
allowance: input.allowance,
|
|
711
|
+
functionNames: PUBLISH_FUNCTION_NAMES,
|
|
712
|
+
publicKey: keyPair.publicKey,
|
|
713
|
+
privateKey: keyPair.privateKey
|
|
714
|
+
};
|
|
715
|
+
} catch (error) {
|
|
716
|
+
return {
|
|
717
|
+
status: "error",
|
|
718
|
+
account,
|
|
719
|
+
network,
|
|
720
|
+
contract,
|
|
721
|
+
allowance: input.allowance,
|
|
722
|
+
functionNames: PUBLISH_FUNCTION_NAMES,
|
|
723
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
}),
|
|
727
|
+
init: builder.init.handler(async ({ input }) => {
|
|
728
|
+
try {
|
|
729
|
+
let account = input.account;
|
|
730
|
+
let gateway = input.gateway;
|
|
731
|
+
let destination = input.destination;
|
|
732
|
+
let name = input.name;
|
|
733
|
+
let domain = input.domain;
|
|
734
|
+
let withHost = input.withHost;
|
|
735
|
+
if (!account || !gateway) {
|
|
736
|
+
if (input.noInteractive) return {
|
|
737
|
+
status: "error",
|
|
738
|
+
destination: "",
|
|
739
|
+
parentAccount: account ?? "",
|
|
740
|
+
parentGateway: gateway ?? "",
|
|
741
|
+
name: input.name,
|
|
742
|
+
domain: input.domain,
|
|
743
|
+
extends: account && gateway ? `bos://${account}/${gateway}` : "",
|
|
744
|
+
filesCopied: 0,
|
|
745
|
+
error: "account and gateway are required (use --no-interactive to skip prompts and provide them as positional args)"
|
|
746
|
+
};
|
|
747
|
+
const prompted = await require_prompts.promptInitOptions({
|
|
748
|
+
account,
|
|
749
|
+
gateway,
|
|
750
|
+
destination,
|
|
751
|
+
name,
|
|
752
|
+
domain,
|
|
753
|
+
withHost
|
|
754
|
+
});
|
|
755
|
+
account = prompted.account;
|
|
756
|
+
gateway = prompted.gateway;
|
|
757
|
+
destination = prompted.destination;
|
|
758
|
+
name = prompted.name;
|
|
759
|
+
domain = prompted.domain;
|
|
760
|
+
withHost = prompted.withHost;
|
|
761
|
+
}
|
|
762
|
+
destination = destination || gateway;
|
|
763
|
+
const { sourceDir, cleanup } = await require_cli_init.resolveSourceDir({
|
|
764
|
+
account,
|
|
765
|
+
gateway,
|
|
766
|
+
source: input.source
|
|
767
|
+
});
|
|
768
|
+
try {
|
|
769
|
+
const patterns = await require_cli_init.readTemplatekeep(sourceDir);
|
|
770
|
+
if (patterns.length === 0) return {
|
|
771
|
+
status: "error",
|
|
772
|
+
destination,
|
|
773
|
+
parentAccount: account,
|
|
774
|
+
parentGateway: gateway,
|
|
775
|
+
name,
|
|
776
|
+
domain,
|
|
777
|
+
extends: `bos://${account}/${gateway}`,
|
|
778
|
+
filesCopied: 0,
|
|
779
|
+
error: "No .templatekeep found in template source"
|
|
780
|
+
};
|
|
781
|
+
const filesCopied = await require_cli_init.copyFilteredFiles(sourceDir, destination, patterns, { withHost });
|
|
782
|
+
await require_cli_init.personalizeConfig(destination, {
|
|
783
|
+
parentAccount: account,
|
|
784
|
+
parentGateway: gateway,
|
|
785
|
+
name: name || account,
|
|
786
|
+
domain: domain || gateway
|
|
787
|
+
});
|
|
788
|
+
if (!input.noInstall) await require_cli_init.runBunInstall(destination);
|
|
789
|
+
return {
|
|
790
|
+
status: "initialized",
|
|
791
|
+
destination: (0, node_path.resolve)(destination),
|
|
792
|
+
parentAccount: account,
|
|
793
|
+
parentGateway: gateway,
|
|
794
|
+
name,
|
|
795
|
+
domain,
|
|
796
|
+
extends: `bos://${account}/${gateway}`,
|
|
797
|
+
filesCopied
|
|
798
|
+
};
|
|
799
|
+
} finally {
|
|
800
|
+
await cleanup();
|
|
801
|
+
}
|
|
802
|
+
} catch (error) {
|
|
803
|
+
return {
|
|
804
|
+
status: "error",
|
|
805
|
+
destination: input.destination ?? input.gateway ?? "",
|
|
806
|
+
parentAccount: input.account ?? "",
|
|
807
|
+
parentGateway: input.gateway ?? "",
|
|
808
|
+
name: input.name,
|
|
809
|
+
domain: input.domain,
|
|
810
|
+
extends: input.account && input.gateway ? `bos://${input.account}/${input.gateway}` : "",
|
|
811
|
+
filesCopied: 0,
|
|
812
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
})
|
|
816
|
+
})
|
|
817
|
+
});
|
|
818
|
+
function extractTransactionHash(error) {
|
|
819
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
820
|
+
return (message.match(/Transaction ID:\s*([A-Za-z0-9]+)/i) || message.match(/([A-HJ-NP-Za-km-z1-9]{43,44})/))?.[1];
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
//#endregion
|
|
824
|
+
module.exports = plugin_default;
|
|
825
|
+
//# sourceMappingURL=plugin.cjs.map
|