@pylair/cli 0.1.0-rc.3 → 0.1.0-rc.31

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.
Files changed (112) hide show
  1. package/README.md +3 -2
  2. package/dist/bin.d.ts +3 -0
  3. package/dist/bin.d.ts.map +1 -0
  4. package/dist/bin.js +7 -0
  5. package/dist/bin.js.map +1 -0
  6. package/dist/build/artifacts.d.ts +14 -0
  7. package/dist/build/artifacts.d.ts.map +1 -0
  8. package/dist/build/artifacts.js +61 -0
  9. package/dist/build/artifacts.js.map +1 -0
  10. package/dist/build/bytecode.d.ts +29 -0
  11. package/dist/build/bytecode.d.ts.map +1 -0
  12. package/dist/build/bytecode.js +65 -0
  13. package/dist/build/bytecode.js.map +1 -0
  14. package/dist/build/download.d.ts +53 -0
  15. package/dist/build/download.d.ts.map +1 -0
  16. package/dist/build/download.js +327 -0
  17. package/dist/build/download.js.map +1 -0
  18. package/dist/build/notices.d.ts +10 -0
  19. package/dist/build/notices.d.ts.map +1 -0
  20. package/dist/build/notices.js +109 -0
  21. package/dist/build/notices.js.map +1 -0
  22. package/dist/build/pbs.d.ts +12 -0
  23. package/dist/build/pbs.d.ts.map +1 -0
  24. package/dist/build/pbs.js +36 -0
  25. package/dist/build/pbs.js.map +1 -0
  26. package/dist/build/python.d.ts +24 -0
  27. package/dist/build/python.d.ts.map +1 -0
  28. package/dist/build/python.js +106 -0
  29. package/dist/build/python.js.map +1 -0
  30. package/dist/build/sign.d.ts +18 -0
  31. package/dist/build/sign.d.ts.map +1 -0
  32. package/dist/build/sign.js +182 -0
  33. package/dist/build/sign.js.map +1 -0
  34. package/dist/build/source.d.ts +19 -0
  35. package/dist/build/source.d.ts.map +1 -0
  36. package/dist/build/source.js +91 -0
  37. package/dist/build/source.js.map +1 -0
  38. package/dist/build/util.d.ts +20 -0
  39. package/dist/build/util.d.ts.map +1 -0
  40. package/dist/build/util.js +62 -0
  41. package/dist/build/util.js.map +1 -0
  42. package/dist/build.d.ts +26 -12
  43. package/dist/build.d.ts.map +1 -1
  44. package/dist/build.js +240 -270
  45. package/dist/build.js.map +1 -1
  46. package/dist/capabilities.d.ts +51 -0
  47. package/dist/capabilities.d.ts.map +1 -0
  48. package/dist/capabilities.js +232 -0
  49. package/dist/capabilities.js.map +1 -0
  50. package/dist/cli.d.ts +38 -1
  51. package/dist/cli.d.ts.map +1 -1
  52. package/dist/cli.js +266 -39
  53. package/dist/cli.js.map +1 -1
  54. package/dist/codegen.d.ts.map +1 -1
  55. package/dist/codegen.js +12 -1
  56. package/dist/codegen.js.map +1 -1
  57. package/dist/config.d.ts +25 -1
  58. package/dist/config.d.ts.map +1 -1
  59. package/dist/config.js +31 -12
  60. package/dist/config.js.map +1 -1
  61. package/dist/dev.d.ts +7 -3
  62. package/dist/dev.d.ts.map +1 -1
  63. package/dist/dev.js +120 -16
  64. package/dist/dev.js.map +1 -1
  65. package/dist/doctor.d.ts +34 -1
  66. package/dist/doctor.d.ts.map +1 -1
  67. package/dist/doctor.js +268 -19
  68. package/dist/doctor.js.map +1 -1
  69. package/dist/keys.d.ts +50 -0
  70. package/dist/keys.d.ts.map +1 -0
  71. package/dist/keys.js +192 -0
  72. package/dist/keys.js.map +1 -0
  73. package/dist/prune.d.ts.map +1 -1
  74. package/dist/prune.js +1 -0
  75. package/dist/prune.js.map +1 -1
  76. package/dist/ui/caps.d.ts +45 -0
  77. package/dist/ui/caps.d.ts.map +1 -0
  78. package/dist/ui/caps.js +81 -0
  79. package/dist/ui/caps.js.map +1 -0
  80. package/dist/ui/index.d.ts +106 -0
  81. package/dist/ui/index.d.ts.map +1 -0
  82. package/dist/ui/index.js +264 -0
  83. package/dist/ui/index.js.map +1 -0
  84. package/dist/ui/prompts.d.ts +39 -0
  85. package/dist/ui/prompts.d.ts.map +1 -0
  86. package/dist/ui/prompts.js +209 -0
  87. package/dist/ui/prompts.js.map +1 -0
  88. package/dist/ui/style.d.ts +27 -0
  89. package/dist/ui/style.d.ts.map +1 -0
  90. package/dist/ui/style.js +71 -0
  91. package/dist/ui/style.js.map +1 -0
  92. package/dist/update.d.ts +64 -0
  93. package/dist/update.d.ts.map +1 -0
  94. package/dist/update.js +266 -0
  95. package/dist/update.js.map +1 -0
  96. package/dist/version.d.ts +5 -0
  97. package/dist/version.d.ts.map +1 -0
  98. package/dist/version.js +15 -0
  99. package/dist/version.js.map +1 -0
  100. package/dist/wrap.d.ts +69 -0
  101. package/dist/wrap.d.ts.map +1 -0
  102. package/dist/wrap.js +292 -0
  103. package/dist/wrap.js.map +1 -0
  104. package/dist/wrapbuild.d.ts +33 -0
  105. package/dist/wrapbuild.d.ts.map +1 -0
  106. package/dist/wrapbuild.js +83 -0
  107. package/dist/wrapbuild.js.map +1 -0
  108. package/dist/wrapconfig.d.ts +52 -0
  109. package/dist/wrapconfig.d.ts.map +1 -0
  110. package/dist/wrapconfig.js +117 -0
  111. package/dist/wrapconfig.js.map +1 -0
  112. package/package.json +4 -3
