adhocteam / pushup

Pushup is for making modern, page-oriented web apps in Go
https://pushup.adhoc.dev
MIT License
840 stars 30 forks source link

`go build -out-dir $(pwd)` will delete your working directory #74

Open llimllib opened 1 year ago

llimllib commented 1 year ago

Right now the first step in the build process is to delete everything in whatever directory you give it for an output directory, this is probably a footgun:

https://github.com/adhocteam/pushup/blob/7b9ec07d4ce06d3cf9fc9fc3d2e0bca92856ee2c/main.go#L303

Is there any reason to delete files other than ones that conflict with what pushup is building?

paulsmith commented 1 year ago

Correct, it's intended to prevent accidental behavior such as a file generated from a previous run causing a Go compilation error.

What are the better approaches?

llimllib commented 1 year ago

What about this:

llimllib commented 1 year ago

potentially with a --force-delete or similar option to allow the user to skip the warning; alternatively you could just leave it up to their responsibility to clear the directory before building if they don't want to receive the prompt

llimllib commented 1 year ago

in #83 we decided to aim for a nondestructive strategy rather than asking for permission to delete, which is not a great DX.

The next question is, how?

Given a build directory build, we want to build our app without interference from old versions of the app, and also without destroying all the files within (the current, "destructive" strategy).

A simple strategy would be:

That might ultimately create more files than are strictly necessary, but it's hard for me to see how we can safely re-use a directory that's already been used?