@dependabit/action 0.1.1
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/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +225 -0
- package/action.yml +85 -0
- package/dist/actions/check.d.ts +33 -0
- package/dist/actions/check.d.ts.map +1 -0
- package/dist/actions/check.js +162 -0
- package/dist/actions/check.js.map +1 -0
- package/dist/actions/generate.d.ts +9 -0
- package/dist/actions/generate.d.ts.map +1 -0
- package/dist/actions/generate.js +152 -0
- package/dist/actions/generate.js.map +1 -0
- package/dist/actions/update.d.ts +9 -0
- package/dist/actions/update.d.ts.map +1 -0
- package/dist/actions/update.js +246 -0
- package/dist/actions/update.js.map +1 -0
- package/dist/actions/validate.d.ts +33 -0
- package/dist/actions/validate.d.ts.map +1 -0
- package/dist/actions/validate.js +226 -0
- package/dist/actions/validate.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +114 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +154 -0
- package/dist/logger.js.map +1 -0
- package/dist/utils/agent-config.d.ts +31 -0
- package/dist/utils/agent-config.d.ts.map +1 -0
- package/dist/utils/agent-config.js +42 -0
- package/dist/utils/agent-config.js.map +1 -0
- package/dist/utils/agent-router.d.ts +33 -0
- package/dist/utils/agent-router.d.ts.map +1 -0
- package/dist/utils/agent-router.js +57 -0
- package/dist/utils/agent-router.js.map +1 -0
- package/dist/utils/errors.d.ts +51 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +219 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/inputs.d.ts +35 -0
- package/dist/utils/inputs.d.ts.map +1 -0
- package/dist/utils/inputs.js +47 -0
- package/dist/utils/inputs.js.map +1 -0
- package/dist/utils/metrics.d.ts +66 -0
- package/dist/utils/metrics.d.ts.map +1 -0
- package/dist/utils/metrics.js +116 -0
- package/dist/utils/metrics.js.map +1 -0
- package/dist/utils/outputs.d.ts +43 -0
- package/dist/utils/outputs.d.ts.map +1 -0
- package/dist/utils/outputs.js +146 -0
- package/dist/utils/outputs.js.map +1 -0
- package/dist/utils/performance.d.ts +100 -0
- package/dist/utils/performance.d.ts.map +1 -0
- package/dist/utils/performance.js +185 -0
- package/dist/utils/performance.js.map +1 -0
- package/dist/utils/reporter.d.ts +43 -0
- package/dist/utils/reporter.d.ts.map +1 -0
- package/dist/utils/reporter.js +122 -0
- package/dist/utils/reporter.js.map +1 -0
- package/dist/utils/secrets.d.ts +45 -0
- package/dist/utils/secrets.d.ts.map +1 -0
- package/dist/utils/secrets.js +94 -0
- package/dist/utils/secrets.js.map +1 -0
- package/package.json +45 -0
- package/src/actions/check.ts +223 -0
- package/src/actions/generate.ts +181 -0
- package/src/actions/update.ts +284 -0
- package/src/actions/validate.ts +292 -0
- package/src/index.ts +43 -0
- package/src/logger.test.ts +200 -0
- package/src/logger.ts +210 -0
- package/src/utils/agent-config.ts +61 -0
- package/src/utils/agent-router.ts +67 -0
- package/src/utils/errors.ts +251 -0
- package/src/utils/inputs.ts +75 -0
- package/src/utils/metrics.ts +169 -0
- package/src/utils/outputs.ts +202 -0
- package/src/utils/performance.ts +248 -0
- package/src/utils/reporter.ts +169 -0
- package/src/utils/secrets.ts +124 -0
- package/test/actions/check.test.ts +216 -0
- package/test/actions/generate.test.ts +82 -0
- package/test/actions/update.test.ts +70 -0
- package/test/actions/validate.test.ts +257 -0
- package/test/utils/agent-config.test.ts +112 -0
- package/test/utils/agent-router.test.ts +129 -0
- package/test/utils/metrics.test.ts +221 -0
- package/test/utils/reporter.test.ts +196 -0
- package/test/utils/secrets.test.ts +217 -0
- package/tsconfig.json +15 -0
- package/tsconfig.tsbuildinfo +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @dependabit/action
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Publish release setup updates and action metadata.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @dependabit/detector@0.1.1
|
|
10
|
+
- @dependabit/github-client@0.1.1
|
|
11
|
+
- @dependabit/manifest@0.1.1
|
|
12
|
+
- @dependabit/monitor@0.1.1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Pradeep Mouli
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# @dependabit/action
|
|
2
|
+
|
|
3
|
+
GitHub Action entry points for AI-powered dependency tracking.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides the main entry points for the dependabit GitHub Actions, orchestrating all other packages to provide a complete dependency tracking solution using LLM-powered detection.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Generate action**: Create initial manifest from codebase analysis
|
|
12
|
+
- **Update action**: Automatically update manifest on push
|
|
13
|
+
- **Check action**: Monitor dependencies for changes and create issues
|
|
14
|
+
- **Validate action**: Validate manifest files and configuration
|
|
15
|
+
- **Authentication**: Multiple auth methods (token, OAuth, basic)
|
|
16
|
+
- **Secret Management**: Secure resolution from GitHub Secrets
|
|
17
|
+
- **Performance Tracking**: Operation duration metrics and API quota monitoring
|
|
18
|
+
- **Error Handling**: Categorized errors with remediation steps
|
|
19
|
+
- **Manifest Size Checks**: Automatic warnings for large manifests
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
This package is distributed as part of the dependabit GitHub Action. See the main repository README for usage instructions.
|
|
24
|
+
|
|
25
|
+
## Actions
|
|
26
|
+
|
|
27
|
+
### Generate
|
|
28
|
+
|
|
29
|
+
Analyzes repository using LLM and generates `.dependabit/manifest.json` with detected dependencies.
|
|
30
|
+
|
|
31
|
+
**Inputs:**
|
|
32
|
+
- `github-token`: GitHub token for API access (required)
|
|
33
|
+
- `llm-provider`: LLM provider (default: copilot)
|
|
34
|
+
- `config-path`: Path to config file (default: .dependabit/config.yml)
|
|
35
|
+
|
|
36
|
+
**Outputs:**
|
|
37
|
+
- `manifest-path`: Path to generated manifest
|
|
38
|
+
- `dependencies-count`: Number of dependencies detected
|
|
39
|
+
|
|
40
|
+
**Example:**
|
|
41
|
+
```yaml
|
|
42
|
+
- uses: ./.github/actions/dependabit
|
|
43
|
+
with:
|
|
44
|
+
action: generate
|
|
45
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Update
|
|
49
|
+
|
|
50
|
+
Automatically updates manifest when code changes are pushed.
|
|
51
|
+
|
|
52
|
+
**Triggers:**
|
|
53
|
+
- Push to main/master branch
|
|
54
|
+
- Pull request changes
|
|
55
|
+
- Manual workflow dispatch
|
|
56
|
+
|
|
57
|
+
**Example:**
|
|
58
|
+
```yaml
|
|
59
|
+
on:
|
|
60
|
+
push:
|
|
61
|
+
branches: [main]
|
|
62
|
+
|
|
63
|
+
jobs:
|
|
64
|
+
update-dependencies:
|
|
65
|
+
runs-on: ubuntu-latest
|
|
66
|
+
steps:
|
|
67
|
+
- uses: actions/checkout@v4
|
|
68
|
+
- uses: ./.github/actions/dependabit
|
|
69
|
+
with:
|
|
70
|
+
action: update
|
|
71
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Check
|
|
75
|
+
|
|
76
|
+
Periodically checks dependencies for changes and creates issues for updates.
|
|
77
|
+
|
|
78
|
+
**Schedule:** Configurable in `.dependabit/config.yml` (default: daily)
|
|
79
|
+
|
|
80
|
+
**Features:**
|
|
81
|
+
- Release monitoring
|
|
82
|
+
- Breaking change detection
|
|
83
|
+
- Automatic issue creation
|
|
84
|
+
- False positive tracking
|
|
85
|
+
|
|
86
|
+
**Example:**
|
|
87
|
+
```yaml
|
|
88
|
+
on:
|
|
89
|
+
schedule:
|
|
90
|
+
- cron: '0 0 * * *' # Daily at midnight
|
|
91
|
+
|
|
92
|
+
jobs:
|
|
93
|
+
check-dependencies:
|
|
94
|
+
runs-on: ubuntu-latest
|
|
95
|
+
steps:
|
|
96
|
+
- uses: actions/checkout@v4
|
|
97
|
+
- uses: ./.github/actions/dependabit
|
|
98
|
+
with:
|
|
99
|
+
action: check
|
|
100
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Validate
|
|
104
|
+
|
|
105
|
+
Validates manifest file structure and content.
|
|
106
|
+
|
|
107
|
+
**Checks:**
|
|
108
|
+
- Schema validation
|
|
109
|
+
- Size limits
|
|
110
|
+
- Required fields
|
|
111
|
+
- Configuration syntax
|
|
112
|
+
|
|
113
|
+
**Example:**
|
|
114
|
+
```yaml
|
|
115
|
+
- uses: ./.github/actions/dependabit
|
|
116
|
+
with:
|
|
117
|
+
action: validate
|
|
118
|
+
manifest-path: .dependabit/manifest.json
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Authentication
|
|
122
|
+
|
|
123
|
+
Supports multiple authentication methods:
|
|
124
|
+
|
|
125
|
+
### Token Authentication (Recommended)
|
|
126
|
+
```yaml
|
|
127
|
+
- uses: ./.github/actions/dependabit
|
|
128
|
+
with:
|
|
129
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Per-Dependency Authentication
|
|
133
|
+
Configure in `.dependabit/config.yml`:
|
|
134
|
+
```yaml
|
|
135
|
+
auth:
|
|
136
|
+
registry.npmjs.org:
|
|
137
|
+
secret: NPM_TOKEN
|
|
138
|
+
api.example.com:
|
|
139
|
+
secret: API_KEY
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Configuration
|
|
143
|
+
|
|
144
|
+
Create `.dependabit/config.yml`:
|
|
145
|
+
|
|
146
|
+
```yaml
|
|
147
|
+
version: "1.0"
|
|
148
|
+
schedule: "0 0 * * *" # Daily checks
|
|
149
|
+
llm:
|
|
150
|
+
provider: copilot
|
|
151
|
+
model: gpt-4
|
|
152
|
+
monitor:
|
|
153
|
+
check_interval: 24h
|
|
154
|
+
severity_threshold: minor
|
|
155
|
+
issues:
|
|
156
|
+
labels:
|
|
157
|
+
- dependency-update
|
|
158
|
+
- bot
|
|
159
|
+
assignees:
|
|
160
|
+
- maintainer-username
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Performance Metrics
|
|
164
|
+
|
|
165
|
+
The action tracks performance metrics:
|
|
166
|
+
|
|
167
|
+
- Operation durations
|
|
168
|
+
- API quota usage
|
|
169
|
+
- Rate limit status
|
|
170
|
+
- Error rates
|
|
171
|
+
|
|
172
|
+
View metrics in action logs or enable detailed reporting:
|
|
173
|
+
|
|
174
|
+
```yaml
|
|
175
|
+
- uses: ./.github/actions/dependabit
|
|
176
|
+
with:
|
|
177
|
+
action: check
|
|
178
|
+
enable-metrics: true
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Error Handling
|
|
182
|
+
|
|
183
|
+
Errors are categorized with remediation steps:
|
|
184
|
+
|
|
185
|
+
- **Authentication**: Token validation, permissions
|
|
186
|
+
- **Rate Limit**: API quota management
|
|
187
|
+
- **Network**: Connectivity issues
|
|
188
|
+
- **Validation**: Data format errors
|
|
189
|
+
- **Configuration**: Setup problems
|
|
190
|
+
|
|
191
|
+
## Manifest Size Management
|
|
192
|
+
|
|
193
|
+
Automatic warnings for large manifests:
|
|
194
|
+
|
|
195
|
+
- **Warning**: >1MB
|
|
196
|
+
- **Error**: >10MB
|
|
197
|
+
|
|
198
|
+
Recommendations provided for size reduction.
|
|
199
|
+
|
|
200
|
+
## Development
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Install dependencies
|
|
204
|
+
pnpm install
|
|
205
|
+
|
|
206
|
+
# Build
|
|
207
|
+
pnpm build
|
|
208
|
+
|
|
209
|
+
# Run tests
|
|
210
|
+
pnpm test
|
|
211
|
+
|
|
212
|
+
# Type check
|
|
213
|
+
pnpm type-check
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Related Packages
|
|
217
|
+
|
|
218
|
+
- `@dependabit/detector`: LLM-based dependency detection
|
|
219
|
+
- `@dependabit/manifest`: Manifest schema and operations
|
|
220
|
+
- `@dependabit/monitor`: Change detection and monitoring
|
|
221
|
+
- `@dependabit/github-client`: GitHub API interactions
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT
|
package/action.yml
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
name: 'Dependabit - AI-Powered Dependency Tracker'
|
|
2
|
+
description: 'Automatically track and monitor external informational dependencies using LLM analysis'
|
|
3
|
+
author: 'Pradeep Mouli'
|
|
4
|
+
|
|
5
|
+
branding:
|
|
6
|
+
icon: 'search'
|
|
7
|
+
color: 'blue'
|
|
8
|
+
|
|
9
|
+
inputs:
|
|
10
|
+
action:
|
|
11
|
+
description: 'Action to perform: generate, update, check, or validate'
|
|
12
|
+
required: true
|
|
13
|
+
default: 'generate'
|
|
14
|
+
|
|
15
|
+
repo_path:
|
|
16
|
+
description: 'Path to repository root'
|
|
17
|
+
required: false
|
|
18
|
+
default: '.'
|
|
19
|
+
|
|
20
|
+
manifest_path:
|
|
21
|
+
description: 'Path to manifest file (relative to repo_path)'
|
|
22
|
+
required: false
|
|
23
|
+
default: '.dependabit/manifest.json'
|
|
24
|
+
|
|
25
|
+
config_path:
|
|
26
|
+
description: 'Path to config file (relative to repo_path)'
|
|
27
|
+
required: false
|
|
28
|
+
default: ''
|
|
29
|
+
|
|
30
|
+
llm_provider:
|
|
31
|
+
description: 'LLM provider: github-copilot, claude, openai'
|
|
32
|
+
required: false
|
|
33
|
+
default: 'github-copilot'
|
|
34
|
+
|
|
35
|
+
llm_model:
|
|
36
|
+
description: 'LLM model to use (optional)'
|
|
37
|
+
required: false
|
|
38
|
+
|
|
39
|
+
llm_api_key:
|
|
40
|
+
description: 'API key for LLM provider (uses GITHUB_TOKEN if not provided)'
|
|
41
|
+
required: false
|
|
42
|
+
|
|
43
|
+
create_issues:
|
|
44
|
+
description: 'Create GitHub issues for detected changes (check action)'
|
|
45
|
+
required: false
|
|
46
|
+
default: 'true'
|
|
47
|
+
|
|
48
|
+
issue_labels:
|
|
49
|
+
description: 'Labels to add to created issues (comma-separated)'
|
|
50
|
+
required: false
|
|
51
|
+
default: 'dependabit,dependency-update'
|
|
52
|
+
|
|
53
|
+
debug:
|
|
54
|
+
description: 'Enable debug logging'
|
|
55
|
+
required: false
|
|
56
|
+
default: 'false'
|
|
57
|
+
|
|
58
|
+
outputs:
|
|
59
|
+
manifest_path:
|
|
60
|
+
description: 'Path to the generated/updated manifest file'
|
|
61
|
+
|
|
62
|
+
dependency_count:
|
|
63
|
+
description: 'Number of dependencies detected'
|
|
64
|
+
|
|
65
|
+
files_scanned:
|
|
66
|
+
description: 'Number of files scanned'
|
|
67
|
+
|
|
68
|
+
llm_calls:
|
|
69
|
+
description: 'Number of LLM API calls made'
|
|
70
|
+
|
|
71
|
+
total_tokens:
|
|
72
|
+
description: 'Total tokens used in LLM calls'
|
|
73
|
+
|
|
74
|
+
average_confidence:
|
|
75
|
+
description: 'Average confidence score of detected dependencies'
|
|
76
|
+
|
|
77
|
+
changes_detected:
|
|
78
|
+
description: 'Number of dependency changes detected (check action)'
|
|
79
|
+
|
|
80
|
+
issues_created:
|
|
81
|
+
description: 'Number of GitHub issues created (check action)'
|
|
82
|
+
|
|
83
|
+
runs:
|
|
84
|
+
using: 'node20'
|
|
85
|
+
main: 'action-dist/index.js'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check Action
|
|
3
|
+
* Monitors dependencies for changes and creates issues when updates are detected
|
|
4
|
+
*/
|
|
5
|
+
import type { DependencyConfig } from '@dependabit/monitor';
|
|
6
|
+
import type { DependencyChange } from '../utils/reporter.js';
|
|
7
|
+
export interface Manifest {
|
|
8
|
+
version: string;
|
|
9
|
+
dependencies: Array<DependencyConfig & {
|
|
10
|
+
name?: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
lastChanged?: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export interface CheckActionResult {
|
|
16
|
+
checked: number;
|
|
17
|
+
skipped: number;
|
|
18
|
+
changes: DependencyChange[];
|
|
19
|
+
issuesCreated: number;
|
|
20
|
+
errors: number;
|
|
21
|
+
rateLimitWarnings?: string[];
|
|
22
|
+
updatedManifest: Manifest;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Main check action - monitors dependencies and creates issues
|
|
26
|
+
*/
|
|
27
|
+
export declare function checkAction(manifest: Manifest, options?: {
|
|
28
|
+
owner?: string;
|
|
29
|
+
repo?: string;
|
|
30
|
+
createIssues?: boolean;
|
|
31
|
+
dryRun?: boolean;
|
|
32
|
+
}): Promise<CheckActionResult>;
|
|
33
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/actions/check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,KAAK,CACjB,gBAAgB,GAAG;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CACF,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,eAAe,EAAE,QAAQ,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GACA,OAAO,CAAC,iBAAiB,CAAC,CAmL5B"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check Action
|
|
3
|
+
* Monitors dependencies for changes and creates issues when updates are detected
|
|
4
|
+
*/
|
|
5
|
+
import { Monitor } from '@dependabit/monitor';
|
|
6
|
+
import { IssueManager, RateLimitHandler } from '@dependabit/github-client';
|
|
7
|
+
import { SummaryReporter } from '../utils/reporter.js';
|
|
8
|
+
/**
|
|
9
|
+
* Main check action - monitors dependencies and creates issues
|
|
10
|
+
*/
|
|
11
|
+
export async function checkAction(manifest, options) {
|
|
12
|
+
const { owner = process.env['GITHUB_REPOSITORY_OWNER'] || '', repo = process.env['GITHUB_REPOSITORY']?.split('/')[1] || '', createIssues = true, dryRun = false } = options || {};
|
|
13
|
+
const monitor = new Monitor();
|
|
14
|
+
const issueManager = new IssueManager();
|
|
15
|
+
const rateLimitHandler = new RateLimitHandler();
|
|
16
|
+
const reporter = new SummaryReporter();
|
|
17
|
+
const result = {
|
|
18
|
+
checked: 0,
|
|
19
|
+
skipped: 0,
|
|
20
|
+
changes: [],
|
|
21
|
+
issuesCreated: 0,
|
|
22
|
+
errors: 0,
|
|
23
|
+
rateLimitWarnings: [],
|
|
24
|
+
updatedManifest: {
|
|
25
|
+
...manifest,
|
|
26
|
+
dependencies: manifest.dependencies.map((dep) => ({ ...dep }))
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
// Check rate limit before starting
|
|
30
|
+
const rateLimit = await rateLimitHandler.checkRateLimit();
|
|
31
|
+
if (rateLimit.warning) {
|
|
32
|
+
result.rateLimitWarnings?.push(rateLimit.warning);
|
|
33
|
+
}
|
|
34
|
+
// Filter enabled dependencies
|
|
35
|
+
const enabledDeps = manifest.dependencies.filter((dep) => {
|
|
36
|
+
if (dep.monitoring?.enabled === false) {
|
|
37
|
+
result.skipped++;
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (dep.monitoring?.ignoreChanges === true) {
|
|
41
|
+
result.skipped++;
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
});
|
|
46
|
+
console.log(`Checking ${enabledDeps.length} dependencies (${result.skipped} skipped)...`);
|
|
47
|
+
// Reserve budget for all checks upfront
|
|
48
|
+
const budgetNeeded = enabledDeps.length + 10; // Extra buffer for issue operations
|
|
49
|
+
const budgetReservation = await rateLimitHandler.reserveBudget(budgetNeeded);
|
|
50
|
+
if (!budgetReservation.reserved) {
|
|
51
|
+
console.warn(`Insufficient API quota: ${budgetReservation.reason}`);
|
|
52
|
+
if (budgetReservation.waitTime) {
|
|
53
|
+
console.log(`Waiting ${Math.ceil(budgetReservation.waitTime / 1000)} seconds for rate limit reset...`);
|
|
54
|
+
await rateLimitHandler.waitIfNeeded();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Check all dependencies
|
|
58
|
+
const checkResults = await monitor.checkAll(enabledDeps);
|
|
59
|
+
// Process results
|
|
60
|
+
for (const checkResult of checkResults) {
|
|
61
|
+
if (!checkResult)
|
|
62
|
+
continue;
|
|
63
|
+
const depIndex = manifest.dependencies.findIndex((d) => d.id === checkResult.dependency.id);
|
|
64
|
+
if (checkResult.error) {
|
|
65
|
+
console.error(`Error checking ${checkResult.dependency.id}: ${checkResult.error}`);
|
|
66
|
+
result.errors++;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
result.checked++;
|
|
70
|
+
// Update manifest with new state
|
|
71
|
+
if (checkResult.newSnapshot && depIndex >= 0) {
|
|
72
|
+
const dep = result.updatedManifest.dependencies[depIndex];
|
|
73
|
+
if (dep) {
|
|
74
|
+
dep.currentStateHash = checkResult.newSnapshot.stateHash;
|
|
75
|
+
dep.lastChecked = checkResult.newSnapshot.fetchedAt.toISOString();
|
|
76
|
+
if (checkResult.newSnapshot.version) {
|
|
77
|
+
dep.currentVersion = checkResult.newSnapshot.version;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Handle detected changes
|
|
82
|
+
if (checkResult.hasChanged && checkResult.changes && checkResult.severity) {
|
|
83
|
+
const change = {
|
|
84
|
+
dependency: {
|
|
85
|
+
id: checkResult.dependency.id,
|
|
86
|
+
...(checkResult.dependency.name && { name: checkResult.dependency.name }),
|
|
87
|
+
url: checkResult.dependency.url,
|
|
88
|
+
...(checkResult.dependency.type && { type: checkResult.dependency.type })
|
|
89
|
+
},
|
|
90
|
+
severity: checkResult.severity,
|
|
91
|
+
changes: checkResult.changes.changes,
|
|
92
|
+
oldVersion: checkResult.changes.oldVersion,
|
|
93
|
+
newVersion: checkResult.changes.newVersion
|
|
94
|
+
};
|
|
95
|
+
result.changes.push(change);
|
|
96
|
+
// Update lastChanged timestamp
|
|
97
|
+
if (depIndex >= 0) {
|
|
98
|
+
const dep = result.updatedManifest.dependencies[depIndex];
|
|
99
|
+
if (dep) {
|
|
100
|
+
dep.lastChanged = new Date().toISOString();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Create issue if enabled
|
|
104
|
+
if (createIssues && !dryRun && owner && repo) {
|
|
105
|
+
try {
|
|
106
|
+
// Check rate limit before creating issue
|
|
107
|
+
await rateLimitHandler.waitIfNeeded();
|
|
108
|
+
// Check if issue already exists
|
|
109
|
+
const existing = await issueManager.findExistingIssue({
|
|
110
|
+
owner,
|
|
111
|
+
repo,
|
|
112
|
+
dependencyId: checkResult.dependency.id
|
|
113
|
+
});
|
|
114
|
+
if (existing) {
|
|
115
|
+
// Update existing issue
|
|
116
|
+
const updateBody = reporter.generateIssueBody(change);
|
|
117
|
+
await issueManager.updateIssue({
|
|
118
|
+
owner,
|
|
119
|
+
repo,
|
|
120
|
+
issueNumber: existing.number,
|
|
121
|
+
body: updateBody,
|
|
122
|
+
severity: checkResult.severity,
|
|
123
|
+
append: true
|
|
124
|
+
});
|
|
125
|
+
console.log(`Updated existing issue #${existing.number} for ${checkResult.dependency.id}`);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Create new issue
|
|
129
|
+
const issueBody = reporter.generateIssueBody(change);
|
|
130
|
+
const issue = await issueManager.createIssue({
|
|
131
|
+
owner,
|
|
132
|
+
repo,
|
|
133
|
+
title: `Dependency Update: ${change.dependency.name || change.dependency.id}`,
|
|
134
|
+
body: issueBody,
|
|
135
|
+
severity: checkResult.severity,
|
|
136
|
+
dependency: {
|
|
137
|
+
id: checkResult.dependency.id,
|
|
138
|
+
url: checkResult.dependency.url
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
result.issuesCreated++;
|
|
142
|
+
console.log(`Created issue #${issue.number} for ${checkResult.dependency.id}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
console.error(`Failed to create/update issue for ${checkResult.dependency.id}:`, error);
|
|
147
|
+
result.errors++;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Generate and log summary
|
|
153
|
+
const summary = reporter.generateSummary(result.changes);
|
|
154
|
+
console.log('\n' + summary);
|
|
155
|
+
// Check rate limit after processing
|
|
156
|
+
const finalRateLimit = await rateLimitHandler.checkRateLimit();
|
|
157
|
+
if (finalRateLimit.warning && !result.rateLimitWarnings?.includes(finalRateLimit.warning)) {
|
|
158
|
+
result.rateLimitWarnings?.push(finalRateLimit.warning);
|
|
159
|
+
}
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/actions/check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAwBvD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAA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