socketdev 3.1.0__tar.gz → 3.1.1__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.
- {socketdev-3.1.0 → socketdev-3.1.1}/.github/workflows/version-check.yml +49 -10
- socketdev-3.1.1/.hooks/sync_version.py +172 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/PKG-INFO +1 -1
- {socketdev-3.1.0 → socketdev-3.1.1}/pyproject.toml +1 -1
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/core/issues.py +1 -1
- socketdev-3.1.1/socketdev/version.py +1 -0
- socketdev-3.1.1/tests/unit/test_issues_did_you_mean_props.py +28 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/uv.lock +1 -1
- socketdev-3.1.0/.hooks/sync_version.py +0 -95
- socketdev-3.1.0/socketdev/version.py +0 -1
- {socketdev-3.1.0 → socketdev-3.1.1}/.github/CODEOWNERS +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/.github/PULL_REQUEST_TEMPLATE/bug-fix.md +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/.github/PULL_REQUEST_TEMPLATE/improvement.md +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/.github/workflows/pr-preview.yml +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/.github/workflows/release.yml +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/.gitignore +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/.python-version +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/LICENSE +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/README.rst +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/scripts/build.sh +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/scripts/deploy-test-pypi.sh +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/alertfullscansearch/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/alerts/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/alerttypes/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/analytics/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/apitokens/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/auditlog/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/basics/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/core/api.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/core/classes.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/core/dedupe.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/dependencies/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/diffscans/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/exceptions.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/export/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/fixes/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/fullscans/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/historical/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/labels/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/licensemetadata/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/log.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/npm/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/openapi/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/org/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/purl/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/quota/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/report/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/repos/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/repositories/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/sbom/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/settings/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/supportedfiles/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/telemetry/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/threatfeed/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/tools/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/triage/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/uploadmanifests/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/utils/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/socketdev/webhooks/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/README.md +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/conftest.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/integration/test_all_endpoints.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/integration/test_comprehensive_integration.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/integration/test_diffscans_integration.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/integration/test_new_endpoints.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/run_tests.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/unit/__init__.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/unit/test_all_endpoints_unit.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/unit/test_dedupe.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/unit/test_socket_alert_category.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/unit/test_socket_sdk_unit.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/unit/test_upload_manifests.py +0 -0
- {socketdev-3.1.0 → socketdev-3.1.1}/tests/unit/test_working_endpoints_unit.py +0 -0
|
@@ -4,8 +4,8 @@ on:
|
|
|
4
4
|
types: [opened, synchronize, ready_for_review]
|
|
5
5
|
paths:
|
|
6
6
|
- 'socketdev/**'
|
|
7
|
-
- 'setup.py'
|
|
8
7
|
- 'pyproject.toml'
|
|
8
|
+
- 'uv.lock'
|
|
9
9
|
|
|
10
10
|
permissions:
|
|
11
11
|
contents: read
|
|
@@ -33,16 +33,55 @@ jobs:
|
|
|
33
33
|
MAIN_VERSION=$(grep -o "__version__.*" socketdev/version.py | awk '{print $3}' | tr -d '"' | tr -d "'")
|
|
34
34
|
echo "MAIN_VERSION=$MAIN_VERSION" >> $GITHUB_ENV
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
export PR_VERSION
|
|
37
|
+
export MAIN_VERSION
|
|
38
|
+
|
|
39
|
+
# Compare against both main and latest published PyPI release.
|
|
40
|
+
python3 <<'PY'
|
|
41
|
+
import json
|
|
42
|
+
import os
|
|
43
|
+
import urllib.request
|
|
38
44
|
from packaging import version
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
|
|
46
|
+
pr_ver = version.parse(os.environ["PR_VERSION"])
|
|
47
|
+
main_ver = version.parse(os.environ["MAIN_VERSION"])
|
|
48
|
+
|
|
49
|
+
with urllib.request.urlopen("https://pypi.org/pypi/socketdev/json") as response:
|
|
50
|
+
pypi_data = json.load(response)
|
|
51
|
+
|
|
52
|
+
published_versions = []
|
|
53
|
+
for raw in pypi_data.get("releases", {}).keys():
|
|
54
|
+
parsed = version.parse(raw)
|
|
55
|
+
if not parsed.is_prerelease and not parsed.is_devrelease:
|
|
56
|
+
published_versions.append(parsed)
|
|
57
|
+
|
|
58
|
+
pypi_ver = max(published_versions) if published_versions else version.parse("0.0.0")
|
|
59
|
+
required_floor = max(main_ver, pypi_ver)
|
|
60
|
+
|
|
61
|
+
if pr_ver <= required_floor:
|
|
62
|
+
print(
|
|
63
|
+
f"❌ Version must be greater than main and PyPI! "
|
|
64
|
+
f"Main: {main_ver}, PyPI: {pypi_ver}, PR: {pr_ver}"
|
|
65
|
+
)
|
|
66
|
+
raise SystemExit(1)
|
|
67
|
+
|
|
68
|
+
print(
|
|
69
|
+
f"✅ Version properly incremented. "
|
|
70
|
+
f"Main: {main_ver}, PyPI: {pypi_ver}, PR: {pr_ver}"
|
|
71
|
+
)
|
|
72
|
+
PY
|
|
73
|
+
|
|
74
|
+
- name: Require uv.lock update when pyproject changes
|
|
75
|
+
run: |
|
|
76
|
+
CHANGED_FILES="$(git diff --name-only origin/main...HEAD)"
|
|
77
|
+
|
|
78
|
+
if echo "$CHANGED_FILES" | grep -qx 'pyproject.toml'; then
|
|
79
|
+
if ! echo "$CHANGED_FILES" | grep -qx 'uv.lock'; then
|
|
80
|
+
echo "❌ pyproject.toml changed, but uv.lock was not updated."
|
|
81
|
+
echo "Run 'uv lock' and commit uv.lock with the version bump."
|
|
82
|
+
exit 1
|
|
83
|
+
fi
|
|
84
|
+
fi
|
|
46
85
|
|
|
47
86
|
- name: Manage PR Comment
|
|
48
87
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import subprocess
|
|
3
|
+
import pathlib
|
|
4
|
+
import re
|
|
5
|
+
import sys
|
|
6
|
+
import urllib.request
|
|
7
|
+
import json
|
|
8
|
+
|
|
9
|
+
VERSION_FILE = pathlib.Path("socketdev/version.py")
|
|
10
|
+
PYPROJECT_FILE = pathlib.Path("pyproject.toml")
|
|
11
|
+
UV_LOCK_FILE = pathlib.Path("uv.lock")
|
|
12
|
+
|
|
13
|
+
VERSION_PATTERN = re.compile(r"__version__\s*=\s*['\"]([^'\"]+)['\"]")
|
|
14
|
+
PYPROJECT_PATTERN = re.compile(r'^version\s*=\s*".*"$', re.MULTILINE)
|
|
15
|
+
STABLE_VERSION_PATTERN = re.compile(r"^\d+\.\d+\.\d+$")
|
|
16
|
+
PYPI_PROD_API = "https://pypi.org/pypi/socketdev/json"
|
|
17
|
+
PYPI_TEST_API = "https://test.pypi.org/pypi/socketdev/json"
|
|
18
|
+
|
|
19
|
+
def read_version_from_version_file(path: pathlib.Path) -> str:
|
|
20
|
+
content = path.read_text()
|
|
21
|
+
match = VERSION_PATTERN.search(content)
|
|
22
|
+
if not match:
|
|
23
|
+
print(f"❌ Could not find __version__ in {path}")
|
|
24
|
+
sys.exit(1)
|
|
25
|
+
return match.group(1)
|
|
26
|
+
|
|
27
|
+
def read_version_from_git(path: str) -> str:
|
|
28
|
+
try:
|
|
29
|
+
output = subprocess.check_output(["git", "show", f"HEAD:{path}"], text=True)
|
|
30
|
+
match = VERSION_PATTERN.search(output)
|
|
31
|
+
if not match:
|
|
32
|
+
return None
|
|
33
|
+
return match.group(1)
|
|
34
|
+
except subprocess.CalledProcessError:
|
|
35
|
+
return None
|
|
36
|
+
|
|
37
|
+
def bump_patch_version(version: str) -> str:
|
|
38
|
+
if ".dev" in version:
|
|
39
|
+
version = version.split(".dev")[0]
|
|
40
|
+
parts = version.split(".")
|
|
41
|
+
parts[-1] = str(int(parts[-1]) + 1)
|
|
42
|
+
return ".".join(parts)
|
|
43
|
+
|
|
44
|
+
def parse_stable_version(version: str):
|
|
45
|
+
if not STABLE_VERSION_PATTERN.fullmatch(version):
|
|
46
|
+
return None
|
|
47
|
+
return tuple(int(part) for part in version.split("."))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def format_stable_version(version_parts) -> str:
|
|
51
|
+
return ".".join(str(part) for part in version_parts)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def fetch_existing_versions(api_url: str) -> set:
|
|
55
|
+
try:
|
|
56
|
+
with urllib.request.urlopen(api_url) as response:
|
|
57
|
+
data = json.load(response)
|
|
58
|
+
return set(data.get("releases", {}).keys())
|
|
59
|
+
except Exception as e:
|
|
60
|
+
print(f"⚠️ Warning: Failed to fetch versions from {api_url}: {e}")
|
|
61
|
+
return set()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def fetch_latest_stable_pypi_version():
|
|
65
|
+
versions = fetch_existing_versions(PYPI_PROD_API)
|
|
66
|
+
stable_versions = []
|
|
67
|
+
for ver in versions:
|
|
68
|
+
parsed = parse_stable_version(ver)
|
|
69
|
+
if parsed is not None:
|
|
70
|
+
stable_versions.append(parsed)
|
|
71
|
+
if not stable_versions:
|
|
72
|
+
return None
|
|
73
|
+
return max(stable_versions)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def find_next_available_dev_version(base_version: str) -> str:
|
|
77
|
+
existing_versions = fetch_existing_versions(PYPI_TEST_API)
|
|
78
|
+
for i in range(1, 100):
|
|
79
|
+
candidate = f"{base_version}.dev{i}"
|
|
80
|
+
if candidate not in existing_versions:
|
|
81
|
+
return candidate
|
|
82
|
+
print("❌ Could not find available .devN slot after 100 attempts.")
|
|
83
|
+
sys.exit(1)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def find_next_stable_patch_version(current_version: str) -> str:
|
|
87
|
+
current_stable = current_version.split(".dev")[0] if ".dev" in current_version else current_version
|
|
88
|
+
current_parts = parse_stable_version(current_stable)
|
|
89
|
+
if current_parts is None:
|
|
90
|
+
print(f"❌ Unsupported version format for stable bump: {current_version}")
|
|
91
|
+
sys.exit(1)
|
|
92
|
+
|
|
93
|
+
latest_pypi_parts = fetch_latest_stable_pypi_version()
|
|
94
|
+
base_parts = max([current_parts, latest_pypi_parts] if latest_pypi_parts else [current_parts])
|
|
95
|
+
next_parts = (base_parts[0], base_parts[1], base_parts[2] + 1)
|
|
96
|
+
return format_stable_version(next_parts)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def inject_version(version: str):
|
|
100
|
+
print(f"🔁 Updating version to: {version}")
|
|
101
|
+
|
|
102
|
+
# Update version.py
|
|
103
|
+
VERSION_FILE.write_text(f'__version__ = "{version}"\n')
|
|
104
|
+
|
|
105
|
+
# Update pyproject.toml if it has a version field (it shouldn't with hatch, but just in case)
|
|
106
|
+
pyproject = PYPROJECT_FILE.read_text()
|
|
107
|
+
if PYPROJECT_PATTERN.search(pyproject):
|
|
108
|
+
new_pyproject = PYPROJECT_PATTERN.sub(f'version = "{version}"', pyproject)
|
|
109
|
+
PYPROJECT_FILE.write_text(new_pyproject)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def run_uv_lock() -> bool:
|
|
113
|
+
before = UV_LOCK_FILE.read_bytes() if UV_LOCK_FILE.exists() else b""
|
|
114
|
+
try:
|
|
115
|
+
subprocess.run(["uv", "lock"], check=True, text=True)
|
|
116
|
+
except FileNotFoundError:
|
|
117
|
+
print("❌ `uv` is required but was not found in PATH.")
|
|
118
|
+
sys.exit(1)
|
|
119
|
+
except subprocess.CalledProcessError:
|
|
120
|
+
print("❌ `uv lock` failed. Please run it manually and fix any errors.")
|
|
121
|
+
sys.exit(1)
|
|
122
|
+
|
|
123
|
+
after = UV_LOCK_FILE.read_bytes() if UV_LOCK_FILE.exists() else b""
|
|
124
|
+
return before != after
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def main():
|
|
128
|
+
dev_mode = "--dev" in sys.argv
|
|
129
|
+
current_version = read_version_from_version_file(VERSION_FILE)
|
|
130
|
+
previous_version = read_version_from_git("socketdev/version.py")
|
|
131
|
+
|
|
132
|
+
print(f"Current: {current_version}, Previous: {previous_version}")
|
|
133
|
+
|
|
134
|
+
if current_version == previous_version:
|
|
135
|
+
if dev_mode:
|
|
136
|
+
base_version = current_version.split(".dev")[0] if ".dev" in current_version else current_version
|
|
137
|
+
new_version = find_next_available_dev_version(base_version)
|
|
138
|
+
inject_version(new_version)
|
|
139
|
+
uv_lock_changed = run_uv_lock()
|
|
140
|
+
lock_hint = " and uv.lock" if uv_lock_changed else ""
|
|
141
|
+
print(f"⚠️ Version was unchanged — auto-bumped. Please git add{lock_hint} + commit again.")
|
|
142
|
+
sys.exit(0)
|
|
143
|
+
else:
|
|
144
|
+
new_version = find_next_stable_patch_version(current_version)
|
|
145
|
+
inject_version(new_version)
|
|
146
|
+
uv_lock_changed = run_uv_lock()
|
|
147
|
+
lock_hint = " and uv.lock" if uv_lock_changed else ""
|
|
148
|
+
print(f"⚠️ Version was unchanged — auto-bumped to {new_version}. Please git add{lock_hint} + commit again.")
|
|
149
|
+
sys.exit(1)
|
|
150
|
+
else:
|
|
151
|
+
if not dev_mode:
|
|
152
|
+
current_parts = parse_stable_version(current_version)
|
|
153
|
+
latest_pypi_parts = fetch_latest_stable_pypi_version()
|
|
154
|
+
if current_parts is not None and latest_pypi_parts is not None and current_parts <= latest_pypi_parts:
|
|
155
|
+
next_parts = (latest_pypi_parts[0], latest_pypi_parts[1], latest_pypi_parts[2] + 1)
|
|
156
|
+
new_version = format_stable_version(next_parts)
|
|
157
|
+
inject_version(new_version)
|
|
158
|
+
uv_lock_changed = run_uv_lock()
|
|
159
|
+
lock_hint = " and uv.lock" if uv_lock_changed else ""
|
|
160
|
+
print(f"⚠️ Version {current_version} is already published on PyPI — auto-bumped to {new_version}. Please git add{lock_hint} + commit again.")
|
|
161
|
+
sys.exit(1)
|
|
162
|
+
|
|
163
|
+
uv_lock_changed = run_uv_lock()
|
|
164
|
+
if uv_lock_changed:
|
|
165
|
+
print("⚠️ Version already bumped, but uv.lock was out of date and has been updated. Please git add uv.lock + commit again.")
|
|
166
|
+
sys.exit(1)
|
|
167
|
+
|
|
168
|
+
print("✅ Version already bumped and uv.lock is up to date — proceeding.")
|
|
169
|
+
sys.exit(0)
|
|
170
|
+
|
|
171
|
+
if __name__ == "__main__":
|
|
172
|
+
main()
|
|
@@ -463,7 +463,7 @@ class didYouMean:
|
|
|
463
463
|
|
|
464
464
|
def __init__(self):
|
|
465
465
|
self.description = "Package name is similar to other popular packages and may not be the package you want."
|
|
466
|
-
self.props = {"alternatePackage": "Alternate package", "
|
|
466
|
+
self.props = {"alternatePackage": "Alternate package", "detectedAt": "Detected at"}
|
|
467
467
|
self.suggestion = "Use care when consuming similarly named packages and ensure that you did not intend to consume a different package. Malicious packages often publish using similar names as existing popular packages."
|
|
468
468
|
self.title = "Possible typosquat attack"
|
|
469
469
|
self.emoji = "\ud83e\uddd0"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "3.1.1"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Contract test for the didYouMean alert-type class's props.
|
|
2
|
+
|
|
3
|
+
The OpenAPI schema (`socket-sdk-js/openapi.json` around line 9298) declares
|
|
4
|
+
that the API emits `didYouMean` alerts with ``props: { alternatePackage,
|
|
5
|
+
detectedAt }``. The Python SDK previously declared four props
|
|
6
|
+
(``alternatePackage``, ``downloads``, ``downloadsRatio``, ``editDistance``);
|
|
7
|
+
the latter three are no longer in the API schema and were dead keys at
|
|
8
|
+
runtime — and ``detectedAt`` was missing.
|
|
9
|
+
|
|
10
|
+
Tracks CUS2-5. Sibling of CUS2-4.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import unittest
|
|
14
|
+
|
|
15
|
+
from socketdev.core.issues import didYouMean
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TestDidYouMeanProps(unittest.TestCase):
|
|
19
|
+
def test_props_match_openapi_schema(self):
|
|
20
|
+
"""API emits props { alternatePackage, detectedAt } (openapi.json:9298)."""
|
|
21
|
+
issue = didYouMean()
|
|
22
|
+
self.assertEqual(set(issue.props.keys()), {"alternatePackage", "detectedAt"})
|
|
23
|
+
|
|
24
|
+
def test_props_label_strings_are_non_empty(self):
|
|
25
|
+
"""Every props key must have a non-empty human-readable label."""
|
|
26
|
+
issue = didYouMean()
|
|
27
|
+
for key, label in issue.props.items():
|
|
28
|
+
self.assertTrue(label, f"props[{key!r}] label should not be empty")
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
import subprocess
|
|
3
|
-
import pathlib
|
|
4
|
-
import re
|
|
5
|
-
import sys
|
|
6
|
-
import urllib.request
|
|
7
|
-
import json
|
|
8
|
-
|
|
9
|
-
VERSION_FILE = pathlib.Path("socketdev/version.py")
|
|
10
|
-
PYPROJECT_FILE = pathlib.Path("pyproject.toml")
|
|
11
|
-
|
|
12
|
-
VERSION_PATTERN = re.compile(r"__version__\s*=\s*['\"]([^'\"]+)['\"]")
|
|
13
|
-
PYPROJECT_PATTERN = re.compile(r'^version\s*=\s*".*"$', re.MULTILINE)
|
|
14
|
-
PYPI_API = "https://test.pypi.org/pypi/socketdev/json"
|
|
15
|
-
|
|
16
|
-
def read_version_from_version_file(path: pathlib.Path) -> str:
|
|
17
|
-
content = path.read_text()
|
|
18
|
-
match = VERSION_PATTERN.search(content)
|
|
19
|
-
if not match:
|
|
20
|
-
print(f"❌ Could not find __version__ in {path}")
|
|
21
|
-
sys.exit(1)
|
|
22
|
-
return match.group(1)
|
|
23
|
-
|
|
24
|
-
def read_version_from_git(path: str) -> str:
|
|
25
|
-
try:
|
|
26
|
-
output = subprocess.check_output(["git", "show", f"HEAD:{path}"], text=True)
|
|
27
|
-
match = VERSION_PATTERN.search(output)
|
|
28
|
-
if not match:
|
|
29
|
-
return None
|
|
30
|
-
return match.group(1)
|
|
31
|
-
except subprocess.CalledProcessError:
|
|
32
|
-
return None
|
|
33
|
-
|
|
34
|
-
def bump_patch_version(version: str) -> str:
|
|
35
|
-
if ".dev" in version:
|
|
36
|
-
version = version.split(".dev")[0]
|
|
37
|
-
parts = version.split(".")
|
|
38
|
-
parts[-1] = str(int(parts[-1]) + 1)
|
|
39
|
-
return ".".join(parts)
|
|
40
|
-
|
|
41
|
-
def fetch_existing_versions() -> set:
|
|
42
|
-
try:
|
|
43
|
-
with urllib.request.urlopen(PYPI_API) as response:
|
|
44
|
-
data = json.load(response)
|
|
45
|
-
return set(data.get("releases", {}).keys())
|
|
46
|
-
except Exception as e:
|
|
47
|
-
print(f"⚠️ Warning: Failed to fetch existing versions from Test PyPI: {e}")
|
|
48
|
-
return set()
|
|
49
|
-
|
|
50
|
-
def find_next_available_dev_version(base_version: str) -> str:
|
|
51
|
-
existing_versions = fetch_existing_versions()
|
|
52
|
-
for i in range(1, 100):
|
|
53
|
-
candidate = f"{base_version}.dev{i}"
|
|
54
|
-
if candidate not in existing_versions:
|
|
55
|
-
return candidate
|
|
56
|
-
print("❌ Could not find available .devN slot after 100 attempts.")
|
|
57
|
-
sys.exit(1)
|
|
58
|
-
|
|
59
|
-
def inject_version(version: str):
|
|
60
|
-
print(f"🔁 Updating version to: {version}")
|
|
61
|
-
|
|
62
|
-
# Update version.py
|
|
63
|
-
VERSION_FILE.write_text(f'__version__ = "{version}"\n')
|
|
64
|
-
|
|
65
|
-
# Update pyproject.toml if it has a version field (it shouldn't with hatch, but just in case)
|
|
66
|
-
pyproject = PYPROJECT_FILE.read_text()
|
|
67
|
-
if PYPROJECT_PATTERN.search(pyproject):
|
|
68
|
-
new_pyproject = PYPROJECT_PATTERN.sub(f'version = "{version}"', pyproject)
|
|
69
|
-
PYPROJECT_FILE.write_text(new_pyproject)
|
|
70
|
-
|
|
71
|
-
def main():
|
|
72
|
-
dev_mode = "--dev" in sys.argv
|
|
73
|
-
current_version = read_version_from_version_file(VERSION_FILE)
|
|
74
|
-
previous_version = read_version_from_git("socketdev/version.py")
|
|
75
|
-
|
|
76
|
-
print(f"Current: {current_version}, Previous: {previous_version}")
|
|
77
|
-
|
|
78
|
-
if current_version == previous_version:
|
|
79
|
-
if dev_mode:
|
|
80
|
-
base_version = current_version.split(".dev")[0] if ".dev" in current_version else current_version
|
|
81
|
-
new_version = find_next_available_dev_version(base_version)
|
|
82
|
-
inject_version(new_version)
|
|
83
|
-
print("⚠️ Version was unchanged — auto-bumped. Please git add + commit again.")
|
|
84
|
-
sys.exit(0)
|
|
85
|
-
else:
|
|
86
|
-
new_version = bump_patch_version(current_version)
|
|
87
|
-
inject_version(new_version)
|
|
88
|
-
print("⚠️ Version was unchanged — auto-bumped. Please git add + commit again.")
|
|
89
|
-
sys.exit(1)
|
|
90
|
-
else:
|
|
91
|
-
print("✅ Version already bumped — proceeding.")
|
|
92
|
-
sys.exit(0)
|
|
93
|
-
|
|
94
|
-
if __name__ == "__main__":
|
|
95
|
-
main()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "3.1.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|