@kaynooo/cli-pkg 0.14.0 → 0.15.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/dist/cli.js +28 -12
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -437,6 +437,10 @@ function warn(text, detail) {
|
|
|
437
437
|
function problem(text, detail) {
|
|
438
438
|
console.error(marked("problem", text, process6.stderr, detail));
|
|
439
439
|
}
|
|
440
|
+
function role(name, stream, env = process6.env) {
|
|
441
|
+
const colors = paint(stream, env);
|
|
442
|
+
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
443
|
+
}
|
|
440
444
|
var MARK_WORDS, STATUS_WORDS, STATUS_OF;
|
|
441
445
|
var init_style = __esm(() => {
|
|
442
446
|
init_colors();
|
|
@@ -1512,7 +1516,11 @@ async function printCandidates(found) {
|
|
|
1512
1516
|
return 0;
|
|
1513
1517
|
}
|
|
1514
1518
|
function packageVersion(entry = Bun.main) {
|
|
1515
|
-
|
|
1519
|
+
let resolved = entry;
|
|
1520
|
+
try {
|
|
1521
|
+
resolved = realpathSync2(entry);
|
|
1522
|
+
} catch {}
|
|
1523
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1516
1524
|
try {
|
|
1517
1525
|
const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
|
|
1518
1526
|
if (typeof version === "string")
|
|
@@ -2911,9 +2919,11 @@ async function checkPackage(text, context) {
|
|
|
2911
2919
|
function when(release, now) {
|
|
2912
2920
|
return release?.published === undefined ? "" : `, published ${formatAge(release.published, now)} (${release.published.slice(0, 10)})`;
|
|
2913
2921
|
}
|
|
2914
|
-
function render(report, now = Date.now()) {
|
|
2922
|
+
function render(report, now = Date.now(), stream = process.stdout, env = process.env) {
|
|
2923
|
+
const id = role("id", stream, env);
|
|
2924
|
+
const warn = role("warn", stream, env);
|
|
2915
2925
|
if (!report.exists)
|
|
2916
|
-
return [report.name, ...report.warnings.map((warning) => ` warning: ${warning}`)].join(`
|
|
2926
|
+
return [id(report.name), ...report.warnings.map((warning) => ` ${warn("warning:")} ${warning}`)].join(`
|
|
2917
2927
|
`);
|
|
2918
2928
|
const asked = report.requested === undefined ? "" : ` (asked for ${report.requested})`;
|
|
2919
2929
|
const rows = [
|
|
@@ -2926,9 +2936,9 @@ function render(report, now = Date.now()) {
|
|
|
2926
2936
|
...Object.entries(report.installScripts).map(([name, command]) => [name, command])
|
|
2927
2937
|
];
|
|
2928
2938
|
return [
|
|
2929
|
-
`${report.name}${report.description === undefined ? "" : `: ${report.description}`}`,
|
|
2939
|
+
`${id(report.name)}${report.description === undefined ? "" : `: ${report.description}`}`,
|
|
2930
2940
|
table(rows.map(([key, value]) => [` ${key}`, value ?? ""])),
|
|
2931
|
-
...report.warnings.map((warning) => ` warning: ${warning}`)
|
|
2941
|
+
...report.warnings.map((warning) => ` ${warn("warning:")} ${warning}`)
|
|
2932
2942
|
].join(`
|
|
2933
2943
|
`);
|
|
2934
2944
|
}
|
|
@@ -3091,14 +3101,19 @@ async function auditPackages(packages, context) {
|
|
|
3091
3101
|
});
|
|
3092
3102
|
return { audited, unavailable };
|
|
3093
3103
|
}
|
|
3094
|
-
function renderAudit(findings, total) {
|
|
3104
|
+
function renderAudit(findings, total, stream = process19.stdout, env = process19.env) {
|
|
3105
|
+
const id = role("id", stream, env);
|
|
3106
|
+
const label = role("label", stream, env);
|
|
3107
|
+
const warning = role("warn", stream, env);
|
|
3108
|
+
const problem = role("problem", stream, env);
|
|
3109
|
+
const blocking = findings.filter((each) => each.blocked).length;
|
|
3095
3110
|
const blocks = findings.map(({ name, version, warnings, advisories }) => [
|
|
3096
|
-
`${name}@${version}
|
|
3097
|
-
...warnings.map((
|
|
3098
|
-
...advisories.map((each) => ` ${each.ghsa ?? each.id} ${each.severity}: ${each.title}${each.fixed === undefined ? "" : ` (fixed in ${each.fixed})`}`)
|
|
3111
|
+
id(`${name}@${version}`),
|
|
3112
|
+
...warnings.map((each) => ` ${warning("warning:")} ${each}`),
|
|
3113
|
+
...advisories.map((each) => ` ${label(String(each.ghsa ?? each.id))} ${(HIGH_SEVERITIES.has(each.severity) ? problem : warning)(each.severity)}: ${each.title}${each.fixed === undefined ? "" : ` ${label(`(fixed in ${each.fixed})`)}`}`)
|
|
3099
3114
|
].join(`
|
|
3100
3115
|
`));
|
|
3101
|
-
return [...blocks, `${findings.length} of ${total} packages with a finding, ${
|
|
3116
|
+
return [...blocks, `${findings.length} of ${total} packages with a finding, ${(blocking === 0 ? label : problem)(`${blocking} blocking`)}`].join(`
|
|
3102
3117
|
|
|
3103
3118
|
`);
|
|
3104
3119
|
}
|
|
@@ -3138,7 +3153,7 @@ var usage3 = `pkg audit [dir]
|
|
|
3138
3153
|
|
|
3139
3154
|
Reads the bun.lock in the folder (the current one by default) and runs on every registry package it pins the checks \`pkg check\` runs before an add: age, install scripts, a deprecated version, a near miss of a popular name, and the licence allowlist of the pkg config. It also lists the known advisories of each version, with the GHSA, the severity and the fixed version, from the registry's bulk advisory endpoint, the one \`bun audit\` reads.
|
|
3140
3155
|
Findings are grouped per package, each registry package looked up once per run.
|
|
3141
|
-
Reach for it to vet one repository in depth; \`audit\` sweeps many repositories for advisories only, and shares --level, --prod and --ignore.`, EXITS2, options2, BATCH = 8;
|
|
3156
|
+
Reach for it to vet one repository in depth; \`audit\` sweeps many repositories for advisories only, and shares --level, --prod and --ignore.`, EXITS2, options2, BATCH = 8, HIGH_SEVERITIES;
|
|
3142
3157
|
var init_audit = __esm(() => {
|
|
3143
3158
|
init_src();
|
|
3144
3159
|
init_advisories();
|
|
@@ -3154,6 +3169,7 @@ var init_audit = __esm(() => {
|
|
|
3154
3169
|
prod: { type: "boolean", description: "only the packages a production dependency or an optional one of a workspace reaches" },
|
|
3155
3170
|
ignore: { type: "string", multiple: true, description: "an advisory skipped by GHSA or numeric id, repeatable" }
|
|
3156
3171
|
};
|
|
3172
|
+
HIGH_SEVERITIES = new Set(["high", "critical"]);
|
|
3157
3173
|
});
|
|
3158
3174
|
|
|
3159
3175
|
// src/commands/outdated.ts
|
|
@@ -3207,7 +3223,7 @@ async function outdatedCommand(args) {
|
|
|
3207
3223
|
if (values.json === true)
|
|
3208
3224
|
printJson(shown);
|
|
3209
3225
|
else if (shown.length === 0)
|
|
3210
|
-
console.log("nothing outdated: every dependency is on its safe version");
|
|
3226
|
+
console.log(role("ok", process.stdout)("nothing outdated: every dependency is on its safe version"));
|
|
3211
3227
|
else
|
|
3212
3228
|
console.log([table([["PACKAGE", "KIND", "CURRENT", "SAFE", "CHANGE", "PUBLISHED", "LATEST"], ...shown.map((each) => [each.name, each.kind, each.current, each.safe, each.change, each.published === undefined ? "-" : formatAge(each.published), each.latest ?? ""])], { header: true }), ...footer === undefined ? [] : [footer]].join(`
|
|
3213
3229
|
`));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-pkg",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"description": "pkg: check an npm package before it is added, for a guessed name, a version under two weeks old and install scripts.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"@kaynooo/utils": "3.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@kaynooo/cli-kit": "0.38.
|
|
36
|
+
"@kaynooo/cli-kit": "0.38.2"
|
|
37
37
|
}
|
|
38
38
|
}
|