mirror of
https://github.com/yt-dlp/ejs.git
synced 2026-06-25 07:41:58 +00:00
* Bump @types/bun 1.3.0 => 1.3.14 * Bump @types/deno 2.5.0 => 2.7.0 * Bump @types/node 24.8.1 => 25.9.3 * Bump bun-types 1.3.0 => 1.3.14 * Bump esbuild 0.28.0 => 0.28.1 * Bump globals 16.4.0 => 17.6.0 * Bump oxfmt 0.48.0 => 0.54.0 * Bump oxlint 1.63.0 => 1.69.0 * Bump undici-types 7.14.0 => 7.24.6 * Remove @types/react 19.2.7 * Remove csstype 3.2.3 * Fix deno lockfile check script Co-authored-by: bashonly <bashonly@protonmail.com>
102 lines
2.7 KiB
Python
Executable File
102 lines
2.7 KiB
Python
Executable File
#!/usr/bin/env python
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import pathlib
|
|
import sys
|
|
|
|
ADDITIONAL_PACKAGES_NODE = {}
|
|
ADDITIONAL_PACKAGES_DENO = {}
|
|
BASE_PATH = pathlib.Path(__file__).parent
|
|
|
|
|
|
def parse_deno() -> dict[str, str]:
|
|
path = BASE_PATH / "deno.lock"
|
|
with path.open("rb") as file:
|
|
lockfile = json.load(file)
|
|
|
|
v = lockfile["version"]
|
|
if v != "5":
|
|
msg = f"Unsupported lockfile version: {v} (expected 5)"
|
|
raise ValueError(msg)
|
|
|
|
integrities = {}
|
|
for name, info in lockfile["npm"].items():
|
|
integrity = info["integrity"]
|
|
other = integrities.get(integrity)
|
|
if other and other != name:
|
|
msg = f"Duplicate integrity for {name} and {other}: {integrity}"
|
|
raise ValueError(msg)
|
|
|
|
integrities[integrity] = name
|
|
|
|
return integrities
|
|
|
|
|
|
def parse_node() -> dict[str, str]:
|
|
path = BASE_PATH / "package-lock.json"
|
|
with path.open("rb") as file:
|
|
lockfile = json.load(file)
|
|
|
|
v = lockfile["lockfileVersion"]
|
|
if v != 3:
|
|
msg = f"Unsupported lockfile version: {v} (expected 3)"
|
|
raise ValueError(msg)
|
|
|
|
integrities = {}
|
|
for path, info in lockfile["packages"].items():
|
|
if not path:
|
|
continue
|
|
|
|
_, _, mod_name = path.rpartition("node_modules/")
|
|
version = info["version"]
|
|
name = f"{mod_name}@{version}"
|
|
|
|
integrity = info["integrity"]
|
|
other = integrities.get(integrity)
|
|
if other and other != name:
|
|
msg = f"Duplicate integrity for {name} and {other}: {integrity}"
|
|
raise ValueError(msg)
|
|
integrities[integrity] = name
|
|
|
|
return integrities
|
|
|
|
|
|
def main():
|
|
try:
|
|
packages_deno = parse_deno()
|
|
except Exception as error:
|
|
print(f"ERROR: Could not read deno lockfile: {error}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
try:
|
|
packages_node = parse_node()
|
|
except Exception as error:
|
|
print(f"ERROR: Could not read npm lockfile: {error}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
packages_deno.update({v: k for k, v in ADDITIONAL_PACKAGES_NODE.items()})
|
|
packages_node.update({v: k for k, v in ADDITIONAL_PACKAGES_DENO.items()})
|
|
differences = packages_deno.keys() ^ packages_node.keys()
|
|
|
|
if diffs_deno := differences.intersection(packages_deno):
|
|
print(
|
|
"deno => npm:",
|
|
*(f"{packages_deno[h]} ({h})" for h in diffs_deno),
|
|
sep="\n\t",
|
|
)
|
|
|
|
if diffs_node := differences.intersection(packages_node):
|
|
print(
|
|
" npm => deno:",
|
|
*(f"{packages_node[h]} ({h})" for h in diffs_node),
|
|
sep="\n\t",
|
|
)
|
|
|
|
if differences:
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|