@kaynooo/cli-pkg 0.13.1 → 0.13.3
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/README.md +2 -1
- package/dist/cli.js +69 -51
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ pkg outdated
|
|
|
29
29
|
|
|
30
30
|
- `licenses` is the allowlist of SPDX ids, compared without regard to case. An expression is allowed when one side of an `OR` is and every term of an `AND` is; a `WITH` exception is ignored. With an allowlist set, `pkg check` refuses a package whose licence is outside it or missing (a legacy `SEE LICENSE IN` or `UNLICENSED` counts as outside), so the `bun add` the guard checks through `pkg check` is refused with it. Without the key the licence is only printed.
|
|
31
31
|
- `minAge` (a whole number of days, 14 when no config sets it) is how old a version must be when `--min-age` is not given, in `check`, `audit` and `outdated`.
|
|
32
|
+
- `concurrency` (a positive whole number, 8 when no config sets it) is how many registry lookups `audit` and `outdated` run at once.
|
|
32
33
|
- `blockSeverity` (`low`, `moderate`, `high` or `critical`, `high` when no config sets it) makes `pkg check` ask the registry for the advisories of the exact `name@version` and refuse it when one is at that severity or above. The request is the one `bun audit` makes: a `POST` of `{"name": ["version"]}` to `<registry>/-/npm/v1/security/advisories/bulk`. A registry without that endpoint (a private one, say) leaves the version unrefused with a warning, while an advisory request that fails (unreachable, a 5xx, not JSON) exits 2, since the advisories could not be read.
|
|
33
34
|
|
|
34
35
|
## Auditing a lockfile
|
|
@@ -55,7 +56,7 @@ pkg consumers @kaynooo/cli-kit
|
|
|
55
56
|
pkg bump @kaynooo/cli-kit 0.8.0 --dry-run
|
|
56
57
|
```
|
|
57
58
|
|
|
58
|
-
- `pkg consumers <name>` lists every `package.json` under `--root` (the configured workspace folder, `~/Workspace` by default) depending on the package, `node_modules`, `dist`, `build`, `vendor`, `target`, `coverage` and dot folders left out and nothing deeper than 5 levels below `--root` (point `--root` at the folder to reach further): the folder, the kind of dependency, the version it asks for and the manager its nearest lockfile pins; `--json` for the rows.
|
|
59
|
+
- `pkg consumers <name>` lists every `package.json` under `--root` (the configured workspace folder, `~/Workspace` by default) depending on the package, `node_modules`, `dist`, `build`, `vendor`, `target`, `coverage`, the names in the `ignore` array of `~/.config/kaynooo-cli/config.json` and dot folders left out and nothing deeper than 5 levels below `--root` (point `--root` at the folder to reach further): the folder, the kind of dependency, the version it asks for and the manager its nearest lockfile pins; `--json` for the rows.
|
|
59
60
|
- `pkg bump <name> [version]` waits until the package's registry serves the version (every 5 s, `-t 10m`; the latest when none is given, an exact version otherwise, never a range or a tag), then vets it with the checks of `pkg check` (advisories, licence allowlist) before any folder is touched, and runs `bun add --exact --no-cache <name>@<version>` in each of those folders, one after another, as the same kind of dependency (`--dev`, `--optional`), a line per folder. A version the vetting blocks is refused with its reasons and exit 1; `--force` bumps it anyway. A bump adopts a release on purpose, often one just made, so it checks no minimum age unless `--min-age <days>` asks for one. A dependency declared through an alias of the package (`"kay": "npm:@scope/name@~1.2.0"`) is found and bumped under its own key, keeping its `~` or `^`; `--only <name|glob>` and `--except <name|glob>` (repeatable) narrow the folders, and a package nothing depends on names similar dependencies. A dependency that is not a registry version (`workspace:`, `link:`, `file:`, `git`, a URL, another package's `npm:` alias, `catalog:`), a `peerDependencies` range, a folder already on the version and one whose lockfile pins another manager are left alone and said so; `--dry-run` prints what would run. On a terminal with no `--only` or `--except`, a checklist asks which consumers to bump (the ones left out last time unchecked, what is unchecked now remembered in `~/.config/kaynooo-cli/pkg-excluded.json`), then the plan is printed and confirmed; `--yes` skips both, as a pipe does. A transient registry error is retried until the timeout. It exits 1 when the vetting refuses the version, an install fails or the registry has no such package (at once, without waiting), 2 when the version never shows within the timeout.
|
|
60
61
|
- `pkg bump <name> [version] --all-consumers` leaves alone a folder whose `package.json` or lockfile already has uncommitted changes, so that `gc` never commits them as the bump, and goes on in each folder whose install went through: it runs the folder's own `check` and, only when that passes, commits with `gc 'chore(deps): bump <name> to <version>' -- package.json <lockfile>` (the `bun.lock` or `bun.lockb` nearest the folder, a monorepo's at its root). A folder whose check fails stays uncommitted. It ends on a summary line of the folders bumped and committed, bumped and failing, and skipped, exits 1 when an install, a check or a commit failed, and never pushes. With `--dry-run` it lists the `bun add`, `check` and `gc` each folder would run.
|
|
61
62
|
- `pkg <name>` alone still runs `pkg check`.
|
package/dist/cli.js
CHANGED
|
@@ -189,7 +189,7 @@ var init_config = __esm(() => {
|
|
|
189
189
|
});
|
|
190
190
|
|
|
191
191
|
// ../kit/src/user-config.ts
|
|
192
|
-
import { existsSync as existsSync2 } from "fs";
|
|
192
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
193
193
|
import { homedir } from "os";
|
|
194
194
|
import { join as join2 } from "path";
|
|
195
195
|
import process4 from "process";
|
|
@@ -207,10 +207,21 @@ function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
|
207
207
|
const base = configBase(where);
|
|
208
208
|
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
209
209
|
}
|
|
210
|
+
function readUserConfig(bin, where = {}, legacy = []) {
|
|
211
|
+
const path = userConfigReadPath(bin, legacy, where);
|
|
212
|
+
if (!existsSync2(path))
|
|
213
|
+
return {};
|
|
214
|
+
try {
|
|
215
|
+
const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
|
|
216
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
217
|
+
} catch {
|
|
218
|
+
return {};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
210
221
|
var init_user_config = () => {};
|
|
211
222
|
|
|
212
223
|
// ../kit/src/theme.ts
|
|
213
|
-
import { existsSync as existsSync3, readFileSync, statSync } from "fs";
|
|
224
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
214
225
|
import { homedir as homedir2 } from "os";
|
|
215
226
|
import { join as join3, resolve as resolve2 } from "path";
|
|
216
227
|
import process5 from "process";
|
|
@@ -255,7 +266,7 @@ function readThemeFile(path, warn) {
|
|
|
255
266
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
256
267
|
return;
|
|
257
268
|
}
|
|
258
|
-
const parsed = JSON.parse(
|
|
269
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
259
270
|
if (isRecord(parsed))
|
|
260
271
|
return parsed;
|
|
261
272
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -1033,13 +1044,15 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
|
1033
1044
|
} };
|
|
1034
1045
|
const write = stream.write.bind(stream);
|
|
1035
1046
|
let frame = 0;
|
|
1036
|
-
let drawn =
|
|
1037
|
-
const columns = () =>
|
|
1038
|
-
|
|
1047
|
+
let drawn = false;
|
|
1048
|
+
const columns = () => {
|
|
1049
|
+
const now = stream.getWindowSize?.()[0] ?? stream.columns;
|
|
1050
|
+
return now === undefined || now === 0 ? 80 : now;
|
|
1051
|
+
};
|
|
1039
1052
|
const clear = () => {
|
|
1040
|
-
if (drawn
|
|
1041
|
-
write(
|
|
1042
|
-
drawn =
|
|
1053
|
+
if (drawn)
|
|
1054
|
+
write(CLEAR_BELOW);
|
|
1055
|
+
drawn = false;
|
|
1043
1056
|
};
|
|
1044
1057
|
const draw = () => {
|
|
1045
1058
|
const width = columns() - 1;
|
|
@@ -1049,9 +1062,9 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
|
1049
1062
|
clear();
|
|
1050
1063
|
return;
|
|
1051
1064
|
}
|
|
1052
|
-
write(`${
|
|
1053
|
-
`)}`);
|
|
1054
|
-
drawn =
|
|
1065
|
+
write(`${CLEAR_BELOW}${lines.join(`
|
|
1066
|
+
`)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
|
|
1067
|
+
drawn = true;
|
|
1055
1068
|
};
|
|
1056
1069
|
const timer = setInterval(draw, FRAME_MS);
|
|
1057
1070
|
stream.on?.("resize", draw);
|
|
@@ -1151,7 +1164,7 @@ function interceptOutput(clear) {
|
|
|
1151
1164
|
}
|
|
1152
1165
|
};
|
|
1153
1166
|
}
|
|
1154
|
-
var FRAMES, FRAME_MS = 200,
|
|
1167
|
+
var FRAMES, FRAME_MS = 200, CLEAR_BELOW = "\r\x1B[J", ESC, ESCAPE_CODE, RESET_STYLE, CTRL_C = 3, CLOSE_LINK, CONSOLE_METHODS;
|
|
1155
1168
|
var init_progress = __esm(() => {
|
|
1156
1169
|
init_format();
|
|
1157
1170
|
init_process();
|
|
@@ -1233,7 +1246,7 @@ var init_usage = __esm(() => {
|
|
|
1233
1246
|
});
|
|
1234
1247
|
|
|
1235
1248
|
// ../kit/src/cli.ts
|
|
1236
|
-
import { readFileSync as
|
|
1249
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
1237
1250
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1238
1251
|
import process14 from "process";
|
|
1239
1252
|
async function commandRows(all, colors) {
|
|
@@ -1475,7 +1488,7 @@ async function printCandidates(found) {
|
|
|
1475
1488
|
function packageVersion(entry = Bun.main) {
|
|
1476
1489
|
for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
|
|
1477
1490
|
try {
|
|
1478
|
-
const { version } = JSON.parse(
|
|
1491
|
+
const { version } = JSON.parse(readFileSync3(join5(dir, "package.json"), "utf8"));
|
|
1479
1492
|
if (typeof version === "string")
|
|
1480
1493
|
return version;
|
|
1481
1494
|
} catch {}
|
|
@@ -1523,8 +1536,14 @@ var init_cli = __esm(() => {
|
|
|
1523
1536
|
TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
1524
1537
|
});
|
|
1525
1538
|
// ../kit/src/folders.ts
|
|
1539
|
+
function ignoredFolders(extra = [], where = {}) {
|
|
1540
|
+
const configured = readUserConfig("config", where).ignore;
|
|
1541
|
+
const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
|
|
1542
|
+
return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
|
|
1543
|
+
}
|
|
1526
1544
|
var SKIPPED_FOLDERS;
|
|
1527
1545
|
var init_folders = __esm(() => {
|
|
1546
|
+
init_user_config();
|
|
1528
1547
|
SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1529
1548
|
});
|
|
1530
1549
|
|
|
@@ -1605,7 +1624,6 @@ var init_watch = __esm(() => {
|
|
|
1605
1624
|
});
|
|
1606
1625
|
|
|
1607
1626
|
// ../kit/src/workspace-root.ts
|
|
1608
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
1609
1627
|
import { homedir as homedir4 } from "os";
|
|
1610
1628
|
import { dirname as dirname4, join as join6, resolve as resolve3 } from "path";
|
|
1611
1629
|
import process15 from "process";
|
|
@@ -1615,16 +1633,8 @@ function expandHome(path, home) {
|
|
|
1615
1633
|
return path.startsWith("~/") ? join6(home, path.slice(2)) : path;
|
|
1616
1634
|
}
|
|
1617
1635
|
function configured(env, home) {
|
|
1618
|
-
const
|
|
1619
|
-
|
|
1620
|
-
return;
|
|
1621
|
-
try {
|
|
1622
|
-
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
1623
|
-
const folder = typeof parsed === "object" && parsed !== null ? parsed.workspace : undefined;
|
|
1624
|
-
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1625
|
-
} catch {
|
|
1626
|
-
return;
|
|
1627
|
-
}
|
|
1636
|
+
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
1637
|
+
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1628
1638
|
}
|
|
1629
1639
|
function workspaceRoot({ given, env = process15.env, home = homedir4() } = {}) {
|
|
1630
1640
|
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
@@ -2620,6 +2630,8 @@ function parseSettings(text) {
|
|
|
2620
2630
|
settings.blockSeverity = raw.blockSeverity;
|
|
2621
2631
|
if (typeof raw?.minAge === "number" && Number.isInteger(raw.minAge) && raw.minAge >= 0)
|
|
2622
2632
|
settings.minAge = raw.minAge;
|
|
2633
|
+
if (typeof raw?.concurrency === "number" && Number.isInteger(raw.concurrency) && raw.concurrency > 0)
|
|
2634
|
+
settings.concurrency = raw.concurrency;
|
|
2623
2635
|
return settings;
|
|
2624
2636
|
}
|
|
2625
2637
|
async function loadSettings(cwd = process17.cwd(), home) {
|
|
@@ -2636,6 +2648,7 @@ async function loadSettings(cwd = process17.cwd(), home) {
|
|
|
2636
2648
|
settings.licenses ??= found.licenses;
|
|
2637
2649
|
settings.blockSeverity ??= found.blockSeverity;
|
|
2638
2650
|
settings.minAge ??= found.minAge;
|
|
2651
|
+
settings.concurrency ??= found.concurrency;
|
|
2639
2652
|
}
|
|
2640
2653
|
return settings;
|
|
2641
2654
|
}
|
|
@@ -2738,9 +2751,9 @@ var init_pin = __esm(() => {
|
|
|
2738
2751
|
});
|
|
2739
2752
|
|
|
2740
2753
|
// src/consumers.ts
|
|
2741
|
-
import { existsSync as
|
|
2754
|
+
import { existsSync as existsSync4, readdirSync, readFileSync as readFileSync4 } from "fs";
|
|
2742
2755
|
import { dirname as dirname6, join as join8, relative } from "path";
|
|
2743
|
-
function packageFiles(dir, depth, found) {
|
|
2756
|
+
function packageFiles(dir, depth, found, ignored = ignoredFolders()) {
|
|
2744
2757
|
let entries;
|
|
2745
2758
|
try {
|
|
2746
2759
|
entries = readdirSync(dir, { withFileTypes: true });
|
|
@@ -2750,14 +2763,14 @@ function packageFiles(dir, depth, found) {
|
|
|
2750
2763
|
for (const entry of entries) {
|
|
2751
2764
|
if (entry.isFile() && entry.name === "package.json")
|
|
2752
2765
|
found.push(join8(dir, entry.name));
|
|
2753
|
-
else if (entry.isDirectory() && depth < MAX_DEPTH && !entry.name.startsWith(".") && !
|
|
2754
|
-
packageFiles(join8(dir, entry.name), depth + 1, found);
|
|
2766
|
+
else if (entry.isDirectory() && depth < MAX_DEPTH && !entry.name.startsWith(".") && !ignored.has(entry.name))
|
|
2767
|
+
packageFiles(join8(dir, entry.name), depth + 1, found, ignored);
|
|
2755
2768
|
}
|
|
2756
2769
|
return found;
|
|
2757
2770
|
}
|
|
2758
2771
|
function managerFor(dir, root) {
|
|
2759
2772
|
for (let at = dir;; at = dirname6(at)) {
|
|
2760
|
-
const lockfile = LOCKFILES.find(([file]) =>
|
|
2773
|
+
const lockfile = LOCKFILES.find(([file]) => existsSync4(join8(at, file)));
|
|
2761
2774
|
if (lockfile !== undefined)
|
|
2762
2775
|
return lockfile[1];
|
|
2763
2776
|
if (at === root || at === dirname6(at))
|
|
@@ -3022,7 +3035,7 @@ async function auditPackages(packages, context) {
|
|
|
3022
3035
|
packuments.set(key, fetchPackument(name, registry, context.fetcher));
|
|
3023
3036
|
return packuments.get(key);
|
|
3024
3037
|
};
|
|
3025
|
-
const looked = await pool(packages, BATCH, async ({ name, version }) => {
|
|
3038
|
+
const looked = await pool(packages, context.settings.concurrency ?? BATCH, async ({ name, version }) => {
|
|
3026
3039
|
const registry = registryFor(name, context.configs);
|
|
3027
3040
|
const input = { spec: { name, request: version }, packument: await lookup(name, registry), registry: new URL(registry.url).host, now: context.now, minAgeDays: context.minAgeDays, licenses: context.settings.licenses };
|
|
3028
3041
|
return { name, version, registry, input, safe: analyze(input).safe?.version };
|
|
@@ -3120,7 +3133,7 @@ var exports_outdated = {};
|
|
|
3120
3133
|
__export(exports_outdated, {
|
|
3121
3134
|
outdatedCommand: () => outdatedCommand
|
|
3122
3135
|
});
|
|
3123
|
-
import { existsSync as
|
|
3136
|
+
import { existsSync as existsSync5 } from "fs";
|
|
3124
3137
|
import { join as join10, resolve as resolve6 } from "path";
|
|
3125
3138
|
function currentOf(name, spec, locked) {
|
|
3126
3139
|
const pinned = locked.filter((each) => each.name === name && Bun.semver.satisfies(each.version, spec)).map((each) => each.version).sort(Bun.semver.order).at(-1);
|
|
@@ -3136,7 +3149,7 @@ function changeOf(current, next) {
|
|
|
3136
3149
|
async function outdated(manifest, context) {
|
|
3137
3150
|
const configs = await loadConfigs();
|
|
3138
3151
|
const dependencies = registryDependencies(manifest);
|
|
3139
|
-
const looked = await pool(dependencies, BATCH2, async ({ name, kind, spec }) => {
|
|
3152
|
+
const looked = await pool(dependencies, context.concurrency ?? BATCH2, async ({ name, kind, spec }) => {
|
|
3140
3153
|
const registry = registryFor(name, configs);
|
|
3141
3154
|
const packument = await fetchPackument(name, registry, context.fetcher);
|
|
3142
3155
|
if (packument === undefined) {
|
|
@@ -3159,8 +3172,9 @@ async function outdatedCommand(args) {
|
|
|
3159
3172
|
if (!await manifest.exists())
|
|
3160
3173
|
fail(`no package.json in ${folder}`);
|
|
3161
3174
|
const lockPath = join10(folder, "bun.lock");
|
|
3162
|
-
const locked =
|
|
3163
|
-
const
|
|
3175
|
+
const locked = existsSync5(lockPath) ? parseBunLock(await Bun.file(lockPath).text()) : [];
|
|
3176
|
+
const settings = await loadSettings(folder);
|
|
3177
|
+
const rows = await outdated(await manifest.text(), { minAgeDays: wholeNumber(values["min-age"], "min-age", settings.minAge ?? DEFAULT_MIN_AGE_DAYS, 0), concurrency: settings.concurrency, locked });
|
|
3164
3178
|
const { shown, footer } = capped(rows, limitOf(values, OUTDATED_LIMIT));
|
|
3165
3179
|
if (values.json === true)
|
|
3166
3180
|
printJson(shown);
|
|
@@ -3200,9 +3214,15 @@ var init_score = __esm(() => {
|
|
|
3200
3214
|
});
|
|
3201
3215
|
|
|
3202
3216
|
// ../kit/src/picker/state.ts
|
|
3217
|
+
function repeat(value, count) {
|
|
3218
|
+
return Array.from({ length: count }).fill(value);
|
|
3219
|
+
}
|
|
3203
3220
|
function parseKeys(input, paste = { active: false }, ctrls = []) {
|
|
3204
3221
|
const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
|
|
3205
3222
|
return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
|
|
3223
|
+
const wheel = MOUSE.exec(sequence)?.[1];
|
|
3224
|
+
if (wheel !== undefined)
|
|
3225
|
+
return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
|
|
3206
3226
|
const named = codes.get(sequence);
|
|
3207
3227
|
const key = named === undefined ? KEYS[sequence] : { ctrl: named };
|
|
3208
3228
|
if (sequence === PASTE_START || sequence === PASTE_END) {
|
|
@@ -3217,11 +3237,12 @@ function parseKeys(input, paste = { active: false }, ctrls = []) {
|
|
|
3217
3237
|
return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
|
|
3218
3238
|
});
|
|
3219
3239
|
}
|
|
3220
|
-
var IS_CONTROL, PASTE_START = "\x1B[200~", PASTE_END = "\x1B[201~", KEY_SEQUENCES, KEYS;
|
|
3240
|
+
var IS_CONTROL, PASTE_START = "\x1B[200~", PASTE_END = "\x1B[201~", KEY_SEQUENCES, MOUSE, WHEEL_LINES = 3, KEYS;
|
|
3221
3241
|
var init_state = __esm(() => {
|
|
3222
3242
|
init_score();
|
|
3223
3243
|
IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
|
|
3224
|
-
KEY_SEQUENCES = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
3244
|
+
KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
3245
|
+
MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
|
|
3225
3246
|
KEYS = {
|
|
3226
3247
|
"\x1B[A": "up",
|
|
3227
3248
|
"\x1BOA": "up",
|
|
@@ -3372,16 +3393,13 @@ async function ask(question, { hint, terminal = process19 }, render, press) {
|
|
|
3372
3393
|
if (!isInteractive(terminal))
|
|
3373
3394
|
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
3374
3395
|
const colors = paint(stderr);
|
|
3375
|
-
let drawn = [];
|
|
3376
3396
|
let current = "asking";
|
|
3377
3397
|
let outcome;
|
|
3378
3398
|
const columns = () => stderr.columns || 80;
|
|
3379
|
-
const draw = (state) => {
|
|
3399
|
+
const draw = (state, last = false) => {
|
|
3380
3400
|
const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
`)}`);
|
|
3384
|
-
drawn = frame;
|
|
3401
|
+
stderr.write(`\r\x1B[0J${frame.join(`
|
|
3402
|
+
`)}${last || frame.length < 2 ? "" : `\x1B[${frame.length - 1}A`}${last ? "" : "\r"}`);
|
|
3385
3403
|
current = state;
|
|
3386
3404
|
};
|
|
3387
3405
|
const redraw = () => draw(current);
|
|
@@ -3417,7 +3435,7 @@ async function ask(question, { hint, terminal = process19 }, render, press) {
|
|
|
3417
3435
|
});
|
|
3418
3436
|
} finally {
|
|
3419
3437
|
stderr.off?.("resize", redraw);
|
|
3420
|
-
draw(outcome ?? "cancel");
|
|
3438
|
+
draw(outcome ?? "cancel", true);
|
|
3421
3439
|
stderr.write(`
|
|
3422
3440
|
\x1B[?25h\x1B[?2004l`);
|
|
3423
3441
|
stdin.setRawMode(false);
|
|
@@ -3436,14 +3454,14 @@ var init_prompt = __esm(() => {
|
|
|
3436
3454
|
});
|
|
3437
3455
|
|
|
3438
3456
|
// src/excluded.ts
|
|
3439
|
-
import { existsSync as
|
|
3457
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync } from "fs";
|
|
3440
3458
|
import { dirname as dirname7 } from "path";
|
|
3441
3459
|
function excludedPath(home) {
|
|
3442
3460
|
return userConfigPath("pkg-excluded", { home });
|
|
3443
3461
|
}
|
|
3444
3462
|
function loadExcluded(home) {
|
|
3445
3463
|
const path = excludedPath(home);
|
|
3446
|
-
if (!
|
|
3464
|
+
if (!existsSync6(path))
|
|
3447
3465
|
return {};
|
|
3448
3466
|
try {
|
|
3449
3467
|
const raw = JSON.parse(readFileSync5(path, "utf8"));
|
|
@@ -3466,8 +3484,8 @@ function saveExcluded(name, dirs, home) {
|
|
|
3466
3484
|
delete excluded[name];
|
|
3467
3485
|
else
|
|
3468
3486
|
excluded[name] = [...dirs].toSorted();
|
|
3469
|
-
|
|
3470
|
-
|
|
3487
|
+
mkdirSync2(dirname7(path), { recursive: true });
|
|
3488
|
+
writeFileSync(path, `${JSON.stringify(excluded, null, 2)}
|
|
3471
3489
|
`);
|
|
3472
3490
|
}
|
|
3473
3491
|
var init_excluded = __esm(() => {
|
|
@@ -3480,7 +3498,7 @@ __export(exports_bump, {
|
|
|
3480
3498
|
ROOT_OPTION: () => ROOT_OPTION,
|
|
3481
3499
|
bump: () => bump
|
|
3482
3500
|
});
|
|
3483
|
-
import { existsSync as
|
|
3501
|
+
import { existsSync as existsSync7 } from "fs";
|
|
3484
3502
|
import { basename, dirname as dirname8, join as join11, relative as relative2 } from "path";
|
|
3485
3503
|
async function lookup(name, registry, fetcher) {
|
|
3486
3504
|
try {
|
|
@@ -3542,7 +3560,7 @@ async function vet(name, version, settings) {
|
|
|
3542
3560
|
}
|
|
3543
3561
|
function lockfileOf(dir, root) {
|
|
3544
3562
|
for (let at = dir;; at = dirname8(at)) {
|
|
3545
|
-
const found = ["bun.lock", "bun.lockb"].find((file) =>
|
|
3563
|
+
const found = ["bun.lock", "bun.lockb"].find((file) => existsSync7(join11(at, file)));
|
|
3546
3564
|
if (found !== undefined)
|
|
3547
3565
|
return relative2(dir, join11(at, found));
|
|
3548
3566
|
if (at === root || at === dirname8(at))
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-pkg",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.13.
|
|
4
|
+
"version": "0.13.3",
|
|
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.37.0"
|
|
37
37
|
}
|
|
38
38
|
}
|