Added smart versioning

This commit is contained in:
Michael Mainguy 2024-06-11 16:58:35 -05:00
parent ae73f3e74b
commit cf278fed3a
3 changed files with 10 additions and 5 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "immersive", "name": "immersive",
"private": true, "private": true,
"version": "0.0.8-12", "version": "0.0.8-13",
"type": "module", "type": "module",
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"

View File

@ -1,5 +1,5 @@
importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.1.0/workbox-sw.js'); importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.1.0/workbox-sw.js');
const VERSION = '11'; const VERSION = '0.0.8-13';
const CACHE = "deepdiagram"; const CACHE = "deepdiagram";
const IMAGEDELIVERY_CACHE = "deepdiagram-images"; const IMAGEDELIVERY_CACHE = "deepdiagram-images";
const MAPTILE_CACHE = 'maptiler'; const MAPTILE_CACHE = 'maptiler';

View File

@ -19,11 +19,16 @@ const getPackageJson = async () => {
json.version = newVersion; json.version = newVersion;
await fs.writeFile('package.json', JSON.stringify(json, null, 2)); await fs.writeFile('package.json', JSON.stringify(json, null, 2));
let indexHtml = await fs.readFile('index.html', 'utf8'); let indexHtml = await fs.readFile('index.html', 'utf8');
indexHtml = indexHtml.replace('@@VERSION', newVersion); indexHtml = indexHtml.replaceAll('@@VERSION', newVersion);
indexHtml = indexHtml.replace('@@DATE', new Date().toISOString()); indexHtml = indexHtml.replaceAll('@@DATE', new Date().toISOString());
const gitId = (await getGitId()).replace('\n', ''); const gitId = (await getGitId()).replace('\n', '');
indexHtml = indexHtml.replace('@@GIT', gitId); indexHtml = indexHtml.replaceAll('@@GIT', gitId);
await fs.writeFile('index.html', indexHtml); await fs.writeFile('index.html', indexHtml);
let sw = await fs.readFile('public/sw.js', 'utf8');
sw = sw.replace('@@VERSION', newVersion);
fs.writeFile('public/sw.js', sw);
} }
await getPackageJson(); await getPackageJson();