Skip to content

Commit 8ba2ed8

Browse files
droguscloutiertylerjdetter
authored
spacetime init rewrite (#3366)
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) --------- Signed-off-by: Tyler Cloutier <[email protected]> Signed-off-by: John Detter <[email protected]> Co-authored-by: = <[email protected]> Co-authored-by: Tyler Cloutier <[email protected]> Co-authored-by: Tyler Cloutier <[email protected]> Co-authored-by: John Detter <[email protected]>
1 parent 912cbf9 commit 8ba2ed8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

examples~/quickstart-chat/client/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ void Main()
3434
}
3535

3636
/// The URI of the SpacetimeDB instance hosting our chat module.
37-
const string HOST = "http://localhost:3000";
37+
string HOST = Environment.GetEnvironmentVariable("SPACETIMEDB_HOST") ?? "http://localhost:3000";
3838

3939
/// The module name we chose when we published our module.
40-
const string DBNAME = "quickstart-chat";
40+
string DB_NAME = Environment.GetEnvironmentVariable("SPACETIMEDB_DB_NAME") ?? "quickstart-chat";
4141

4242
/// Load credentials from a file and connect to the database.
4343
DbConnection ConnectToDB()
4444
{
4545
DbConnection? conn = null;
4646
conn = DbConnection.Builder()
4747
.WithUri(HOST)
48-
.WithModuleName(DBNAME)
48+
.WithModuleName(DB_NAME)
4949
.WithToken(AuthToken.Token)
5050
.OnConnect(OnConnected)
5151
.OnConnectError(OnConnectError)

examples~/quickstart-chat/client/client.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@
1515
<ProjectReference Include="../../../SpacetimeDB.ClientSDK.csproj" />
1616
</ItemGroup>
1717

18+
<ItemGroup>
19+
<Compile Remove="spacetimedb/**" />
20+
</ItemGroup>
21+
1822
</Project>

0 commit comments

Comments
 (0)