This commit is contained in:
2021-03-22 15:59:05 +01:00
parent dd27483b16
commit 626e83d010
46 changed files with 5636 additions and 0 deletions

40
scripts/deploy.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/sh
host=$1
user=$2
pass=$3
if [ "$host" == "" ]; then
echo "missing host"
exit 1
fi
if [ "$user" == "" ]; then
echo "missing username"
exit 1
fi
if [ "$pass" == "" ]; then
echo "missing password"
exit 1
fi
echo "sync frontend"
rsync -rlcgD --perms -i -u -v --stats --progress \
--delete \
-e "sshpass -p $pass ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 22222" \
dist/ \
$user@$host:./frontend/
echo "sync api config"
rsync -rlcgD --perms -i -u -v --stats --progress \
--delete \
-e "sshpass -p $pass ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 22222" \
api/ \
$user@$host:./api/
echo "create media directory"
mkdir media
chmod 770 media
rsync -rlcgD --perms -i -u -v --stats --progress \
-e "sshpass -p $pass ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 22222" \
media \
$user@$host:./

View File

@@ -0,0 +1,51 @@
const esbuild = require("esbuild")
const config = require(process.cwd() +
(process.argv?.length > 3 ? "/" + process.argv[3] : "/esbuild.config.js"))
const { watch } = require("chokidar")
function log(str, clear) {
if (clear) {
process.stdout.cursorTo(0, 0)
process.stdout.clearScreenDown()
}
console.log("\x1b[36m%s\x1b[0m", str)
}
let buildResults
async function build(catchError) {
log((buildResults ? "re" : "") + "building...")
const timerStart = Date.now()
try {
buildResults = buildResults
? await buildResults.rebuild()
: await esbuild.build(config.options)
} catch (e) {
console.log(e)
if (!catchError) throw e
}
const timerEnd = Date.now()
log(`built in ${timerEnd - timerStart}ms.`)
}
switch (process.argv?.length > 2 ? process.argv[2] : "build") {
case "serve":
console.log("\x1b[36m%s\x1b[0mserving...")
esbuild.serve(config.serve, config.options).catch((err) => {
console.error(err)
process.exit(1)
})
break
case "watch":
config.options.incremental = true
build(true)
const watcher = watch(config.watch.path)
log("watching files...")
watcher.on("change", function (path) {
log(`${path} changed`, true)
build(true)
})
break
default:
build()
}

35
scripts/modify-config.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
branch=$1
url=$2
paypal=sandbox
if [ "$branch" == "" ]; then
echo missing branch name
exit 1
fi
if [ "$url" == "" ]; then
echo missing url
exit 1
fi
if [ "$branch" == "master" ]; then
paypal=live
fi
sed -i 's#\(apiBase:\).*#apiBase:"'$url'/api/",#g' api/hooks/config.js
sed -i 's#\(frontendBase:\).*#frontendBase:"'$url'/",#g' api/hooks/config.js
sed -i 's#\(pppReturnURL:\).*#pppReturnURL:"'$url'/checkout/overview\?type=paypal",#g' api/hooks/config.js
sed -i 's#\(pppCancelURL:\).*#pppCancelURL:"'$url'/checkout/payment\?type=paypal",#g' api/hooks/config.js
sed -i 's#\(var paypalMode *=\).*#var paypalMode = "'$paypal'"#g' api/hooks/config.js
cat api/hooks/config.js
sed -i 's#\(apiBaseURL.*\)"http.*"#\1"'$url'/api/"#g' src/config.ts
sed -i 's#\(sentryEnvironment.*\)".*"#\1"'$branch'"#g' src/config.ts
if [ "$branch" == "master" || "$branch" == "dev" ]; then
sed -i 's#//\( sentry\\.init.*\)#\1#g' src/config.ts
fi
cat src/config.ts

16
scripts/preload-meta.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
if [ "$1" == "" ]; then
echo template filename required
exit 1
fi
preload=$(for f in dist/_dist_/*.woff2; do
echo "<link rel=\"preload\" href=\"/_dist_/`basename $f`\" as=\"font\" type=\"font/woff2\" crossorigin />"
done)
template="`cat $1 | sed -e 's#<!--PRELOAD-->#\$preload#'`"
eval "cat <<EOF
$template
EOF"