Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.docusaurus
node_modules/
build/
static/maplibre/
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ export default [
},
prettier,
{
ignores: ['build/', '.docusaurus/', 'node_modules/'],
ignores: ['build/', '.docusaurus/', 'node_modules/', 'static/maplibre/'],
},
];
153 changes: 54 additions & 99 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"private": true,
"scripts": {
"fetch-og": "node scripts/fetch-og-images.mjs",
"copy-maplibre-worker": "node scripts/copy-maplibre-worker.mjs",
"docusaurus": "docusaurus",
"start": "npm run docusaurus start",
"build": "npm run docusaurus build",
"start": "npm run copy-maplibre-worker && npm run docusaurus start",
"build": "npm run copy-maplibre-worker && npm run docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"deploy": "npm run copy-maplibre-worker && docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
Expand All @@ -33,7 +34,7 @@
"clsx": "^2.1.1",
"docusaurus-plugin-llms": "^0.5.1",
"js-yaml": "^5.2.2",
"maplibre-gl": "^5.24.0",
"maplibre-gl": "^6.0.0",
"pmtiles": "^4.4.1",
"prism-react-renderer": "^2.1.0",
"raw-loader": "^4.0.2",
Expand Down
22 changes: 22 additions & 0 deletions scripts/copy-maplibre-worker.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// MapLibre GL JS v6 ships ESM-only, and its worker (maplibre-gl-worker.mjs)
// statically imports a sibling chunk (maplibre-gl-shared.mjs). Neither Rspack
// nor webpack's `new URL(..., import.meta.url)` asset handling follows that
// relative import when copying the worker as a build asset, so the sibling
// never lands next to it and the worker fails to load at runtime with an
// opaque error. Copying both files verbatim into static/ (served as-is,
// unprocessed, by Docusaurus) keeps them side by side and importable.
// See src/components/map.js and src/components/buildings-map.js, and the
// MapLibre v5->v6 migration guide's ESM/worker section.
import { copyFileSync, mkdirSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = dirname(fileURLToPath(import.meta.url));
const source = join(__dirname, '..', 'node_modules', 'maplibre-gl', 'dist');
const destination = join(__dirname, '..', 'static', 'maplibre');

mkdirSync(destination, { recursive: true });

for (const file of ['maplibre-gl-worker.mjs', 'maplibre-gl-shared.mjs']) {
copyFileSync(join(source, file), join(destination, file));
}
31 changes: 23 additions & 8 deletions scripts/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import tempfile
import time
from pathlib import Path
from urllib.request import urlopen
from urllib.request import Request, urlopen

import duckdb

STAC_URL = "https://stac.overturemaps.org/catalog.json"
FALLBACK_RELEASE = "2026-05-20.0"
DOCUSAURUS_CONFIG = Path(__file__).parent.parent / "docusaurus.config.js"
QUERIES_DIR = Path(__file__).parent.parent / "src" / "queries" / "duckdb"

# Colorize SQL in the log to set it apart from status lines (GitHub Actions
Expand Down Expand Up @@ -74,13 +74,28 @@ def limit_copy(stmt: str) -> str:
return f"{prefix}SELECT * FROM (\n{inner}\n) _q LIMIT 0{suffix}"


def fallback_release() -> str:
"""Reuse the docusaurus fallback so there's one release pin to keep fresh."""
m = re.search(r"const fallback = '(\d{4}-\d{2}-\d{2}\.\d+)'", DOCUSAURUS_CONFIG.read_text())
if not m:
sys.exit("No fallback release found in docusaurus.config.js")
return m.group(1)


def fetch_release() -> str:
try:
with urlopen(STAC_URL, timeout=10) as r:
return json.loads(r.read())["latest"]
except Exception as exc:
print(f" STAC fetch failed ({exc}), falling back to {FALLBACK_RELEASE}")
return FALLBACK_RELEASE
# CloudFront 403s the default Python-urllib user agent from some networks
# (GitHub Actions runners included), so send a real one and retry.
req = Request(STAC_URL, headers={"User-Agent": "overture-docs-query-tests"})
for attempt in range(1, 4):
try:
with urlopen(req, timeout=10) as r:
return json.loads(r.read())["latest"]
except Exception as exc:
print(f" STAC fetch attempt {attempt} failed ({exc})")
time.sleep(2 * attempt)
fallback = fallback_release()
print(f" Falling back to {fallback} from docusaurus.config.js")
return fallback


def split_statements(sql: str) -> list[str]:
Expand Down
Loading