Add JSON schemas for DistroMeta and ServerMeta.

JSON schemas are used by editors to validate data and provide useful insights.
The JSON schemas will be generated by the init root command. They can also be generated
using the generate schemas command.

The JSON files will reference the schemas on the user's local disk rather than hosted versions.
This allows offline editing and ensures that the schema is exactly one-to-one with the local
version of Nebula.

Existing servers will have to manually add the schema property. To see how to do this, generate
a new server and copy the $\schema value.
The schema property will need to be added to any existing distrometa files. This is the same
format as the server meta, just replace ServerMeta with DistroMeta.

More information, including sample files with json schemas, is provided
on the README.
This commit is contained in:
Daniel Scalzi
2020-09-13 00:47:18 -04:00
parent 24b0923903
commit 42e47f4748
9 changed files with 207 additions and 21 deletions

View File

@@ -72,7 +72,7 @@ __*Subcommands*__
#### Init Root
Generate an empty standard file structure.
Generate an empty standard file structure. JSON schemas will also be generated.
`init root`
@@ -139,6 +139,14 @@ Options:
---
#### Generate Schemas
Generate the JSON schemas used by Nebula's internal types (ex. Distro Meta and Server Meta schemas). This command should be used to update the schemas when a change to Nebula requires it. You may need to reopen your editor for the new JSON schemas to take effect.
`generate schemas`
---
### Latest Forge
Get the latest version of Forge.
@@ -200,14 +208,19 @@ If a directory represents a toggleable mod, it will have three subdirectories. Y
### Additional Metadata
To preserve metadata that cannot be inferred via file structure, two files exist. Default values will be generated when applicable. Customize to fit your needs. These values should be self explanatory. If further details are required, see the [distribution.json specification document][distro.md].
To preserve metadata that cannot be inferred via file structure, two files exist. Default values will be generated when applicable. Customize to fit your needs. These values should be self explanatory. If further details are required, see the [distribution.json specification document][distro.md].
#### ${ROOT}/meta/distrometa.json
Represents the additiona metadata on the distribution object. Sample:
Represents the additiona metadata on the distribution object.
A JSON schema is provided to assist editing this file. It should automatically be referenced when the default file is generated.
Sample:
```json
{
"$schema": "file:///${ROOT}/schemas/DistroMetaSchema.schema.json",
"meta": {
"rss": "<LINK TO RSS FEED>",
"discord": {
@@ -221,10 +234,15 @@ Represents the additiona metadata on the distribution object. Sample:
#### servers/${YOUR_SERVER}/servermeta.json
Represents the additional metadata on the server object (for a YOUR_SERVER). Sample:
Represents the additional metadata on the server object (for a YOUR_SERVER).
A JSON schema is provided to assist editing this file. It should automatically be referenced when the default file is generated.
Sample:
```json
{
"$schema": "file:///${ROOT}/schemas/ServerMetaSchema.schema.json",
"meta": {
"version": "1.0.0",
"name": "Test (Minecraft 1.12.2)",
@@ -285,6 +303,13 @@ In the above example, all files of type `cfg` in the config directory will be un
Another example where all `optionalon` forgemods and litemods are untracked. **Untracking mods is NOT recommended. This is an example ONLY.**
### Note on JSON Schemas
The `$schema` property in a JSON file is a URL to a JSON schema file. This property is optional. Nebula provides schemas for internal types to make editing the JSON easier. Editors, such as Visual Studio Code, will use this schema file to validate the data and show useful information, like property descriptions. Valid properties will also be autocompleted. For detailed information, you may view the [JSON Schema Website](jsonschemawebsite).
Nebula will store JSON schemas in `${ROOT}/schemas`. This is so that they will always be in sync with your local version of Nebula. They will initially be generated by the `init root` command. To update the schemas, you can run the `generate schemas` command.
[dotenvnpm]: https://www.npmjs.com/package/dotenv
[distro.md]: https://github.com/dscalzi/HeliosLauncher/blob/master/docs/distro.md
[distro.md]: https://github.com/dscalzi/HeliosLauncher/blob/master/docs/distro.md
[jsonschemawebsite]: https://json-schema.org/