@bunli/test 0.3.0 → 0.3.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/index.js +116 -128
- package/dist/index.js.map +7 -9
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -473,115 +473,6 @@ var require_browser = __commonJS((exports, module) => {
|
|
|
473
473
|
};
|
|
474
474
|
});
|
|
475
475
|
|
|
476
|
-
// ../../node_modules/has-flag/index.js
|
|
477
|
-
var require_has_flag = __commonJS((exports, module) => {
|
|
478
|
-
module.exports = (flag, argv = process.argv) => {
|
|
479
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
480
|
-
const position = argv.indexOf(prefix + flag);
|
|
481
|
-
const terminatorPosition = argv.indexOf("--");
|
|
482
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
483
|
-
};
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
// ../../node_modules/supports-color/index.js
|
|
487
|
-
var require_supports_color = __commonJS((exports, module) => {
|
|
488
|
-
var os = __require("os");
|
|
489
|
-
var tty = __require("tty");
|
|
490
|
-
var hasFlag = require_has_flag();
|
|
491
|
-
var { env } = process;
|
|
492
|
-
var forceColor;
|
|
493
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
494
|
-
forceColor = 0;
|
|
495
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
496
|
-
forceColor = 1;
|
|
497
|
-
}
|
|
498
|
-
if ("FORCE_COLOR" in env) {
|
|
499
|
-
if (env.FORCE_COLOR === "true") {
|
|
500
|
-
forceColor = 1;
|
|
501
|
-
} else if (env.FORCE_COLOR === "false") {
|
|
502
|
-
forceColor = 0;
|
|
503
|
-
} else {
|
|
504
|
-
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
function translateLevel(level) {
|
|
508
|
-
if (level === 0) {
|
|
509
|
-
return false;
|
|
510
|
-
}
|
|
511
|
-
return {
|
|
512
|
-
level,
|
|
513
|
-
hasBasic: true,
|
|
514
|
-
has256: level >= 2,
|
|
515
|
-
has16m: level >= 3
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
function supportsColor(haveStream, streamIsTTY) {
|
|
519
|
-
if (forceColor === 0) {
|
|
520
|
-
return 0;
|
|
521
|
-
}
|
|
522
|
-
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
523
|
-
return 3;
|
|
524
|
-
}
|
|
525
|
-
if (hasFlag("color=256")) {
|
|
526
|
-
return 2;
|
|
527
|
-
}
|
|
528
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
529
|
-
return 0;
|
|
530
|
-
}
|
|
531
|
-
const min = forceColor || 0;
|
|
532
|
-
if (env.TERM === "dumb") {
|
|
533
|
-
return min;
|
|
534
|
-
}
|
|
535
|
-
if (process.platform === "win32") {
|
|
536
|
-
const osRelease = os.release().split(".");
|
|
537
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
538
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
539
|
-
}
|
|
540
|
-
return 1;
|
|
541
|
-
}
|
|
542
|
-
if ("CI" in env) {
|
|
543
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
|
|
544
|
-
return 1;
|
|
545
|
-
}
|
|
546
|
-
return min;
|
|
547
|
-
}
|
|
548
|
-
if ("TEAMCITY_VERSION" in env) {
|
|
549
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
550
|
-
}
|
|
551
|
-
if (env.COLORTERM === "truecolor") {
|
|
552
|
-
return 3;
|
|
553
|
-
}
|
|
554
|
-
if ("TERM_PROGRAM" in env) {
|
|
555
|
-
const version2 = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
556
|
-
switch (env.TERM_PROGRAM) {
|
|
557
|
-
case "iTerm.app":
|
|
558
|
-
return version2 >= 3 ? 3 : 2;
|
|
559
|
-
case "Apple_Terminal":
|
|
560
|
-
return 2;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
564
|
-
return 2;
|
|
565
|
-
}
|
|
566
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
567
|
-
return 1;
|
|
568
|
-
}
|
|
569
|
-
if ("COLORTERM" in env) {
|
|
570
|
-
return 1;
|
|
571
|
-
}
|
|
572
|
-
return min;
|
|
573
|
-
}
|
|
574
|
-
function getSupportLevel(stream) {
|
|
575
|
-
const level = supportsColor(stream, stream && stream.isTTY);
|
|
576
|
-
return translateLevel(level);
|
|
577
|
-
}
|
|
578
|
-
module.exports = {
|
|
579
|
-
supportsColor: getSupportLevel,
|
|
580
|
-
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
581
|
-
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
582
|
-
};
|
|
583
|
-
});
|
|
584
|
-
|
|
585
476
|
// ../../node_modules/debug/src/node.js
|
|
586
477
|
var require_node = __commonJS((exports, module) => {
|
|
587
478
|
var tty = __require("tty");
|
|
@@ -595,7 +486,7 @@ var require_node = __commonJS((exports, module) => {
|
|
|
595
486
|
exports.destroy = util.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
596
487
|
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
597
488
|
try {
|
|
598
|
-
const supportsColor =
|
|
489
|
+
const supportsColor = (()=>{throw new Error("Cannot require module "+"supports-color");})();
|
|
599
490
|
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
600
491
|
exports.colors = [
|
|
601
492
|
20,
|
|
@@ -14774,7 +14665,10 @@ var bunliConfigSchema = exports_external.object({
|
|
|
14774
14665
|
tagFormat: "v{{version}}",
|
|
14775
14666
|
conventionalCommits: true
|
|
14776
14667
|
}),
|
|
14777
|
-
plugins: exports_external.array(exports_external.any()).default([])
|
|
14668
|
+
plugins: exports_external.array(exports_external.any()).default([]),
|
|
14669
|
+
help: exports_external.object({
|
|
14670
|
+
renderer: exports_external.any().optional()
|
|
14671
|
+
}).optional()
|
|
14778
14672
|
});
|
|
14779
14673
|
var bunliConfigStrictSchema = bunliConfigSchema.extend({
|
|
14780
14674
|
name: exports_external.string().min(1, "Name is required"),
|
|
@@ -15139,7 +15033,7 @@ class PluginManager {
|
|
|
15139
15033
|
plugins = [];
|
|
15140
15034
|
combinedStore = {};
|
|
15141
15035
|
loader = new PluginLoader;
|
|
15142
|
-
logger = createLogger("plugin-manager");
|
|
15036
|
+
logger = createLogger("core:plugin-manager");
|
|
15143
15037
|
async loadPlugins(configs) {
|
|
15144
15038
|
const loadPromises = configs.map(async (config2) => {
|
|
15145
15039
|
try {
|
|
@@ -15165,10 +15059,10 @@ class PluginManager {
|
|
|
15165
15059
|
}
|
|
15166
15060
|
return acc;
|
|
15167
15061
|
}, {});
|
|
15168
|
-
this.logger.
|
|
15062
|
+
this.logger.debug(`Loaded ${this.plugins.length} plugins`);
|
|
15169
15063
|
}
|
|
15170
15064
|
async runSetup(config2) {
|
|
15171
|
-
const context = new PluginContext(config2, new Map(Object.entries(this.combinedStore)), createLogger("plugins"), {
|
|
15065
|
+
const context = new PluginContext(config2, new Map(Object.entries(this.combinedStore)), createLogger("core:plugins"), {
|
|
15172
15066
|
cwd: process.cwd(),
|
|
15173
15067
|
home: homedir(),
|
|
15174
15068
|
config: join2(homedir(), ".config", config2.name || "bunli")
|
|
@@ -15444,7 +15338,9 @@ async function createCLI(configOverride) {
|
|
|
15444
15338
|
await pluginManager.loadPlugins(mergedConfig.plugins);
|
|
15445
15339
|
const { config: updatedConfig, commands: pluginCommands, middlewares } = await pluginManager.runSetup(fullConfig);
|
|
15446
15340
|
fullConfig = bunliConfigStrictSchema.parse(updatedConfig);
|
|
15447
|
-
|
|
15341
|
+
for (const cmd of pluginCommands) {
|
|
15342
|
+
registerCommand(cmd);
|
|
15343
|
+
}
|
|
15448
15344
|
}
|
|
15449
15345
|
const resolvedConfig = {
|
|
15450
15346
|
name: fullConfig.name,
|
|
@@ -15475,7 +15371,8 @@ async function createCLI(configOverride) {
|
|
|
15475
15371
|
tagFormat: "v{{version}}",
|
|
15476
15372
|
conventionalCommits: true
|
|
15477
15373
|
},
|
|
15478
|
-
plugins: fullConfig.plugins || []
|
|
15374
|
+
plugins: fullConfig.plugins || [],
|
|
15375
|
+
help: fullConfig.help
|
|
15479
15376
|
};
|
|
15480
15377
|
if (mergedConfig.plugins && mergedConfig.plugins.length > 0) {
|
|
15481
15378
|
await pluginManager.runConfigResolved(resolvedConfig);
|
|
@@ -15506,7 +15403,92 @@ async function createCLI(configOverride) {
|
|
|
15506
15403
|
}
|
|
15507
15404
|
return { command: undefined, remainingArgs: args };
|
|
15508
15405
|
}
|
|
15406
|
+
function wrapText(text, width) {
|
|
15407
|
+
const safeWidth = Math.max(10, width);
|
|
15408
|
+
const words = text.trim().split(/\s+/).filter(Boolean);
|
|
15409
|
+
if (words.length === 0)
|
|
15410
|
+
return [""];
|
|
15411
|
+
const first = words[0];
|
|
15412
|
+
if (!first)
|
|
15413
|
+
return [""];
|
|
15414
|
+
const lines = [];
|
|
15415
|
+
let line = first;
|
|
15416
|
+
for (let i = 1;i < words.length; i += 1) {
|
|
15417
|
+
const word = words[i] ?? "";
|
|
15418
|
+
if (!word)
|
|
15419
|
+
continue;
|
|
15420
|
+
if ((line + " " + word).length <= safeWidth) {
|
|
15421
|
+
line = `${line} ${word}`;
|
|
15422
|
+
} else {
|
|
15423
|
+
lines.push(line);
|
|
15424
|
+
line = word;
|
|
15425
|
+
}
|
|
15426
|
+
}
|
|
15427
|
+
lines.push(line);
|
|
15428
|
+
return lines;
|
|
15429
|
+
}
|
|
15430
|
+
function printTwoColumnRows(rows, terminalWidth) {
|
|
15431
|
+
const indent = " ";
|
|
15432
|
+
const maxLabel = rows.reduce((max, row) => Math.max(max, row.label.length), 0);
|
|
15433
|
+
const maxColumn = Math.max(18, Math.floor(terminalWidth * 0.4));
|
|
15434
|
+
const labelWidth = Math.min(maxLabel + 2, maxColumn);
|
|
15435
|
+
const descWidth = Math.max(20, terminalWidth - indent.length - labelWidth - 1);
|
|
15436
|
+
for (const row of rows) {
|
|
15437
|
+
const label = row.label;
|
|
15438
|
+
const description = row.description || "";
|
|
15439
|
+
if (label.length >= labelWidth - 1) {
|
|
15440
|
+
console.log(`${indent}${label}`);
|
|
15441
|
+
const lines2 = wrapText(description, descWidth);
|
|
15442
|
+
for (const line of lines2) {
|
|
15443
|
+
console.log(`${indent}${" ".repeat(labelWidth)}${line}`);
|
|
15444
|
+
}
|
|
15445
|
+
continue;
|
|
15446
|
+
}
|
|
15447
|
+
const paddedLabel = label.padEnd(labelWidth);
|
|
15448
|
+
const lines = wrapText(description, descWidth);
|
|
15449
|
+
lines.forEach((line, index) => {
|
|
15450
|
+
if (index === 0) {
|
|
15451
|
+
console.log(`${indent}${paddedLabel}${line}`);
|
|
15452
|
+
} else {
|
|
15453
|
+
console.log(`${indent}${" ".repeat(labelWidth)}${line}`);
|
|
15454
|
+
}
|
|
15455
|
+
});
|
|
15456
|
+
}
|
|
15457
|
+
}
|
|
15509
15458
|
function showHelp(cmd, path2 = []) {
|
|
15459
|
+
const terminalInfo = getTerminalInfo();
|
|
15460
|
+
const terminalWidth = terminalInfo.width || 80;
|
|
15461
|
+
const helpRenderer = fullConfig.help?.renderer;
|
|
15462
|
+
if (typeof helpRenderer === "function") {
|
|
15463
|
+
if (!cmd) {
|
|
15464
|
+
const topLevel = new Set;
|
|
15465
|
+
for (const [name2, command] of commands) {
|
|
15466
|
+
if (!name2.includes(" ") && !command.alias?.includes(name2)) {
|
|
15467
|
+
topLevel.add(command);
|
|
15468
|
+
}
|
|
15469
|
+
}
|
|
15470
|
+
helpRenderer({
|
|
15471
|
+
cliName: fullConfig.name,
|
|
15472
|
+
version: fullConfig.version,
|
|
15473
|
+
description: fullConfig.description,
|
|
15474
|
+
command: undefined,
|
|
15475
|
+
path: path2,
|
|
15476
|
+
commands: Array.from(topLevel),
|
|
15477
|
+
terminal: terminalInfo
|
|
15478
|
+
});
|
|
15479
|
+
return;
|
|
15480
|
+
}
|
|
15481
|
+
helpRenderer({
|
|
15482
|
+
cliName: fullConfig.name,
|
|
15483
|
+
version: fullConfig.version,
|
|
15484
|
+
description: fullConfig.description,
|
|
15485
|
+
command: cmd,
|
|
15486
|
+
path: path2,
|
|
15487
|
+
commands: cmd.commands ?? [],
|
|
15488
|
+
terminal: terminalInfo
|
|
15489
|
+
});
|
|
15490
|
+
return;
|
|
15491
|
+
}
|
|
15510
15492
|
if (!cmd) {
|
|
15511
15493
|
console.log(`${fullConfig.name} v${fullConfig.version}`);
|
|
15512
15494
|
if (fullConfig.description) {
|
|
@@ -15520,9 +15502,11 @@ Commands:`);
|
|
|
15520
15502
|
topLevel.add(command);
|
|
15521
15503
|
}
|
|
15522
15504
|
}
|
|
15523
|
-
|
|
15524
|
-
|
|
15525
|
-
|
|
15505
|
+
const rows = Array.from(topLevel).map((command) => ({
|
|
15506
|
+
label: command.name,
|
|
15507
|
+
description: command.description || ""
|
|
15508
|
+
}));
|
|
15509
|
+
printTwoColumnRows(rows, terminalWidth);
|
|
15526
15510
|
} else {
|
|
15527
15511
|
const fullPath = [...path2, cmd.name].join(" ");
|
|
15528
15512
|
console.log(`Usage: ${fullConfig.name} ${fullPath} [options]`);
|
|
@@ -15531,19 +15515,21 @@ ${cmd.description}`);
|
|
|
15531
15515
|
if (cmd.options && Object.keys(cmd.options).length > 0) {
|
|
15532
15516
|
console.log(`
|
|
15533
15517
|
Options:`);
|
|
15534
|
-
|
|
15518
|
+
const rows = Object.entries(cmd.options).map(([name2, opt]) => {
|
|
15535
15519
|
const option2 = opt;
|
|
15536
15520
|
const flag = `--${name2}${option2.short ? `, -${option2.short}` : ""}`;
|
|
15537
|
-
|
|
15538
|
-
|
|
15539
|
-
|
|
15521
|
+
return { label: flag, description: option2.description || "" };
|
|
15522
|
+
});
|
|
15523
|
+
printTwoColumnRows(rows, terminalWidth);
|
|
15540
15524
|
}
|
|
15541
15525
|
if (cmd.commands && cmd.commands.length > 0) {
|
|
15542
15526
|
console.log(`
|
|
15543
15527
|
Subcommands:`);
|
|
15544
|
-
|
|
15545
|
-
|
|
15546
|
-
|
|
15528
|
+
const rows = cmd.commands.map((subCmd) => ({
|
|
15529
|
+
label: subCmd.name,
|
|
15530
|
+
description: subCmd.description || ""
|
|
15531
|
+
}));
|
|
15532
|
+
printTwoColumnRows(rows, terminalWidth);
|
|
15547
15533
|
}
|
|
15548
15534
|
}
|
|
15549
15535
|
}
|
|
@@ -15602,7 +15588,9 @@ Subcommands:`);
|
|
|
15602
15588
|
return commands2;
|
|
15603
15589
|
}
|
|
15604
15590
|
const loadedCommands = await loadFromManifest(manifest);
|
|
15605
|
-
|
|
15591
|
+
for (const cmd of loadedCommands) {
|
|
15592
|
+
registerCommand(cmd);
|
|
15593
|
+
}
|
|
15606
15594
|
}
|
|
15607
15595
|
async function runCommandInternal(command, argv, providedFlags) {
|
|
15608
15596
|
let context;
|
|
@@ -16291,4 +16279,4 @@ export {
|
|
|
16291
16279
|
createMatchers
|
|
16292
16280
|
};
|
|
16293
16281
|
|
|
16294
|
-
//# debugId=
|
|
16282
|
+
//# debugId=4B648A1569272EFB64756E2164756E21
|