everything-dev 1.12.4 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.cjs +17 -5
- package/dist/app.cjs.map +1 -1
- package/dist/app.mjs +17 -5
- package/dist/app.mjs.map +1 -1
- package/dist/cli/init.cjs +151 -74
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +1 -1
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +1 -1
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +152 -75
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/prompts.cjs +3 -3
- package/dist/cli/prompts.cjs.map +1 -1
- package/dist/cli/prompts.mjs +3 -3
- package/dist/cli/prompts.mjs.map +1 -1
- package/dist/cli/status.cjs +22 -0
- package/dist/cli/status.cjs.map +1 -1
- package/dist/cli/status.mjs +22 -0
- package/dist/cli/status.mjs.map +1 -1
- package/dist/cli/sync.cjs +15 -56
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +15 -56
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli/upgrade.cjs +59 -5
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +59 -5
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/config.cjs +206 -69
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +13 -6
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +13 -6
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +201 -71
- package/dist/config.mjs.map +1 -1
- package/dist/contract.d.cts +106 -10
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +106 -10
- package/dist/contract.d.mts.map +1 -1
- package/dist/host.cjs +34 -1
- package/dist/host.cjs.map +1 -1
- package/dist/host.d.cts.map +1 -1
- package/dist/host.d.mts.map +1 -1
- package/dist/host.mjs +34 -1
- package/dist/host.mjs.map +1 -1
- package/dist/index.cjs +16 -0
- package/dist/index.d.cts +5 -3
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +5 -3
- package/dist/internal/manifest-normalizer.cjs +14 -1
- package/dist/internal/manifest-normalizer.cjs.map +1 -1
- package/dist/internal/manifest-normalizer.mjs +14 -1
- package/dist/internal/manifest-normalizer.mjs.map +1 -1
- package/dist/merge.cjs +113 -0
- package/dist/merge.cjs.map +1 -0
- package/dist/merge.d.cts +7 -0
- package/dist/merge.d.cts.map +1 -0
- package/dist/merge.d.mts +7 -0
- package/dist/merge.d.mts.map +1 -0
- package/dist/merge.mjs +107 -0
- package/dist/merge.mjs.map +1 -0
- package/dist/orchestrator.d.cts +1 -1
- package/dist/orchestrator.d.mts +1 -1
- package/dist/plugin.cjs +117 -105
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +115 -9
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +115 -9
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +117 -105
- package/dist/plugin.mjs.map +1 -1
- package/dist/service-descriptor.cjs +21 -0
- package/dist/service-descriptor.cjs.map +1 -1
- package/dist/service-descriptor.d.cts +23 -1
- package/dist/service-descriptor.d.cts.map +1 -1
- package/dist/service-descriptor.d.mts +23 -1
- package/dist/service-descriptor.d.mts.map +1 -1
- package/dist/service-descriptor.mjs +21 -0
- package/dist/service-descriptor.mjs.map +1 -1
- package/dist/shared.cjs +24 -2
- package/dist/shared.cjs.map +1 -1
- package/dist/shared.d.cts +3 -0
- package/dist/shared.d.cts.map +1 -1
- package/dist/shared.d.mts +3 -0
- package/dist/shared.d.mts.map +1 -1
- package/dist/shared.mjs +25 -3
- package/dist/shared.mjs.map +1 -1
- package/dist/sidebar.cjs +124 -0
- package/dist/sidebar.cjs.map +1 -0
- package/dist/sidebar.d.cts +8 -0
- package/dist/sidebar.d.cts.map +1 -0
- package/dist/sidebar.d.mts +8 -0
- package/dist/sidebar.d.mts.map +1 -0
- package/dist/sidebar.mjs +122 -0
- package/dist/sidebar.mjs.map +1 -0
- package/dist/types.cjs +104 -10
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +256 -29
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +256 -29
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +100 -11
- package/dist/types.mjs.map +1 -1
- package/dist/utils/path-match.cjs +18 -0
- package/dist/utils/path-match.cjs.map +1 -0
- package/dist/utils/path-match.mjs +17 -0
- package/dist/utils/path-match.mjs.map +1 -0
- package/dist/utils/save-config.cjs +19 -0
- package/dist/utils/save-config.cjs.map +1 -0
- package/dist/utils/save-config.mjs +18 -0
- package/dist/utils/save-config.mjs.map +1 -0
- package/package.json +6 -6
- package/skills/dev-workflow/SKILL.md +8 -0
- package/skills/extends-config/SKILL.md +132 -0
- package/skills/init-upgrade/SKILL.md +128 -0
- package/skills/publish-sync/SKILL.md +30 -0
- package/src/app.ts +15 -5
- package/src/cli/init.ts +207 -108
- package/src/cli/prompts.ts +2 -2
- package/src/cli/status.ts +20 -0
- package/src/cli/sync.ts +27 -96
- package/src/cli/upgrade.ts +65 -3
- package/src/cli.ts +1 -1
- package/src/config.ts +306 -119
- package/src/host.ts +45 -0
- package/src/index.ts +1 -0
- package/src/internal/manifest-normalizer.ts +16 -4
- package/src/merge.ts +198 -0
- package/src/plugin.ts +340 -318
- package/src/service-descriptor.ts +23 -0
- package/src/shared.ts +48 -5
- package/src/sidebar.ts +162 -0
- package/src/types.ts +134 -28
- package/src/utils/path-match.ts +16 -0
- package/src/utils/save-config.ts +20 -0
- package/cli.js +0 -10
package/dist/config.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_fastkv = require('./fastkv.cjs');
|
|
4
|
+
const require_merge = require('./merge.cjs');
|
|
4
5
|
const require_network = require('./network.cjs');
|
|
5
6
|
const require_types = require('./types.cjs');
|
|
6
7
|
let node_fs = require("node:fs");
|
|
@@ -9,6 +10,7 @@ let node_path = require("node:path");
|
|
|
9
10
|
//#region src/config.ts
|
|
10
11
|
const LOCAL_PREFIX = "local:";
|
|
11
12
|
const DEFAULT_HOST_PORT = 3e3;
|
|
13
|
+
const RESOLVED_CONFIG_FILENAME = "bos.resolved-config.json";
|
|
12
14
|
let cachedConfig = null;
|
|
13
15
|
let projectRoot = null;
|
|
14
16
|
function clearConfigCache() {
|
|
@@ -38,16 +40,17 @@ async function loadConfig(options) {
|
|
|
38
40
|
return null;
|
|
39
41
|
}
|
|
40
42
|
const baseDir = (0, node_path.dirname)(configPath);
|
|
43
|
+
const env = options?.env ?? "development";
|
|
44
|
+
const runtimeEnv = env === "staging" ? "production" : env;
|
|
41
45
|
try {
|
|
42
46
|
const extendedChain = [];
|
|
43
|
-
const parsed = await resolveConfigWithExtends(configPath, baseDir, /* @__PURE__ */ new Set(), extendedChain);
|
|
47
|
+
const parsed = await resolveConfigWithExtends(configPath, baseDir, /* @__PURE__ */ new Set(), extendedChain, env);
|
|
44
48
|
const config = require_types.BosConfigSchema.parse(parsed);
|
|
45
49
|
cachedConfig = config;
|
|
46
50
|
projectRoot = baseDir;
|
|
47
|
-
const pluginRuntime = await resolveRuntimePlugins(config.plugins ?? {}, baseDir, options?.env ?? "development");
|
|
48
51
|
return {
|
|
49
52
|
config,
|
|
50
|
-
runtime: buildRuntimeConfig(config, baseDir,
|
|
53
|
+
runtime: buildRuntimeConfig(config, baseDir, runtimeEnv, { plugins: await resolveRuntimePlugins(config.plugins ?? {}, baseDir, runtimeEnv) }),
|
|
51
54
|
source: {
|
|
52
55
|
path: configPath,
|
|
53
56
|
extended: extendedChain.length > 0 ? extendedChain : void 0,
|
|
@@ -67,6 +70,58 @@ async function buildRuntimePluginsForConfig(config, baseDir, env) {
|
|
|
67
70
|
const plugins = await resolveRuntimePlugins(config.plugins ?? {}, baseDir, env);
|
|
68
71
|
return Object.keys(plugins).length > 0 ? plugins : void 0;
|
|
69
72
|
}
|
|
73
|
+
function getResolvedConfigPath(configDir) {
|
|
74
|
+
return (0, node_path.join)(configDir, ".bos", RESOLVED_CONFIG_FILENAME);
|
|
75
|
+
}
|
|
76
|
+
function loadResolvedConfig(configDir) {
|
|
77
|
+
const resolvedPath = getResolvedConfigPath(configDir);
|
|
78
|
+
if (!(0, node_fs.existsSync)(resolvedPath)) return null;
|
|
79
|
+
try {
|
|
80
|
+
const raw = JSON.parse((0, node_fs.readFileSync)(resolvedPath, "utf-8"));
|
|
81
|
+
if (!require_merge.isPlainObject(raw)) return null;
|
|
82
|
+
const { _resolved, ...configData } = raw;
|
|
83
|
+
return require_types.BosConfigSchema.parse(configData);
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function writeResolvedConfig(configDir, config, env, extendsChain, source) {
|
|
89
|
+
const resolvedPath = getResolvedConfigPath(configDir);
|
|
90
|
+
const resolvedDir = (0, node_path.dirname)(resolvedPath);
|
|
91
|
+
if (!(0, node_fs.existsSync)(resolvedDir)) (0, node_fs.mkdirSync)(resolvedDir, { recursive: true });
|
|
92
|
+
const ordered = require_merge.rebuildOrderedConfig(config);
|
|
93
|
+
const output = {
|
|
94
|
+
_resolved: {
|
|
95
|
+
env,
|
|
96
|
+
resolvedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
97
|
+
extendsChain: extendsChain ?? [],
|
|
98
|
+
...source ? { source } : {}
|
|
99
|
+
},
|
|
100
|
+
...ordered
|
|
101
|
+
};
|
|
102
|
+
const content = `${JSON.stringify(output, null, 2)}\n`;
|
|
103
|
+
try {
|
|
104
|
+
if ((0, node_fs.readFileSync)(resolvedPath, "utf-8") === content) return;
|
|
105
|
+
} catch {}
|
|
106
|
+
(0, node_fs.writeFileSync)(resolvedPath, content);
|
|
107
|
+
}
|
|
108
|
+
function resolveBosConfigPath(configDir) {
|
|
109
|
+
const resolvedPath = getResolvedConfigPath(configDir);
|
|
110
|
+
if ((0, node_fs.existsSync)(resolvedPath)) return resolvedPath;
|
|
111
|
+
return (0, node_path.join)(configDir, "bos.config.json");
|
|
112
|
+
}
|
|
113
|
+
function readBosConfigForBuild(configDir) {
|
|
114
|
+
const resolvedPath = getResolvedConfigPath(configDir);
|
|
115
|
+
if ((0, node_fs.existsSync)(resolvedPath)) try {
|
|
116
|
+
const raw = JSON.parse((0, node_fs.readFileSync)(resolvedPath, "utf-8"));
|
|
117
|
+
if (require_merge.isPlainObject(raw)) {
|
|
118
|
+
const { _resolved, ...configData } = raw;
|
|
119
|
+
return configData;
|
|
120
|
+
}
|
|
121
|
+
} catch {}
|
|
122
|
+
const bosConfigPath = (0, node_path.join)(configDir, "bos.config.json");
|
|
123
|
+
return JSON.parse((0, node_fs.readFileSync)(bosConfigPath, "utf-8"));
|
|
124
|
+
}
|
|
70
125
|
function resolveDevelopmentTarget(development, production, baseDir, forceSource) {
|
|
71
126
|
if (forceSource === "remote") return resolveRuntimeTarget(production, baseDir, "remote");
|
|
72
127
|
const devTarget = resolveRuntimeTarget(development, baseDir);
|
|
@@ -82,7 +137,7 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
82
137
|
const authRuntime = authConfig ? env === "development" ? resolveDevelopmentTarget(authConfig.development, authConfig.production, baseDir, options?.authSource) : resolveRuntimeTarget(authConfig.production, baseDir, "remote") : void 0;
|
|
83
138
|
const hostConfig = config.app.host;
|
|
84
139
|
const hostRuntime = env === "development" ? resolveDevelopmentTarget(hostConfig.development, hostConfig.production, baseDir, options?.hostSource) : resolveRuntimeTarget(hostConfig.production, baseDir, "remote");
|
|
85
|
-
const hostListeningUrl = resolveDevelopmentHostUrl(hostConfig.development)
|
|
140
|
+
const hostListeningUrl = env === "development" ? resolveDevelopmentHostUrl(hostConfig.development) : `http://localhost:${hostRuntime.port ?? DEFAULT_HOST_PORT}`;
|
|
86
141
|
const hostIsRemote = hostRuntime.source === "remote";
|
|
87
142
|
const uiIsRemote = uiRuntime.source === "remote";
|
|
88
143
|
const apiIsRemote = apiRuntime.source === "remote";
|
|
@@ -127,18 +182,26 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
127
182
|
secrets: apiConfig.secrets,
|
|
128
183
|
integrity: apiIsRemote ? apiConfig.integrity : void 0
|
|
129
184
|
},
|
|
130
|
-
auth:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
185
|
+
auth: (() => {
|
|
186
|
+
if (!authConfig || !authRuntime) return void 0;
|
|
187
|
+
return {
|
|
188
|
+
name: resolvePluginRuntimeName(void 0, authRuntime.localPath, authConfig.name),
|
|
189
|
+
url: authRuntime.url,
|
|
190
|
+
entry: authRuntime.url ? `${authRuntime.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
191
|
+
localPath: authRuntime.localPath,
|
|
192
|
+
port: authRuntime.port,
|
|
193
|
+
source: authRuntime.source,
|
|
194
|
+
proxy: authConfig.proxy,
|
|
195
|
+
variables: authConfig.variables,
|
|
196
|
+
secrets: authConfig.secrets,
|
|
197
|
+
integrity: authRuntime.source === "remote" ? authConfig.integrity : void 0,
|
|
198
|
+
sidebar: authConfig.sidebar?.map((item) => ({
|
|
199
|
+
...item,
|
|
200
|
+
to: item.to ?? "/auth",
|
|
201
|
+
roleRequired: item.roleRequired ?? "member"
|
|
202
|
+
}))
|
|
203
|
+
};
|
|
204
|
+
})(),
|
|
142
205
|
plugins: options?.plugins && Object.keys(options.plugins).length > 0 ? options.plugins : void 0
|
|
143
206
|
};
|
|
144
207
|
}
|
|
@@ -147,42 +210,89 @@ async function loadConfigFile(configPath, baseDir) {
|
|
|
147
210
|
const resolvedPath = (0, node_path.isAbsolute)(configPath) ? configPath : (0, node_path.resolve)(baseDir, configPath);
|
|
148
211
|
return JSON.parse((0, node_fs.readFileSync)(resolvedPath, "utf-8"));
|
|
149
212
|
}
|
|
150
|
-
async function resolveConfigWithExtends(configPath, baseDir, visited, chain) {
|
|
213
|
+
async function resolveConfigWithExtends(configPath, baseDir, visited, chain, env = "development") {
|
|
151
214
|
if (visited.has(configPath)) throw new Error(`Circular extends detected: ${[...visited, configPath].join(" -> ")}`);
|
|
152
215
|
const config = await loadConfigFile(configPath, baseDir);
|
|
153
|
-
|
|
216
|
+
chain.push(configPath);
|
|
154
217
|
if (!config.extends) return config;
|
|
218
|
+
const extendsRef = require_merge.resolveExtendsRef(config.extends, env);
|
|
219
|
+
if (!extendsRef) return config;
|
|
155
220
|
const nextVisited = new Set(visited);
|
|
156
221
|
nextVisited.add(configPath);
|
|
157
|
-
|
|
158
|
-
return mergeConfigs(await resolveConfigWithExtends(parentPath, parentPath.startsWith("bos://") ? baseDir : (0, node_path.isAbsolute)(parentPath) ? (0, node_path.dirname)(parentPath) : baseDir, nextVisited, chain), config);
|
|
222
|
+
return require_merge.mergeBosConfigWithExtends(await resolveConfigWithExtends(extendsRef, extendsRef.startsWith("bos://") ? baseDir : (0, node_path.isAbsolute)(extendsRef) ? (0, node_path.dirname)(extendsRef) : baseDir, nextVisited, chain, env), config);
|
|
159
223
|
}
|
|
160
|
-
function
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
return
|
|
224
|
+
function normalizePluginEntry(raw) {
|
|
225
|
+
if (raw === null || raw === false) return raw;
|
|
226
|
+
if (typeof raw === "string") return { extends: raw };
|
|
227
|
+
return raw;
|
|
164
228
|
}
|
|
165
|
-
async function resolveRuntimePlugins(plugins, baseDir, env
|
|
229
|
+
async function resolveRuntimePlugins(plugins, baseDir, env) {
|
|
166
230
|
const out = {};
|
|
167
|
-
for (const [pluginId,
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const nested = await resolveRuntimePlugins(resolvedConfig.plugins, pluginBaseDir, env, [...prefix, pluginId]);
|
|
178
|
-
Object.assign(out, nested);
|
|
231
|
+
for (const [pluginId, rawInput] of Object.entries(plugins)) {
|
|
232
|
+
const normalized = normalizePluginEntry(rawInput);
|
|
233
|
+
if (normalized === null || normalized === false) continue;
|
|
234
|
+
let resolvedConfig = {};
|
|
235
|
+
let pluginBaseDir = baseDir;
|
|
236
|
+
if (normalized.extends) try {
|
|
237
|
+
const extendsUrl = require_merge.resolveExtendsRef(normalized.extends, env);
|
|
238
|
+
if (extendsUrl) resolvedConfig = await require_fastkv.fetchBosConfigFromFastKv(extendsUrl);
|
|
239
|
+
} catch {
|
|
240
|
+
resolvedConfig = {};
|
|
179
241
|
}
|
|
242
|
+
if (normalized.development?.startsWith(LOCAL_PREFIX)) {
|
|
243
|
+
const localPath = (0, node_path.resolve)(baseDir, normalized.development.slice(6).trim());
|
|
244
|
+
if ((0, node_fs.existsSync)(localPath)) {
|
|
245
|
+
const localConfigPath = (0, node_path.join)(localPath, "bos.config.json");
|
|
246
|
+
if ((0, node_fs.existsSync)(localConfigPath)) try {
|
|
247
|
+
const localRaw = JSON.parse((0, node_fs.readFileSync)(localConfigPath, "utf-8"));
|
|
248
|
+
resolvedConfig = require_merge.mergeBosConfigWithExtends(resolvedConfig, localRaw);
|
|
249
|
+
pluginBaseDir = localPath;
|
|
250
|
+
} catch {}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (normalized.app && require_merge.isPlainObject(normalized.app)) {
|
|
254
|
+
const mergedApp = {
|
|
255
|
+
...resolvedConfig.app ?? {},
|
|
256
|
+
...normalized.app
|
|
257
|
+
};
|
|
258
|
+
resolvedConfig = {
|
|
259
|
+
...resolvedConfig,
|
|
260
|
+
app: mergedApp
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
if (normalized.shared && require_merge.isPlainObject(normalized.shared)) {
|
|
264
|
+
const mergedShared = {
|
|
265
|
+
...resolvedConfig.shared ?? {},
|
|
266
|
+
...normalized.shared
|
|
267
|
+
};
|
|
268
|
+
resolvedConfig = {
|
|
269
|
+
...resolvedConfig,
|
|
270
|
+
shared: mergedShared
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
if (normalized.sidebar) resolvedConfig = {
|
|
274
|
+
...resolvedConfig,
|
|
275
|
+
sidebar: normalized.sidebar
|
|
276
|
+
};
|
|
277
|
+
if (normalized.routes) resolvedConfig = {
|
|
278
|
+
...resolvedConfig,
|
|
279
|
+
routes: normalized.routes
|
|
280
|
+
};
|
|
281
|
+
const pluginRuntime = await buildRuntimePluginConfig(pluginId, resolvedConfig, pluginBaseDir, env, normalized);
|
|
282
|
+
if (normalized.name && typeof normalized.name === "string" && !pluginRuntime.name.includes("/")) pluginRuntime.name = normalized.name;
|
|
283
|
+
const integrity = normalized.integrity;
|
|
284
|
+
if (env === "production" && integrity) pluginRuntime.integrity = integrity;
|
|
285
|
+
if (pluginRuntime.source === "remote" && pluginRuntime.url && !pluginRuntime.localPath && typeof resolvedConfig.app?.api?.name !== "string" && !normalized.name) pluginRuntime.name = await resolveRemotePluginRuntimeName(pluginRuntime.url, pluginRuntime.name);
|
|
286
|
+
out[pluginId] = pluginRuntime;
|
|
180
287
|
}
|
|
181
288
|
return out;
|
|
182
289
|
}
|
|
183
290
|
async function resolveRemotePluginRuntimeName(baseUrl, fallback) {
|
|
184
291
|
try {
|
|
185
|
-
const
|
|
292
|
+
const controller = new AbortController();
|
|
293
|
+
const timeout = setTimeout(() => controller.abort(), 5e3);
|
|
294
|
+
const response = await fetch(`${baseUrl.replace(/\/$/, "")}/plugin.manifest.json`, { signal: controller.signal });
|
|
295
|
+
clearTimeout(timeout);
|
|
186
296
|
if (!response.ok) return fallback;
|
|
187
297
|
const manifest = await response.json();
|
|
188
298
|
return typeof manifest.plugin?.name === "string" && manifest.plugin.name.length > 0 ? manifest.plugin.name : fallback;
|
|
@@ -190,7 +300,23 @@ async function resolveRemotePluginRuntimeName(baseUrl, fallback) {
|
|
|
190
300
|
return fallback;
|
|
191
301
|
}
|
|
192
302
|
}
|
|
193
|
-
function
|
|
303
|
+
async function resolveBosPluginUrl(bosUrl) {
|
|
304
|
+
const parsed = require_fastkv.parsePluginBosUrl(bosUrl);
|
|
305
|
+
if (!parsed) return null;
|
|
306
|
+
try {
|
|
307
|
+
const entry = await require_fastkv.fetchPluginFromRegistry(parsed.accountId, parsed.pluginName);
|
|
308
|
+
if (!entry) return null;
|
|
309
|
+
const cdnUrl = entry.metadata.cdnUrl;
|
|
310
|
+
if (!cdnUrl) return null;
|
|
311
|
+
return {
|
|
312
|
+
url: cdnUrl,
|
|
313
|
+
integrity: entry.metadata.integrity ?? void 0
|
|
314
|
+
};
|
|
315
|
+
} catch {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
async function buildRuntimePluginConfig(pluginId, config, baseDir, env, source) {
|
|
194
320
|
const apiConfig = config.app?.api ?? {};
|
|
195
321
|
const apiDevelopment = typeof apiConfig.development === "string" ? apiConfig.development : void 0;
|
|
196
322
|
const apiProduction = typeof apiConfig.production === "string" ? apiConfig.production : void 0;
|
|
@@ -198,10 +324,28 @@ function buildRuntimePluginConfig(pluginId, config, baseDir, env, source) {
|
|
|
198
324
|
const sourceProduction = typeof source.production === "string" ? source.production : void 0;
|
|
199
325
|
const proxy = typeof apiConfig.proxy === "string" ? apiConfig.proxy : void 0;
|
|
200
326
|
const development = apiDevelopment ?? sourceDevelopment;
|
|
201
|
-
|
|
327
|
+
let production = apiProduction ?? sourceProduction;
|
|
328
|
+
if (production?.startsWith("bos://")) {
|
|
329
|
+
const resolved = await resolveBosPluginUrl(production);
|
|
330
|
+
if (resolved) {
|
|
331
|
+
production = resolved.url;
|
|
332
|
+
if (resolved.integrity && env === "production") source.integrity = resolved.integrity;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
202
335
|
const runtimeTarget = env === "development" ? resolveDevelopmentTarget(development, production, baseDir) : resolveRuntimeTarget(production, baseDir, "remote");
|
|
336
|
+
const apiName = resolvePluginRuntimeName(typeof apiConfig.name === "string" ? apiConfig.name : void 0, runtimeTarget.localPath, pluginId);
|
|
337
|
+
const uiConfig = config.app?.ui;
|
|
338
|
+
const uiDevelopment = typeof uiConfig?.development === "string" ? uiConfig.development : void 0;
|
|
339
|
+
const uiProduction = typeof uiConfig?.production === "string" ? uiConfig.production : void 0;
|
|
340
|
+
const uiRuntime = uiConfig && (uiDevelopment || uiProduction) ? env === "development" ? resolveDevelopmentTarget(uiDevelopment, uiProduction, baseDir) : resolveRuntimeTarget(uiProduction, baseDir, "remote") : void 0;
|
|
341
|
+
const sidebar = (config.sidebar ?? source.sidebar)?.map((item) => ({
|
|
342
|
+
...item,
|
|
343
|
+
to: item.to ?? `/${pluginId}`,
|
|
344
|
+
roleRequired: item.roleRequired ?? "member"
|
|
345
|
+
}));
|
|
346
|
+
const routes = config.routes ?? source.routes;
|
|
203
347
|
return {
|
|
204
|
-
name:
|
|
348
|
+
name: apiName,
|
|
205
349
|
url: runtimeTarget.url,
|
|
206
350
|
entry: runtimeTarget.url ? `${runtimeTarget.url.replace(/\/$/, "")}/mf-manifest.json` : "/mf-manifest.json",
|
|
207
351
|
source: runtimeTarget.source,
|
|
@@ -209,7 +353,18 @@ function buildRuntimePluginConfig(pluginId, config, baseDir, env, source) {
|
|
|
209
353
|
port: runtimeTarget.port,
|
|
210
354
|
proxy: proxy ?? (typeof source.proxy === "string" ? source.proxy : void 0),
|
|
211
355
|
variables: normalizeStringRecord(apiConfig.variables ?? source.variables),
|
|
212
|
-
secrets: normalizeStringArray(apiConfig.secrets ?? source.secrets)
|
|
356
|
+
secrets: normalizeStringArray(apiConfig.secrets ?? source.secrets),
|
|
357
|
+
ui: uiRuntime ? {
|
|
358
|
+
name: typeof uiConfig?.name === "string" ? uiConfig.name : `${apiName}-ui`,
|
|
359
|
+
url: uiRuntime.url,
|
|
360
|
+
entry: uiRuntime.url ? `${uiRuntime.url.replace(/\/$/, "")}/mf-manifest.json` : "/mf-manifest.json",
|
|
361
|
+
source: uiRuntime.source,
|
|
362
|
+
localPath: uiRuntime.localPath,
|
|
363
|
+
port: uiRuntime.port,
|
|
364
|
+
integrity: uiRuntime.source === "remote" && typeof uiConfig?.integrity === "string" ? uiConfig.integrity : void 0
|
|
365
|
+
} : void 0,
|
|
366
|
+
sidebar,
|
|
367
|
+
routes
|
|
213
368
|
};
|
|
214
369
|
}
|
|
215
370
|
function resolvePluginRuntimeName(explicitName, localPath, fallback) {
|
|
@@ -222,33 +377,8 @@ function resolvePluginRuntimeName(explicitName, localPath, fallback) {
|
|
|
222
377
|
} catch {}
|
|
223
378
|
return fallback;
|
|
224
379
|
}
|
|
225
|
-
async function resolveBosConfigInput(input, baseDir, visited, chain) {
|
|
226
|
-
if (input.extends) {
|
|
227
|
-
const parentBaseDir = input.extends.startsWith("bos://") ? baseDir : (0, node_path.isAbsolute)(input.extends) ? (0, node_path.dirname)(input.extends) : baseDir;
|
|
228
|
-
return {
|
|
229
|
-
config: mergeConfigs(await resolveConfigWithExtends(input.extends, parentBaseDir, visited, chain), input),
|
|
230
|
-
baseDir: parentBaseDir
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
return {
|
|
234
|
-
config: input,
|
|
235
|
-
baseDir
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
function mergeValues(parent, child) {
|
|
239
|
-
if (Array.isArray(parent) && Array.isArray(child)) return child;
|
|
240
|
-
if (isPlainObject(parent) && isPlainObject(child)) {
|
|
241
|
-
const merged = { ...parent };
|
|
242
|
-
for (const [key, value] of Object.entries(child)) merged[key] = key in merged ? mergeValues(merged[key], value) : value;
|
|
243
|
-
return merged;
|
|
244
|
-
}
|
|
245
|
-
return child ?? parent;
|
|
246
|
-
}
|
|
247
|
-
function isPlainObject(value) {
|
|
248
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
249
|
-
}
|
|
250
380
|
function normalizeStringRecord(value) {
|
|
251
|
-
if (!isPlainObject(value)) return void 0;
|
|
381
|
+
if (!require_merge.isPlainObject(value)) return void 0;
|
|
252
382
|
const out = {};
|
|
253
383
|
for (const [key, raw] of Object.entries(value)) if (typeof raw === "string") out[key] = raw;
|
|
254
384
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
@@ -264,7 +394,7 @@ function resolveRuntimeTarget(value, baseDir, defaultSource = "remote") {
|
|
|
264
394
|
url: ""
|
|
265
395
|
};
|
|
266
396
|
if (value.startsWith(LOCAL_PREFIX)) {
|
|
267
|
-
const localTarget = value
|
|
397
|
+
const localTarget = value?.slice(6).trim();
|
|
268
398
|
if (!localTarget) throw new Error(`Invalid local development target: ${value}`);
|
|
269
399
|
const localPath = (0, node_path.resolve)(baseDir, localTarget);
|
|
270
400
|
if (!(0, node_fs.existsSync)(localPath)) return {
|
|
@@ -308,6 +438,7 @@ function parsePort(url) {
|
|
|
308
438
|
}
|
|
309
439
|
|
|
310
440
|
//#endregion
|
|
441
|
+
exports.BOS_CONFIG_ORDER = require_merge.BOS_CONFIG_ORDER;
|
|
311
442
|
exports.BosConfigSchema = require_types.BosConfigSchema;
|
|
312
443
|
exports.buildRuntimeConfig = buildRuntimeConfig;
|
|
313
444
|
exports.buildRuntimePluginsForConfig = buildRuntimePluginsForConfig;
|
|
@@ -316,11 +447,17 @@ exports.findConfigPath = findConfigPath;
|
|
|
316
447
|
exports.getConfig = getConfig;
|
|
317
448
|
exports.getHostDevelopmentPort = getHostDevelopmentPort;
|
|
318
449
|
exports.getProjectRoot = getProjectRoot;
|
|
450
|
+
exports.getResolvedConfigPath = getResolvedConfigPath;
|
|
319
451
|
exports.isLocalDevelopmentTarget = isLocalDevelopmentTarget;
|
|
320
452
|
exports.loadBosConfig = loadBosConfig;
|
|
321
453
|
exports.loadConfig = loadConfig;
|
|
454
|
+
exports.loadResolvedConfig = loadResolvedConfig;
|
|
322
455
|
exports.parsePort = parsePort;
|
|
456
|
+
exports.readBosConfigForBuild = readBosConfigForBuild;
|
|
457
|
+
exports.rebuildOrderedConfig = require_merge.rebuildOrderedConfig;
|
|
458
|
+
exports.resolveBosConfigPath = resolveBosConfigPath;
|
|
323
459
|
exports.resolveDevelopmentHostUrl = resolveDevelopmentHostUrl;
|
|
324
460
|
exports.resolveLocalDevelopmentPath = resolveLocalDevelopmentPath;
|
|
325
461
|
exports.resolvePluginRuntimeName = resolvePluginRuntimeName;
|
|
462
|
+
exports.writeResolvedConfig = writeResolvedConfig;
|
|
326
463
|
//# sourceMappingURL=config.cjs.map
|
package/dist/config.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","names":["BosConfigSchema","getNetworkIdForAccount","fetchBosConfigFromFastKv"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { fetchBosConfigFromFastKv } from \"./fastkv\";\nimport { getNetworkIdForAccount } from \"./network\";\nimport type { BosConfig, BosConfigInput, RuntimeConfig, RuntimePluginConfig } from \"./types\";\nimport { BosConfigSchema } from \"./types\";\n\nconst LOCAL_PREFIX = \"local:\";\nconst DEFAULT_HOST_PORT = 3000;\n\ninterface RuntimeTarget {\n source: \"local\" | \"remote\";\n url: string;\n localPath?: string;\n port?: number;\n}\n\nlet cachedConfig: BosConfig | null = null;\nlet projectRoot: string | null = null;\n\nexport function clearConfigCache(): void {\n cachedConfig = null;\n projectRoot = null;\n}\n\nexport function findConfigPath(cwd?: string): string | null {\n let dir = cwd ?? process.cwd();\n while (dir !== \"/\") {\n const configPath = join(dir, \"bos.config.json\");\n if (existsSync(configPath)) {\n return configPath;\n }\n dir = dirname(dir);\n }\n return null;\n}\n\nexport function getConfig(): BosConfig | null {\n return cachedConfig;\n}\n\nexport function getProjectRoot(): string {\n if (!projectRoot) {\n throw new Error(\"Config not loaded. Call loadConfig() first.\");\n }\n return projectRoot;\n}\n\nexport interface ConfigResult {\n config: BosConfig;\n runtime: RuntimeConfig;\n source: {\n path: string;\n extended?: string[];\n remote?: boolean;\n };\n}\n\nexport async function loadConfig(options?: {\n cwd?: string;\n path?: string;\n env?: \"development\" | \"production\";\n}): Promise<ConfigResult | null> {\n const configPath = options?.path ?? findConfigPath(options?.cwd);\n if (!configPath) {\n projectRoot = options?.cwd ?? process.cwd();\n return null;\n }\n\n const baseDir = dirname(configPath);\n\n try {\n const extendedChain: string[] = [];\n const parsed = await resolveConfigWithExtends(configPath, baseDir, new Set(), extendedChain);\n const config = BosConfigSchema.parse(parsed);\n\n cachedConfig = config;\n projectRoot = baseDir;\n\n const pluginRuntime = await resolveRuntimePlugins(\n config.plugins ?? {},\n baseDir,\n options?.env ?? \"development\",\n );\n const runtime = buildRuntimeConfig(config, baseDir, options?.env ?? \"development\", {\n plugins: pluginRuntime,\n });\n\n return {\n config,\n runtime,\n source: {\n path: configPath,\n extended: extendedChain.length > 0 ? extendedChain : undefined,\n remote: extendedChain.some((entry) => entry.startsWith(\"bos://\")),\n },\n };\n } catch (error) {\n throw new Error(`Failed to load config from ${configPath}: ${error}`);\n }\n}\n\nexport async function loadBosConfig(options?: {\n cwd?: string;\n path?: string;\n env?: \"development\" | \"production\";\n}): Promise<RuntimeConfig> {\n const result = await loadConfig(options);\n if (!result) {\n throw new Error(\"No bos.config.json found\");\n }\n\n return result.runtime;\n}\n\nexport async function buildRuntimePluginsForConfig(\n config: BosConfig,\n baseDir: string,\n env: \"development\" | \"production\",\n): Promise<Record<string, RuntimePluginConfig> | undefined> {\n const plugins = await resolveRuntimePlugins(config.plugins ?? {}, baseDir, env);\n return Object.keys(plugins).length > 0 ? plugins : undefined;\n}\n\nfunction resolveDevelopmentTarget(\n development: string | undefined,\n production: string | undefined,\n baseDir: string,\n forceSource?: \"local\" | \"remote\",\n): RuntimeTarget {\n if (forceSource === \"remote\") {\n return resolveRuntimeTarget(production, baseDir, \"remote\");\n }\n const devTarget = resolveRuntimeTarget(development, baseDir);\n if (devTarget.source === \"local\" && (!devTarget.localPath || !existsSync(devTarget.localPath))) {\n return resolveRuntimeTarget(production, baseDir, \"remote\");\n }\n return devTarget;\n}\n\nexport interface BuildRuntimeConfigOptions {\n plugins?: Record<string, RuntimePluginConfig>;\n hostSource?: \"local\" | \"remote\";\n uiSource?: \"local\" | \"remote\";\n apiSource?: \"local\" | \"remote\";\n authSource?: \"local\" | \"remote\";\n proxy?: string;\n}\n\nexport function buildRuntimeConfig(\n config: BosConfig,\n baseDir: string,\n env: \"development\" | \"production\",\n options?: BuildRuntimeConfigOptions,\n): RuntimeConfig {\n const uiConfig = config.app.ui;\n const apiConfig = config.app.api;\n const authConfig = config.app.auth;\n const uiRuntime =\n env === \"development\"\n ? resolveDevelopmentTarget(\n uiConfig.development,\n uiConfig.production,\n baseDir,\n options?.uiSource,\n )\n : resolveRuntimeTarget(uiConfig.production, baseDir, \"remote\");\n const apiRuntime =\n env === \"development\"\n ? resolveDevelopmentTarget(\n apiConfig.development,\n apiConfig.production,\n baseDir,\n options?.apiSource,\n )\n : resolveRuntimeTarget(apiConfig.production, baseDir, \"remote\");\n const authRuntime = authConfig\n ? env === \"development\"\n ? resolveDevelopmentTarget(\n authConfig.development,\n authConfig.production,\n baseDir,\n options?.authSource,\n )\n : resolveRuntimeTarget(authConfig.production, baseDir, \"remote\")\n : undefined;\n\n const hostConfig = config.app.host;\n const hostRuntime =\n env === \"development\"\n ? resolveDevelopmentTarget(\n hostConfig.development,\n hostConfig.production,\n baseDir,\n options?.hostSource,\n )\n : resolveRuntimeTarget(hostConfig.production, baseDir, \"remote\");\n\n const hostListeningUrl = resolveDevelopmentHostUrl(hostConfig.development);\n\n const hostIsRemote = hostRuntime.source === \"remote\";\n const uiIsRemote = uiRuntime.source === \"remote\";\n const apiIsRemote = apiRuntime.source === \"remote\";\n\n return {\n env,\n account: config.account,\n domain: config.domain,\n networkId: getNetworkIdForAccount(config.account),\n repository: config.repository,\n host: {\n name: \"host\",\n url: hostListeningUrl,\n entry: `${hostListeningUrl}/mf-manifest.json`,\n localPath: hostRuntime.localPath,\n port: hostRuntime.port ?? DEFAULT_HOST_PORT,\n secrets: hostConfig.secrets,\n integrity: hostIsRemote ? hostConfig.integrity : undefined,\n source: hostRuntime.source,\n remoteUrl: hostIsRemote ? hostRuntime.url : undefined,\n },\n shared: config.shared,\n ui: {\n name: uiConfig.name,\n url: uiRuntime.url,\n entry: uiRuntime.url ? `${uiRuntime.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: uiRuntime.localPath,\n port: uiRuntime.port,\n ssrUrl: uiIsRemote ? uiConfig.ssr : undefined,\n ssrIntegrity: uiIsRemote ? uiConfig.ssrIntegrity : undefined,\n integrity: uiIsRemote ? uiConfig.integrity : undefined,\n source: uiRuntime.source,\n },\n api: {\n name: apiConfig.name,\n url: apiRuntime.url,\n entry: apiRuntime.url ? `${apiRuntime.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: apiRuntime.localPath,\n port: apiRuntime.port,\n source: apiRuntime.source,\n proxy: options?.proxy ?? apiConfig.proxy,\n variables: apiConfig.variables,\n secrets: apiConfig.secrets,\n integrity: apiIsRemote ? apiConfig.integrity : undefined,\n },\n auth: authConfig\n ? {\n name: resolvePluginRuntimeName(undefined, authRuntime!.localPath, authConfig.name),\n url: authRuntime!.url,\n entry: authRuntime!.url ? `${authRuntime!.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: authRuntime!.localPath,\n port: authRuntime!.port,\n source: authRuntime!.source,\n proxy: authConfig.proxy,\n variables: authConfig.variables,\n secrets: authConfig.secrets,\n integrity: authRuntime!.source === \"remote\" ? authConfig.integrity : undefined,\n }\n : undefined,\n plugins:\n options?.plugins && Object.keys(options.plugins).length > 0 ? options.plugins : undefined,\n };\n}\n\nasync function loadConfigFile(configPath: string, baseDir: string): Promise<BosConfigInput> {\n if (configPath.startsWith(\"bos://\")) {\n return fetchBosConfigFromFastKv<BosConfigInput>(configPath);\n }\n\n const resolvedPath = isAbsolute(configPath) ? configPath : resolve(baseDir, configPath);\n return JSON.parse(readFileSync(resolvedPath, \"utf-8\")) as BosConfigInput;\n}\n\nasync function resolveConfigWithExtends(\n configPath: string,\n baseDir: string,\n visited: Set<string>,\n chain: string[],\n): Promise<BosConfigInput> {\n if (visited.has(configPath)) {\n throw new Error(`Circular extends detected: ${[...visited, configPath].join(\" -> \")}`);\n }\n\n const config = await loadConfigFile(configPath, baseDir);\n if (configPath.startsWith(\"bos://\")) {\n chain.push(configPath);\n }\n\n if (!config.extends) {\n return config;\n }\n\n const nextVisited = new Set(visited);\n nextVisited.add(configPath);\n const parentPath = config.extends;\n const parentBaseDir = parentPath.startsWith(\"bos://\")\n ? baseDir\n : isAbsolute(parentPath)\n ? dirname(parentPath)\n : baseDir;\n const parent = await resolveConfigWithExtends(parentPath, parentBaseDir, nextVisited, chain);\n\n return mergeConfigs(parent, config);\n}\n\nfunction mergeConfigs(parent: BosConfigInput, child: BosConfigInput): BosConfigInput {\n const result = mergeValues(parent, child) as BosConfigInput;\n if (child.plugins !== undefined) {\n result.plugins = child.plugins;\n }\n return result;\n}\n\nasync function resolveRuntimePlugins(\n plugins: Record<string, BosConfigInput>,\n baseDir: string,\n env: \"development\" | \"production\",\n prefix: string[] = [],\n): Promise<Record<string, RuntimePluginConfig>> {\n const out: Record<string, RuntimePluginConfig> = {};\n\n for (const [pluginId, pluginInput] of Object.entries(plugins)) {\n const runtimeKey = [...prefix, pluginId].join(\"/\");\n const { config: resolvedConfig, baseDir: pluginBaseDir } = await resolveBosConfigInput(\n pluginInput,\n baseDir,\n new Set(),\n [],\n );\n\n const pluginRuntime = buildRuntimePluginConfig(\n runtimeKey,\n resolvedConfig,\n pluginBaseDir,\n env,\n pluginInput,\n );\n if (\n pluginInput.name &&\n typeof pluginInput.name === \"string\" &&\n !pluginRuntime.name.includes(\"/\")\n ) {\n pluginRuntime.name = pluginInput.name;\n }\n\n const integrity = pluginInput.integrity;\n if (env === \"production\" && integrity) {\n pluginRuntime.integrity = integrity;\n }\n\n if (\n pluginRuntime.source === \"remote\" &&\n pluginRuntime.url &&\n !pluginRuntime.localPath &&\n typeof resolvedConfig.app?.api?.name !== \"string\" &&\n !pluginInput.name\n ) {\n pluginRuntime.name = await resolveRemotePluginRuntimeName(\n pluginRuntime.url,\n pluginRuntime.name,\n );\n }\n\n out[runtimeKey] = pluginRuntime;\n\n if (resolvedConfig.plugins && Object.keys(resolvedConfig.plugins).length > 0) {\n const nested = await resolveRuntimePlugins(resolvedConfig.plugins, pluginBaseDir, env, [\n ...prefix,\n pluginId,\n ]);\n Object.assign(out, nested);\n }\n }\n\n return out;\n}\n\nasync function resolveRemotePluginRuntimeName(baseUrl: string, fallback: string): Promise<string> {\n try {\n const response = await fetch(`${baseUrl.replace(/\\/$/, \"\")}/plugin.manifest.json`);\n if (!response.ok) {\n return fallback;\n }\n\n const manifest = (await response.json()) as {\n plugin?: { name?: unknown };\n };\n\n return typeof manifest.plugin?.name === \"string\" && manifest.plugin.name.length > 0\n ? manifest.plugin.name\n : fallback;\n } catch {\n return fallback;\n }\n}\n\nfunction buildRuntimePluginConfig(\n pluginId: string,\n config: BosConfigInput,\n baseDir: string,\n env: \"development\" | \"production\",\n source: BosConfigInput,\n): RuntimePluginConfig {\n const apiConfig = config.app?.api ?? {};\n const apiDevelopment =\n typeof apiConfig.development === \"string\" ? apiConfig.development : undefined;\n const apiProduction = typeof apiConfig.production === \"string\" ? apiConfig.production : undefined;\n const sourceDevelopment = typeof source.development === \"string\" ? source.development : undefined;\n const sourceProduction = typeof source.production === \"string\" ? source.production : undefined;\n const proxy = typeof apiConfig.proxy === \"string\" ? apiConfig.proxy : undefined;\n const development = apiDevelopment ?? sourceDevelopment;\n const production = apiProduction ?? sourceProduction;\n const runtimeTarget =\n env === \"development\"\n ? resolveDevelopmentTarget(development, production, baseDir)\n : resolveRuntimeTarget(production, baseDir, \"remote\");\n const apiName = resolvePluginRuntimeName(\n typeof apiConfig.name === \"string\" ? apiConfig.name : undefined,\n runtimeTarget.localPath,\n pluginId,\n );\n\n return {\n name: apiName,\n url: runtimeTarget.url,\n entry: runtimeTarget.url\n ? `${runtimeTarget.url.replace(/\\/$/, \"\")}/mf-manifest.json`\n : \"/mf-manifest.json\",\n source: runtimeTarget.source,\n localPath: runtimeTarget.localPath,\n port: runtimeTarget.port,\n proxy: proxy ?? (typeof source.proxy === \"string\" ? source.proxy : undefined),\n variables: normalizeStringRecord(apiConfig.variables ?? source.variables),\n secrets: normalizeStringArray(apiConfig.secrets ?? source.secrets),\n };\n}\n\nexport function resolvePluginRuntimeName(\n explicitName: string | undefined,\n localPath: string | undefined,\n fallback: string,\n): string {\n if (explicitName) {\n return explicitName;\n }\n\n if (!localPath) {\n return fallback;\n }\n\n try {\n const packageJsonPath = join(localPath, \"package.json\");\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as { name?: unknown };\n if (typeof packageJson.name === \"string\" && packageJson.name.length > 0) {\n return packageJson.name;\n }\n } catch {}\n\n return fallback;\n}\n\nasync function resolveBosConfigInput(\n input: BosConfigInput,\n baseDir: string,\n visited: Set<string>,\n chain: string[],\n): Promise<{ config: BosConfigInput; baseDir: string }> {\n if (input.extends) {\n const parentBaseDir = input.extends.startsWith(\"bos://\")\n ? baseDir\n : isAbsolute(input.extends)\n ? dirname(input.extends)\n : baseDir;\n const config = await resolveConfigWithExtends(input.extends, parentBaseDir, visited, chain);\n return { config: mergeConfigs(config, input), baseDir: parentBaseDir };\n }\n\n return { config: input, baseDir };\n}\n\nfunction mergeValues(parent: unknown, child: unknown): unknown {\n if (Array.isArray(parent) && Array.isArray(child)) {\n return child;\n }\n\n if (isPlainObject(parent) && isPlainObject(child)) {\n const merged: Record<string, unknown> = { ...parent };\n for (const [key, value] of Object.entries(child)) {\n merged[key] = key in merged ? mergeValues(merged[key], value) : value;\n }\n return merged;\n }\n\n return child ?? parent;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction normalizeStringRecord(value: unknown): Record<string, string> | undefined {\n if (!isPlainObject(value)) return undefined;\n const out: Record<string, string> = {};\n for (const [key, raw] of Object.entries(value)) {\n if (typeof raw === \"string\") {\n out[key] = raw;\n }\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\nfunction normalizeStringArray(value: unknown): string[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const out = value.filter((item): item is string => typeof item === \"string\" && item.length > 0);\n return out.length > 0 ? out : undefined;\n}\n\nfunction resolveRuntimeTarget(\n value: string | undefined,\n baseDir: string,\n defaultSource: \"local\" | \"remote\" = \"remote\",\n): RuntimeTarget {\n if (!value) {\n return { source: defaultSource, url: \"\" };\n }\n\n if (value.startsWith(LOCAL_PREFIX)) {\n const localTarget = value.slice(LOCAL_PREFIX.length).trim();\n if (!localTarget) {\n throw new Error(`Invalid local development target: ${value}`);\n }\n\n const localPath = resolve(baseDir, localTarget);\n if (!existsSync(localPath)) {\n return { source: \"local\", url: \"\" };\n }\n\n return {\n source: \"local\",\n url: \"\",\n localPath,\n };\n }\n\n return {\n source: defaultSource,\n url: value.replace(/\\/$/, \"\"),\n port: parsePort(value),\n };\n}\n\nexport function isLocalDevelopmentTarget(value: string | undefined): boolean {\n return typeof value === \"string\" && value.startsWith(LOCAL_PREFIX);\n}\n\nexport function resolveLocalDevelopmentPath(\n value: string | undefined,\n baseDir: string,\n): string | null {\n if (!isLocalDevelopmentTarget(value)) {\n return null;\n }\n\n const localTarget = value!.slice(LOCAL_PREFIX.length).trim();\n return localTarget ? resolve(baseDir, localTarget) : null;\n}\n\nexport function resolveDevelopmentHostUrl(value: string | undefined): string {\n if (!value || isLocalDevelopmentTarget(value)) {\n return `http://localhost:${DEFAULT_HOST_PORT}`;\n }\n\n return value.replace(/\\/$/, \"\");\n}\n\nexport function getHostDevelopmentPort(value: string | undefined): number {\n return parsePort(resolveDevelopmentHostUrl(value));\n}\n\nexport function parsePort(url: string): number {\n try {\n const parsed = new URL(url);\n return parsed.port ? parseInt(parsed.port, 10) : parsed.protocol === \"https:\" ? 443 : 80;\n } catch {\n return 3000;\n }\n}\n\nexport type { BosConfig, RuntimeConfig } from \"./types\";\nexport { BosConfigSchema } from \"./types\";\n"],"mappings":";;;;;;;;;AAOA,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAS1B,IAAI,eAAiC;AACrC,IAAI,cAA6B;AAEjC,SAAgB,mBAAyB;AACvC,gBAAe;AACf,eAAc;;AAGhB,SAAgB,eAAe,KAA6B;CAC1D,IAAI,MAAM,OAAO,QAAQ,KAAK;AAC9B,QAAO,QAAQ,KAAK;EAClB,MAAM,iCAAkB,KAAK,kBAAkB;AAC/C,8BAAe,WAAW,CACxB,QAAO;AAET,+BAAc,IAAI;;AAEpB,QAAO;;AAGT,SAAgB,YAA8B;AAC5C,QAAO;;AAGT,SAAgB,iBAAyB;AACvC,KAAI,CAAC,YACH,OAAM,IAAI,MAAM,8CAA8C;AAEhE,QAAO;;AAaT,eAAsB,WAAW,SAIA;CAC/B,MAAM,aAAa,SAAS,QAAQ,eAAe,SAAS,IAAI;AAChE,KAAI,CAAC,YAAY;AACf,gBAAc,SAAS,OAAO,QAAQ,KAAK;AAC3C,SAAO;;CAGT,MAAM,iCAAkB,WAAW;AAEnC,KAAI;EACF,MAAM,gBAA0B,EAAE;EAClC,MAAM,SAAS,MAAM,yBAAyB,YAAY,yBAAS,IAAI,KAAK,EAAE,cAAc;EAC5F,MAAM,SAASA,8BAAgB,MAAM,OAAO;AAE5C,iBAAe;AACf,gBAAc;EAEd,MAAM,gBAAgB,MAAM,sBAC1B,OAAO,WAAW,EAAE,EACpB,SACA,SAAS,OAAO,cACjB;AAKD,SAAO;GACL;GACA,SANc,mBAAmB,QAAQ,SAAS,SAAS,OAAO,eAAe,EACjF,SAAS,eACV,CAAC;GAKA,QAAQ;IACN,MAA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mCAAoB,SAAS,YAAY;AAC/C,MAAI,yBAAY,UAAU,CACxB,QAAO;GAAE,QAAQ;GAAS,KAAK;GAAI;AAGrC,SAAO;GACL,QAAQ;GACR,KAAK;GACL;GACD;;AAGH,QAAO;EACL,QAAQ;EACR,KAAK,MAAM,QAAQ,OAAO,GAAG;EAC7B,MAAM,UAAU,MAAM;EACvB;;AAGH,SAAgB,yBAAyB,OAAoC;AAC3E,QAAO,OAAO,UAAU,YAAY,MAAM,WAAW,aAAa;;AAGpE,SAAgB,4BACd,OACA,SACe;AACf,KAAI,CAAC,yBAAyB,MAAM,CAClC,QAAO;CAGT,MAAM,cAAc,MAAO,MAAM,EAAoB,CAAC,MAAM;AAC5D,QAAO,qCAAsB,SAAS,YAAY,GAAG;;AAGvD,SAAgB,0BAA0B,OAAmC;AAC3E,KAAI,CAAC,SAAS,yBAAyB,MAAM,CAC3C,QAAO,oBAAoB;AAG7B,QAAO,MAAM,QAAQ,OAAO,GAAG;;AAGjC,SAAgB,uBAAuB,OAAmC;AACxE,QAAO,UAAU,0BAA0B,MAAM,CAAC;;AAGpD,SAAgB,UAAU,KAAqB;AAC7C,KAAI;EACF,MAAM,SAAS,IAAI,IAAI,IAAI;AAC3B,SAAO,OAAO,OAAO,SAAS,OAAO,MAAM,GAAG,GAAG,OAAO,aAAa,WAAW,MAAM;SAChF;AACN,SAAO"}
|
|
1
|
+
{"version":3,"file":"config.cjs","names":["BosConfigSchema","isPlainObject","rebuildOrderedConfig","getNetworkIdForAccount","fetchBosConfigFromFastKv","resolveExtendsRef","mergeBosConfigWithExtends","parsePluginBosUrl","fetchPluginFromRegistry"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { fetchBosConfigFromFastKv, fetchPluginFromRegistry, parsePluginBosUrl } from \"./fastkv\";\nimport {\n type BosEnv,\n isPlainObject,\n mergeBosConfigWithExtends,\n type ResolvedConfigMeta,\n rebuildOrderedConfig,\n resolveExtendsRef,\n} from \"./merge\";\nimport { getNetworkIdForAccount } from \"./network\";\nimport type {\n BosConfig,\n BosConfigInput,\n BosPluginRef,\n ExtendsConfig,\n PluginEntryValue,\n RuntimeConfig,\n RuntimePluginConfig,\n SharedDepConfig,\n} from \"./types\";\nimport { BosConfigSchema } from \"./types\";\n\nconst LOCAL_PREFIX = \"local:\";\nconst DEFAULT_HOST_PORT = 3000;\nconst RESOLVED_CONFIG_FILENAME = \"bos.resolved-config.json\";\n\ninterface RuntimeTarget {\n source: \"local\" | \"remote\";\n url: string;\n localPath?: string;\n port?: number;\n}\n\nlet cachedConfig: BosConfig | null = null;\nlet projectRoot: string | null = null;\n\nexport function clearConfigCache(): void {\n cachedConfig = null;\n projectRoot = null;\n}\n\nexport function findConfigPath(cwd?: string): string | null {\n let dir = cwd ?? process.cwd();\n while (dir !== \"/\") {\n const configPath = join(dir, \"bos.config.json\");\n if (existsSync(configPath)) {\n return configPath;\n }\n dir = dirname(dir);\n }\n return null;\n}\n\nexport function getConfig(): BosConfig | null {\n return cachedConfig;\n}\n\nexport function getProjectRoot(): string {\n if (!projectRoot) {\n throw new Error(\"Config not loaded. Call loadConfig() first.\");\n }\n return projectRoot;\n}\n\nexport interface ConfigResult {\n config: BosConfig;\n runtime: RuntimeConfig;\n source: {\n path: string;\n extended?: string[];\n remote?: boolean;\n };\n}\n\nexport async function loadConfig(options?: {\n cwd?: string;\n path?: string;\n env?: BosEnv;\n}): Promise<ConfigResult | null> {\n const configPath = options?.path ?? findConfigPath(options?.cwd);\n if (!configPath) {\n projectRoot = options?.cwd ?? process.cwd();\n return null;\n }\n\n const baseDir = dirname(configPath);\n const env = options?.env ?? \"development\";\n const runtimeEnv: BosEnv = env === \"staging\" ? \"production\" : env;\n\n try {\n const extendedChain: string[] = [];\n const parsed = await resolveConfigWithExtends(\n configPath,\n baseDir,\n new Set(),\n extendedChain,\n env,\n );\n const config = BosConfigSchema.parse(parsed);\n\n cachedConfig = config;\n projectRoot = baseDir;\n\n const pluginRuntime = await resolveRuntimePlugins(config.plugins ?? {}, baseDir, runtimeEnv);\n const runtime = buildRuntimeConfig(config, baseDir, runtimeEnv, {\n plugins: pluginRuntime,\n });\n\n return {\n config,\n runtime,\n source: {\n path: configPath,\n extended: extendedChain.length > 0 ? extendedChain : undefined,\n remote: extendedChain.some((entry) => entry.startsWith(\"bos://\")),\n },\n };\n } catch (error) {\n throw new Error(`Failed to load config from ${configPath}: ${error}`);\n }\n}\n\nexport async function loadBosConfig(options?: {\n cwd?: string;\n path?: string;\n env?: BosEnv;\n}): Promise<RuntimeConfig> {\n const result = await loadConfig(options);\n if (!result) {\n throw new Error(\"No bos.config.json found\");\n }\n\n return result.runtime;\n}\n\nexport async function buildRuntimePluginsForConfig(\n config: BosConfig,\n baseDir: string,\n env: BosEnv,\n): Promise<Record<string, RuntimePluginConfig> | undefined> {\n const plugins = await resolveRuntimePlugins(config.plugins ?? {}, baseDir, env);\n return Object.keys(plugins).length > 0 ? plugins : undefined;\n}\n\nexport function getResolvedConfigPath(configDir: string): string {\n return join(configDir, \".bos\", RESOLVED_CONFIG_FILENAME);\n}\n\nexport function loadResolvedConfig(configDir: string): BosConfig | null {\n const resolvedPath = getResolvedConfigPath(configDir);\n if (!existsSync(resolvedPath)) return null;\n try {\n const raw = JSON.parse(readFileSync(resolvedPath, \"utf-8\"));\n if (!isPlainObject(raw)) return null;\n const { _resolved, ...configData } = raw;\n return BosConfigSchema.parse(configData);\n } catch {\n return null;\n }\n}\n\nexport function writeResolvedConfig(\n configDir: string,\n config: BosConfig,\n env: BosEnv,\n extendsChain?: string[],\n source?: string,\n): void {\n const resolvedPath = getResolvedConfigPath(configDir);\n const resolvedDir = dirname(resolvedPath);\n if (!existsSync(resolvedDir)) {\n mkdirSync(resolvedDir, { recursive: true });\n }\n\n const ordered = rebuildOrderedConfig(config);\n const meta: ResolvedConfigMeta = {\n env,\n resolvedAt: new Date().toISOString(),\n extendsChain: extendsChain ?? [],\n ...(source ? { source } : {}),\n };\n const output = {\n _resolved: meta,\n ...ordered,\n };\n\n const content = `${JSON.stringify(output, null, 2)}\\n`;\n try {\n if (readFileSync(resolvedPath, \"utf-8\") === content) return;\n } catch {\n // file doesn't exist yet\n }\n writeFileSync(resolvedPath, content);\n}\n\nexport function resolveBosConfigPath(configDir: string): string {\n const resolvedPath = getResolvedConfigPath(configDir);\n if (existsSync(resolvedPath)) return resolvedPath;\n return join(configDir, \"bos.config.json\");\n}\n\nexport function readBosConfigForBuild(configDir: string): Record<string, unknown> {\n const resolvedPath = getResolvedConfigPath(configDir);\n if (existsSync(resolvedPath)) {\n try {\n const raw = JSON.parse(readFileSync(resolvedPath, \"utf-8\"));\n if (isPlainObject(raw)) {\n const { _resolved, ...configData } = raw;\n return configData as Record<string, unknown>;\n }\n } catch {}\n }\n const bosConfigPath = join(configDir, \"bos.config.json\");\n return JSON.parse(readFileSync(bosConfigPath, \"utf-8\")) as Record<string, unknown>;\n}\n\nfunction resolveDevelopmentTarget(\n development: string | undefined,\n production: string | undefined,\n baseDir: string,\n forceSource?: \"local\" | \"remote\",\n): RuntimeTarget {\n if (forceSource === \"remote\") {\n return resolveRuntimeTarget(production, baseDir, \"remote\");\n }\n const devTarget = resolveRuntimeTarget(development, baseDir);\n if (devTarget.source === \"local\" && (!devTarget.localPath || !existsSync(devTarget.localPath))) {\n return resolveRuntimeTarget(production, baseDir, \"remote\");\n }\n return devTarget;\n}\n\nexport interface BuildRuntimeConfigOptions {\n plugins?: Record<string, RuntimePluginConfig>;\n hostSource?: \"local\" | \"remote\";\n uiSource?: \"local\" | \"remote\";\n apiSource?: \"local\" | \"remote\";\n authSource?: \"local\" | \"remote\";\n proxy?: string;\n}\n\nexport function buildRuntimeConfig(\n config: BosConfig,\n baseDir: string,\n env: BosEnv,\n options?: BuildRuntimeConfigOptions,\n): RuntimeConfig {\n const uiConfig = config.app.ui;\n const apiConfig = config.app.api;\n const authConfig = config.app.auth;\n const uiRuntime =\n env === \"development\"\n ? resolveDevelopmentTarget(\n uiConfig.development,\n uiConfig.production,\n baseDir,\n options?.uiSource,\n )\n : resolveRuntimeTarget(uiConfig.production, baseDir, \"remote\");\n const apiRuntime =\n env === \"development\"\n ? resolveDevelopmentTarget(\n apiConfig.development,\n apiConfig.production,\n baseDir,\n options?.apiSource,\n )\n : resolveRuntimeTarget(apiConfig.production, baseDir, \"remote\");\n const authRuntime = authConfig\n ? env === \"development\"\n ? resolveDevelopmentTarget(\n authConfig.development,\n authConfig.production,\n baseDir,\n options?.authSource,\n )\n : resolveRuntimeTarget(authConfig.production, baseDir, \"remote\")\n : undefined;\n\n const hostConfig = config.app.host;\n const hostRuntime =\n env === \"development\"\n ? resolveDevelopmentTarget(\n hostConfig.development,\n hostConfig.production,\n baseDir,\n options?.hostSource,\n )\n : resolveRuntimeTarget(hostConfig.production, baseDir, \"remote\");\n\n const hostListeningUrl =\n env === \"development\"\n ? resolveDevelopmentHostUrl(hostConfig.development)\n : `http://localhost:${hostRuntime.port ?? DEFAULT_HOST_PORT}`;\n\n const hostIsRemote = hostRuntime.source === \"remote\";\n const uiIsRemote = uiRuntime.source === \"remote\";\n const apiIsRemote = apiRuntime.source === \"remote\";\n\n return {\n env,\n account: config.account,\n domain: config.domain,\n networkId: getNetworkIdForAccount(config.account),\n repository: config.repository,\n host: {\n name: \"host\",\n url: hostListeningUrl,\n entry: `${hostListeningUrl}/mf-manifest.json`,\n localPath: hostRuntime.localPath,\n port: hostRuntime.port ?? DEFAULT_HOST_PORT,\n secrets: hostConfig.secrets,\n integrity: hostIsRemote ? hostConfig.integrity : undefined,\n source: hostRuntime.source,\n remoteUrl: hostIsRemote ? hostRuntime.url : undefined,\n },\n shared: config.shared,\n ui: {\n name: uiConfig.name,\n url: uiRuntime.url,\n entry: uiRuntime.url ? `${uiRuntime.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: uiRuntime.localPath,\n port: uiRuntime.port,\n ssrUrl: uiIsRemote ? uiConfig.ssr : undefined,\n ssrIntegrity: uiIsRemote ? uiConfig.ssrIntegrity : undefined,\n integrity: uiIsRemote ? uiConfig.integrity : undefined,\n source: uiRuntime.source,\n },\n api: {\n name: apiConfig.name,\n url: apiRuntime.url,\n entry: apiRuntime.url ? `${apiRuntime.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: apiRuntime.localPath,\n port: apiRuntime.port,\n source: apiRuntime.source,\n proxy: options?.proxy ?? apiConfig.proxy,\n variables: apiConfig.variables,\n secrets: apiConfig.secrets,\n integrity: apiIsRemote ? apiConfig.integrity : undefined,\n },\n auth: (() => {\n if (!authConfig || !authRuntime) return undefined;\n return {\n name: resolvePluginRuntimeName(undefined, authRuntime.localPath, authConfig.name),\n url: authRuntime.url,\n entry: authRuntime.url ? `${authRuntime.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: authRuntime.localPath,\n port: authRuntime.port,\n source: authRuntime.source,\n proxy: authConfig.proxy,\n variables: authConfig.variables,\n secrets: authConfig.secrets,\n integrity: authRuntime.source === \"remote\" ? authConfig.integrity : undefined,\n sidebar: authConfig.sidebar?.map((item) => ({\n ...item,\n to: item.to ?? \"/auth\",\n roleRequired: item.roleRequired ?? (\"member\" as const),\n })),\n };\n })(),\n plugins:\n options?.plugins && Object.keys(options.plugins).length > 0 ? options.plugins : undefined,\n };\n}\n\nasync function loadConfigFile(configPath: string, baseDir: string): Promise<BosConfigInput> {\n if (configPath.startsWith(\"bos://\")) {\n return fetchBosConfigFromFastKv<BosConfigInput>(configPath);\n }\n\n const resolvedPath = isAbsolute(configPath) ? configPath : resolve(baseDir, configPath);\n return JSON.parse(readFileSync(resolvedPath, \"utf-8\")) as BosConfigInput;\n}\n\nasync function resolveConfigWithExtends(\n configPath: string,\n baseDir: string,\n visited: Set<string>,\n chain: string[],\n env: BosEnv = \"development\",\n): Promise<BosConfigInput> {\n if (visited.has(configPath)) {\n throw new Error(`Circular extends detected: ${[...visited, configPath].join(\" -> \")}`);\n }\n\n const config = await loadConfigFile(configPath, baseDir);\n chain.push(configPath);\n\n if (!config.extends) {\n return config;\n }\n\n const extendsRef = resolveExtendsRef(config.extends as string | ExtendsConfig, env);\n if (!extendsRef) {\n return config;\n }\n\n const nextVisited = new Set(visited);\n nextVisited.add(configPath);\n const parentBaseDir = extendsRef.startsWith(\"bos://\")\n ? baseDir\n : isAbsolute(extendsRef)\n ? dirname(extendsRef)\n : baseDir;\n const parent = await resolveConfigWithExtends(extendsRef, parentBaseDir, nextVisited, chain, env);\n\n return mergeBosConfigWithExtends(parent, config);\n}\n\ntype PluginOverrideValue = PluginEntryValue | null | false;\n\nfunction normalizePluginEntry(raw: PluginOverrideValue): BosPluginRef | null | false {\n if (raw === null || raw === false) return raw;\n if (typeof raw === \"string\") {\n return { extends: raw };\n }\n return raw;\n}\n\nasync function resolveRuntimePlugins(\n plugins: Record<string, PluginOverrideValue>,\n baseDir: string,\n env: BosEnv,\n): Promise<Record<string, RuntimePluginConfig>> {\n const out: Record<string, RuntimePluginConfig> = {};\n\n for (const [pluginId, rawInput] of Object.entries(plugins)) {\n const normalized = normalizePluginEntry(rawInput);\n if (normalized === null || normalized === false) continue;\n\n let resolvedConfig: BosConfigInput = {};\n let pluginBaseDir = baseDir;\n\n if (normalized.extends) {\n try {\n const extendsUrl = resolveExtendsRef(normalized.extends, env);\n if (extendsUrl) {\n const remoteConfig = await fetchBosConfigFromFastKv<BosConfigInput>(extendsUrl);\n resolvedConfig = remoteConfig;\n }\n } catch {\n resolvedConfig = {};\n }\n }\n\n if (normalized.development?.startsWith(LOCAL_PREFIX)) {\n const localPath = resolve(baseDir, normalized.development.slice(LOCAL_PREFIX.length).trim());\n if (existsSync(localPath)) {\n const localConfigPath = join(localPath, \"bos.config.json\");\n if (existsSync(localConfigPath)) {\n try {\n const localRaw = JSON.parse(readFileSync(localConfigPath, \"utf-8\")) as BosConfigInput;\n resolvedConfig = mergeBosConfigWithExtends(resolvedConfig, localRaw);\n pluginBaseDir = localPath;\n } catch {}\n }\n }\n }\n\n if (normalized.app && isPlainObject(normalized.app)) {\n const mergedApp: Record<string, unknown> = {\n ...((resolvedConfig.app as Record<string, unknown>) ?? {}),\n ...(normalized.app as Record<string, unknown>),\n };\n resolvedConfig = { ...resolvedConfig, app: mergedApp as BosConfigInput[\"app\"] };\n }\n if (normalized.shared && isPlainObject(normalized.shared)) {\n const mergedShared: Record<string, Record<string, SharedDepConfig>> = {\n ...(resolvedConfig.shared ?? {}),\n ...(normalized.shared as Record<string, Record<string, SharedDepConfig>>),\n };\n resolvedConfig = { ...resolvedConfig, shared: mergedShared };\n }\n if (normalized.sidebar) {\n resolvedConfig = { ...resolvedConfig, sidebar: normalized.sidebar };\n }\n if (normalized.routes) {\n resolvedConfig = { ...resolvedConfig, routes: normalized.routes };\n }\n\n const pluginRuntime = await buildRuntimePluginConfig(\n pluginId,\n resolvedConfig,\n pluginBaseDir,\n env,\n normalized,\n );\n if (\n normalized.name &&\n typeof normalized.name === \"string\" &&\n !pluginRuntime.name.includes(\"/\")\n ) {\n pluginRuntime.name = normalized.name;\n }\n\n const integrity = normalized.integrity;\n if (env === \"production\" && integrity) {\n pluginRuntime.integrity = integrity;\n }\n\n if (\n pluginRuntime.source === \"remote\" &&\n pluginRuntime.url &&\n !pluginRuntime.localPath &&\n typeof resolvedConfig.app?.api?.name !== \"string\" &&\n !normalized.name\n ) {\n pluginRuntime.name = await resolveRemotePluginRuntimeName(\n pluginRuntime.url,\n pluginRuntime.name,\n );\n }\n\n out[pluginId] = pluginRuntime;\n }\n\n return out;\n}\n\nasync function resolveRemotePluginRuntimeName(baseUrl: string, fallback: string): Promise<string> {\n try {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 5000);\n const response = await fetch(`${baseUrl.replace(/\\/$/, \"\")}/plugin.manifest.json`, {\n signal: controller.signal,\n });\n clearTimeout(timeout);\n\n if (!response.ok) {\n return fallback;\n }\n\n const manifest = (await response.json()) as {\n plugin?: { name?: unknown };\n };\n\n return typeof manifest.plugin?.name === \"string\" && manifest.plugin.name.length > 0\n ? manifest.plugin.name\n : fallback;\n } catch {\n return fallback;\n }\n}\n\ninterface ResolvedBosPlugin {\n url: string;\n integrity?: string;\n}\n\nasync function resolveBosPluginUrl(bosUrl: string): Promise<ResolvedBosPlugin | null> {\n const parsed = parsePluginBosUrl(bosUrl);\n if (!parsed) return null;\n\n try {\n const entry = await fetchPluginFromRegistry(parsed.accountId, parsed.pluginName);\n if (!entry) return null;\n\n const cdnUrl = entry.metadata.cdnUrl;\n if (!cdnUrl) return null;\n\n return {\n url: cdnUrl,\n integrity: entry.metadata.integrity ?? undefined,\n };\n } catch {\n return null;\n }\n}\n\nasync function buildRuntimePluginConfig(\n pluginId: string,\n config: BosConfigInput,\n baseDir: string,\n env: BosEnv,\n source: BosPluginRef,\n): Promise<RuntimePluginConfig> {\n const apiConfig = config.app?.api ?? {};\n const apiDevelopment =\n typeof apiConfig.development === \"string\" ? apiConfig.development : undefined;\n const apiProduction = typeof apiConfig.production === \"string\" ? apiConfig.production : undefined;\n const sourceDevelopment = typeof source.development === \"string\" ? source.development : undefined;\n const sourceProduction = typeof source.production === \"string\" ? source.production : undefined;\n const proxy = typeof apiConfig.proxy === \"string\" ? apiConfig.proxy : undefined;\n const development = apiDevelopment ?? sourceDevelopment;\n let production = apiProduction ?? sourceProduction;\n\n if (production?.startsWith(\"bos://\")) {\n const resolved = await resolveBosPluginUrl(production);\n if (resolved) {\n production = resolved.url;\n if (resolved.integrity && env === \"production\") {\n source.integrity = resolved.integrity;\n }\n }\n }\n\n const runtimeTarget =\n env === \"development\"\n ? resolveDevelopmentTarget(development, production, baseDir)\n : resolveRuntimeTarget(production, baseDir, \"remote\");\n const apiName = resolvePluginRuntimeName(\n typeof apiConfig.name === \"string\" ? apiConfig.name : undefined,\n runtimeTarget.localPath,\n pluginId,\n );\n\n const uiConfig = config.app?.ui;\n const uiDevelopment =\n typeof uiConfig?.development === \"string\" ? uiConfig.development : undefined;\n const uiProduction = typeof uiConfig?.production === \"string\" ? uiConfig.production : undefined;\n const uiRuntime =\n uiConfig && (uiDevelopment || uiProduction)\n ? env === \"development\"\n ? resolveDevelopmentTarget(uiDevelopment, uiProduction, baseDir)\n : resolveRuntimeTarget(uiProduction, baseDir, \"remote\")\n : undefined;\n\n const sidebar = (config.sidebar ?? source.sidebar)?.map((item) => ({\n ...item,\n to: item.to ?? `/${pluginId}`,\n roleRequired: item.roleRequired ?? (\"member\" as const),\n }));\n\n const routes = config.routes ?? source.routes;\n\n return {\n name: apiName,\n url: runtimeTarget.url,\n entry: runtimeTarget.url\n ? `${runtimeTarget.url.replace(/\\/$/, \"\")}/mf-manifest.json`\n : \"/mf-manifest.json\",\n source: runtimeTarget.source,\n localPath: runtimeTarget.localPath,\n port: runtimeTarget.port,\n proxy: proxy ?? (typeof source.proxy === \"string\" ? source.proxy : undefined),\n variables: normalizeStringRecord(apiConfig.variables ?? source.variables),\n secrets: normalizeStringArray(apiConfig.secrets ?? source.secrets),\n ui: uiRuntime\n ? {\n name: typeof uiConfig?.name === \"string\" ? uiConfig.name : `${apiName}-ui`,\n url: uiRuntime.url,\n entry: uiRuntime.url\n ? `${uiRuntime.url.replace(/\\/$/, \"\")}/mf-manifest.json`\n : \"/mf-manifest.json\",\n source: uiRuntime.source,\n localPath: uiRuntime.localPath,\n port: uiRuntime.port,\n integrity:\n uiRuntime.source === \"remote\" && typeof uiConfig?.integrity === \"string\"\n ? uiConfig.integrity\n : undefined,\n }\n : undefined,\n sidebar,\n routes,\n };\n}\n\nexport function resolvePluginRuntimeName(\n explicitName: string | undefined,\n localPath: string | undefined,\n fallback: string,\n): string {\n if (explicitName) {\n return explicitName;\n }\n\n if (!localPath) {\n return fallback;\n }\n\n try {\n const packageJsonPath = join(localPath, \"package.json\");\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as { name?: unknown };\n if (typeof packageJson.name === \"string\" && packageJson.name.length > 0) {\n return packageJson.name;\n }\n } catch {}\n\n return fallback;\n}\n\nfunction normalizeStringRecord(value: unknown): Record<string, string> | undefined {\n if (!isPlainObject(value)) return undefined;\n const out: Record<string, string> = {};\n for (const [key, raw] of Object.entries(value)) {\n if (typeof raw === \"string\") {\n out[key] = raw;\n }\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\nfunction normalizeStringArray(value: unknown): string[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const out = value.filter((item): item is string => typeof item === \"string\" && item.length > 0);\n return out.length > 0 ? out : undefined;\n}\n\nfunction resolveRuntimeTarget(\n value: string | undefined,\n baseDir: string,\n defaultSource: \"local\" | \"remote\" = \"remote\",\n): RuntimeTarget {\n if (!value) {\n return { source: defaultSource, url: \"\" };\n }\n\n if (value.startsWith(LOCAL_PREFIX)) {\n const localTarget = value?.slice(LOCAL_PREFIX.length).trim();\n if (!localTarget) {\n throw new Error(`Invalid local development target: ${value}`);\n }\n\n const localPath = resolve(baseDir, localTarget);\n if (!existsSync(localPath)) {\n return { source: \"local\", url: \"\" };\n }\n\n return {\n source: \"local\",\n url: \"\",\n localPath,\n };\n }\n\n return {\n source: defaultSource,\n url: value.replace(/\\/$/, \"\"),\n port: parsePort(value),\n };\n}\n\nexport function isLocalDevelopmentTarget(\n value: string | undefined,\n): value is `${typeof LOCAL_PREFIX}${string}` {\n return typeof value === \"string\" && value.startsWith(LOCAL_PREFIX);\n}\n\nexport function resolveLocalDevelopmentPath(\n value: string | undefined,\n baseDir: string,\n): string | null {\n if (!isLocalDevelopmentTarget(value)) {\n return null;\n }\n\n const localTarget = value.slice(LOCAL_PREFIX.length).trim();\n return localTarget ? resolve(baseDir, localTarget) : null;\n}\n\nexport function resolveDevelopmentHostUrl(value: string | undefined): string {\n if (!value || isLocalDevelopmentTarget(value)) {\n return `http://localhost:${DEFAULT_HOST_PORT}`;\n }\n\n return value.replace(/\\/$/, \"\");\n}\n\nexport function getHostDevelopmentPort(value: string | undefined): number {\n return parsePort(resolveDevelopmentHostUrl(value));\n}\n\nexport function parsePort(url: string): number {\n try {\n const parsed = new URL(url);\n return parsed.port ? parseInt(parsed.port, 10) : parsed.protocol === \"https:\" ? 443 : 80;\n } catch {\n return 3000;\n }\n}\n\nexport { BOS_CONFIG_ORDER, rebuildOrderedConfig } from \"./merge\";\nexport type { BosConfig, RuntimeConfig } from \"./types\";\nexport { BosConfigSchema } from \"./types\";\n"],"mappings":";;;;;;;;;;AAwBA,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,2BAA2B;AASjC,IAAI,eAAiC;AACrC,IAAI,cAA6B;AAEjC,SAAgB,mBAAyB;AACvC,gBAAe;AACf,eAAc;;AAGhB,SAAgB,eAAe,KAA6B;CAC1D,IAAI,MAAM,OAAO,QAAQ,KAAK;AAC9B,QAAO,QAAQ,KAAK;EAClB,MAAM,iCAAkB,KAAK,kBAAkB;AAC/C,8BAAe,WAAW,CACxB,QAAO;AAET,+BAAc,IAAI;;AAEpB,QAAO;;AAGT,SAAgB,YAA8B;AAC5C,QAAO;;AAGT,SAAgB,iBAAyB;AACvC,KAAI,CAAC,YACH,OAAM,IAAI,MAAM,8CAA8C;AAEhE,QAAO;;AAaT,eAAsB,WAAW,SAIA;CAC/B,MAAM,aAAa,SAAS,QAAQ,eAAe,SAAS,IAAI;AAChE,KAAI,CAAC,YAAY;AACf,gBAAc,SAAS,OAAO,QAAQ,KAAK;AAC3C,SAAO;;CAGT,MAAM,iCAAkB,WAAW;CACnC,MAAM,MAAM,SAAS,OAAO;CAC5B,MAAM,aAAqB,QAAQ,YAAY,eAAe;AAE9D,KAAI;EACF,MAAM,gBAA0B,EAAE;EAClC,MAAM,SAAS,MAAM,yBACnB,YACA,yBACA,IAAI,KAAK,EACT,eACA,IACD;EACD,MAAM,SAASA,8BAAgB,MAAM,OAAO;AAE5C,iBAAe;AACf,gBAAc;AAOd,SAAO;GACL;GACA,SANc,mBAAmB,QAAQ,SAAS,YAAY,EAC9D,SAFoB,MAAM,sBAAsB,OAAO,WAAW,EAAE,EAAE,SAAS,WA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F,MAAM,SAAS,IAAI,IAAI,IAAI;AAC3B,SAAO,OAAO,OAAO,SAAS,OAAO,MAAM,GAAG,GAAG,OAAO,aAAa,WAAW,MAAM;SAChF;AACN,SAAO"}
|
package/dist/config.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BosConfig, BosConfigSchema, RuntimeConfig, RuntimePluginConfig } from "./types.cjs";
|
|
2
|
+
import { BOS_CONFIG_ORDER, BosEnv, rebuildOrderedConfig } from "./merge.cjs";
|
|
2
3
|
|
|
3
4
|
//#region src/config.d.ts
|
|
5
|
+
declare const LOCAL_PREFIX = "local:";
|
|
4
6
|
declare function clearConfigCache(): void;
|
|
5
7
|
declare function findConfigPath(cwd?: string): string | null;
|
|
6
8
|
declare function getConfig(): BosConfig | null;
|
|
@@ -17,14 +19,19 @@ interface ConfigResult {
|
|
|
17
19
|
declare function loadConfig(options?: {
|
|
18
20
|
cwd?: string;
|
|
19
21
|
path?: string;
|
|
20
|
-
env?:
|
|
22
|
+
env?: BosEnv;
|
|
21
23
|
}): Promise<ConfigResult | null>;
|
|
22
24
|
declare function loadBosConfig(options?: {
|
|
23
25
|
cwd?: string;
|
|
24
26
|
path?: string;
|
|
25
|
-
env?:
|
|
27
|
+
env?: BosEnv;
|
|
26
28
|
}): Promise<RuntimeConfig>;
|
|
27
|
-
declare function buildRuntimePluginsForConfig(config: BosConfig, baseDir: string, env:
|
|
29
|
+
declare function buildRuntimePluginsForConfig(config: BosConfig, baseDir: string, env: BosEnv): Promise<Record<string, RuntimePluginConfig> | undefined>;
|
|
30
|
+
declare function getResolvedConfigPath(configDir: string): string;
|
|
31
|
+
declare function loadResolvedConfig(configDir: string): BosConfig | null;
|
|
32
|
+
declare function writeResolvedConfig(configDir: string, config: BosConfig, env: BosEnv, extendsChain?: string[], source?: string): void;
|
|
33
|
+
declare function resolveBosConfigPath(configDir: string): string;
|
|
34
|
+
declare function readBosConfigForBuild(configDir: string): Record<string, unknown>;
|
|
28
35
|
interface BuildRuntimeConfigOptions {
|
|
29
36
|
plugins?: Record<string, RuntimePluginConfig>;
|
|
30
37
|
hostSource?: "local" | "remote";
|
|
@@ -33,13 +40,13 @@ interface BuildRuntimeConfigOptions {
|
|
|
33
40
|
authSource?: "local" | "remote";
|
|
34
41
|
proxy?: string;
|
|
35
42
|
}
|
|
36
|
-
declare function buildRuntimeConfig(config: BosConfig, baseDir: string, env:
|
|
43
|
+
declare function buildRuntimeConfig(config: BosConfig, baseDir: string, env: BosEnv, options?: BuildRuntimeConfigOptions): RuntimeConfig;
|
|
37
44
|
declare function resolvePluginRuntimeName(explicitName: string | undefined, localPath: string | undefined, fallback: string): string;
|
|
38
|
-
declare function isLocalDevelopmentTarget(value: string | undefined):
|
|
45
|
+
declare function isLocalDevelopmentTarget(value: string | undefined): value is `${typeof LOCAL_PREFIX}${string}`;
|
|
39
46
|
declare function resolveLocalDevelopmentPath(value: string | undefined, baseDir: string): string | null;
|
|
40
47
|
declare function resolveDevelopmentHostUrl(value: string | undefined): string;
|
|
41
48
|
declare function getHostDevelopmentPort(value: string | undefined): number;
|
|
42
49
|
declare function parsePort(url: string): number;
|
|
43
50
|
//#endregion
|
|
44
|
-
export { type BosConfig, BosConfigSchema, BuildRuntimeConfigOptions, ConfigResult, type RuntimeConfig, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName };
|
|
51
|
+
export { BOS_CONFIG_ORDER, type BosConfig, BosConfigSchema, BuildRuntimeConfigOptions, ConfigResult, type RuntimeConfig, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, getResolvedConfigPath, isLocalDevelopmentTarget, loadBosConfig, loadConfig, loadResolvedConfig, parsePort, readBosConfigForBuild, rebuildOrderedConfig, resolveBosConfigPath, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName, writeResolvedConfig };
|
|
45
52
|
//# sourceMappingURL=config.d.cts.map
|
package/dist/config.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":";;;;cAwBM,YAAA;AAAA,iBAcU,gBAAA,CAAA;AAAA,iBAKA,cAAA,CAAe,GAAA;AAAA,iBAYf,SAAA,CAAA,GAAa,SAAA;AAAA,iBAIb,cAAA,CAAA;AAAA,UAOC,YAAA;EACf,MAAA,EAAQ,SAAA;EACR,OAAA,EAAS,aAAA;EACT,MAAA;IACE,IAAA;IACA,QAAA;IACA,MAAA;EAAA;AAAA;AAAA,iBAIkB,UAAA,CAAW,OAAA;EAC/B,GAAA;EACA,IAAA;EACA,GAAA,GAAM,MAAA;AAAA,IACJ,OAAA,CAAQ,YAAA;AAAA,iBA4CU,aAAA,CAAc,OAAA;EAClC,GAAA;EACA,IAAA;EACA,GAAA,GAAM,MAAA;AAAA,IACJ,OAAA,CAAQ,aAAA;AAAA,iBASU,4BAAA,CACpB,MAAA,EAAQ,SAAA,EACR,OAAA,UACA,GAAA,EAAK,MAAA,GACJ,OAAA,CAAQ,MAAA,SAAe,mBAAA;AAAA,iBAKV,qBAAA,CAAsB,SAAA;AAAA,iBAItB,kBAAA,CAAmB,SAAA,WAAoB,SAAA;AAAA,iBAavC,mBAAA,CACd,SAAA,UACA,MAAA,EAAQ,SAAA,EACR,GAAA,EAAK,MAAA,EACL,YAAA,aACA,MAAA;AAAA,iBA6Bc,oBAAA,CAAqB,SAAA;AAAA,iBAMrB,qBAAA,CAAsB,SAAA,WAAoB,MAAA;AAAA,UA+BzC,yBAAA;EACf,OAAA,GAAU,MAAA,SAAe,mBAAA;EACzB,UAAA;EACA,QAAA;EACA,SAAA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