Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/typescript-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ jobs:
fi

- name: Generate client bindings
working-directory: templates/quickstart-chat-typescript
working-directory: templates/chat-react-ts
run: |
pnpm generate

- name: Check for changes
working-directory: templates/quickstart-chat-typescript
working-directory: templates/chat-react-ts
run: |
"${GITHUB_WORKSPACE}"/tools/check-diff.sh src/module_bindings || {
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
Expand All @@ -144,7 +144,7 @@ jobs:
# spacetime logs quickstart-chat

- name: Check that quickstart-chat builds
working-directory: templates/quickstart-chat-typescript
working-directory: templates/chat-react-ts
run: pnpm build

- name: Check that templates build
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ members = [
"modules/keynote-benchmarks",
"modules/perf-test",
"modules/module-test",
"templates/quickstart-chat-rust/spacetimedb",
"templates/chat-console-rs/spacetimedb",
"modules/sdk-test",
"modules/sdk-test-connect-disconnect",
"modules/sdk-test-procedure",
Expand Down
6 changes: 3 additions & 3 deletions crates/bindings-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"generate:moduledef": "cargo run -p spacetimedb-codegen --example regen-typescript-moduledef && prettier --write src/lib/autogen",
"generate:client-api": "cargo run -p generate-client-api && prettier --write src/sdk/client_api",
"generate:test-app": "pnpm --filter @clockworklabs/test-app generate",
"generate:examples:quickstart-chat": "pnpm --filter @clockworklabs/quickstart-chat generate",
"generate:examples:basic-react": "pnpm --filter @clockworklabs/basic-react generate",
"generate:examples:chat-react-ts": "pnpm --filter @clockworklabs/chat-react-ts generate",
"generate:examples:react-ts": "pnpm --filter @clockworklabs/react-ts generate",
"generate:examples:empty": "pnpm --filter @clockworklabs/empty-client generate",
"generate": "pnpm generate:moduledef && pnpm generate:client-api && pnpm generate:test-app && pnpm generate:examples:quickstart-chat && pnpm generate:examples:basic-react && pnpm generate:examples:empty",
"generate": "pnpm generate:moduledef && pnpm generate:client-api && pnpm generate:test-app && pnpm generate:examples:chat-react-ts && pnpm generate:examples:react-ts && pnpm generate:examples:empty",
"prepublishOnly": "pnpm run build && pnpm run test && pnpm run size"
},
"main": "dist/index.cjs",
Expand Down
24 changes: 12 additions & 12 deletions crates/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ fn generate_template_entry(code: &mut String, template_path: &Path, source: &str
// Example: crates/cli
let manifest_rel = manifest_canonical.strip_prefix(&repo_root_canonical).unwrap();

// Example for inside crate: /Users/user/SpacetimeDB/crates/cli/templates/basic-rust/server
// Example for outside crate: /Users/user/SpacetimeDB/modules/quickstart-chat
// Example for inside crate: /Users/user/SpacetimeDB/crates/cli/templates/basic-rs/server
// Example for outside crate: /Users/user/SpacetimeDB/modules/chat-console-rs
let resolved_canonical = repo_root.join(&resolved_base).canonicalize().unwrap();

// If the files are outside of the cli crate we need to copy them to the crate directory,
Expand All @@ -337,8 +337,8 @@ fn generate_template_entry(code: &mut String, template_path: &Path, source: &str
code.push_str(" let mut files = HashMap::new();\n");

for file_path in git_files {
// Example file_path: modules/quickstart-chat/src/lib.rs (relative to repo root)
// Example resolved_base: modules/quickstart-chat
// Example file_path: modules/chat-console-rs/src/lib.rs (relative to repo root)
// Example resolved_base: modules/chat-console-rs
// Example relative_path: src/lib.rs
let relative_path = match file_path.strip_prefix(&resolved_base) {
Ok(p) => p,
Expand All @@ -360,33 +360,33 @@ fn generate_template_entry(code: &mut String, template_path: &Path, source: &str
if full_path.exists() && full_path.is_file() {
let include_path = if let Some(ref copy_dir) = local_copy_dir {
// Outside crate: copy to .templates
// Example dest_file: /Users/user/SpacetimeDB/crates/cli/.templates/parent_parent_modules_quickstart-chat/src/lib.rs
// Example dest_file: /Users/user/SpacetimeDB/crates/cli/.templates/parent_parent_modules_chat-console-rs/src/lib.rs
let dest_file = copy_dir.join(relative_path);
fs::create_dir_all(dest_file.parent().unwrap()).expect("Failed to create parent directory");
copy_if_changed(&full_path, &dest_file)
.unwrap_or_else(|_| panic!("Failed to copy file {:?} to {:?}", full_path, dest_file));

// Example relative_to_manifest: .templates/parent_parent_modules_quickstart-chat/src/lib.rs
// Example relative_to_manifest: .templates/parent_parent_modules_chat-console-rs/src/lib.rs
let relative_to_manifest = dest_file.strip_prefix(manifest_dir).unwrap();
let path_str = relative_to_manifest.to_str().unwrap().replace("\\", "/");
// Watch the original file for changes
// Example: modules/quickstart-chat/src/lib.rs
// Example: modules/chat-console-rs/src/lib.rs
println!("cargo:rerun-if-changed={}", full_path.display());
path_str
} else {
// Inside crate: use path relative to CARGO_MANIFEST_DIR
// Example file_path: crates/cli/templates/basic-rust/server/src/lib.rs
// Example file_path: crates/cli/templates/basic-rs/server/src/lib.rs
// Example manifest_rel: crates/cli
// Result: templates/basic-rust/server/src/lib.rs
// Result: templates/basic-rs/server/src/lib.rs
let relative_to_manifest = file_path.strip_prefix(manifest_rel).unwrap();
let path_str = relative_to_manifest.to_str().unwrap().replace("\\", "/");
// Example: crates/cli/templates/basic-rust/server/src/lib.rs
// Example: crates/cli/templates/basic-rs/server/src/lib.rs
println!("cargo:rerun-if-changed={}", full_path.display());
path_str
};

// Example include_path (inside crate): "templates/basic-rust/server/src/lib.rs"
// Example include_path (outside crate): ".templates/parent_parent_modules_quickstart-chat/src/lib.rs"
// Example include_path (inside crate): "templates/basic-rs/server/src/lib.rs"
// Example include_path (outside crate): ".templates/parent_parent_modules_chat-console-rs/src/lib.rs"
// Example relative_str: "src/lib.rs"
code.push_str(&format!(
" files.insert(\"{}\", include_str!(concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/{}\")));\n",
Expand Down
16 changes: 8 additions & 8 deletions crates/cli/src/subcommands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1484,11 +1484,11 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> anyhow::Result<PathB
pub fn init_rust_project(project_path: &Path) -> anyhow::Result<()> {
let export_files = vec![
(
include_str!("../../../../templates/basic-rust/spacetimedb/Cargo.toml"),
include_str!("../../../../templates/basic-rs/spacetimedb/Cargo.toml"),
"Cargo.toml",
),
(
include_str!("../../../../templates/basic-rust/spacetimedb/src/lib.rs"),
include_str!("../../../../templates/basic-rs/spacetimedb/src/lib.rs"),
"src/lib.rs",
),
];
Expand All @@ -1508,15 +1508,15 @@ pub fn init_rust_project(project_path: &Path) -> anyhow::Result<()> {
pub fn init_csharp_project(project_path: &Path) -> anyhow::Result<()> {
let export_files = vec![
(
include_str!("../../../../templates/basic-c-sharp/spacetimedb/StdbModule.csproj"),
include_str!("../../../../templates/basic-cs/spacetimedb/StdbModule.csproj"),
"StdbModule.csproj",
),
(
include_str!("../../../../templates/basic-c-sharp/spacetimedb/Lib.cs"),
include_str!("../../../../templates/basic-cs/spacetimedb/Lib.cs"),
"Lib.cs",
),
(
include_str!("../../../../templates/basic-c-sharp/spacetimedb/global.json"),
include_str!("../../../../templates/basic-cs/spacetimedb/global.json"),
"global.json",
),
];
Expand All @@ -1536,15 +1536,15 @@ pub fn init_csharp_project(project_path: &Path) -> anyhow::Result<()> {
pub fn init_typescript_project(project_path: &Path) -> anyhow::Result<()> {
let export_files = vec![
(
include_str!("../../../../templates/basic-typescript/spacetimedb/package.json"),
include_str!("../../../../templates/basic-ts/spacetimedb/package.json"),
"package.json",
),
(
include_str!("../../../../templates/basic-typescript/spacetimedb/tsconfig.json"),
include_str!("../../../../templates/basic-ts/spacetimedb/tsconfig.json"),
"tsconfig.json",
),
(
include_str!("../../../../templates/basic-typescript/spacetimedb/src/index.ts"),
include_str!("../../../../templates/basic-ts/spacetimedb/src/index.ts"),
"src/index.ts",
),
];
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn cli_init_with_template_creates_project() {
.args([
"init",
"--template",
"basic-rust",
"basic-rs",
"--local",
"--non-interactive",
"test-project",
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn cli_can_publish_spacetimedb_on_disk() {
// dir = <workspace_root>/modules/quickstart-chat
let dir = workspace_dir
.join("templates")
.join("quickstart-chat-rust")
.join("chat-console-rs")
.join("spacetimedb");

let mut cmd = cargo_bin_cmd!("spacetimedb-cli");
Expand Down
2 changes: 1 addition & 1 deletion docs/STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,4 @@ If the tutorial involved writing code, add a link to the complete code. This sho

At the end of the tutorial that builds the `quickstart-chat` module in Rust, you might write:

> You can find the full code for this module in [the SpacetimeDB module examples](https://github.com/clockworklabs/SpacetimeDB/tree/master/templates/quickstart-chat-rust/spacetimedb).
> You can find the full code for this module in [the SpacetimeDB module examples](https://github.com/clockworklabs/SpacetimeDB/tree/master/templates/chat-console-rs/spacetimedb).
2 changes: 1 addition & 1 deletion docs/docs/00100-intro/00200-quickstarts/00100-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Get a SpacetimeDB React app running in under 5 minutes.
</StepText>
<StepCode>
```bash
spacetime dev --template basic-react my-spacetime-app
spacetime dev --template react-ts my-spacetime-app
```
</StepCode>
</Step>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Get a SpacetimeDB TypeScript app running in under 5 minutes.
</StepText>
<StepCode>
```bash
spacetime dev --template basic-typescript my-spacetime-app
spacetime dev --template basic-ts my-spacetime-app
```
</StepCode>
</Step>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/00100-intro/00200-quickstarts/00500-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Get a SpacetimeDB Rust app running in under 5 minutes.
</StepText>
<StepCode>
```bash
spacetime dev --template basic-rust my-spacetime-app
spacetime dev --template basic-rs my-spacetime-app
```
</StepCode>
</Step>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/00100-intro/00200-quickstarts/00600-c-sharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dotnet workload install wasi-experimental
</StepText>
<StepCode>
```bash
spacetime dev --template basic-c-sharp my-spacetime-app
spacetime dev --template basic-cs my-spacetime-app
```
</StepCode>
</Step>
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/00100-intro/00300-tutorials/00100-chat-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,9 @@ Output will resemble:
```

You've just set up your first SpacetimeDB module! You can find the full code for this module:
- [TypeScript server module](https://github.com/clockworklabs/SpacetimeDB/tree/master/templates/quickstart-chat-typescript)
- [C# server module](https://github.com/clockworklabs/SpacetimeDB/tree/master/templates/quickstart-chat-c-sharp/spacetimedb)
- [Rust server module](https://github.com/clockworklabs/SpacetimeDB/tree/master/templates/quickstart-chat-rust/spacetimedb)
- [TypeScript server module](https://github.com/clockworklabs/SpacetimeDB/tree/master/templates/chat-react-ts)
- [C# server module](https://github.com/clockworklabs/SpacetimeDB/tree/master/templates/chat-console-cs/spacetimedb)
- [Rust server module](https://github.com/clockworklabs/SpacetimeDB/tree/master/templates/chat-console-rs/spacetimedb)

---

Expand Down Expand Up @@ -1429,7 +1429,7 @@ You've just experienced the core features of SpacetimeDB: real-time synchronizat

### Conclusion

Congratulations! You've built a simple chat app with SpacetimeDB. You can find the full source code for the client we've created in this quickstart tutorial [here](https://github.com/clockworklabs/SpacetimeDB/tree/master/templates/quickstart-chat-typescript).
Congratulations! You've built a simple chat app with SpacetimeDB. You can find the full source code for the client we've created in this quickstart tutorial [here](https://github.com/clockworklabs/SpacetimeDB/tree/master/templates/chat-react-ts).

At this point you've learned how to create a basic TypeScript client for your SpacetimeDB `quickstart-chat` module. You've learned how to connect to SpacetimeDB and call reducers to update data. You've learned how to subscribe to table data, and hook it up so that it updates reactively in a React application.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ Creates a full-stack React web application with:
#### Use Template
Choose from several built-in templates:

- `basic-typescript` - Basic TypeScript client and server stubs
- `basic-c-sharp` - Basic C# client and server stubs
- `basic-rust` - Basic Rust client and server stubs
- `basic-react` - React web app with TypeScript server
- `quickstart-chat-rust` - Complete Rust chat implementation
- `quickstart-chat-c-sharp` - Complete C# chat implementation
- `quickstart-chat-typescript` - Complete TypeScript chat implementation
- `basic-ts` - Basic TypeScript client and server stubs
- `basic-cs` - Basic C# client and server stubs
- `basic-rs` - Basic Rust client and server stubs
- `react-ts` - React web app with TypeScript server
- `chat-console-rs` - Complete Rust chat implementation
- `chat-console-cs` - Complete C# chat implementation
- `chat-react-ts` - Complete TypeScript chat implementation

You can also clone an existing project by entering a GitHub repository (`owner/repo`) or git URL.

Expand Down
Loading
Loading