Add optional locked plugin download URLs

This commit is contained in:
pleb
2026-07-10 09:17:02 -07:00
parent 26def9609d
commit 538feae811
7 changed files with 121 additions and 10 deletions
+54 -1
View File
@@ -22,7 +22,7 @@ from plugin_helper.config import is_windows, load_local_config, resolve_runtime_
from plugin_helper.fsutil import sha256_file
from plugin_helper.installer import apply_plan, disable_plugin, uninstall_plugin
from plugin_helper.instances import get_instance, list_instances
from plugin_helper.models import Dependency, Lockfile, LockedPlugin, Registry, RegistryPlugin, load_lockfile, load_registry
from plugin_helper.models import Dependency, Lockfile, LockedPlugin, Registry, RegistryPlugin, load_lockfile, load_registry, write_lockfile
from plugin_helper.operations import enable_disabled_plugin
from plugin_helper.planner import create_plan
from plugin_helper.scanner import scan_bootstrap_files, scan_instance
@@ -82,6 +82,57 @@ dependencies = [
self.assertEqual(plugin.asset_patterns, ("Example-*.zip",))
self.assertEqual(plugin.dependencies, (Dependency(id="bsipa", constraint=">=4.3.7"),))
def test_lockfile_download_url_is_optional_and_round_trips(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
old_lock_path = root / "old.lock.toml"
old_lock_path.write_text(
"""
beat_saber_version = "1.40.8"
instance = "1.40.8"
[[plugins]]
id = "old"
repo = "owner/old"
tag = "v1"
asset = "Old.zip"
sha256 = "abc"
install_strategy = "bsipa-zip"
""".lstrip(),
encoding="utf-8",
)
old_lock = load_lockfile(old_lock_path)
self.assertIsNone(old_lock.plugins[0].download_url)
new_lock_path = root / "new.lock.toml"
write_lockfile(
new_lock_path,
Lockfile(
beat_saber_version="1.40.8",
instance="1.40.8",
plugins=(
LockedPlugin(
id="example",
repo="owner/example",
tag="v2",
asset="Example.zip",
download_url="https://example.invalid/Example.zip",
sha256="def",
install_strategy="bsipa-zip",
),
),
),
)
text = new_lock_path.read_text(encoding="utf-8")
reloaded = load_lockfile(new_lock_path)
self.assertIn('download_url = "https://example.invalid/Example.zip"', text)
self.assertLess(text.index("asset = "), text.index("download_url = "))
self.assertLess(text.index("download_url = "), text.index("sha256 = "))
self.assertEqual(reloaded.plugins[0].download_url, "https://example.invalid/Example.zip")
def test_normalize_beatmods_current_nested_response(self) -> None:
payload = {
"mods": [
@@ -2015,6 +2066,7 @@ instance = "1.40.8"
self.assertEqual(updated_lock.plugins[0].tag, "v2.0.0")
self.assertEqual(updated_lock.plugins[0].asset, "Example-v2.zip")
self.assertEqual(updated_lock.plugins[0].sha256, source_sha)
self.assertEqual(updated_lock.plugins[0].download_url, "https://example.invalid/Example-v2.zip")
self.assertIn("GitHub release digest matched", updated_lock.plugins[0].reason or "")
def test_update_command_prepares_beatmods_update(self) -> None:
@@ -2080,6 +2132,7 @@ instance = "1.40.8"
updated_lock = load_lockfile(lock_path)
self.assertEqual(updated_lock.plugins[0].tag, "beatmods-3.17.0")
self.assertEqual(updated_lock.plugins[0].asset, "SongCore-3.17.0.zip")
self.assertEqual(updated_lock.plugins[0].download_url, "https://beatmods.com/cdn/mod/abc.zip")
self.assertIn("version id 2600", updated_lock.plugins[0].reason or "")
self.assertIn("zipHash abc", updated_lock.plugins[0].reason or "")