@claudemini/shit-cli 1.8.0 → 1.8.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/README.md +24 -10
- package/lib/webhook.js +16 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -262,7 +262,30 @@ shit-cli can send webhook notifications to external systems (Slack, Lark, CI, cu
|
|
|
262
262
|
|
|
263
263
|
### Configuration
|
|
264
264
|
|
|
265
|
-
|
|
265
|
+
Webhook supports three configuration sources (highest priority first):
|
|
266
|
+
|
|
267
|
+
**1. Environment variables** (highest priority):
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
export SHIT_WEBHOOK_URL=https://example.com/hook
|
|
271
|
+
export SHIT_WEBHOOK_SECRET=my-secret # HMAC-SHA256 signing
|
|
272
|
+
export SHIT_WEBHOOK_AUTH_TOKEN=bearer-token # Bearer auth (alternative to secret)
|
|
273
|
+
export SHIT_WEBHOOK_EVENTS=session.ended,review.completed
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**2. `.shit-logs/config.json` `env` field**:
|
|
277
|
+
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"env": {
|
|
281
|
+
"SHIT_WEBHOOK_URL": "https://example.com/hook",
|
|
282
|
+
"SHIT_WEBHOOK_SECRET": "my-secret",
|
|
283
|
+
"SHIT_WEBHOOK_EVENTS": "session.ended,review.completed"
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**3. `.shit-logs/config.json` `webhooks` field** (lowest priority):
|
|
266
289
|
|
|
267
290
|
```json
|
|
268
291
|
{
|
|
@@ -277,15 +300,6 @@ Add a `webhooks` field to `.shit-logs/config.json`:
|
|
|
277
300
|
}
|
|
278
301
|
```
|
|
279
302
|
|
|
280
|
-
Or use environment variables (higher priority than config.json):
|
|
281
|
-
|
|
282
|
-
```bash
|
|
283
|
-
export SHIT_WEBHOOK_URL=https://example.com/hook
|
|
284
|
-
export SHIT_WEBHOOK_SECRET=my-secret # HMAC-SHA256 signing
|
|
285
|
-
export SHIT_WEBHOOK_AUTH_TOKEN=bearer-token # Bearer auth (alternative to secret)
|
|
286
|
-
export SHIT_WEBHOOK_EVENTS=session.ended,review.completed
|
|
287
|
-
```
|
|
288
|
-
|
|
289
303
|
### Authentication
|
|
290
304
|
|
|
291
305
|
- **HMAC-SHA256** — Set `secret` or `SHIT_WEBHOOK_SECRET`. Adds `X-Signature-256: sha256=<hex>` header (GitHub-compatible format).
|
package/lib/webhook.js
CHANGED
|
@@ -11,22 +11,29 @@ import { request as httpRequest } from 'http';
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Load webhook configuration from .shit-logs/config.json + environment variables.
|
|
14
|
-
*
|
|
14
|
+
* Priority (highest wins): process.env > config.json env > config.json webhooks
|
|
15
15
|
*/
|
|
16
16
|
export function loadWebhookConfig(projectRoot) {
|
|
17
17
|
let fileConfig = {};
|
|
18
|
+
let configEnv = {};
|
|
18
19
|
const configPath = join(projectRoot, '.shit-logs', 'config.json');
|
|
19
20
|
if (existsSync(configPath)) {
|
|
20
21
|
try {
|
|
21
22
|
const raw = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
22
23
|
fileConfig = raw.webhooks || {};
|
|
24
|
+
if (raw.env && typeof raw.env === 'object') {
|
|
25
|
+
configEnv = raw.env;
|
|
26
|
+
}
|
|
23
27
|
} catch { /* ignore malformed config */ }
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
// Resolve: process.env > config.json env > config.json webhooks field
|
|
31
|
+
const env = (key) => process.env[key] || configEnv[key] || '';
|
|
32
|
+
|
|
33
|
+
const url = env('SHIT_WEBHOOK_URL') || fileConfig.url;
|
|
27
34
|
if (!url) return null;
|
|
28
35
|
|
|
29
|
-
const envEvents =
|
|
36
|
+
const envEvents = env('SHIT_WEBHOOK_EVENTS');
|
|
30
37
|
const events = envEvents
|
|
31
38
|
? envEvents.split(',').map(e => e.trim()).filter(Boolean)
|
|
32
39
|
: (Array.isArray(fileConfig.events) ? fileConfig.events : []);
|
|
@@ -34,8 +41,8 @@ export function loadWebhookConfig(projectRoot) {
|
|
|
34
41
|
return {
|
|
35
42
|
url,
|
|
36
43
|
events,
|
|
37
|
-
secret:
|
|
38
|
-
auth_token:
|
|
44
|
+
secret: env('SHIT_WEBHOOK_SECRET') || fileConfig.secret || '',
|
|
45
|
+
auth_token: env('SHIT_WEBHOOK_AUTH_TOKEN') || fileConfig.auth_token || '',
|
|
39
46
|
headers: fileConfig.headers || {},
|
|
40
47
|
timeout_ms: fileConfig.timeout_ms || 5000,
|
|
41
48
|
retry: typeof fileConfig.retry === 'number' ? fileConfig.retry : 1,
|
|
@@ -169,12 +176,14 @@ export default async function webhook(args) {
|
|
|
169
176
|
console.log(' --test Send a test webhook ping');
|
|
170
177
|
console.log(' --help Show this help');
|
|
171
178
|
console.log('');
|
|
172
|
-
console.log('Configuration:');
|
|
173
|
-
console.log('
|
|
179
|
+
console.log('Configuration (highest priority first):');
|
|
180
|
+
console.log(' 1. Environment variables:');
|
|
174
181
|
console.log(' SHIT_WEBHOOK_URL Webhook endpoint URL');
|
|
175
182
|
console.log(' SHIT_WEBHOOK_SECRET HMAC-SHA256 signing secret');
|
|
176
183
|
console.log(' SHIT_WEBHOOK_AUTH_TOKEN Bearer token');
|
|
177
184
|
console.log(' SHIT_WEBHOOK_EVENTS Comma-separated event list');
|
|
185
|
+
console.log(' 2. .shit-logs/config.json "env" field');
|
|
186
|
+
console.log(' 3. .shit-logs/config.json "webhooks" field');
|
|
178
187
|
return 0;
|
|
179
188
|
}
|
|
180
189
|
|