socketdev 3.0.16__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.0.16/.github/CODEOWNERS +1 -0
- socketdev-3.0.16/.github/PULL_REQUEST_TEMPLATE/bug-fix.md +19 -0
- socketdev-3.0.16/.github/PULL_REQUEST_TEMPLATE/feature.md +16 -0
- socketdev-3.0.16/.github/PULL_REQUEST_TEMPLATE/improvement.md +10 -0
- socketdev-3.0.16/.github/PULL_REQUEST_TEMPLATE.md +5 -0
- socketdev-3.0.16/.github/workflows/pr-preview.yml +131 -0
- socketdev-3.0.16/.github/workflows/release.yml +75 -0
- socketdev-3.0.16/.github/workflows/version-check.yml +90 -0
- socketdev-3.0.16/.gitignore +19 -0
- socketdev-3.0.16/.hooks/sync_version.py +95 -0
- socketdev-3.0.16/.python-version +1 -0
- socketdev-3.0.16/LICENSE +21 -0
- socketdev-3.0.16/PKG-INFO +1209 -0
- socketdev-3.0.16/README.rst +1158 -0
- socketdev-3.0.16/pyproject.toml +126 -0
- socketdev-3.0.16/scripts/build.sh +21 -0
- socketdev-3.0.16/scripts/deploy-test-pypi.sh +50 -0
- socketdev-3.0.16/socketdev/__init__.py +83 -0
- socketdev-3.0.16/socketdev/alerttypes/__init__.py +38 -0
- socketdev-3.0.16/socketdev/analytics/__init__.py +64 -0
- socketdev-3.0.16/socketdev/apitokens/__init__.py +126 -0
- socketdev-3.0.16/socketdev/auditlog/__init__.py +30 -0
- socketdev-3.0.16/socketdev/basics/__init__.py +120 -0
- socketdev-3.0.16/socketdev/core/api.py +144 -0
- socketdev-3.0.16/socketdev/core/classes.py +148 -0
- socketdev-3.0.16/socketdev/core/dedupe.py +130 -0
- socketdev-3.0.16/socketdev/core/issues.py +2101 -0
- socketdev-3.0.16/socketdev/dependencies/__init__.py +53 -0
- socketdev-3.0.16/socketdev/diffscans/__init__.py +107 -0
- socketdev-3.0.16/socketdev/exceptions.py +47 -0
- socketdev-3.0.16/socketdev/export/__init__.py +75 -0
- socketdev-3.0.16/socketdev/fullscans/__init__.py +898 -0
- socketdev-3.0.16/socketdev/historical/__init__.py +84 -0
- socketdev-3.0.16/socketdev/labels/__init__.py +121 -0
- socketdev-3.0.16/socketdev/licensemetadata/__init__.py +27 -0
- socketdev-3.0.16/socketdev/log.py +4 -0
- socketdev-3.0.16/socketdev/npm/__init__.py +28 -0
- socketdev-3.0.16/socketdev/openapi/__init__.py +19 -0
- socketdev-3.0.16/socketdev/org/__init__.py +34 -0
- socketdev-3.0.16/socketdev/purl/__init__.py +41 -0
- socketdev-3.0.16/socketdev/quota/__init__.py +19 -0
- socketdev-3.0.16/socketdev/report/__init__.py +87 -0
- socketdev-3.0.16/socketdev/repos/__init__.py +165 -0
- socketdev-3.0.16/socketdev/repositories/__init__.py +31 -0
- socketdev-3.0.16/socketdev/sbom/__init__.py +62 -0
- socketdev-3.0.16/socketdev/settings/__init__.py +172 -0
- socketdev-3.0.16/socketdev/threatfeed/__init__.py +37 -0
- socketdev-3.0.16/socketdev/tools/__init__.py +65 -0
- socketdev-3.0.16/socketdev/triage/__init__.py +47 -0
- socketdev-3.0.16/socketdev/uploadmanifests/__init__.py +67 -0
- socketdev-3.0.16/socketdev/utils/__init__.py +342 -0
- socketdev-3.0.16/socketdev/version.py +1 -0
- socketdev-3.0.16/tests/README.md +121 -0
- socketdev-3.0.16/tests/conftest.py +167 -0
- socketdev-3.0.16/tests/integration/test_all_endpoints.py +567 -0
- socketdev-3.0.16/tests/integration/test_comprehensive_integration.py +354 -0
- socketdev-3.0.16/tests/integration/test_diffscans_integration.py +319 -0
- socketdev-3.0.16/tests/integration/test_new_endpoints.py +319 -0
- socketdev-3.0.16/tests/run_tests.py +378 -0
- socketdev-3.0.16/tests/unit/__init__.py +1 -0
- socketdev-3.0.16/tests/unit/test_all_endpoints_unit.py +658 -0
- socketdev-3.0.16/tests/unit/test_dedupe.py +192 -0
- socketdev-3.0.16/tests/unit/test_socket_sdk_unit.py +280 -0
- socketdev-3.0.16/tests/unit/test_working_endpoints_unit.py +464 -0
- socketdev-3.0.16/uv.lock +1203 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @socketdev/eng
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!--Description: Briefly describe the bug and its impact. ⬇️ -->
|
|
2
|
+
|
|
3
|
+
## Root Cause
|
|
4
|
+
<!-- Concise explanation of what caused the bug ⬇️ -->
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Fix
|
|
9
|
+
<!-- Explain how your changes address the bug ⬇️ -->
|
|
10
|
+
|
|
11
|
+
## Public Changelog
|
|
12
|
+
<!-- Write a changelog message between comment tags if this should be included in the public product changelog, Leave blank otherwise. -->
|
|
13
|
+
|
|
14
|
+
<!-- changelog ⬇️-->
|
|
15
|
+
N/A
|
|
16
|
+
<!-- /changelog ⬆️ -->
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
<!-- TEMPLATE TYPE DON'T REMOVE: python-sdk-template-bug-fix -->
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!-- Description: Briefly describe the new feature you're introducing ⬇️ -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Why?
|
|
5
|
+
<!-- Explain the motivation behind this feature and its expected benefits ⬇️ -->
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Public Changelog
|
|
10
|
+
<!-- Write a changelog message between comment tags if this should be included in the public product changelog. -->
|
|
11
|
+
|
|
12
|
+
<!-- changelog ⬇️-->
|
|
13
|
+
N/A
|
|
14
|
+
<!-- /changelog ⬆️ -->
|
|
15
|
+
|
|
16
|
+
<!-- TEMPLATE TYPE DON'T REMOVE: python-sdk-template-feature -->
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<!-- Description: Briefly describe the code improvement you're making. This could include things like lint fixes, adding monitoring dashboards, optimizing scripts, refactoring, etc. ⬇️ -->
|
|
2
|
+
|
|
3
|
+
## Public Changelog
|
|
4
|
+
<!-- Write a changelog message between comment tags if this should be included in the public product changelog. -->
|
|
5
|
+
|
|
6
|
+
<!-- changelog ⬇️-->
|
|
7
|
+
N/A
|
|
8
|
+
<!-- /changelog ⬆️ -->
|
|
9
|
+
|
|
10
|
+
<!-- TEMPLATE TYPE DON'T REMOVE: python-sdk-template-improvement -->
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
name: PR Preview
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [opened, synchronize, ready_for_review]
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
preview:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
permissions:
|
|
10
|
+
id-token: write
|
|
11
|
+
contents: read
|
|
12
|
+
pull-requests: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
|
15
|
+
with:
|
|
16
|
+
fetch-depth: 0
|
|
17
|
+
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
|
|
18
|
+
with:
|
|
19
|
+
python-version: '3.x'
|
|
20
|
+
|
|
21
|
+
# Install all dependencies from pyproject.toml
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: |
|
|
24
|
+
python -m pip install --upgrade pip
|
|
25
|
+
pip install hatchling==1.27.0
|
|
26
|
+
pip install hatch==1.14.0
|
|
27
|
+
|
|
28
|
+
- name: Inject full dynamic version
|
|
29
|
+
run: python .hooks/sync_version.py --dev
|
|
30
|
+
|
|
31
|
+
- name: Check if version exists on Test PyPI
|
|
32
|
+
id: version_check
|
|
33
|
+
run: |
|
|
34
|
+
VERSION=$(hatch version | cut -d+ -f1)
|
|
35
|
+
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
36
|
+
if curl -s -f https://test.pypi.org/pypi/socketdev/$VERSION/json > /dev/null; then
|
|
37
|
+
echo "Version ${VERSION} already exists on Test PyPI"
|
|
38
|
+
echo "exists=true" >> $GITHUB_OUTPUT
|
|
39
|
+
else
|
|
40
|
+
echo "Version ${VERSION} not found on Test PyPI - proceeding with test deployment"
|
|
41
|
+
echo "exists=false" >> $GITHUB_OUTPUT
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
- name: Clean previous builds
|
|
45
|
+
run: rm -rf dist/ build/ *.egg-info
|
|
46
|
+
|
|
47
|
+
- name: Get Hatch version
|
|
48
|
+
id: version
|
|
49
|
+
run: |
|
|
50
|
+
VERSION=$(hatch version | cut -d+ -f1)
|
|
51
|
+
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
52
|
+
|
|
53
|
+
- name: Build package
|
|
54
|
+
if: steps.version_check.outputs.exists != 'true'
|
|
55
|
+
run: |
|
|
56
|
+
hatch build
|
|
57
|
+
|
|
58
|
+
- name: Publish to Test PyPI
|
|
59
|
+
if: steps.version_check.outputs.exists != 'true'
|
|
60
|
+
uses: pypa/gh-action-pypi-publish@ab69e431e9c9f48a3310be0a56527c679f56e04d
|
|
61
|
+
with:
|
|
62
|
+
repository-url: https://test.pypi.org/legacy/
|
|
63
|
+
verbose: true
|
|
64
|
+
|
|
65
|
+
- name: Comment on PR
|
|
66
|
+
if: steps.version_check.outputs.exists != 'true'
|
|
67
|
+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
|
|
68
|
+
env:
|
|
69
|
+
VERSION: ${{ env.VERSION }}
|
|
70
|
+
with:
|
|
71
|
+
script: |
|
|
72
|
+
const version = process.env.VERSION;
|
|
73
|
+
const prNumber = context.payload.pull_request.number;
|
|
74
|
+
const owner = context.repo.owner;
|
|
75
|
+
const repo = context.repo.repo;
|
|
76
|
+
// Find existing bot comments
|
|
77
|
+
const comments = await github.rest.issues.listComments({
|
|
78
|
+
owner: context.repo.owner,
|
|
79
|
+
repo: context.repo.repo,
|
|
80
|
+
issue_number: prNumber,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const botComment = comments.data.find(comment =>
|
|
84
|
+
comment.user.type === 'Bot' &&
|
|
85
|
+
comment.body.includes('🚀 Preview package published!')
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const comment = `
|
|
89
|
+
🚀 Preview package published!
|
|
90
|
+
|
|
91
|
+
Install with:
|
|
92
|
+
\`\`\`bash
|
|
93
|
+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketdev==${version}
|
|
94
|
+
\`\`\``;
|
|
95
|
+
|
|
96
|
+
if (botComment) {
|
|
97
|
+
// Update existing comment
|
|
98
|
+
await github.rest.issues.updateComment({
|
|
99
|
+
owner: owner,
|
|
100
|
+
repo: repo,
|
|
101
|
+
comment_id: botComment.id,
|
|
102
|
+
body: comment
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
// Create new comment
|
|
106
|
+
await github.rest.issues.createComment({
|
|
107
|
+
owner: owner,
|
|
108
|
+
repo: repo,
|
|
109
|
+
issue_number: prNumber,
|
|
110
|
+
body: comment
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
- name: Verify package is available
|
|
115
|
+
if: steps.version_check.outputs.exists != 'true'
|
|
116
|
+
id: verify_package
|
|
117
|
+
env:
|
|
118
|
+
VERSION: ${{ env.VERSION }}
|
|
119
|
+
run: |
|
|
120
|
+
for i in {1..30}; do
|
|
121
|
+
if pip install --index-url 'https://test.pypi.org/simple/' --extra-index-url 'https://pypi.org/simple' socketdev==${VERSION}; then
|
|
122
|
+
echo "Package ${VERSION} is now available and installable on Test PyPI"
|
|
123
|
+
pip uninstall -y socketdev
|
|
124
|
+
echo "success=true" >> $GITHUB_OUTPUT
|
|
125
|
+
exit 0
|
|
126
|
+
fi
|
|
127
|
+
echo "Attempt $i: Package not yet installable, waiting 20s... (${i}/30)"
|
|
128
|
+
sleep 20
|
|
129
|
+
done
|
|
130
|
+
echo "success=false" >> $GITHUB_OUTPUT
|
|
131
|
+
exit 1
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [published]
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
release:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
permissions:
|
|
10
|
+
id-token: write
|
|
11
|
+
contents: read
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
|
|
17
|
+
with:
|
|
18
|
+
python-version: '3.x'
|
|
19
|
+
|
|
20
|
+
# Install all dependencies from pyproject.toml
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: |
|
|
23
|
+
python -m pip install --upgrade pip
|
|
24
|
+
pip install hatchling==1.27.0
|
|
25
|
+
pip install hatch==1.14.0
|
|
26
|
+
|
|
27
|
+
- name: Get Version
|
|
28
|
+
id: version
|
|
29
|
+
run: |
|
|
30
|
+
RAW_VERSION=$(hatch version)
|
|
31
|
+
echo "VERSION=$RAW_VERSION" >> $GITHUB_ENV
|
|
32
|
+
if [ "v$RAW_VERSION" != "${{ github.ref_name }}" ]; then
|
|
33
|
+
echo "Error: Git tag (${{ github.ref_name }}) does not match hatch version (v$RAW_VERSION)"
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
- name: Check if version exists on PyPI
|
|
38
|
+
id: version_check
|
|
39
|
+
env:
|
|
40
|
+
VERSION: ${{ env.VERSION }}
|
|
41
|
+
run: |
|
|
42
|
+
if curl -s -f https://pypi.org/pypi/socketdev/$VERSION/json > /dev/null; then
|
|
43
|
+
echo "Version ${VERSION} already exists on PyPI"
|
|
44
|
+
echo "pypi_exists=true" >> $GITHUB_OUTPUT
|
|
45
|
+
else
|
|
46
|
+
echo "Version ${VERSION} not found on PyPI - proceeding with PyPI deployment"
|
|
47
|
+
echo "pypi_exists=false" >> $GITHUB_OUTPUT
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
- name: Build package
|
|
51
|
+
if: steps.version_check.outputs.pypi_exists != 'true'
|
|
52
|
+
run: |
|
|
53
|
+
hatch build
|
|
54
|
+
|
|
55
|
+
- name: Publish to PyPI
|
|
56
|
+
if: steps.version_check.outputs.pypi_exists != 'true'
|
|
57
|
+
uses: pypa/gh-action-pypi-publish@ab69e431e9c9f48a3310be0a56527c679f56e04d
|
|
58
|
+
|
|
59
|
+
- name: Verify package is installable
|
|
60
|
+
id: verify_package
|
|
61
|
+
env:
|
|
62
|
+
VERSION: ${{ env.VERSION }}
|
|
63
|
+
run: |
|
|
64
|
+
for i in {1..30}; do
|
|
65
|
+
if pip install socketdev==${VERSION}; then
|
|
66
|
+
echo "Package ${VERSION} is now available and installable on PyPI"
|
|
67
|
+
pip uninstall -y socketdev
|
|
68
|
+
echo "success=true" >> $GITHUB_OUTPUT
|
|
69
|
+
exit 0
|
|
70
|
+
fi
|
|
71
|
+
echo "Attempt $i: Package not yet installable, waiting 20s... (${i}/30)"
|
|
72
|
+
sleep 20
|
|
73
|
+
done
|
|
74
|
+
echo "success=false" >> $GITHUB_OUTPUT
|
|
75
|
+
exit 1
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
name: Version Check
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [opened, synchronize, ready_for_review]
|
|
5
|
+
paths:
|
|
6
|
+
- 'socketdev/**'
|
|
7
|
+
- 'setup.py'
|
|
8
|
+
- 'pyproject.toml'
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
check_version:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
|
15
|
+
with:
|
|
16
|
+
fetch-depth: 0 # Fetch all history for all branches
|
|
17
|
+
|
|
18
|
+
- name: Check version increment
|
|
19
|
+
id: version_check
|
|
20
|
+
run: |
|
|
21
|
+
# Get version from current PR
|
|
22
|
+
PR_VERSION=$(grep -o "__version__.*" socketdev/version.py | awk '{print $3}' | tr -d '"' | tr -d "'")
|
|
23
|
+
echo "PR_VERSION=$PR_VERSION" >> $GITHUB_ENV
|
|
24
|
+
|
|
25
|
+
# Get version from main branch
|
|
26
|
+
git checkout origin/main
|
|
27
|
+
MAIN_VERSION=$(grep -o "__version__.*" socketdev/version.py | awk '{print $3}' | tr -d '"' | tr -d "'")
|
|
28
|
+
echo "MAIN_VERSION=$MAIN_VERSION" >> $GITHUB_ENV
|
|
29
|
+
|
|
30
|
+
# Compare versions using Python
|
|
31
|
+
python3 -c "
|
|
32
|
+
from packaging import version
|
|
33
|
+
pr_ver = version.parse('${PR_VERSION}')
|
|
34
|
+
main_ver = version.parse('${MAIN_VERSION}')
|
|
35
|
+
if pr_ver <= main_ver:
|
|
36
|
+
print(f'❌ Version must be incremented! Main: {main_ver}, PR: {pr_ver}')
|
|
37
|
+
exit(1)
|
|
38
|
+
print(f'✅ Version properly incremented from {main_ver} to {pr_ver}')
|
|
39
|
+
"
|
|
40
|
+
|
|
41
|
+
- name: Manage PR Comment
|
|
42
|
+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
|
|
43
|
+
if: always()
|
|
44
|
+
env:
|
|
45
|
+
MAIN_VERSION: ${{ env.MAIN_VERSION }}
|
|
46
|
+
PR_VERSION: ${{ env.PR_VERSION }}
|
|
47
|
+
CHECK_RESULT: ${{ steps.version_check.outcome }}
|
|
48
|
+
with:
|
|
49
|
+
script: |
|
|
50
|
+
const success = process.env.CHECK_RESULT === 'success';
|
|
51
|
+
const prNumber = context.payload.pull_request.number;
|
|
52
|
+
const owner = context.repo.owner;
|
|
53
|
+
const repo = context.repo.repo;
|
|
54
|
+
const comments = await github.rest.issues.listComments({
|
|
55
|
+
owner: owner,
|
|
56
|
+
repo: repo,
|
|
57
|
+
issue_number: prNumber,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const versionComment = comments.data.find(comment =>
|
|
61
|
+
comment.user.type === 'Bot' &&
|
|
62
|
+
comment.body.includes('Version Check')
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
if (versionComment) {
|
|
66
|
+
if (success) {
|
|
67
|
+
// Delete the warning comment if check passes
|
|
68
|
+
await github.rest.issues.deleteComment({
|
|
69
|
+
owner: owner,
|
|
70
|
+
repo: repo,
|
|
71
|
+
comment_id: versionComment.id
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
// Update existing warning
|
|
75
|
+
await github.rest.issues.updateComment({
|
|
76
|
+
owner: owner,
|
|
77
|
+
repo: repo,
|
|
78
|
+
comment_id: versionComment.id,
|
|
79
|
+
body: `❌ **Version Check Failed**\n\nPlease increment...`
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
} else if (!success) {
|
|
83
|
+
// Create new warning comment only if check fails
|
|
84
|
+
await github.rest.issues.createComment({
|
|
85
|
+
owner: owner,
|
|
86
|
+
repo: repo,
|
|
87
|
+
issue_number: prNumber,
|
|
88
|
+
body: `❌ **Version Check Failed**\n\nPlease increment...`
|
|
89
|
+
});
|
|
90
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
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()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12.7
|
socketdev-3.0.16/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Socket Inc.
|
|
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.
|