Initial commit

This commit is contained in:
2023-12-24 11:38:32 +01:00
commit f71174d884
1963 changed files with 24504 additions and 0 deletions

10
scripts/cy-command.docker.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
#export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0
#export DISPLAY=host.docker.internal:0.0
rm -r coverage
rm -r .nyc_output
yarn build:instanbul
echo DISPLAY: $DISPLAY
yarn cy:$1

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" \
frontend/ \
$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,68 @@
const esbuild = require("esbuild")
const fs = require("fs")
const path = require("path")
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) {
if (process.stdout.cursorTo && process.stdout.clearScreenDown) {
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)
if (config.options.metafile) {
fs.writeFileSync(
path.dirname(config.options.outfile) + "/meta.json",
JSON.stringify(buildResults.metafile, null, 4)
)
}
} catch (e) {
console.log(e)
if (!catchError) throw e
}
const timerEnd = Date.now()
log(`built in ${timerEnd - timerStart}ms.`)
}
let bs
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 "start":
bs = require("browser-sync")
bs.init(config.browserSync)
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).then(() => {
if (bs) {
bs.reload()
}
})
})
break
default:
build()
}

5
scripts/init.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
files=`find .drone.yml api src -type f -name "config*" -or -name "*drone*"`
grep -E "__.*__" $files | grep -v TIMESTAMP

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

@@ -0,0 +1,37 @@
#!/bin/bash
branch=$1
url=$2
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#\(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
if [ "$branch" != "master" ]; then
sed -i 's#\(namespace:.*\)#\1_'$branch'#g' api/config.yml
cat api/config.yml
fi

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 frontend/_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"