feat: v0.4.1 — untrack map-asset pack (~100 MB): compose volume mount + runtime fallback to remote OFM styles

This commit is contained in:
2026-09-17 09:14:34 +00:00
parent 501c452377
commit 1c50cfeab2
791 changed files with 257 additions and 5171 deletions
+14 -3
View File
@@ -4,8 +4,9 @@
// the full Noto Sans font set, and the sprite sheet. Vector tiles (/planet) and
// the ne2_shaded raster stay remote — this script never touches tile data.
//
// Run manually (not part of tests/CI): node scripts/download-map-assets.mjs
// Idempotent: overwrites existing files in public/.
// Run manually (not part of tests/CI): npm run assets:download
// Idempotent: overwrites existing files in public/. The generated pack is git-ignored
// and docker-ignored; it reaches the container via the compose volume mount.
import { execFileSync } from 'node:child_process';
import { mkdirSync, mkdtempSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';
@@ -79,8 +80,18 @@ try {
if (!sprites.includes(f)) throw new Error(`unexpected sprite layout: missing "${f}" in public/sprites`);
}
// 4. Manifest: written LAST so its presence means the whole pack is in place —
// the app probes it at runtime (lib/mapStyles.ts localAssetsAvailable) and falls
// back to remote OFM styles when it's missing.
const manifest = {
name: 'ofm-map-assets',
generatedAt: new Date().toISOString(),
styles: STYLES.map((s) => s.id),
};
writeFileSync(path.join(publicDir, 'map-assets-manifest.json'), JSON.stringify(manifest, null, 2) + '\n');
const fmt = (n) => `${(n / 1048576).toFixed(1)} MB`;
console.log(`done. public/styles ${fmt(dirSize(stylesDir))}, public/fonts ${fmt(dirSize(path.join(publicDir, 'fonts')))}, public/sprites ${fmt(dirSize(path.join(publicDir, 'sprites')))}`);
console.log(`done. public/styles ${fmt(dirSize(stylesDir))}, public/fonts ${fmt(dirSize(path.join(publicDir, 'fonts')))}, public/sprites ${fmt(dirSize(path.join(publicDir, 'sprites')))}, manifest written`);
} finally {
rmSync(tmp, { recursive: true, force: true });
}