Spaces:
Running
Running
Commit ·
fdb15c0
1
Parent(s): 447d2ec
feat: add blocked sync Teams notifier cli
Browse files
.claude/skills/sync-nowai-leaderboard/notify-blocked.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env node
|
| 2 |
+
|
| 3 |
+
import { postTeams } from './lib/teams.mjs';
|
| 4 |
+
import {
|
| 5 |
+
buildBlockedNotification,
|
| 6 |
+
parseBlockedCliArgs,
|
| 7 |
+
} from './lib/blocked-notify.mjs';
|
| 8 |
+
|
| 9 |
+
const isMain = import.meta.url === `file://${process.argv[1]}`;
|
| 10 |
+
|
| 11 |
+
if (isMain) {
|
| 12 |
+
try {
|
| 13 |
+
const { reason, facts } = parseBlockedCliArgs(process.argv.slice(2));
|
| 14 |
+
const ok = await postTeams(buildBlockedNotification({ reason, facts }));
|
| 15 |
+
console.log(ok ? '[teams] posted.' : '[teams] not posted.');
|
| 16 |
+
process.exit(ok ? 0 : 1);
|
| 17 |
+
} catch (e) {
|
| 18 |
+
console.error('[teams] invalid blocked notification args: ' + e.message);
|
| 19 |
+
process.exit(2);
|
| 20 |
+
}
|
| 21 |
+
}
|
.claude/skills/sync-nowai-leaderboard/test/notify-blocked-cli.test.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { test } from 'node:test';
|
| 2 |
+
import assert from 'node:assert/strict';
|
| 3 |
+
import { spawnSync } from 'node:child_process';
|
| 4 |
+
import { fileURLToPath } from 'node:url';
|
| 5 |
+
|
| 6 |
+
const ENTRY = fileURLToPath(new URL('../notify-blocked.mjs', import.meta.url));
|
| 7 |
+
|
| 8 |
+
test('notify-blocked CLI exits 1 when no Teams webhook is configured', () => {
|
| 9 |
+
const result = spawnSync(
|
| 10 |
+
process.execPath,
|
| 11 |
+
[ENTRY, '--reason', 'wrong-branch', '--fact', 'Branch=feature/demo'],
|
| 12 |
+
{
|
| 13 |
+
env: { ...process.env, TEAMS_WEBHOOK_URL: '' },
|
| 14 |
+
encoding: 'utf8',
|
| 15 |
+
},
|
| 16 |
+
);
|
| 17 |
+
|
| 18 |
+
assert.equal(result.status, 1);
|
| 19 |
+
assert.match(result.stdout, /no TEAMS_WEBHOOK_URL set; skipping card/);
|
| 20 |
+
assert.match(result.stdout, /\[teams\] not posted\./);
|
| 21 |
+
assert.equal(result.stderr, '');
|
| 22 |
+
});
|