From 6fcedd7eae644ff95602614d7188df390bb081a4 Mon Sep 17 00:00:00 2001 From: Zoe Codez Date: Mon, 16 Feb 2026 20:13:02 -0700 Subject: [PATCH 1/2] Add overrdie --- src/helpers/config-file-loader.mts | 5 +- testing/configuration.spec.mts | 81 ++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/src/helpers/config-file-loader.mts b/src/helpers/config-file-loader.mts index d6c242d6..b509c02c 100644 --- a/src/helpers/config-file-loader.mts +++ b/src/helpers/config-file-loader.mts @@ -45,9 +45,10 @@ export function configFilePaths(name: string): string[] { export async function configLoaderFile< S extends ServiceMap = ServiceMap, C extends ModuleConfiguration = ModuleConfiguration, ->({ application, logger }: ConfigLoaderParams): ConfigLoaderReturn { +>({ application, logger, internal }: ConfigLoaderParams): ConfigLoaderReturn { const CLI_SWITCHES = minimist(process.argv); - const configFile = CLI_SWITCHES.config; + const configFile = + CLI_SWITCHES.config ?? internal?.boot?.options?.configuration?.boilerplate?.CONFIG; let files: string[]; if (is.boolean(configFile)) { logger.fatal({ argv: process.argv }, "system failed to parse argv"); diff --git a/testing/configuration.spec.mts b/testing/configuration.spec.mts index a1332a29..004547dc 100644 --- a/testing/configuration.spec.mts +++ b/testing/configuration.spec.mts @@ -884,6 +884,87 @@ describe("Configuration", () => { expect(readSpy).toHaveBeenCalledWith("./config_file", "utf8"); }); + + it("uses bootstrap-provided CONFIG when no CLI switch", async () => { + vi.spyOn(fs, "existsSync").mockImplementation(() => true); + + const readSpy = vi.spyOn(fs, "readFileSync").mockImplementation(() => ``); + const logger = createMockLogger(); + process.argv = [""]; + await configLoaderFile({ + // @ts-expect-error not needed for test + application: {}, + internal: { + boot: { + options: { + configuration: { + boilerplate: { + CONFIG: "./bootstrap_config.yaml", + }, + }, + }, + }, + } as InternalDefinition, + logger, + }); + + expect(readSpy).toHaveBeenCalledWith("./bootstrap_config.yaml", "utf8"); + }); + + it("CLI switch takes precedence over bootstrap-provided CONFIG", async () => { + vi.spyOn(fs, "existsSync").mockImplementation(() => true); + + const readSpy = vi.spyOn(fs, "readFileSync").mockImplementation(() => ``); + const logger = createMockLogger(); + process.argv = ["", "--config=./cli_config.yaml"]; + await configLoaderFile({ + // @ts-expect-error not needed for test + application: {}, + internal: { + boot: { + options: { + configuration: { + boilerplate: { + CONFIG: "./bootstrap_config.yaml", + }, + }, + }, + }, + } as InternalDefinition, + logger, + }); + + expect(readSpy).toHaveBeenCalledWith("./cli_config.yaml", "utf8"); + }); + + it("bootstrap CONFIG overrides auto-discovery", async () => { + vi.spyOn(fs, "existsSync").mockImplementation(() => true); + // @ts-expect-error rest isn't needed + vi.spyOn(fs, "statSync").mockImplementation(() => ({ isFile: () => true })); + + const readSpy = vi.spyOn(fs, "readFileSync").mockImplementation(() => ``); + const logger = createMockLogger(); + process.argv = [""]; + await configLoaderFile({ + // @ts-expect-error not needed for test + application: { name: "test-app" }, + internal: { + boot: { + options: { + configuration: { + boilerplate: { + CONFIG: "./explicit_config.yaml", + }, + }, + }, + }, + } as InternalDefinition, + logger, + }); + + expect(readSpy).toHaveBeenCalledWith("./explicit_config.yaml", "utf8"); + expect(readSpy).not.toHaveBeenCalledWith(expect.stringContaining(".test-app"), "utf8"); + }); }); // #MARK: loadConfigFromFile From 9bb939c6e6dd82f01b4d41c5e77b9f836929af2c Mon Sep 17 00:00:00 2001 From: Zoe Codez Date: Mon, 16 Feb 2026 20:15:14 -0700 Subject: [PATCH 2/2] comment --- src/services/wiring.service.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/wiring.service.mts b/src/services/wiring.service.mts index 593d9b2c..838976fa 100644 --- a/src/services/wiring.service.mts +++ b/src/services/wiring.service.mts @@ -62,7 +62,7 @@ function createBoilerplate() { return CreateLibrary({ configuration: { /** - * Only usable by **cli switch**. + * Only usable by **cli switch** / application bootstrap. * Pass path to a config file for loader * * ```bash