bivium 0.8.0 → 0.9.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/cli.js CHANGED
@@ -41,6 +41,7 @@ import {
41
41
  truncatePath,
42
42
  textWidth,
43
43
  MEASURE,
44
+ fitTerminal,
44
45
  RULE,
45
46
  aligned,
46
47
  headerRow,
@@ -51,7 +52,7 @@ import {
51
52
  orphanOf,
52
53
  computePlan2,
53
54
  prepare2
54
- } from "./shared-9qcbzxw3.js";
55
+ } from "./shared-07rt4zr7.js";
55
56
 
56
57
  // src/main.ts
57
58
  import { spawnSync } from "node:child_process";
@@ -2189,7 +2190,7 @@ function fail(argv, error) {
2189
2190
  async function main(argv, io = PIPED) {
2190
2191
  const out = outFor(io, argv, nowMs());
2191
2192
  if (argv.includes("--help") || argv.includes("-h")) {
2192
- console.log(usage(out.paint));
2193
+ console.log(fitTerminal(usage(out.paint), out.io.stdout, process.stdout.columns));
2193
2194
  return 0;
2194
2195
  }
2195
2196
  if (argv.includes("--version") || argv.includes("-v")) {
@@ -2199,7 +2200,7 @@ async function main(argv, io = PIPED) {
2199
2200
  const at = commandAt(argv);
2200
2201
  const command = at === -1 ? undefined : argv[at];
2201
2202
  if (command === "help") {
2202
- console.log(usage(out.paint));
2203
+ console.log(fitTerminal(usage(out.paint), out.io.stdout, process.stdout.columns));
2203
2204
  return 0;
2204
2205
  }
2205
2206
  if (command === undefined) {
package/compute.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  computePlan2,
7
7
  prepare2,
8
8
  plan2
9
- } from "./shared-9qcbzxw3.js";
9
+ } from "./shared-07rt4zr7.js";
10
10
  import"./shared-550cvwt2.js";
11
11
  import"./shared-211m8fjt.js";
12
12
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bivium",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Run only the tests your change can reach.",
5
5
  "license": "MIT",
6
6
  "author": "Eric Liu (https://github.com/metonym)",
@@ -35,7 +35,7 @@ function agentVariable(env) {
35
35
  }
36
36
 
37
37
  // package.json
38
- var version = "0.8.0";
38
+ var version = "0.9.0";
39
39
 
40
40
  // src/barrel.ts
41
41
  var COMMENTS = /\/\/.*$|\/\*[\s\S]*?\*\//gm;
@@ -2568,8 +2568,66 @@ function truncatePath(path, max) {
2568
2568
  return end === "" ? `${prefix}${[...stem].slice(0, room).join("")}…${tail}` : `${prefix}${first}…${end}${tail}`;
2569
2569
  }
2570
2570
  var ESCAPE = /\x1b\[[0-9;]*m/g;
2571
+ var LEADING_ESCAPE = /^\x1b\[[0-9;]*m/;
2571
2572
  var textWidth = (text) => typeof Bun === "undefined" ? [...text.replace(ESCAPE, "")].length : Bun.stringWidth(text);
2572
2573
  var MEASURE = 80;
2574
+ function hangOf(line) {
2575
+ const plain = line.replace(ESCAPE, "");
2576
+ const lead = /^ */.exec(plain)?.[0].length ?? 0;
2577
+ const gap = /^ *\S.*? {2,}(?=\S)/.exec(plain);
2578
+ return gap ? textWidth(gap[0]) : lead;
2579
+ }
2580
+ function splitAt(line, columns) {
2581
+ let seen = 0;
2582
+ let i = 0;
2583
+ while (i < line.length && seen < columns) {
2584
+ const escape = LEADING_ESCAPE.exec(line.slice(i));
2585
+ if (escape) {
2586
+ i += escape[0].length;
2587
+ continue;
2588
+ }
2589
+ const ch = String.fromCodePoint(line.codePointAt(i) ?? 32);
2590
+ seen += textWidth(ch);
2591
+ i += ch.length;
2592
+ }
2593
+ return [line.slice(0, i), line.slice(i)];
2594
+ }
2595
+ var fitTerminal = (text, terminal, columns) => terminal ? fitWidth(text, Math.min(MEASURE, columns || MEASURE)) : text;
2596
+ function fitWidth(text, width) {
2597
+ return text.split(`
2598
+ `).flatMap((line) => {
2599
+ if (textWidth(line) <= width)
2600
+ return [line];
2601
+ let hang = hangOf(line);
2602
+ if (hang > width / 2)
2603
+ hang = /^ */.exec(line.replace(ESCAPE, ""))?.[0].length ?? 0;
2604
+ const [head, rest] = splitAt(line, hang);
2605
+ const room = Math.max(1, width - hang);
2606
+ const lines = [];
2607
+ let current = "";
2608
+ const words = [];
2609
+ for (const word of rest.split(/ +/)) {
2610
+ const last = words.at(-1);
2611
+ if (last !== undefined && last.replace(ESCAPE, "") === "·") {
2612
+ words[words.length - 1] = `${last} ${word}`;
2613
+ } else if (word !== "")
2614
+ words.push(word);
2615
+ }
2616
+ for (const word of words) {
2617
+ const next = current === "" ? word : `${current} ${word}`;
2618
+ if (current !== "" && textWidth(next) > room) {
2619
+ lines.push(current);
2620
+ current = word;
2621
+ } else {
2622
+ current = next;
2623
+ }
2624
+ }
2625
+ if (current !== "")
2626
+ lines.push(current);
2627
+ return lines.map((part, k) => (k === 0 ? head : " ".repeat(hang)) + part);
2628
+ }).join(`
2629
+ `);
2630
+ }
2573
2631
  var RULE = "\x00rule";
2574
2632
  function aligned(table, rightColumns = [], paintRule = asIs, indent = " ") {
2575
2633
  const blank = (cell) => cell === "" || cell === RULE;
@@ -4422,4 +4480,4 @@ async function plan2(options = {}) {
4422
4480
  };
4423
4481
  }
4424
4482
 
4425
- export { githubOutputPath, nowMs, environment, agentVariable, version, QUERY, UNDECLARED_READS, RELATIVE, aliasPath, createResolver, SCANNED, formatOf, extract, stringsOf, finish, gotoPage, walksByTypes, importersOf, affectedBy, sorted, PLAIN, createPaint, wantsColor, isDumb, SEPARATOR, branch, NOTE_INDENT, closingLine, failLine, truncateWords, truncatePath, textWidth, MEASURE, RULE, aligned, headerRow, plural, SILENT, createProgress, formatSelection, orphanOf, readSources2, collectPackages2, extractRevision2, graphView2, computePlan2, prepare2, plan2 };
4483
+ export { githubOutputPath, nowMs, environment, agentVariable, version, QUERY, UNDECLARED_READS, RELATIVE, aliasPath, createResolver, SCANNED, formatOf, extract, stringsOf, finish, gotoPage, walksByTypes, importersOf, affectedBy, sorted, PLAIN, createPaint, wantsColor, isDumb, SEPARATOR, branch, NOTE_INDENT, closingLine, failLine, truncateWords, truncatePath, textWidth, MEASURE, fitTerminal, RULE, aligned, headerRow, plural, SILENT, createProgress, formatSelection, orphanOf, readSources2, collectPackages2, extractRevision2, graphView2, computePlan2, prepare2, plan2 };