jkomoros / boardgame

An in-progress framework in golang to easily build boardgame Progressive Web Apps
Apache License 2.0
31 stars 4 forks source link

autoreader should detect when it's out of date #632

Open jkomoros opened 6 years ago

jkomoros commented 6 years ago

In case there's a new version of the library and you're about to overwrite with an old version.

The easiest approach is probably to emit a structure comment in autoreader output that contains the version number of autoreader that created it, and then before we overwrite a file, check to see if it was saved with a newer version of autoreader before, and if so, refuse to overwrite and provide instructions to updgrade autoreader.

jkomoros commented 6 years ago

Also captured in #655, which now makes more sense given that more is moving to that tool.

This is actually pretty easy: boardgame should have the main version as a public field. Autoreader emits something like this at the top of auto_reader.go:

func init() {
  if !boardgame.Version.Equivalent(semvar.Version("BAKED VERSION STRING") {
    panic("Package uses an autoreader generated by an old version of boardgame-util. Re-run `go generate`")
  }
}
jkomoros commented 6 years ago
jkomoros commented 6 years ago

A similar thing should happen for boardgame-util in general. It should check and verify if it's the most recent boardgame-util version or if it needs to be reinstalled.

Note that keeping the version in the main package up to date with the version that it is as far as go get is concerned will be interesting