Quantum-Game / quantum-game-2

LEGACY open-source version of Quantum Game 2 (Sept 2019 - Oct 2020)
https://quantumgame.io
MIT License
65 stars 16 forks source link

feat(landing) display QG version and git hash #164

Closed stared closed 4 years ago

stared commented 4 years ago

I want to make it easier to see which version we display. Right now it works that way:

image

Looking at how to add the release date, as it may be more informative than version (or hash).

@KlemKlem - obviously style is temporary, so feel invited to change it in any way you like.

I didn't try to deploy it yet. Since these are build-related things, it make work or not.

Notes

It took me quite a lot of time to figure out how to include hash commits. In the end, I use git-describe, see vue.config.js.

I did try:

git-revision-webpack-plugin

Works, but code seems extraneous. vue.config.js would look like (example from: https://forum.vuejs.org/t/trying-to-add-gitrevisionplugin-to-cli-3/65567):

const GitRevisionPlugin = require('git-revision-webpack-plugin')

module.exports = {
  'chainWebpack': config => {
    config.plugin('define').tap(args => {
      const gitRevisionPlugin = new GitRevisionPlugin()
      args[0]['process.env']['VUE_APP_COMMIT_HASH'] = JSON.stringify(gitRevisionPlugin.commithash())
      return args
    })
  }
}

vue-cli-plugin-git-describe

Package not maintained (only a single release) + variables in the global space (problems with linters).

.env or assets

git log -n 1 --pretty=format:"VUE_APP_GIT_HASH=%h%nVUE_APP_GIT_DATE=%aD" >> .env

But had some issues with reading .env variables. Similarly, one can create a JSON asset and load it from there. It might be a not that bad idea (just one need to add extra scripts in package.json so to generate these files, always when building).

See also: