Update package.json and version.json

This commit is contained in:
Dede Fuji Abdul
2024-04-29 22:50:51 +07:00
parent fcb0f87093
commit 8f57d4c612
3 changed files with 44 additions and 2 deletions

42
version.js Normal file
View File

@ -0,0 +1,42 @@
// build-and-push.js
const { exec, writeFile } = require('child_process')
const fs = require('fs')
function setVersion(version) {
var packageFile = require('./package.json')
packageFile = {
...packageFile,
version: version
}
const packageJsonPath = './package.json'
fs.writeFile(packageJsonPath, JSON.stringify(packageFile), (err) => {
if (err) {
console.error('Error writing package.json', err)
return
}
console.log('package.json updated successfully')
const versionData = {
version: version
}
const versionJsonPath = './public/version.json'
fs.writeFile(versionJsonPath, JSON.stringify(versionData), (err) => {
if (err) {
console.error('Error writing version.json', err)
return
}
console.log('version.json updated successfully')
})
})
}
// Ambil argumen versi dari command line
const version = process.argv[2]
if (!version) {
console.error('Usage: node version.js <version>')
process.exit(1)
}
setVersion(version)