From a3741b2934a8c8dffd3f665576f33324e89a4a1b Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sat, 19 Feb 2022 22:05:05 +0100 Subject: updated build scripts/code tests build/langs.js now gives more info and has colors. It also changes it's exit code if an error happened, we then use that in build/publish.sh to catch localization errors before publishing. We also ensure that version numbers are set correctly. Then at last we will make sure $GH_TOKEN is set, and if not, prompt for the token, to make sure you don't build everything then error out when you forgot to put in your token. --- build/langs.js | 24 +++++++++++++++++++++--- build/publish.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100755 build/publish.sh (limited to 'build') diff --git a/build/langs.js b/build/langs.js index 9e21dff..e870a3c 100644 --- a/build/langs.js +++ b/build/langs.js @@ -1,5 +1,6 @@ const fs = require("fs"); +let problems = false; let lang = require("../src/lang/en.json"); let maintainers = require("../src/lang/maintainers.json"); @@ -9,7 +10,14 @@ langs.forEach((localefile) => { let missing = []; let langmaintainers = maintainers.list[localefile.replace(/\..*$/, "")]; - let locale = require("../src/lang/" + localefile) + 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); @@ -17,16 +25,26 @@ langs.forEach((localefile) => { } if (missing.length > 0) { + problems = true; + console.error(`${localefile} is missing:`) for (let i in missing) { - console.log(` ${missing[i]}`) + console.log(`\x1b[31m ${missing[i]}\x1b[0m`) } console.log() - console.log("Maintainers of language: ") + 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/build/publish.sh b/build/publish.sh new file mode 100755 index 0000000..c8f7832 --- /dev/null +++ b/build/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 build/langs.js || { + echo "Please fix localization errors before publishing..." + exit 1 +} + +GH_TOKEN="$GH_TOKEN" + +[ "$GH_TOKEN" = "" ] && { + echo "GH_TOKEN is not set, please type it below:" + read -p "> " GH_TOKEN +} + +npm run publish -- cgit v1.2.3 From 30358b9c8b30bf10ff62e32e655e37cc15d4dcdb Mon Sep 17 00:00:00 2001 From: 0neGal Date: Tue, 22 Mar 2022 20:14:58 +0100 Subject: fixed GH_TOKEN not being properly exposed to npm This lead to you going through the whole build process but it never actually uploaded all the files. Quite annoying! --- build/publish.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'build') diff --git a/build/publish.sh b/build/publish.sh index c8f7832..042b7c1 100755 --- a/build/publish.sh +++ b/build/publish.sh @@ -31,11 +31,11 @@ node build/langs.js || { exit 1 } -GH_TOKEN="$GH_TOKEN" +TOKEN="$GH_TOKEN" -[ "$GH_TOKEN" = "" ] && { +[ "$TOKEN" = "" ] && { echo "GH_TOKEN is not set, please type it below:" - read -p "> " GH_TOKEN + read -p "> " TOKEN } -npm run publish +GH_TOKEN="$TOKEN" npm run publish -- cgit v1.2.3