Files
maptool/bin/vendor-sync.mjs
T
randy f62987b1de
CI / check (push) Successful in 36s
CI / deploy (push) Successful in 13s
Add Renovate config, track vendored JS libs via package.json
The Renovate workflow had no renovate.json, so with onboarding off it
skipped the repo entirely. Now config:recommended plus a regex manager
for the Dockerfile's PMTILES_VERSION/PLANETILER_VERSION pins.

public/vendor/'s npm-published libraries (maplibre-gl, pmtiles,
maplibre-contour, maplibre-gl-lanes, flag-icons, suncalc) are pinned in
package.json; bin/vendor-sync.mjs copies them out of node_modules, and
runs as a Renovate postUpgradeTask so bump PRs carry the new files.
Re-syncing the current versions reproduces the vendored files exactly,
except suncalc's hand-added header, moved into third-party-notices.
2026-11-03 17:15:28 +01:00

33 lines
1.6 KiB
JavaScript

#!/usr/bin/env node
// Copies the npm-managed frontend libraries from node_modules/ into
// public/vendor/ (committed, served as-is, no bundler). package.json pins
// the versions; Renovate bumps them and runs this as a postUpgradeTask so
// its PR carries the new files too. Manually: `npm ci && node bin/vendor-sync.mjs`.
// Libraries not on npm (NPS plugins, Liberty style/sprite, fonts) stay
// hand-updated, see docs/third-party-notices.adoc.
import { copyFileSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
const root = new URL("..", import.meta.url).pathname;
const nm = (p) => `${root}node_modules/${p}`;
const vendor = (p) => `${root}public/vendor/${p}`;
const copy = (from, to) => copyFileSync(nm(from), vendor(to));
for (const f of ["maplibre-gl.css", "maplibre-gl.mjs", "maplibre-gl-shared.mjs", "maplibre-gl-worker.mjs"])
copy(`maplibre-gl/dist/${f}`, `maplibre-gl/${f}`);
copy("pmtiles/dist/pmtiles.js", "pmtiles/pmtiles.js");
copy("maplibre-contour/dist/index.min.js", "maplibre-contour/maplibre-contour.min.js");
// Trailing sourceMappingURL dropped: the .map isn't vendored.
writeFileSync(
vendor("maplibre-gl-lanes/maplibre-gl-lanes.mjs"),
readFileSync(nm("maplibre-gl-lanes/dist/maplibre-gl-lanes.mjs"), "utf8").replace(/\n\/\/# sourceMappingURL=.*\n?$/, "\n"),
);
copy("maplibre-gl-lanes/LICENSE", "maplibre-gl-lanes/LICENSE");
copy("suncalc/index.js", "suncalc/suncalc.js");
copy("suncalc/LICENSE", "suncalc/LICENSE");
// Only the flags already vendored (the European subset), not all ~270.
for (const f of readdirSync(vendor("flag-icons/1x1"))) copy(`flag-icons/flags/1x1/${f}`, `flag-icons/1x1/${f}`);