Changed version scripts to run on win and macos as well

This commit is contained in:
RemixDev 2021-07-18 22:29:07 +02:00
parent 4604f2176e
commit 5f7a02a6f5
3 changed files with 26 additions and 2 deletions

View File

@ -17,8 +17,8 @@
"start-server-build": "yarn --cwd server start-build",
"build-server": "yarn --cwd server build",
"build-webui": "yarn --cwd webui build",
"set-version": "NEW_VERSION=$(printf \"%s-r%s.%s\" \"$(date +'%Y.%m.%d')\" \"$(git rev-list --count HEAD)\" \"$(git rev-parse --short=10 HEAD)\") && sed -i 's/\"version\": \".*\",/\"version\": \"'\"$NEW_VERSION\"'\",/g' package.json",
"reset-version": "sed -i 's/\"version\": \".*\",/\"version\": \"0.0.0\",/g' package.json"
"set-version": "node scripts/set-version.js",
"reset-version": "node scripts/reset-version.js"
},
"devDependencies": {
"electron": "^12.0.9",

6
scripts/reset-version.js Normal file
View File

@ -0,0 +1,6 @@
const { execSync } = require('child_process')
const fs = require('fs')
let package = JSON.parse(fs.readFileSync('package.json'))
package.version = "0.0.0"
fs.writeFileSync('package.json', JSON.stringify(package, null, 2)+"\n")

18
scripts/set-version.js Normal file
View File

@ -0,0 +1,18 @@
const { execSync } = require('child_process')
const fs = require('fs')
function generateVersion(){
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth();
const day = now.getDate();
const commitsNumber = String(execSync('git rev-list --count HEAD')).trim()
const commitHash = String(execSync('git rev-parse --short=10 HEAD')).trim()
return `${year}.${month}.${day}-r${commitsNumber}.${commitHash}`
}
let package = JSON.parse(fs.readFileSync('package.json'))
package.version = generateVersion()
fs.writeFileSync('package.json', JSON.stringify(package, null, 2)+"\n")