Renovate: track Noto Sans glyphs and the Liberty style/sprite via git commit pins
CI / check (push) Successful in 19s
CI / deploy (push) Successful in 12s

This commit is contained in:
randy committed 2026-11-13 09:32:33 +01:00
1 parent ad8b72c3d3
commit 5e1d1988ab
4 files changed
+68 -9

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env node
// Re-downloads the vendored assets that aren't on npm, pinned to the git
// commits below. Renovate bumps each pin (git-refs digest, see renovate.json)
// and runs this as a postUpgradeTask, so its PR carries the new files.
// Manually: bump a sha, then `node bin/assets-sync.mjs`.
import { mkdirSync, writeFileSync } from "node:fs";
// renovate: datasource=git-refs depName=https://github.com/protomaps/basemaps-assets branch=main
const BASEMAPS_ASSETS = "028c18f713baecad011301ff7a69acc39bcc2ae7";
// renovate: datasource=git-refs depName=https://github.com/hyperknot/openfreemap-styles branch=main
const OPENFREEMAP_STYLES = "6e5361286c3e1eac7b7c89800ff63218297b5cfd";
const vendor = new URL("../public/vendor/", import.meta.url).pathname;
async function get(url, to) {
const res = await fetch(url);
if (!res.ok) throw new Error(`${res.status} ${url}`);
const body = Buffer.from(await res.arrayBuffer());
if (to) {
mkdirSync(`${vendor}${to}`.replace(/\/[^/]+$/, ""), { recursive: true });
writeFileSync(`${vendor}${to}`, body);
}
return body;
}
const raw = `https://raw.githubusercontent.com/protomaps/basemaps-assets/${BASEMAPS_ASSETS}/fonts`;
await get(`${raw}/OFL.txt`, "fonts/OFL.txt");
for (const font of ["Noto Sans Regular", "Noto Sans Italic", "Noto Sans Medium"])
for (const range of ["0-255", "256-511"])
await get(`${raw}/${encodeURIComponent(font)}/${range}.pbf`, `fonts/${font}/${range}.pbf`);
// ponytail: OPENFREEMAP_STYLES only triggers the sync; what's fetched is the
// style tiles.openfreemap.org serves right now (built from that repo), and the
// sprite at whatever versioned path that style points to.
const style = await get("https://tiles.openfreemap.org/styles/liberty", "liberty-style/liberty.json");
const sprite = JSON.parse(style).sprite;
for (const suffix of [".json", ".png", "@2x.json", "@2x.png"])
await get(`${sprite}${suffix}`, `liberty-sprite/ofm${suffix}`);
console.log(`synced (openfreemap-styles ${OPENFREEMAP_STYLES.slice(0, 7)}, sprite ${sprite})`);
+2 -2
View File
@@ -3,8 +3,8 @@
// 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.
// Assets not on npm: fonts and the Liberty style/sprite go through
// bin/assets-sync.mjs, the NPS plugins are updated by hand.
import { copyFileSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
const root = new URL("..", import.meta.url).pathname;