fix: bootstrap config propagation

This commit is contained in:
cha0s 2024-02-07 15:40:46 -06:00
parent 85020d98df
commit 9a0a028d63
2 changed files with 31 additions and 4 deletions

View File

@ -116,6 +116,10 @@ class Flecks {
for (let i = 0; i < flecks.length; i++) {
this.configureFleckDefaults(flecks[i]);
}
this.config = {
...this.bootstrappedConfig,
...this.config,
};
}
/**

View File

@ -1,14 +1,37 @@
import {mkdir, writeFile} from 'fs/promises';
import {join} from 'path';
import {expect} from 'chai';
import {build, createApplication, serverActions} from './build/build';
it('propagates bootstrap config', async () => {
const path = await createApplication();
await mkdir(join(path, 'server-only', 'build'), {recursive: true});
await writeFile(join(path, 'server-only', 'package.json'), '{}');
const config = `
exports.hooks = {
'@flecks/core.config': () => ({
foo: 'bar',
}),
};
`;
await writeFile(join(path, 'server-only', 'build', 'flecks.bootstrap.js'), config);
await writeFile(
join(path, 'build', 'flecks.yml'),
`
'@flecks/build': {}
'@flecks/core': {}
'@flecks/server': {}
'comm:./comm': {}
'server-only:./server-only': {}
`,
);
await build(path, {args: ['-d']});
const {results: [{payload: id}]} = await serverActions(path, [
{type: 'config.get', payload: '@flecks/core.id'},
const {results: [{payload: foo}]} = await serverActions(path, [
{type: 'config.get', payload: 'server-only.foo'},
{type: 'exit'},
]);
expect(id)
.to.equal('flecks');
expect(foo)
.to.equal('bar');
});