demo project
This commit is contained in:
42
scripts/deploy.sh
Executable file
42
scripts/deploy.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
|
||||
# if RSYNC_USER or RSYNC_PASS is not set, exit
|
||||
if [ -z "${RSYNC_USER}" ] || [ -z "${RSYNC_PASS}" ]; then
|
||||
echo "RSYNC_USER or RSYNC_PASS not set, exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
excludes=""
|
||||
if [ "${DRONE_BRANCH}" == "master" ]; then
|
||||
excludes='--exclude=src --exclude=*.map'
|
||||
echo "master 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 22222" \
|
||||
$excludes \
|
||||
frontend/ \
|
||||
${RSYNC_USER}@ftp1.webmakers.de:./frontend/ \
|
||||
|
||||
# sync images getter
|
||||
rsync -rlcgD --perms -i -u -v --stats --progress \
|
||||
-e "sshpass -p ${RSYNC_PASS} ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 22222" \
|
||||
images/ \
|
||||
${RSYNC_USER}@ftp1.webmakers.de:./images/
|
||||
|
||||
# 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 22222" \
|
||||
api/ \
|
||||
${RSYNC_USER}@ftp1.webmakers.de:./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 22222" \
|
||||
media \
|
||||
${RSYNC_USER}@ftp1.webmakers.de:./
|
||||
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"
|
||||
10
scripts/upload-sourcemaps.sh
Executable file
10
scripts/upload-sourcemaps.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
BASEDIR=$(dirname $0)
|
||||
|
||||
. $BASEDIR/../.env
|
||||
|
||||
echo deleting old release ${RELEASE_ORG_SLUG} ${RELEASE_VERSION:-$RELEASE_PROJECT_SLUG.dirty}
|
||||
sentry-cli --url https://glitchtip.basehosts.de/ --auth-token ${GLITCHTIP_TOKEN} releases --org ${RELEASE_ORG_SLUG} --project ${RELEASE_PROJECT_SLUG} delete ${RELEASE_VERSION:-$RELEASE_PROJECT_SLUG.dirty}
|
||||
|
||||
echo creating release ${RELEASE_ORG_SLUG} ${RELEASE_VERSION:-$RELEASE_PROJECT_SLUG.dirty} and uploading sourcemaps
|
||||
sentry-cli --url https://glitchtip.basehosts.de/ --auth-token ${GLITCHTIP_TOKEN} releases --org ${RELEASE_ORG_SLUG} --project ${RELEASE_PROJECT_SLUG} files ${RELEASE_VERSION:-$RELEASE_PROJECT_SLUG.dirty} upload-sourcemaps --url-prefix='~/' --ext js --ext mjs --ext svelte --ext map frontend
|
||||
Reference in New Issue
Block a user