Initial commit
This commit is contained in:
38
scripts/deploy.sh
Executable file
38
scripts/deploy.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
# if RSYNC_USER or RSYNC_PASS is not set, exit
|
||||
if [ -z "${RSYNC_USER}" ] || [ -z "${RSYNC_PASS}" ] || [ -z "${RSYNC_HOST}" ] || [ -z "${RSYNC_PORT}" ]; then
|
||||
echo "RSYNC_ settings not complete, exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
excludes=""
|
||||
if [ "${BRANCH}" == "main" ]; then
|
||||
excludes='--exclude=src --exclude=*.map'
|
||||
echo "main deploy, excluding $excludes"
|
||||
fi
|
||||
|
||||
# sync frontend
|
||||
rsync -rlcgD --perms -i -u -v --stats --progress \
|
||||
--delete \
|
||||
-e "sshpass -p ${RSYNC_PASS} ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p ${RSYNC_PORT}" \
|
||||
$excludes \
|
||||
frontend/ \
|
||||
${RSYNC_USER}@${RSYNC_HOST}:./frontend/ \
|
||||
|
||||
# sync api config
|
||||
rsync -rlcgD --perms -i -u -v --stats --progress \
|
||||
--delete \
|
||||
-e "sshpass -p ${RSYNC_PASS} ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p ${RSYNC_PORT}" \
|
||||
api/ \
|
||||
${RSYNC_USER}@${RSYNC_HOST}:./api/
|
||||
|
||||
# create media directory
|
||||
mkdir media
|
||||
chmod 770 media
|
||||
rsync -rlcgD --perms -i -u -v --stats --progress \
|
||||
-e "sshpass -p ${RSYNC_PASS} ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p ${RSYNC_PORT}" \
|
||||
media \
|
||||
${RSYNC_USER}@${RSYNC_HOST}:./
|
||||
|
||||
# tst
|
||||
78
scripts/esbuild-wrapper.js
Normal file
78
scripts/esbuild-wrapper.js
Normal file
@@ -0,0 +1,78 @@
|
||||
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 && process.stdout.cursorTo && process.stdout.clearScreenDown) {
|
||||
process.stdout.cursorTo(0, 0)
|
||||
process.stdout.clearScreenDown()
|
||||
}
|
||||
console.log("\x1b[36m%s\x1b[0m", str)
|
||||
}
|
||||
|
||||
let buildResults
|
||||
let ctx
|
||||
|
||||
async function build(catchError) {
|
||||
if (!ctx) ctx = await esbuild.context(config.options)
|
||||
log((buildResults ? "re" : "") + "building...")
|
||||
const timerStart = Date.now()
|
||||
try {
|
||||
buildResults = await ctx.rebuild()
|
||||
if (config.options.metafile) {
|
||||
fs.writeFileSync(
|
||||
(config.options.outfile ? path.dirname(config.options.outfile) : config.options.outdir) + "/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.context(config.options).then(function (_ctx) {
|
||||
_ctx.serve(config.serve).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:
|
||||
esbuild.build(config.options).then(function (buildResults) {
|
||||
if (config.options.metafile) {
|
||||
fs.writeFileSync(
|
||||
(config.options.outfile ? path.dirname(config.options.outfile) : config.options.outdir) +
|
||||
"/meta.json",
|
||||
JSON.stringify(buildResults.metafile, null, 4)
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
16
scripts/preload-meta.sh
Executable file
16
scripts/preload-meta.sh
Executable 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"
|
||||
6
scripts/py-command.docker.sh
Normal file
6
scripts/py-command.docker.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
PY_SPECFLAG=${PY_SPECFLAG:-""}
|
||||
PY_MODE=${PY_MODE:-"--ui"}
|
||||
# Führe Playwright-Tests aus
|
||||
npx playwright test $PY_MODE $PY_SPECFLAG
|
||||
21
scripts/reload-local-tibi.sh
Normal file
21
scripts/reload-local-tibi.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
# clear ssr cache
|
||||
set -o allexport
|
||||
SCRIPTDIR=$(dirname "$0")
|
||||
source $SCRIPTDIR/../.env
|
||||
set +o allexport
|
||||
|
||||
ssrUrl="https://${PROJECT_NAME}-tibiserver.code.testversion.online/api/v1/_/${TIBI_NAMESPACE}/ssr"
|
||||
curl -X POST -H "Content-Type: application/json" -d '{}' "${ssrUrl}?clear=1"
|
||||
|
||||
sleep 1
|
||||
|
||||
|
||||
# restart tibiserver and tibiserver-dev (if exists)
|
||||
docker compose -f docker-compose-local.yml restart tibiserver 2>&1
|
||||
docker compose -f docker-compose-local.yml restart tibiserver-dev 2>&1
|
||||
|
||||
|
||||
exit 0
|
||||
25
scripts/upload-sourcemaps.sh
Executable file
25
scripts/upload-sourcemaps.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASEDIR=$(dirname $0)
|
||||
|
||||
#set -o allexport
|
||||
#source $BASEDIR/../.env
|
||||
#set +o allexport
|
||||
|
||||
export $(grep -v '^#' $BASEDIR/../.env | grep -v 'UID=' | grep -v 'GID=' | xargs -d '\n')
|
||||
|
||||
echo SENTRY_URL=${SENTRY_URL}
|
||||
echo SENTRY_ORG=${SENTRY_ORG}
|
||||
echo SENTRY_PROJECT=${SENTRY_PROJECT}
|
||||
echo PROJECT_RELEASE=${PROJECT_RELEASE}
|
||||
|
||||
# echo deleting old release
|
||||
# sentry-cli --url https://sentry.basehosts.de --auth-token ${SENTRY_TOKEN} releases --org ${RELEASE_ORG_SLUG} --project renz-eshop delete ${PROJECT_RELEASE:-$RELEASE_PROJECT_SLUG.dirty}
|
||||
|
||||
echo injecting debug id
|
||||
sentry-cli sourcemaps --log-level info inject frontend/dist
|
||||
|
||||
|
||||
echo creating release and uploading sourcemaps
|
||||
#sentry-cli --url https://sentry.basehosts.de --auth-token ${SENTRY_TOKEN} releases --org ${RELEASE_ORG_SLUG} --project renz-eshop files ${PROJECT_RELEASE:-$RELEASE_PROJECT_SLUG.dirty} upload-sourcemaps --url-prefix='~/' --ext js --ext mjs --ext svelte --ext map frontend
|
||||
sentry-cli sourcemaps --log-level info upload --release=${PROJECT_RELEASE:-$RELEASE_PROJECT_SLUG.dirty} --url-prefix='~/dist' --ext js --ext mjs --ext map frontend/dist
|
||||
Reference in New Issue
Block a user