Auto-update manifest version on build

This commit is contained in:
Brahim Hadriche committed 2022-11-06 12:36:13 -05:00
1 parent 0fba45717f
commit e61cf6ae8a
3 files changed
+30 -5

No files matched your search

+4 -2
View File
@@ -14,7 +14,8 @@
"maestro-roku-bsc-plugin": "^0.25.7", "maestro-roku-bsc-plugin": "^0.25.7",
"roku-log-bsc-plugin": "^0.6.1", "roku-log-bsc-plugin": "^0.6.1",
"rooibos-roku": "^5.2.3", "rooibos-roku": "^5.2.3",
"ropm": "^0.10.10" "ropm": "^0.10.10",
"semver": "^7.3.8"
}, },
"ropm": { "ropm": {
"rootDir": "src", "rootDir": "src",
@@ -25,8 +26,9 @@
] ]
}, },
"scripts": { "scripts": {
"build": "node scripts/run-roku-youtube.js", "build": "npm run manifest-version && node scripts/run-roku-youtube.js",
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"manifest-version": "node scripts/update-manifest-version.js",
"postinstall": "npx ropm copy", "postinstall": "npx ropm copy",
"lint": "npx bsc" "lint": "npx bsc"
}, },
+21
View File
@@ -0,0 +1,21 @@
const path = require('path');
const fs = require('fs');
const semverParse = require('semver/functions/parse')
const packageJsonContent = fs.readFileSync("./package.json", {encoding:'utf8', flag:'r'})
const packageJson = JSON.parse(packageJsonContent)
const version = packageJson.version
const parsedVersion = semverParse(version)
let appManifestContent = fs.readFileSync("./src/manifest", {encoding:'utf8', flag:'r'})
const majorPattern = /major_version=(\d+)/
const minorPattern = /minor_version=(\d+)/
const buildPattern = /build_version=(\d+)/
appManifestContent = appManifestContent.replace(majorPattern, `major_version=${parsedVersion.major}`)
appManifestContent = appManifestContent.replace(minorPattern, `minor_version=${parsedVersion.minor}`)
appManifestContent = appManifestContent.replace(buildPattern, `build_version=${String(parsedVersion.patch).padStart(5, '0')}`)
fs.writeFileSync("./src/manifest", appManifestContent)
+5 -3
View File
@@ -1,7 +1,9 @@
title=Roku Youtube title=Roku Youtube
major_version=1
minor_version=0 # Do not update version manually, it is auto updated from package.json
build_version=00001 major_version=0
minor_version=1
build_version=00000
## Channel Assets ## Channel Assets
### Main Menu Icons / Channel Poster Artwork ### Main Menu Icons / Channel Poster Artwork