nodecg / nodecg-cli

NodeCG's command line interface. https://github.com/nodecg/nodecg
13 stars 9 forks source link

Generate default bundle config from configschema.json #12

Closed denolfe closed 8 years ago

denolfe commented 8 years ago

I looked into this last night after speaking briefly with @Lange on gitter. Generating questions for inquirer.js to question the user, then populate a config is not feasible due to how complex a schema can be.

However, generating a config based on the configschema.json can be done rather easily using something like JSON-Schema-Instantiator, which supports the "default" tag in JSON Schema.

For instance:

{
  "properties": {
    "twitchUsername": {
      "type": "string"
    },
    "updateViewerInterval": {
      "description": "Interval to update viewer count (seconds)",
      "type": "integer",
      "default": 15,
      "minimum": 5
    },
    "updateFollowerInterval": {
      "description": "Interval to update followers (seconds)",
      "type": "integer",
      "default": 15,
      "minimum": 5
    }
  },
  "required": ["twitchUsername"]
}

would output

{
  "twitchUsername": "",
  "updateViewerInterval": 15,
  "updateFollowerInterval": 15
}

Is this something that would still be useful?

denolfe commented 8 years ago

I'll look into using json-schema-defaults.

The name.... Yeah, I'm unsure as well. nodecg defaultconfig is ugly, but nodecg config is a bit vague.

denolfe commented 8 years ago

Closed by e247110