Renovate: track Noto Sans glyphs and the Liberty style/sprite via git commit pins
This commit is contained in:
1 parent
ad8b72c3d3
commit
5e1d1988ab
4 files changed
+68
-9
No files matched your search
Executable
+39
@@ -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
@@ -3,8 +3,8 @@
|
|||||||
// public/vendor/ (committed, served as-is, no bundler). package.json pins
|
// public/vendor/ (committed, served as-is, no bundler). package.json pins
|
||||||
// the versions; Renovate bumps them and runs this as a postUpgradeTask so
|
// 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`.
|
// 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
|
// Assets not on npm: fonts and the Liberty style/sprite go through
|
||||||
// hand-updated, see docs/third-party-notices.adoc.
|
// bin/assets-sync.mjs, the NPS plugins are updated by hand.
|
||||||
import { copyFileSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
import { copyFileSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
||||||
|
|
||||||
const root = new URL("..", import.meta.url).pathname;
|
const root = new URL("..", import.meta.url).pathname;
|
||||||
|
|||||||
@@ -122,10 +122,14 @@ at runtime for the "Online" layer, and as a one-time vendored snapshot
|
|||||||
(`public/vendor/liberty-style/liberty.json`) that the "Offline" layer
|
(`public/vendor/liberty-style/liberty.json`) that the "Offline" layer
|
||||||
repoints at local data instead. Its icon sprite is vendored the same
|
repoints at local data instead. Its icon sprite is vendored the same
|
||||||
way, under `public/vendor/liberty-sprite/` (`ofm.json`/`ofm.png` +
|
way, under `public/vendor/liberty-sprite/` (`ofm.json`/`ofm.png` +
|
||||||
`@2x` variants, from `tiles.openfreemap.org/sprites/`). Neither has
|
`@2x` variants, from `tiles.openfreemap.org/sprites/`).
|
||||||
been re-checked against a specific upstream version pin the way the
|
|
||||||
table above does — re-fetch both from `tiles.openfreemap.org` if
|
The Noto Sans glyphs and the Liberty style/sprite are pinned to git
|
||||||
Liberty's own style/sprite ever visibly drifts from what's vendored.
|
commits (protomaps/basemaps-assets, hyperknot/openfreemap-styles) in
|
||||||
|
`bin/assets-sync.mjs`. Renovate bumps those pins and runs the script in
|
||||||
|
the same PR, so the new files arrive with it. A new openfreemap-styles
|
||||||
|
commit only triggers the sync, which then saves whatever style
|
||||||
|
`tiles.openfreemap.org` currently serves.
|
||||||
|
|
||||||
`data/offline.pmtiles` (`lib/maptool/pmtiles_builder.rb`'s in-app
|
`data/offline.pmtiles` (`lib/maptool/pmtiles_builder.rb`'s in-app
|
||||||
regeneration, or the manual recipe in `docs/development.adoc`) is
|
regeneration, or the manual recipe in `docs/development.adoc`) is
|
||||||
@@ -175,9 +179,8 @@ build step. Renovate (`renovate.json`) opens a PR per bump and its
|
|||||||
already contains the new files under `public/vendor/`. By hand: edit
|
already contains the new files under `public/vendor/`. By hand: edit
|
||||||
`package.json`, then `npm install && node bin/vendor-sync.mjs`.
|
`package.json`, then `npm install && node bin/vendor-sync.mjs`.
|
||||||
|
|
||||||
Everything else under `public/vendor/` (NPS plugins, Liberty
|
The NPS plugins (patched, from an unmerged branch) and the National
|
||||||
style/sprite, fonts) isn't on npm or has no version to track — update
|
Park typeface (no versioned source) are still updated by hand.
|
||||||
by hand and adjust this file.
|
|
||||||
|
|
||||||
go-pmtiles and Planetiler are pinned by `PMTILES_VERSION`/
|
go-pmtiles and Planetiler are pinned by `PMTILES_VERSION`/
|
||||||
`PLANETILER_VERSION` in the `Dockerfile`, which Renovate also bumps
|
`PLANETILER_VERSION` in the `Dockerfile`, which Renovate also bumps
|
||||||
|
|||||||
@@ -12,6 +12,15 @@
|
|||||||
"fileFilters": ["public/vendor/**"],
|
"fileFilters": ["public/vendor/**"],
|
||||||
"executionMode": "branch"
|
"executionMode": "branch"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Fonts and the Liberty style/sprite are pinned to git commits in bin/assets-sync.mjs, re-download them in the same PR",
|
||||||
|
"matchFileNames": ["bin/assets-sync.mjs"],
|
||||||
|
"postUpgradeTasks": {
|
||||||
|
"commands": ["node bin/assets-sync.mjs"],
|
||||||
|
"fileFilters": ["public/vendor/**"],
|
||||||
|
"executionMode": "branch"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"customManagers": [
|
"customManagers": [
|
||||||
@@ -23,6 +32,14 @@
|
|||||||
"# renovate: datasource=(?<datasource>\\S+) depName=(?<depName>\\S+)\\s+ARG \\S+_VERSION=(?<currentValue>\\S+)"
|
"# renovate: datasource=(?<datasource>\\S+) depName=(?<depName>\\S+)\\s+ARG \\S+_VERSION=(?<currentValue>\\S+)"
|
||||||
],
|
],
|
||||||
"extractVersionTemplate": "^v?(?<version>.*)$"
|
"extractVersionTemplate": "^v?(?<version>.*)$"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"customType": "regex",
|
||||||
|
"description": "Git commit pins annotated with a `// renovate:` comment",
|
||||||
|
"managerFilePatterns": ["/^bin/assets-sync\\.mjs$/"],
|
||||||
|
"matchStrings": [
|
||||||
|
"// renovate: datasource=(?<datasource>\\S+) depName=(?<depName>\\S+) branch=(?<currentValue>\\S+)\\s+const \\w+ = \"(?<currentDigest>[0-9a-f]{40})\""
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user