From 33ce48ad020b7380879105aea5c36dc8d0701fe3 Mon Sep 17 00:00:00 2001 From: nyagami Date: Sun, 24 Mar 2024 14:56:56 +0700 Subject: [PATCH] Dist version (#854) * unique branch for each version * fix: json_plugins * update readme --- README.md | 2 +- host.ps1 | 3 ++- host.sh | 3 ++- scripts/json_plugins.ts | 26 +++++++++++--------------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index a55c782..c0e495a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # LNReader Plugins

-LNReader plugins counting +LNReader plugins counting GitHub issues by-label GitHub issues by-label

diff --git a/host.ps1 b/host.ps1 index 62ea012..890de22 100644 --- a/host.ps1 +++ b/host.ps1 @@ -1,5 +1,6 @@ $current=$(git rev-parse --abbrev-ref HEAD) -$dist='dist' +$version=$(node -e "console.log(require('./package.json').version);") +$dist="plugins/v$($version)" $exists=$(git show-ref refs/heads/$dist) if ($exists){ diff --git a/host.sh b/host.sh index 7a4d0ab..899b336 100755 --- a/host.sh +++ b/host.sh @@ -1,5 +1,6 @@ current=`git rev-parse --abbrev-ref HEAD` -dist=dist +version=`node -e "console.log(require('./package.json').version);"` +dist="plugins/v$version" exists=`git show-ref refs/heads/$dist` if [ -n "$exists" ]; then diff --git a/scripts/json_plugins.ts b/scripts/json_plugins.ts index f1c3389..55e980b 100644 --- a/scripts/json_plugins.ts +++ b/scripts/json_plugins.ts @@ -12,14 +12,9 @@ const { execSync } = require('child_process'); const REMOTE = execSync('git remote get-url origin') .toString() .replace(/[\s\n]/g, ''); -let CURRENT_BRANCH = 'dist'; -try { - CURRENT_BRANCH = execSync('git rev-parse --abbrev-ref HEAD') - .toString() - .replace(/[\s\n]/g, ''); -} catch { - // -} +const CURRENT_BRANCH = execSync('git branch --show-current') + .toString() + .replace(/[\s\n]/g, ''); const matched = REMOTE.match(/([^:/]+?)\/([^/.]+)(\.git)?$/); if (!matched) throw Error('Cant parse git url'); const USERNAME = matched[1]; @@ -90,13 +85,14 @@ for (let lang in json) json[lang].sort((a, b) => a.id.localeCompare(b.id)); fs.writeFileSync(jsonMinPath, JSON.stringify(json)); fs.writeFileSync(jsonPath, JSON.stringify(json, null, '\t')); -if (CURRENT_BRANCH === 'dist') { - fetch(`https://img.shields.io/badge/Plugins-${totalPlugins}-blue`) - .then(res => res.text()) - .then(data => { - fs.writeFileSync('total.svg', data, { encoding: 'utf-8' }); - }); -} +fetch(`https://img.shields.io/badge/Plugins-${totalPlugins}-blue`) + .then(res => res.text()) + .then(data => { + fs.writeFileSync('total.svg', data, { encoding: 'utf-8' }); + }) + .catch(error => { + fs.writeFileSync('total.svg', '', { encoding: 'utf-8' }); + }); // check for broken plugins for (let language in languages) {