From 7af18cf51f187766fdc30d3b88daa72d6e499164 Mon Sep 17 00:00:00 2001 From: Doan Bui Date: Fri, 10 Jan 2025 15:59:28 +0700 Subject: [PATCH 1/5] Add support version patch and restore support for all platforms --- electron/package.json | 8 ++++---- electron/scripts/version-patch.js | 18 ++++++++++++++++++ electron/scripts/version-restore.js | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 electron/scripts/version-patch.js create mode 100644 electron/scripts/version-restore.js diff --git a/electron/package.json b/electron/package.json index c058370a7b..57637e9553 100644 --- a/electron/package.json +++ b/electron/package.json @@ -1,6 +1,6 @@ { "name": "jan", - "version": "0.1.3", + "version": "0.1.1736498766", "main": "./build/main.js", "author": "Jan ", "license": "MIT", @@ -80,8 +80,8 @@ "lint": "eslint . --ext \".js,.jsx,.ts,.tsx\"", "test:e2e": "DEBUG=pw:browser xvfb-maybe -- playwright test --workers=1", "copy:assets": "rimraf --glob \"./pre-install/*.tgz\" && cpx \"../pre-install/*.tgz\" \"./pre-install\"", - "version-patch": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", - "version-restore": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak", + "version-patch": "node scripts/version-patch.js", + "version-restore": "node scripts/version-restore.js", "dev": "yarn copy:assets && tsc -p . && yarn version-patch && electron . && yarn version-restore", "compile": "tsc -p .", "start": "electron .", @@ -138,4 +138,4 @@ "hoistingLimits": "workspaces" }, "packageManager": "yarn@4.5.3" -} +} \ No newline at end of file diff --git a/electron/scripts/version-patch.js b/electron/scripts/version-patch.js new file mode 100644 index 0000000000..33bdc7f0e2 --- /dev/null +++ b/electron/scripts/version-patch.js @@ -0,0 +1,18 @@ +const fs = require('fs'); +const path = require('path'); + +const packagePath = path.join(__dirname, '..', 'package.json'); +const backupPath = path.join(__dirname, '..', '.version.bak'); + +// Read package.json +const package = require(packagePath); + +// Backup current version +fs.writeFileSync(backupPath, package.version); + +// Update version +const timestamp = Math.floor(Date.now() / 1000); +package.version = `0.1.${timestamp}`; + +// Write back to package.json +fs.writeFileSync(packagePath, JSON.stringify(package, null, 2)); \ No newline at end of file diff --git a/electron/scripts/version-restore.js b/electron/scripts/version-restore.js new file mode 100644 index 0000000000..6dc8d78b6d --- /dev/null +++ b/electron/scripts/version-restore.js @@ -0,0 +1,20 @@ +const fs = require('fs'); +const path = require('path'); + +const packagePath = path.join(__dirname, '..', 'package.json'); +const backupPath = path.join(__dirname, '..', '.version.bak'); + +// Read backup version +const backupVersion = fs.readFileSync(backupPath, 'utf8'); + +// Read package.json +const package = require(packagePath); + +// Restore version +package.version = backupVersion; + +// Write back to package.json +fs.writeFileSync(packagePath, JSON.stringify(package, null, 2)); + +// Delete backup file +fs.unlinkSync(backupPath); \ No newline at end of file From 55804caeaca7e0ebbbde90105051cf8c87b53266 Mon Sep 17 00:00:00 2001 From: Doan Bui Date: Mon, 13 Jan 2025 08:50:29 +0700 Subject: [PATCH 2/5] Add support version patch and restore support for all platforms --- electron/package.json | 12 +++++++++--- electron/scripts/version-patch.js | 18 ------------------ electron/scripts/version-restore.js | 20 -------------------- 3 files changed, 9 insertions(+), 41 deletions(-) delete mode 100644 electron/scripts/version-patch.js delete mode 100644 electron/scripts/version-restore.js diff --git a/electron/package.json b/electron/package.json index 57637e9553..9c4ee93501 100644 --- a/electron/package.json +++ b/electron/package.json @@ -1,6 +1,6 @@ { "name": "jan", - "version": "0.1.1736498766", + "version": "0.1.3", "main": "./build/main.js", "author": "Jan ", "license": "MIT", @@ -80,8 +80,14 @@ "lint": "eslint . --ext \".js,.jsx,.ts,.tsx\"", "test:e2e": "DEBUG=pw:browser xvfb-maybe -- playwright test --workers=1", "copy:assets": "rimraf --glob \"./pre-install/*.tgz\" && cpx \"../pre-install/*.tgz\" \"./pre-install\"", - "version-patch": "node scripts/version-patch.js", - "version-restore": "node scripts/version-restore.js", + "version-patch": "run-script-os", + "version-patch:darwin": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", + "version-patch:linux": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", + "version-patch:win32": "node -e \"const fs=require('fs');const pkg=require('./package.json');const bak=pkg.version;fs.writeFileSync('.version.bak',bak);pkg.version='0.1.'+Math.floor(Date.now()/1000);fs.writeFileSync('package.json',JSON.stringify(pkg,null,2));\"", + "version-restore": "run-script-os", + "version-restore:darwin": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", + "version-restore:linux": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", + "version-restore:win32": "node -e \"const fs=require('fs');const pkg=require('./package.json');const bak=fs.readFileSync('.version.bak','utf8');pkg.version=bak;fs.writeFileSync('package.json',JSON.stringify(pkg,null,2));\"", "dev": "yarn copy:assets && tsc -p . && yarn version-patch && electron . && yarn version-restore", "compile": "tsc -p .", "start": "electron .", diff --git a/electron/scripts/version-patch.js b/electron/scripts/version-patch.js deleted file mode 100644 index 33bdc7f0e2..0000000000 --- a/electron/scripts/version-patch.js +++ /dev/null @@ -1,18 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const packagePath = path.join(__dirname, '..', 'package.json'); -const backupPath = path.join(__dirname, '..', '.version.bak'); - -// Read package.json -const package = require(packagePath); - -// Backup current version -fs.writeFileSync(backupPath, package.version); - -// Update version -const timestamp = Math.floor(Date.now() / 1000); -package.version = `0.1.${timestamp}`; - -// Write back to package.json -fs.writeFileSync(packagePath, JSON.stringify(package, null, 2)); \ No newline at end of file diff --git a/electron/scripts/version-restore.js b/electron/scripts/version-restore.js deleted file mode 100644 index 6dc8d78b6d..0000000000 --- a/electron/scripts/version-restore.js +++ /dev/null @@ -1,20 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const packagePath = path.join(__dirname, '..', 'package.json'); -const backupPath = path.join(__dirname, '..', '.version.bak'); - -// Read backup version -const backupVersion = fs.readFileSync(backupPath, 'utf8'); - -// Read package.json -const package = require(packagePath); - -// Restore version -package.version = backupVersion; - -// Write back to package.json -fs.writeFileSync(packagePath, JSON.stringify(package, null, 2)); - -// Delete backup file -fs.unlinkSync(backupPath); \ No newline at end of file From 1d349ff03fd63c5dffebb195324b40c64a9014f9 Mon Sep 17 00:00:00 2001 From: Doan Bui Date: Mon, 13 Jan 2025 08:59:14 +0700 Subject: [PATCH 3/5] Add support version patch and restore support for all platforms --- electron/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/electron/package.json b/electron/package.json index 9c4ee93501..ae7e81c5d3 100644 --- a/electron/package.json +++ b/electron/package.json @@ -85,8 +85,8 @@ "version-patch:linux": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", "version-patch:win32": "node -e \"const fs=require('fs');const pkg=require('./package.json');const bak=pkg.version;fs.writeFileSync('.version.bak',bak);pkg.version='0.1.'+Math.floor(Date.now()/1000);fs.writeFileSync('package.json',JSON.stringify(pkg,null,2));\"", "version-restore": "run-script-os", - "version-restore:darwin": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", - "version-restore:linux": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", + "version-restore:darwin": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak", + "version-restore:linux": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak", "version-restore:win32": "node -e \"const fs=require('fs');const pkg=require('./package.json');const bak=fs.readFileSync('.version.bak','utf8');pkg.version=bak;fs.writeFileSync('package.json',JSON.stringify(pkg,null,2));\"", "dev": "yarn copy:assets && tsc -p . && yarn version-patch && electron . && yarn version-restore", "compile": "tsc -p .", From 5812fd798f23c6107f4b3a98b42f9d2138ccc2c4 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 13 Jan 2025 13:04:27 +0700 Subject: [PATCH 4/5] Update electron/package.json --- electron/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/electron/package.json b/electron/package.json index 33d0a8554e..a80a41160e 100644 --- a/electron/package.json +++ b/electron/package.json @@ -81,8 +81,7 @@ "test:e2e": "DEBUG=pw:browser xvfb-maybe -- playwright test --workers=1", "copy:assets": "rimraf --glob \"./pre-install/*.tgz\" && cpx \"../pre-install/*.tgz\" \"./pre-install\"", "version-patch": "run-script-os", - "version-patch:darwin": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", - "version-patch:linux": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", + "version-patch:darwin:linux": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", "version-patch:win32": "node -e \"const fs=require('fs');const pkg=require('./package.json');const bak=pkg.version;fs.writeFileSync('.version.bak',bak);pkg.version='0.1.'+Math.floor(Date.now()/1000);fs.writeFileSync('package.json',JSON.stringify(pkg,null,2));\"", "version-restore": "run-script-os", "version-restore:darwin": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak", From 53cd8a49da5863e3d0fcf0344031a637b320a1d6 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 13 Jan 2025 13:04:35 +0700 Subject: [PATCH 5/5] Update electron/package.json --- electron/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/electron/package.json b/electron/package.json index a80a41160e..b8ab96dd41 100644 --- a/electron/package.json +++ b/electron/package.json @@ -84,8 +84,7 @@ "version-patch:darwin:linux": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json", "version-patch:win32": "node -e \"const fs=require('fs');const pkg=require('./package.json');const bak=pkg.version;fs.writeFileSync('.version.bak',bak);pkg.version='0.1.'+Math.floor(Date.now()/1000);fs.writeFileSync('package.json',JSON.stringify(pkg,null,2));\"", "version-restore": "run-script-os", - "version-restore:darwin": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak", - "version-restore:linux": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak", + "version-restore:darwin:linux": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak", "version-restore:win32": "node -e \"const fs=require('fs');const pkg=require('./package.json');const bak=fs.readFileSync('.version.bak','utf8');pkg.version=bak;fs.writeFileSync('package.json',JSON.stringify(pkg,null,2));\"", "dev:darwin:linux": "yarn copy:assets && tsc -p . && yarn version-patch && electron . && yarn version-restore", "dev:windows": "yarn copy:assets && tsc -p . && electron .",