MCPcopy
hub / github.com/Waishnav/devspace / loadConfig

Function loadConfig

src/config.ts:208–241  ·  view source on GitHub ↗
(env: NodeJS.ProcessEnv = process.env)

Source from the content-addressed store, hash-verified

206}
207
208export function loadConfig(env: NodeJS.ProcessEnv = process.env): ServerConfig {
209 const files = loadDevspaceFiles(env);
210 const host = env.HOST ?? files.config.host ?? "127.0.0.1";
211 const port = parsePort(env.PORT ?? files.config.port);
212 const publicBaseUrl = parsePublicBaseUrl(
213 env.DEVSPACE_PUBLIC_BASE_URL ?? files.config.publicBaseUrl ?? localPublicBaseUrl(host, port),
214 );
215 const derivedAllowedHosts = [
216 "localhost",
217 "127.0.0.1",
218 "::1",
219 host,
220 new URL(publicBaseUrl).hostname,
221 ...(files.config.allowedHosts ?? []),
222 ];
223
224 return {
225 host,
226 port,
227 oauth: parseOAuthConfig(env, files.auth.ownerToken),
228 allowedRoots: parseAllowedRoots(env.DEVSPACE_ALLOWED_ROOTS ?? files.config.allowedRoots),
229 allowedHosts: parseAllowedHosts(env.DEVSPACE_ALLOWED_HOSTS, derivedAllowedHosts),
230 publicBaseUrl,
231 toolMode: parseToolMode(env),
232 toolNaming: parseToolNaming(env.DEVSPACE_TOOL_NAMING),
233 widgets: parseWidgetMode(env.DEVSPACE_WIDGETS),
234 stateDir: resolve(expandHomePath(env.DEVSPACE_STATE_DIR ?? files.config.stateDir ?? defaultStateDir())),
235 worktreeRoot: resolve(expandHomePath(env.DEVSPACE_WORKTREE_ROOT ?? files.config.worktreeRoot ?? defaultWorktreeRoot())),
236 skillsEnabled: env.DEVSPACE_SKILLS === undefined ? true : parseBoolean(env.DEVSPACE_SKILLS),
237 skillPaths: parsePathList(env.DEVSPACE_SKILL_PATHS),
238 agentDir: resolve(expandHomePath(env.DEVSPACE_AGENT_DIR ?? files.config.agentDir ?? defaultAgentDir())),
239 logging: parseLoggingConfig(env),
240 };
241}
242
243function parsePublicBaseUrl(value: string): string {
244 const parsed = new URL(value);

Callers 6

skills.test.tsFile · 0.85
config.test.tsFile · 0.85
workspaces.test.tsFile · 0.85
serveFunction · 0.85
runDoctorFunction · 0.85
createServerFunction · 0.85

Calls 15

loadDevspaceFilesFunction · 0.85
parsePortFunction · 0.85
parsePublicBaseUrlFunction · 0.85
localPublicBaseUrlFunction · 0.85
parseOAuthConfigFunction · 0.85
parseAllowedRootsFunction · 0.85
parseAllowedHostsFunction · 0.85
parseToolModeFunction · 0.85
parseToolNamingFunction · 0.85
parseWidgetModeFunction · 0.85
expandHomePathFunction · 0.85
defaultStateDirFunction · 0.85

Tested by

no test coverage detected