add version (#455)

This commit is contained in:
mihaisc 2022-06-23 04:51:32 -07:00 committed by GitHub
parent d87fbed5b5
commit 28979c8c79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 1 deletions

View File

@ -28,6 +28,7 @@
"lint:fix": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx . --fix",
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json,yaml}' --write",
"type-check": "tsc --noEmit",
"replaceVersion": "node ./scripts/replaceVersion.js",
"release": "release-it --non-interactive",
"changelog": "auto-changelog -p"
},
@ -68,7 +69,7 @@
"license": "Apache-2.0",
"release-it": {
"hooks": {
"after:bump": "npm run changelog"
"after:bump": "npm run changelog && npm run replaceVersion"
},
"plugins": {},
"git": {

View File

@ -492,6 +492,9 @@ type GlobalStatistic @entity {
"number of dispensers created"
dispenserCount: Int!
"current version"
version: String
}
type OPC @entity {

17
scripts/replaceVersion.js Normal file
View File

@ -0,0 +1,17 @@
const fs = require('fs')
const packageJson = require('../package.json')
async function replaceVersion() {
let globalUtils = fs.readFileSync(
'./src/mappings/utils/globalUtils.ts',
'utf8'
)
globalUtils = globalUtils.replace(
/.*globalStats\.version.*\n/,
" globalStats.version = '" + packageJson.version + "'\n"
)
fs.writeFileSync('./src/mappings/utils/globalUtils.ts', globalUtils, 'utf8')
}
replaceVersion()

View File

@ -14,6 +14,7 @@ export function getGlobalStats(): GlobalStatistic {
let globalStats = GlobalStatistic.load(GLOBAL_ID)
if (!globalStats) {
globalStats = new GlobalStatistic(GLOBAL_ID)
globalStats.version = '1.2.0'
globalStats.save()
}
return globalStats