diff options
author | 0neGal <mail@0negal.com> | 2023-01-15 20:57:41 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2023-01-15 20:57:41 +0100 |
commit | 84a88c8bdbe2f85e14032f5b9941549fb8553f4c (patch) | |
tree | 247586a887f663b78033423ec88e3266914a33c0 /scripts | |
parent | 72c3c54dbf24819072fc38eaf552b5870d6bbe57 (diff) | |
download | Viper-84a88c8bdbe2f85e14032f5b9941549fb8553f4c.tar.gz Viper-84a88c8bdbe2f85e14032f5b9941549fb8553f4c.zip |
rename build/ to scripts/
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/langs.js | 50 | ||||
-rwxr-xr-x | scripts/publish.sh | 41 |
2 files changed, 91 insertions, 0 deletions
diff --git a/scripts/langs.js b/scripts/langs.js new file mode 100644 index 0000000..e870a3c --- /dev/null +++ b/scripts/langs.js @@ -0,0 +1,50 @@ +const fs = require("fs"); + +let problems = false; +let lang = require("../src/lang/en.json"); +let maintainers = require("../src/lang/maintainers.json"); + +langs = fs.readdirSync("src/lang") +langs.forEach((localefile) => { + if (localefile == "maintainers.json") {return} + + let missing = []; + let langmaintainers = maintainers.list[localefile.replace(/\..*$/, "")]; + let locale = false; + try { + locale = require("../src/lang/" + localefile) + }catch(err) { + console.log(`\x1b[101m!! ${localefile} is not formatted right !!\x1b[0m`); + return + } + + for (let i in lang) { + if (! locale[i]) { + missing.push(i); + } + } + + if (missing.length > 0) { + problems = true; + + console.error(`${localefile} is missing:`) + for (let i in missing) { + console.log(`\x1b[31m ${missing[i]}\x1b[0m`) + } + + console.log() + + console.log("Maintainers: ") + for (let i in langmaintainers) { + console.log(` ${langmaintainers[i]}`) + } + + console.log("\n") + } +}) + +if (! problems) { + console.log("\x1b[32mAll localizations are complete and formatted properly.\x1b[0m"); +} else { + process.exit(1); +} diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 0000000..bff91df --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +VERSION="v$(jq '.version' package.json -r)" +LOCK1="v$(jq '.version' package-lock.json -r)" +LOCK2="v$(jq '.packages[""].version' package-lock.json -r)" + +REPO="$(jq '.repository.url' package.json -r | sed 's/.*.com\///g')" + +REMOTEVERSION="$(curl --silent "https://api.github.com/repos/0neGal/viper/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" + +[ "$REMOTEVERSION" = "$VERSION" ] && { + echo "A release already exists with the current version number!" + exit 1 +} + +[ "$VERSION" != "$LOCK1" ] && { + echo "Two seperate version numbers in package.json and package-lock.json" + echo " $VERSION, $LOCK1" + exit 1 +} + +[ "$LOCK1" != "$LOCK2" ] && { + echo "Version mismatches in package-lock.json" + echo " $LOCK1, $LOCK2" + exit 1 +} + + +node scripts/langs.js || { + echo "Please fix localization errors before publishing..." + exit 1 +} + +TOKEN="$GH_TOKEN" + +[ "$TOKEN" = "" ] && { + echo "GH_TOKEN is not set, please type it below:" + read -p "> " TOKEN +} + +GH_TOKEN="$TOKEN" npm run publish |