From e61cf6ae8a46f97fb6b574cf6c34e19844430025 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sun, 6 Nov 2022 12:36:13 -0500 Subject: [PATCH] Auto-update manifest version on build --- package.json | 6 ++++-- scripts/update-manifest-version.js | 21 +++++++++++++++++++++ src/manifest | 12 +++++++----- 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 scripts/update-manifest-version.js diff --git a/package.json b/package.json index 527841a5..650f9c3d 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "maestro-roku-bsc-plugin": "^0.25.7", "roku-log-bsc-plugin": "^0.6.1", "rooibos-roku": "^5.2.3", - "ropm": "^0.10.10" + "ropm": "^0.10.10", + "semver": "^7.3.8" }, "ropm": { "rootDir": "src", @@ -25,8 +26,9 @@ ] }, "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", + "manifest-version": "node scripts/update-manifest-version.js", "postinstall": "npx ropm copy", "lint": "npx bsc" }, diff --git a/scripts/update-manifest-version.js b/scripts/update-manifest-version.js new file mode 100644 index 00000000..b492deeb --- /dev/null +++ b/scripts/update-manifest-version.js @@ -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) \ No newline at end of file diff --git a/src/manifest b/src/manifest index 1105c18a..442fb0bd 100644 --- a/src/manifest +++ b/src/manifest @@ -1,16 +1,18 @@ title=Roku Youtube -major_version=1 -minor_version=0 -build_version=00001 + +# Do not update version manually, it is auto updated from package.json +major_version=0 +minor_version=1 +build_version=00000 ## Channel Assets -### Main Menu Icons / Channel Poster Artwork +### Main Menu Icons / Channel Poster Artwork #### Image sizes are FHD: 540x405px | HD: 290x218px | SD: 214x144px mm_icon_focus_fhd=pkg:/images/channel-poster_fhd.png mm_icon_focus_hd=pkg:/images/channel-poster_hd.png mm_icon_focus_sd=pkg:/images/channel-poster_sd.png -### Splash Screen + Loading Screen Artwork +### Splash Screen + Loading Screen Artwork #### Image sizes are FHD: 1920x1080px | HD: 1280x720px | SD: 720x480px splash_screen_fhd=pkg:/images/splash-screen_fhd.jpg splash_screen_hd=pkg:/images/splash-screen_hd.jpg