everything-dev 1.12.3 → 1.12.4
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 +7 -96
- package/dist/app.cjs.map +1 -1
- package/dist/app.mjs +8 -97
- package/dist/app.mjs.map +1 -1
- package/dist/config.cjs +18 -13
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +10 -1
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +10 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +18 -14
- package/dist/config.mjs.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/src/app.ts +8 -113
- package/src/config.ts +51 -14
package/dist/app.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_network = require('./network.cjs');
|
|
3
2
|
const require_config = require('./config.cjs');
|
|
4
3
|
let node_fs = require("node:fs");
|
|
5
4
|
let node_path = require("node:path");
|
|
@@ -27,102 +26,14 @@ function detectLocalPackages(bosConfig, runtimeConfig) {
|
|
|
27
26
|
return packages;
|
|
28
27
|
}
|
|
29
28
|
function buildRuntimeConfig(bosConfig, options) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (preferredSource === "remote") return {
|
|
37
|
-
source: "remote",
|
|
38
|
-
url: entry.production ?? ""
|
|
39
|
-
};
|
|
40
|
-
const localPath = require_config.resolveLocalDevelopmentPath(entry.development, configDir);
|
|
41
|
-
if (localPath && (0, node_fs.existsSync)(localPath)) return {
|
|
42
|
-
source: "local",
|
|
43
|
-
url: "",
|
|
44
|
-
localPath
|
|
45
|
-
};
|
|
46
|
-
const devUrl = entry.development && !require_config.isLocalDevelopmentTarget(entry.development) ? entry.development.replace(/\/$/, "") : null;
|
|
47
|
-
if (devUrl) return {
|
|
48
|
-
source: "local",
|
|
49
|
-
url: devUrl,
|
|
50
|
-
port: require_config.parsePort(devUrl)
|
|
51
|
-
};
|
|
52
|
-
return {
|
|
53
|
-
source: "remote",
|
|
54
|
-
url: entry.production ?? ""
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const hostEntry = resolveDevelopmentEntry(hostConfig, options.hostSource ?? "local");
|
|
58
|
-
const uiEntry = resolveDevelopmentEntry(uiConfig, options.uiSource ?? "local");
|
|
59
|
-
const apiEntry = resolveDevelopmentEntry(apiConfig, options.apiSource ?? "local");
|
|
60
|
-
const authEntry = authConfig ? resolveDevelopmentEntry(authConfig, options.authSource ?? "local") : void 0;
|
|
61
|
-
const hostUrl = `http://localhost:${DEFAULT_HOST_PORT}`;
|
|
62
|
-
return {
|
|
63
|
-
env: options.env ?? "development",
|
|
64
|
-
account: bosConfig.account,
|
|
65
|
-
domain: bosConfig.domain,
|
|
66
|
-
networkId: require_network.getNetworkIdForAccount(bosConfig.account),
|
|
67
|
-
host: {
|
|
68
|
-
name: "host",
|
|
69
|
-
url: hostUrl,
|
|
70
|
-
entry: `${hostUrl}/mf-manifest.json`,
|
|
71
|
-
localPath: hostEntry.localPath,
|
|
72
|
-
port: hostEntry.port ?? DEFAULT_HOST_PORT,
|
|
73
|
-
secrets: hostConfig.secrets,
|
|
74
|
-
integrity: hostEntry.source === "remote" ? hostConfig.integrity : void 0,
|
|
75
|
-
source: hostEntry.source,
|
|
76
|
-
remoteUrl: hostEntry.source === "remote" ? hostEntry.url : void 0
|
|
77
|
-
},
|
|
78
|
-
shared: bosConfig.shared,
|
|
79
|
-
ui: uiConfig ? {
|
|
80
|
-
name: uiConfig.name,
|
|
81
|
-
url: uiEntry.url,
|
|
82
|
-
entry: uiEntry.url ? `${uiEntry.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
83
|
-
localPath: uiEntry.localPath,
|
|
84
|
-
port: uiEntry.port,
|
|
85
|
-
ssrUrl: uiEntry.source === "remote" ? uiConfig.ssr : void 0,
|
|
86
|
-
ssrIntegrity: uiEntry.source === "remote" ? uiConfig.ssrIntegrity : void 0,
|
|
87
|
-
integrity: uiEntry.source === "remote" ? uiConfig.integrity : void 0,
|
|
88
|
-
source: uiEntry.source
|
|
89
|
-
} : {
|
|
90
|
-
name: "ui",
|
|
91
|
-
url: "",
|
|
92
|
-
entry: "/mf-manifest.json",
|
|
93
|
-
source: uiEntry.source
|
|
94
|
-
},
|
|
95
|
-
api: apiConfig ? {
|
|
96
|
-
name: apiConfig.name,
|
|
97
|
-
url: apiEntry.url,
|
|
98
|
-
entry: apiEntry.url ? `${apiEntry.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
99
|
-
localPath: apiEntry.localPath,
|
|
100
|
-
port: apiEntry.port,
|
|
101
|
-
source: apiEntry.source,
|
|
102
|
-
proxy: options.proxy ?? apiConfig.proxy,
|
|
103
|
-
variables: apiConfig.variables,
|
|
104
|
-
secrets: apiConfig.secrets,
|
|
105
|
-
integrity: apiEntry.source === "remote" ? apiConfig.integrity : void 0
|
|
106
|
-
} : {
|
|
107
|
-
name: "api",
|
|
108
|
-
url: "",
|
|
109
|
-
entry: "/mf-manifest.json",
|
|
110
|
-
source: apiEntry.source
|
|
111
|
-
},
|
|
112
|
-
auth: authEntry && authConfig ? {
|
|
113
|
-
name: require_config.resolvePluginRuntimeName(void 0, authEntry.localPath, authConfig.name),
|
|
114
|
-
url: authEntry.url,
|
|
115
|
-
entry: authEntry.url ? `${authEntry.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
116
|
-
localPath: authEntry.localPath,
|
|
117
|
-
port: authEntry.port,
|
|
118
|
-
source: authEntry.source,
|
|
119
|
-
proxy: authConfig.proxy,
|
|
120
|
-
variables: authConfig.variables,
|
|
121
|
-
secrets: authConfig.secrets,
|
|
122
|
-
integrity: authEntry.source === "remote" ? authConfig.integrity : void 0
|
|
123
|
-
} : void 0,
|
|
29
|
+
return require_config.buildRuntimeConfig(bosConfig, require_config.getProjectRoot(), options.env ?? "development", {
|
|
30
|
+
hostSource: options.hostSource,
|
|
31
|
+
uiSource: options.uiSource,
|
|
32
|
+
apiSource: options.apiSource,
|
|
33
|
+
authSource: options.authSource,
|
|
34
|
+
proxy: options.proxy,
|
|
124
35
|
plugins: options.plugins
|
|
125
|
-
};
|
|
36
|
+
});
|
|
126
37
|
}
|
|
127
38
|
function probeTcpOpen(port, timeoutMs = 250) {
|
|
128
39
|
return new Promise((resolve) => {
|
package/dist/app.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.cjs","names":["getProjectRoot","resolveLocalDevelopmentPath","isLocalDevelopmentTarget","parsePort","getNetworkIdForAccount","resolvePluginRuntimeName"],"sources":["../src/app.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { createConnection } from \"node:net\";\nimport { join } from \"node:path\";\nimport {\n getProjectRoot,\n isLocalDevelopmentTarget,\n parsePort,\n resolveLocalDevelopmentPath,\n resolvePluginRuntimeName,\n} from \"./config\";\nimport { getNetworkIdForAccount } from \"./network\";\nimport type { AppOrchestrator } from \"./service-descriptor\";\nimport type { BosConfig, RuntimeConfig, RuntimePluginConfig } from \"./types\";\n\nexport type { AppOrchestrator };\n\nconst DEFAULT_HOST_PORT = 3000;\nconst DEFAULT_API_PORT = 3001;\nconst DEFAULT_AUTH_PORT = 3002;\nconst DEFAULT_UI_PORT = 3003;\nconst DEFAULT_PLUGIN_PORT_START = 3010;\n\nexport function detectLocalPackages(\n bosConfig?: BosConfig,\n runtimeConfig?: RuntimeConfig,\n): string[] {\n const packages: string[] = [];\n const configDir = getProjectRoot();\n\n const uiLocalPath =\n runtimeConfig?.ui.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.ui.development, configDir);\n if (uiLocalPath && existsSync(join(uiLocalPath, \"package.json\"))) {\n packages.push(\"ui\");\n }\n\n const apiLocalPath =\n runtimeConfig?.api.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.api.development, configDir);\n if (apiLocalPath && existsSync(join(apiLocalPath, \"package.json\"))) {\n packages.push(\"api\");\n }\n\n const hostLocalPath =\n runtimeConfig?.host?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.host.development, configDir);\n if (hostLocalPath && existsSync(join(hostLocalPath, \"package.json\"))) {\n packages.push(\"host\");\n } else if (existsSync(join(configDir, \"host\", \"package.json\"))) {\n packages.push(\"host\");\n }\n\n for (const [pluginId, pluginConfig] of Object.entries(runtimeConfig?.plugins ?? {})) {\n if (pluginConfig.localPath && existsSync(join(pluginConfig.localPath, \"package.json\"))) {\n packages.push(`plugin:${pluginId}`);\n }\n }\n\n const authLocalPath =\n runtimeConfig?.auth?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.auth?.development, configDir);\n if (authLocalPath && existsSync(join(authLocalPath, \"package.json\"))) {\n packages.push(\"auth\");\n }\n\n return packages;\n}\n\nexport function buildRuntimeConfig(\n bosConfig: BosConfig,\n options: {\n hostSource?: \"local\" | \"remote\";\n uiSource?: \"local\" | \"remote\";\n apiSource?: \"local\" | \"remote\";\n authSource?: \"local\" | \"remote\";\n proxy?: string;\n env?: \"development\" | \"production\";\n plugins?: Record<string, RuntimePluginConfig>;\n },\n): RuntimeConfig {\n const configDir = getProjectRoot();\n const hostConfig = bosConfig.app.host;\n const uiConfig = bosConfig.app.ui;\n const apiConfig = bosConfig.app.api;\n const authConfig = bosConfig.app.auth;\n\n function resolveDevelopmentEntry(\n entry: { development?: string; production?: string },\n preferredSource: \"local\" | \"remote\",\n ): { source: \"local\" | \"remote\"; url: string; localPath?: string; port?: number } {\n if (preferredSource === \"remote\") {\n return { source: \"remote\", url: entry.production ?? \"\" };\n }\n\n const localPath = resolveLocalDevelopmentPath(entry.development, configDir);\n if (localPath && existsSync(localPath)) {\n return { source: \"local\", url: \"\", localPath };\n }\n\n const devUrl =\n entry.development && !isLocalDevelopmentTarget(entry.development)\n ? entry.development.replace(/\\/$/, \"\")\n : null;\n if (devUrl) {\n return { source: \"local\", url: devUrl, port: parsePort(devUrl) };\n }\n\n return { source: \"remote\", url: entry.production ?? \"\" };\n }\n\n const hostEntry = resolveDevelopmentEntry(hostConfig, options.hostSource ?? \"local\");\n const uiEntry = resolveDevelopmentEntry(uiConfig, options.uiSource ?? \"local\");\n const apiEntry = resolveDevelopmentEntry(apiConfig, options.apiSource ?? \"local\");\n const authEntry = authConfig\n ? resolveDevelopmentEntry(authConfig, options.authSource ?? \"local\")\n : undefined;\n\n const hostUrl = `http://localhost:${DEFAULT_HOST_PORT}`;\n\n return {\n env: options.env ?? \"development\",\n account: bosConfig.account,\n domain: bosConfig.domain,\n networkId: getNetworkIdForAccount(bosConfig.account),\n host: {\n name: \"host\",\n url: hostUrl,\n entry: `${hostUrl}/mf-manifest.json`,\n localPath: hostEntry.localPath,\n port: hostEntry.port ?? DEFAULT_HOST_PORT,\n secrets: hostConfig.secrets,\n integrity: hostEntry.source === \"remote\" ? hostConfig.integrity : undefined,\n source: hostEntry.source,\n remoteUrl: hostEntry.source === \"remote\" ? hostEntry.url : undefined,\n },\n shared: bosConfig.shared,\n ui: uiConfig\n ? {\n name: uiConfig.name,\n url: uiEntry.url,\n entry: uiEntry.url ? `${uiEntry.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: uiEntry.localPath,\n port: uiEntry.port,\n ssrUrl: uiEntry.source === \"remote\" ? uiConfig.ssr : undefined,\n ssrIntegrity: uiEntry.source === \"remote\" ? uiConfig.ssrIntegrity : undefined,\n integrity: uiEntry.source === \"remote\" ? uiConfig.integrity : undefined,\n source: uiEntry.source,\n }\n : {\n name: \"ui\",\n url: \"\",\n entry: \"/mf-manifest.json\",\n source: uiEntry.source,\n },\n api: apiConfig\n ? {\n name: apiConfig.name,\n url: apiEntry.url,\n entry: apiEntry.url ? `${apiEntry.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: apiEntry.localPath,\n port: apiEntry.port,\n source: apiEntry.source,\n proxy: options.proxy ?? apiConfig.proxy,\n variables: apiConfig.variables,\n secrets: apiConfig.secrets,\n integrity: apiEntry.source === \"remote\" ? apiConfig.integrity : undefined,\n }\n : {\n name: \"api\",\n url: \"\",\n entry: \"/mf-manifest.json\",\n source: apiEntry.source,\n },\n auth:\n authEntry && authConfig\n ? {\n name: resolvePluginRuntimeName(undefined, authEntry.localPath, authConfig.name),\n url: authEntry.url,\n entry: authEntry.url ? `${authEntry.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: authEntry.localPath,\n port: authEntry.port,\n source: authEntry.source,\n proxy: authConfig.proxy,\n variables: authConfig.variables,\n secrets: authConfig.secrets,\n integrity: authEntry.source === \"remote\" ? authConfig.integrity : undefined,\n }\n : undefined,\n plugins: options.plugins,\n };\n}\n\nfunction probeTcpOpen(port: number, timeoutMs = 250): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = createConnection({ host: \"127.0.0.1\", port });\n const timer = setTimeout(() => {\n socket.destroy();\n resolve(false);\n }, timeoutMs);\n\n socket.once(\"connect\", () => {\n clearTimeout(timer);\n socket.destroy();\n resolve(true);\n });\n\n socket.once(\"error\", () => {\n clearTimeout(timer);\n resolve(false);\n });\n });\n}\n\nasync function pickAvailablePort(preferred: number, usedPorts: Set<number>): Promise<number> {\n let port = preferred;\n while (usedPorts.has(port) || (await probeTcpOpen(port))) {\n port += 1;\n }\n usedPorts.add(port);\n return port;\n}\n\nfunction withLocalRuntimeUrl<\n T extends { url: string; entry: string; port?: number; localPath?: string },\n>(entry: T, port: number): T {\n const url = `http://localhost:${port}`;\n return {\n ...entry,\n url,\n entry: `${url}/mf-manifest.json`,\n port,\n };\n}\n\nexport async function prepareDevelopmentRuntimeConfig(\n runtimeConfig: RuntimeConfig,\n options?: { hostPort?: number; ssr?: boolean },\n): Promise<RuntimeConfig> {\n const usedPorts = new Set<number>();\n const hostPort = await pickAvailablePort(options?.hostPort ?? DEFAULT_HOST_PORT, usedPorts);\n\n const next: RuntimeConfig = {\n ...runtimeConfig,\n host: { ...runtimeConfig.host, url: `http://localhost:${hostPort}`, port: hostPort },\n ui: { ...runtimeConfig.ui },\n api: { ...runtimeConfig.api },\n auth: runtimeConfig.auth ? { ...runtimeConfig.auth } : undefined,\n plugins: runtimeConfig.plugins ? { ...runtimeConfig.plugins } : undefined,\n };\n\n if (next.api.source === \"local\" && next.api.localPath) {\n const apiPort = await pickAvailablePort(next.api.port ?? DEFAULT_API_PORT, usedPorts);\n next.api = withLocalRuntimeUrl(next.api, apiPort);\n }\n\n if (next.auth?.source === \"local\" && next.auth.localPath) {\n const authPort = await pickAvailablePort(next.auth.port ?? DEFAULT_AUTH_PORT, usedPorts);\n next.auth = withLocalRuntimeUrl(next.auth, authPort);\n }\n\n if (next.ui.source === \"local\" && next.ui.localPath) {\n const uiPort = await pickAvailablePort(next.ui.port ?? DEFAULT_UI_PORT, usedPorts);\n next.ui = withLocalRuntimeUrl(next.ui, uiPort);\n if (options?.ssr) {\n const ssrPort = await pickAvailablePort(uiPort + 1, usedPorts);\n next.ui.ssrUrl = `http://localhost:${ssrPort}`;\n } else {\n next.ui.ssrUrl = undefined;\n }\n }\n\n if (next.plugins) {\n const entries = Object.entries(next.plugins).sort(([a], [b]) => a.localeCompare(b));\n let pluginBasePort = DEFAULT_PLUGIN_PORT_START;\n\n for (const [pluginId, plugin] of entries) {\n if (plugin.source !== \"local\" || !plugin.localPath) {\n continue;\n }\n\n const pluginPort = await pickAvailablePort(plugin.port ?? pluginBasePort, usedPorts);\n next.plugins[pluginId] = withLocalRuntimeUrl(plugin, pluginPort);\n pluginBasePort = pluginPort + 1;\n }\n }\n\n return next;\n}\n"],"mappings":";;;;;;;;AAgBA,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;AACxB,MAAM,4BAA4B;AAElC,SAAgB,oBACd,WACA,eACU;CACV,MAAM,WAAqB,EAAE;CAC7B,MAAM,YAAYA,+BAAgB;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AAC,UAAU,WAAW,SAAS;AACxC,OAAI,OAAO,WAAW,WAAW,CAAC,OAAO,UACvC;GAGF,MAAM,aAAa,MAAM,kBAAkB,OAAO,QAAQ,gBAAgB,UAAU;AACpF,QAAK,QAAQ,YAAY,oBAAoB,QAAQ,WAAW;AAChE,oBAAiB,aAAa;;;AAIlC,QAAO"}
|
|
1
|
+
{"version":3,"file":"app.cjs","names":["getProjectRoot","resolveLocalDevelopmentPath","configBuildRuntimeConfig"],"sources":["../src/app.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { createConnection } from \"node:net\";\nimport { join } from \"node:path\";\nimport {\n buildRuntimeConfig as configBuildRuntimeConfig,\n getProjectRoot,\n resolveLocalDevelopmentPath,\n} from \"./config\";\nimport type { AppOrchestrator } from \"./service-descriptor\";\nimport type { BosConfig, RuntimeConfig, RuntimePluginConfig } from \"./types\";\n\nexport type { AppOrchestrator };\n\nconst DEFAULT_HOST_PORT = 3000;\nconst DEFAULT_API_PORT = 3001;\nconst DEFAULT_AUTH_PORT = 3002;\nconst DEFAULT_UI_PORT = 3003;\nconst DEFAULT_PLUGIN_PORT_START = 3010;\n\nexport function detectLocalPackages(\n bosConfig?: BosConfig,\n runtimeConfig?: RuntimeConfig,\n): string[] {\n const packages: string[] = [];\n const configDir = getProjectRoot();\n\n const uiLocalPath =\n runtimeConfig?.ui.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.ui.development, configDir);\n if (uiLocalPath && existsSync(join(uiLocalPath, \"package.json\"))) {\n packages.push(\"ui\");\n }\n\n const apiLocalPath =\n runtimeConfig?.api.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.api.development, configDir);\n if (apiLocalPath && existsSync(join(apiLocalPath, \"package.json\"))) {\n packages.push(\"api\");\n }\n\n const hostLocalPath =\n runtimeConfig?.host?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.host.development, configDir);\n if (hostLocalPath && existsSync(join(hostLocalPath, \"package.json\"))) {\n packages.push(\"host\");\n } else if (existsSync(join(configDir, \"host\", \"package.json\"))) {\n packages.push(\"host\");\n }\n\n for (const [pluginId, pluginConfig] of Object.entries(runtimeConfig?.plugins ?? {})) {\n if (pluginConfig.localPath && existsSync(join(pluginConfig.localPath, \"package.json\"))) {\n packages.push(`plugin:${pluginId}`);\n }\n }\n\n const authLocalPath =\n runtimeConfig?.auth?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.auth?.development, configDir);\n if (authLocalPath && existsSync(join(authLocalPath, \"package.json\"))) {\n packages.push(\"auth\");\n }\n\n return packages;\n}\n\nexport function buildRuntimeConfig(\n bosConfig: BosConfig,\n options: {\n hostSource?: \"local\" | \"remote\";\n uiSource?: \"local\" | \"remote\";\n apiSource?: \"local\" | \"remote\";\n authSource?: \"local\" | \"remote\";\n proxy?: string;\n env?: \"development\" | \"production\";\n plugins?: Record<string, RuntimePluginConfig>;\n },\n): RuntimeConfig {\n return configBuildRuntimeConfig(bosConfig, getProjectRoot(), options.env ?? \"development\", {\n hostSource: options.hostSource,\n uiSource: options.uiSource,\n apiSource: options.apiSource,\n authSource: options.authSource,\n proxy: options.proxy,\n plugins: options.plugins,\n });\n}\n\nfunction probeTcpOpen(port: number, timeoutMs = 250): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = createConnection({ host: \"127.0.0.1\", port });\n const timer = setTimeout(() => {\n socket.destroy();\n resolve(false);\n }, timeoutMs);\n\n socket.once(\"connect\", () => {\n clearTimeout(timer);\n socket.destroy();\n resolve(true);\n });\n\n socket.once(\"error\", () => {\n clearTimeout(timer);\n resolve(false);\n });\n });\n}\n\nasync function pickAvailablePort(preferred: number, usedPorts: Set<number>): Promise<number> {\n let port = preferred;\n while (usedPorts.has(port) || (await probeTcpOpen(port))) {\n port += 1;\n }\n usedPorts.add(port);\n return port;\n}\n\nfunction withLocalRuntimeUrl<\n T extends { url: string; entry: string; port?: number; localPath?: string },\n>(entry: T, port: number): T {\n const url = `http://localhost:${port}`;\n return {\n ...entry,\n url,\n entry: `${url}/mf-manifest.json`,\n port,\n };\n}\n\nexport async function prepareDevelopmentRuntimeConfig(\n runtimeConfig: RuntimeConfig,\n options?: { hostPort?: number; ssr?: boolean },\n): Promise<RuntimeConfig> {\n const usedPorts = new Set<number>();\n const hostPort = await pickAvailablePort(options?.hostPort ?? DEFAULT_HOST_PORT, usedPorts);\n\n const next: RuntimeConfig = {\n ...runtimeConfig,\n host: { ...runtimeConfig.host, url: `http://localhost:${hostPort}`, port: hostPort },\n ui: { ...runtimeConfig.ui },\n api: { ...runtimeConfig.api },\n auth: runtimeConfig.auth ? { ...runtimeConfig.auth } : undefined,\n plugins: runtimeConfig.plugins ? { ...runtimeConfig.plugins } : undefined,\n };\n\n if (next.api.source === \"local\" && next.api.localPath) {\n const apiPort = await pickAvailablePort(next.api.port ?? DEFAULT_API_PORT, usedPorts);\n next.api = withLocalRuntimeUrl(next.api, apiPort);\n }\n\n if (next.auth?.source === \"local\" && next.auth.localPath) {\n const authPort = await pickAvailablePort(next.auth.port ?? DEFAULT_AUTH_PORT, usedPorts);\n next.auth = withLocalRuntimeUrl(next.auth, authPort);\n }\n\n if (next.ui.source === \"local\" && next.ui.localPath) {\n const uiPort = await pickAvailablePort(next.ui.port ?? DEFAULT_UI_PORT, usedPorts);\n next.ui = withLocalRuntimeUrl(next.ui, uiPort);\n if (options?.ssr) {\n const ssrPort = await pickAvailablePort(uiPort + 1, usedPorts);\n next.ui.ssrUrl = `http://localhost:${ssrPort}`;\n } else {\n next.ui.ssrUrl = undefined;\n }\n }\n\n if (next.plugins) {\n const entries = Object.entries(next.plugins).sort(([a], [b]) => a.localeCompare(b));\n let pluginBasePort = DEFAULT_PLUGIN_PORT_START;\n\n for (const [pluginId, plugin] of entries) {\n if (plugin.source !== \"local\" || !plugin.localPath) {\n continue;\n }\n\n const pluginPort = await pickAvailablePort(plugin.port ?? pluginBasePort, usedPorts);\n next.plugins[pluginId] = withLocalRuntimeUrl(plugin, pluginPort);\n pluginBasePort = pluginPort + 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AI,KAAK,MAAM,WAAW,WAAW,KAAK,KAAK,WAAW;EACxD,MAAM,WAAW,MAAM,kBAAkB,KAAK,KAAK,QAAQ,mBAAmB,UAAU;AACxF,OAAK,OAAO,oBAAoB,KAAK,MAAM,SAAS;;AAGtD,KAAI,KAAK,GAAG,WAAW,WAAW,KAAK,GAAG,WAAW;EACnD,MAAM,SAAS,MAAM,kBAAkB,KAAK,GAAG,QAAQ,iBAAiB,UAAU;AAClF,OAAK,KAAK,oBAAoB,KAAK,IAAI,OAAO;AAC9C,MAAI,SAAS,KAAK;GAChB,MAAM,UAAU,MAAM,kBAAkB,SAAS,GAAG,UAAU;AAC9D,QAAK,GAAG,SAAS,oBAAoB;QAErC,MAAK,GAAG,SAAS;;AAIrB,KAAI,KAAK,SAAS;EAChB,MAAM,UAAU,OAAO,QAAQ,KAAK,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;EACnF,IAAI,iBAAiB;AAErB,OAAK,MAAM,CAAC,UAAU,WAAW,SAAS;AACxC,OAAI,OAAO,WAAW,WAAW,CAAC,OAAO,UACvC;GAGF,MAAM,aAAa,MAAM,kBAAkB,OAAO,QAAQ,gBAAgB,UAAU;AACpF,QAAK,QAAQ,YAAY,oBAAoB,QAAQ,WAAW;AAChE,oBAAiB,aAAa;;;AAIlC,QAAO"}
|
package/dist/app.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getProjectRoot, isLocalDevelopmentTarget, parsePort, resolveLocalDevelopmentPath, resolvePluginRuntimeName } from "./config.mjs";
|
|
1
|
+
import { buildRuntimeConfig as buildRuntimeConfig$1, getProjectRoot, resolveLocalDevelopmentPath } from "./config.mjs";
|
|
3
2
|
import { existsSync } from "node:fs";
|
|
4
3
|
import { join } from "node:path";
|
|
5
4
|
import { createConnection } from "node:net";
|
|
@@ -26,102 +25,14 @@ function detectLocalPackages(bosConfig, runtimeConfig) {
|
|
|
26
25
|
return packages;
|
|
27
26
|
}
|
|
28
27
|
function buildRuntimeConfig(bosConfig, options) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (preferredSource === "remote") return {
|
|
36
|
-
source: "remote",
|
|
37
|
-
url: entry.production ?? ""
|
|
38
|
-
};
|
|
39
|
-
const localPath = resolveLocalDevelopmentPath(entry.development, configDir);
|
|
40
|
-
if (localPath && existsSync(localPath)) return {
|
|
41
|
-
source: "local",
|
|
42
|
-
url: "",
|
|
43
|
-
localPath
|
|
44
|
-
};
|
|
45
|
-
const devUrl = entry.development && !isLocalDevelopmentTarget(entry.development) ? entry.development.replace(/\/$/, "") : null;
|
|
46
|
-
if (devUrl) return {
|
|
47
|
-
source: "local",
|
|
48
|
-
url: devUrl,
|
|
49
|
-
port: parsePort(devUrl)
|
|
50
|
-
};
|
|
51
|
-
return {
|
|
52
|
-
source: "remote",
|
|
53
|
-
url: entry.production ?? ""
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
const hostEntry = resolveDevelopmentEntry(hostConfig, options.hostSource ?? "local");
|
|
57
|
-
const uiEntry = resolveDevelopmentEntry(uiConfig, options.uiSource ?? "local");
|
|
58
|
-
const apiEntry = resolveDevelopmentEntry(apiConfig, options.apiSource ?? "local");
|
|
59
|
-
const authEntry = authConfig ? resolveDevelopmentEntry(authConfig, options.authSource ?? "local") : void 0;
|
|
60
|
-
const hostUrl = `http://localhost:${DEFAULT_HOST_PORT}`;
|
|
61
|
-
return {
|
|
62
|
-
env: options.env ?? "development",
|
|
63
|
-
account: bosConfig.account,
|
|
64
|
-
domain: bosConfig.domain,
|
|
65
|
-
networkId: getNetworkIdForAccount(bosConfig.account),
|
|
66
|
-
host: {
|
|
67
|
-
name: "host",
|
|
68
|
-
url: hostUrl,
|
|
69
|
-
entry: `${hostUrl}/mf-manifest.json`,
|
|
70
|
-
localPath: hostEntry.localPath,
|
|
71
|
-
port: hostEntry.port ?? DEFAULT_HOST_PORT,
|
|
72
|
-
secrets: hostConfig.secrets,
|
|
73
|
-
integrity: hostEntry.source === "remote" ? hostConfig.integrity : void 0,
|
|
74
|
-
source: hostEntry.source,
|
|
75
|
-
remoteUrl: hostEntry.source === "remote" ? hostEntry.url : void 0
|
|
76
|
-
},
|
|
77
|
-
shared: bosConfig.shared,
|
|
78
|
-
ui: uiConfig ? {
|
|
79
|
-
name: uiConfig.name,
|
|
80
|
-
url: uiEntry.url,
|
|
81
|
-
entry: uiEntry.url ? `${uiEntry.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
82
|
-
localPath: uiEntry.localPath,
|
|
83
|
-
port: uiEntry.port,
|
|
84
|
-
ssrUrl: uiEntry.source === "remote" ? uiConfig.ssr : void 0,
|
|
85
|
-
ssrIntegrity: uiEntry.source === "remote" ? uiConfig.ssrIntegrity : void 0,
|
|
86
|
-
integrity: uiEntry.source === "remote" ? uiConfig.integrity : void 0,
|
|
87
|
-
source: uiEntry.source
|
|
88
|
-
} : {
|
|
89
|
-
name: "ui",
|
|
90
|
-
url: "",
|
|
91
|
-
entry: "/mf-manifest.json",
|
|
92
|
-
source: uiEntry.source
|
|
93
|
-
},
|
|
94
|
-
api: apiConfig ? {
|
|
95
|
-
name: apiConfig.name,
|
|
96
|
-
url: apiEntry.url,
|
|
97
|
-
entry: apiEntry.url ? `${apiEntry.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
98
|
-
localPath: apiEntry.localPath,
|
|
99
|
-
port: apiEntry.port,
|
|
100
|
-
source: apiEntry.source,
|
|
101
|
-
proxy: options.proxy ?? apiConfig.proxy,
|
|
102
|
-
variables: apiConfig.variables,
|
|
103
|
-
secrets: apiConfig.secrets,
|
|
104
|
-
integrity: apiEntry.source === "remote" ? apiConfig.integrity : void 0
|
|
105
|
-
} : {
|
|
106
|
-
name: "api",
|
|
107
|
-
url: "",
|
|
108
|
-
entry: "/mf-manifest.json",
|
|
109
|
-
source: apiEntry.source
|
|
110
|
-
},
|
|
111
|
-
auth: authEntry && authConfig ? {
|
|
112
|
-
name: resolvePluginRuntimeName(void 0, authEntry.localPath, authConfig.name),
|
|
113
|
-
url: authEntry.url,
|
|
114
|
-
entry: authEntry.url ? `${authEntry.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
115
|
-
localPath: authEntry.localPath,
|
|
116
|
-
port: authEntry.port,
|
|
117
|
-
source: authEntry.source,
|
|
118
|
-
proxy: authConfig.proxy,
|
|
119
|
-
variables: authConfig.variables,
|
|
120
|
-
secrets: authConfig.secrets,
|
|
121
|
-
integrity: authEntry.source === "remote" ? authConfig.integrity : void 0
|
|
122
|
-
} : void 0,
|
|
28
|
+
return buildRuntimeConfig$1(bosConfig, getProjectRoot(), options.env ?? "development", {
|
|
29
|
+
hostSource: options.hostSource,
|
|
30
|
+
uiSource: options.uiSource,
|
|
31
|
+
apiSource: options.apiSource,
|
|
32
|
+
authSource: options.authSource,
|
|
33
|
+
proxy: options.proxy,
|
|
123
34
|
plugins: options.plugins
|
|
124
|
-
};
|
|
35
|
+
});
|
|
125
36
|
}
|
|
126
37
|
function probeTcpOpen(port, timeoutMs = 250) {
|
|
127
38
|
return new Promise((resolve) => {
|
package/dist/app.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.mjs","names":[],"sources":["../src/app.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { createConnection } from \"node:net\";\nimport { join } from \"node:path\";\nimport {\n getProjectRoot,\n isLocalDevelopmentTarget,\n parsePort,\n resolveLocalDevelopmentPath,\n resolvePluginRuntimeName,\n} from \"./config\";\nimport { getNetworkIdForAccount } from \"./network\";\nimport type { AppOrchestrator } from \"./service-descriptor\";\nimport type { BosConfig, RuntimeConfig, RuntimePluginConfig } from \"./types\";\n\nexport type { AppOrchestrator };\n\nconst DEFAULT_HOST_PORT = 3000;\nconst DEFAULT_API_PORT = 3001;\nconst DEFAULT_AUTH_PORT = 3002;\nconst DEFAULT_UI_PORT = 3003;\nconst DEFAULT_PLUGIN_PORT_START = 3010;\n\nexport function detectLocalPackages(\n bosConfig?: BosConfig,\n runtimeConfig?: RuntimeConfig,\n): string[] {\n const packages: string[] = [];\n const configDir = getProjectRoot();\n\n const uiLocalPath =\n runtimeConfig?.ui.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.ui.development, configDir);\n if (uiLocalPath && existsSync(join(uiLocalPath, \"package.json\"))) {\n packages.push(\"ui\");\n }\n\n const apiLocalPath =\n runtimeConfig?.api.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.api.development, configDir);\n if (apiLocalPath && existsSync(join(apiLocalPath, \"package.json\"))) {\n packages.push(\"api\");\n }\n\n const hostLocalPath =\n runtimeConfig?.host?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.host.development, configDir);\n if (hostLocalPath && existsSync(join(hostLocalPath, \"package.json\"))) {\n packages.push(\"host\");\n } else if (existsSync(join(configDir, \"host\", \"package.json\"))) {\n packages.push(\"host\");\n }\n\n for (const [pluginId, pluginConfig] of Object.entries(runtimeConfig?.plugins ?? {})) {\n if (pluginConfig.localPath && existsSync(join(pluginConfig.localPath, \"package.json\"))) {\n packages.push(`plugin:${pluginId}`);\n }\n }\n\n const authLocalPath =\n runtimeConfig?.auth?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.auth?.development, configDir);\n if (authLocalPath && existsSync(join(authLocalPath, \"package.json\"))) {\n packages.push(\"auth\");\n }\n\n return packages;\n}\n\nexport function buildRuntimeConfig(\n bosConfig: BosConfig,\n options: {\n hostSource?: \"local\" | \"remote\";\n uiSource?: \"local\" | \"remote\";\n apiSource?: \"local\" | \"remote\";\n authSource?: \"local\" | \"remote\";\n proxy?: string;\n env?: \"development\" | \"production\";\n plugins?: Record<string, RuntimePluginConfig>;\n },\n): RuntimeConfig {\n const configDir = getProjectRoot();\n const hostConfig = bosConfig.app.host;\n const uiConfig = bosConfig.app.ui;\n const apiConfig = bosConfig.app.api;\n const authConfig = bosConfig.app.auth;\n\n function resolveDevelopmentEntry(\n entry: { development?: string; production?: string },\n preferredSource: \"local\" | \"remote\",\n ): { source: \"local\" | \"remote\"; url: string; localPath?: string; port?: number } {\n if (preferredSource === \"remote\") {\n return { source: \"remote\", url: entry.production ?? \"\" };\n }\n\n const localPath = resolveLocalDevelopmentPath(entry.development, configDir);\n if (localPath && existsSync(localPath)) {\n return { source: \"local\", url: \"\", localPath };\n }\n\n const devUrl =\n entry.development && !isLocalDevelopmentTarget(entry.development)\n ? entry.development.replace(/\\/$/, \"\")\n : null;\n if (devUrl) {\n return { source: \"local\", url: devUrl, port: parsePort(devUrl) };\n }\n\n return { source: \"remote\", url: entry.production ?? \"\" };\n }\n\n const hostEntry = resolveDevelopmentEntry(hostConfig, options.hostSource ?? \"local\");\n const uiEntry = resolveDevelopmentEntry(uiConfig, options.uiSource ?? \"local\");\n const apiEntry = resolveDevelopmentEntry(apiConfig, options.apiSource ?? \"local\");\n const authEntry = authConfig\n ? resolveDevelopmentEntry(authConfig, options.authSource ?? \"local\")\n : undefined;\n\n const hostUrl = `http://localhost:${DEFAULT_HOST_PORT}`;\n\n return {\n env: options.env ?? \"development\",\n account: bosConfig.account,\n domain: bosConfig.domain,\n networkId: getNetworkIdForAccount(bosConfig.account),\n host: {\n name: \"host\",\n url: hostUrl,\n entry: `${hostUrl}/mf-manifest.json`,\n localPath: hostEntry.localPath,\n port: hostEntry.port ?? DEFAULT_HOST_PORT,\n secrets: hostConfig.secrets,\n integrity: hostEntry.source === \"remote\" ? hostConfig.integrity : undefined,\n source: hostEntry.source,\n remoteUrl: hostEntry.source === \"remote\" ? hostEntry.url : undefined,\n },\n shared: bosConfig.shared,\n ui: uiConfig\n ? {\n name: uiConfig.name,\n url: uiEntry.url,\n entry: uiEntry.url ? `${uiEntry.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: uiEntry.localPath,\n port: uiEntry.port,\n ssrUrl: uiEntry.source === \"remote\" ? uiConfig.ssr : undefined,\n ssrIntegrity: uiEntry.source === \"remote\" ? uiConfig.ssrIntegrity : undefined,\n integrity: uiEntry.source === \"remote\" ? uiConfig.integrity : undefined,\n source: uiEntry.source,\n }\n : {\n name: \"ui\",\n url: \"\",\n entry: \"/mf-manifest.json\",\n source: uiEntry.source,\n },\n api: apiConfig\n ? {\n name: apiConfig.name,\n url: apiEntry.url,\n entry: apiEntry.url ? `${apiEntry.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: apiEntry.localPath,\n port: apiEntry.port,\n source: apiEntry.source,\n proxy: options.proxy ?? apiConfig.proxy,\n variables: apiConfig.variables,\n secrets: apiConfig.secrets,\n integrity: apiEntry.source === \"remote\" ? apiConfig.integrity : undefined,\n }\n : {\n name: \"api\",\n url: \"\",\n entry: \"/mf-manifest.json\",\n source: apiEntry.source,\n },\n auth:\n authEntry && authConfig\n ? {\n name: resolvePluginRuntimeName(undefined, authEntry.localPath, authConfig.name),\n url: authEntry.url,\n entry: authEntry.url ? `${authEntry.url}/mf-manifest.json` : \"/mf-manifest.json\",\n localPath: authEntry.localPath,\n port: authEntry.port,\n source: authEntry.source,\n proxy: authConfig.proxy,\n variables: authConfig.variables,\n secrets: authConfig.secrets,\n integrity: authEntry.source === \"remote\" ? authConfig.integrity : undefined,\n }\n : undefined,\n plugins: options.plugins,\n };\n}\n\nfunction probeTcpOpen(port: number, timeoutMs = 250): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = createConnection({ host: \"127.0.0.1\", port });\n const timer = setTimeout(() => {\n socket.destroy();\n resolve(false);\n }, timeoutMs);\n\n socket.once(\"connect\", () => {\n clearTimeout(timer);\n socket.destroy();\n resolve(true);\n });\n\n socket.once(\"error\", () => {\n clearTimeout(timer);\n resolve(false);\n });\n });\n}\n\nasync function pickAvailablePort(preferred: number, usedPorts: Set<number>): Promise<number> {\n let port = preferred;\n while (usedPorts.has(port) || (await probeTcpOpen(port))) {\n port += 1;\n }\n usedPorts.add(port);\n return port;\n}\n\nfunction withLocalRuntimeUrl<\n T extends { url: string; entry: string; port?: number; localPath?: string },\n>(entry: T, port: number): T {\n const url = `http://localhost:${port}`;\n return {\n ...entry,\n url,\n entry: `${url}/mf-manifest.json`,\n port,\n };\n}\n\nexport async function prepareDevelopmentRuntimeConfig(\n runtimeConfig: RuntimeConfig,\n options?: { hostPort?: number; ssr?: boolean },\n): Promise<RuntimeConfig> {\n const usedPorts = new Set<number>();\n const hostPort = await pickAvailablePort(options?.hostPort ?? DEFAULT_HOST_PORT, usedPorts);\n\n const next: RuntimeConfig = {\n ...runtimeConfig,\n host: { ...runtimeConfig.host, url: `http://localhost:${hostPort}`, port: hostPort },\n ui: { ...runtimeConfig.ui },\n api: { ...runtimeConfig.api },\n auth: runtimeConfig.auth ? { ...runtimeConfig.auth } : undefined,\n plugins: runtimeConfig.plugins ? { ...runtimeConfig.plugins } : undefined,\n };\n\n if (next.api.source === \"local\" && next.api.localPath) {\n const apiPort = await pickAvailablePort(next.api.port ?? DEFAULT_API_PORT, usedPorts);\n next.api = withLocalRuntimeUrl(next.api, apiPort);\n }\n\n if (next.auth?.source === \"local\" && next.auth.localPath) {\n const authPort = await pickAvailablePort(next.auth.port ?? DEFAULT_AUTH_PORT, usedPorts);\n next.auth = withLocalRuntimeUrl(next.auth, authPort);\n }\n\n if (next.ui.source === \"local\" && next.ui.localPath) {\n const uiPort = await pickAvailablePort(next.ui.port ?? DEFAULT_UI_PORT, usedPorts);\n next.ui = withLocalRuntimeUrl(next.ui, uiPort);\n if (options?.ssr) {\n const ssrPort = await pickAvailablePort(uiPort + 1, usedPorts);\n next.ui.ssrUrl = `http://localhost:${ssrPort}`;\n } else {\n next.ui.ssrUrl = undefined;\n }\n }\n\n if (next.plugins) {\n const entries = Object.entries(next.plugins).sort(([a], [b]) => a.localeCompare(b));\n let pluginBasePort = DEFAULT_PLUGIN_PORT_START;\n\n for (const [pluginId, plugin] of entries) {\n if (plugin.source !== \"local\" || !plugin.localPath) {\n continue;\n }\n\n const pluginPort = await pickAvailablePort(plugin.port ?? pluginBasePort, usedPorts);\n next.plugins[pluginId] = withLocalRuntimeUrl(plugin, pluginPort);\n pluginBasePort = pluginPort + 1;\n }\n }\n\n return next;\n}\n"],"mappings":";;;;;;;AAgBA,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;AACxB,MAAM,4BAA4B;AAElC,SAAgB,oBACd,WACA,eACU;CACV,MAAM,WAAqB,EAAE;CAC7B,MAAM,YAAY,gBAAgB;CAElC,MAAM,cACJ,eAAe,GAAG,aAClB,4BAA4B,WAAW,IAAI,GAAG,aAAa,UAAU;AACvE,KAAI,eAAe,WAAW,KAAK,aAAa,eAAe,CAAC,CAC9D,UAAS,KAAK,KAAK;CAGrB,MAAM,eACJ,eAAe,IAAI,aACnB,4BAA4B,WAAW,IAAI,IAAI,aAAa,UAAU;AACxE,KAAI,gBAAgB,WAAW,KAAK,cAAc,eAAe,CAAC,CAChE,UAAS,KAAK,MAAM;CAGtB,MAAM,gBACJ,eAAe,MAAM,aACrB,4BAA4B,WAAW,IAAI,KAAK,aAAa,UAAU;AACzE,KAAI,iBAAiB,WAAW,KAAK,eAAe,eAAe,CAAC,CAClE,UAAS,KAAK,OAAO;UACZ,WAAW,KAAK,WAAW,QAAQ,eAAe,CAAC,CAC5D,UAAS,KAAK,OAAO;AAGvB,MAAK,MAAM,CAAC,UAAU,iBAAiB,OAAO,QAAQ,eAAe,WAAW,EAAE,CAAC,CACjF,KAAI,aAAa,aAAa,WAAW,KAAK,aAAa,WAAW,eAAe,CAAC,CACpF,UAAS,KAAK,UAAU,WAAW;CAIvC,MAAM,gBACJ,eAAe,MAAM,aACrB,4BAA4B,WAAW,IAAI,MAAM,aAAa,UAAU;AAC1E,KAAI,iBAAiB,WAAW,KAAK,eAAe,eAAe,CAAC,CAClE,UAAS,KAAK,OAAO;AAGvB,QAAO;;AAGT,SAAgB,mBACd,WACA,SASe;CACf,MAAM,YAAY,gBAAg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,kBAAkB,KAAK,GAAG,QAAQ,iBAAiB,UAAU;AAClF,OAAK,KAAK,oBAAoB,KAAK,IAAI,OAAO;AAC9C,MAAI,SAAS,KAAK;GAChB,MAAM,UAAU,MAAM,kBAAkB,SAAS,GAAG,UAAU;AAC9D,QAAK,GAAG,SAAS,oBAAoB;QAErC,MAAK,GAAG,SAAS;;AAIrB,KAAI,KAAK,SAAS;EAChB,MAAM,UAAU,OAAO,QAAQ,KAAK,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;EACnF,IAAI,iBAAiB;AAErB,OAAK,MAAM,CAAC,UAAU,WAAW,SAAS;AACxC,OAAI,OAAO,WAAW,WAAW,CAAC,OAAO,UACvC;GAGF,MAAM,aAAa,MAAM,kBAAkB,OAAO,QAAQ,gBAAgB,UAAU;AACpF,QAAK,QAAQ,YAAY,oBAAoB,QAAQ,WAAW;AAChE,oBAAiB,aAAa;;;AAIlC,QAAO"}
|
|
1
|
+
{"version":3,"file":"app.mjs","names":["configBuildRuntimeConfig"],"sources":["../src/app.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { createConnection } from \"node:net\";\nimport { join } from \"node:path\";\nimport {\n buildRuntimeConfig as configBuildRuntimeConfig,\n getProjectRoot,\n resolveLocalDevelopmentPath,\n} from \"./config\";\nimport type { AppOrchestrator } from \"./service-descriptor\";\nimport type { BosConfig, RuntimeConfig, RuntimePluginConfig } from \"./types\";\n\nexport type { AppOrchestrator };\n\nconst DEFAULT_HOST_PORT = 3000;\nconst DEFAULT_API_PORT = 3001;\nconst DEFAULT_AUTH_PORT = 3002;\nconst DEFAULT_UI_PORT = 3003;\nconst DEFAULT_PLUGIN_PORT_START = 3010;\n\nexport function detectLocalPackages(\n bosConfig?: BosConfig,\n runtimeConfig?: RuntimeConfig,\n): string[] {\n const packages: string[] = [];\n const configDir = getProjectRoot();\n\n const uiLocalPath =\n runtimeConfig?.ui.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.ui.development, configDir);\n if (uiLocalPath && existsSync(join(uiLocalPath, \"package.json\"))) {\n packages.push(\"ui\");\n }\n\n const apiLocalPath =\n runtimeConfig?.api.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.api.development, configDir);\n if (apiLocalPath && existsSync(join(apiLocalPath, \"package.json\"))) {\n packages.push(\"api\");\n }\n\n const hostLocalPath =\n runtimeConfig?.host?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.host.development, configDir);\n if (hostLocalPath && existsSync(join(hostLocalPath, \"package.json\"))) {\n packages.push(\"host\");\n } else if (existsSync(join(configDir, \"host\", \"package.json\"))) {\n packages.push(\"host\");\n }\n\n for (const [pluginId, pluginConfig] of Object.entries(runtimeConfig?.plugins ?? {})) {\n if (pluginConfig.localPath && existsSync(join(pluginConfig.localPath, \"package.json\"))) {\n packages.push(`plugin:${pluginId}`);\n }\n }\n\n const authLocalPath =\n runtimeConfig?.auth?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.app.auth?.development, configDir);\n if (authLocalPath && existsSync(join(authLocalPath, \"package.json\"))) {\n packages.push(\"auth\");\n }\n\n return packages;\n}\n\nexport function buildRuntimeConfig(\n bosConfig: BosConfig,\n options: {\n hostSource?: \"local\" | \"remote\";\n uiSource?: \"local\" | \"remote\";\n apiSource?: \"local\" | \"remote\";\n authSource?: \"local\" | \"remote\";\n proxy?: string;\n env?: \"development\" | \"production\";\n plugins?: Record<string, RuntimePluginConfig>;\n },\n): RuntimeConfig {\n return configBuildRuntimeConfig(bosConfig, getProjectRoot(), options.env ?? \"development\", {\n hostSource: options.hostSource,\n uiSource: options.uiSource,\n apiSource: options.apiSource,\n authSource: options.authSource,\n proxy: options.proxy,\n plugins: options.plugins,\n });\n}\n\nfunction probeTcpOpen(port: number, timeoutMs = 250): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = createConnection({ host: \"127.0.0.1\", port });\n const timer = setTimeout(() => {\n socket.destroy();\n resolve(false);\n }, timeoutMs);\n\n socket.once(\"connect\", () => {\n clearTimeout(timer);\n socket.destroy();\n resolve(true);\n });\n\n socket.once(\"error\", () => {\n clearTimeout(timer);\n resolve(false);\n });\n });\n}\n\nasync function pickAvailablePort(preferred: number, usedPorts: Set<number>): Promise<number> {\n let port = preferred;\n while (usedPorts.has(port) || (await probeTcpOpen(port))) {\n port += 1;\n }\n usedPorts.add(port);\n return port;\n}\n\nfunction withLocalRuntimeUrl<\n T extends { url: string; entry: string; port?: number; localPath?: string },\n>(entry: T, port: number): T {\n const url = `http://localhost:${port}`;\n return {\n ...entry,\n url,\n entry: `${url}/mf-manifest.json`,\n port,\n };\n}\n\nexport async function prepareDevelopmentRuntimeConfig(\n runtimeConfig: RuntimeConfig,\n options?: { hostPort?: number; ssr?: boolean },\n): Promise<RuntimeConfig> {\n const usedPorts = new Set<number>();\n const hostPort = await pickAvailablePort(options?.hostPort ?? DEFAULT_HOST_PORT, usedPorts);\n\n const next: RuntimeConfig = {\n ...runtimeConfig,\n host: { ...runtimeConfig.host, url: `http://localhost:${hostPort}`, port: hostPort },\n ui: { ...runtimeConfig.ui },\n api: { ...runtimeConfig.api },\n auth: runtimeConfig.auth ? { ...runtimeConfig.auth } : undefined,\n plugins: runtimeConfig.plugins ? { ...runtimeConfig.plugins } : undefined,\n };\n\n if (next.api.source === \"local\" && next.api.localPath) {\n const apiPort = await pickAvailablePort(next.api.port ?? DEFAULT_API_PORT, usedPorts);\n next.api = withLocalRuntimeUrl(next.api, apiPort);\n }\n\n if (next.auth?.source === \"local\" && next.auth.localPath) {\n const authPort = await pickAvailablePort(next.auth.port ?? DEFAULT_AUTH_PORT, usedPorts);\n next.auth = withLocalRuntimeUrl(next.auth, authPort);\n }\n\n if (next.ui.source === \"local\" && next.ui.localPath) {\n const uiPort = await pickAvailablePort(next.ui.port ?? DEFAULT_UI_PORT, usedPorts);\n next.ui = withLocalRuntimeUrl(next.ui, uiPort);\n if (options?.ssr) {\n const ssrPort = await pickAvailablePort(uiPort + 1, usedPorts);\n next.ui.ssrUrl = `http://localhost:${ssrPort}`;\n } else {\n next.ui.ssrUrl = undefined;\n }\n }\n\n if (next.plugins) {\n const entries = Object.entries(next.plugins).sort(([a], [b]) => a.localeCompare(b));\n let pluginBasePort = DEFAULT_PLUGIN_PORT_START;\n\n for (const [pluginId, plugin] of entries) {\n if (plugin.source !== \"local\" || !plugin.localPath) {\n continue;\n }\n\n const pluginPort = await pickAvailablePort(plugin.port ?? pluginBasePort, usedPorts);\n next.plugins[pluginId] = withLocalRuntimeUrl(plugin, pluginPort);\n pluginBasePort = pluginPort + 1;\n }\n }\n\n return next;\n}\n"],"mappings":";;;;;;AAaA,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;AACxB,MAAM,4BAA4B;AAElC,SAAgB,oBACd,WACA,eACU;CACV,MAAM,WAAqB,EAAE;CAC7B,MAAM,YAAY,gBAAgB;CAElC,MAAM,cACJ,eAAe,GAAG,aAClB,4BAA4B,WAAW,IAAI,GAAG,aAAa,UAAU;AACvE,KAAI,eAAe,WAAW,KAAK,aAAa,eAAe,CAAC,CAC9D,UAAS,KAAK,KAAK;CAGrB,MAAM,eACJ,eAAe,IAAI,aACnB,4BAA4B,WAAW,IAAI,IAAI,aAAa,UAAU;AACxE,KAAI,gBAAgB,WAAW,KAAK,cAAc,eAAe,CAAC,CAChE,UAAS,KAAK,MAAM;CAGtB,MAAM,gBACJ,eAAe,MAAM,aACrB,4BAA4B,WAAW,IAAI,KAAK,aAAa,UAAU;AACzE,KAAI,iBAAiB,WAAW,KAAK,eAAe,eAAe,CAAC,CAClE,UAAS,KAAK,OAAO;UACZ,WAAW,KAAK,WAAW,QAAQ,eAAe,CAAC,CAC5D,UAAS,KAAK,OAAO;AAGvB,MAAK,MAAM,CAAC,UAAU,iBAAiB,OAAO,QAAQ,eAAe,WAAW,EAAE,CAAC,CACjF,KAAI,aAAa,aAAa,WAAW,KAAK,aAAa,WAAW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AW;AAChE,oBAAiB,aAAa;;;AAIlC,QAAO"}
|
package/dist/config.cjs
CHANGED
|
@@ -67,7 +67,8 @@ async function buildRuntimePluginsForConfig(config, baseDir, env) {
|
|
|
67
67
|
const plugins = await resolveRuntimePlugins(config.plugins ?? {}, baseDir, env);
|
|
68
68
|
return Object.keys(plugins).length > 0 ? plugins : void 0;
|
|
69
69
|
}
|
|
70
|
-
function resolveDevelopmentTarget(development, production, baseDir) {
|
|
70
|
+
function resolveDevelopmentTarget(development, production, baseDir, forceSource) {
|
|
71
|
+
if (forceSource === "remote") return resolveRuntimeTarget(production, baseDir, "remote");
|
|
71
72
|
const devTarget = resolveRuntimeTarget(development, baseDir);
|
|
72
73
|
if (devTarget.source === "local" && (!devTarget.localPath || !(0, node_fs.existsSync)(devTarget.localPath))) return resolveRuntimeTarget(production, baseDir, "remote");
|
|
73
74
|
return devTarget;
|
|
@@ -76,12 +77,15 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
76
77
|
const uiConfig = config.app.ui;
|
|
77
78
|
const apiConfig = config.app.api;
|
|
78
79
|
const authConfig = config.app.auth;
|
|
79
|
-
const uiRuntime = env === "development" ? resolveDevelopmentTarget(uiConfig.development, uiConfig.production, baseDir) : resolveRuntimeTarget(uiConfig.production, baseDir, "remote");
|
|
80
|
-
const apiRuntime = env === "development" ? resolveDevelopmentTarget(apiConfig.development, apiConfig.production, baseDir) : resolveRuntimeTarget(apiConfig.production, baseDir, "remote");
|
|
81
|
-
const authRuntime = authConfig ? env === "development" ? resolveDevelopmentTarget(authConfig.development, authConfig.production, baseDir) : resolveRuntimeTarget(authConfig.production, baseDir, "remote") : void 0;
|
|
80
|
+
const uiRuntime = env === "development" ? resolveDevelopmentTarget(uiConfig.development, uiConfig.production, baseDir, options?.uiSource) : resolveRuntimeTarget(uiConfig.production, baseDir, "remote");
|
|
81
|
+
const apiRuntime = env === "development" ? resolveDevelopmentTarget(apiConfig.development, apiConfig.production, baseDir, options?.apiSource) : resolveRuntimeTarget(apiConfig.production, baseDir, "remote");
|
|
82
|
+
const authRuntime = authConfig ? env === "development" ? resolveDevelopmentTarget(authConfig.development, authConfig.production, baseDir, options?.authSource) : resolveRuntimeTarget(authConfig.production, baseDir, "remote") : void 0;
|
|
82
83
|
const hostConfig = config.app.host;
|
|
83
|
-
const hostRuntime = env === "development" ? resolveDevelopmentTarget(hostConfig.development, hostConfig.production, baseDir) : resolveRuntimeTarget(hostConfig.production, baseDir, "remote");
|
|
84
|
+
const hostRuntime = env === "development" ? resolveDevelopmentTarget(hostConfig.development, hostConfig.production, baseDir, options?.hostSource) : resolveRuntimeTarget(hostConfig.production, baseDir, "remote");
|
|
84
85
|
const hostListeningUrl = resolveDevelopmentHostUrl(hostConfig.development);
|
|
86
|
+
const hostIsRemote = hostRuntime.source === "remote";
|
|
87
|
+
const uiIsRemote = uiRuntime.source === "remote";
|
|
88
|
+
const apiIsRemote = apiRuntime.source === "remote";
|
|
85
89
|
return {
|
|
86
90
|
env,
|
|
87
91
|
account: config.account,
|
|
@@ -95,9 +99,9 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
95
99
|
localPath: hostRuntime.localPath,
|
|
96
100
|
port: hostRuntime.port ?? DEFAULT_HOST_PORT,
|
|
97
101
|
secrets: hostConfig.secrets,
|
|
98
|
-
integrity:
|
|
102
|
+
integrity: hostIsRemote ? hostConfig.integrity : void 0,
|
|
99
103
|
source: hostRuntime.source,
|
|
100
|
-
remoteUrl:
|
|
104
|
+
remoteUrl: hostIsRemote ? hostRuntime.url : void 0
|
|
101
105
|
},
|
|
102
106
|
shared: config.shared,
|
|
103
107
|
ui: {
|
|
@@ -106,9 +110,9 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
106
110
|
entry: uiRuntime.url ? `${uiRuntime.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
107
111
|
localPath: uiRuntime.localPath,
|
|
108
112
|
port: uiRuntime.port,
|
|
109
|
-
ssrUrl: uiConfig.ssr,
|
|
110
|
-
ssrIntegrity:
|
|
111
|
-
integrity:
|
|
113
|
+
ssrUrl: uiIsRemote ? uiConfig.ssr : void 0,
|
|
114
|
+
ssrIntegrity: uiIsRemote ? uiConfig.ssrIntegrity : void 0,
|
|
115
|
+
integrity: uiIsRemote ? uiConfig.integrity : void 0,
|
|
112
116
|
source: uiRuntime.source
|
|
113
117
|
},
|
|
114
118
|
api: {
|
|
@@ -118,10 +122,10 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
118
122
|
localPath: apiRuntime.localPath,
|
|
119
123
|
port: apiRuntime.port,
|
|
120
124
|
source: apiRuntime.source,
|
|
121
|
-
proxy: apiConfig.proxy,
|
|
125
|
+
proxy: options?.proxy ?? apiConfig.proxy,
|
|
122
126
|
variables: apiConfig.variables,
|
|
123
127
|
secrets: apiConfig.secrets,
|
|
124
|
-
integrity:
|
|
128
|
+
integrity: apiIsRemote ? apiConfig.integrity : void 0
|
|
125
129
|
},
|
|
126
130
|
auth: authConfig ? {
|
|
127
131
|
name: resolvePluginRuntimeName(void 0, authRuntime.localPath, authConfig.name),
|
|
@@ -133,7 +137,7 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
133
137
|
proxy: authConfig.proxy,
|
|
134
138
|
variables: authConfig.variables,
|
|
135
139
|
secrets: authConfig.secrets,
|
|
136
|
-
integrity:
|
|
140
|
+
integrity: authRuntime.source === "remote" ? authConfig.integrity : void 0
|
|
137
141
|
} : void 0,
|
|
138
142
|
plugins: options?.plugins && Object.keys(options.plugins).length > 0 ? options.plugins : void 0
|
|
139
143
|
};
|
|
@@ -305,6 +309,7 @@ function parsePort(url) {
|
|
|
305
309
|
|
|
306
310
|
//#endregion
|
|
307
311
|
exports.BosConfigSchema = require_types.BosConfigSchema;
|
|
312
|
+
exports.buildRuntimeConfig = buildRuntimeConfig;
|
|
308
313
|
exports.buildRuntimePluginsForConfig = buildRuntimePluginsForConfig;
|
|
309
314
|
exports.clearConfigCache = clearConfigCache;
|
|
310
315
|
exports.findConfigPath = findConfigPath;
|
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): RuntimeTarget {\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\nfunction buildRuntimeConfig(\n config: BosConfig,\n baseDir: string,\n env: \"development\" | \"production\",\n options?: { plugins?: Record<string, RuntimePluginConfig> },\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(uiConfig.development, uiConfig.production, baseDir)\n : resolveRuntimeTarget(uiConfig.production, baseDir, \"remote\");\n const apiRuntime =\n env === \"development\"\n ? resolveDevelopmentTarget(apiConfig.development, apiConfig.production, baseDir)\n : resolveRuntimeTarget(apiConfig.production, baseDir, \"remote\");\n const authRuntime = authConfig\n ? env === \"development\"\n ? resolveDevelopmentTarget(authConfig.development, authConfig.production, baseDir)\n : resolveRuntimeTarget(authConfig.production, baseDir, \"remote\")\n : undefined;\n\n const hostConfig = config.app.host;\n const hostRuntime =\n env === \"development\"\n ? resolveDevelopmentTarget(hostConfig.development, hostConfig.production, baseDir)\n : resolveRuntimeTarget(hostConfig.production, baseDir, \"remote\");\n\n const hostListeningUrl = resolveDevelopmentHostUrl(hostConfig.development);\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: env === \"production\" ? hostConfig.integrity : undefined,\n source: hostRuntime.source,\n remoteUrl: hostRuntime.source === \"remote\" ? 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: uiConfig.ssr,\n ssrIntegrity: env === \"production\" ? uiConfig.ssrIntegrity : undefined,\n integrity: env === \"production\" ? 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: apiConfig.proxy,\n variables: apiConfig.variables,\n secrets: apiConfig.secrets,\n integrity: env === \"production\" ? 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: env === \"production\" ? 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,MAA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BAAoC,UACrB;AACf,KAAI,CAAC,MACH,QAAO;EAAE,QAAQ;EAAe,KAAK;EAAI;AAG3C,KAAI,MAAM,WAAW,aAAa,EAAE;EAClC,MAAM,cAAc,MAAM,MAAM,EAAoB,CAAC,MAAM;AAC3D,MAAI,CAAC,YACH,OAAM,IAAI,MAAM,qCAAqC,QAAQ;EAG/D,MAAM,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","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;A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B,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"}
|
package/dist/config.d.cts
CHANGED
|
@@ -25,6 +25,15 @@ declare function loadBosConfig(options?: {
|
|
|
25
25
|
env?: "development" | "production";
|
|
26
26
|
}): Promise<RuntimeConfig>;
|
|
27
27
|
declare function buildRuntimePluginsForConfig(config: BosConfig, baseDir: string, env: "development" | "production"): Promise<Record<string, RuntimePluginConfig> | undefined>;
|
|
28
|
+
interface BuildRuntimeConfigOptions {
|
|
29
|
+
plugins?: Record<string, RuntimePluginConfig>;
|
|
30
|
+
hostSource?: "local" | "remote";
|
|
31
|
+
uiSource?: "local" | "remote";
|
|
32
|
+
apiSource?: "local" | "remote";
|
|
33
|
+
authSource?: "local" | "remote";
|
|
34
|
+
proxy?: string;
|
|
35
|
+
}
|
|
36
|
+
declare function buildRuntimeConfig(config: BosConfig, baseDir: string, env: "development" | "production", options?: BuildRuntimeConfigOptions): RuntimeConfig;
|
|
28
37
|
declare function resolvePluginRuntimeName(explicitName: string | undefined, localPath: string | undefined, fallback: string): string;
|
|
29
38
|
declare function isLocalDevelopmentTarget(value: string | undefined): boolean;
|
|
30
39
|
declare function resolveLocalDevelopmentPath(value: string | undefined, baseDir: string): string | null;
|
|
@@ -32,5 +41,5 @@ declare function resolveDevelopmentHostUrl(value: string | undefined): string;
|
|
|
32
41
|
declare function getHostDevelopmentPort(value: string | undefined): number;
|
|
33
42
|
declare function parsePort(url: string): number;
|
|
34
43
|
//#endregion
|
|
35
|
-
export { type BosConfig, BosConfigSchema, ConfigResult, type RuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName };
|
|
44
|
+
export { type BosConfig, BosConfigSchema, BuildRuntimeConfigOptions, ConfigResult, type RuntimeConfig, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName };
|
|
36
45
|
//# 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":";;;iBAoBgB,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;AAAA,IACE,OAAA,CAAQ,YAAA;AAAA,iBAwCU,aAAA,CAAc,OAAA;EAClC,GAAA;EACA,IAAA;EACA,GAAA;AAAA,IACE,OAAA,CAAQ,aAAA;AAAA,iBASU,4BAAA,CACpB,MAAA,EAAQ,SAAA,EACR,OAAA,UACA,GAAA,iCACC,OAAA,CAAQ,MAAA,SAAe,mBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":";;;iBAoBgB,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;AAAA,IACE,OAAA,CAAQ,YAAA;AAAA,iBAwCU,aAAA,CAAc,OAAA;EAClC,GAAA;EACA,IAAA;EACA,GAAA;AAAA,IACE,OAAA,CAAQ,aAAA;AAAA,iBASU,4BAAA,CACpB,MAAA,EAAQ,SAAA,EACR,OAAA,UACA,GAAA,iCACC,OAAA,CAAQ,MAAA,SAAe,mBAAA;AAAA,UAqBT,yBAAA;EACf,OAAA,GAAU,MAAA,SAAe,mBAAA;EACzB,UAAA;EACA,QAAA;EACA,SAAA;EACA,UAAA;EACA,KAAA;AAAA;AAAA,iBAGc,kBAAA,CACd,MAAA,EAAQ,SAAA,EACR,OAAA,UACA,GAAA,gCACA,OAAA,GAAU,yBAAA,GACT,aAAA;AAAA,iBA2Ra,wBAAA,CACd,YAAA,sBACA,SAAA,sBACA,QAAA;AAAA,iBA+Gc,wBAAA,CAAyB,KAAA;AAAA,iBAIzB,2BAAA,CACd,KAAA,sBACA,OAAA;AAAA,iBAUc,yBAAA,CAA0B,KAAA;AAAA,iBAQ1B,sBAAA,CAAuB,KAAA;AAAA,iBAIvB,SAAA,CAAU,GAAA"}
|
package/dist/config.d.mts
CHANGED
|
@@ -25,6 +25,15 @@ declare function loadBosConfig(options?: {
|
|
|
25
25
|
env?: "development" | "production";
|
|
26
26
|
}): Promise<RuntimeConfig>;
|
|
27
27
|
declare function buildRuntimePluginsForConfig(config: BosConfig, baseDir: string, env: "development" | "production"): Promise<Record<string, RuntimePluginConfig> | undefined>;
|
|
28
|
+
interface BuildRuntimeConfigOptions {
|
|
29
|
+
plugins?: Record<string, RuntimePluginConfig>;
|
|
30
|
+
hostSource?: "local" | "remote";
|
|
31
|
+
uiSource?: "local" | "remote";
|
|
32
|
+
apiSource?: "local" | "remote";
|
|
33
|
+
authSource?: "local" | "remote";
|
|
34
|
+
proxy?: string;
|
|
35
|
+
}
|
|
36
|
+
declare function buildRuntimeConfig(config: BosConfig, baseDir: string, env: "development" | "production", options?: BuildRuntimeConfigOptions): RuntimeConfig;
|
|
28
37
|
declare function resolvePluginRuntimeName(explicitName: string | undefined, localPath: string | undefined, fallback: string): string;
|
|
29
38
|
declare function isLocalDevelopmentTarget(value: string | undefined): boolean;
|
|
30
39
|
declare function resolveLocalDevelopmentPath(value: string | undefined, baseDir: string): string | null;
|
|
@@ -32,5 +41,5 @@ declare function resolveDevelopmentHostUrl(value: string | undefined): string;
|
|
|
32
41
|
declare function getHostDevelopmentPort(value: string | undefined): number;
|
|
33
42
|
declare function parsePort(url: string): number;
|
|
34
43
|
//#endregion
|
|
35
|
-
export { type BosConfig, BosConfigSchema, ConfigResult, type RuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName };
|
|
44
|
+
export { type BosConfig, BosConfigSchema, BuildRuntimeConfigOptions, ConfigResult, type RuntimeConfig, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName };
|
|
36
45
|
//# sourceMappingURL=config.d.mts.map
|
package/dist/config.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;;iBAoBgB,gBAAA,CAAA;AAAA,iBAKA,cAAA,CAAe,GAAA;AAAA,iBAYf,SAAA,CAAA,GAAa,SAAA;AAAA,iBAIb,cAAA,CAAA;AAAA,UAOC,YAAA;EACf,MAAA,EAAQ,SAA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,YAAA,sBACA,SAAA,sBACA,QAAA;AAAA,iBA+Gc,wBAAA,CAAyB,KAAA;AAAA,iBAIzB,2BAAA,CACd,KAAA,sBACA,OAAA;AAAA,iBAUc,yBAAA,CAA0B,KAAA;AAAA,iBAQ1B,sBAAA,CAAuB,KAAA;AAAA,iBAIvB,SAAA,CAAU,GAAA"}
|
package/dist/config.mjs
CHANGED
|
@@ -65,7 +65,8 @@ async function buildRuntimePluginsForConfig(config, baseDir, env) {
|
|
|
65
65
|
const plugins = await resolveRuntimePlugins(config.plugins ?? {}, baseDir, env);
|
|
66
66
|
return Object.keys(plugins).length > 0 ? plugins : void 0;
|
|
67
67
|
}
|
|
68
|
-
function resolveDevelopmentTarget(development, production, baseDir) {
|
|
68
|
+
function resolveDevelopmentTarget(development, production, baseDir, forceSource) {
|
|
69
|
+
if (forceSource === "remote") return resolveRuntimeTarget(production, baseDir, "remote");
|
|
69
70
|
const devTarget = resolveRuntimeTarget(development, baseDir);
|
|
70
71
|
if (devTarget.source === "local" && (!devTarget.localPath || !existsSync(devTarget.localPath))) return resolveRuntimeTarget(production, baseDir, "remote");
|
|
71
72
|
return devTarget;
|
|
@@ -74,12 +75,15 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
74
75
|
const uiConfig = config.app.ui;
|
|
75
76
|
const apiConfig = config.app.api;
|
|
76
77
|
const authConfig = config.app.auth;
|
|
77
|
-
const uiRuntime = env === "development" ? resolveDevelopmentTarget(uiConfig.development, uiConfig.production, baseDir) : resolveRuntimeTarget(uiConfig.production, baseDir, "remote");
|
|
78
|
-
const apiRuntime = env === "development" ? resolveDevelopmentTarget(apiConfig.development, apiConfig.production, baseDir) : resolveRuntimeTarget(apiConfig.production, baseDir, "remote");
|
|
79
|
-
const authRuntime = authConfig ? env === "development" ? resolveDevelopmentTarget(authConfig.development, authConfig.production, baseDir) : resolveRuntimeTarget(authConfig.production, baseDir, "remote") : void 0;
|
|
78
|
+
const uiRuntime = env === "development" ? resolveDevelopmentTarget(uiConfig.development, uiConfig.production, baseDir, options?.uiSource) : resolveRuntimeTarget(uiConfig.production, baseDir, "remote");
|
|
79
|
+
const apiRuntime = env === "development" ? resolveDevelopmentTarget(apiConfig.development, apiConfig.production, baseDir, options?.apiSource) : resolveRuntimeTarget(apiConfig.production, baseDir, "remote");
|
|
80
|
+
const authRuntime = authConfig ? env === "development" ? resolveDevelopmentTarget(authConfig.development, authConfig.production, baseDir, options?.authSource) : resolveRuntimeTarget(authConfig.production, baseDir, "remote") : void 0;
|
|
80
81
|
const hostConfig = config.app.host;
|
|
81
|
-
const hostRuntime = env === "development" ? resolveDevelopmentTarget(hostConfig.development, hostConfig.production, baseDir) : resolveRuntimeTarget(hostConfig.production, baseDir, "remote");
|
|
82
|
+
const hostRuntime = env === "development" ? resolveDevelopmentTarget(hostConfig.development, hostConfig.production, baseDir, options?.hostSource) : resolveRuntimeTarget(hostConfig.production, baseDir, "remote");
|
|
82
83
|
const hostListeningUrl = resolveDevelopmentHostUrl(hostConfig.development);
|
|
84
|
+
const hostIsRemote = hostRuntime.source === "remote";
|
|
85
|
+
const uiIsRemote = uiRuntime.source === "remote";
|
|
86
|
+
const apiIsRemote = apiRuntime.source === "remote";
|
|
83
87
|
return {
|
|
84
88
|
env,
|
|
85
89
|
account: config.account,
|
|
@@ -93,9 +97,9 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
93
97
|
localPath: hostRuntime.localPath,
|
|
94
98
|
port: hostRuntime.port ?? DEFAULT_HOST_PORT,
|
|
95
99
|
secrets: hostConfig.secrets,
|
|
96
|
-
integrity:
|
|
100
|
+
integrity: hostIsRemote ? hostConfig.integrity : void 0,
|
|
97
101
|
source: hostRuntime.source,
|
|
98
|
-
remoteUrl:
|
|
102
|
+
remoteUrl: hostIsRemote ? hostRuntime.url : void 0
|
|
99
103
|
},
|
|
100
104
|
shared: config.shared,
|
|
101
105
|
ui: {
|
|
@@ -104,9 +108,9 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
104
108
|
entry: uiRuntime.url ? `${uiRuntime.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
105
109
|
localPath: uiRuntime.localPath,
|
|
106
110
|
port: uiRuntime.port,
|
|
107
|
-
ssrUrl: uiConfig.ssr,
|
|
108
|
-
ssrIntegrity:
|
|
109
|
-
integrity:
|
|
111
|
+
ssrUrl: uiIsRemote ? uiConfig.ssr : void 0,
|
|
112
|
+
ssrIntegrity: uiIsRemote ? uiConfig.ssrIntegrity : void 0,
|
|
113
|
+
integrity: uiIsRemote ? uiConfig.integrity : void 0,
|
|
110
114
|
source: uiRuntime.source
|
|
111
115
|
},
|
|
112
116
|
api: {
|
|
@@ -116,10 +120,10 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
116
120
|
localPath: apiRuntime.localPath,
|
|
117
121
|
port: apiRuntime.port,
|
|
118
122
|
source: apiRuntime.source,
|
|
119
|
-
proxy: apiConfig.proxy,
|
|
123
|
+
proxy: options?.proxy ?? apiConfig.proxy,
|
|
120
124
|
variables: apiConfig.variables,
|
|
121
125
|
secrets: apiConfig.secrets,
|
|
122
|
-
integrity:
|
|
126
|
+
integrity: apiIsRemote ? apiConfig.integrity : void 0
|
|
123
127
|
},
|
|
124
128
|
auth: authConfig ? {
|
|
125
129
|
name: resolvePluginRuntimeName(void 0, authRuntime.localPath, authConfig.name),
|
|
@@ -131,7 +135,7 @@ function buildRuntimeConfig(config, baseDir, env, options) {
|
|
|
131
135
|
proxy: authConfig.proxy,
|
|
132
136
|
variables: authConfig.variables,
|
|
133
137
|
secrets: authConfig.secrets,
|
|
134
|
-
integrity:
|
|
138
|
+
integrity: authRuntime.source === "remote" ? authConfig.integrity : void 0
|
|
135
139
|
} : void 0,
|
|
136
140
|
plugins: options?.plugins && Object.keys(options.plugins).length > 0 ? options.plugins : void 0
|
|
137
141
|
};
|
|
@@ -302,5 +306,5 @@ function parsePort(url) {
|
|
|
302
306
|
}
|
|
303
307
|
|
|
304
308
|
//#endregion
|
|
305
|
-
export { BosConfigSchema, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName };
|
|
309
|
+
export { BosConfigSchema, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName };
|
|
306
310
|
//# sourceMappingURL=config.mjs.map
|
package/dist/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"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): RuntimeTarget {\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\nfunction buildRuntimeConfig(\n config: BosConfig,\n baseDir: string,\n env: \"development\" | \"production\",\n options?: { plugins?: Record<string, RuntimePluginConfig> },\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(uiConfig.development, uiConfig.production, baseDir)\n : resolveRuntimeTarget(uiConfig.production, baseDir, \"remote\");\n const apiRuntime =\n env === \"development\"\n ? resolveDevelopmentTarget(apiConfig.development, apiConfig.production, baseDir)\n : resolveRuntimeTarget(apiConfig.production, baseDir, \"remote\");\n const authRuntime = authConfig\n ? env === \"development\"\n ? resolveDevelopmentTarget(authConfig.development, authConfig.production, baseDir)\n : resolveRuntimeTarget(authConfig.production, baseDir, \"remote\")\n : undefined;\n\n const hostConfig = config.app.host;\n const hostRuntime =\n env === \"development\"\n ? resolveDevelopmentTarget(hostConfig.development, hostConfig.production, baseDir)\n : resolveRuntimeTarget(hostConfig.production, baseDir, \"remote\");\n\n const hostListeningUrl = resolveDevelopmentHostUrl(hostConfig.development);\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: env === \"production\" ? hostConfig.integrity : undefined,\n source: hostRuntime.source,\n remoteUrl: hostRuntime.source === \"remote\" ? 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: uiConfig.ssr,\n ssrIntegrity: env === \"production\" ? uiConfig.ssrIntegrity : undefined,\n integrity: env === \"production\" ? 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: apiConfig.proxy,\n variables: apiConfig.variables,\n secrets: apiConfig.secrets,\n integrity: env === \"production\" ? 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: env === \"production\" ? 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,aAAa,KAAK,KAAK,kBAAkB;AAC/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,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.mjs","names":[],"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":";;;;;;;AAO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AM,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,cAAc,QAAQ,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"}
|
package/dist/index.cjs
CHANGED
|
@@ -86,6 +86,7 @@ exports.UpgradeResultSchema = require_contract.UpgradeResultSchema;
|
|
|
86
86
|
exports.bosContract = require_contract.bosContract;
|
|
87
87
|
exports.buildRegistryConfigUrl = require_fastkv.buildRegistryConfigUrl;
|
|
88
88
|
exports.buildRegistryConfigUrlForNetwork = require_fastkv.buildRegistryConfigUrlForNetwork;
|
|
89
|
+
exports.buildRuntimeConfig = require_config.buildRuntimeConfig;
|
|
89
90
|
exports.buildRuntimePluginsForConfig = require_config.buildRuntimePluginsForConfig;
|
|
90
91
|
exports.clearConfigCache = require_config.clearConfigCache;
|
|
91
92
|
exports.cliCommandMeta = require_contract_meta.cliCommandMeta;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyContractRouter, AnySchema, Context, Effect, Layer, LoadedPluginWithBinding, Plugin, PluginRuntime, Scope, createPlugin, createPluginRuntime, oc, z } from "./sdk.cjs";
|
|
2
2
|
import { ApiPluginConfig, ApiPluginConfigSchema, BosConfig, BosConfigInput, BosConfigSchema, BosPluginRef, BosPluginRefSchema, BosStaging, BosStagingSchema, ClientRuntimeConfig, ClientRuntimeConfigSchema, ClientRuntimeInfo, ClientRuntimeInfoSchema, FederationEntry, FederationEntrySchema, HostConfig, HostConfigSchema, RuntimeConfig, RuntimeConfigSchema, RuntimePluginConfig, RuntimePluginConfigSchema, SharedConfig, SharedConfigSchema, SharedDepConfig, SharedDepConfigSchema, SourceMode, SourceModeSchema, UiConfig, UiConfigSchema } from "./types.cjs";
|
|
3
|
-
import { ConfigResult, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName } from "./config.cjs";
|
|
3
|
+
import { BuildRuntimeConfigOptions, ConfigResult, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName } from "./config.cjs";
|
|
4
4
|
import { CliCommandMeta, cliCommandMeta } from "./contract.meta.cjs";
|
|
5
5
|
import { NetworkId, PluginManifest, PluginMetadata, PluginRegistryEntry, buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, fetchBosConfigFromFastKv, fetchPluginFromRegistry, fetchRemotePluginManifest, getFastKvBaseUrlForNetwork, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, parsePluginBosUrl } from "./fastkv.cjs";
|
|
6
6
|
import { BosConfigResult, BuildOptions, BuildOptionsSchema, BuildResultSchema, ConfigResultSchema, DevOptions, DevOptionsSchema, DevResultSchema, InitOptions, InitOptionsSchema, InitResult, InitResultSchema, KeyPublishOptions, KeyPublishOptionsSchema, KeyPublishResult, KeyPublishResultSchema, PluginAddOptions, PluginAddOptionsSchema, PluginAddResult, PluginAddResultSchema, PluginListResult, PluginListResultSchema, PluginPublishOptions, PluginPublishOptionsSchema, PluginPublishResult, PluginPublishResultSchema, PluginRemoveOptions, PluginRemoveOptionsSchema, PluginRemoveResult, PluginRemoveResultSchema, PublishOptions, PublishOptionsSchema, PublishResultSchema, StartOptions, StartOptionsSchema, StartResultSchema, StatusResult, StatusResultSchema, SyncOptions, SyncOptionsSchema, SyncResult, SyncResultSchema, TypesGenOptions, TypesGenOptionsSchema, TypesGenResult, TypesGenResultSchema, UpgradeOptions, UpgradeOptionsSchema, UpgradeResult, UpgradeResultSchema, bosContract } from "./contract.cjs";
|
|
7
|
-
export { AnyContractRouter, AnySchema, ApiPluginConfig, ApiPluginConfigSchema, BosConfig, BosConfigInput, BosConfigResult, BosConfigSchema, BosPluginRef, BosPluginRefSchema, BosStaging, BosStagingSchema, BuildOptions, BuildOptionsSchema, BuildResultSchema, CliCommandMeta, ClientRuntimeConfig, ClientRuntimeConfigSchema, ClientRuntimeInfo, ClientRuntimeInfoSchema, ConfigResult, ConfigResultSchema, Context, DevOptions, DevOptionsSchema, DevResultSchema, Effect, FederationEntry, FederationEntrySchema, HostConfig, HostConfigSchema, InitOptions, InitOptionsSchema, InitResult, InitResultSchema, KeyPublishOptions, KeyPublishOptionsSchema, KeyPublishResult, KeyPublishResultSchema, Layer, LoadedPluginWithBinding, NetworkId, Plugin, PluginAddOptions, PluginAddOptionsSchema, PluginAddResult, PluginAddResultSchema, PluginListResult, PluginListResultSchema, PluginManifest, PluginMetadata, PluginPublishOptions, PluginPublishOptionsSchema, PluginPublishResult, PluginPublishResultSchema, PluginRegistryEntry, PluginRemoveOptions, PluginRemoveOptionsSchema, PluginRemoveResult, PluginRemoveResultSchema, PluginRuntime, PublishOptions, PublishOptionsSchema, PublishResultSchema, RuntimeConfig, RuntimeConfigSchema, RuntimePluginConfig, RuntimePluginConfigSchema, Scope, SharedConfig, SharedConfigSchema, SharedDepConfig, SharedDepConfigSchema, SourceMode, SourceModeSchema, StartOptions, StartOptionsSchema, StartResultSchema, StatusResult, StatusResultSchema, SyncOptions, SyncOptionsSchema, SyncResult, SyncResultSchema, TypesGenOptions, TypesGenOptionsSchema, TypesGenResult, TypesGenResultSchema, UiConfig, UiConfigSchema, UpgradeOptions, UpgradeOptionsSchema, UpgradeResult, UpgradeResultSchema, bosContract, buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, buildRuntimePluginsForConfig, clearConfigCache, cliCommandMeta, createPlugin, createPluginRuntime, fetchBosConfigFromFastKv, fetchPluginFromRegistry, fetchRemotePluginManifest, findConfigPath, getConfig, getFastKvBaseUrlForNetwork, getHostDevelopmentPort, getProjectRoot, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, isLocalDevelopmentTarget, loadBosConfig, loadConfig, oc, parsePluginBosUrl, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName, z };
|
|
7
|
+
export { AnyContractRouter, AnySchema, ApiPluginConfig, ApiPluginConfigSchema, BosConfig, BosConfigInput, BosConfigResult, BosConfigSchema, BosPluginRef, BosPluginRefSchema, BosStaging, BosStagingSchema, BuildOptions, BuildOptionsSchema, BuildResultSchema, BuildRuntimeConfigOptions, CliCommandMeta, ClientRuntimeConfig, ClientRuntimeConfigSchema, ClientRuntimeInfo, ClientRuntimeInfoSchema, ConfigResult, ConfigResultSchema, Context, DevOptions, DevOptionsSchema, DevResultSchema, Effect, FederationEntry, FederationEntrySchema, HostConfig, HostConfigSchema, InitOptions, InitOptionsSchema, InitResult, InitResultSchema, KeyPublishOptions, KeyPublishOptionsSchema, KeyPublishResult, KeyPublishResultSchema, Layer, LoadedPluginWithBinding, NetworkId, Plugin, PluginAddOptions, PluginAddOptionsSchema, PluginAddResult, PluginAddResultSchema, PluginListResult, PluginListResultSchema, PluginManifest, PluginMetadata, PluginPublishOptions, PluginPublishOptionsSchema, PluginPublishResult, PluginPublishResultSchema, PluginRegistryEntry, PluginRemoveOptions, PluginRemoveOptionsSchema, PluginRemoveResult, PluginRemoveResultSchema, PluginRuntime, PublishOptions, PublishOptionsSchema, PublishResultSchema, RuntimeConfig, RuntimeConfigSchema, RuntimePluginConfig, RuntimePluginConfigSchema, Scope, SharedConfig, SharedConfigSchema, SharedDepConfig, SharedDepConfigSchema, SourceMode, SourceModeSchema, StartOptions, StartOptionsSchema, StartResultSchema, StatusResult, StatusResultSchema, SyncOptions, SyncOptionsSchema, SyncResult, SyncResultSchema, TypesGenOptions, TypesGenOptionsSchema, TypesGenResult, TypesGenResultSchema, UiConfig, UiConfigSchema, UpgradeOptions, UpgradeOptionsSchema, UpgradeResult, UpgradeResultSchema, bosContract, buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, cliCommandMeta, createPlugin, createPluginRuntime, fetchBosConfigFromFastKv, fetchPluginFromRegistry, fetchRemotePluginManifest, findConfigPath, getConfig, getFastKvBaseUrlForNetwork, getHostDevelopmentPort, getProjectRoot, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, isLocalDevelopmentTarget, loadBosConfig, loadConfig, oc, parsePluginBosUrl, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName, z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyContractRouter, AnySchema, Context, Effect, Layer, LoadedPluginWithBinding, Plugin, PluginRuntime, Scope, createPlugin, createPluginRuntime, oc, z } from "./sdk.mjs";
|
|
2
2
|
import { ApiPluginConfig, ApiPluginConfigSchema, BosConfig, BosConfigInput, BosConfigSchema, BosPluginRef, BosPluginRefSchema, BosStaging, BosStagingSchema, ClientRuntimeConfig, ClientRuntimeConfigSchema, ClientRuntimeInfo, ClientRuntimeInfoSchema, FederationEntry, FederationEntrySchema, HostConfig, HostConfigSchema, RuntimeConfig, RuntimeConfigSchema, RuntimePluginConfig, RuntimePluginConfigSchema, SharedConfig, SharedConfigSchema, SharedDepConfig, SharedDepConfigSchema, SourceMode, SourceModeSchema, UiConfig, UiConfigSchema } from "./types.mjs";
|
|
3
|
-
import { ConfigResult, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName } from "./config.mjs";
|
|
3
|
+
import { BuildRuntimeConfigOptions, ConfigResult, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName } from "./config.mjs";
|
|
4
4
|
import { CliCommandMeta, cliCommandMeta } from "./contract.meta.mjs";
|
|
5
5
|
import { NetworkId, PluginManifest, PluginMetadata, PluginRegistryEntry, buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, fetchBosConfigFromFastKv, fetchPluginFromRegistry, fetchRemotePluginManifest, getFastKvBaseUrlForNetwork, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, parsePluginBosUrl } from "./fastkv.mjs";
|
|
6
6
|
import { BosConfigResult, BuildOptions, BuildOptionsSchema, BuildResultSchema, ConfigResultSchema, DevOptions, DevOptionsSchema, DevResultSchema, InitOptions, InitOptionsSchema, InitResult, InitResultSchema, KeyPublishOptions, KeyPublishOptionsSchema, KeyPublishResult, KeyPublishResultSchema, PluginAddOptions, PluginAddOptionsSchema, PluginAddResult, PluginAddResultSchema, PluginListResult, PluginListResultSchema, PluginPublishOptions, PluginPublishOptionsSchema, PluginPublishResult, PluginPublishResultSchema, PluginRemoveOptions, PluginRemoveOptionsSchema, PluginRemoveResult, PluginRemoveResultSchema, PublishOptions, PublishOptionsSchema, PublishResultSchema, StartOptions, StartOptionsSchema, StartResultSchema, StatusResult, StatusResultSchema, SyncOptions, SyncOptionsSchema, SyncResult, SyncResultSchema, TypesGenOptions, TypesGenOptionsSchema, TypesGenResult, TypesGenResultSchema, UpgradeOptions, UpgradeOptionsSchema, UpgradeResult, UpgradeResultSchema, bosContract } from "./contract.mjs";
|
|
7
|
-
export { AnyContractRouter, AnySchema, ApiPluginConfig, ApiPluginConfigSchema, BosConfig, BosConfigInput, BosConfigResult, BosConfigSchema, BosPluginRef, BosPluginRefSchema, BosStaging, BosStagingSchema, BuildOptions, BuildOptionsSchema, BuildResultSchema, CliCommandMeta, ClientRuntimeConfig, ClientRuntimeConfigSchema, ClientRuntimeInfo, ClientRuntimeInfoSchema, ConfigResult, ConfigResultSchema, Context, DevOptions, DevOptionsSchema, DevResultSchema, Effect, FederationEntry, FederationEntrySchema, HostConfig, HostConfigSchema, InitOptions, InitOptionsSchema, InitResult, InitResultSchema, KeyPublishOptions, KeyPublishOptionsSchema, KeyPublishResult, KeyPublishResultSchema, Layer, LoadedPluginWithBinding, NetworkId, Plugin, PluginAddOptions, PluginAddOptionsSchema, PluginAddResult, PluginAddResultSchema, PluginListResult, PluginListResultSchema, PluginManifest, PluginMetadata, PluginPublishOptions, PluginPublishOptionsSchema, PluginPublishResult, PluginPublishResultSchema, PluginRegistryEntry, PluginRemoveOptions, PluginRemoveOptionsSchema, PluginRemoveResult, PluginRemoveResultSchema, PluginRuntime, PublishOptions, PublishOptionsSchema, PublishResultSchema, RuntimeConfig, RuntimeConfigSchema, RuntimePluginConfig, RuntimePluginConfigSchema, Scope, SharedConfig, SharedConfigSchema, SharedDepConfig, SharedDepConfigSchema, SourceMode, SourceModeSchema, StartOptions, StartOptionsSchema, StartResultSchema, StatusResult, StatusResultSchema, SyncOptions, SyncOptionsSchema, SyncResult, SyncResultSchema, TypesGenOptions, TypesGenOptionsSchema, TypesGenResult, TypesGenResultSchema, UiConfig, UiConfigSchema, UpgradeOptions, UpgradeOptionsSchema, UpgradeResult, UpgradeResultSchema, bosContract, buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, buildRuntimePluginsForConfig, clearConfigCache, cliCommandMeta, createPlugin, createPluginRuntime, fetchBosConfigFromFastKv, fetchPluginFromRegistry, fetchRemotePluginManifest, findConfigPath, getConfig, getFastKvBaseUrlForNetwork, getHostDevelopmentPort, getProjectRoot, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, isLocalDevelopmentTarget, loadBosConfig, loadConfig, oc, parsePluginBosUrl, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName, z };
|
|
7
|
+
export { AnyContractRouter, AnySchema, ApiPluginConfig, ApiPluginConfigSchema, BosConfig, BosConfigInput, BosConfigResult, BosConfigSchema, BosPluginRef, BosPluginRefSchema, BosStaging, BosStagingSchema, BuildOptions, BuildOptionsSchema, BuildResultSchema, BuildRuntimeConfigOptions, CliCommandMeta, ClientRuntimeConfig, ClientRuntimeConfigSchema, ClientRuntimeInfo, ClientRuntimeInfoSchema, ConfigResult, ConfigResultSchema, Context, DevOptions, DevOptionsSchema, DevResultSchema, Effect, FederationEntry, FederationEntrySchema, HostConfig, HostConfigSchema, InitOptions, InitOptionsSchema, InitResult, InitResultSchema, KeyPublishOptions, KeyPublishOptionsSchema, KeyPublishResult, KeyPublishResultSchema, Layer, LoadedPluginWithBinding, NetworkId, Plugin, PluginAddOptions, PluginAddOptionsSchema, PluginAddResult, PluginAddResultSchema, PluginListResult, PluginListResultSchema, PluginManifest, PluginMetadata, PluginPublishOptions, PluginPublishOptionsSchema, PluginPublishResult, PluginPublishResultSchema, PluginRegistryEntry, PluginRemoveOptions, PluginRemoveOptionsSchema, PluginRemoveResult, PluginRemoveResultSchema, PluginRuntime, PublishOptions, PublishOptionsSchema, PublishResultSchema, RuntimeConfig, RuntimeConfigSchema, RuntimePluginConfig, RuntimePluginConfigSchema, Scope, SharedConfig, SharedConfigSchema, SharedDepConfig, SharedDepConfigSchema, SourceMode, SourceModeSchema, StartOptions, StartOptionsSchema, StartResultSchema, StatusResult, StatusResultSchema, SyncOptions, SyncOptionsSchema, SyncResult, SyncResultSchema, TypesGenOptions, TypesGenOptionsSchema, TypesGenResult, TypesGenResultSchema, UiConfig, UiConfigSchema, UpgradeOptions, UpgradeOptionsSchema, UpgradeResult, UpgradeResultSchema, bosContract, buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, cliCommandMeta, createPlugin, createPluginRuntime, fetchBosConfigFromFastKv, fetchPluginFromRegistry, fetchRemotePluginManifest, findConfigPath, getConfig, getFastKvBaseUrlForNetwork, getHostDevelopmentPort, getProjectRoot, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, isLocalDevelopmentTarget, loadBosConfig, loadConfig, oc, parsePluginBosUrl, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName, z };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, fetchBosConfigFromFastKv, fetchPluginFromRegistry, fetchRemotePluginManifest, getFastKvBaseUrlForNetwork, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, parsePluginBosUrl } from "./fastkv.mjs";
|
|
2
2
|
import { Context, Effect, Layer, PluginRuntime, Scope, createPlugin, createPluginRuntime, oc, z } from "./sdk.mjs";
|
|
3
3
|
import { ApiPluginConfigSchema, BosConfigSchema, BosPluginRefSchema, BosStagingSchema, ClientRuntimeConfigSchema, ClientRuntimeInfoSchema, FederationEntrySchema, HostConfigSchema, RuntimeConfigSchema, RuntimePluginConfigSchema, SharedConfigSchema, SharedDepConfigSchema, SourceModeSchema, UiConfigSchema } from "./types.mjs";
|
|
4
|
-
import { buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName } from "./config.mjs";
|
|
4
|
+
import { buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, isLocalDevelopmentTarget, loadBosConfig, loadConfig, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName } from "./config.mjs";
|
|
5
5
|
import { BuildOptionsSchema, BuildResultSchema, ConfigResultSchema, DevOptionsSchema, DevResultSchema, InitOptionsSchema, InitResultSchema, KeyPublishOptionsSchema, KeyPublishResultSchema, PluginAddOptionsSchema, PluginAddResultSchema, PluginListResultSchema, PluginPublishOptionsSchema, PluginPublishResultSchema, PluginRemoveOptionsSchema, PluginRemoveResultSchema, PublishOptionsSchema, PublishResultSchema, StartOptionsSchema, StartResultSchema, StatusResultSchema, SyncOptionsSchema, SyncResultSchema, TypesGenOptionsSchema, TypesGenResultSchema, UpgradeOptionsSchema, UpgradeResultSchema, bosContract } from "./contract.mjs";
|
|
6
6
|
import { cliCommandMeta } from "./contract.meta.mjs";
|
|
7
7
|
import "./plugin.mjs";
|
|
8
8
|
|
|
9
|
-
export { ApiPluginConfigSchema, BosConfigSchema, BosPluginRefSchema, BosStagingSchema, BuildOptionsSchema, BuildResultSchema, ClientRuntimeConfigSchema, ClientRuntimeInfoSchema, ConfigResultSchema, Context, DevOptionsSchema, DevResultSchema, Effect, FederationEntrySchema, HostConfigSchema, InitOptionsSchema, InitResultSchema, KeyPublishOptionsSchema, KeyPublishResultSchema, Layer, PluginAddOptionsSchema, PluginAddResultSchema, PluginListResultSchema, PluginPublishOptionsSchema, PluginPublishResultSchema, PluginRemoveOptionsSchema, PluginRemoveResultSchema, PluginRuntime, PublishOptionsSchema, PublishResultSchema, RuntimeConfigSchema, RuntimePluginConfigSchema, Scope, SharedConfigSchema, SharedDepConfigSchema, SourceModeSchema, StartOptionsSchema, StartResultSchema, StatusResultSchema, SyncOptionsSchema, SyncResultSchema, TypesGenOptionsSchema, TypesGenResultSchema, UiConfigSchema, UpgradeOptionsSchema, UpgradeResultSchema, bosContract, buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, buildRuntimePluginsForConfig, clearConfigCache, cliCommandMeta, createPlugin, createPluginRuntime, fetchBosConfigFromFastKv, fetchPluginFromRegistry, fetchRemotePluginManifest, findConfigPath, getConfig, getFastKvBaseUrlForNetwork, getHostDevelopmentPort, getProjectRoot, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, isLocalDevelopmentTarget, loadBosConfig, loadConfig, oc, parsePluginBosUrl, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName, z };
|
|
9
|
+
export { ApiPluginConfigSchema, BosConfigSchema, BosPluginRefSchema, BosStagingSchema, BuildOptionsSchema, BuildResultSchema, ClientRuntimeConfigSchema, ClientRuntimeInfoSchema, ConfigResultSchema, Context, DevOptionsSchema, DevResultSchema, Effect, FederationEntrySchema, HostConfigSchema, InitOptionsSchema, InitResultSchema, KeyPublishOptionsSchema, KeyPublishResultSchema, Layer, PluginAddOptionsSchema, PluginAddResultSchema, PluginListResultSchema, PluginPublishOptionsSchema, PluginPublishResultSchema, PluginRemoveOptionsSchema, PluginRemoveResultSchema, PluginRuntime, PublishOptionsSchema, PublishResultSchema, RuntimeConfigSchema, RuntimePluginConfigSchema, Scope, SharedConfigSchema, SharedDepConfigSchema, SourceModeSchema, StartOptionsSchema, StartResultSchema, StatusResultSchema, SyncOptionsSchema, SyncResultSchema, TypesGenOptionsSchema, TypesGenResultSchema, UiConfigSchema, UpgradeOptionsSchema, UpgradeResultSchema, bosContract, buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, cliCommandMeta, createPlugin, createPluginRuntime, fetchBosConfigFromFastKv, fetchPluginFromRegistry, fetchRemotePluginManifest, findConfigPath, getConfig, getFastKvBaseUrlForNetwork, getHostDevelopmentPort, getProjectRoot, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, isLocalDevelopmentTarget, loadBosConfig, loadConfig, oc, parsePluginBosUrl, parsePort, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName, z };
|
package/package.json
CHANGED
package/src/app.ts
CHANGED
|
@@ -2,13 +2,10 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { createConnection } from "node:net";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import {
|
|
5
|
+
buildRuntimeConfig as configBuildRuntimeConfig,
|
|
5
6
|
getProjectRoot,
|
|
6
|
-
isLocalDevelopmentTarget,
|
|
7
|
-
parsePort,
|
|
8
7
|
resolveLocalDevelopmentPath,
|
|
9
|
-
resolvePluginRuntimeName,
|
|
10
8
|
} from "./config";
|
|
11
|
-
import { getNetworkIdForAccount } from "./network";
|
|
12
9
|
import type { AppOrchestrator } from "./service-descriptor";
|
|
13
10
|
import type { BosConfig, RuntimeConfig, RuntimePluginConfig } from "./types";
|
|
14
11
|
|
|
@@ -78,116 +75,14 @@ export function buildRuntimeConfig(
|
|
|
78
75
|
plugins?: Record<string, RuntimePluginConfig>;
|
|
79
76
|
},
|
|
80
77
|
): RuntimeConfig {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
function resolveDevelopmentEntry(
|
|
88
|
-
entry: { development?: string; production?: string },
|
|
89
|
-
preferredSource: "local" | "remote",
|
|
90
|
-
): { source: "local" | "remote"; url: string; localPath?: string; port?: number } {
|
|
91
|
-
if (preferredSource === "remote") {
|
|
92
|
-
return { source: "remote", url: entry.production ?? "" };
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const localPath = resolveLocalDevelopmentPath(entry.development, configDir);
|
|
96
|
-
if (localPath && existsSync(localPath)) {
|
|
97
|
-
return { source: "local", url: "", localPath };
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const devUrl =
|
|
101
|
-
entry.development && !isLocalDevelopmentTarget(entry.development)
|
|
102
|
-
? entry.development.replace(/\/$/, "")
|
|
103
|
-
: null;
|
|
104
|
-
if (devUrl) {
|
|
105
|
-
return { source: "local", url: devUrl, port: parsePort(devUrl) };
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return { source: "remote", url: entry.production ?? "" };
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const hostEntry = resolveDevelopmentEntry(hostConfig, options.hostSource ?? "local");
|
|
112
|
-
const uiEntry = resolveDevelopmentEntry(uiConfig, options.uiSource ?? "local");
|
|
113
|
-
const apiEntry = resolveDevelopmentEntry(apiConfig, options.apiSource ?? "local");
|
|
114
|
-
const authEntry = authConfig
|
|
115
|
-
? resolveDevelopmentEntry(authConfig, options.authSource ?? "local")
|
|
116
|
-
: undefined;
|
|
117
|
-
|
|
118
|
-
const hostUrl = `http://localhost:${DEFAULT_HOST_PORT}`;
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
env: options.env ?? "development",
|
|
122
|
-
account: bosConfig.account,
|
|
123
|
-
domain: bosConfig.domain,
|
|
124
|
-
networkId: getNetworkIdForAccount(bosConfig.account),
|
|
125
|
-
host: {
|
|
126
|
-
name: "host",
|
|
127
|
-
url: hostUrl,
|
|
128
|
-
entry: `${hostUrl}/mf-manifest.json`,
|
|
129
|
-
localPath: hostEntry.localPath,
|
|
130
|
-
port: hostEntry.port ?? DEFAULT_HOST_PORT,
|
|
131
|
-
secrets: hostConfig.secrets,
|
|
132
|
-
integrity: hostEntry.source === "remote" ? hostConfig.integrity : undefined,
|
|
133
|
-
source: hostEntry.source,
|
|
134
|
-
remoteUrl: hostEntry.source === "remote" ? hostEntry.url : undefined,
|
|
135
|
-
},
|
|
136
|
-
shared: bosConfig.shared,
|
|
137
|
-
ui: uiConfig
|
|
138
|
-
? {
|
|
139
|
-
name: uiConfig.name,
|
|
140
|
-
url: uiEntry.url,
|
|
141
|
-
entry: uiEntry.url ? `${uiEntry.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
142
|
-
localPath: uiEntry.localPath,
|
|
143
|
-
port: uiEntry.port,
|
|
144
|
-
ssrUrl: uiEntry.source === "remote" ? uiConfig.ssr : undefined,
|
|
145
|
-
ssrIntegrity: uiEntry.source === "remote" ? uiConfig.ssrIntegrity : undefined,
|
|
146
|
-
integrity: uiEntry.source === "remote" ? uiConfig.integrity : undefined,
|
|
147
|
-
source: uiEntry.source,
|
|
148
|
-
}
|
|
149
|
-
: {
|
|
150
|
-
name: "ui",
|
|
151
|
-
url: "",
|
|
152
|
-
entry: "/mf-manifest.json",
|
|
153
|
-
source: uiEntry.source,
|
|
154
|
-
},
|
|
155
|
-
api: apiConfig
|
|
156
|
-
? {
|
|
157
|
-
name: apiConfig.name,
|
|
158
|
-
url: apiEntry.url,
|
|
159
|
-
entry: apiEntry.url ? `${apiEntry.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
160
|
-
localPath: apiEntry.localPath,
|
|
161
|
-
port: apiEntry.port,
|
|
162
|
-
source: apiEntry.source,
|
|
163
|
-
proxy: options.proxy ?? apiConfig.proxy,
|
|
164
|
-
variables: apiConfig.variables,
|
|
165
|
-
secrets: apiConfig.secrets,
|
|
166
|
-
integrity: apiEntry.source === "remote" ? apiConfig.integrity : undefined,
|
|
167
|
-
}
|
|
168
|
-
: {
|
|
169
|
-
name: "api",
|
|
170
|
-
url: "",
|
|
171
|
-
entry: "/mf-manifest.json",
|
|
172
|
-
source: apiEntry.source,
|
|
173
|
-
},
|
|
174
|
-
auth:
|
|
175
|
-
authEntry && authConfig
|
|
176
|
-
? {
|
|
177
|
-
name: resolvePluginRuntimeName(undefined, authEntry.localPath, authConfig.name),
|
|
178
|
-
url: authEntry.url,
|
|
179
|
-
entry: authEntry.url ? `${authEntry.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
180
|
-
localPath: authEntry.localPath,
|
|
181
|
-
port: authEntry.port,
|
|
182
|
-
source: authEntry.source,
|
|
183
|
-
proxy: authConfig.proxy,
|
|
184
|
-
variables: authConfig.variables,
|
|
185
|
-
secrets: authConfig.secrets,
|
|
186
|
-
integrity: authEntry.source === "remote" ? authConfig.integrity : undefined,
|
|
187
|
-
}
|
|
188
|
-
: undefined,
|
|
78
|
+
return configBuildRuntimeConfig(bosConfig, getProjectRoot(), options.env ?? "development", {
|
|
79
|
+
hostSource: options.hostSource,
|
|
80
|
+
uiSource: options.uiSource,
|
|
81
|
+
apiSource: options.apiSource,
|
|
82
|
+
authSource: options.authSource,
|
|
83
|
+
proxy: options.proxy,
|
|
189
84
|
plugins: options.plugins,
|
|
190
|
-
};
|
|
85
|
+
});
|
|
191
86
|
}
|
|
192
87
|
|
|
193
88
|
function probeTcpOpen(port: number, timeoutMs = 250): Promise<boolean> {
|
package/src/config.ts
CHANGED
|
@@ -126,7 +126,11 @@ function resolveDevelopmentTarget(
|
|
|
126
126
|
development: string | undefined,
|
|
127
127
|
production: string | undefined,
|
|
128
128
|
baseDir: string,
|
|
129
|
+
forceSource?: "local" | "remote",
|
|
129
130
|
): RuntimeTarget {
|
|
131
|
+
if (forceSource === "remote") {
|
|
132
|
+
return resolveRuntimeTarget(production, baseDir, "remote");
|
|
133
|
+
}
|
|
130
134
|
const devTarget = resolveRuntimeTarget(development, baseDir);
|
|
131
135
|
if (devTarget.source === "local" && (!devTarget.localPath || !existsSync(devTarget.localPath))) {
|
|
132
136
|
return resolveRuntimeTarget(production, baseDir, "remote");
|
|
@@ -134,37 +138,70 @@ function resolveDevelopmentTarget(
|
|
|
134
138
|
return devTarget;
|
|
135
139
|
}
|
|
136
140
|
|
|
137
|
-
|
|
141
|
+
export interface BuildRuntimeConfigOptions {
|
|
142
|
+
plugins?: Record<string, RuntimePluginConfig>;
|
|
143
|
+
hostSource?: "local" | "remote";
|
|
144
|
+
uiSource?: "local" | "remote";
|
|
145
|
+
apiSource?: "local" | "remote";
|
|
146
|
+
authSource?: "local" | "remote";
|
|
147
|
+
proxy?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function buildRuntimeConfig(
|
|
138
151
|
config: BosConfig,
|
|
139
152
|
baseDir: string,
|
|
140
153
|
env: "development" | "production",
|
|
141
|
-
options?:
|
|
154
|
+
options?: BuildRuntimeConfigOptions,
|
|
142
155
|
): RuntimeConfig {
|
|
143
156
|
const uiConfig = config.app.ui;
|
|
144
157
|
const apiConfig = config.app.api;
|
|
145
158
|
const authConfig = config.app.auth;
|
|
146
159
|
const uiRuntime =
|
|
147
160
|
env === "development"
|
|
148
|
-
? resolveDevelopmentTarget(
|
|
161
|
+
? resolveDevelopmentTarget(
|
|
162
|
+
uiConfig.development,
|
|
163
|
+
uiConfig.production,
|
|
164
|
+
baseDir,
|
|
165
|
+
options?.uiSource,
|
|
166
|
+
)
|
|
149
167
|
: resolveRuntimeTarget(uiConfig.production, baseDir, "remote");
|
|
150
168
|
const apiRuntime =
|
|
151
169
|
env === "development"
|
|
152
|
-
? resolveDevelopmentTarget(
|
|
170
|
+
? resolveDevelopmentTarget(
|
|
171
|
+
apiConfig.development,
|
|
172
|
+
apiConfig.production,
|
|
173
|
+
baseDir,
|
|
174
|
+
options?.apiSource,
|
|
175
|
+
)
|
|
153
176
|
: resolveRuntimeTarget(apiConfig.production, baseDir, "remote");
|
|
154
177
|
const authRuntime = authConfig
|
|
155
178
|
? env === "development"
|
|
156
|
-
? resolveDevelopmentTarget(
|
|
179
|
+
? resolveDevelopmentTarget(
|
|
180
|
+
authConfig.development,
|
|
181
|
+
authConfig.production,
|
|
182
|
+
baseDir,
|
|
183
|
+
options?.authSource,
|
|
184
|
+
)
|
|
157
185
|
: resolveRuntimeTarget(authConfig.production, baseDir, "remote")
|
|
158
186
|
: undefined;
|
|
159
187
|
|
|
160
188
|
const hostConfig = config.app.host;
|
|
161
189
|
const hostRuntime =
|
|
162
190
|
env === "development"
|
|
163
|
-
? resolveDevelopmentTarget(
|
|
191
|
+
? resolveDevelopmentTarget(
|
|
192
|
+
hostConfig.development,
|
|
193
|
+
hostConfig.production,
|
|
194
|
+
baseDir,
|
|
195
|
+
options?.hostSource,
|
|
196
|
+
)
|
|
164
197
|
: resolveRuntimeTarget(hostConfig.production, baseDir, "remote");
|
|
165
198
|
|
|
166
199
|
const hostListeningUrl = resolveDevelopmentHostUrl(hostConfig.development);
|
|
167
200
|
|
|
201
|
+
const hostIsRemote = hostRuntime.source === "remote";
|
|
202
|
+
const uiIsRemote = uiRuntime.source === "remote";
|
|
203
|
+
const apiIsRemote = apiRuntime.source === "remote";
|
|
204
|
+
|
|
168
205
|
return {
|
|
169
206
|
env,
|
|
170
207
|
account: config.account,
|
|
@@ -178,9 +215,9 @@ function buildRuntimeConfig(
|
|
|
178
215
|
localPath: hostRuntime.localPath,
|
|
179
216
|
port: hostRuntime.port ?? DEFAULT_HOST_PORT,
|
|
180
217
|
secrets: hostConfig.secrets,
|
|
181
|
-
integrity:
|
|
218
|
+
integrity: hostIsRemote ? hostConfig.integrity : undefined,
|
|
182
219
|
source: hostRuntime.source,
|
|
183
|
-
remoteUrl:
|
|
220
|
+
remoteUrl: hostIsRemote ? hostRuntime.url : undefined,
|
|
184
221
|
},
|
|
185
222
|
shared: config.shared,
|
|
186
223
|
ui: {
|
|
@@ -189,9 +226,9 @@ function buildRuntimeConfig(
|
|
|
189
226
|
entry: uiRuntime.url ? `${uiRuntime.url}/mf-manifest.json` : "/mf-manifest.json",
|
|
190
227
|
localPath: uiRuntime.localPath,
|
|
191
228
|
port: uiRuntime.port,
|
|
192
|
-
ssrUrl: uiConfig.ssr,
|
|
193
|
-
ssrIntegrity:
|
|
194
|
-
integrity:
|
|
229
|
+
ssrUrl: uiIsRemote ? uiConfig.ssr : undefined,
|
|
230
|
+
ssrIntegrity: uiIsRemote ? uiConfig.ssrIntegrity : undefined,
|
|
231
|
+
integrity: uiIsRemote ? uiConfig.integrity : undefined,
|
|
195
232
|
source: uiRuntime.source,
|
|
196
233
|
},
|
|
197
234
|
api: {
|
|
@@ -201,10 +238,10 @@ function buildRuntimeConfig(
|
|
|
201
238
|
localPath: apiRuntime.localPath,
|
|
202
239
|
port: apiRuntime.port,
|
|
203
240
|
source: apiRuntime.source,
|
|
204
|
-
proxy: apiConfig.proxy,
|
|
241
|
+
proxy: options?.proxy ?? apiConfig.proxy,
|
|
205
242
|
variables: apiConfig.variables,
|
|
206
243
|
secrets: apiConfig.secrets,
|
|
207
|
-
integrity:
|
|
244
|
+
integrity: apiIsRemote ? apiConfig.integrity : undefined,
|
|
208
245
|
},
|
|
209
246
|
auth: authConfig
|
|
210
247
|
? {
|
|
@@ -217,7 +254,7 @@ function buildRuntimeConfig(
|
|
|
217
254
|
proxy: authConfig.proxy,
|
|
218
255
|
variables: authConfig.variables,
|
|
219
256
|
secrets: authConfig.secrets,
|
|
220
|
-
integrity:
|
|
257
|
+
integrity: authRuntime!.source === "remote" ? authConfig.integrity : undefined,
|
|
221
258
|
}
|
|
222
259
|
: undefined,
|
|
223
260
|
plugins:
|