mirror of
https://github.com/n30nex/CartoLite-Server.git
synced 2026-10-30 05:02:36 +00:00
Make Terminal traffic shine and report build sizes without caps (#32)
This commit is contained in:
1 parent
ca6b955c05
commit
8e1ef6d3f1
18 files changed
+175
-69
No files matched your search
@@ -1,9 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
image="${1:?usage: check-image-size.sh IMAGE}"
|
||||
limit="${CARTOLITE_IMAGE_SIZE_BUDGET:-52428800}"
|
||||
size="$(docker image inspect "$image" --format '{{.Size}}')"
|
||||
[[ "$size" =~ ^[0-9]+$ ]]
|
||||
echo "$size image bytes (budget $limit)"
|
||||
test "$size" -le "$limit"
|
||||
@@ -3,14 +3,7 @@ import { readdir, readFile } from "node:fs/promises";
|
||||
import { basename, join } from "node:path";
|
||||
|
||||
const root = process.argv[2] ?? "web/dist";
|
||||
// MapLibre 6 requires a separate Vite worker (129,701 gzip bytes in Actions).
|
||||
// Keep the previous cap for all other JS/CSS; account for the worker explicitly.
|
||||
// Combined measured cost: 446,084 bytes. Runtime timing/route gates are unchanged.
|
||||
const uiLimit = 350 * 1024;
|
||||
const workerLimit = 128 * 1024;
|
||||
// Optional Terminal view is lazy-loaded; original UI and worker caps stay fixed.
|
||||
const terminalLimit = 8 * 1024;
|
||||
const limit = Number(process.env.CARTOLITE_GZIP_BUDGET ?? (uiLimit + workerLimit + terminalLimit));
|
||||
// Report artifact sizes without release-blocking caps. Runtime gates remain.
|
||||
|
||||
async function assets(dir, pattern) {
|
||||
const found = [];
|
||||
@@ -40,11 +33,9 @@ for (const file of files) {
|
||||
console.log(`${bytes.toString().padStart(8)} ${file}`);
|
||||
}
|
||||
|
||||
console.log(`${total} gzip bytes total (budget ${limit})`);
|
||||
console.log(`${total - workerBytes - terminalBytes} gzip bytes excluding map worker (budget ${uiLimit})`);
|
||||
console.log(`${workerBytes} gzip bytes for map worker (budget ${workerLimit})`);
|
||||
console.log(terminalBytes + ' gzip bytes for optional Terminal (budget ' + terminalLimit + ')');
|
||||
if (terminalBytes <= 0 || terminalBytes > terminalLimit) process.exitCode = 1;
|
||||
console.log(`${total} gzip bytes total`);
|
||||
console.log(`${total - workerBytes - terminalBytes} gzip bytes for main UI`);
|
||||
console.log(`${workerBytes} gzip bytes for map worker`);
|
||||
console.log(terminalBytes + ' gzip bytes for optional Terminal');
|
||||
if (terminalBytes <= 0) throw new Error('missing optional Terminal assets');
|
||||
if (workerCount !== 1) throw new Error(`expected one map worker, found ${workerCount}`);
|
||||
if (!Number.isFinite(limit) || limit <= 0) throw new Error('invalid total frontend budget');
|
||||
if (total > limit || total - workerBytes - terminalBytes > uiLimit || workerBytes > workerLimit) process.exitCode = 1;
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
image="${1:?usage: report-image-size.sh IMAGE}"
|
||||
size="$(docker image inspect "$image" --format '{{.Size}}')"
|
||||
[[ "$size" =~ ^[0-9]+$ ]]
|
||||
echo "$size image bytes"
|
||||
Reference in new issue
Block a user