Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function generateEnvConfigs(slug: string, name: string, portOffset: numbe
const be = 4000 + portOffset;

const header =
"import type { DeepPartial } from '../src/config-builder/types';\nimport type _default from './config.default';\n";
"import type { DeepPartial } from '../src/config-builder/types';\nimport type { config as _default } from './config.default';\n";

// Per-environment specs: optional imports + object props (= prefix → raw TS expression)
const envs: Record<string, { imports?: string; props: Record<string, string | boolean> }> = {
Expand Down Expand Up @@ -148,7 +148,7 @@ export function generateEnvConfigs(slug: string, name: string, portOffset: numbe
},
},
test: {
imports: "import development from './config.development';\n",
imports: "import { development } from './config.development';\n",
props: {
domain: '',
frontendUrl: '=development.frontendUrl',
Expand All @@ -174,7 +174,7 @@ export function generateEnvConfigs(slug: string, name: string, portOffset: numbe
.map(([k, v]) => ` ${k}: ${lit(v)},`)
.join('\n');
result[`./shared/config/config.${mode}.ts`] =
`${imports}${header}\nexport default {\n mode: '${mode}',\n${nameEntry}${body}\n} satisfies DeepPartial<typeof _default>;\n`;
`${header}${imports}\nexport const ${mode} = {\n mode: '${mode}',\n${nameEntry}${body}\n} satisfies DeepPartial<typeof _default>;\n`;
}

return result;
Expand Down
11 changes: 10 additions & 1 deletion tests/env-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ describe('generateEnvConfigs', () => {
}
});

it('exports each environment as a named const (config-builder imports them by name)', () => {
for (const mode of ['development', 'staging', 'tunnel', 'test', 'production']) {
const content = configs[`./shared/config/config.${mode}.ts`];
expect(content).toContain(`export const ${mode} = {`);
expect(content).not.toContain('export default');
expect(content).toContain("import type { config as _default } from './config.default'");
}
});

it('imports DeepPartial from the config-builder module', () => {
for (const content of Object.values(configs)) {
expect(content).toContain("from '../src/config-builder/types'");
Expand All @@ -95,7 +104,7 @@ describe('generateEnvConfigs', () => {

it('derives test urls from development as raw expressions', () => {
const test = configs['./shared/config/config.test.ts'];
expect(test).toContain("import development from './config.development'");
expect(test).toContain("import { development } from './config.development'");
expect(test).toContain('frontendUrl: development.frontendUrl');
expect(test).toContain('backendUrl: development.backendUrl');
});
Expand Down