yarn 4
This commit is contained in:
@@ -6,25 +6,25 @@ const config = require(process.cwd() + (process.argv?.length > 3 ? "/" + process
|
||||
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()
|
||||
}
|
||||
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 = buildResults ? await buildResults.rebuild() : await esbuild.build(config.options)
|
||||
buildResults = await ctx.rebuild()
|
||||
if (config.options.metafile) {
|
||||
fs.writeFileSync(
|
||||
path.dirname(config.options.outfile) + "/meta.json",
|
||||
(config.options.outfile ? path.dirname(config.options.outfile) : config.options.outdir) + "/meta.json",
|
||||
JSON.stringify(buildResults.metafile, null, 4)
|
||||
)
|
||||
}
|
||||
@@ -41,16 +41,18 @@ 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)
|
||||
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
|
||||
// config.options.incremental = true
|
||||
build(true)
|
||||
const watcher = watch(config.watch.path)
|
||||
log("watching files...")
|
||||
@@ -64,5 +66,13 @@ switch (process.argv?.length > 2 ? process.argv[2] : "build") {
|
||||
})
|
||||
break
|
||||
default:
|
||||
build()
|
||||
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)
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
21
scripts/reload-local-tibi.sh
Executable file
21
scripts/reload-local-tibi.sh
Executable 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 --silent -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
|
||||
Reference in New Issue
Block a user