Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI - spacetime generate always deletes stale files #1774

Merged
merged 5 commits into from
Oct 1, 2024

Conversation

bfops
Copy link
Collaborator

@bfops bfops commented Sep 30, 2024

Description of Changes

spacetime generate --delete-files deletes all files in the target directory that start with the SpacetimeDB autogenerated file header. This PR makes turns that behavior permanently on, and removes the flag.

We think this is unlikely to negatively affect users, since it only deletes files that start with the header that is automatically generated by SpacetimeDB. If users do experience negative effects, we can add a flag to disable this behavior.

API and ABI breaking changes

Yes. We no longer support --delete-files.

Expected complexity level and risk

2

Testing

$ cargo run -- generate --lang csharp --out-dir $WORK/my_new_project/ --project-path $WORK/my_new_project/
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.23s
     Running `target/debug/spacetime generate --lang csharp --out-dir /home/lead/work/clockwork/my_new_project/ --project-path /home/lead/work/clockwork/my_new_project/`
Saving config to /home/lead/.spacetime/config.toml.
info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date
checking crate with spacetimedb's clippy configuration
    Checking spacetime-module v0.1.0 (/mnt/nutera/work/my_new_project)
    Finished `release` profile [optimized] target(s) in 0.15s
    Finished `release` profile [optimized] target(s) in 0.07s
Optimising module with wasm-opt...
Could not find wasm-opt to optimise the module.
For best performance install wasm-opt from https://github.com/WebAssembly/binaryen/releases.
Continuing with unoptimised module.
Build finished successfully.
compilation took 2.092558726s
Generate finished successfully.

$ cp $WORK/my_new_project/AddReducer.{cs,cs.stale}

$ cargo run -- generate --lang csharp --out-dir $WORK/my_new_project/ --project-path $WORK/my_new_project/
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.23s
     Running `target/debug/spacetime generate --lang csharp --out-dir /home/lead/work/clockwork/my_new_project/ --project-path /home/lead/work/clockwork/my_new_project/`
Saving config to /home/lead/.spacetime/config.toml.
info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date
checking crate with spacetimedb's clippy configuration
    Checking spacetime-module v0.1.0 (/mnt/nutera/work/my_new_project)
    Finished `release` profile [optimized] target(s) in 0.14s
    Finished `release` profile [optimized] target(s) in 0.07s
Optimising module with wasm-opt...
Could not find wasm-opt to optimise the module.
For best performance install wasm-opt from https://github.com/WebAssembly/binaryen/releases.
Continuing with unoptimised module.
Build finished successfully.
compilation took 2.110778341s
The following files were not generated by this command and will be deleted:
  /home/lead/work/clockwork/my_new_project/AddReducer.cs.stale
Are you sure you want to delete these files? [y/N]y
Files deleted successfully.
Generate finished successfully.

@bfops bfops requested a review from jdetter September 30, 2024 22:46
.iter()
.any(|x| x.file_name().unwrap() == path.file_name().unwrap())
{
// TODO: We should probably just delete all generated files before we generate any, rather than selectively deleting some afterward.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bfops Yeah hold on I think there are some bugs here. We only prompt users after we've already done the generation? That seems wrong to me. Also we should only be replacing files which contain our special header, not just overwriting whatever file is already there. Can we fix those issues here or do you want to do a separate PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's do those things in a separate PR since they're not API-breaking.
Also, it looks like we have the capacity to generate files in subdirectories, but it's not clear to me that we can delete them from subdirectories..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created #1786

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.

I'm approving this - we're fixing the other existing issues in a separate PR

@bfops bfops added this pull request to the merge queue Oct 1, 2024
Merged via the queue into master with commit 6fa8fe1 Oct 1, 2024
11 checks passed
@bfops bfops deleted the bfops/cli-generate-delete branch October 18, 2024 19:09
@bfops bfops added the api-break A PR that makes an API breaking change label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-break A PR that makes an API breaking change release-0.12
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants