youpdated-scanning 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- youpdated_scanning-0.1.0/LICENSE +21 -0
- youpdated_scanning-0.1.0/PKG-INFO +61 -0
- youpdated_scanning-0.1.0/README.md +35 -0
- youpdated_scanning-0.1.0/pyproject.toml +42 -0
- youpdated_scanning-0.1.0/setup.cfg +4 -0
- youpdated_scanning-0.1.0/tests/test_browsers.py +111 -0
- youpdated_scanning-0.1.0/tests/test_cargo.py +84 -0
- youpdated_scanning-0.1.0/tests/test_dotnet.py +74 -0
- youpdated_scanning-0.1.0/tests/test_electron.py +96 -0
- youpdated_scanning-0.1.0/tests/test_flatpak.py +53 -0
- youpdated_scanning-0.1.0/tests/test_golang.py +102 -0
- youpdated_scanning-0.1.0/tests/test_homebrew.py +177 -0
- youpdated_scanning-0.1.0/tests/test_macapps.py +248 -0
- youpdated_scanning-0.1.0/tests/test_npm.py +95 -0
- youpdated_scanning-0.1.0/tests/test_pipx.py +94 -0
- youpdated_scanning-0.1.0/tests/test_scanning.py +177 -0
- youpdated_scanning-0.1.0/tests/test_steam.py +167 -0
- youpdated_scanning-0.1.0/tests/test_uv.py +87 -0
- youpdated_scanning-0.1.0/tests/test_winget.py +328 -0
- youpdated_scanning-0.1.0/youpdated_scanning/__init__.py +75 -0
- youpdated_scanning-0.1.0/youpdated_scanning/base.py +70 -0
- youpdated_scanning-0.1.0/youpdated_scanning/browsers.py +115 -0
- youpdated_scanning-0.1.0/youpdated_scanning/cargo.py +76 -0
- youpdated_scanning-0.1.0/youpdated_scanning/dotnet.py +60 -0
- youpdated_scanning-0.1.0/youpdated_scanning/electron.py +126 -0
- youpdated_scanning-0.1.0/youpdated_scanning/flatpak.py +53 -0
- youpdated_scanning-0.1.0/youpdated_scanning/golang.py +141 -0
- youpdated_scanning-0.1.0/youpdated_scanning/homebrew.py +78 -0
- youpdated_scanning-0.1.0/youpdated_scanning/macapps.py +177 -0
- youpdated_scanning-0.1.0/youpdated_scanning/npm.py +75 -0
- youpdated_scanning-0.1.0/youpdated_scanning/pipx.py +87 -0
- youpdated_scanning-0.1.0/youpdated_scanning/py.typed +0 -0
- youpdated_scanning-0.1.0/youpdated_scanning/steam.py +245 -0
- youpdated_scanning-0.1.0/youpdated_scanning/uv.py +68 -0
- youpdated_scanning-0.1.0/youpdated_scanning/winget.py +318 -0
- youpdated_scanning-0.1.0/youpdated_scanning/wingetnames.py +279 -0
- youpdated_scanning-0.1.0/youpdated_scanning.egg-info/PKG-INFO +61 -0
- youpdated_scanning-0.1.0/youpdated_scanning.egg-info/SOURCES.txt +39 -0
- youpdated_scanning-0.1.0/youpdated_scanning.egg-info/dependency_links.txt +1 -0
- youpdated_scanning-0.1.0/youpdated_scanning.egg-info/requires.txt +4 -0
- youpdated_scanning-0.1.0/youpdated_scanning.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Void1-1
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: youpdated-scanning
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Find installed sources on this machine and watch them with Youpdated
|
|
5
|
+
Author-email: Void1-1 <161782542+Void1-1@users.noreply.github.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Void1-1/youpdated
|
|
8
|
+
Project-URL: Repository, https://github.com/Void1-1/youpdated
|
|
9
|
+
Project-URL: Issues, https://github.com/Void1-1/youpdated/issues
|
|
10
|
+
Keywords: updates,release-tracking,steam,sparkle,winget,homebrew,pipx,npm,electron,youpdated
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Topic :: Utilities
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: youpdated>=0.7.0b2
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# youpdated-scanning
|
|
28
|
+
|
|
29
|
+
Finds what's installed on this machine and adds it to your [Youpdated](https://github.com/Void1-1/youpdated) config:
|
|
30
|
+
|
|
31
|
+
- `steam`: Steam games, from each library's `appmanifest_*.acf`, under `steam`. On macOS a library on another drive or in Desktop, Documents, Downloads, or iCloud Drive makes macOS confirm before allowing the terminal to read it, so it's read only with `--only steam`
|
|
32
|
+
- `homebrew`: Homebrew formulae you installed and casks, under `homebrew`
|
|
33
|
+
- `winget`: Windows programs winget can identify, matched against winget's local index the way winget matches them, under `winget`. A program whose installer writes a version differently than winget gets no installed version
|
|
34
|
+
- `flatpak`: Flatpak apps from Flathub, under `flathub`
|
|
35
|
+
- `pipx` and `uv`: Python apps from PyPI installed with `pipx install` or `uv tool install`, under `pypi`
|
|
36
|
+
- `npm`: packages installed with `npm install -g`, under `npm`
|
|
37
|
+
- `cargo`: programs installed from crates.io with `cargo install`, under `crates`
|
|
38
|
+
- `go`: programs installed with `go install module@version`, from their build info, under `go`
|
|
39
|
+
- `dotnet`: .NET tools installed with `dotnet tool install -g`, under `nuget`
|
|
40
|
+
- `browsers`: Chrome, Brave, Firefox, and Edge on macOS and Linux (stable channel), under `browser`
|
|
41
|
+
- `apps`: macOS apps in `/Applications` and `~/Applications` with a Sparkle feed, under `sparkle`, or from the App Store, under `appstore`. A feed an app saved to its own settings with a query string or a user name, which can be a license or install id, is skipped with a warning, and a plain `http://` feed is added with one. (Youpdated expects you to manually edit or add any feeds with secrets to your config). Apps in `/Applications/Setapp` are skipped with a warning, since Setapp updates them itself
|
|
42
|
+
- `electron`: Electron apps whose `app-update.yml` names a GitHub repo, under `git`
|
|
43
|
+
|
|
44
|
+
Package managers run first. An app one of them installed isn't also added by a later scanner that finds it in the same place, such as a Homebrew cask's Sparkle feed.
|
|
45
|
+
|
|
46
|
+
It isn't part of the default install. Add it with the `scanning` extra:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
pipx install 'youpdated[scanning]' # or: pipx inject youpdated youpdated-scanning
|
|
50
|
+
youpdated scan --test # show what would be added
|
|
51
|
+
youpdated scan
|
|
52
|
+
youpdated scan --only steam --only apps # certain scanners
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
While the Youpdated release with `scan` is a beta, add `--pip-args=--pre` to `pipx install`.
|
|
56
|
+
|
|
57
|
+
Scanning is local only. It reads files, runs package managers already installed and Spotlight's `mdls`, and makes no network requests on its own.
|
|
58
|
+
|
|
59
|
+
- winget isn't run, because `winget export` refreshes its index over the network when that's over 15 minutes old.
|
|
60
|
+
- cargo and go aren't run because `cargo` is usually rustup's proxy, which can install a toolchain, and `go` can download one.
|
|
61
|
+
- The programs that are run are given environment variables turning off their own network use: Homebrew's auto-update and analytics, npm's update notifier, uv's network access, and the .NET CLI's telemetry and workload update checks.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# youpdated-scanning
|
|
2
|
+
|
|
3
|
+
Finds what's installed on this machine and adds it to your [Youpdated](https://github.com/Void1-1/youpdated) config:
|
|
4
|
+
|
|
5
|
+
- `steam`: Steam games, from each library's `appmanifest_*.acf`, under `steam`. On macOS a library on another drive or in Desktop, Documents, Downloads, or iCloud Drive makes macOS confirm before allowing the terminal to read it, so it's read only with `--only steam`
|
|
6
|
+
- `homebrew`: Homebrew formulae you installed and casks, under `homebrew`
|
|
7
|
+
- `winget`: Windows programs winget can identify, matched against winget's local index the way winget matches them, under `winget`. A program whose installer writes a version differently than winget gets no installed version
|
|
8
|
+
- `flatpak`: Flatpak apps from Flathub, under `flathub`
|
|
9
|
+
- `pipx` and `uv`: Python apps from PyPI installed with `pipx install` or `uv tool install`, under `pypi`
|
|
10
|
+
- `npm`: packages installed with `npm install -g`, under `npm`
|
|
11
|
+
- `cargo`: programs installed from crates.io with `cargo install`, under `crates`
|
|
12
|
+
- `go`: programs installed with `go install module@version`, from their build info, under `go`
|
|
13
|
+
- `dotnet`: .NET tools installed with `dotnet tool install -g`, under `nuget`
|
|
14
|
+
- `browsers`: Chrome, Brave, Firefox, and Edge on macOS and Linux (stable channel), under `browser`
|
|
15
|
+
- `apps`: macOS apps in `/Applications` and `~/Applications` with a Sparkle feed, under `sparkle`, or from the App Store, under `appstore`. A feed an app saved to its own settings with a query string or a user name, which can be a license or install id, is skipped with a warning, and a plain `http://` feed is added with one. (Youpdated expects you to manually edit or add any feeds with secrets to your config). Apps in `/Applications/Setapp` are skipped with a warning, since Setapp updates them itself
|
|
16
|
+
- `electron`: Electron apps whose `app-update.yml` names a GitHub repo, under `git`
|
|
17
|
+
|
|
18
|
+
Package managers run first. An app one of them installed isn't also added by a later scanner that finds it in the same place, such as a Homebrew cask's Sparkle feed.
|
|
19
|
+
|
|
20
|
+
It isn't part of the default install. Add it with the `scanning` extra:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
pipx install 'youpdated[scanning]' # or: pipx inject youpdated youpdated-scanning
|
|
24
|
+
youpdated scan --test # show what would be added
|
|
25
|
+
youpdated scan
|
|
26
|
+
youpdated scan --only steam --only apps # certain scanners
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
While the Youpdated release with `scan` is a beta, add `--pip-args=--pre` to `pipx install`.
|
|
30
|
+
|
|
31
|
+
Scanning is local only. It reads files, runs package managers already installed and Spotlight's `mdls`, and makes no network requests on its own.
|
|
32
|
+
|
|
33
|
+
- winget isn't run, because `winget export` refreshes its index over the network when that's over 15 minutes old.
|
|
34
|
+
- cargo and go aren't run because `cargo` is usually rustup's proxy, which can install a toolchain, and `go` can download one.
|
|
35
|
+
- The programs that are run are given environment variables turning off their own network use: Homebrew's auto-update and analytics, npm's update notifier, uv's network access, and the .NET CLI's telemetry and workload update checks.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "youpdated-scanning"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Find installed sources on this machine and watch them with Youpdated"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Void1-1", email = "161782542+Void1-1@users.noreply.github.com" }]
|
|
14
|
+
keywords = ["updates", "release-tracking", "steam", "sparkle", "winget", "homebrew", "pipx", "npm", "electron", "youpdated"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Intended Audience :: End Users/Desktop",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
22
|
+
"Topic :: Utilities",
|
|
23
|
+
"Typing :: Typed",
|
|
24
|
+
]
|
|
25
|
+
dependencies = ["youpdated>=0.7.0b2"]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
dev = ["pytest>=8.0"]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/Void1-1/youpdated"
|
|
32
|
+
Repository = "https://github.com/Void1-1/youpdated"
|
|
33
|
+
Issues = "https://github.com/Void1-1/youpdated/issues"
|
|
34
|
+
|
|
35
|
+
[tool.setuptools.packages.find]
|
|
36
|
+
include = ["youpdated_scanning*"]
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.package-data]
|
|
39
|
+
youpdated_scanning = ["py.typed"]
|
|
40
|
+
|
|
41
|
+
[tool.pytest.ini_options]
|
|
42
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""The browsers scanner, against Chrome's and Brave's real Info.plist files"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import plistlib
|
|
7
|
+
import shutil
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from youpdated.importers import Found
|
|
13
|
+
from youpdated_scanning.browsers import BrowsersScanner, comparable, desktop_dirs, firefox_channel
|
|
14
|
+
|
|
15
|
+
FIXTURES = Path(__file__).parent / "fixtures" / "browsers"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def install(where: Path, name: str, plist: str, bundle_id: str | None = None) -> Path:
|
|
19
|
+
"""``where/name.app`` with the fixture ``plist``, its bundle id changed to ``bundle_id``"""
|
|
20
|
+
app = where / f"{name}.app"
|
|
21
|
+
(app / "Contents").mkdir(parents=True)
|
|
22
|
+
if bundle_id is None:
|
|
23
|
+
shutil.copyfile(FIXTURES / plist, app / "Contents" / "Info.plist")
|
|
24
|
+
else:
|
|
25
|
+
info = plistlib.loads((FIXTURES / plist).read_bytes())
|
|
26
|
+
info["CFBundleIdentifier"] = bundle_id
|
|
27
|
+
(app / "Contents" / "Info.plist").write_bytes(plistlib.dumps(info))
|
|
28
|
+
return app
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def mac(tmp_path: Path) -> list:
|
|
32
|
+
return list(BrowsersScanner([tmp_path], platform="darwin").scan())
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_chrome_and_brave_by_bundle_id(tmp_path):
|
|
36
|
+
chrome = install(tmp_path, "Google Chrome", "Chrome.plist")
|
|
37
|
+
install(tmp_path, "Brave Browser", "Brave.plist")
|
|
38
|
+
finds = mac(tmp_path)
|
|
39
|
+
assert [(item.source, item.entry, item.name, item.version) for item in finds] == [
|
|
40
|
+
("browser", "brave", "Brave", "1.100.59"),
|
|
41
|
+
("browser", "chrome", "Google Chrome", "158.0.8127.37"),
|
|
42
|
+
]
|
|
43
|
+
assert finds[1].where == chrome.resolve()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_other_channels_arent_stable(tmp_path):
|
|
47
|
+
install(tmp_path, "Google Chrome Beta", "Chrome.plist", "com.google.Chrome.beta")
|
|
48
|
+
install(tmp_path, "Google Chrome Canary", "Chrome.plist", "com.google.Chrome.canary")
|
|
49
|
+
install(tmp_path, "Brave Browser Nightly", "Brave.plist", "com.brave.Browser.nightly")
|
|
50
|
+
assert mac(tmp_path) == []
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_firefox_by_its_channel(tmp_path):
|
|
54
|
+
app = install(tmp_path, "Firefox", "Chrome.plist", "org.mozilla.firefox")
|
|
55
|
+
(item,) = mac(tmp_path)
|
|
56
|
+
assert item.entry == "firefox"
|
|
57
|
+
prefs = app / "Contents" / "Resources" / "defaults" / "pref"
|
|
58
|
+
prefs.mkdir(parents=True)
|
|
59
|
+
(prefs / "channel-prefs.js").write_text('pref("app.update.channel", "beta");\n', encoding="utf-8")
|
|
60
|
+
assert firefox_channel(app) == "beta"
|
|
61
|
+
assert mac(tmp_path) == []
|
|
62
|
+
(prefs / "channel-prefs.js").write_text("pref('app.update.channel', 'release');\n", encoding="utf-8")
|
|
63
|
+
assert [item.entry for item in mac(tmp_path)] == ["firefox"]
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_two_copies_are_one_find(tmp_path):
|
|
67
|
+
install(tmp_path / "a", "Google Chrome", "Chrome.plist")
|
|
68
|
+
install(tmp_path / "b", "Google Chrome", "Chrome.plist")
|
|
69
|
+
assert len(list(BrowsersScanner([tmp_path / "a", tmp_path / "b"], platform="darwin").scan())) == 1
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_linux_by_desktop_file(tmp_path):
|
|
73
|
+
shared = tmp_path / "share" / "applications"
|
|
74
|
+
shared.mkdir(parents=True)
|
|
75
|
+
for name in ("google-chrome.desktop", "google-chrome-beta.desktop", "firefox_firefox.desktop", "code.desktop"):
|
|
76
|
+
(shared / name).write_text("[Desktop Entry]\n", encoding="utf-8")
|
|
77
|
+
finds = list(BrowsersScanner([shared], platform="linux").scan())
|
|
78
|
+
assert [(item.entry, item.version, item.where) for item in finds] == [("chrome", None, None), ("firefox", None, None)]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_desktop_dirs_follow_xdg(monkeypatch, tmp_path):
|
|
82
|
+
for path in ("home/applications", "a/applications", "b"):
|
|
83
|
+
(tmp_path / path).mkdir(parents=True)
|
|
84
|
+
monkeypatch.setenv("XDG_DATA_HOME", str(tmp_path / "home"))
|
|
85
|
+
monkeypatch.setenv("XDG_DATA_DIRS", os.pathsep.join(str(tmp_path / name) for name in "aba"))
|
|
86
|
+
assert desktop_dirs() == [tmp_path / "home" / "applications", tmp_path / "a" / "applications"]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@pytest.mark.parametrize("platform, available", [("darwin", True), ("linux", True), ("win32", False)])
|
|
90
|
+
def test_not_on_windows_where_winget_finds_them(platform, available):
|
|
91
|
+
assert BrowsersScanner(platform=platform).available() is available
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_every_find_is_one_the_browser_source_reads(tmp_path):
|
|
95
|
+
install(tmp_path, "Google Chrome", "Chrome.plist")
|
|
96
|
+
install(tmp_path, "Brave Browser", "Brave.plist")
|
|
97
|
+
install(tmp_path, "Firefox", "Chrome.plist", "org.mozilla.firefox")
|
|
98
|
+
install(tmp_path, "Microsoft Edge", "Chrome.plist", "com.microsoft.edgemac")
|
|
99
|
+
found = Found()
|
|
100
|
+
for item in mac(tmp_path):
|
|
101
|
+
found.add(item.source, item.entry)
|
|
102
|
+
# in the order of the apps' names
|
|
103
|
+
assert found.entries == {"browser": ["brave", "firefox", "chrome", "edge"]} and not found.skipped
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@pytest.mark.parametrize(
|
|
107
|
+
"browser,version,expected",
|
|
108
|
+
[("brave", "158.1.100.59", "1.100.59"), ("brave", "1.100.59", None), ("chrome", "158.0.8127.37", "158.0.8127.37"), ("firefox", None, None)],
|
|
109
|
+
)
|
|
110
|
+
def test_versions_compare_with_the_browser_sources(browser, version, expected):
|
|
111
|
+
assert comparable(browser, version) == expected
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""The cargo scanner.
|
|
2
|
+
|
|
3
|
+
`path-install.*` are what cargo 1.99 wrote for `cargo install --path` (the path renamed). Installs from crates.io are
|
|
4
|
+
the same records with crates.io's index as the source, in its git (`registry+`) and sparse (`sparse+`) spellings.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import shutil
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
import pytest
|
|
14
|
+
|
|
15
|
+
from youpdated.importers import Found
|
|
16
|
+
from youpdated_scanning.cargo import CargoScanner, install_root, parse_package_id
|
|
17
|
+
|
|
18
|
+
FIXTURES = Path(__file__).parent / "fixtures" / "cargo"
|
|
19
|
+
RIPGREP = "ripgrep 14.1.1 (registry+https://github.com/rust-lang/crates.io-index)"
|
|
20
|
+
BAT = "bat 0.25.0 (sparse+https://index.crates.io/)"
|
|
21
|
+
GIT = "zola 0.20.0 (git+https://github.com/getzola/zola#4a1e2b3c)"
|
|
22
|
+
OTHER = "internal 1.0.0 (sparse+https://cargo.example.com/index/)"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@pytest.fixture
|
|
26
|
+
def root(tmp_path):
|
|
27
|
+
"""An install root with the path install and crates.io installs beside it"""
|
|
28
|
+
doc = json.loads((FIXTURES / "path-install.crates2.json").read_text(encoding="utf-8"))
|
|
29
|
+
(record,) = doc["installs"].values()
|
|
30
|
+
for package_id in (RIPGREP, BAT, GIT, OTHER):
|
|
31
|
+
doc["installs"][package_id] = {**record, "bins": [package_id.split()[0]]}
|
|
32
|
+
(tmp_path / ".crates2.json").write_text(json.dumps(doc), encoding="utf-8")
|
|
33
|
+
return tmp_path
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_crates_io_installs(root):
|
|
37
|
+
finds = list(CargoScanner(root).scan())
|
|
38
|
+
assert [(item.source, item.entry, item.version) for item in finds] == [
|
|
39
|
+
("crates", "ripgrep", "14.1.1"), ("crates", "bat", "0.25.0"),
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_the_old_record_when_theres_no_new_one(tmp_path):
|
|
44
|
+
shutil.copyfile(FIXTURES / "path-install.crates.toml", tmp_path / ".crates.toml")
|
|
45
|
+
assert CargoScanner(tmp_path).available()
|
|
46
|
+
assert list(CargoScanner(tmp_path).scan()) == []
|
|
47
|
+
with (tmp_path / ".crates.toml").open("a", encoding="utf-8") as file:
|
|
48
|
+
file.write(f'"{RIPGREP}" = ["rg"]\n')
|
|
49
|
+
assert [item.entry for item in CargoScanner(tmp_path).scan()] == ["ripgrep"]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_an_empty_record_is_nothing_installed(tmp_path):
|
|
53
|
+
# what cargo leaves after the last `cargo uninstall`
|
|
54
|
+
(tmp_path / ".crates2.json").write_text("", encoding="utf-8")
|
|
55
|
+
assert CargoScanner(tmp_path).available()
|
|
56
|
+
assert list(CargoScanner(tmp_path).scan()) == []
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_nothing_installed_isnt_available(tmp_path):
|
|
60
|
+
assert not CargoScanner(tmp_path).available()
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def test_install_root_order(monkeypatch, tmp_path):
|
|
64
|
+
monkeypatch.delenv("CARGO_INSTALL_ROOT", raising=False)
|
|
65
|
+
monkeypatch.delenv("CARGO_HOME", raising=False)
|
|
66
|
+
assert install_root() == Path.home() / ".cargo"
|
|
67
|
+
monkeypatch.setenv("CARGO_HOME", str(tmp_path / "home"))
|
|
68
|
+
assert install_root() == tmp_path / "home"
|
|
69
|
+
monkeypatch.setenv("CARGO_INSTALL_ROOT", str(tmp_path / "root"))
|
|
70
|
+
assert install_root() == tmp_path / "root"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_parse_package_id():
|
|
74
|
+
assert parse_package_id(RIPGREP) == ("ripgrep", "14.1.1")
|
|
75
|
+
assert parse_package_id(GIT) is None
|
|
76
|
+
assert parse_package_id(OTHER) is None
|
|
77
|
+
assert parse_package_id("not an id") is None
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_every_find_is_one_the_crates_source_reads(root):
|
|
81
|
+
found = Found()
|
|
82
|
+
for item in CargoScanner(root).scan():
|
|
83
|
+
found.add(item.source, item.entry)
|
|
84
|
+
assert found.entries == {"crates": ["ripgrep", "bat"]} and not found.skipped
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""The dotnet scanner.
|
|
2
|
+
|
|
3
|
+
`none.json` is `dotnet tool list -g --format json` from a real SDK (10.0.403) with no tools. The listing with tools is
|
|
4
|
+
written in the same shape, with each tool's `packageId`, `version`, and `commands`.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import subprocess
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from types import SimpleNamespace
|
|
13
|
+
|
|
14
|
+
import pytest
|
|
15
|
+
|
|
16
|
+
from youpdated.importers import Found
|
|
17
|
+
from youpdated_scanning import ScanError, base, dotnet
|
|
18
|
+
from youpdated_scanning.dotnet import DotnetScanner, parse_list
|
|
19
|
+
|
|
20
|
+
FIXTURES = Path(__file__).parent / "fixtures" / "dotnet"
|
|
21
|
+
TOOLS = json.dumps({"version": 1, "data": [
|
|
22
|
+
{"packageId": "dotnet-ef", "version": "10.0.0", "commands": ["dotnet-ef"]},
|
|
23
|
+
{"packageId": "csharpier", "version": "1.2.1", "commands": ["csharpier"]},
|
|
24
|
+
]})
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_no_tools():
|
|
28
|
+
assert parse_list((FIXTURES / "none.json").read_text(encoding="utf-8")) == []
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_tools_by_package_id():
|
|
32
|
+
class Dotnet(DotnetScanner):
|
|
33
|
+
def dotnet(self, *args):
|
|
34
|
+
assert args == ("tool", "list", "-g", "--format", "json")
|
|
35
|
+
return TOOLS
|
|
36
|
+
|
|
37
|
+
finds = list(Dotnet().scan())
|
|
38
|
+
assert [(item.source, item.entry, item.version) for item in finds] == [
|
|
39
|
+
("nuget", "dotnet-ef", "10.0.0"), ("nuget", "csharpier", "1.2.1"),
|
|
40
|
+
]
|
|
41
|
+
found = Found()
|
|
42
|
+
for item in finds:
|
|
43
|
+
found.add(item.source, item.entry)
|
|
44
|
+
assert found.entries == {"nuget": ["dotnet-ef", "csharpier"]}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_an_old_sdks_table_is_a_scan_error():
|
|
48
|
+
with pytest.raises(ScanError, match="other than JSON"):
|
|
49
|
+
parse_list("Package Id Version Commands\n-------------------------------------\n")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_only_with_a_tools_folder(monkeypatch, tmp_path):
|
|
53
|
+
monkeypatch.setattr(dotnet.shutil, "which", lambda name: "/usr/local/bin/dotnet")
|
|
54
|
+
monkeypatch.setenv("DOTNET_CLI_HOME", str(tmp_path))
|
|
55
|
+
assert not DotnetScanner().available()
|
|
56
|
+
(tmp_path / ".dotnet" / "tools").mkdir(parents=True)
|
|
57
|
+
assert DotnetScanner().available()
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def test_dotnet_runs_without_telemetry_or_update_checks(monkeypatch):
|
|
61
|
+
calls = []
|
|
62
|
+
|
|
63
|
+
def run(command, **kwargs):
|
|
64
|
+
calls.append((command, kwargs))
|
|
65
|
+
return subprocess.CompletedProcess(command, 0, stdout=TOOLS, stderr="")
|
|
66
|
+
|
|
67
|
+
monkeypatch.setattr(base.shutil, "which", lambda name: "/usr/local/bin/dotnet")
|
|
68
|
+
monkeypatch.setattr(base.subprocess, "run", run)
|
|
69
|
+
DotnetScanner().dotnet("tool", "list")
|
|
70
|
+
(_, kwargs), = calls
|
|
71
|
+
env = SimpleNamespace(**{key.lower(): value for key, value in kwargs["env"].items() if key.startswith("DOTNET_")})
|
|
72
|
+
assert env.dotnet_cli_telemetry_optout == "1"
|
|
73
|
+
assert env.dotnet_cli_workload_update_notify_disable == "1"
|
|
74
|
+
assert env.dotnet_skip_first_time_experience == "1"
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""The electron scanner.
|
|
2
|
+
|
|
3
|
+
`curseforge-gitlab.yml` and `vernier-generic.yml` are copied from real apps. No app with `provider: github` was
|
|
4
|
+
installed where they came from, so that one is written in the shape electron-builder writes it.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import shutil
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from youpdated.importers import Found
|
|
13
|
+
from youpdated_scanning.electron import ElectronScanner, github_repo, read_update_config
|
|
14
|
+
|
|
15
|
+
FIXTURES = Path(__file__).parent / "fixtures" / "electron"
|
|
16
|
+
MAC_FIXTURES = Path(__file__).parent / "fixtures" / "macapps"
|
|
17
|
+
GITHUB = "owner: someone\nrepo: some-app\nprovider: github\nupdaterCacheDirName: some-app-updater\n"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def mac_app(where: Path, name: str, update: str | None) -> Path:
|
|
21
|
+
"""``where/name.app`` with UTM's real Info.plist and ``update`` as its app-update.yml"""
|
|
22
|
+
app = where / f"{name}.app"
|
|
23
|
+
(app / "Contents" / "Resources").mkdir(parents=True)
|
|
24
|
+
shutil.copyfile(MAC_FIXTURES / "UTM.plist", app / "Contents" / "Info.plist")
|
|
25
|
+
if update is not None:
|
|
26
|
+
(app / "Contents" / "Resources" / "app-update.yml").write_text(update, encoding="utf-8")
|
|
27
|
+
return app
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def fixture(name: str) -> str:
|
|
31
|
+
return (FIXTURES / name).read_text(encoding="utf-8")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_a_mac_app_updating_from_github(tmp_path):
|
|
35
|
+
app = mac_app(tmp_path, "Some App", GITHUB)
|
|
36
|
+
(item,) = ElectronScanner([tmp_path], platform="darwin").scan()
|
|
37
|
+
assert (item.source, item.entry, item.name, item.version) == ("git", "github.com/someone/some-app", "UTM", "5.0.9")
|
|
38
|
+
assert item.where == app.resolve()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_setapps_apps_are_skipped(tmp_path):
|
|
42
|
+
mac_app(tmp_path / "Setapp", "Some App", GITHUB)
|
|
43
|
+
assert list(ElectronScanner([tmp_path], platform="darwin").scan()) == []
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_other_providers_and_none_are_skipped(tmp_path):
|
|
47
|
+
mac_app(tmp_path, "CurseForge", fixture("curseforge-gitlab.yml"))
|
|
48
|
+
mac_app(tmp_path, "Vernier Graphical Analysis", fixture("vernier-generic.yml"))
|
|
49
|
+
mac_app(tmp_path, "Plain", None)
|
|
50
|
+
mac_app(tmp_path, "Broken", "provider: [github")
|
|
51
|
+
assert list(ElectronScanner([tmp_path], platform="darwin").scan()) == []
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_a_private_repo_is_skipped():
|
|
55
|
+
assert github_repo({"provider": "github", "owner": "someone", "repo": "app", "private": True}) is None
|
|
56
|
+
assert github_repo({"provider": "github", "owner": "someone", "repo": "app", "private": False}) == "github.com/someone/app"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_github_enterprise_and_odd_values():
|
|
60
|
+
assert github_repo({"provider": "github", "owner": "a", "repo": "b", "host": "GitHub.Example.com"}) == "github.example.com/a/b"
|
|
61
|
+
assert github_repo({"provider": "github", "owner": "a", "repo": "b", "host": "api.github.com"}) == "github.com/a/b"
|
|
62
|
+
assert github_repo({"provider": "github", "owner": "a/../x", "repo": "b"}) is None
|
|
63
|
+
assert github_repo({"provider": "github", "owner": "a"}) is None
|
|
64
|
+
assert github_repo({"provider": "github", "owner": "a", "repo": "b", "host": "http://x"}) is None
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_the_real_configs_read():
|
|
68
|
+
assert read_update_config(FIXTURES / "curseforge-gitlab.yml") == {
|
|
69
|
+
"provider": "gitlab", "updaterCacheDirName": "curseforge-updater",
|
|
70
|
+
}
|
|
71
|
+
assert read_update_config(FIXTURES / "vernier-generic.yml")["provider"] == "generic"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_windows_and_linux_install_folders(tmp_path):
|
|
75
|
+
programs = tmp_path / "Programs"
|
|
76
|
+
(programs / "some-app" / "resources").mkdir(parents=True)
|
|
77
|
+
(programs / "some-app" / "resources" / "app-update.yml").write_text(GITHUB, encoding="utf-8")
|
|
78
|
+
(programs / "other" / "resources").mkdir(parents=True)
|
|
79
|
+
(programs / "notes.txt").write_text("not a program", encoding="utf-8")
|
|
80
|
+
finds = list(ElectronScanner([programs], platform="win32").scan())
|
|
81
|
+
assert [(item.entry, item.name, item.version) for item in finds] == [("github.com/someone/some-app", "some-app", None)]
|
|
82
|
+
assert finds[0].where == (programs / "some-app").resolve()
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_the_same_repo_in_two_places_is_one_find(tmp_path):
|
|
86
|
+
mac_app(tmp_path / "a", "Some App", GITHUB)
|
|
87
|
+
mac_app(tmp_path / "b", "Some App", GITHUB.replace("someone", "SomeOne"))
|
|
88
|
+
assert len(list(ElectronScanner([tmp_path / "a", tmp_path / "b"], platform="darwin").scan())) == 1
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_every_find_is_one_the_git_source_reads(tmp_path):
|
|
92
|
+
mac_app(tmp_path, "Some App", GITHUB)
|
|
93
|
+
found = Found()
|
|
94
|
+
for item in ElectronScanner([tmp_path], platform="darwin").scan():
|
|
95
|
+
found.add(item.source, item.entry)
|
|
96
|
+
assert found.entries == {"git": ["github.com/someone/some-app"]} and not found.skipped
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""The flatpak scanner"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from youpdated.importers import Found
|
|
8
|
+
from youpdated_scanning import flatpak
|
|
9
|
+
from youpdated_scanning.flatpak import FlatpakScanner, parse_list
|
|
10
|
+
|
|
11
|
+
FIXTURES = Path(__file__).parent / "fixtures" / "flatpak"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Flatpak(FlatpakScanner):
|
|
15
|
+
def __init__(self, listed: str | None = None) -> None:
|
|
16
|
+
self.listed, self.calls = listed, []
|
|
17
|
+
|
|
18
|
+
def flatpak(self, *args: str) -> str:
|
|
19
|
+
self.calls.append(args)
|
|
20
|
+
return self.listed if self.listed is not None else (FIXTURES / "list.txt").read_text(encoding="utf-8")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_apps_from_flathub_once_each():
|
|
24
|
+
finds = list(Flatpak().scan())
|
|
25
|
+
assert [(item.entry, item.name, item.version) for item in finds] == [
|
|
26
|
+
("org.mozilla.firefox", "Firefox", "146.0"),
|
|
27
|
+
("com.valvesoftware.Steam", "Steam", "1.0.0.85"),
|
|
28
|
+
# no AppStream version
|
|
29
|
+
("io.github.Hand.Made", "Hand Made", None),
|
|
30
|
+
]
|
|
31
|
+
assert all(item.source == "flathub" for item in finds)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_lists_apps_only_without_fancy_output():
|
|
35
|
+
scanner = Flatpak()
|
|
36
|
+
list(scanner.scan())
|
|
37
|
+
assert scanner.calls == [("list", "--app", "--columns=application,version,origin,name")]
|
|
38
|
+
assert flatpak.ENV == {"FLATPAK_FANCY_OUTPUT": "0"}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_no_apps_and_short_rows():
|
|
42
|
+
assert list(Flatpak("").scan()) == []
|
|
43
|
+
assert parse_list("org.a.App\t1.0\n\t1.0\tflathub\norg.b.App\t2.0\tflathub\r\n") == [
|
|
44
|
+
("org.b.App", "2.0", "flathub", None)
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_every_find_is_one_the_flathub_source_reads():
|
|
49
|
+
found = Found()
|
|
50
|
+
for item in Flatpak().scan():
|
|
51
|
+
found.add(item.source, item.entry)
|
|
52
|
+
assert found.entries == {"flathub": ["org.mozilla.firefox", "com.valvesoftware.Steam", "io.github.Hand.Made"]}
|
|
53
|
+
assert not found.skipped
|