FluffyLabs / FluffyLabs/typeberry

Improve config ovewrite

Open
#822 0 comments 0 reactions 0 assignees View on GitHub
M-node
Dominant language
TypeScript
Stars
10
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Currently it's possible to overwrite some part of the config using the pseudo-jq syntax (introduced in #733).

So I can just load a different chain spec, like so:
```
npm start -- --config=default --config=".chain_spec = ./chain-spec.json"
```

However it's necessary to provide the initial `--config=default` as a base config, otherwise we get a rather cryptic error:
```bash
> NODE_ENV=development tsx ./index.ts --config=.chain_spec = ./chain-spec.json import ./fallback.bin

LOG [config] 🔧 Loading config
LOG [config] 🔧 Applying '.chain_spec = ./chain-spec.json'
Error: Unable to parse config: Error: [] Error while parsing the value: Error: [] Unexpected or missing keys: ,"$schema" | ,"authorship" | ,"flavor" | ,"version"
Data: chain_spec,database_base_path
Schema: $schema,version,flavor,chain_spec,database_base_path,authorship
```

My proposed solution would be to simply always apply `default` config at the very beginning. However we should make sure that loading another full config will ovewrite the entire config instead of doing a deep merge, so: `--config=default --config=dev` should simply load dev config and not deep merge `default` with `dev` (as it is currently)

CC @skoszuta

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.