Skip to content

Conversation

@drogus
Copy link
Collaborator

@drogus drogus commented Oct 7, 2025

This is a draft of the new functionality for spacetime init. In order to run it with built-in templates you have to set the path to the config file:

export SPACETIMEDB_CLI_TEMPLATES_FILE=crates/cli/.init-templates.json

In the future it will fetch the list from GH.

A few notes:

  • the previous functionality of spacetime init does not work at the moment
  • the code needs a bit more cleanup and tests before merging
  • there is a bit of a mix in how we generate empty server and client projects. For Rust we use the existing way of generating. For TypeScript we clone an empty project from the repo. I wanted to play with both ways of doing things, and I'm still not sure which is better. Generation in Rust means that the generated code will match the CLI version and not necessarily whatever is in Git. On the other hand, for the builtin templates we will be fetching the newest version from GH, which I guess might also not what we want, ie. we probably want only stable templates. More discussion is needed here
  • we use spacetimedb directory for the server files
  • I don't particularly like the inability to disable interactive mode easily. We discussed disabling it by default if all of the required arguments are passed, but I don't think it's feature proof. For example, if someone relies on a non-interactive mode, and we add a new required argument, instead of printing a message missing --foo, we will automatically launch interactive mode, which is harder to debug. That's why I think I'd prefer to implement --non-interactive argument
  • it's kind of hard to keep the legacy behaviour. If you don't pass any arguments, we go into interactive mode. In the legacy version, we would print required arguments. If someone passes --lang or --project-path explicitly, I guess we could run the legacy workflow, but not sure if it's worth it, as the command was marked as unstable anyway
  • the project path defaults to the project name, but I think we should probably replace change whitespaces to dashes, or at least ask for the project path with the project name being the default (or both)

@drogus drogus self-assigned this Oct 7, 2025
@drogus drogus marked this pull request as draft October 7, 2025 10:55
@drogus drogus force-pushed the drogus/spacetime-init branch 18 times, most recently from c022d34 to ea0f0f7 Compare October 15, 2025 20:52
@drogus drogus force-pushed the drogus/spacetime-init branch from ea0f0f7 to e536cc3 Compare October 15, 2025 20:53
@drogus drogus force-pushed the drogus/spacetime-init branch from 10f14ee to cc118cc Compare October 16, 2025 11:49
Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Copy link
Collaborator

@jdetter jdetter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some UX questions/nits about github templates, I'm still reviewing

Copy link
Collaborator

@jdetter jdetter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More review

Copy link
Collaborator

@jdetter jdetter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some docs feedback for now


```bash
spacetime init --lang=rust server-rust
spacetime init --lang rust server-rust
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I'm being prompted for a project path, I think most users would be smart enough to just press enter to do the default thing but maybe it would be good to just include the --project-path option here so that users don't get prompted?

spacetime init --lang rust server-rust
```

This command creates a new folder named `server-rust` alongside your Unity project `client-unity` directory and sets up the SpacetimeDB server project with Rust as the programming language.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instructions now create a directory structure which looks like this:

boppy@geralt MINGW64 ~/clockwork/tmp
$ ls
server-rust/

boppy@geralt MINGW64 ~/clockwork/tmp
$ ls server-rust/
spacetimedb/

boppy@geralt MINGW64 ~/clockwork/tmp
$ ls server-rust/spacetimedb/
Cargo.toml  src/

I think we need to update the tutorials to use the new flow otherwise some of these steps will be out of date and won't work. For Unity specifically we might want people to run the spacetime init ... command first so that they can then open Unity in the project directory so that Unity can populate the required files. Although I'm not sure if you can create a new Unity project in a directory which already contains files.

I'm happy to help with this if needed 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-any To be landed in any release window

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants