@kaynooo/cli-pkg 0.15.0 → 0.15.2
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 +24 -21
- 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";
|
|
@@ -1339,7 +1335,6 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1339
1335
|
header(colors, summary),
|
|
1340
1336
|
"",
|
|
1341
1337
|
usageLine(`${prefix} ${defaultCommand === undefined ? colors.cyan("<command>") : `[${colors.cyan("<command>")}]`} [options]`, colors),
|
|
1342
|
-
...replacesRows(replaces, colors),
|
|
1343
1338
|
"",
|
|
1344
1339
|
...await commandRows(commands, colors),
|
|
1345
1340
|
...own.length === 0 ? [] : ["", `${colors.bold(`Options of ${defaultCommand}:`)} ${colors.dim("the command run when none is named")}`, ...optionRows(Object.fromEntries(own), colors)],
|
|
@@ -3317,6 +3312,16 @@ var init_state = __esm(() => {
|
|
|
3317
3312
|
};
|
|
3318
3313
|
});
|
|
3319
3314
|
|
|
3315
|
+
// ../kit/src/redraw.ts
|
|
3316
|
+
function overwrite(lines, columns) {
|
|
3317
|
+
return lines.map((line) => textWidth(line) < columns ? `${line}\x1B[K` : `\x1B[2K${line}`).join(`
|
|
3318
|
+
`);
|
|
3319
|
+
}
|
|
3320
|
+
var SYNC_START = "\x1B[?2026h", SYNC_END = "\x1B[?2026l";
|
|
3321
|
+
var init_redraw = __esm(() => {
|
|
3322
|
+
init_format();
|
|
3323
|
+
});
|
|
3324
|
+
|
|
3320
3325
|
// ../kit/src/prompt.ts
|
|
3321
3326
|
import process20 from "process";
|
|
3322
3327
|
function readKeys(input, paste = { active: false }) {
|
|
@@ -3442,8 +3447,7 @@ async function ask(question, { hint, terminal = process20 }, render, press) {
|
|
|
3442
3447
|
const columns = () => stderr.columns || 80;
|
|
3443
3448
|
const draw = (state, last = false) => {
|
|
3444
3449
|
const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
|
|
3445
|
-
stderr.write(
|
|
3446
|
-
`)}${last || frame.length < 2 ? "" : `\x1B[${frame.length - 1}A`}${last ? "" : "\r"}`);
|
|
3450
|
+
stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || frame.length < 2 ? "" : `\x1B[${frame.length - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
|
|
3447
3451
|
current = state;
|
|
3448
3452
|
};
|
|
3449
3453
|
const redraw = () => draw(current);
|
|
@@ -3492,6 +3496,7 @@ var init_prompt = __esm(() => {
|
|
|
3492
3496
|
init_format();
|
|
3493
3497
|
init_mode();
|
|
3494
3498
|
init_state();
|
|
3499
|
+
init_redraw();
|
|
3495
3500
|
init_style();
|
|
3496
3501
|
WORDS2 = /\s+/;
|
|
3497
3502
|
PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "erase"]);
|
|
@@ -3719,7 +3724,7 @@ async function choosePlan(name, version, settings, chooser = terminalChooser, ho
|
|
|
3719
3724
|
return { chosen: chosen.map((plan) => plan.dir), declined };
|
|
3720
3725
|
}
|
|
3721
3726
|
async function bump(args) {
|
|
3722
|
-
const { values, positionals: [name, asked] } = parse(args, usage5, options4, { positionals: ["<name>", "[version]"] });
|
|
3727
|
+
const { values, positionals: [name, asked] } = parse(args, usage5, options4, { exits: EXITS4, positionals: ["<name>", "[version]"] });
|
|
3723
3728
|
const settings = {
|
|
3724
3729
|
root: workspaceRoot({ given: values.root }),
|
|
3725
3730
|
configs: await loadConfigs(),
|
|
@@ -3752,9 +3757,7 @@ A version the vetting blocks is refused before any folder is touched, unless --f
|
|
|
3752
3757
|
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
3758
|
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
3759
|
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;
|
|
3760
|
+
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
3761
|
var init_bump = __esm(() => {
|
|
3759
3762
|
init_src();
|
|
3760
3763
|
init_progress();
|
|
@@ -3766,6 +3769,7 @@ var init_bump = __esm(() => {
|
|
|
3766
3769
|
init_registry();
|
|
3767
3770
|
init_semver();
|
|
3768
3771
|
init_check();
|
|
3772
|
+
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
3773
|
ROOT_OPTION = { type: "string", description: "the folder holding the repositories (the workspace of the user config or KAYNOOO_WORKSPACE, ~/Workspace by default)" };
|
|
3770
3774
|
options4 = {
|
|
3771
3775
|
root: ROOT_OPTION,
|
|
@@ -3790,7 +3794,7 @@ __export(exports_consumers, {
|
|
|
3790
3794
|
consumers: () => consumers
|
|
3791
3795
|
});
|
|
3792
3796
|
function consumers(args) {
|
|
3793
|
-
const { values, positionals: [name] } = parse(args, usage6, options5, { positionals: ["<name>"] });
|
|
3797
|
+
const { values, positionals: [name] } = parse(args, usage6, options5, { exits: EXITS5, positionals: ["<name>"] });
|
|
3794
3798
|
const root = workspaceRoot({ given: values.root });
|
|
3795
3799
|
const { shown, footer } = capped(findConsumers(name, root), limitOf(values, CONSUMERS_LIMIT));
|
|
3796
3800
|
if (values.json === true) {
|
|
@@ -3806,13 +3810,12 @@ function consumers(args) {
|
|
|
3806
3810
|
}
|
|
3807
3811
|
var usage6 = `pkg consumers <name>
|
|
3808
3812
|
|
|
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;
|
|
3813
|
+
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
3814
|
var init_consumers2 = __esm(() => {
|
|
3813
3815
|
init_src();
|
|
3814
3816
|
init_consumers();
|
|
3815
3817
|
init_bump();
|
|
3818
|
+
EXITS5 = [[0, "it listed them"], [2, "a usage error"]];
|
|
3816
3819
|
options5 = {
|
|
3817
3820
|
root: ROOT_OPTION,
|
|
3818
3821
|
...limitOptions(CONSUMERS_LIMIT),
|
|
@@ -3860,6 +3863,7 @@ __export(exports_manager, {
|
|
|
3860
3863
|
import process21 from "process";
|
|
3861
3864
|
function manager(args) {
|
|
3862
3865
|
const { values, positionals } = parse(args, usage7, options6, {
|
|
3866
|
+
exits: EXITS6,
|
|
3863
3867
|
positionals: ["<action>"],
|
|
3864
3868
|
candidates: { "<action>": () => [...ACTIONS2] },
|
|
3865
3869
|
replaces: "telling bun, yarn, pnpm, npm, composer and uv apart by their lockfile before typing an add, remove or dlx",
|
|
@@ -3876,12 +3880,11 @@ function manager(args) {
|
|
|
3876
3880
|
}
|
|
3877
3881
|
var usage7 = `pkg manager <install|dev|remove|update|exec>
|
|
3878
3882
|
|
|
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;
|
|
3883
|
+
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
3884
|
var init_manager2 = __esm(() => {
|
|
3883
3885
|
init_src();
|
|
3884
3886
|
init_manager();
|
|
3887
|
+
EXITS6 = [[0, "it printed the command"], [2, "a usage error"]];
|
|
3885
3888
|
options6 = {
|
|
3886
3889
|
json: jsonOption("{manager, action, command}")
|
|
3887
3890
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-pkg",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.2",
|
|
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.4"
|
|
37
37
|
}
|
|
38
38
|
}
|