Files
clockwork-labs-bot 9fbb322b0b CLI - preserve leading .. in --out-dir paths (#4431)
## Problem

`spacetime generate --out-dir ../frontend-ts-src/module-bindings` was
resolving the path incorrectly, stripping the leading `..` component.
Reported in #4429 via a [user report on
Discord](https://discord.com/channels/1037340874172014652/1475935288919462072/1475935288919462072).

## Root Cause

`normalize_path_lexical()` in `spacetime_config.rs` used
`PathBuf::pop()` to handle `..` components, but `pop()` is a no-op on an
empty `PathBuf`. This silently dropped leading `..` segments:

- Input: `../frontend-ts-src/module-bindings`
- Output: `frontend-ts-src/module-bindings` (wrong — `..` was eaten)

## Fix

Replace the `PathBuf`-based normalization with a `Vec<Component>` stack
approach. `..` only cancels a preceding `Normal` component; otherwise it
is preserved. This correctly handles:

- `../foo` → `../foo` (leading `..` preserved)
- `../../a/b` → `../../a/b` (multiple leading `..` preserved)
- `a/b/../c` → `a/c` (inner `..` still resolves)
- `/home/user/project/../foo` → `/home/user/foo` (absolute paths work)

## Testing

Added `test_normalize_path_preserves_leading_dotdot` covering all edge
cases.

Closes #4429

---------

Co-authored-by: clockwork-labs-bot <bot@clockworklabs.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-02-26 19:54:20 +00:00

111 lines
3.1 KiB
TOML

[package]
name = "spacetimedb-cli"
version.workspace = true
edition.workspace = true
license-file = "LICENSE"
description = "A command line interface for SpacetimeDB"
rust-version.workspace = true
[features]
markdown-docs = []
[lib]
bench = false
[[bin]]
name = "spacetimedb-cli"
path = "src/main.rs"
# Benching off, because of https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options
bench = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
spacetimedb-auth.workspace = true
spacetimedb-client-api-messages.workspace = true
spacetimedb-codegen.workspace = true
spacetimedb-data-structures.workspace = true
spacetimedb-fs-utils.workspace = true
spacetimedb-lib.workspace = true
spacetimedb-paths.workspace = true
spacetimedb-primitives.workspace = true
spacetimedb-schema.workspace = true
anyhow.workspace = true
base64.workspace = true
bytes.workspace = true
cargo_metadata.workspace = true
chrono.workspace = true
clap = { workspace = true, features = ["derive", "env", "string"] }
colored.workspace = true
convert_case.workspace = true
dirs.workspace = true
duct.workspace = true
email_address.workspace = true
futures.workspace = true
flate2.workspace = true
fs-err.workspace = true
http.workspace = true
is-terminal.workspace = true
itertools.workspace = true
ignore.workspace = true
indicatif.workspace = true
json5.workspace = true
jsonwebtoken.workspace = true
mimalloc.workspace = true
percent-encoding.workspace = true
regex.workspace = true
reqwest.workspace = true
rustyline.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["raw_value", "preserve_order"] }
serde_with = { workspace = true, features = ["chrono_0_4"] }
slab.workspace = true
syntect.workspace = true
tabled.workspace = true
tar.workspace = true
tempfile.workspace = true
termcolor.workspace = true
termtree.workspace = true
thiserror.workspace = true
tokio.workspace = true
tokio-tungstenite.workspace = true
toml.workspace = true
toml_edit.workspace = true
tracing = { workspace = true, features = ["release_max_level_off"] }
walkdir.workspace = true
wasmbin.workspace = true
webbrowser.workspace = true
clap-markdown.workspace = true
git2.workspace = true
glob.workspace = true
dialoguer = { workspace = true, features = ["fuzzy-select"] }
rolldown.workspace = true
rolldown_common.workspace = true
rolldown_error.workspace = true
rolldown_utils.workspace = true
xmltree.workspace = true
quick-xml.workspace = true
names.workspace = true
notify.workspace = true
path-clean = "1.0.1"
[dev-dependencies]
pretty_assertions.workspace = true
fs_extra.workspace = true
[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = { workspace = true }
tikv-jemalloc-ctl = { workspace = true }
[target.'cfg(windows)'.dependencies]
windows-sys = { workspace = true, features = ["Win32_System_Console"] }
[build-dependencies]
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
toml.workspace = true
[lints]
workspace = true