Changed version scripts to run on win and macos as well
This commit is contained in:
parent
4604f2176e
commit
5f7a02a6f5
@ -17,8 +17,8 @@
|
|||||||
"start-server-build": "yarn --cwd server start-build",
|
"start-server-build": "yarn --cwd server start-build",
|
||||||
"build-server": "yarn --cwd server build",
|
"build-server": "yarn --cwd server build",
|
||||||
"build-webui": "yarn --cwd webui 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",
|
"set-version": "node scripts/set-version.js",
|
||||||
"reset-version": "sed -i 's/\"version\": \".*\",/\"version\": \"0.0.0\",/g' package.json"
|
"reset-version": "node scripts/reset-version.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "^12.0.9",
|
"electron": "^12.0.9",
|
||||||
|
6
scripts/reset-version.js
Normal file
6
scripts/reset-version.js
Normal 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
18
scripts/set-version.js
Normal 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")
|
Loading…
Reference in New Issue
Block a user