Files
PMTiles/.github/check_examples.py
Brandon Liu 61e60c69d2 Make aws/cloudflare depend on pmtiles from npm [#455] (#515)
* Make aws/cloudflare depend on pmtiles from npm [#455]

This is clearer to developers than relying on the local code being built.

* update check_examples.py
* bump openlayers to v2 with upgrade of pmtiles to v4 [#455]
* update to 4.2.1
2025-01-14 17:09:11 +08:00

39 lines
1.0 KiB
Python

import json
import glob
import re
fail = 0
for package in glob.glob("**/package.json",recursive=True):
if "node_modules" in package:
continue
with open(package,"r") as f:
j = json.loads(f.read())
name = j["name"]
version = j["version"]
for dependent in glob.glob("**/package.json",recursive=True):
if "node_modules" in dependent:
continue
with open(dependent,"r") as f:
j2 = json.loads(f.read())
if 'dependencies' in j2 and name in j2["dependencies"]:
dependent_version = j2["dependencies"]["pmtiles"]
if dependent_version != "^" + version:
print(dependent,"should be ^",version,"was",dependent_version)
fail = 1
for html in glob.glob("**/*.html",recursive=True):
if "node_modules" in html:
continue
with open(html,"r") as f:
matches = re.findall("https://unpkg.com/" + name + r"@(\d+\.\d+\.\d+|latest)/",f.read())
for match in matches:
if matches[0] == "latest" or matches[0] != version:
print(html,"should be",version,"was",matches)
fail = 1
exit(fail)