@kaynooo/cli-pkg 0.16.0 → 0.16.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/dist/cli.js +85 -7
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -902,7 +902,7 @@ var init_args = __esm(() => {
|
|
|
902
902
|
};
|
|
903
903
|
completion = { active: false };
|
|
904
904
|
OUTPUT_OPTIONS = {
|
|
905
|
-
color: { type: "string", description: "auto (on a terminal alone
|
|
905
|
+
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
906
906
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
907
907
|
};
|
|
908
908
|
UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
@@ -1227,6 +1227,66 @@ var init_ci = __esm(() => {
|
|
|
1227
1227
|
init_tool();
|
|
1228
1228
|
});
|
|
1229
1229
|
|
|
1230
|
+
// ../kit/src/completions.ts
|
|
1231
|
+
function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
|
|
1232
|
+
if (shell === "fish")
|
|
1233
|
+
return `${header}
|
|
1234
|
+
${FISH_FUNCTION}
|
|
1235
|
+
${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
|
|
1236
|
+
`).join("")}`;
|
|
1237
|
+
if (shell === "bash")
|
|
1238
|
+
return `${header}
|
|
1239
|
+
${BASH_FUNCTION}
|
|
1240
|
+
complete -F __kaynooo_cli_complete ${bins.join(" ")}
|
|
1241
|
+
`;
|
|
1242
|
+
return `${header}
|
|
1243
|
+
${ZSH_FUNCTION}
|
|
1244
|
+
compdef __kaynooo_cli_complete ${bins.join(" ")}
|
|
1245
|
+
`;
|
|
1246
|
+
}
|
|
1247
|
+
var COMPLETION_SHELLS, FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
|
|
1248
|
+
set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
|
|
1249
|
+
set -l current (commandline -ct)
|
|
1250
|
+
for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
|
|
1251
|
+
if test "$line" = __files__
|
|
1252
|
+
__fish_complete_path $current
|
|
1253
|
+
else
|
|
1254
|
+
echo $line
|
|
1255
|
+
end
|
|
1256
|
+
end
|
|
1257
|
+
end`, BASH_FUNCTION = `__kaynooo_cli_complete() {
|
|
1258
|
+
local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
|
|
1259
|
+
local -a lines
|
|
1260
|
+
COMPREPLY=()
|
|
1261
|
+
lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
|
|
1262
|
+
for line in "\${lines[@]}"; do
|
|
1263
|
+
if [[ $line == __files__ ]]; then
|
|
1264
|
+
COMPREPLY+=($(compgen -f -- "$cur"))
|
|
1265
|
+
else
|
|
1266
|
+
words+="\${line%%$'\\t'*}"$'\\n'
|
|
1267
|
+
fi
|
|
1268
|
+
done
|
|
1269
|
+
COMPREPLY+=($(compgen -W "$words" -- "$cur"))
|
|
1270
|
+
}`, ZSH_FUNCTION = `__kaynooo_cli_complete() {
|
|
1271
|
+
local line
|
|
1272
|
+
local -a described plain
|
|
1273
|
+
for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
|
|
1274
|
+
if [[ $line == __files__ ]]; then
|
|
1275
|
+
_files
|
|
1276
|
+
elif [[ $line == *$'\\t'* ]]; then
|
|
1277
|
+
described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
|
|
1278
|
+
else
|
|
1279
|
+
plain+=("$line")
|
|
1280
|
+
fi
|
|
1281
|
+
done
|
|
1282
|
+
(( \${#described} )) && _describe -V value described
|
|
1283
|
+
(( \${#plain} )) && compadd -- "\${plain[@]}"
|
|
1284
|
+
return 0
|
|
1285
|
+
}`;
|
|
1286
|
+
var init_completions = __esm(() => {
|
|
1287
|
+
COMPLETION_SHELLS = ["fish", "bash", "zsh"];
|
|
1288
|
+
});
|
|
1289
|
+
|
|
1230
1290
|
// ../kit/src/notify.ts
|
|
1231
1291
|
import process14 from "process";
|
|
1232
1292
|
function base64(text) {
|
|
@@ -1534,6 +1594,18 @@ async function candidates(scope, defaultCommand, words, before = []) {
|
|
|
1534
1594
|
}
|
|
1535
1595
|
return "commands" in command ? candidates(scopeOf(command.commands, command.extraCommands, command.aliases), undefined, rest, [...before, word]) : leafCandidates(command.run, rest);
|
|
1536
1596
|
}
|
|
1597
|
+
function flagValue([flag = "", ...rest]) {
|
|
1598
|
+
return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
|
|
1599
|
+
}
|
|
1600
|
+
function printCompletionScript(name, args) {
|
|
1601
|
+
const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
|
|
1602
|
+
if (shell === undefined || args.length !== 1) {
|
|
1603
|
+
printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
|
|
1604
|
+
return 2;
|
|
1605
|
+
}
|
|
1606
|
+
console.log(completionScript(shell, [name]).trimEnd());
|
|
1607
|
+
return 0;
|
|
1608
|
+
}
|
|
1537
1609
|
async function printCandidates(found) {
|
|
1538
1610
|
for (const line of await found)
|
|
1539
1611
|
console.log(line);
|
|
@@ -1558,6 +1630,8 @@ async function runCli(cli, argv = scriptArgs()) {
|
|
|
1558
1630
|
const version = cli.version ?? packageVersion();
|
|
1559
1631
|
if (argv[0] === COMPLETE)
|
|
1560
1632
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
1633
|
+
if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
|
|
1634
|
+
return printCompletionScript(cli.name, flagValue(argv));
|
|
1561
1635
|
const started = performance.now();
|
|
1562
1636
|
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
1637
|
const command = commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv);
|
|
@@ -1584,10 +1658,11 @@ function commandPath(scope, argv) {
|
|
|
1584
1658
|
}
|
|
1585
1659
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1586
1660
|
}
|
|
1587
|
-
var LEVEL_OPTIONS, TOP_OPTIONS, COMPLETE = "__complete", FILES = "__files__";
|
|
1661
|
+
var LEVEL_OPTIONS, TOP_OPTIONS, COMPLETE = "__complete", FILES = "__files__", COMPLETIONS = "--completions";
|
|
1588
1662
|
var init_cli = __esm(() => {
|
|
1589
1663
|
init_args();
|
|
1590
1664
|
init_argv();
|
|
1665
|
+
init_completions();
|
|
1591
1666
|
init_notify();
|
|
1592
1667
|
init_style();
|
|
1593
1668
|
init_text2();
|
|
@@ -1596,7 +1671,11 @@ var init_cli = __esm(() => {
|
|
|
1596
1671
|
...OUTPUT_OPTIONS,
|
|
1597
1672
|
help: { type: "boolean", short: "h", description: "show this help" }
|
|
1598
1673
|
};
|
|
1599
|
-
TOP_OPTIONS = {
|
|
1674
|
+
TOP_OPTIONS = {
|
|
1675
|
+
...LEVEL_OPTIONS,
|
|
1676
|
+
version: { type: "boolean", short: "v", description: "print the version" },
|
|
1677
|
+
completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
|
|
1678
|
+
};
|
|
1600
1679
|
});
|
|
1601
1680
|
// ../kit/src/excerpt.ts
|
|
1602
1681
|
var init_excerpt = __esm(() => {
|
|
@@ -1721,6 +1800,7 @@ var init_src = __esm(() => {
|
|
|
1721
1800
|
init_chart();
|
|
1722
1801
|
init_ci();
|
|
1723
1802
|
init_cli();
|
|
1803
|
+
init_completions();
|
|
1724
1804
|
init_config();
|
|
1725
1805
|
init_folders();
|
|
1726
1806
|
init_format();
|
|
@@ -3172,9 +3252,7 @@ function renderAudit(findings, total, stream = process20.stdout, env = process20
|
|
|
3172
3252
|
}
|
|
3173
3253
|
async function audit(args) {
|
|
3174
3254
|
const { values, positionals: [asked] } = parse(args, usage3, options2, { positionals: ["[dir]"], exits: EXITS2 });
|
|
3175
|
-
const level = values
|
|
3176
|
-
if (!isSeverity(level))
|
|
3177
|
-
fail(`--level takes ${SEVERITIES.join(", ")}, not ${level}`);
|
|
3255
|
+
const { level } = values;
|
|
3178
3256
|
const dir = resolve6(asked ?? process20.cwd());
|
|
3179
3257
|
const lock = Bun.file(join9(dir, "bun.lock"));
|
|
3180
3258
|
if (!await lock.exists())
|
|
@@ -3218,7 +3296,7 @@ var init_audit = __esm(() => {
|
|
|
3218
3296
|
options2 = {
|
|
3219
3297
|
json: jsonOption("[{name, version, license, blocked, warnings, advisories}] for the packages with a finding"),
|
|
3220
3298
|
"min-age": { type: "string", description: `days a version must be old (${DEFAULT_MIN_AGE_DAYS}, or the minAge setting)` },
|
|
3221
|
-
level: { type: "string", description: "lowest advisory severity listed and failing
|
|
3299
|
+
level: { type: "string", choices: SEVERITIES, default: "moderate", description: "lowest advisory severity listed and failing (moderate)" },
|
|
3222
3300
|
prod: { type: "boolean", description: "only the packages a production dependency or an optional one of a workspace reaches" },
|
|
3223
3301
|
ignore: { type: "string", multiple: true, description: "an advisory skipped by GHSA or numeric id, repeatable" }
|
|
3224
3302
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-pkg",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.1",
|
|
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.41.0"
|
|
37
37
|
}
|
|
38
38
|
}
|