UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

48 lines (46 loc) • 2.31 kB
const require_runtime = require('../resolution/runtime.cjs'); let node_fs = require("node:fs"); let node_path = require("node:path"); //#region src/services/workspace/linked-packages.ts function detectLocalPackages(bosConfig, runtimeConfig, root = process.cwd()) { const packages = []; const configDir = root; const uiLocalPath = runtimeConfig?.ui.localPath ?? require_runtime.resolveLocalDevelopmentPath(bosConfig?.app.ui.development, configDir); if (uiLocalPath && (0, node_fs.existsSync)((0, node_path.join)(uiLocalPath, "package.json"))) packages.push({ name: "ui", dir: uiLocalPath }); const apiLocalPath = runtimeConfig?.api.localPath ?? require_runtime.resolveLocalDevelopmentPath(bosConfig?.app.api.development, configDir); if (apiLocalPath && (0, node_fs.existsSync)((0, node_path.join)(apiLocalPath, "package.json"))) packages.push({ name: "api", dir: apiLocalPath }); const hostLocalPath = runtimeConfig?.host?.localPath ?? require_runtime.resolveLocalDevelopmentPath(bosConfig?.app.host.development, configDir); if (hostLocalPath && (0, node_fs.existsSync)((0, node_path.join)(hostLocalPath, "package.json"))) packages.push({ name: "host", dir: hostLocalPath }); else if ((0, node_fs.existsSync)((0, node_path.join)(configDir, "host", "package.json"))) packages.push({ name: "host", dir: (0, node_path.join)(configDir, "host") }); for (const [pluginId, pluginConfig] of Object.entries(runtimeConfig?.plugins ?? {})) { if (pluginConfig.localPath && (0, node_fs.existsSync)((0, node_path.join)(pluginConfig.localPath, "package.json"))) packages.push({ name: `plugin:${pluginId}`, dir: pluginConfig.localPath }); if (pluginConfig.ui?.localPath && (0, node_fs.existsSync)((0, node_path.join)(pluginConfig.ui.localPath, "package.json"))) packages.push({ name: `plugin-ui:${pluginId}`, dir: pluginConfig.ui.localPath }); } const authLocalPath = runtimeConfig?.auth?.localPath ?? require_runtime.resolveLocalDevelopmentPath(bosConfig?.app.auth?.development, configDir); if (authLocalPath && (0, node_fs.existsSync)((0, node_path.join)(authLocalPath, "package.json"))) packages.push({ name: "auth", dir: authLocalPath }); return packages; } //#endregion exports.detectLocalPackages = detectLocalPackages; //# sourceMappingURL=linked-packages.cjs.map