spacetime.json config implementation
#4199
Open
+2,884
−261
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
This PR implements support for the
spacetime.jsonconfiguration file that can be used to set up commongenerateandpublishtargets. An example ofspacetime.jsoncould look like this:With this config, running
spacetime generatewithout any arguments would generate bindings for two targets:region-moduleandglobal-module.spacetime publishwithout any arguments would publish three modules, starting from the parent:bitcraft,region-1, andregion-2. On top of that, the commandpnpm devwould be executed when usingspacetime dev.It is also possible to pass additional command line arguments when calling the
publishandgeneratecommands, but there are certain limitations. There is a special case when passing either a module path to generate or a module name to publish. Doing that will filter out entries in the config file that do not match. For example, running:would only generate bindings for the second entry in the
generatelist.In a similar fashion, running:
would only publish the child database with the name
region-1Passing other existing arguments is also possible, but not all of the arguments are available for multiple configs. For example, when running
spacetime publish --server maincloud, the publish command would be applied to all of the modules listed in the config file, but theservervalue from the command line arguments would take precedence. Running with arguments like--bin-pathwould, however, would throw an error as--bin-pathmakes sense only in a context of a specific module, thus this wouldn't work:spacetime publish --bin-path spacetimedb/target/debug/bitcraft.wasm. I will throw an error unless there is only one entry to process, thusspacetime publish --bin-path spacetimedb/target/debug/bitcraft.wasm bitcraftwould work, as it filters the publish targets to one entry.API and ABI breaking changes
None
Expected complexity level and risk
3
The config file in itself is not overly complex, but when coupled with the CLI it is somewhat tricky to get right. There are also some changes that I had to make to how clap arguments are validated - because the values can now come from both the config file and the clap config, we can't use some of the built-in validations like
required, or at least I haven't found a clean way to do so.Testing
I've added some automated tests, but more tests and manual testing is coming.