Automattic / Automattic/dot-handy

Unify the schema of configurable properties.

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
3
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Currently dot-handy provides two ways to configure: commandline parameters and configuration files. However, they are connected loosely in a hard-coding way. The configuration files are flexible JSON files that can be written arbitrarily, and the overrides from the command line are bound to those properties through [hard-coding code in main.js](https://github.com/Automattic/dot-handy/blob/trunk/main.js#L17):

```
// TODO: this shouldn't be too hard to generalized to enable complete overriding of config flags through commandline params. I should consider to implement a config schema.
const parseOverrides = ( argv ) => {
const eligibleParams = [
'browser',
'cookies',
'currency',
'env',
'path',
'username',
'password',
'localstorage',
'locale',
];

const overrides = {};

for( const key of eligibleParams ) {
if ( argv[ key ] ) {
// FIXME: terrible!
if ( key == 'localstorage' || key == 'cookies' ) {
overrides[ key ] = JSON.parse( argv[ key] );
continue;
}
overrides[ key ] = argv[ key];
}
}

return overrides;
};
```

Ideally,

1. There should be a unified schema defining what's available in a configuration object.
2. How configuration properties bound to command line parameters won't need to be coded explicitly like this.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in main.js at parseOverrides and inspect how command-line arguments and configuration-file properties are currently connected. Define the configuration shape and replace the explicit eligibleParams mapping with a schema-driven connection; done means available properties and command-line overrides share one configuration definition without this hard-coded list.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.