MCPcopy
hub / github.com/coder/mux / normalizeProjectRuntimeSettings

Function normalizeProjectRuntimeSettings

src/node/config.ts:593–645  ·  view source on GitHub ↗
(projectConfig: ProjectConfig)

Source from the content-addressed store, hash-verified

591}
592
593function normalizeProjectRuntimeSettings(projectConfig: ProjectConfig): ProjectConfig {
594 // Per-project runtime overrides are optional; keep config.json sparse by persisting only explicit
595 // overrides (false enablement + explicit default runtime selections).
596 if (!projectConfig || typeof projectConfig !== "object") {
597 return { workspaces: [] };
598 }
599
600 const record = projectConfig as ProjectConfig & {
601 runtimeEnablement?: unknown;
602 defaultRuntime?: unknown;
603 runtimeOverridesEnabled?: unknown;
604 projectKind?: unknown;
605 };
606 const runtimeEnablement = normalizeRuntimeEnablementOverrides(record.runtimeEnablement);
607 const defaultRuntime = normalizeRuntimeEnablementId(record.defaultRuntime);
608 const runtimeOverridesEnabled = record.runtimeOverridesEnabled === true ? true : undefined;
609
610 const next = { ...record };
611 delete (next as ProjectConfig & { sections?: unknown }).sections;
612 if (runtimeEnablement) {
613 next.runtimeEnablement = runtimeEnablement;
614 } else {
615 delete next.runtimeEnablement;
616 }
617
618 if (runtimeOverridesEnabled) {
619 next.runtimeOverridesEnabled = runtimeOverridesEnabled;
620 } else {
621 delete next.runtimeOverridesEnabled;
622 }
623
624 if (defaultRuntime) {
625 next.defaultRuntime = defaultRuntime;
626 } else {
627 delete next.defaultRuntime;
628 }
629
630 const workspaces = Array.isArray(record.workspaces) ? record.workspaces : [];
631 next.workspaces = workspaces.map(stripLegacyWorkspaceWorkflowSchedule);
632
633 const projectKind = normalizeProjectKind(record.projectKind);
634 if (projectKind !== undefined) {
635 next.projectKind = projectKind;
636 } else {
637 delete next.projectKind;
638 }
639
640 // Legacy named workflow schedules are intentionally dropped while workflow
641 // scheduling is disabled during the explicit script_path migration.
642 delete (next as ProjectConfig & { workflowSchedules?: unknown }).workflowSchedules;
643
644 return next;
645}
646/**
647 * Config - Centralized configuration management
648 *

Callers 2

loadConfigOrDefaultMethod · 0.85
saveConfigMethod · 0.85

Tested by

no test coverage detected