Skip to content

Commit 5bf4304

Browse files
feat: CLI ready for npmjs.com, --ci flag for GitHub Actions annotations
- Fixed: unscoped oss-health-scan name for public npm registry - Removed: .npmrc GitHub Packages lock - Added: --ci flag outputs ::warning:: and ::error:: annotations in GitHub Actions - Keywords: added deprecated, dead-packages, supply-chain for npm search
1 parent 355b94d commit 5bf4304

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

cli/.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

cli/bin/scan.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ const HELP = `
1717
1818
Options:
1919
--json Output raw JSON instead of terminal report
20+
--ci Output GitHub Actions annotations (::warning::, ::error::)
2021
--threshold N Only show packages below health score N (default: show all)
2122
--dev Include devDependencies
2223
--no-color Disable colored output
2324
-h, --help Show this help
2425
`;
2526

2627
async function resolvePackages(args) {
27-
const flags = { json: false, threshold: 0, dev: false, color: true, packages: [] };
28+
const flags = { json: false, ci: false, threshold: 0, dev: false, color: true, packages: [] };
2829

2930
for (let i = 0; i < args.length; i++) {
3031
const a = args[i];
3132
if (a === '--json') flags.json = true;
33+
else if (a === '--ci') flags.ci = true;
3234
else if (a === '--dev') flags.dev = true;
3335
else if (a === '--no-color') flags.color = false;
3436
else if (a === '-h' || a === '--help') { process.stdout.write(HELP); process.exit(0); }
@@ -161,6 +163,16 @@ async function main() {
161163

162164
if (flags.json) {
163165
process.stdout.write(JSON.stringify({ scanned: packages.length, results: filtered }, null, 2) + '\n');
166+
} else if (flags.ci) {
167+
for (const r of filtered) {
168+
if (r.error) continue;
169+
const level = r.risk_level === 'critical' ? 'error' : r.risk_level === 'warning' ? 'warning' : 'notice';
170+
const msg = `${r.name}@${r.latest || '?'}: health ${r.health_score}/100` +
171+
(r.reason ? ` — ${r.reason}` : '') +
172+
(r.daysSincePush ? ` (last push ${r.daysSincePush}d ago)` : '');
173+
process.stdout.write(`::${level}::${msg}\n`);
174+
}
175+
printReport(filtered, flags.color);
164176
} else {
165177
printReport(filtered, flags.color);
166178
}

cli/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@dusan-maintains/oss-health-scan",
2+
"name": "oss-health-scan",
33
"version": "1.0.0",
44
"description": "Scan your package.json for abandoned, unmaintained, or unhealthy npm dependencies. Get health scores (0-100) for every dependency. Zero external dependencies.",
55
"bin": {
@@ -16,7 +16,9 @@
1616
"maintenance",
1717
"oss",
1818
"scanner",
19-
"supply-chain"
19+
"supply-chain",
20+
"deprecated",
21+
"dead-packages"
2022
],
2123
"author": "dusan-maintains",
2224
"license": "MIT",
@@ -36,8 +38,5 @@
3638
"bin/",
3739
"lib/",
3840
"README.md"
39-
],
40-
"publishConfig": {
41-
"registry": "https://npm.pkg.github.com"
42-
}
41+
]
4342
}

0 commit comments

Comments
 (0)