lockdelta 0.1.0
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.
- package/LICENSE +183 -0
- package/README.md +342 -0
- package/action.yml +90 -0
- package/dist/action.js +1144 -0
- package/dist/action.js.map +1 -0
- package/dist/cli.js +972 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +922 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other transformations
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
55
|
+
improving the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
57
|
+
Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and included
|
|
61
|
+
within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those patent claims licensable
|
|
76
|
+
by such Contributor that are necessarily infringed by their
|
|
77
|
+
Contribution(s) alone or by the combination of their Contribution(s)
|
|
78
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
79
|
+
institute patent litigation against any entity (including a cross-claim
|
|
80
|
+
or counterclaim in a lawsuit) alleging that the Work or any
|
|
81
|
+
Contribution embodied within the Work constitutes direct or contributory
|
|
82
|
+
patent infringement, then any patent licenses granted to You under
|
|
83
|
+
this License for that Work shall terminate as of the date such
|
|
84
|
+
litigation is filed.
|
|
85
|
+
|
|
86
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
87
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
88
|
+
modifications, and in Source or Object form, provided that You
|
|
89
|
+
meet the following conditions:
|
|
90
|
+
|
|
91
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
92
|
+
Works a copy of this License; and
|
|
93
|
+
|
|
94
|
+
(b) You must cause any modified files to carry prominent notices
|
|
95
|
+
stating that You changed the files; and
|
|
96
|
+
|
|
97
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
98
|
+
that You distribute, all copyright, patent, trademark, and
|
|
99
|
+
attribution notices from the Source form of the Work,
|
|
100
|
+
excluding those notices that do not pertain to any part of
|
|
101
|
+
the Derivative Works; and
|
|
102
|
+
|
|
103
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
104
|
+
distribution, You must include a readable copy of the
|
|
105
|
+
attribution notices contained within such NOTICE file, in
|
|
106
|
+
at least one of the following places: within a NOTICE text file
|
|
107
|
+
distributed as part of the Derivative Works; within the Source
|
|
108
|
+
form or documentation, if provided along with the Derivative
|
|
109
|
+
Works; or, within a display generated by the Derivative Works,
|
|
110
|
+
if and wherever such third-party notices normally appear. The
|
|
111
|
+
contents of the NOTICE file are for informational purposes only
|
|
112
|
+
and do not modify the License. You may add Your own attribution
|
|
113
|
+
notices within Derivative Works that You distribute, alongside
|
|
114
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
115
|
+
that such additional attribution notices cannot be construed
|
|
116
|
+
as modifying the License.
|
|
117
|
+
|
|
118
|
+
You may add Your own license statement for Your modifications and
|
|
119
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
120
|
+
publish, distribute, sublicense, and/or sell copies of the
|
|
121
|
+
Derivative Works, as Your separate and expressed permission.
|
|
122
|
+
|
|
123
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
124
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
125
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
126
|
+
this License, without any additional terms or conditions.
|
|
127
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
128
|
+
the terms of any separate license agreement you may have executed
|
|
129
|
+
with Licensor regarding such Contributions.
|
|
130
|
+
|
|
131
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
132
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
133
|
+
except as required for reasonable and customary use in describing the
|
|
134
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
135
|
+
|
|
136
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
137
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
138
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
139
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
140
|
+
implied, including, without limitation, any warranties or conditions
|
|
141
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
142
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
143
|
+
appropriateness of using or reproducing the Work and assume any
|
|
144
|
+
risks associated with Your exercise of permissions under this License.
|
|
145
|
+
|
|
146
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
147
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
148
|
+
unless required by applicable law (such as deliberate and grossly
|
|
149
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
150
|
+
liable to You for damages, including any direct, indirect, special,
|
|
151
|
+
incidental, or exemplary damages of any character arising as a
|
|
152
|
+
result of this License or out of the use or inability to use the
|
|
153
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
154
|
+
work stoppage, computer failure or malfunction, or all other
|
|
155
|
+
commercial damages or losses), even if such Contributor has been
|
|
156
|
+
advised of the possibility of such damages.
|
|
157
|
+
|
|
158
|
+
9. Accepting Warranty or Liability. While redistributing the Work or
|
|
159
|
+
Derivative Works thereof, You may choose to offer, and charge a fee
|
|
160
|
+
for, acceptance of support, warranty, indemnity, or other liability
|
|
161
|
+
obligations and/or rights consistent with this License. However, in
|
|
162
|
+
accepting such obligations, You may offer such obligations only on
|
|
163
|
+
Your own behalf and on Your sole responsibility, not on behalf of
|
|
164
|
+
any other Contributor, and only if You agree to indemnify, defend,
|
|
165
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
166
|
+
or claims asserted against, such Contributor by reason of your
|
|
167
|
+
accepting any warranty or additional liability.
|
|
168
|
+
|
|
169
|
+
END OF TERMS AND CONDITIONS
|
|
170
|
+
|
|
171
|
+
Copyright 2026 Louis-Amaury Chaib
|
|
172
|
+
|
|
173
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
174
|
+
you may not use this file except in compliance with the License.
|
|
175
|
+
You may obtain a copy of the License at
|
|
176
|
+
|
|
177
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
178
|
+
|
|
179
|
+
Unless required by applicable law or agreed to in writing, software
|
|
180
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
181
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
182
|
+
See the License for the specific language governing permissions and
|
|
183
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# lockdelta
|
|
2
|
+
|
|
3
|
+
Diff dependency lockfiles between git refs or PRs and emit a structured report. Works as a **GitHub Action**, **CLI**, or **Node.js library**.
|
|
4
|
+
|
|
5
|
+
Supports Python, JavaScript, and Deno ecosystems — including automatic detection of tool migrations (e.g. poetry → uv). Monorepo-aware: all lockfiles in the repository are auto-discovered.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## GitHub Action
|
|
10
|
+
|
|
11
|
+
### Basic usage
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
name: Dependency review
|
|
15
|
+
on:
|
|
16
|
+
pull_request:
|
|
17
|
+
push:
|
|
18
|
+
branches: [main]
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
lockdelta:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
permissions:
|
|
24
|
+
contents: read
|
|
25
|
+
pull-requests: read
|
|
26
|
+
|
|
27
|
+
steps:
|
|
28
|
+
- name: Diff dependencies
|
|
29
|
+
id: lockdelta
|
|
30
|
+
uses: lachaib/lockdelta@v1
|
|
31
|
+
env:
|
|
32
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
33
|
+
|
|
34
|
+
- name: Use the diff
|
|
35
|
+
run: echo '${{ steps.lockdelta.outputs.diff }}'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
No inputs are required on `pull_request` or `push` events. The action reads the relevant SHAs from the GitHub event payload automatically and fetches everything through the GitHub API — no `actions/checkout` needed.
|
|
39
|
+
|
|
40
|
+
| Event | What is compared |
|
|
41
|
+
|-------|-----------------|
|
|
42
|
+
| `pull_request` | PR base commit → head commit |
|
|
43
|
+
| `push` | SHA before the push → SHA after the push |
|
|
44
|
+
|
|
45
|
+
`GITHUB_TOKEN` is provided automatically by GitHub Actions — no extra secrets needed.
|
|
46
|
+
|
|
47
|
+
> **First push to a branch**: when `before` is the null SHA (no previous commit on the branch), the action skips rather than erroring.
|
|
48
|
+
|
|
49
|
+
### Inputs
|
|
50
|
+
|
|
51
|
+
| Input | Description | Default |
|
|
52
|
+
|-------|-------------|---------|
|
|
53
|
+
| `pr-number` | GitHub PR number. Auto-detected from the event payload on `pull_request` events — usually not needed. | Auto |
|
|
54
|
+
| `base-ref` | Base git ref (branch, tag, SHA). Reads `GITHUB_BASE_REF` in CI. | `HEAD~1` |
|
|
55
|
+
| `head-ref` | Head git ref. Reads `GITHUB_HEAD_REF` in CI. | `HEAD` |
|
|
56
|
+
| `repo` | GitHub repo in `OWNER/NAME` format. Auto-detected from `GITHUB_REPOSITORY`. | Auto |
|
|
57
|
+
| `lockfile` | Specific lockfile path. Auto-discovers all if omitted. | — |
|
|
58
|
+
| `type` | Force lockfile type: `uv`, `poetry`, `pdm`, etc. Used with `lockfile`. | — |
|
|
59
|
+
| `filters` | YAML map of named package groups → boolean outputs (see [Filters](#filters)). | — |
|
|
60
|
+
| `markdown` | Set to `'true'` to generate a markdown summary output. | `false` |
|
|
61
|
+
| `json-to-file` | File path to write the JSON report to. | — |
|
|
62
|
+
| `markdown-to-file` | File path to write the markdown summary to. Requires `markdown: 'true'`. | — |
|
|
63
|
+
| `post-comment` | `'true'` always posts/updates a comment. `'if-changed'` posts only when at least one dependency changed. `'false'` never posts. Requires `pull-requests: write`. | `false` |
|
|
64
|
+
|
|
65
|
+
### Outputs
|
|
66
|
+
|
|
67
|
+
| Output | Description |
|
|
68
|
+
|--------|-------------|
|
|
69
|
+
| `diff` | Full JSON diff report (see [Output schema](#output-schema)) |
|
|
70
|
+
| `markdown` | Markdown summary (Added / Changed / Removed). Set when `markdown: 'true'`. |
|
|
71
|
+
| `<group>` | One boolean output per group defined in `filters`. |
|
|
72
|
+
|
|
73
|
+
### Markdown summary
|
|
74
|
+
|
|
75
|
+
When `markdown: 'true'` or `post-comment` is not `'false'`, lockdelta generates a three-section markdown summary. Direct production dependencies are **bold**, dev dependencies are *italic*, and transitive deps are plain. Package names link to their registry (PyPI, npmjs, jsr.io).
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
- name: Diff dependencies
|
|
79
|
+
id: lockdelta
|
|
80
|
+
uses: lachaib/lockdelta@v1
|
|
81
|
+
env:
|
|
82
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
83
|
+
with:
|
|
84
|
+
markdown: 'true'
|
|
85
|
+
post-comment: 'if-changed'
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
(`pull-requests: write` permission required on the job for `post-comment`.)
|
|
89
|
+
|
|
90
|
+
Example output:
|
|
91
|
+
|
|
92
|
+
```markdown
|
|
93
|
+
### Changed
|
|
94
|
+
|
|
95
|
+
- **[requests](https://pypi.org/project/requests/)**: `2.31.0` → `2.32.3`
|
|
96
|
+
- *[pytest](https://pypi.org/project/pytest/)*: `8.0.0` → `8.1.0`
|
|
97
|
+
- [certifi](https://pypi.org/project/certifi/): `2024.2.2` → `2024.7.4`
|
|
98
|
+
|
|
99
|
+
### Added
|
|
100
|
+
|
|
101
|
+
- **[httpx](https://pypi.org/project/httpx/)**: `0.27.0`
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Filters
|
|
105
|
+
|
|
106
|
+
Inspired by [dorny/paths-filter](https://github.com/dorny/paths-filter), the `filters` input lets you name groups of packages. Each group produces a boolean output you can use to gate subsequent steps.
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
- name: Diff dependencies
|
|
110
|
+
id: lockdelta
|
|
111
|
+
uses: lachaib/lockdelta@v1
|
|
112
|
+
env:
|
|
113
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
114
|
+
with:
|
|
115
|
+
filters: |
|
|
116
|
+
auth:
|
|
117
|
+
- pyjwt
|
|
118
|
+
- cryptography
|
|
119
|
+
- authlib
|
|
120
|
+
http-client:
|
|
121
|
+
- httpx
|
|
122
|
+
- requests
|
|
123
|
+
- urllib3
|
|
124
|
+
|
|
125
|
+
- name: Run auth tests
|
|
126
|
+
if: steps.lockdelta.outputs.auth == 'true'
|
|
127
|
+
run: pytest tests/auth/
|
|
128
|
+
|
|
129
|
+
- name: Run integration tests
|
|
130
|
+
if: steps.lockdelta.outputs.http-client == 'true'
|
|
131
|
+
run: pytest tests/integration/
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Full example: review gate with PR comment
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
name: Dependency review
|
|
138
|
+
on:
|
|
139
|
+
pull_request:
|
|
140
|
+
|
|
141
|
+
jobs:
|
|
142
|
+
review:
|
|
143
|
+
runs-on: ubuntu-latest
|
|
144
|
+
permissions:
|
|
145
|
+
contents: read
|
|
146
|
+
pull-requests: write
|
|
147
|
+
|
|
148
|
+
steps:
|
|
149
|
+
- name: Diff dependencies
|
|
150
|
+
id: lockdelta
|
|
151
|
+
uses: lachaib/lockdelta@v1
|
|
152
|
+
env:
|
|
153
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
154
|
+
with:
|
|
155
|
+
markdown: 'true'
|
|
156
|
+
post-comment: 'if-changed'
|
|
157
|
+
filters: |
|
|
158
|
+
security:
|
|
159
|
+
- pyjwt
|
|
160
|
+
- cryptography
|
|
161
|
+
- certifi
|
|
162
|
+
|
|
163
|
+
- name: Block on security package changes
|
|
164
|
+
if: steps.lockdelta.outputs.security == 'true'
|
|
165
|
+
run: |
|
|
166
|
+
echo "Security-sensitive packages changed — manual review required."
|
|
167
|
+
exit 1
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## CLI
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npx lockdelta [options]
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
> **Note:** `GITHUB_TOKEN` must be set in the environment when using `--pr`.
|
|
179
|
+
|
|
180
|
+
### Options
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
--base <ref> Base git ref (default: HEAD~1, or GITHUB_BASE_REF)
|
|
184
|
+
--head <ref> Head git ref (default: HEAD, or GITHUB_HEAD_REF)
|
|
185
|
+
--pr <number> GitHub PR number (uses GitHub API for exact SHAs)
|
|
186
|
+
--repo <owner/name> GitHub repository (auto-detected from GITHUB_REPOSITORY or git remote)
|
|
187
|
+
--lockfile <path> Compare a specific lockfile only
|
|
188
|
+
--type <type> Force lockfile type: uv, poetry, pdm, npm, yarn, pnpm, bun, deno
|
|
189
|
+
--old <path> Old lockfile path (local file comparison mode)
|
|
190
|
+
--new <path> New lockfile path (local file comparison mode)
|
|
191
|
+
--output <path> Write JSON to file instead of stdout
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Examples
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Compare against previous commit (git repo)
|
|
198
|
+
lockdelta
|
|
199
|
+
|
|
200
|
+
# Compare two specific refs
|
|
201
|
+
lockdelta --base main --head my-feature-branch
|
|
202
|
+
|
|
203
|
+
# Compare a GitHub PR by number
|
|
204
|
+
GITHUB_TOKEN=ghp_... lockdelta --pr 123 --repo owner/myrepo
|
|
205
|
+
|
|
206
|
+
# Compare two local lockfiles directly
|
|
207
|
+
lockdelta --old old/uv.lock --new new/uv.lock
|
|
208
|
+
|
|
209
|
+
# Filter to direct dependencies only
|
|
210
|
+
lockdelta --pr 123 | jq '.lockfiles[].changes[] | select(.is_direct)'
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Library
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
import { run } from 'lockdelta';
|
|
219
|
+
|
|
220
|
+
// Compare a PR (requires GITHUB_TOKEN in environment)
|
|
221
|
+
const report = await run({ prNumber: '123', repo: 'owner/myrepo' });
|
|
222
|
+
|
|
223
|
+
// Compare git refs
|
|
224
|
+
const report = await run({ base: 'main', head: 'my-branch' });
|
|
225
|
+
|
|
226
|
+
// Compare local files
|
|
227
|
+
const report = await run({ oldFile: './old.lock', newFile: './new.lock' });
|
|
228
|
+
|
|
229
|
+
console.log(report.summary);
|
|
230
|
+
// { added: 1, removed: 0, updated: 3, total_changes: 4, ecosystems: ['python'] }
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Extending with custom ecosystems
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
import { registerEcosystem } from 'lockdelta';
|
|
237
|
+
import type { Ecosystem, DirectDeps } from 'lockdelta';
|
|
238
|
+
|
|
239
|
+
const rubyEcosystem: Ecosystem = {
|
|
240
|
+
name: 'ruby',
|
|
241
|
+
supportedLockfiles: [{ filename: 'Gemfile.lock', type: 'bundler' }],
|
|
242
|
+
manifestName: 'Gemfile',
|
|
243
|
+
getLockfileType: (filename) => filename === 'Gemfile.lock' ? 'bundler' : undefined,
|
|
244
|
+
parseLockfile: (content, _type) => { /* parse and return { name: version } */ return {}; },
|
|
245
|
+
parseDirectDeps: (content): DirectDeps => ({ prod: new Set(), dev: new Set() }),
|
|
246
|
+
normalizeName: (name) => name.toLowerCase(),
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
registerEcosystem(rubyEcosystem);
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Output schema
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
interface PackageChange {
|
|
258
|
+
name: string;
|
|
259
|
+
change_type: 'added' | 'removed' | 'updated';
|
|
260
|
+
old_version: string | null;
|
|
261
|
+
new_version: string | null;
|
|
262
|
+
is_direct: boolean; // declared in the project manifest
|
|
263
|
+
is_dev: boolean; // declared in a dev/optional dependency section
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
interface DiffReport {
|
|
267
|
+
schema_version: '1';
|
|
268
|
+
generated_at: string; // ISO 8601
|
|
269
|
+
base_ref: string;
|
|
270
|
+
head_ref: string;
|
|
271
|
+
summary: {
|
|
272
|
+
added: number;
|
|
273
|
+
removed: number;
|
|
274
|
+
updated: number;
|
|
275
|
+
total_changes: number;
|
|
276
|
+
ecosystems: string[]; // e.g. ['python', 'javascript']
|
|
277
|
+
};
|
|
278
|
+
lockfiles: Array<{
|
|
279
|
+
path: string | null;
|
|
280
|
+
workspace: string; // '.' for root, 'packages/backend' for monorepos
|
|
281
|
+
type: string | null; // e.g. 'uv' | 'poetry' | 'npm' | 'yarn'
|
|
282
|
+
ecosystem: string; // e.g. 'python' | 'javascript' | 'deno'
|
|
283
|
+
summary: { added: number; removed: number; updated: number; total_changes: number };
|
|
284
|
+
changes: PackageChange[];
|
|
285
|
+
migration: { // non-null when the lockfile tool changed between refs
|
|
286
|
+
note: string;
|
|
287
|
+
base_lockfile: string | null;
|
|
288
|
+
base_lockfile_type: string | null;
|
|
289
|
+
head_lockfile: string | null;
|
|
290
|
+
head_lockfile_type: string | null;
|
|
291
|
+
} | null;
|
|
292
|
+
}>;
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Supported ecosystems
|
|
299
|
+
|
|
300
|
+
### Python
|
|
301
|
+
|
|
302
|
+
| Lockfile | Tool | Notes |
|
|
303
|
+
|----------|------|-------|
|
|
304
|
+
| `uv.lock` | [uv](https://github.com/astral-sh/uv) | |
|
|
305
|
+
| `poetry.lock` | [Poetry](https://python-poetry.org) | |
|
|
306
|
+
| `pdm.lock` | [PDM](https://pdm-project.org) | |
|
|
307
|
+
| `pylock.toml` | pip / any ([PEP 751](https://peps.python.org/pep-0751/)) | standard format |
|
|
308
|
+
|
|
309
|
+
Manifest: `pyproject.toml`. Direct deps are read from `[project].dependencies` (prod) and `[project.optional-dependencies]`, `[tool.poetry.group.*]`, `[tool.uv.dev-dependencies]`, `[dependency-groups]` (dev).
|
|
310
|
+
|
|
311
|
+
### JavaScript
|
|
312
|
+
|
|
313
|
+
| Lockfile | Tool | Notes |
|
|
314
|
+
|----------|------|-------|
|
|
315
|
+
| `package-lock.json` | [npm](https://www.npmjs.com) | v1, v2, v3 |
|
|
316
|
+
| `yarn.lock` | [Yarn](https://yarnpkg.com) | Classic (v1) and Berry (v2+) |
|
|
317
|
+
| `pnpm-lock.yaml` | [pnpm](https://pnpm.io) | v5, v6, v9 |
|
|
318
|
+
| `bun.lock` | [Bun](https://bun.sh) | v1.2+ |
|
|
319
|
+
|
|
320
|
+
Manifest: `package.json`. `dependencies`, `optionalDependencies`, `peerDependencies` → prod. `devDependencies` → dev.
|
|
321
|
+
|
|
322
|
+
### Deno
|
|
323
|
+
|
|
324
|
+
| Lockfile | Tool |
|
|
325
|
+
|----------|------|
|
|
326
|
+
| `deno.lock` | [Deno](https://deno.land) |
|
|
327
|
+
|
|
328
|
+
Manifest: `deno.json`. Both npm and JSR packages are tracked (JSR packages are prefixed with `jsr:` to avoid name collisions).
|
|
329
|
+
|
|
330
|
+
Migrations between lockfile formats within the same ecosystem are detected automatically (e.g. poetry → uv).
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Contributing
|
|
335
|
+
|
|
336
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, how to add a new ecosystem, and contribution guidelines.
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## License
|
|
341
|
+
|
|
342
|
+
Apache 2.0 — Copyright 2026 Louis-Amaury Chaib. See [LICENSE](LICENSE).
|
package/action.yml
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
name: 'lockdelta'
|
|
2
|
+
description: 'Diff dependency lockfiles between git refs or PRs and emit a structured JSON report'
|
|
3
|
+
author: 'lachaib'
|
|
4
|
+
|
|
5
|
+
branding:
|
|
6
|
+
icon: 'git-pull-request'
|
|
7
|
+
color: 'blue'
|
|
8
|
+
|
|
9
|
+
inputs:
|
|
10
|
+
base-ref:
|
|
11
|
+
description: >
|
|
12
|
+
Base git ref (branch, tag, or SHA). Auto-detected from GITHUB_BASE_REF in CI.
|
|
13
|
+
In git mode (no pr-number), defaults to HEAD~1.
|
|
14
|
+
required: false
|
|
15
|
+
head-ref:
|
|
16
|
+
description: >
|
|
17
|
+
Head git ref. Auto-detected from GITHUB_HEAD_REF in CI.
|
|
18
|
+
In git mode, defaults to HEAD.
|
|
19
|
+
required: false
|
|
20
|
+
pr-number:
|
|
21
|
+
description: >
|
|
22
|
+
GitHub PR number. Uses the PR's exact base and head commit SHAs via the gh CLI,
|
|
23
|
+
which avoids branch timing issues. Set to ${{ github.event.pull_request.number }}.
|
|
24
|
+
required: false
|
|
25
|
+
repo:
|
|
26
|
+
description: >
|
|
27
|
+
GitHub repository in OWNER/NAME format.
|
|
28
|
+
Auto-detected from GITHUB_REPOSITORY if omitted.
|
|
29
|
+
required: false
|
|
30
|
+
lockfile:
|
|
31
|
+
description: >
|
|
32
|
+
Specific lockfile path to compare. When omitted, all lockfiles in the
|
|
33
|
+
repository are auto-discovered (monorepo-aware).
|
|
34
|
+
required: false
|
|
35
|
+
type:
|
|
36
|
+
description: >
|
|
37
|
+
Force lockfile type: uv, poetry, pdm. Only used together with the lockfile input.
|
|
38
|
+
required: false
|
|
39
|
+
filters:
|
|
40
|
+
description: >
|
|
41
|
+
YAML map of named package groups. Each group produces a boolean output named after
|
|
42
|
+
the group, set to 'true' if any package in the group changed. Inspired by
|
|
43
|
+
dorny/paths-filter. Example:
|
|
44
|
+
auth:
|
|
45
|
+
- pyjwt
|
|
46
|
+
- cryptography
|
|
47
|
+
http-client:
|
|
48
|
+
- httpx
|
|
49
|
+
- requests
|
|
50
|
+
required: false
|
|
51
|
+
markdown:
|
|
52
|
+
description: >
|
|
53
|
+
Set to 'true' to generate a markdown summary of changes. The summary has three
|
|
54
|
+
sections (Added, Changed, Removed). Direct prod dependencies are **bold**,
|
|
55
|
+
dev dependencies are *italic*, transitive deps are plain.
|
|
56
|
+
required: false
|
|
57
|
+
default: 'false'
|
|
58
|
+
json-to-file:
|
|
59
|
+
description: >
|
|
60
|
+
File path to write the JSON diff report to. When set, the full report is also
|
|
61
|
+
written to this path in addition to being emitted as the `diff` output.
|
|
62
|
+
required: false
|
|
63
|
+
markdown-to-file:
|
|
64
|
+
description: >
|
|
65
|
+
File path to write the markdown summary to. Requires markdown: 'true'.
|
|
66
|
+
required: false
|
|
67
|
+
post-comment:
|
|
68
|
+
description: >
|
|
69
|
+
Controls PR comment posting. 'true' always posts or updates a comment.
|
|
70
|
+
'if-changed' posts only when at least one dependency changed (silent skip
|
|
71
|
+
when nothing changed). 'false' never posts. Uses the GitHub REST API;
|
|
72
|
+
updates an existing lockdelta comment on re-runs. PR number is auto-detected
|
|
73
|
+
from the event payload on pull_request events. The markdown summary is
|
|
74
|
+
generated even if markdown: 'false'.
|
|
75
|
+
required: false
|
|
76
|
+
default: 'false'
|
|
77
|
+
|
|
78
|
+
outputs:
|
|
79
|
+
diff:
|
|
80
|
+
description: >
|
|
81
|
+
JSON diff report. Schema matches DiffReport in the TypeScript types.
|
|
82
|
+
Contains schema_version, generated_at, base_ref, head_ref, summary, and lockfiles[].
|
|
83
|
+
markdown:
|
|
84
|
+
description: >
|
|
85
|
+
Markdown summary of dependency changes (Added/Changed/Removed sections).
|
|
86
|
+
Only set when the markdown input is 'true'.
|
|
87
|
+
|
|
88
|
+
runs:
|
|
89
|
+
using: 'node24'
|
|
90
|
+
main: 'dist/action.js'
|