@kaynooo/cli-pkg 0.15.0 → 0.16.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 +316 -71
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -555,18 +555,14 @@ import process8 from "process";
|
|
|
555
555
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
556
556
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
557
557
|
}
|
|
558
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
559
|
-
return [usageLine(usage, colors),
|
|
558
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
559
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
560
560
|
`);
|
|
561
561
|
}
|
|
562
562
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
563
563
|
if (exits.length === 0)
|
|
564
564
|
return [];
|
|
565
|
-
|
|
566
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
567
|
-
}
|
|
568
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
569
|
-
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
565
|
+
return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
|
|
570
566
|
}
|
|
571
567
|
function wantsHelpJson(env = process8.env) {
|
|
572
568
|
return env.KIT_HELP === "json";
|
|
@@ -595,33 +591,44 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
|
595
591
|
function optionRows(options, colors = paint(process8.stdout)) {
|
|
596
592
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
597
593
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
598
|
-
const
|
|
594
|
+
const choices = option.choices?.join("|");
|
|
595
|
+
const inline = choices !== undefined && choices.length <= MAX_INLINE_CHOICES;
|
|
596
|
+
const named = inline ? `<${choices}>` : "<value>";
|
|
599
597
|
const placeholder = option.optional === undefined ? named : `[${named}]`;
|
|
600
598
|
const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
|
|
601
|
-
|
|
599
|
+
const described = choices === undefined || inline ? option.description ?? "" : [option.description, `one of ${option.choices.join(", ")}`].filter(Boolean).join("; ");
|
|
600
|
+
return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: described };
|
|
602
601
|
});
|
|
603
602
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
604
603
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
605
604
|
}
|
|
606
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP;
|
|
605
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
607
606
|
var init_help = __esm(() => {
|
|
608
607
|
init_mode();
|
|
609
608
|
init_style();
|
|
610
|
-
OPTIONAL =
|
|
609
|
+
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
611
610
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
612
611
|
FULL_STOP = /\.$/;
|
|
613
612
|
});
|
|
614
613
|
|
|
615
614
|
// ../kit/src/text.ts
|
|
616
615
|
function distance(a, b) {
|
|
617
|
-
|
|
618
|
-
|
|
616
|
+
const left = [...a];
|
|
617
|
+
const right = [...b];
|
|
618
|
+
let before = [];
|
|
619
|
+
let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
620
|
+
for (const [i, x] of left.entries()) {
|
|
619
621
|
const current = [i + 1];
|
|
620
|
-
for (const [j,
|
|
621
|
-
|
|
622
|
+
for (const [j, y] of right.entries()) {
|
|
623
|
+
let cost = Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (x === y ? 0 : 1));
|
|
624
|
+
if (i > 0 && j > 0 && x === right[j - 1] && left[i - 1] === y)
|
|
625
|
+
cost = Math.min(cost, (before[j - 1] ?? 0) + 1);
|
|
626
|
+
current.push(cost);
|
|
627
|
+
}
|
|
628
|
+
before = previous;
|
|
622
629
|
previous = current;
|
|
623
630
|
}
|
|
624
|
-
return previous[
|
|
631
|
+
return previous[right.length] ?? 0;
|
|
625
632
|
}
|
|
626
633
|
function closest(name, names) {
|
|
627
634
|
const started = names.find((known) => known.startsWith(name));
|
|
@@ -630,10 +637,7 @@ function closest(name, names) {
|
|
|
630
637
|
const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
|
|
631
638
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
632
639
|
}
|
|
633
|
-
var
|
|
634
|
-
var init_text2 = __esm(() => {
|
|
635
|
-
ANSI = new RegExp(`${String.fromCharCode(27)}\\[[\\d;?]*[a-z]`, "gi");
|
|
636
|
-
});
|
|
640
|
+
var init_text2 = () => {};
|
|
637
641
|
|
|
638
642
|
// ../kit/src/input.ts
|
|
639
643
|
import { fstatSync } from "fs";
|
|
@@ -1223,6 +1227,27 @@ var init_ci = __esm(() => {
|
|
|
1223
1227
|
init_tool();
|
|
1224
1228
|
});
|
|
1225
1229
|
|
|
1230
|
+
// ../kit/src/notify.ts
|
|
1231
|
+
import process14 from "process";
|
|
1232
|
+
function base64(text) {
|
|
1233
|
+
return Buffer.from(text).toString("base64");
|
|
1234
|
+
}
|
|
1235
|
+
function notification(title, body, env = process14.env) {
|
|
1236
|
+
const id = `kit${process14.pid}`;
|
|
1237
|
+
const codes = [`\x1B]99;i=${id}:d=0:o=unfocused:e=1;${base64(title)}\x1B\\`, `\x1B]99;i=${id}:p=body:e=1;${base64(body)}\x1B\\`];
|
|
1238
|
+
return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
|
|
1239
|
+
}
|
|
1240
|
+
function notifyEnd(command, code, ms, { stream = process14.stderr, env = process14.env } = {}) {
|
|
1241
|
+
if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
|
|
1242
|
+
return;
|
|
1243
|
+
stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
|
|
1244
|
+
}
|
|
1245
|
+
var NOTIFY_AFTER_MS = 1e4, CANCELLED = 130;
|
|
1246
|
+
var init_notify = __esm(() => {
|
|
1247
|
+
init_format();
|
|
1248
|
+
init_mode();
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1226
1251
|
// ../kit/src/logs.ts
|
|
1227
1252
|
var DAY_MS, CLI_FOLDER = "kaynooo-cli";
|
|
1228
1253
|
var init_logs = __esm(() => {
|
|
@@ -1233,18 +1258,18 @@ var init_logs = __esm(() => {
|
|
|
1233
1258
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1234
1259
|
import { homedir as homedir3 } from "os";
|
|
1235
1260
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
1236
|
-
import
|
|
1261
|
+
import process15 from "process";
|
|
1237
1262
|
function noteUsageError(message) {
|
|
1238
1263
|
usageError = message;
|
|
1239
1264
|
}
|
|
1240
|
-
function stateHome(env =
|
|
1265
|
+
function stateHome(env = process15.env) {
|
|
1241
1266
|
const dir = env.XDG_STATE_HOME;
|
|
1242
1267
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
1243
1268
|
}
|
|
1244
|
-
function usagePath(env =
|
|
1269
|
+
function usagePath(env = process15.env) {
|
|
1245
1270
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1246
1271
|
}
|
|
1247
|
-
function usageRecorded(env =
|
|
1272
|
+
function usageRecorded(env = process15.env) {
|
|
1248
1273
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1249
1274
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1250
1275
|
}
|
|
@@ -1258,7 +1283,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1258
1283
|
usageError = undefined;
|
|
1259
1284
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1260
1285
|
}
|
|
1261
|
-
function recordUsage(entry, env =
|
|
1286
|
+
function recordUsage(entry, env = process15.env) {
|
|
1262
1287
|
if (!usageRecorded(env))
|
|
1263
1288
|
return;
|
|
1264
1289
|
try {
|
|
@@ -1278,7 +1303,7 @@ var init_usage = __esm(() => {
|
|
|
1278
1303
|
// ../kit/src/cli.ts
|
|
1279
1304
|
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
1280
1305
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1281
|
-
import
|
|
1306
|
+
import process16 from "process";
|
|
1282
1307
|
async function commandRows(all, colors) {
|
|
1283
1308
|
const commands = shown(all);
|
|
1284
1309
|
const width = Math.max(0, ...Object.keys(commands).map((name) => name.length));
|
|
@@ -1339,7 +1364,6 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1339
1364
|
header(colors, summary),
|
|
1340
1365
|
"",
|
|
1341
1366
|
usageLine(`${prefix} ${defaultCommand === undefined ? colors.cyan("<command>") : `[${colors.cyan("<command>")}]`} [options]`, colors),
|
|
1342
|
-
...replacesRows(replaces, colors),
|
|
1343
1367
|
"",
|
|
1344
1368
|
...await commandRows(commands, colors),
|
|
1345
1369
|
...own.length === 0 ? [] : ["", `${colors.bold(`Options of ${defaultCommand}:`)} ${colors.dim("the command run when none is named")}`, ...optionRows(Object.fromEntries(own), colors)],
|
|
@@ -1353,8 +1377,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1353
1377
|
`);
|
|
1354
1378
|
}
|
|
1355
1379
|
function printError(prefix, message, hint, cause) {
|
|
1356
|
-
const colors = paint(
|
|
1357
|
-
const styled = takesControlCodes(
|
|
1380
|
+
const colors = paint(process16.stderr);
|
|
1381
|
+
const styled = takesControlCodes(process16.stderr);
|
|
1358
1382
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1359
1383
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1360
1384
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1397,11 +1421,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1397
1421
|
}
|
|
1398
1422
|
}
|
|
1399
1423
|
if (name === undefined && level.path.length > 1) {
|
|
1400
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1424
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process16.stderr));
|
|
1401
1425
|
return 2;
|
|
1402
1426
|
}
|
|
1403
1427
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1404
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1428
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process16.stdout));
|
|
1405
1429
|
return 0;
|
|
1406
1430
|
}
|
|
1407
1431
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1534,10 +1558,13 @@ async function runCli(cli, argv = scriptArgs()) {
|
|
|
1534
1558
|
const version = cli.version ?? packageVersion();
|
|
1535
1559
|
if (argv[0] === COMPLETE)
|
|
1536
1560
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
1561
|
+
const started = performance.now();
|
|
1537
1562
|
const code = await dispatch({ path: [cli.name], header: (colors, about) => `${colors.bold(cli.name)} ${colors.dim(version)} ${about}`, summary: cli.about, ...scopeOf(cli.commands, cli.extraCommands, cli.aliases), defaultCommand: cli.defaultCommand, runBare: cli.runBare === true, examples: cli.examples, replaces: cli.replaces }, argv, { version, redact: cli.redact });
|
|
1563
|
+
const command = commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv);
|
|
1564
|
+
notifyEnd(command === undefined ? cli.name : `${cli.name} ${command}`, code, performance.now() - started);
|
|
1538
1565
|
if (cli.usage !== false) {
|
|
1539
1566
|
try {
|
|
1540
|
-
recordUsage(usageEntry(cli.name,
|
|
1567
|
+
recordUsage(usageEntry(cli.name, command, argv, code));
|
|
1541
1568
|
} catch {}
|
|
1542
1569
|
}
|
|
1543
1570
|
return code;
|
|
@@ -1561,6 +1588,7 @@ var LEVEL_OPTIONS, TOP_OPTIONS, COMPLETE = "__complete", FILES = "__files__";
|
|
|
1561
1588
|
var init_cli = __esm(() => {
|
|
1562
1589
|
init_args();
|
|
1563
1590
|
init_argv();
|
|
1591
|
+
init_notify();
|
|
1564
1592
|
init_style();
|
|
1565
1593
|
init_text2();
|
|
1566
1594
|
init_usage();
|
|
@@ -1570,6 +1598,11 @@ var init_cli = __esm(() => {
|
|
|
1570
1598
|
};
|
|
1571
1599
|
TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
1572
1600
|
});
|
|
1601
|
+
// ../kit/src/excerpt.ts
|
|
1602
|
+
var init_excerpt = __esm(() => {
|
|
1603
|
+
init_text2();
|
|
1604
|
+
});
|
|
1605
|
+
|
|
1573
1606
|
// ../kit/src/folders.ts
|
|
1574
1607
|
function ignoredFolders(extra = [], where = {}) {
|
|
1575
1608
|
const configured = readUserConfig("config", where).ignore;
|
|
@@ -1661,7 +1694,7 @@ var init_watch = __esm(() => {
|
|
|
1661
1694
|
// ../kit/src/workspace-root.ts
|
|
1662
1695
|
import { homedir as homedir4 } from "os";
|
|
1663
1696
|
import { dirname as dirname4, join as join6, resolve as resolve4 } from "path";
|
|
1664
|
-
import
|
|
1697
|
+
import process17 from "process";
|
|
1665
1698
|
function expandHome(path, home) {
|
|
1666
1699
|
if (path === "~")
|
|
1667
1700
|
return home;
|
|
@@ -1671,7 +1704,7 @@ function configured(env, home) {
|
|
|
1671
1704
|
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
1672
1705
|
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1673
1706
|
}
|
|
1674
|
-
function workspaceRoot({ given, env =
|
|
1707
|
+
function workspaceRoot({ given, env = process17.env, home = homedir4() } = {}) {
|
|
1675
1708
|
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
1676
1709
|
return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
|
|
1677
1710
|
}
|
|
@@ -1681,6 +1714,7 @@ var init_workspace_root = __esm(() => {
|
|
|
1681
1714
|
|
|
1682
1715
|
// ../kit/src/index.ts
|
|
1683
1716
|
var init_src = __esm(() => {
|
|
1717
|
+
init_excerpt();
|
|
1684
1718
|
init_advisory();
|
|
1685
1719
|
init_args();
|
|
1686
1720
|
init_argv();
|
|
@@ -2467,6 +2501,24 @@ function safeRelease(packument, now, minAgeDays) {
|
|
|
2467
2501
|
const version = old.sort(Bun.semver.order).at(-1);
|
|
2468
2502
|
return version === undefined ? undefined : { version, published: packument.time?.[version] };
|
|
2469
2503
|
}
|
|
2504
|
+
function previousRelease(packument, version) {
|
|
2505
|
+
const below = Object.keys(packument.versions ?? {}).filter((each) => (isStable(each) || !isStable(version)) && Bun.semver.order(each, version) < 0).sort(Bun.semver.order).at(-1);
|
|
2506
|
+
return below === undefined ? undefined : packument.versions?.[below];
|
|
2507
|
+
}
|
|
2508
|
+
function publisherWarnings(packument, version) {
|
|
2509
|
+
const current = packument.versions?.[version];
|
|
2510
|
+
const previous = previousRelease(packument, version);
|
|
2511
|
+
const warnings = [];
|
|
2512
|
+
if (current === undefined || previous === undefined)
|
|
2513
|
+
return warnings;
|
|
2514
|
+
const by = current._npmUser?.name;
|
|
2515
|
+
const before = previous._npmUser?.name;
|
|
2516
|
+
if (by !== undefined && before !== undefined && by !== before)
|
|
2517
|
+
warnings.push(`${version} was published by ${by}, ${previous.version} by ${before}`);
|
|
2518
|
+
if (previous.dist?.attestations !== undefined && current.dist?.attestations === undefined)
|
|
2519
|
+
warnings.push(`${version} has no provenance attestation, ${previous.version} had one`);
|
|
2520
|
+
return warnings;
|
|
2521
|
+
}
|
|
2470
2522
|
function analyze(input) {
|
|
2471
2523
|
const { spec, packument, registry, now = Date.now(), minAgeDays = DEFAULT_MIN_AGE_DAYS } = input;
|
|
2472
2524
|
const report = { name: spec.name, registry, exists: packument !== undefined, requested: spec.request, installScripts: {}, nearMisses: nearMisses(spec.name), advisories: input.advisories ?? [], fixes: [], warnings: [], blocked: false, downloads: input.downloads };
|
|
@@ -2512,6 +2564,7 @@ function analyze(input) {
|
|
|
2512
2564
|
report.warnings.push(`${version} runs ${scripts.join(", ")} at install`);
|
|
2513
2565
|
if (report.deprecated !== undefined)
|
|
2514
2566
|
report.warnings.push(`${version} is deprecated: ${report.deprecated}`);
|
|
2567
|
+
report.warnings.push(...publisherWarnings(packument, version));
|
|
2515
2568
|
if (input.licenses !== undefined) {
|
|
2516
2569
|
const isMissing = report.license === undefined || report.license === "";
|
|
2517
2570
|
if (isMissing) {
|
|
@@ -2548,7 +2601,7 @@ var init_analyze = __esm(() => {
|
|
|
2548
2601
|
// src/config.ts
|
|
2549
2602
|
import { homedir as homedir5 } from "os";
|
|
2550
2603
|
import { dirname as dirname5, join as join7 } from "path";
|
|
2551
|
-
import
|
|
2604
|
+
import process19 from "process";
|
|
2552
2605
|
function expand2(value, env) {
|
|
2553
2606
|
let missing = false;
|
|
2554
2607
|
const expanded = value.replace(ENV_REFERENCE, (_, braced, bare) => {
|
|
@@ -2637,7 +2690,7 @@ async function readIfThere(path) {
|
|
|
2637
2690
|
const file = Bun.file(path);
|
|
2638
2691
|
return await file.exists() ? file.text() : undefined;
|
|
2639
2692
|
}
|
|
2640
|
-
async function loadConfigs(cwd =
|
|
2693
|
+
async function loadConfigs(cwd = process19.cwd(), env = process19.env, home = homedir5()) {
|
|
2641
2694
|
const directories = [];
|
|
2642
2695
|
for (let dir = cwd;!directories.includes(dir); dir = dirname5(dir))
|
|
2643
2696
|
directories.push(dir);
|
|
@@ -2670,7 +2723,7 @@ function parseSettings(text) {
|
|
|
2670
2723
|
settings.concurrency = raw.concurrency;
|
|
2671
2724
|
return settings;
|
|
2672
2725
|
}
|
|
2673
|
-
async function loadSettings(cwd =
|
|
2726
|
+
async function loadSettings(cwd = process19.cwd(), home) {
|
|
2674
2727
|
const files = [];
|
|
2675
2728
|
for (let dir = cwd;!files.includes(join7(dir, SETTINGS_FILE)); dir = dirname5(dir))
|
|
2676
2729
|
files.push(join7(dir, SETTINGS_FILE));
|
|
@@ -2969,7 +3022,7 @@ ${usage2}` : `${values.from} has no registry dependency to check`);
|
|
|
2969
3022
|
}
|
|
2970
3023
|
var usage2 = `pkg [check] <name>[@version]... | --from <package.json> | -
|
|
2971
3024
|
|
|
2972
|
-
Checks npm packages before they are added: whether the name exists, the latest and the newest version at least two weeks old, weekly downloads, licence, repository, install scripts
|
|
3025
|
+
Checks npm packages before they are added: whether the name exists, the latest and the newest version at least two weeks old, weekly downloads, licence, repository, install scripts, a near miss of a popular name, and a warning when the version's publisher differs from the previous release's or its provenance attestation is gone.
|
|
2973
3026
|
|
|
2974
3027
|
Names come from the arguments, from the dependencies of a package.json with --from (each checked as \`name@range\`, so it resolves what an install would; dev and optional ones included, peer ranges and local or remote sources left out), or from stdin, separated by spaces or lines, when \`-\` is given or nothing else is and stdin is piped.
|
|
2975
3028
|
|
|
@@ -3061,7 +3114,7 @@ __export(exports_audit, {
|
|
|
3061
3114
|
audit: () => audit
|
|
3062
3115
|
});
|
|
3063
3116
|
import { join as join9, resolve as resolve6 } from "path";
|
|
3064
|
-
import
|
|
3117
|
+
import process20 from "process";
|
|
3065
3118
|
function hasFinding(audited) {
|
|
3066
3119
|
return audited.blocked || audited.warnings.length > 0 || audited.advisories.length > 0;
|
|
3067
3120
|
}
|
|
@@ -3101,7 +3154,7 @@ async function auditPackages(packages, context) {
|
|
|
3101
3154
|
});
|
|
3102
3155
|
return { audited, unavailable };
|
|
3103
3156
|
}
|
|
3104
|
-
function renderAudit(findings, total, stream =
|
|
3157
|
+
function renderAudit(findings, total, stream = process20.stdout, env = process20.env) {
|
|
3105
3158
|
const id = role("id", stream, env);
|
|
3106
3159
|
const label = role("label", stream, env);
|
|
3107
3160
|
const warning = role("warn", stream, env);
|
|
@@ -3122,7 +3175,7 @@ async function audit(args) {
|
|
|
3122
3175
|
const level = values.level ?? "moderate";
|
|
3123
3176
|
if (!isSeverity(level))
|
|
3124
3177
|
fail(`--level takes ${SEVERITIES.join(", ")}, not ${level}`);
|
|
3125
|
-
const dir = resolve6(asked ??
|
|
3178
|
+
const dir = resolve6(asked ?? process20.cwd());
|
|
3126
3179
|
const lock = Bun.file(join9(dir, "bun.lock"));
|
|
3127
3180
|
if (!await lock.exists())
|
|
3128
3181
|
fail(`no bun.lock in ${dir}`);
|
|
@@ -3151,7 +3204,7 @@ async function audit(args) {
|
|
|
3151
3204
|
}
|
|
3152
3205
|
var usage3 = `pkg audit [dir]
|
|
3153
3206
|
|
|
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.
|
|
3207
|
+
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 changed publisher or lost attestation, 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.
|
|
3155
3208
|
Findings are grouped per package, each registry package looked up once per run.
|
|
3156
3209
|
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;
|
|
3157
3210
|
var init_audit = __esm(() => {
|
|
@@ -3250,6 +3303,134 @@ var init_outdated = __esm(() => {
|
|
|
3250
3303
|
};
|
|
3251
3304
|
});
|
|
3252
3305
|
|
|
3306
|
+
// ../kit/src/answers.ts
|
|
3307
|
+
var init_answers = __esm(() => {
|
|
3308
|
+
init_folders();
|
|
3309
|
+
});
|
|
3310
|
+
|
|
3311
|
+
// ../kit/src/job.ts
|
|
3312
|
+
import process21 from "process";
|
|
3313
|
+
function stopJob() {
|
|
3314
|
+
process21.kill(0, "SIGTSTP");
|
|
3315
|
+
}
|
|
3316
|
+
var init_job = () => {};
|
|
3317
|
+
|
|
3318
|
+
// ../kit/src/picker/line.ts
|
|
3319
|
+
function isEditKey(key) {
|
|
3320
|
+
return EDIT_KEYS.has(key);
|
|
3321
|
+
}
|
|
3322
|
+
function endsKills(key) {
|
|
3323
|
+
return typeof key !== "object" && !isEditKey(key);
|
|
3324
|
+
}
|
|
3325
|
+
function isWord(char) {
|
|
3326
|
+
return char !== undefined && WORD_CHARACTER.test(char);
|
|
3327
|
+
}
|
|
3328
|
+
function wordStart(chars, from) {
|
|
3329
|
+
let at = from;
|
|
3330
|
+
while (at > 0 && !isWord(chars[at - 1]))
|
|
3331
|
+
at--;
|
|
3332
|
+
while (at > 0 && isWord(chars[at - 1]))
|
|
3333
|
+
at--;
|
|
3334
|
+
return at;
|
|
3335
|
+
}
|
|
3336
|
+
function wordEnd(chars, from) {
|
|
3337
|
+
let at = from;
|
|
3338
|
+
while (at < chars.length && !isWord(chars[at]))
|
|
3339
|
+
at++;
|
|
3340
|
+
while (at < chars.length && isWord(chars[at]))
|
|
3341
|
+
at++;
|
|
3342
|
+
return at;
|
|
3343
|
+
}
|
|
3344
|
+
function spacedStart(chars, from) {
|
|
3345
|
+
let at = from;
|
|
3346
|
+
while (at > 0 && SPACE.test(chars[at - 1] ?? ""))
|
|
3347
|
+
at--;
|
|
3348
|
+
while (at > 0 && !SPACE.test(chars[at - 1] ?? ""))
|
|
3349
|
+
at--;
|
|
3350
|
+
return at;
|
|
3351
|
+
}
|
|
3352
|
+
function cut(chars, from, to) {
|
|
3353
|
+
return { text: [...chars.slice(0, from), ...chars.slice(to)].join(""), caret: from };
|
|
3354
|
+
}
|
|
3355
|
+
function insert(chars, at, text) {
|
|
3356
|
+
const typed = [...text];
|
|
3357
|
+
return { text: [...chars.slice(0, at), ...typed, ...chars.slice(at)].join(""), caret: at + typed.length };
|
|
3358
|
+
}
|
|
3359
|
+
function editLine(line, key) {
|
|
3360
|
+
const { killed = "", chained = false } = line;
|
|
3361
|
+
const chars = [...line.text];
|
|
3362
|
+
const at = Math.min(Math.max(line.caret, 0), chars.length);
|
|
3363
|
+
const edited = edit(chars, at, key, killed);
|
|
3364
|
+
if (typeof key === "object" || !BACKWARD_KILLS.has(key) && !FORWARD_KILLS.has(key))
|
|
3365
|
+
return line.killed === undefined ? edited : { ...edited, killed };
|
|
3366
|
+
const taken = chars.slice(edited.caret, edited.caret + chars.length - [...edited.text].length).join("");
|
|
3367
|
+
if (taken === "")
|
|
3368
|
+
return { ...edited, killed, chained };
|
|
3369
|
+
if (!chained)
|
|
3370
|
+
return { ...edited, killed: taken, chained: true };
|
|
3371
|
+
return { ...edited, killed: BACKWARD_KILLS.has(key) ? taken + killed : killed + taken, chained: true };
|
|
3372
|
+
}
|
|
3373
|
+
function edit(chars, at, key, killed) {
|
|
3374
|
+
const text = chars.join("");
|
|
3375
|
+
if (typeof key === "object")
|
|
3376
|
+
return insert(chars, at, key.text);
|
|
3377
|
+
switch (key) {
|
|
3378
|
+
case "left":
|
|
3379
|
+
return { text, caret: Math.max(at - 1, 0) };
|
|
3380
|
+
case "right":
|
|
3381
|
+
return { text, caret: Math.min(at + 1, chars.length) };
|
|
3382
|
+
case "wordleft":
|
|
3383
|
+
return { text, caret: wordStart(chars, at) };
|
|
3384
|
+
case "wordright":
|
|
3385
|
+
return { text, caret: wordEnd(chars, at) };
|
|
3386
|
+
case "linestart":
|
|
3387
|
+
return { text, caret: 0 };
|
|
3388
|
+
case "lineend":
|
|
3389
|
+
return { text, caret: chars.length };
|
|
3390
|
+
case "erase":
|
|
3391
|
+
return cut(chars, Math.max(at - 1, 0), at);
|
|
3392
|
+
case "delete":
|
|
3393
|
+
return cut(chars, at, Math.min(at + 1, chars.length));
|
|
3394
|
+
case "word":
|
|
3395
|
+
return cut(chars, spacedStart(chars, at), at);
|
|
3396
|
+
case "killword":
|
|
3397
|
+
return cut(chars, wordStart(chars, at), at);
|
|
3398
|
+
case "killnext":
|
|
3399
|
+
return cut(chars, at, wordEnd(chars, at));
|
|
3400
|
+
case "clear":
|
|
3401
|
+
return cut(chars, 0, at);
|
|
3402
|
+
case "killend":
|
|
3403
|
+
return cut(chars, at, chars.length);
|
|
3404
|
+
case "yank":
|
|
3405
|
+
return insert(chars, at, killed);
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
function visible({ text, caret }, room) {
|
|
3409
|
+
const chars = [...text];
|
|
3410
|
+
const at = Math.min(Math.max(caret, 0), chars.length);
|
|
3411
|
+
const cells = at === chars.length ? [...chars, " "] : chars;
|
|
3412
|
+
const widths = cells.map((char) => Bun.stringWidth(char));
|
|
3413
|
+
const width = (from, to) => widths.slice(from, to).reduce((sum, size) => sum + size, 0);
|
|
3414
|
+
const fits = (from, to) => (from > 0 ? 1 : 0) + width(from, to) + (to < cells.length ? 1 : 0) <= room;
|
|
3415
|
+
let start = at;
|
|
3416
|
+
let end = at + 1;
|
|
3417
|
+
while (start > 0 && fits(start - 1, end))
|
|
3418
|
+
start--;
|
|
3419
|
+
while (end < cells.length && fits(start, end + 1))
|
|
3420
|
+
end++;
|
|
3421
|
+
const left = start > 0 ? "\u2026" : "";
|
|
3422
|
+
const right = end < cells.length ? "\u2026" : "";
|
|
3423
|
+
return { before: left + chars.slice(start, at).join(""), at: chars[at], after: chars.slice(at + 1, end).join("") + right, column: left.length + width(start, at) };
|
|
3424
|
+
}
|
|
3425
|
+
var EDIT_KEYS, BACKWARD_KILLS, FORWARD_KILLS, WORD_CHARACTER, SPACE;
|
|
3426
|
+
var init_line = __esm(() => {
|
|
3427
|
+
EDIT_KEYS = new Set(["left", "right", "wordleft", "wordright", "linestart", "lineend", "erase", "delete", "word", "killword", "killnext", "clear", "killend", "yank"]);
|
|
3428
|
+
BACKWARD_KILLS = new Set(["word", "killword", "clear"]);
|
|
3429
|
+
FORWARD_KILLS = new Set(["killnext", "killend"]);
|
|
3430
|
+
WORD_CHARACTER = /[\p{L}\p{N}_]/u;
|
|
3431
|
+
SPACE = /\s/;
|
|
3432
|
+
});
|
|
3433
|
+
|
|
3253
3434
|
// ../kit/src/picker/score.ts
|
|
3254
3435
|
var BOUNDARY_AFTER, NONE;
|
|
3255
3436
|
var init_score = __esm(() => {
|
|
@@ -3283,6 +3464,8 @@ function parseKeys(input, paste = { active: false }, ctrls = []) {
|
|
|
3283
3464
|
}
|
|
3284
3465
|
var IS_CONTROL, PASTE_START = "\x1B[200~", PASTE_END = "\x1B[201~", KEY_SEQUENCES, MOUSE, WHEEL_LINES = 3, KEYS;
|
|
3285
3466
|
var init_state = __esm(() => {
|
|
3467
|
+
init_text2();
|
|
3468
|
+
init_line();
|
|
3286
3469
|
init_score();
|
|
3287
3470
|
IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
|
|
3288
3471
|
KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
@@ -3306,10 +3489,29 @@ var init_state = __esm(() => {
|
|
|
3306
3489
|
"\n": "enter",
|
|
3307
3490
|
"\x03": "cancel",
|
|
3308
3491
|
"\x1B": "cancel",
|
|
3492
|
+
"\x1B[D": "left",
|
|
3493
|
+
"\x1BOD": "left",
|
|
3494
|
+
"\x1B[C": "right",
|
|
3495
|
+
"\x1BOC": "right",
|
|
3496
|
+
"\x1B[1;5D": "wordleft",
|
|
3497
|
+
"\x1B[1;3D": "wordleft",
|
|
3498
|
+
"\x1Bb": "wordleft",
|
|
3499
|
+
"\x1B[1;5C": "wordright",
|
|
3500
|
+
"\x1B[1;3C": "wordright",
|
|
3501
|
+
"\x1Bf": "wordright",
|
|
3502
|
+
"\x01": "linestart",
|
|
3503
|
+
"\x05": "lineend",
|
|
3309
3504
|
"\x7F": "erase",
|
|
3310
|
-
"\
|
|
3505
|
+
"\x1B[3~": "delete",
|
|
3506
|
+
"\b": "killword",
|
|
3507
|
+
"\x1B\x7F": "killword",
|
|
3508
|
+
"\x1B[3;5~": "killnext",
|
|
3509
|
+
"\x1Bd": "killnext",
|
|
3311
3510
|
"\x15": "clear",
|
|
3511
|
+
"\v": "killend",
|
|
3312
3512
|
"\x17": "word",
|
|
3513
|
+
"\x19": "yank",
|
|
3514
|
+
"\x1A": "suspend",
|
|
3313
3515
|
"\t": "tab",
|
|
3314
3516
|
"\x1F": "help",
|
|
3315
3517
|
"\x1BOP": "help",
|
|
@@ -3317,10 +3519,31 @@ var init_state = __esm(() => {
|
|
|
3317
3519
|
};
|
|
3318
3520
|
});
|
|
3319
3521
|
|
|
3522
|
+
// ../kit/src/redraw.ts
|
|
3523
|
+
function overwrite(lines, columns) {
|
|
3524
|
+
return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
|
|
3525
|
+
`);
|
|
3526
|
+
}
|
|
3527
|
+
function rowsTaken(lines, columns) {
|
|
3528
|
+
return lines.reduce((rows, line) => rows + Math.max(1, Math.ceil(textWidth(line) / columns)), 0);
|
|
3529
|
+
}
|
|
3530
|
+
var SYNC_START = "\x1B[?2026h", SYNC_END = "\x1B[?2026l";
|
|
3531
|
+
var init_redraw = __esm(() => {
|
|
3532
|
+
init_format();
|
|
3533
|
+
});
|
|
3534
|
+
|
|
3320
3535
|
// ../kit/src/prompt.ts
|
|
3321
|
-
import
|
|
3536
|
+
import process22 from "process";
|
|
3322
3537
|
function readKeys(input, paste = { active: false }) {
|
|
3323
|
-
return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key));
|
|
3538
|
+
return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key) || isEditKey(key));
|
|
3539
|
+
}
|
|
3540
|
+
function roomAfter(question, columns) {
|
|
3541
|
+
return Math.max(columns - textWidth(`? ${question} `) % columns - 1, 1);
|
|
3542
|
+
}
|
|
3543
|
+
function withCaret(colors, line, room, dim = false) {
|
|
3544
|
+
const { before, at, after } = visible(line, room);
|
|
3545
|
+
const tone = dim ? colors.dim : (text) => text;
|
|
3546
|
+
return `${tone(before)}${at === undefined ? colors.dim("\u2588") : colors.inverse(at)}${tone(after)}`;
|
|
3324
3547
|
}
|
|
3325
3548
|
function flip(checked, value) {
|
|
3326
3549
|
const next = new Set(checked);
|
|
@@ -3332,7 +3555,7 @@ async function checklist(question, choices, { initial = new Set, min = 0, toggle
|
|
|
3332
3555
|
const list = new List(choices, 0);
|
|
3333
3556
|
let checked = initial;
|
|
3334
3557
|
let invalid;
|
|
3335
|
-
const accepted = await ask(question, settings, (colors, state, rows) => state === "asking" ? [asking(colors, question, list.
|
|
3558
|
+
const accepted = await ask(question, settings, (colors, state, rows) => state === "asking" ? [asking(colors, question, list.typed(colors, rows.columns, question), "type to filter, space toggles, enter accepts"), ...list.rows(colors, rows, (choice) => checked.has(choice.value) ? `${colors.cyan("\u25C9")} ` : `${colors.dim("\u25EF")} `), ...invalid === undefined ? [] : [` ${colors.red(invalid)}`]] : [answer(colors, question, state, choices.filter((choice) => checked.has(choice.value)).map((choice) => choice.label).join(", ") || "none")], (key) => {
|
|
3336
3559
|
if (key === "cancel")
|
|
3337
3560
|
return key;
|
|
3338
3561
|
invalid = undefined;
|
|
@@ -3370,7 +3593,7 @@ async function confirm(question, { default: fallback, ...settings } = {}) {
|
|
|
3370
3593
|
|
|
3371
3594
|
class List {
|
|
3372
3595
|
choices;
|
|
3373
|
-
|
|
3596
|
+
line = { text: "", caret: 0 };
|
|
3374
3597
|
matches;
|
|
3375
3598
|
cursor;
|
|
3376
3599
|
top = 0;
|
|
@@ -3385,6 +3608,8 @@ class List {
|
|
|
3385
3608
|
return this.matches[this.cursor];
|
|
3386
3609
|
}
|
|
3387
3610
|
press(key) {
|
|
3611
|
+
if (this.line.chained === true && endsKills(key))
|
|
3612
|
+
this.line = { ...this.line, chained: false };
|
|
3388
3613
|
if (key === "up" || key === "down") {
|
|
3389
3614
|
if (this.matches.length > 0)
|
|
3390
3615
|
this.cursor = (this.cursor + (key === "up" ? this.matches.length - 1 : 1)) % this.matches.length;
|
|
@@ -3396,15 +3621,19 @@ class List {
|
|
|
3396
3621
|
this.cursor = Math.max(0, Math.min(last, to));
|
|
3397
3622
|
return;
|
|
3398
3623
|
}
|
|
3399
|
-
if (key
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3624
|
+
if (typeof key !== "object" && !isEditKey(key))
|
|
3625
|
+
return;
|
|
3626
|
+
const edited = editLine(this.line, key);
|
|
3627
|
+
if (edited.text !== this.line.text)
|
|
3628
|
+
this.filter(edited.text);
|
|
3629
|
+
this.line = edited;
|
|
3630
|
+
}
|
|
3631
|
+
typed(colors, columns, question) {
|
|
3632
|
+
return this.line.text === "" ? "" : withCaret(colors, this.line, roomAfter(question, columns));
|
|
3403
3633
|
}
|
|
3404
3634
|
filter(query) {
|
|
3405
3635
|
const words = query.toLowerCase().split(WORDS2).filter((word) => word !== "");
|
|
3406
3636
|
const current = this.current();
|
|
3407
|
-
this.query = query;
|
|
3408
3637
|
this.matches = this.choices.filter(({ label, hint }) => words.every((word) => `${label} ${hint}`.toLowerCase().includes(word)));
|
|
3409
3638
|
this.cursor = current === undefined ? 0 : Math.max(this.matches.indexOf(current), 0);
|
|
3410
3639
|
this.top = 0;
|
|
@@ -3432,7 +3661,7 @@ function asking(colors, question, typed, keys) {
|
|
|
3432
3661
|
function answer(colors, question, state, picked) {
|
|
3433
3662
|
return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
|
|
3434
3663
|
}
|
|
3435
|
-
async function ask(question, { hint, terminal =
|
|
3664
|
+
async function ask(question, { hint, terminal = process22 }, render, press) {
|
|
3436
3665
|
const { stdin, stderr } = terminal;
|
|
3437
3666
|
if (!isInteractive(terminal))
|
|
3438
3667
|
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
@@ -3442,12 +3671,22 @@ async function ask(question, { hint, terminal = process20 }, render, press) {
|
|
|
3442
3671
|
const columns = () => stderr.columns || 80;
|
|
3443
3672
|
const draw = (state, last = false) => {
|
|
3444
3673
|
const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
|
|
3445
|
-
|
|
3446
|
-
|
|
3674
|
+
const rows = rowsTaken(frame, columns());
|
|
3675
|
+
stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || rows < 2 ? "" : `\x1B[${rows - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
|
|
3447
3676
|
current = state;
|
|
3448
3677
|
};
|
|
3449
3678
|
const redraw = () => draw(current);
|
|
3450
3679
|
const paste = { active: false };
|
|
3680
|
+
const stop = terminal.stop ?? (terminal === process22 ? stopJob : undefined);
|
|
3681
|
+
const suspend = () => {
|
|
3682
|
+
if (stop === undefined)
|
|
3683
|
+
return;
|
|
3684
|
+
stderr.write("\x1B[0J\x1B[?25h\x1B[?2004l");
|
|
3685
|
+
stdin.setRawMode(false);
|
|
3686
|
+
stop();
|
|
3687
|
+
stdin.setRawMode(true);
|
|
3688
|
+
stderr.write("\x1B[?25l\x1B[?2004h");
|
|
3689
|
+
};
|
|
3451
3690
|
try {
|
|
3452
3691
|
stderr.on?.("resize", redraw);
|
|
3453
3692
|
stdin.setRawMode(true);
|
|
@@ -3457,6 +3696,10 @@ async function ask(question, { hint, terminal = process20 }, render, press) {
|
|
|
3457
3696
|
return await new Promise((resolve) => {
|
|
3458
3697
|
function onData(data) {
|
|
3459
3698
|
for (const key of readKeys(data.toString(), paste)) {
|
|
3699
|
+
if (key === "suspend") {
|
|
3700
|
+
suspend();
|
|
3701
|
+
continue;
|
|
3702
|
+
}
|
|
3460
3703
|
const pressed = press(key);
|
|
3461
3704
|
if (pressed !== undefined) {
|
|
3462
3705
|
settle(pressed);
|
|
@@ -3488,13 +3731,17 @@ async function ask(question, { hint, terminal = process20 }, render, press) {
|
|
|
3488
3731
|
}
|
|
3489
3732
|
var WORDS2, MAX_ROWS = 10, PROMPT_KEYS;
|
|
3490
3733
|
var init_prompt = __esm(() => {
|
|
3734
|
+
init_answers();
|
|
3491
3735
|
init_args();
|
|
3492
3736
|
init_format();
|
|
3737
|
+
init_job();
|
|
3493
3738
|
init_mode();
|
|
3739
|
+
init_line();
|
|
3494
3740
|
init_state();
|
|
3741
|
+
init_redraw();
|
|
3495
3742
|
init_style();
|
|
3496
3743
|
WORDS2 = /\s+/;
|
|
3497
|
-
PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "
|
|
3744
|
+
PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "suspend", "tab"]);
|
|
3498
3745
|
});
|
|
3499
3746
|
|
|
3500
3747
|
// src/excluded.ts
|
|
@@ -3719,7 +3966,7 @@ async function choosePlan(name, version, settings, chooser = terminalChooser, ho
|
|
|
3719
3966
|
return { chosen: chosen.map((plan) => plan.dir), declined };
|
|
3720
3967
|
}
|
|
3721
3968
|
async function bump(args) {
|
|
3722
|
-
const { values, positionals: [name, asked] } = parse(args, usage5, options4, { positionals: ["<name>", "[version]"] });
|
|
3969
|
+
const { values, positionals: [name, asked] } = parse(args, usage5, options4, { exits: EXITS4, positionals: ["<name>", "[version]"] });
|
|
3723
3970
|
const settings = {
|
|
3724
3971
|
root: workspaceRoot({ given: values.root }),
|
|
3725
3972
|
configs: await loadConfigs(),
|
|
@@ -3752,9 +3999,7 @@ A version the vetting blocks is refused before any folder is touched, unless --f
|
|
|
3752
3999
|
A dependency declared through an alias of the package (\`"kay": "npm:@kaynooo/kayjs@~1.77.0"\`) is bumped under its own key, keeping the \`~\` or \`^\` of its range; --only and --except narrow the folders by name or glob (\`app\`, \`kay-*\`, a path relative to --root).
|
|
3753
4000
|
A dependency that is not a registry version (workspace:, link:, file:, git, a URL, an npm: alias of another package, catalog:), a peer range, a folder already on the version and one whose lockfile pins another manager are left as they are, each said so.
|
|
3754
4001
|
On a terminal with no --only or --except, a checklist asks which consumers to bump (those left out last time are unchecked, and what is unchecked is remembered in ~/.config/kaynooo-cli/pkg-excluded.json), then the plan is printed and confirmed; --yes skips both, as a pipe or --dry-run does.
|
|
3755
|
-
With --all-consumers a folder whose package.json or lockfile already has uncommitted changes is left alone, and each folder whose install went through then runs its own \`check\` (the check bin) and is committed with \`gc 'chore(deps): bump <name> to <version>' -- package.json <lockfile>\` only when that passes; a failing one is left uncommitted and listed in the summary with the skipped ones, and nothing is ever pushed
|
|
3756
|
-
|
|
3757
|
-
Exits 0 when every install ran or was left as it is (with --all-consumers, and every check passed and every commit landed), 1 when the vetting refuses the version, an install, a check or a commit fails or the registry has no such package, 2 when the version never shows within the timeout (a registry that cannot be reached is retried until then) or on a usage error.`, ROOT_OPTION, options4, POLL = 5000, terminalChooser;
|
|
4002
|
+
With --all-consumers a folder whose package.json or lockfile already has uncommitted changes is left alone, and each folder whose install went through then runs its own \`check\` (the check bin) and is committed with \`gc 'chore(deps): bump <name> to <version>' -- package.json <lockfile>\` only when that passes; a failing one is left uncommitted and listed in the summary with the skipped ones, and nothing is ever pushed.`, EXITS4, ROOT_OPTION, options4, POLL = 5000, terminalChooser;
|
|
3758
4003
|
var init_bump = __esm(() => {
|
|
3759
4004
|
init_src();
|
|
3760
4005
|
init_progress();
|
|
@@ -3766,6 +4011,7 @@ var init_bump = __esm(() => {
|
|
|
3766
4011
|
init_registry();
|
|
3767
4012
|
init_semver();
|
|
3768
4013
|
init_check();
|
|
4014
|
+
EXITS4 = [[0, "every install ran or was left as it is (with --all-consumers, and every check passed and every commit landed)"], [1, "the vetting refuses the version, an install, a check or a commit fails or the registry has no such package"], [2, "the version never shows within the timeout (a registry that cannot be reached is retried until then) or a usage error"]];
|
|
3769
4015
|
ROOT_OPTION = { type: "string", description: "the folder holding the repositories (the workspace of the user config or KAYNOOO_WORKSPACE, ~/Workspace by default)" };
|
|
3770
4016
|
options4 = {
|
|
3771
4017
|
root: ROOT_OPTION,
|
|
@@ -3790,7 +4036,7 @@ __export(exports_consumers, {
|
|
|
3790
4036
|
consumers: () => consumers
|
|
3791
4037
|
});
|
|
3792
4038
|
function consumers(args) {
|
|
3793
|
-
const { values, positionals: [name] } = parse(args, usage6, options5, { positionals: ["<name>"] });
|
|
4039
|
+
const { values, positionals: [name] } = parse(args, usage6, options5, { exits: EXITS5, positionals: ["<name>"] });
|
|
3794
4040
|
const root = workspaceRoot({ given: values.root });
|
|
3795
4041
|
const { shown, footer } = capped(findConsumers(name, root), limitOf(values, CONSUMERS_LIMIT));
|
|
3796
4042
|
if (values.json === true) {
|
|
@@ -3806,13 +4052,12 @@ function consumers(args) {
|
|
|
3806
4052
|
}
|
|
3807
4053
|
var usage6 = `pkg consumers <name>
|
|
3808
4054
|
|
|
3809
|
-
Lists the folders under --root whose package.json depends on the package, by its own name or through an \`npm:\` alias of it (the alias key is shown after the kind): the folder, the kind of dependency, the version it asks for and the manager its lockfile pins, 30 at most with the count of the rest after them (--limit <n>, --full for all; --json is never cut unless --limit is given)
|
|
3810
|
-
|
|
3811
|
-
Exits 0 when it listed them, 2 on a usage error.`, CONSUMERS_LIMIT = 30, options5;
|
|
4055
|
+
Lists the folders under --root whose package.json depends on the package, by its own name or through an \`npm:\` alias of it (the alias key is shown after the kind): the folder, the kind of dependency, the version it asks for and the manager its lockfile pins, 30 at most with the count of the rest after them (--limit <n>, --full for all; --json is never cut unless --limit is given).`, EXITS5, CONSUMERS_LIMIT = 30, options5;
|
|
3812
4056
|
var init_consumers2 = __esm(() => {
|
|
3813
4057
|
init_src();
|
|
3814
4058
|
init_consumers();
|
|
3815
4059
|
init_bump();
|
|
4060
|
+
EXITS5 = [[0, "it listed them"], [2, "a usage error"]];
|
|
3816
4061
|
options5 = {
|
|
3817
4062
|
root: ROOT_OPTION,
|
|
3818
4063
|
...limitOptions(CONSUMERS_LIMIT),
|
|
@@ -3857,16 +4102,17 @@ var exports_manager = {};
|
|
|
3857
4102
|
__export(exports_manager, {
|
|
3858
4103
|
manager: () => manager
|
|
3859
4104
|
});
|
|
3860
|
-
import
|
|
4105
|
+
import process23 from "process";
|
|
3861
4106
|
function manager(args) {
|
|
3862
4107
|
const { values, positionals } = parse(args, usage7, options6, {
|
|
4108
|
+
exits: EXITS6,
|
|
3863
4109
|
positionals: ["<action>"],
|
|
3864
4110
|
candidates: { "<action>": () => [...ACTIONS2] },
|
|
3865
4111
|
replaces: "telling bun, yarn, pnpm, npm, composer and uv apart by their lockfile before typing an add, remove or dlx",
|
|
3866
4112
|
examples: ["pkg manager dev", ["pkg manager exec", "bunx, npx, pnpm dlx... for this folder"]]
|
|
3867
4113
|
});
|
|
3868
4114
|
const action = oneOf(positionals[0] ?? "", "<action>", ACTIONS2);
|
|
3869
|
-
const found = detectManager(
|
|
4115
|
+
const found = detectManager(process23.cwd());
|
|
3870
4116
|
const command = commandFor(action, found);
|
|
3871
4117
|
if (values.json === true)
|
|
3872
4118
|
printJson({ manager: found, action, command });
|
|
@@ -3876,12 +4122,11 @@ function manager(args) {
|
|
|
3876
4122
|
}
|
|
3877
4123
|
var usage7 = `pkg manager <install|dev|remove|update|exec>
|
|
3878
4124
|
|
|
3879
|
-
Prints the command the package manager of this folder runs for the action: install is the add or install of a package, dev adds one as a dev dependency, remove drops one, update upgrades them and exec runs a package's bin without installing it. The manager is the one whose lockfile (bun.lock, bun.lockb, yarn.lock, pnpm-lock.yaml, package-lock.json, uv.lock) or composer.json is nearest, here or in a parent folder, bun when none is found
|
|
3880
|
-
|
|
3881
|
-
Exits 0 when it printed the command, 2 on a usage error.`, options6;
|
|
4125
|
+
Prints the command the package manager of this folder runs for the action: install is the add or install of a package, dev adds one as a dev dependency, remove drops one, update upgrades them and exec runs a package's bin without installing it. The manager is the one whose lockfile (bun.lock, bun.lockb, yarn.lock, pnpm-lock.yaml, package-lock.json, uv.lock) or composer.json is nearest, here or in a parent folder, bun when none is found.`, EXITS6, options6;
|
|
3882
4126
|
var init_manager2 = __esm(() => {
|
|
3883
4127
|
init_src();
|
|
3884
4128
|
init_manager();
|
|
4129
|
+
EXITS6 = [[0, "it printed the command"], [2, "a usage error"]];
|
|
3885
4130
|
options6 = {
|
|
3886
4131
|
json: jsonOption("{manager, action, command}")
|
|
3887
4132
|
};
|
|
@@ -3889,8 +4134,8 @@ var init_manager2 = __esm(() => {
|
|
|
3889
4134
|
|
|
3890
4135
|
// src/cli.ts
|
|
3891
4136
|
init_src();
|
|
3892
|
-
import
|
|
3893
|
-
|
|
4137
|
+
import process24 from "process";
|
|
4138
|
+
process24.exitCode = await runCli({
|
|
3894
4139
|
name: "pkg",
|
|
3895
4140
|
about: "checks npm packages before they are added, and moves a lib's consumers onto a new release",
|
|
3896
4141
|
replaces: "bun add on trust, and a bun info and sleep loop then a bun add per consumer",
|
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.16.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.
|
|
36
|
+
"@kaynooo/cli-kit": "0.40.0"
|
|
37
37
|
}
|
|
38
38
|
}
|