@@ -1 +1 @@
1
- {"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../src/prune.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,eAAO,MAAM,aAAa,UA8BzB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC3C;AAWD,kEAAkE;AAClE,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,WAAW,CAmBnE"}
1
+ {"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../src/prune.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,eAAO,MAAM,aAAa,UA+BzB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC3C;AAWD,kEAAkE;AAClE,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,WAAW,CAmBnE"}
package/dist/prune.js CHANGED
@@ -35,6 +35,7 @@ export const DEFAULT_PRUNE = [
35
35
  "site-packages/**/*.dist-info/RECORD.jws",
36
36
  // stray caches anywhere
37
37
  "backend/**/__pycache__",
38
+ "app/**/__pycache__", // wrap mode stages the app as app/
38
39
  ];
39
40
  function dirSize(dir) {
40
41
  let n = 0;
package/dist/prune.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"prune.js","sourceRoot":"","sources":["../src/prune.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,mCAAmC;IACnC,gBAAgB;IAChB,sBAAsB;IACtB,yBAAyB;IACzB,4BAA4B;IAC5B,4BAA4B;IAC5B,+BAA+B;IAC/B,+BAA+B;IAC/B,8BAA8B;IAC9B,yBAAyB;IACzB,cAAc;IACd,YAAY;IACZ,mBAAmB;IACnB,gEAAgE;IAChE,uDAAuD;IACvD,4BAA4B;IAC5B,mBAAmB;IACnB,qBAAqB;IACrB,+BAA+B;IAC/B,uBAAuB;IACvB,sBAAsB;IACtB,sEAAsE;IACtE,oEAAoE;IACpE,wEAAwE;IACxE,wBAAwB;IACxB,8BAA8B;IAC9B,yCAAyC;IACzC,wBAAwB;IACxB,wBAAwB;CACzB,CAAC;AAQF,SAAS,OAAO,CAAC,GAAW;IAC1B,I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AAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAClE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;gBACzC,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,MAAM,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9C,CAAC;iBAAM,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;gBAC3B,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACb,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACf,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,45 @@
1
+ /** What the terminal can show, decided ONCE at startup.
2
+ *
3
+ * Two independent questions:
4
+ *
5
+ * - fancy or plain? Fancy is colour, symbols, a spinner and folded tool
6
+ * output; plain is stable, readable text with no ANSI codes and no spinner
7
+ * frames (logs, CI, pipes, `--plain`).
8
+ * - unicode or ascii symbols? Only asked when fancy. A glyph the console
9
+ * cannot show comes out as mojibake (a UTF-8 em dash read as code page 437
10
+ * prints "ΓÇö"), so on Windows unicode is used only where it is known to
11
+ * work.
12
+ *
13
+ * Pure: everything it needs comes in as arguments, so it is unit-tested for
14
+ * every TTY / CI / NO_COLOR / FORCE_COLOR / Windows-console case.
15
+ */
16
+ export interface Caps {
17
+ /** Colour, symbols, spinner, folded tool output. False means plain text. */
18
+ fancy: boolean;
19
+ /** Emit ANSI colour codes (equal to `fancy`). */
20
+ color: boolean;
21
+ /** Use Unicode symbols (otherwise ASCII). Always false when plain. */
22
+ unicode: boolean;
23
+ /** Redraw lines in place (a live spinner): fancy AND an interactive TTY. */
24
+ animate: boolean;
25
+ /** Terminal width, for truncating folded progress lines. */
26
+ columns: number;
27
+ }
28
+ export interface CapsInput {
29
+ env: Record<string, string | undefined>;
30
+ platform: string;
31
+ stdoutIsTTY: boolean;
32
+ /** Command-line arguments (for `--plain`). */
33
+ argv: readonly string[];
34
+ /** Windows only: the console's output code page, asked lazily and at most
35
+ * once, and only when the answer matters. */
36
+ codePage?: () => number | undefined;
37
+ columns?: number;
38
+ }
39
+ export declare function detectCaps(i: CapsInput): Caps;
40
+ /** Windows: the active console code page, from `chcp`. Undefined when it
41
+ * cannot be read (treated as "not UTF-8": ASCII is always safe). */
42
+ export declare function windowsCodePage(): number | undefined;
43
+ /** The real thing, from the running process. */
44
+ export declare function detectProcessCaps(argv?: readonly string[]): Caps;
45
+ //# sourceMappingURL=caps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"caps.d.ts","sourceRoot":"","sources":["../../src/ui/caps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,WAAW,IAAI;IACnB,4EAA4E;IAC5E,KAAK,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,KAAK,EAAE,OAAO,CAAC;IACf,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;IACjB,4EAA4E;IAC5E,OAAO,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,8CAA8C;IAC9C,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB;iDAC6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAeD,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAuB7C;AAED;oEACoE;AACpE,wBAAgB,eAAe,IAAI,MAAM,GAAG,SAAS,CAapD;AAED,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,SAAS,MAAM,EAA0B,GAAG,IAAI,CASvF"}
@@ -0,0 +1,81 @@
1
+ /** What the terminal can show, decided ONCE at startup.
2
+ *
3
+ * Two independent questions:
4
+ *
5
+ * - fancy or plain? Fancy is colour, symbols, a spinner and folded tool
6
+ * output; plain is stable, readable text with no ANSI codes and no spinner
7
+ * frames (logs, CI, pipes, `--plain`).
8
+ * - unicode or ascii symbols? Only asked when fancy. A glyph the console
9
+ * cannot show comes out as mojibake (a UTF-8 em dash read as code page 437
10
+ * prints "ΓÇö"), so on Windows unicode is used only where it is known to
11
+ * work.
12
+ *
13
+ * Pure: everything it needs comes in as arguments, so it is unit-tested for
14
+ * every TTY / CI / NO_COLOR / FORCE_COLOR / Windows-console case.
15
+ */
16
+ import { execFileSync } from "node:child_process";
17
+ /** FORCE_COLOR: "0" and "false" force colour OFF, any other non-empty value
18
+ * forces it ON, unset or empty leaves the decision to the terminal. */
19
+ function forceColor(env) {
20
+ const v = env.FORCE_COLOR;
21
+ if (v === undefined || v === "")
22
+ return undefined;
23
+ return v === "0" || v.toLowerCase() === "false" ? "off" : "on";
24
+ }
25
+ function localeIsUtf8(env) {
26
+ const loc = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
27
+ return /utf-?8/i.test(loc);
28
+ }
29
+ export function detectCaps(i) {
30
+ const { env } = i;
31
+ const force = forceColor(env);
32
+ const auto = i.stdoutIsTTY && !env.CI && !env.NO_COLOR && env.TERM !== "dumb";
33
+ // Precedence: --plain, then FORCE_COLOR (off, then on), then the terminal.
34
+ const fancy = !i.argv.includes("--plain") && force !== "off" && (force === "on" || auto);
35
+ const animate = fancy && i.stdoutIsTTY && env.TERM !== "dumb";
36
+ let unicode = false;
37
+ if (fancy) {
38
+ if (i.platform === "win32") {
39
+ // Windows Terminal renders Unicode whatever the code page says; the
40
+ // classic console (PowerShell 5.1, cmd) only when it was switched to
41
+ // UTF-8 (code page 65001).
42
+ unicode = !!env.WT_SESSION || i.codePage?.() === 65001;
43
+ }
44
+ else if (env.TERM === "linux") {
45
+ unicode = false; // the bare Linux virtual console
46
+ }
47
+ else {
48
+ unicode = localeIsUtf8(env) || i.platform === "darwin";
49
+ }
50
+ }
51
+ return { fancy, color: fancy, unicode, animate, columns: i.columns && i.columns > 0 ? i.columns : 80 };
52
+ }
53
+ /** Windows: the active console code page, from `chcp`. Undefined when it
54
+ * cannot be read (treated as "not UTF-8": ASCII is always safe). */
55
+ export function windowsCodePage() {
56
+ try {
57
+ const out = execFileSync("cmd.exe", ["/d", "/c", "chcp"], {
58
+ encoding: "utf8",
59
+ timeout: 2000,
60
+ windowsHide: true,
61
+ stdio: ["ignore", "pipe", "ignore"],
62
+ });
63
+ const m = /(\d{3,5})\s*$/.exec(out.trim());
64
+ return m ? Number(m[1]) : undefined;
65
+ }
66
+ catch {
67
+ return undefined;
68
+ }
69
+ }
70
+ /** The real thing, from the running process. */
71
+ export function detectProcessCaps(argv = process.argv.slice(2)) {
72
+ return detectCaps({
73
+ env: process.env,
74
+ platform: process.platform,
75
+ stdoutIsTTY: !!process.stdout.isTTY,
76
+ argv,
77
+ codePage: windowsCodePage,
78
+ columns: process.stdout.columns,
79
+ });
80
+ }
81
+ //# sourceMappingURL=caps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"caps.js","sourceRoot":"","sources":["../../src/ui/caps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA2BlD;uEACuE;AACvE,SAAS,UAAU,CAAC,GAAqB;IACvC,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC;IAC1B,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IAClD,O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;QACnC,IAAI;QACJ,QAAQ,EAAE,eAAe;QACzB,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO;KAChC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,106 @@
1
+ /** The one output module every `pylair` command prints through.
2
+ *
3
+ * Two renderings, chosen once at startup (see caps.ts):
4
+ *
5
+ * - fancy: colour only for meaning, consistent symbols, aligned columns, a
6
+ * spinner on the step that is running and a timing on each finished step;
7
+ * - plain: stable text with no ANSI codes and no spinner frames. Wherever
8
+ * something parses today's output (the doctor check lines, the "pylair
9
+ * <command>: message" errors), plain keeps today's wording.
10
+ *
11
+ * Nothing here prints an em dash or any other non-ASCII glyph unless the
12
+ * terminal was shown to handle it, so it cannot come out as mojibake.
13
+ */
14
+ import type { Caps } from "./caps.js";
15
+ import { type Symbols } from "./style.js";
16
+ export { detectCaps, detectProcessCaps } from "./caps.js";
17
+ export type { Caps, CapsInput } from "./caps.js";
18
+ export { formatDuration, formatSize, paint, stripAnsi, symbolsFor, truncate } from "./style.js";
19
+ export interface Sink {
20
+ out: (s: string) => void;
21
+ err: (s: string) => void;
22
+ }
23
+ export interface Clock {
24
+ now: () => number;
25
+ setInterval: (fn: () => void, ms: number) => unknown;
26
+ clearInterval: (h: unknown) => void;
27
+ }
28
+ export interface StepHandle {
29
+ /** Short result shown after the step finishes ("3.12.16, cached"). */
30
+ detail(text: string): void;
31
+ /** Live detail for the running line (the last line of a tool's output). */
32
+ progress(text: string): void;
33
+ }
34
+ export interface Hint {
35
+ file?: string;
36
+ fix?: string;
37
+ }
38
+ export declare class Ui {
39
+ readonly caps: Caps;
40
+ private readonly sink;
41
+ private readonly clock;
42
+ readonly sym: Symbols;
43
+ private active?;
44
+ private labelWidth;
45
+ private stepHandle?;
46
+ constructor(caps: Caps, sink: Sink, clock?: Clock);
47
+ private p;
48
+ /** A status glyph padded to a fixed width, so columns after it line up in
49
+ * both the Unicode (1 wide) and ASCII (`[ok]`, 4 wide) sets. */
50
+ private mark;
51
+ private clearActive;
52
+ private drawActive;
53
+ private emit;
54
+ /** Raw text to stderr, above the live line (a failed tool's captured log). */
55
+ dump(text: string): void;
56
+ /** A line as is (stdout). */
57
+ line(text?: string): void;
58
+ /** A fact: `ok text` in fancy mode, just the text in plain. */
59
+ ok(text: string): void;
60
+ /** Neutral information. */
61
+ info(text: string): void;
62
+ /** Detail, de-emphasised. */
63
+ note(text: string): void;
64
+ /** A warning (stderr). A leading "warning: " is dropped in fancy mode (the
65
+ * symbol says it) and kept in plain mode, as it always was. `bare` marks a
66
+ * message that never carried the prefix (a retry notice): plain prints it as is. */
67
+ warn(text: string, opts?: {
68
+ bare?: boolean;
69
+ plain?: string;
70
+ }): void;
71
+ /** A status note from deep inside a step (a download source, a cache hit).
72
+ * Fancy: it becomes the running step's detail, so the step list stays one
73
+ * line per stage. Plain, or outside a step: a line of its own. */
74
+ status(text: string): void;
75
+ /** A failure (stderr). Plain mode prints `text` exactly (callers pass the
76
+ * `pylair <command>: message` form the tests and scripts see today). */
77
+ error(text: string): void;
78
+ /** The final line of a command. */
79
+ summary(kind: "ok" | "fail" | "warn", text: string): void;
80
+ /** Aligned `key value` rows. */
81
+ rows(pairs: ReadonlyArray<readonly [string, string]>, indent?: number): void;
82
+ /** A command header. Fancy: a bold title and aligned rows. Plain: the
83
+ * legacy lines the command printed before (kept for anything that reads them). */
84
+ header(title: string, pairs: ReadonlyArray<readonly [string, string]>, plainLines: readonly string[]): void;
85
+ /** One doctor check. Plain keeps the exact legacy line (` ok ` / `FAIL`,
86
+ * name padded, two spaces, detail); fancy aligns a symbol, the name and the
87
+ * detail. A failure gets its file and a one-line fix underneath in both. */
88
+ check(ok: boolean, name: string, nameWidth: number, detail: string, hint?: Hint): void;
89
+ /** Align the finished step lines on the longest label. */
90
+ setStepWidth(w: number): void;
91
+ /** Run one stage of work with a live spinner (when the terminal can show
92
+ * one) and a timing line when it ends. Rethrows what `fn` throws, after
93
+ * marking the step failed. */
94
+ step<T>(label: string, fn: (s: StepHandle) => T | Promise<T>): Promise<T>;
95
+ /** Restore the cursor if the process is about to exit mid-spinner. */
96
+ dispose(): void;
97
+ }
98
+ /** Decide capabilities once and install the process-wide Ui. Called first
99
+ * thing by the CLI entry; commands then print through `ui`. */
100
+ export declare function initUi(argv?: readonly string[]): Ui;
101
+ /** Install a Ui built elsewhere (tests). */
102
+ export declare function setUi(u: Ui): void;
103
+ export declare function getUi(): Ui;
104
+ /** `ui.ok(...)`, `ui.step(...)`: the process-wide instance, created on first use. */
105
+ export declare const ui: Ui;
106
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAA0D,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAElG,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC1D,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEhG,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzB,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;IACrD,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC;AAYD,MAAM,WAAW,UAAU;IACzB,sEAAsE;IACtE,MA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,0 +1,264 @@
1
+ /** The one output module every `pylair` command prints through.
2
+ *
3
+ * Two renderings, chosen once at startup (see caps.ts):
4
+ *
5
+ * - fancy: colour only for meaning, consistent symbols, aligned columns, a
6
+ * spinner on the step that is running and a timing on each finished step;
7
+ * - plain: stable text with no ANSI codes and no spinner frames. Wherever
8
+ * something parses today's output (the doctor check lines, the "pylair
9
+ * <command>: message" errors), plain keeps today's wording.
10
+ *
11
+ * Nothing here prints an em dash or any other non-ASCII glyph unless the
12
+ * terminal was shown to handle it, so it cannot come out as mojibake.
13
+ */
14
+ import { detectProcessCaps } from "./caps.js";
15
+ import { formatDuration, paint, stripAnsi, symbolsFor, truncate } from "./style.js";
16
+ export { detectCaps, detectProcessCaps } from "./caps.js";
17
+ export { formatDuration, formatSize, paint, stripAnsi, symbolsFor, truncate } from "./style.js";
18
+ const realClock = {
19
+ now: () => Date.now(),
20
+ setInterval: (fn, ms) => {
21
+ const t = setInterval(fn, ms);
22
+ t.unref?.();
23
+ return t;
24
+ },
25
+ clearInterval: (h) => clearInterval(h),
26
+ };
27
+ const CLEAR_LINE = "\r\u001b[2K";
28
+ const HIDE_CURSOR = "\u001b[?25l";
29
+ const SHOW_CURSOR = "\u001b[?25h";
30
+ export class Ui {
31
+ caps;
32
+ sink;
33
+ clock;
34
+ sym;
35
+ active;
36
+ labelWidth = 0;
37
+ stepHandle;
38
+ constructor(caps, sink, clock = realClock) {
39
+ this.caps = caps;
40
+ this.sink = sink;
41
+ this.clock = clock;
42
+ this.sym = symbolsFor(caps);
43
+ }
44
+ p(role, text) {
45
+ return paint(this.caps, role, text);
46
+ }
47
+ /** A status glyph padded to a fixed width, so columns after it line up in
48
+ * both the Unicode (1 wide) and ASCII (`[ok]`, 4 wide) sets. */
49
+ mark(role, glyph) {
50
+ return this.p(role, glyph.padEnd(this.caps.unicode ? 1 : 4));
51
+ }
52
+ // ---- low level: never corrupt the live spinner line -----------------------
53
+ clearActive() {
54
+ if (this.active && this.caps.animate)
55
+ this.sink.out(CLEAR_LINE);
56
+ }
57
+ drawActive() {
58
+ const a = this.active;
59
+ if (!a || !this.caps.animate)
60
+ return;
61
+ const frame = this.sym.frames[a.frame % this.sym.frames.length];
62
+ const head = `${frame} ${a.label}`;
63
+ const room = Math.max(0, this.caps.columns - head.length - 3);
64
+ const detail = a.detail ? ` ${this.p("muted", truncate(stripAnsi(a.detail), room, this.sym.ellipsis))}` : "";
65
+ this.sink.out(`${CLEAR_LINE}${this.p("accent", frame)} ${a.label}${detail}`);
66
+ }
67
+ emit(channel, text) {
68
+ this.clearActive();
69
+ this.sink[channel](text);
70
+ this.drawActive();
71
+ }
72
+ // ---- lines -------------------------------------------------------------------
73
+ /** Raw text to stderr, above the live line (a failed tool's captured log). */
74
+ dump(text) {
75
+ this.emit("err", text);
76
+ }
77
+ /** A line as is (stdout). */
78
+ line(text = "") {
79
+ this.emit("out", text + "\n");
80
+ }
81
+ /** A fact: `ok text` in fancy mode, just the text in plain. */
82
+ ok(text) {
83
+ this.line(this.caps.fancy ? `${this.p("ok", this.sym.ok)} ${text}` : text);
84
+ }
85
+ /** Neutral information. */
86
+ info(text) {
87
+ this.line(this.caps.fancy ? `${this.p("accent", this.sym.bullet)} ${text}` : text);
88
+ }
89
+ /** Detail, de-emphasised. */
90
+ note(text) {
91
+ this.line(this.p("muted", text));
92
+ }
93
+ /** A warning (stderr). A leading "warning: " is dropped in fancy mode (the
94
+ * symbol says it) and kept in plain mode, as it always was. `bare` marks a
95
+ * message that never carried the prefix (a retry notice): plain prints it as is. */
96
+ warn(text, opts = {}) {
97
+ const body = text.replace(/^warn(ing)?:\s*/i, "");
98
+ const plain = opts.plain ?? (opts.bare ? text : `warning: ${body}`);
99
+ this.emit("err", (this.caps.fancy ? `${this.p("warn", this.sym.warn)} ${this.p("warn", body)}` : plain) + "\n");
100
+ }
101
+ /** A status note from deep inside a step (a download source, a cache hit).
102
+ * Fancy: it becomes the running step's detail, so the step list stays one
103
+ * line per stage. Plain, or outside a step: a line of its own. */
104
+ status(text) {
105
+ if (this.caps.fancy && this.stepHandle)
106
+ this.stepHandle.detail(text);
107
+ else
108
+ this.line(text);
109
+ }
110
+ /** A failure (stderr). Plain mode prints `text` exactly (callers pass the
111
+ * `pylair <command>: message` form the tests and scripts see today). */
112
+ error(text) {
113
+ this.emit("err", (this.caps.fancy ? `${this.p("fail", this.sym.fail)} ${this.p("fail", text)}` : text) + "\n");
114
+ }
115
+ /** The final line of a command. */
116
+ summary(kind, text) {
117
+ if (!this.caps.fancy)
118
+ return this.line(text);
119
+ const sym = kind === "ok" ? this.sym.ok : kind === "fail" ? this.sym.fail : this.sym.warn;
120
+ this.line(`${this.p(kind, sym)} ${this.p("bold", text)}`);
121
+ }
122
+ /** Aligned `key value` rows. */
123
+ rows(pairs, indent = 2) {
124
+ const w = Math.max(0, ...pairs.map(([k]) => k.length));
125
+ for (const [k, v] of pairs)
126
+ this.line(`${" ".repeat(indent)}${this.p("muted", k.padEnd(w))} ${v}`);
127
+ }
128
+ /** A command header. Fancy: a bold title and aligned rows. Plain: the
129
+ * legacy lines the command printed before (kept for anything that reads them). */
130
+ header(title, pairs, plainLines) {
131
+ if (!this.caps.fancy) {
132
+ for (const l of plainLines)
133
+ this.line(l);
134
+ return;
135
+ }
136
+ this.line(this.p("bold", title));
137
+ this.rows(pairs);
138
+ this.line();
139
+ }
140
+ /** One doctor check. Plain keeps the exact legacy line (` ok ` / `FAIL`,
141
+ * name padded, two spaces, detail); fancy aligns a symbol, the name and the
142
+ * detail. A failure gets its file and a one-line fix underneath in both. */
143
+ check(ok, name, nameWidth, detail, hint) {
144
+ if (!this.caps.fancy) {
145
+ this.line(`${ok ? " ok " : "FAIL"} ${name.padEnd(nameWidth)} ${detail}`);
146
+ }
147
+ else {
148
+ const sym = ok ? this.mark("ok", this.sym.ok) : this.mark("fail", this.sym.fail);
149
+ const lines = detail.split("\n");
150
+ this.line(` ${sym} ${name.padEnd(nameWidth)} ${this.p("muted", lines[0])}`);
151
+ for (const extra of lines.slice(1))
152
+ this.line(` ${" ".repeat(nameWidth + 2)}${this.p("muted", extra.trim())}`);
153
+ }
154
+ if (!ok && hint) {
155
+ const pad = this.caps.fancy ? " " : " ";
156
+ const arrow = this.sym.arrow;
157
+ if (hint.file)
158
+ this.line(`${pad}${this.p("muted", `${arrow} file`)} ${this.p("accent", hint.file)}`);
159
+ if (hint.fix)
160
+ this.line(`${pad}${this.p("muted", `${arrow} fix`)} ${hint.fix}`);
161
+ }
162
+ }
163
+ // ---- steps ---------------------------------------------------------------------
164
+ /** Align the finished step lines on the longest label. */
165
+ setStepWidth(w) {
166
+ this.labelWidth = w;
167
+ }
168
+ /** Run one stage of work with a live spinner (when the terminal can show
169
+ * one) and a timing line when it ends. Rethrows what `fn` throws, after
170
+ * marking the step failed. */
171
+ async step(label, fn) {
172
+ const start = this.clock.now();
173
+ let detail = "";
174
+ const handle = {
175
+ detail: (t) => {
176
+ detail = t;
177
+ },
178
+ progress: (t) => {
179
+ if (this.active)
180
+ this.active.detail = t;
181
+ },
182
+ };
183
+ this.stepHandle = handle;
184
+ if (this.caps.animate) {
185
+ this.active = { label, detail: "", frame: 0 };
186
+ this.sink.out(HIDE_CURSOR);
187
+ this.drawActive();
188
+ this.active.timer = this.clock.setInterval(() => {
189
+ if (!this.active)
190
+ return;
191
+ this.active.frame++;
192
+ this.drawActive();
193
+ }, 80);
194
+ }
195
+ else if (!this.caps.fancy) {
196
+ this.line(`-> ${label}`);
197
+ }
198
+ const finish = (ok) => {
199
+ this.stepHandle = undefined;
200
+ if (this.active) {
201
+ this.clock.clearInterval(this.active.timer);
202
+ this.sink.out(CLEAR_LINE + SHOW_CURSOR);
203
+ this.active = undefined;
204
+ }
205
+ const time = formatDuration(this.clock.now() - start);
206
+ if (!this.caps.fancy) {
207
+ this.line(`${ok ? "[ok]" : "[x]"} ${label} (${time})${detail ? `: ${detail}` : ""}`);
208
+ return;
209
+ }
210
+ const sym = ok ? this.mark("ok", this.sym.ok) : this.mark("fail", this.sym.fail);
211
+ const w = Math.max(this.labelWidth, label.length);
212
+ const used = (this.caps.unicode ? 1 : 4) + 1 + w + 2 + 7 + 2; // symbol, space, label, gap, time, gap
213
+ const shown = detail ? truncate(detail, Math.max(12, this.caps.columns - used - 1), this.sym.ellipsis) : "";
214
+ this.line(`${sym} ${label.padEnd(w)} ${this.p("muted", time.padStart(7))}${shown ? ` ${this.p("muted", shown)}` : ""}`);
215
+ };
216
+ try {
217
+ const r = await fn(handle);
218
+ finish(true);
219
+ return r;
220
+ }
221
+ catch (e) {
222
+ finish(false);
223
+ throw e;
224
+ }
225
+ }
226
+ /** Restore the cursor if the process is about to exit mid-spinner. */
227
+ dispose() {
228
+ if (this.active) {
229
+ this.clock.clearInterval(this.active.timer);
230
+ this.sink.out(CLEAR_LINE + SHOW_CURSOR);
231
+ this.active = undefined;
232
+ }
233
+ }
234
+ }
235
+ // ---- the process-wide instance ------------------------------------------------------
236
+ let current;
237
+ /** Decide capabilities once and install the process-wide Ui. Called first
238
+ * thing by the CLI entry; commands then print through `ui`. */
239
+ export function initUi(argv = process.argv.slice(2)) {
240
+ current?.dispose();
241
+ current = new Ui(detectProcessCaps(argv), {
242
+ out: (s) => void process.stdout.write(s),
243
+ err: (s) => void process.stderr.write(s),
244
+ });
245
+ const u = current;
246
+ process.once("exit", () => u.dispose());
247
+ return current;
248
+ }
249
+ /** Install a Ui built elsewhere (tests). */
250
+ export function setUi(u) {
251
+ current = u;
252
+ }
253
+ export function getUi() {
254
+ return current ?? initUi();
255
+ }
256
+ /** `ui.ok(...)`, `ui.step(...)`: the process-wide instance, created on first use. */
257
+ export const ui = new Proxy({}, {
258
+ get(_t, key) {
259
+ const u = getUi();
260
+ const v = u[key];
261
+ return typeof v === "function" ? v.bind(u) : v;
262
+ },
263
+ });
264
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH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AAM,UAAU,KAAK;IACnB,OAAO,OAAO,IAAI,MAAM,EAAE,CAAC;AAC7B,CAAC;AAED,qFAAqF;AACrF,MAAM,CAAC,MAAM,EAAE,GAAO,IAAI,KAAK,CAAC,EAAQ,EAAE;IACxC,GAAG,CAAC,EAAE,EAAE,GAAW;QACjB,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC;QAClB,MAAM,CAAC,GAAI,CAAwC,CAAC,GAAG,CAAC,CAAC;QACzD,OAAO,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,39 @@
1
+ /** Interactive prompts, hand-rolled on node:readline keypress events so the
2
+ * packages sharing this file (the CLI directly, create-pylair vendored) stay
3
+ * dependency-free.
4
+ *
5
+ * Callers gate on interactive(): prompts never fire without a TTY or under
6
+ * CI. Ctrl+C cancels through PromptCancelled; the caller catches it, prints
7
+ * a short line and exits before writing any files.
8
+ */
9
+ import type { Caps } from "./caps.js";
10
+ /** The readable side of a terminal. `setRawMode` exists on a real TTY; fake
11
+ * streams (tests) omit it and the prompts still work byte for byte. */
12
+ export interface PromptInput extends NodeJS.ReadableStream {
13
+ isTTY?: boolean;
14
+ setRawMode?(mode: boolean): unknown;
15
+ }
16
+ export interface PromptIo {
17
+ input: PromptInput;
18
+ output: NodeJS.WritableStream;
19
+ caps: Caps;
20
+ }
21
+ /** Prompts are for a person at a keyboard: interactive stdin, never CI. */
22
+ export declare function interactive(input: {
23
+ isTTY?: boolean;
24
+ }, env: NodeJS.ProcessEnv): boolean;
25
+ /** Ctrl+C at a prompt. Callers treat it as "clean exit, nothing written". */
26
+ export declare class PromptCancelled extends Error {
27
+ constructor();
28
+ }
29
+ /** Free-text question. `validate` returns an error message to show (then the
30
+ * question repeats) or undefined to accept. Empty answers repeat. */
31
+ export declare function askText(io: PromptIo, label: string, validate?: (value: string) => string | undefined): Promise<string>;
32
+ export interface SelectOption<T> {
33
+ value: T;
34
+ label: string;
35
+ }
36
+ /** Pick one of `options`. Fancy consoles get an arrow-key menu; plain ones
37
+ * get a numbered list answered by typing a digit. */
38
+ export declare function askSelect<T>(io: PromptIo, label: string, options: SelectOption<T>[]): Promise<T>;
39
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/ui/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGtC;uEACuE;AACvE,MAAM,WAAW,WAAY,SAAQ,MAAM,CAAC,cAAc;IACxD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAEvF;AAED,6EAA6E;AAC7E,qBAAa,eAAgB,SAAQ,KAAK;;CAKzC;AAiHD;qEACqE;AACrE,wBAAsB,OAAO,CAC3B,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAC/C,OAAO,CAAC,MAAM,CAAC,CAiCjB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;CACf;AAED;qDACqD;AACrD,wBAAsB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAuDtG"}