@contember/cli-common 2.2.0-alpha.2 → 2.2.0-alpha.20

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 (246) hide show
  1. package/dist/development/index.cjs +27 -0
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +29 -2
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/application/Application.cjs +116 -59
  6. package/dist/development/src/application/Application.cjs.map +1 -1
  7. package/dist/development/src/application/Application.js +116 -59
  8. package/dist/development/src/application/Application.js.map +1 -1
  9. package/dist/development/src/application/CliError.cjs +104 -0
  10. package/dist/development/src/application/CliError.cjs.map +1 -0
  11. package/dist/development/src/application/CliError.js +104 -0
  12. package/dist/development/src/application/CliError.js.map +1 -0
  13. package/dist/development/src/application/Command.cjs +18 -5
  14. package/dist/development/src/application/Command.cjs.map +1 -1
  15. package/dist/development/src/application/Command.js +18 -5
  16. package/dist/development/src/application/Command.js.map +1 -1
  17. package/dist/development/src/application/CommandConfiguration.cjs +21 -3
  18. package/dist/development/src/application/CommandConfiguration.cjs.map +1 -1
  19. package/dist/development/src/application/CommandConfiguration.js +23 -5
  20. package/dist/development/src/application/CommandConfiguration.js.map +1 -1
  21. package/dist/development/src/application/CommandManager.cjs +139 -21
  22. package/dist/development/src/application/CommandManager.cjs.map +1 -1
  23. package/dist/development/src/application/CommandManager.js +139 -21
  24. package/dist/development/src/application/CommandManager.js.map +1 -1
  25. package/dist/development/src/application/ErrorRenderer.cjs +38 -0
  26. package/dist/development/src/application/ErrorRenderer.cjs.map +1 -0
  27. package/dist/development/src/application/ErrorRenderer.js +38 -0
  28. package/dist/development/src/application/ErrorRenderer.js.map +1 -0
  29. package/dist/development/src/application/GlobalOptions.cjs +54 -0
  30. package/dist/development/src/application/GlobalOptions.cjs.map +1 -0
  31. package/dist/development/src/application/GlobalOptions.js +54 -0
  32. package/dist/development/src/application/GlobalOptions.js.map +1 -0
  33. package/dist/development/src/application/Input.cjs +5 -0
  34. package/dist/development/src/application/Input.cjs.map +1 -1
  35. package/dist/development/src/application/Input.js +5 -0
  36. package/dist/development/src/application/Input.js.map +1 -1
  37. package/dist/development/src/application/InputParser.cjs +7 -3
  38. package/dist/development/src/application/InputParser.cjs.map +1 -1
  39. package/dist/development/src/application/InputParser.js +7 -3
  40. package/dist/development/src/application/InputParser.js.map +1 -1
  41. package/dist/development/src/application/Option.cjs +11 -0
  42. package/dist/development/src/application/Option.cjs.map +1 -1
  43. package/dist/development/src/application/Option.js +12 -1
  44. package/dist/development/src/application/Option.js.map +1 -1
  45. package/dist/development/src/application/Output.cjs +275 -0
  46. package/dist/development/src/application/Output.cjs.map +1 -0
  47. package/dist/development/src/application/Output.js +275 -0
  48. package/dist/development/src/application/Output.js.map +1 -0
  49. package/dist/development/src/application/colors.cjs +29 -0
  50. package/dist/development/src/application/colors.cjs.map +1 -0
  51. package/dist/development/src/application/colors.js +29 -0
  52. package/dist/development/src/application/colors.js.map +1 -0
  53. package/dist/development/src/application/exitProcess.cjs +7 -0
  54. package/dist/development/src/application/exitProcess.cjs.map +1 -0
  55. package/dist/development/src/application/exitProcess.js +7 -0
  56. package/dist/development/src/application/exitProcess.js.map +1 -0
  57. package/dist/development/src/application/table.cjs +23 -0
  58. package/dist/development/src/application/table.cjs.map +1 -0
  59. package/dist/development/src/application/table.js +23 -0
  60. package/dist/development/src/application/table.js.map +1 -0
  61. package/dist/development/src/npm/CommandRunner.cjs +126 -24
  62. package/dist/development/src/npm/CommandRunner.cjs.map +1 -1
  63. package/dist/development/src/npm/CommandRunner.js +126 -24
  64. package/dist/development/src/npm/CommandRunner.js.map +1 -1
  65. package/dist/development/src/npm/packageManagers/Bun.cjs +1 -2
  66. package/dist/development/src/npm/packageManagers/Bun.cjs.map +1 -1
  67. package/dist/development/src/npm/packageManagers/Bun.js +1 -2
  68. package/dist/development/src/npm/packageManagers/Bun.js.map +1 -1
  69. package/dist/development/src/npm/packageManagers/Npm.cjs +1 -2
  70. package/dist/development/src/npm/packageManagers/Npm.cjs.map +1 -1
  71. package/dist/development/src/npm/packageManagers/Npm.js +1 -2
  72. package/dist/development/src/npm/packageManagers/Npm.js.map +1 -1
  73. package/dist/development/src/npm/packageManagers/Pnpm.cjs +1 -2
  74. package/dist/development/src/npm/packageManagers/Pnpm.cjs.map +1 -1
  75. package/dist/development/src/npm/packageManagers/Pnpm.js +1 -2
  76. package/dist/development/src/npm/packageManagers/Pnpm.js.map +1 -1
  77. package/dist/development/src/npm/packageManagers/Yarn.cjs +1 -2
  78. package/dist/development/src/npm/packageManagers/Yarn.cjs.map +1 -1
  79. package/dist/development/src/npm/packageManagers/Yarn.js +1 -2
  80. package/dist/development/src/npm/packageManagers/Yarn.js.map +1 -1
  81. package/dist/development/src/npm/packageManagers/YarnClassic.cjs +1 -2
  82. package/dist/development/src/npm/packageManagers/YarnClassic.cjs.map +1 -1
  83. package/dist/development/src/npm/packageManagers/YarnClassic.js +1 -2
  84. package/dist/development/src/npm/packageManagers/YarnClassic.js.map +1 -1
  85. package/dist/production/index.cjs +27 -0
  86. package/dist/production/index.cjs.map +1 -1
  87. package/dist/production/index.js +29 -2
  88. package/dist/production/index.js.map +1 -1
  89. package/dist/production/src/application/Application.cjs +116 -59
  90. package/dist/production/src/application/Application.cjs.map +1 -1
  91. package/dist/production/src/application/Application.js +116 -59
  92. package/dist/production/src/application/Application.js.map +1 -1
  93. package/dist/production/src/application/CliError.cjs +104 -0
  94. package/dist/production/src/application/CliError.cjs.map +1 -0
  95. package/dist/production/src/application/CliError.js +104 -0
  96. package/dist/production/src/application/CliError.js.map +1 -0
  97. package/dist/production/src/application/Command.cjs +18 -5
  98. package/dist/production/src/application/Command.cjs.map +1 -1
  99. package/dist/production/src/application/Command.js +18 -5
  100. package/dist/production/src/application/Command.js.map +1 -1
  101. package/dist/production/src/application/CommandConfiguration.cjs +21 -3
  102. package/dist/production/src/application/CommandConfiguration.cjs.map +1 -1
  103. package/dist/production/src/application/CommandConfiguration.js +23 -5
  104. package/dist/production/src/application/CommandConfiguration.js.map +1 -1
  105. package/dist/production/src/application/CommandManager.cjs +139 -21
  106. package/dist/production/src/application/CommandManager.cjs.map +1 -1
  107. package/dist/production/src/application/CommandManager.js +139 -21
  108. package/dist/production/src/application/CommandManager.js.map +1 -1
  109. package/dist/production/src/application/ErrorRenderer.cjs +38 -0
  110. package/dist/production/src/application/ErrorRenderer.cjs.map +1 -0
  111. package/dist/production/src/application/ErrorRenderer.js +38 -0
  112. package/dist/production/src/application/ErrorRenderer.js.map +1 -0
  113. package/dist/production/src/application/GlobalOptions.cjs +54 -0
  114. package/dist/production/src/application/GlobalOptions.cjs.map +1 -0
  115. package/dist/production/src/application/GlobalOptions.js +54 -0
  116. package/dist/production/src/application/GlobalOptions.js.map +1 -0
  117. package/dist/production/src/application/Input.cjs +5 -0
  118. package/dist/production/src/application/Input.cjs.map +1 -1
  119. package/dist/production/src/application/Input.js +5 -0
  120. package/dist/production/src/application/Input.js.map +1 -1
  121. package/dist/production/src/application/InputParser.cjs +7 -3
  122. package/dist/production/src/application/InputParser.cjs.map +1 -1
  123. package/dist/production/src/application/InputParser.js +7 -3
  124. package/dist/production/src/application/InputParser.js.map +1 -1
  125. package/dist/production/src/application/Option.cjs +11 -0
  126. package/dist/production/src/application/Option.cjs.map +1 -1
  127. package/dist/production/src/application/Option.js +12 -1
  128. package/dist/production/src/application/Option.js.map +1 -1
  129. package/dist/production/src/application/Output.cjs +275 -0
  130. package/dist/production/src/application/Output.cjs.map +1 -0
  131. package/dist/production/src/application/Output.js +275 -0
  132. package/dist/production/src/application/Output.js.map +1 -0
  133. package/dist/production/src/application/colors.cjs +29 -0
  134. package/dist/production/src/application/colors.cjs.map +1 -0
  135. package/dist/production/src/application/colors.js +29 -0
  136. package/dist/production/src/application/colors.js.map +1 -0
  137. package/dist/production/src/application/exitProcess.cjs +7 -0
  138. package/dist/production/src/application/exitProcess.cjs.map +1 -0
  139. package/dist/production/src/application/exitProcess.js +7 -0
  140. package/dist/production/src/application/exitProcess.js.map +1 -0
  141. package/dist/production/src/application/table.cjs +23 -0
  142. package/dist/production/src/application/table.cjs.map +1 -0
  143. package/dist/production/src/application/table.js +23 -0
  144. package/dist/production/src/application/table.js.map +1 -0
  145. package/dist/production/src/npm/CommandRunner.cjs +126 -24
  146. package/dist/production/src/npm/CommandRunner.cjs.map +1 -1
  147. package/dist/production/src/npm/CommandRunner.js +126 -24
  148. package/dist/production/src/npm/CommandRunner.js.map +1 -1
  149. package/dist/production/src/npm/packageManagers/Bun.cjs +1 -2
  150. package/dist/production/src/npm/packageManagers/Bun.cjs.map +1 -1
  151. package/dist/production/src/npm/packageManagers/Bun.js +1 -2
  152. package/dist/production/src/npm/packageManagers/Bun.js.map +1 -1
  153. package/dist/production/src/npm/packageManagers/Npm.cjs +1 -2
  154. package/dist/production/src/npm/packageManagers/Npm.cjs.map +1 -1
  155. package/dist/production/src/npm/packageManagers/Npm.js +1 -2
  156. package/dist/production/src/npm/packageManagers/Npm.js.map +1 -1
  157. package/dist/production/src/npm/packageManagers/Pnpm.cjs +1 -2
  158. package/dist/production/src/npm/packageManagers/Pnpm.cjs.map +1 -1
  159. package/dist/production/src/npm/packageManagers/Pnpm.js +1 -2
  160. package/dist/production/src/npm/packageManagers/Pnpm.js.map +1 -1
  161. package/dist/production/src/npm/packageManagers/Yarn.cjs +1 -2
  162. package/dist/production/src/npm/packageManagers/Yarn.cjs.map +1 -1
  163. package/dist/production/src/npm/packageManagers/Yarn.js +1 -2
  164. package/dist/production/src/npm/packageManagers/Yarn.js.map +1 -1
  165. package/dist/production/src/npm/packageManagers/YarnClassic.cjs +1 -2
  166. package/dist/production/src/npm/packageManagers/YarnClassic.cjs.map +1 -1
  167. package/dist/production/src/npm/packageManagers/YarnClassic.js +1 -2
  168. package/dist/production/src/npm/packageManagers/YarnClassic.js.map +1 -1
  169. package/dist/types/application/Application.d.ts +22 -11
  170. package/dist/types/application/Application.d.ts.map +1 -1
  171. package/dist/types/application/Argument.d.ts.map +1 -1
  172. package/dist/types/application/CliError.d.ts +40 -0
  173. package/dist/types/application/CliError.d.ts.map +1 -0
  174. package/dist/types/application/Command.d.ts +12 -2
  175. package/dist/types/application/Command.d.ts.map +1 -1
  176. package/dist/types/application/CommandConfiguration.d.ts +7 -4
  177. package/dist/types/application/CommandConfiguration.d.ts.map +1 -1
  178. package/dist/types/application/CommandManager.d.ts +40 -2
  179. package/dist/types/application/CommandManager.d.ts.map +1 -1
  180. package/dist/types/application/ErrorRenderer.d.ts +8 -0
  181. package/dist/types/application/ErrorRenderer.d.ts.map +1 -0
  182. package/dist/types/application/GlobalOptions.d.ts +28 -0
  183. package/dist/types/application/GlobalOptions.d.ts.map +1 -0
  184. package/dist/types/application/Input.d.ts +2 -0
  185. package/dist/types/application/Input.d.ts.map +1 -1
  186. package/dist/types/application/InputParser.d.ts +5 -1
  187. package/dist/types/application/InputParser.d.ts.map +1 -1
  188. package/dist/types/application/Option.d.ts +2 -0
  189. package/dist/types/application/Option.d.ts.map +1 -1
  190. package/dist/types/application/Output.d.ts +96 -0
  191. package/dist/types/application/Output.d.ts.map +1 -0
  192. package/dist/types/application/UsageFormatter.d.ts.map +1 -1
  193. package/dist/types/application/colors.d.ts +10 -0
  194. package/dist/types/application/colors.d.ts.map +1 -0
  195. package/dist/types/application/exitProcess.d.ts +11 -0
  196. package/dist/types/application/exitProcess.d.ts.map +1 -0
  197. package/dist/types/application/index.d.ts +7 -0
  198. package/dist/types/application/index.d.ts.map +1 -1
  199. package/dist/types/application/table.d.ts +7 -0
  200. package/dist/types/application/table.d.ts.map +1 -0
  201. package/dist/types/index.d.ts +2 -2
  202. package/dist/types/index.d.ts.map +1 -1
  203. package/dist/types/npm/CommandRunner.d.ts +13 -0
  204. package/dist/types/npm/CommandRunner.d.ts.map +1 -1
  205. package/dist/types/npm/Package.d.ts.map +1 -1
  206. package/dist/types/npm/PackageWorkspace.d.ts.map +1 -1
  207. package/dist/types/npm/PackageWorkspaceResolver.d.ts.map +1 -1
  208. package/dist/types/npm/packageManagers/Bun.d.ts.map +1 -1
  209. package/dist/types/npm/packageManagers/Npm.d.ts.map +1 -1
  210. package/dist/types/npm/packageManagers/PackageManagerHelpers.d.ts.map +1 -1
  211. package/dist/types/npm/packageManagers/Pnpm.d.ts.map +1 -1
  212. package/dist/types/npm/packageManagers/Yarn.d.ts.map +1 -1
  213. package/dist/types/npm/packageManagers/YarnClassic.d.ts.map +1 -1
  214. package/dist/types/tsconfig.tsbuildinfo +1 -1
  215. package/dist/types/utils/findPackageRoot.d.ts.map +1 -1
  216. package/package.json +2 -6
  217. package/src/application/Application.ts +138 -76
  218. package/src/application/CliError.ts +117 -0
  219. package/src/application/Command.ts +27 -6
  220. package/src/application/CommandConfiguration.ts +22 -4
  221. package/src/application/CommandManager.ts +172 -22
  222. package/src/application/ErrorRenderer.ts +40 -0
  223. package/src/application/GlobalOptions.ts +76 -0
  224. package/src/application/Input.ts +6 -0
  225. package/src/application/InputParser.ts +13 -4
  226. package/src/application/Option.ts +12 -0
  227. package/src/application/Output.ts +365 -0
  228. package/src/application/colors.ts +36 -0
  229. package/src/application/exitProcess.ts +12 -0
  230. package/src/application/index.ts +7 -0
  231. package/src/application/table.ts +31 -0
  232. package/src/index.ts +47 -2
  233. package/src/npm/CommandRunner.ts +166 -23
  234. package/src/npm/packageManagers/Bun.ts +1 -2
  235. package/src/npm/packageManagers/Npm.ts +1 -2
  236. package/src/npm/packageManagers/Pnpm.ts +1 -2
  237. package/src/npm/packageManagers/Yarn.ts +1 -2
  238. package/src/npm/packageManagers/YarnClassic.ts +1 -2
  239. package/tests/cases/unit/application.test.ts +426 -0
  240. package/tests/cases/unit/cliError.test.ts +127 -0
  241. package/tests/cases/unit/colors.test.ts +49 -0
  242. package/tests/cases/unit/commandManager.test.ts +270 -0
  243. package/tests/cases/unit/commandRunner.test.ts +192 -0
  244. package/tests/cases/unit/inputParser.test.ts +21 -0
  245. package/tests/cases/unit/output.test.ts +434 -0
  246. package/tests/lib/testOutput.ts +43 -0
@@ -0,0 +1,275 @@
1
+ import { createInterface } from "node:readline";
2
+ import { CliError, ExitCode } from "./CliError.js";
3
+ import { setColorsEnabled, terminalSupportsColor, style } from "./colors.js";
4
+ import { formatTable } from "./table.js";
5
+ var __defProp = Object.defineProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
+ const resolveOutputMode = (globals) => {
9
+ if (globals.json) {
10
+ return "json";
11
+ }
12
+ if (globals.quiet) {
13
+ return "quiet";
14
+ }
15
+ return "human";
16
+ };
17
+ class Output {
18
+ constructor(options = {}) {
19
+ __publicField(this, "currentMode", "human");
20
+ __publicField(this, "progressVisible", false);
21
+ __publicField(this, "stdout");
22
+ __publicField(this, "stderr");
23
+ __publicField(this, "stdinIsTty");
24
+ __publicField(this, "readPromptLine");
25
+ this.stdout = options.stdout ?? createProcessStream(process.stdout);
26
+ this.stderr = options.stderr ?? createProcessStream(process.stderr);
27
+ this.stdinIsTty = options.isStdinTty ?? (() => process.stdin.isTTY === true);
28
+ this.readPromptLine = options.readPromptLine ?? readStdinLine;
29
+ this.stdout.onError?.(handleStreamError);
30
+ this.stderr.onError?.(handleStreamError);
31
+ }
32
+ get mode() {
33
+ return this.currentMode;
34
+ }
35
+ get isJson() {
36
+ return this.currentMode === "json";
37
+ }
38
+ get isQuiet() {
39
+ return this.currentMode === "quiet";
40
+ }
41
+ /** Set by `Application` once the global options are parsed. */
42
+ setMode(mode) {
43
+ this.currentMode = mode;
44
+ }
45
+ applyGlobalOptions(globals) {
46
+ this.setMode(resolveOutputMode(globals));
47
+ setColorsEnabled(globals.color && this.currentMode === "human" && terminalSupportsColor);
48
+ }
49
+ data(value, rendering) {
50
+ const human = typeof rendering === "function" ? rendering : rendering?.human;
51
+ if (this.currentMode === "json") {
52
+ this.writeStdout(JSON.stringify(value ?? null, null, 2));
53
+ return;
54
+ }
55
+ if (this.currentMode === "quiet") {
56
+ const quietValue = typeof rendering === "object" && rendering.quiet ? rendering.quiet(value) : value;
57
+ for (const line of toScalarLines(quietValue)) {
58
+ this.writeStdout(line);
59
+ }
60
+ return;
61
+ }
62
+ this.writeStdout(human ? human(value) : JSON.stringify(value ?? null, null, 2));
63
+ }
64
+ table(columns, rows, quietField) {
65
+ if (this.currentMode === "json") {
66
+ this.writeStdout(JSON.stringify(rows, null, 2));
67
+ return;
68
+ }
69
+ if (this.currentMode === "quiet") {
70
+ const field = quietField ?? columns[0]?.field;
71
+ if (field === void 0) {
72
+ return;
73
+ }
74
+ for (const row of rows) {
75
+ this.writeStdout(formatCell(row[field]));
76
+ }
77
+ return;
78
+ }
79
+ if (rows.length === 0) {
80
+ return;
81
+ }
82
+ const data = rows.map((row) => {
83
+ const cells = {};
84
+ for (const column of columns) {
85
+ cells[column.field] = renderTableCell(column, row);
86
+ }
87
+ return cells;
88
+ });
89
+ this.writeStdout(formatTable(columns.map((it) => ({ field: it.field, name: it.name })), data));
90
+ }
91
+ // DIAGNOSTICS → stderr
92
+ info(message) {
93
+ this.writeDiagnostic(message);
94
+ }
95
+ warn(message) {
96
+ this.writeDiagnostic(message, (text) => style("yellow", text));
97
+ }
98
+ error(message) {
99
+ this.writeDiagnostic(message, (text) => style("red", text));
100
+ }
101
+ // PROGRESS → stderr
102
+ progress(message) {
103
+ if (this.currentMode !== "human" || !this.stderr.isTty) {
104
+ return;
105
+ }
106
+ this.clearProgress();
107
+ writeStream(this.stderr, escapeTerminalText(message));
108
+ this.progressVisible = true;
109
+ }
110
+ clearProgress() {
111
+ if (!this.progressVisible) {
112
+ return;
113
+ }
114
+ this.progressVisible = false;
115
+ writeStream(this.stderr, "\r\x1B[K");
116
+ }
117
+ /** False unless both sides of an interactive prompt are TTYs in human mode. */
118
+ canPrompt() {
119
+ return this.currentMode === "human" && this.stdinIsTty() && this.stderr.isTty;
120
+ }
121
+ /** Writes `question` to stderr and reads one answer line. */
122
+ prompt(question) {
123
+ if (!this.canPrompt()) {
124
+ throw new CliError("TTY not available. Pass --yes to confirm.", { code: "TTY_UNAVAILABLE", exitCode: ExitCode.InputError });
125
+ }
126
+ this.clearProgress();
127
+ writeStream(this.stderr, question);
128
+ return this.readPromptLine();
129
+ }
130
+ /**
131
+ * Writes a line to stderr regardless of the mode. Reserved for content the user explicitly asked for
132
+ * (help) or must always see (a fatal error) — everything else belongs to the methods above.
133
+ */
134
+ writeStderr(text) {
135
+ this.clearProgress();
136
+ writeStream(this.stderr, text + "\n");
137
+ }
138
+ writeStdout(text) {
139
+ this.clearProgress();
140
+ writeStream(this.stdout, text + "\n");
141
+ }
142
+ writeDiagnostic(message, format = (text) => text) {
143
+ if (this.currentMode !== "human") {
144
+ return;
145
+ }
146
+ this.clearProgress();
147
+ writeStream(this.stderr, format(escapeTerminalText(message)) + "\n");
148
+ }
149
+ }
150
+ const createProcessStream = (stream) => ({
151
+ write: (text) => {
152
+ stream.write(text);
153
+ },
154
+ get isTty() {
155
+ return stream.isTTY === true;
156
+ },
157
+ get columns() {
158
+ return stream.columns;
159
+ },
160
+ onError: (listener) => {
161
+ stream.on("error", (error) => listener(error));
162
+ }
163
+ });
164
+ let stdinReader;
165
+ const readStdinLine = () => {
166
+ stdinReader ?? (stdinReader = new LineReader(process.stdin));
167
+ return stdinReader.read();
168
+ };
169
+ class LineReader {
170
+ constructor(input) {
171
+ this.input = input;
172
+ __publicField(this, "reader");
173
+ __publicField(this, "lines", []);
174
+ __publicField(this, "waiting");
175
+ __publicField(this, "closed", false);
176
+ }
177
+ read() {
178
+ if (this.waiting) {
179
+ throw new Error("LineReader: a read is already pending");
180
+ }
181
+ const line = this.lines.shift();
182
+ if (line !== void 0) {
183
+ return Promise.resolve(line);
184
+ }
185
+ if (this.closed || this.input.readableEnded) {
186
+ this.closed = true;
187
+ return Promise.resolve(void 0);
188
+ }
189
+ return new Promise((resolve) => {
190
+ this.waiting = resolve;
191
+ this.open().resume();
192
+ });
193
+ }
194
+ open() {
195
+ if (this.reader) {
196
+ return this.reader;
197
+ }
198
+ const reader = createInterface({ input: this.input, terminal: false });
199
+ reader.on("line", (line) => this.settle(line));
200
+ reader.on("close", () => {
201
+ this.closed = true;
202
+ this.settle(void 0);
203
+ });
204
+ this.reader = reader;
205
+ return reader;
206
+ }
207
+ settle(line) {
208
+ const waiting = this.waiting;
209
+ if (!waiting) {
210
+ if (line !== void 0) {
211
+ this.lines.push(line);
212
+ }
213
+ return;
214
+ }
215
+ this.waiting = void 0;
216
+ if (!this.closed) {
217
+ this.reader?.pause();
218
+ }
219
+ waiting(line);
220
+ }
221
+ }
222
+ const writeStream = (stream, text) => {
223
+ try {
224
+ stream.write(text);
225
+ } catch (error) {
226
+ handleStreamError(error);
227
+ }
228
+ };
229
+ const handleStreamError = (error) => {
230
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "EPIPE") {
231
+ return;
232
+ }
233
+ throw error;
234
+ };
235
+ const escapeTerminalText = (value) => {
236
+ let escaped = "";
237
+ for (const character of value) {
238
+ if (!isTerminalControl(character)) {
239
+ escaped += character;
240
+ }
241
+ }
242
+ return escaped;
243
+ };
244
+ const isTerminalControl = (character) => {
245
+ const codePoint = character.codePointAt(0);
246
+ return codePoint !== void 0 && (codePoint <= 31 || codePoint >= 127 && codePoint <= 159);
247
+ };
248
+ const renderTableCell = (column, row) => column.format ? column.format(row[column.field], row) : formatCell(row[column.field]);
249
+ const formatCell = (value) => {
250
+ if (value === void 0 || value === null) {
251
+ return "";
252
+ }
253
+ if (typeof value === "string") {
254
+ return escapeTerminalText(value);
255
+ }
256
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
257
+ return String(value);
258
+ }
259
+ return JSON.stringify(value) ?? "";
260
+ };
261
+ const toScalarLines = (value) => {
262
+ const values = Array.isArray(value) ? value : [value];
263
+ if (!values.every(isOutputScalar)) {
264
+ throw new TypeError("Quiet output requires a scalar value or an array of scalar values. Pass an explicit quiet projection for structured data.");
265
+ }
266
+ return values.filter((it) => it !== void 0 && it !== null).map(formatCell);
267
+ };
268
+ const isOutputScalar = (value) => value === null || value === void 0 || ["string", "number", "boolean", "bigint"].includes(typeof value);
269
+ export {
270
+ LineReader,
271
+ Output,
272
+ escapeTerminalText,
273
+ resolveOutputMode
274
+ };
275
+ //# sourceMappingURL=Output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Output.js","sources":["../../../../../packages/cli-common/src/application/Output.ts"],"sourcesContent":["import { createInterface, type Interface } from 'node:readline'\nimport type { Readable } from 'node:stream'\nimport { CliError, ExitCode } from './CliError.js'\nimport { setColorsEnabled, style, terminalSupportsColor } from './colors.js'\nimport type { GlobalOptionValues } from './GlobalOptions.js'\nimport { formatTable } from './table.js'\n\nexport type OutputMode = 'human' | 'json' | 'quiet'\n\nexport interface OutputStream {\n\twrite(text: string): void\n\treadonly isTty: boolean\n\treadonly columns?: number\n\tonError?(listener: (error: unknown) => void): void\n}\n\n/** Reads one line of the user's answer, or `undefined` when the input is closed. */\nexport type PromptLineReader = () => Promise<string | undefined>\n\nexport interface OutputOptions {\n\tstdout?: OutputStream\n\tstderr?: OutputStream\n\tisStdinTty?: () => boolean\n\treadPromptLine?: PromptLineReader\n}\n\nexport type OutputScalar = string | number | boolean | bigint | null | undefined\n\nexport interface OutputDataOptions<T> {\n\thuman?: (value: T) => string\n\tquiet?: (value: T) => OutputScalar | readonly OutputScalar[]\n}\n\n/**\n * Per field column specs, so that each `format` sees the exact type of its own field. Indexed by the\n * field name only to let {@link Output.table} render a cell without widening the union.\n */\nexport type OutputTableColumns<T> = {\n\t[K in keyof T & string]: {\n\t\tfield: K\n\t\tname: string\n\t\t/** Human mode only — `--json` still emits the raw row and `--quiet` the raw value. */\n\t\tformat?: (value: T[K], row: T) => string\n\t}\n}\n\nexport type OutputTableColumn<T> = OutputTableColumns<T>[keyof T & string]\n\nexport const resolveOutputMode = (globals: GlobalOptionValues): OutputMode => {\n\tif (globals.json) {\n\t\treturn 'json'\n\t}\n\tif (globals.quiet) {\n\t\treturn 'quiet'\n\t}\n\treturn 'human'\n}\n\n/**\n * The single output channel of the CLI: stdout carries data, stderr carries everything a human reads.\n *\n * The instance is created before argv is parsed, so the mode is mutable and set by `Application` once\n * the global options are known. Every consumer holds the same instance.\n */\nexport class Output {\n\tprivate currentMode: OutputMode = 'human'\n\tprivate progressVisible = false\n\tprivate readonly stdout: OutputStream\n\tprivate readonly stderr: OutputStream\n\tprivate readonly stdinIsTty: () => boolean\n\tprivate readonly readPromptLine: PromptLineReader\n\n\tconstructor(options: OutputOptions = {}) {\n\t\tthis.stdout = options.stdout ?? createProcessStream(process.stdout)\n\t\tthis.stderr = options.stderr ?? createProcessStream(process.stderr)\n\t\tthis.stdinIsTty = options.isStdinTty ?? (() => process.stdin.isTTY === true)\n\t\tthis.readPromptLine = options.readPromptLine ?? readStdinLine\n\t\tthis.stdout.onError?.(handleStreamError)\n\t\tthis.stderr.onError?.(handleStreamError)\n\t}\n\n\tpublic get mode(): OutputMode {\n\t\treturn this.currentMode\n\t}\n\n\tpublic get isJson(): boolean {\n\t\treturn this.currentMode === 'json'\n\t}\n\n\tpublic get isQuiet(): boolean {\n\t\treturn this.currentMode === 'quiet'\n\t}\n\n\t/** Set by `Application` once the global options are parsed. */\n\tpublic setMode(mode: OutputMode): void {\n\t\tthis.currentMode = mode\n\t}\n\n\tpublic applyGlobalOptions(globals: GlobalOptionValues): void {\n\t\tthis.setMode(resolveOutputMode(globals))\n\t\tsetColorsEnabled(globals.color && this.currentMode === 'human' && terminalSupportsColor)\n\t}\n\n\t// DATA → stdout\n\n\t/** Prints command data with optional mode-specific projections. JSON always receives the raw value. */\n\tpublic data<T>(value: T, human?: (value: T) => string): void\n\tpublic data<T>(value: T, options?: OutputDataOptions<T>): void\n\tpublic data<T>(value: T, rendering?: ((value: T) => string) | OutputDataOptions<T>): void {\n\t\tconst human = typeof rendering === 'function' ? rendering : rendering?.human\n\t\tif (this.currentMode === 'json') {\n\t\t\tthis.writeStdout(JSON.stringify(value ?? null, null, 2))\n\t\t\treturn\n\t\t}\n\t\tif (this.currentMode === 'quiet') {\n\t\t\tconst quietValue = typeof rendering === 'object' && rendering.quiet ? rendering.quiet(value) : value\n\t\t\tfor (const line of toScalarLines(quietValue)) {\n\t\t\t\tthis.writeStdout(line)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tthis.writeStdout(human ? human(value) : JSON.stringify(value ?? null, null, 2))\n\t}\n\n\tpublic table<T>(columns: OutputTableColumn<T>[], rows: T[], quietField?: keyof T & string): void {\n\t\tif (this.currentMode === 'json') {\n\t\t\tthis.writeStdout(JSON.stringify(rows, null, 2))\n\t\t\treturn\n\t\t}\n\t\tif (this.currentMode === 'quiet') {\n\t\t\tconst field = quietField ?? columns[0]?.field\n\t\t\tif (field === undefined) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfor (const row of rows) {\n\t\t\t\tthis.writeStdout(formatCell(row[field]))\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tif (rows.length === 0) {\n\t\t\treturn\n\t\t}\n\t\tconst data = rows.map(row => {\n\t\t\tconst cells: Partial<Record<keyof T & string, string>> = {}\n\t\t\tfor (const column of columns) {\n\t\t\t\tcells[column.field] = renderTableCell(column, row)\n\t\t\t}\n\t\t\treturn cells\n\t\t})\n\t\tthis.writeStdout(formatTable(columns.map(it => ({ field: it.field, name: it.name })), data))\n\t}\n\n\t// DIAGNOSTICS → stderr\n\n\tpublic info(message: string): void {\n\t\tthis.writeDiagnostic(message)\n\t}\n\n\tpublic warn(message: string): void {\n\t\tthis.writeDiagnostic(message, text => style('yellow', text))\n\t}\n\n\tpublic error(message: string): void {\n\t\tthis.writeDiagnostic(message, text => style('red', text))\n\t}\n\n\t// PROGRESS → stderr\n\n\tpublic progress(message: string): void {\n\t\tif (this.currentMode !== 'human' || !this.stderr.isTty) {\n\t\t\treturn\n\t\t}\n\t\tthis.clearProgress()\n\t\twriteStream(this.stderr, escapeTerminalText(message))\n\t\tthis.progressVisible = true\n\t}\n\n\tpublic clearProgress(): void {\n\t\tif (!this.progressVisible) {\n\t\t\treturn\n\t\t}\n\t\tthis.progressVisible = false\n\t\twriteStream(this.stderr, '\\r\\u001b[K')\n\t}\n\n\t/** False unless both sides of an interactive prompt are TTYs in human mode. */\n\tpublic canPrompt(): boolean {\n\t\treturn this.currentMode === 'human' && this.stdinIsTty() && this.stderr.isTty\n\t}\n\n\t/** Writes `question` to stderr and reads one answer line. */\n\tpublic prompt(question: string): Promise<string | undefined> {\n\t\tif (!this.canPrompt()) {\n\t\t\tthrow new CliError('TTY not available. Pass --yes to confirm.', { code: 'TTY_UNAVAILABLE', exitCode: ExitCode.InputError })\n\t\t}\n\t\tthis.clearProgress()\n\t\twriteStream(this.stderr, question)\n\t\treturn this.readPromptLine()\n\t}\n\n\t/**\n\t * Writes a line to stderr regardless of the mode. Reserved for content the user explicitly asked for\n\t * (help) or must always see (a fatal error) — everything else belongs to the methods above.\n\t */\n\tpublic writeStderr(text: string): void {\n\t\tthis.clearProgress()\n\t\twriteStream(this.stderr, text + '\\n')\n\t}\n\n\tprivate writeStdout(text: string): void {\n\t\tthis.clearProgress()\n\t\twriteStream(this.stdout, text + '\\n')\n\t}\n\n\tprivate writeDiagnostic(message: string, format: (text: string) => string = text => text): void {\n\t\tif (this.currentMode !== 'human') {\n\t\t\treturn\n\t\t}\n\t\tthis.clearProgress()\n\t\twriteStream(this.stderr, format(escapeTerminalText(message)) + '\\n')\n\t}\n}\n\nconst createProcessStream = (stream: NodeJS.WriteStream): OutputStream => ({\n\twrite: text => {\n\t\tstream.write(text)\n\t},\n\tget isTty() {\n\t\treturn stream.isTTY === true\n\t},\n\tget columns() {\n\t\treturn stream.columns\n\t},\n\tonError: listener => {\n\t\tstream.on('error', error => listener(error))\n\t},\n})\n\nlet stdinReader: LineReader | undefined\nconst readStdinLine: PromptLineReader = () => {\n\tstdinReader ??= new LineReader(process.stdin)\n\treturn stdinReader.read()\n}\n\n/**\n * Reads answer lines from one input for all prompts, so that a line typed or pasted ahead of the next prompt is kept\n * and an input that already ended reads as closed. Not in readline's terminal mode: the TTY handles line editing and\n * echo, and Ctrl+C stays a plain SIGINT.\n */\nexport class LineReader {\n\tprivate reader: Interface | undefined\n\tprivate readonly lines: string[] = []\n\tprivate waiting: ((line: string | undefined) => void) | undefined\n\tprivate closed = false\n\n\tconstructor(private readonly input: Readable) {}\n\n\tpublic read(): Promise<string | undefined> {\n\t\tif (this.waiting) {\n\t\t\tthrow new Error('LineReader: a read is already pending')\n\t\t}\n\t\tconst line = this.lines.shift()\n\t\tif (line !== undefined) {\n\t\t\treturn Promise.resolve(line)\n\t\t}\n\t\t// readline never reports `close` for an input that ended before it was attached (Bun does not set readableEnded)\n\t\tif (this.closed || this.input.readableEnded) {\n\t\t\tthis.closed = true\n\t\t\treturn Promise.resolve(undefined)\n\t\t}\n\t\treturn new Promise(resolve => {\n\t\t\tthis.waiting = resolve\n\t\t\tthis.open().resume()\n\t\t})\n\t}\n\n\tprivate open(): Interface {\n\t\tif (this.reader) {\n\t\t\treturn this.reader\n\t\t}\n\t\tconst reader = createInterface({ input: this.input, terminal: false })\n\t\treader.on('line', line => this.settle(line))\n\t\treader.on('close', () => {\n\t\t\tthis.closed = true\n\t\t\tthis.settle(undefined)\n\t\t})\n\t\tthis.reader = reader\n\t\treturn reader\n\t}\n\n\tprivate settle(line: string | undefined): void {\n\t\tconst waiting = this.waiting\n\t\tif (!waiting) {\n\t\t\tif (line !== undefined) {\n\t\t\t\tthis.lines.push(line)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tthis.waiting = undefined\n\t\tif (!this.closed) {\n\t\t\t// a paused TTY does not keep the process alive between prompts; Node throws when pausing a closed interface\n\t\t\tthis.reader?.pause()\n\t\t}\n\t\twaiting(line)\n\t}\n}\n\nconst writeStream = (stream: OutputStream, text: string): void => {\n\ttry {\n\t\tstream.write(text)\n\t} catch (error) {\n\t\thandleStreamError(error)\n\t}\n}\n\nconst handleStreamError = (error: unknown): void => {\n\tif (typeof error === 'object' && error !== null && 'code' in error && error.code === 'EPIPE') {\n\t\treturn\n\t}\n\tthrow error\n}\n\n/** Removes terminal control characters from untrusted human-readable text. */\nexport const escapeTerminalText = (value: string): string => {\n\tlet escaped = ''\n\tfor (const character of value) {\n\t\tif (!isTerminalControl(character)) {\n\t\t\tescaped += character\n\t\t}\n\t}\n\treturn escaped\n}\n\nconst isTerminalControl = (character: string): boolean => {\n\tconst codePoint = character.codePointAt(0)\n\treturn codePoint !== undefined && (codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f))\n}\n\n// generic in the field so that `format` is a single signature here, not a union of them\nconst renderTableCell = <T, K extends keyof T & string>(column: OutputTableColumns<T>[K], row: T): string =>\n\tcolumn.format ? column.format(row[column.field], row) : formatCell(row[column.field])\n\nconst formatCell = (value: unknown): string => {\n\tif (value === undefined || value === null) {\n\t\treturn ''\n\t}\n\tif (typeof value === 'string') {\n\t\treturn escapeTerminalText(value)\n\t}\n\tif (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {\n\t\treturn String(value)\n\t}\n\treturn JSON.stringify(value) ?? ''\n}\n\nconst toScalarLines = (value: unknown): string[] => {\n\tconst values: unknown[] = Array.isArray(value) ? value : [value]\n\tif (!values.every(isOutputScalar)) {\n\t\tthrow new TypeError('Quiet output requires a scalar value or an array of scalar values. Pass an explicit quiet projection for structured data.')\n\t}\n\treturn values.filter(it => it !== undefined && it !== null).map(formatCell)\n}\n\nconst isOutputScalar = (value: unknown): value is OutputScalar =>\n\tvalue === null || value === undefined || ['string', 'number', 'boolean', 'bigint'].includes(typeof value)\n"],"names":[],"mappings":";;;;;;;AAgDO,MAAM,oBAAoB,CAAC,YAA4C;AAC7E,MAAI,QAAQ,MAAM;AACjB,WAAO;AAAA,EACR;AACA,MAAI,QAAQ,OAAO;AAClB,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAQO,MAAM,OAAO;AAAA,EAQnB,Y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D,MAAI,CAAC,OAAO,MAAM,cAAc,GAAG;AAClC,UAAM,IAAI,UAAU,2HAA2H;AAAA,EAChJ;AACA,SAAO,OAAO,OAAO,CAAA,OAAM,OAAO,UAAa,OAAO,IAAI,EAAE,IAAI,UAAU;AAC3E;AAEA,MAAM,iBAAiB,CAAC,UACvB,UAAU,QAAQ,UAAU,UAAa,CAAC,UAAU,UAAU,WAAW,QAAQ,EAAE,SAAS,OAAO,KAAK;"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const node_util = require("node:util");
4
+ const detectColorSupport = () => {
5
+ const forceColor = process.env.FORCE_COLOR;
6
+ if (forceColor !== void 0) {
7
+ return forceColor !== "0" && forceColor !== "false";
8
+ }
9
+ const stdout = process.stdout;
10
+ return stdout.isTTY === true && (typeof stdout.hasColors !== "function" || stdout.hasColors());
11
+ };
12
+ const terminalSupportsColor = detectColorSupport();
13
+ let colorsEnabled = terminalSupportsColor;
14
+ const setColorsEnabled = (enabled) => {
15
+ colorsEnabled = enabled;
16
+ };
17
+ const areColorsEnabled = () => colorsEnabled;
18
+ const style = (styles, text) => {
19
+ if (!colorsEnabled) {
20
+ return text;
21
+ }
22
+ const list = typeof styles === "string" ? [styles] : styles;
23
+ return list.reduceRight((result, current) => node_util.styleText(current, result, { validateStream: false }), text);
24
+ };
25
+ exports.areColorsEnabled = areColorsEnabled;
26
+ exports.setColorsEnabled = setColorsEnabled;
27
+ exports.style = style;
28
+ exports.terminalSupportsColor = terminalSupportsColor;
29
+ //# sourceMappingURL=colors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.cjs","sources":["../../../../../packages/cli-common/src/application/colors.ts"],"sourcesContent":["import { styleText } from 'node:util'\n\nexport type TextStyle = Exclude<Parameters<typeof styleText>[0], readonly unknown[]>\n\n// Same detection as in @contember/logger's PrettyPrintLoggerHandler (which cannot depend on cli-common); keep them in sync.\nconst detectColorSupport = (): boolean => {\n\tconst forceColor = process.env.FORCE_COLOR\n\tif (forceColor !== undefined) {\n\t\treturn forceColor !== '0' && forceColor !== 'false'\n\t}\n\t// hasColors() honours NO_COLOR, NODE_DISABLE_COLORS and TERM=dumb; Bun's non-TTY stdout has no hasColors.\n\tconst stdout = process.stdout\n\treturn stdout.isTTY === true && (typeof stdout.hasColors !== 'function' || stdout.hasColors())\n}\n\n/** Whether stdout can show colors, detected once at startup. */\nexport const terminalSupportsColor: boolean = detectColorSupport()\n\nlet colorsEnabled = terminalSupportsColor\n\n/** Turns colored output on or off for the whole process (`--no-color`, machine-readable modes). */\nexport const setColorsEnabled = (enabled: boolean): void => {\n\tcolorsEnabled = enabled\n}\n\nexport const areColorsEnabled = (): boolean => colorsEnabled\n\n/** Styles `text` with the given styles (outermost first), or returns it unchanged when colors are off. */\nexport const style = (styles: TextStyle | readonly TextStyle[], text: string): string => {\n\tif (!colorsEnabled) {\n\t\treturn text\n\t}\n\tconst list: readonly TextStyle[] = typeof styles === 'string' ? [styles] : styles\n\t// validateStream is off because the decision above is ours; Bun ignores the option and Node < 22.13 lacks it.\n\treturn list.reduceRight((result, current) => styleText(current, result, { validateStream: false }), text)\n}\n"],"names":["styleText"],"mappings":";;;AAKA,MAAM,qBAAqB,MAAe;AACzC,QAAM,aAAa,QAAQ,IAAI;AAC/B,MAAI,eAAe,QAAW;AAC7B,WAAO,eAAe,OAAO,eAAe;AAAA,EAC7C;AAEA,QAAM,SAAS,QAAQ;AACvB,SAAO,OAAO,UAAU,SAAS,OAAO,OAAO,cAAc,cAAc,OAAO;AACnF;AAGO,MAAM,wBAAiC,mBAAA;AAE9C,IAAI,gBAAgB;AAGb,MAAM,mBAAmB,CAAC,YAA2B;AAC3D,kBAAgB;AACjB;AAEO,MAAM,mBAAmB,MAAe;AAGxC,MAAM,QAAQ,CAAC,QAA0C,SAAyB;AACxF,MAAI,CAAC,eAAe;AACnB,WAAO;AAAA,EACR;AACA,QAAM,OAA6B,OAAO,WAAW,WAAW,CAAC,MAAM,IAAI;AAE3E,SAAO,KAAK,YAAY,CAAC,QAAQ,YAAYA,UAAAA,UAAU,SAAS,QAAQ,EAAE,gBAAgB,MAAA,CAAO,GAAG,IAAI;AACzG;;;;;"}
@@ -0,0 +1,29 @@
1
+ import { styleText } from "node:util";
2
+ const detectColorSupport = () => {
3
+ const forceColor = process.env.FORCE_COLOR;
4
+ if (forceColor !== void 0) {
5
+ return forceColor !== "0" && forceColor !== "false";
6
+ }
7
+ const stdout = process.stdout;
8
+ return stdout.isTTY === true && (typeof stdout.hasColors !== "function" || stdout.hasColors());
9
+ };
10
+ const terminalSupportsColor = detectColorSupport();
11
+ let colorsEnabled = terminalSupportsColor;
12
+ const setColorsEnabled = (enabled) => {
13
+ colorsEnabled = enabled;
14
+ };
15
+ const areColorsEnabled = () => colorsEnabled;
16
+ const style = (styles, text) => {
17
+ if (!colorsEnabled) {
18
+ return text;
19
+ }
20
+ const list = typeof styles === "string" ? [styles] : styles;
21
+ return list.reduceRight((result, current) => styleText(current, result, { validateStream: false }), text);
22
+ };
23
+ export {
24
+ areColorsEnabled,
25
+ setColorsEnabled,
26
+ style,
27
+ terminalSupportsColor
28
+ };
29
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.js","sources":["../../../../../packages/cli-common/src/application/colors.ts"],"sourcesContent":["import { styleText } from 'node:util'\n\nexport type TextStyle = Exclude<Parameters<typeof styleText>[0], readonly unknown[]>\n\n// Same detection as in @contember/logger's PrettyPrintLoggerHandler (which cannot depend on cli-common); keep them in sync.\nconst detectColorSupport = (): boolean => {\n\tconst forceColor = process.env.FORCE_COLOR\n\tif (forceColor !== undefined) {\n\t\treturn forceColor !== '0' && forceColor !== 'false'\n\t}\n\t// hasColors() honours NO_COLOR, NODE_DISABLE_COLORS and TERM=dumb; Bun's non-TTY stdout has no hasColors.\n\tconst stdout = process.stdout\n\treturn stdout.isTTY === true && (typeof stdout.hasColors !== 'function' || stdout.hasColors())\n}\n\n/** Whether stdout can show colors, detected once at startup. */\nexport const terminalSupportsColor: boolean = detectColorSupport()\n\nlet colorsEnabled = terminalSupportsColor\n\n/** Turns colored output on or off for the whole process (`--no-color`, machine-readable modes). */\nexport const setColorsEnabled = (enabled: boolean): void => {\n\tcolorsEnabled = enabled\n}\n\nexport const areColorsEnabled = (): boolean => colorsEnabled\n\n/** Styles `text` with the given styles (outermost first), or returns it unchanged when colors are off. */\nexport const style = (styles: TextStyle | readonly TextStyle[], text: string): string => {\n\tif (!colorsEnabled) {\n\t\treturn text\n\t}\n\tconst list: readonly TextStyle[] = typeof styles === 'string' ? [styles] : styles\n\t// validateStream is off because the decision above is ours; Bun ignores the option and Node < 22.13 lacks it.\n\treturn list.reduceRight((result, current) => styleText(current, result, { validateStream: false }), text)\n}\n"],"names":[],"mappings":";AAKA,MAAM,qBAAqB,MAAe;AACzC,QAAM,aAAa,QAAQ,IAAI;AAC/B,MAAI,eAAe,QAAW;AAC7B,WAAO,eAAe,OAAO,eAAe;AAAA,EAC7C;AAEA,QAAM,SAAS,QAAQ;AACvB,SAAO,OAAO,UAAU,SAAS,OAAO,OAAO,cAAc,cAAc,OAAO;AACnF;AAGO,MAAM,wBAAiC,mBAAA;AAE9C,IAAI,gBAAgB;AAGb,MAAM,mBAAmB,CAAC,YAA2B;AAC3D,kBAAgB;AACjB;AAEO,MAAM,mBAAmB,MAAe;AAGxC,MAAM,QAAQ,CAAC,QAA0C,SAAyB;AACxF,MAAI,CAAC,eAAe;AACnB,WAAO;AAAA,EACR;AACA,QAAM,OAA6B,OAAO,WAAW,WAAW,CAAC,MAAM,IAAI;AAE3E,SAAO,KAAK,YAAY,CAAC,QAAQ,YAAY,UAAU,SAAS,QAAQ,EAAE,gBAAgB,MAAA,CAAO,GAAG,IAAI;AACzG;"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const exitProcess = (code) => {
4
+ process.exitCode = code;
5
+ };
6
+ exports.exitProcess = exitProcess;
7
+ //# sourceMappingURL=exitProcess.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exitProcess.cjs","sources":["../../../../../packages/cli-common/src/application/exitProcess.ts"],"sourcesContent":["/**\n * Ends the process with the given exit code without losing buffered output.\n *\n * `process.exit()` terminates immediately and discards whatever `process.stdout` has not yet handed\n * to the OS. Writes to a pipe are asynchronous, so anything past the 64 KB pipe buffer was silently\n * dropped — `contember commands --json | jq` got a truncated document while the same command\n * redirected to a file was complete. Assigning `exitCode` instead lets the runtime exit on its own\n * once the streams have drained, which also covers output written directly through `console.log`.\n */\nexport const exitProcess = (code: number): void => {\n\tprocess.exitCode = code\n}\n"],"names":[],"mappings":";;AASO,MAAM,cAAc,CAAC,SAAuB;AAClD,UAAQ,WAAW;AACpB;;"}
@@ -0,0 +1,7 @@
1
+ const exitProcess = (code) => {
2
+ process.exitCode = code;
3
+ };
4
+ export {
5
+ exitProcess
6
+ };
7
+ //# sourceMappingURL=exitProcess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exitProcess.js","sources":["../../../../../packages/cli-common/src/application/exitProcess.ts"],"sourcesContent":["/**\n * Ends the process with the given exit code without losing buffered output.\n *\n * `process.exit()` terminates immediately and discards whatever `process.stdout` has not yet handed\n * to the OS. Writes to a pipe are asynchronous, so anything past the 64 KB pipe buffer was silently\n * dropped — `contember commands --json | jq` got a truncated document while the same command\n * redirected to a file was complete. Assigning `exitCode` instead lets the runtime exit on its own\n * once the streams have drained, which also covers output written directly through `console.log`.\n */\nexport const exitProcess = (code: number): void => {\n\tprocess.exitCode = code\n}\n"],"names":[],"mappings":"AASO,MAAM,cAAc,CAAC,SAAuB;AAClD,UAAQ,WAAW;AACpB;"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const node_util = require("node:util");
4
+ const colors = require("./colors.cjs");
5
+ const visibleLength = (text) => node_util.stripVTControlCharacters(text).length;
6
+ const pad = (text, width) => text + " ".repeat(Math.max(width - visibleLength(text), 0));
7
+ const formatTable = (columns, rows) => {
8
+ const headers = columns.map((column) => colors.style("bold", column.name));
9
+ const widths = columns.map(
10
+ (column, index) => rows.reduce((width, row) => Math.max(width, visibleLength(row[column.field] ?? "")), visibleLength(headers[index]))
11
+ );
12
+ const separator = `+${widths.map((width) => "-".repeat(width + 2)).join("+")}+`;
13
+ const line = (cells) => `| ${cells.map((cell, index) => pad(cell, widths[index])).join(" | ")} |`;
14
+ return [
15
+ separator,
16
+ line(headers),
17
+ separator,
18
+ ...rows.map((row) => line(columns.map((column) => row[column.field] ?? ""))),
19
+ separator
20
+ ].join("\n");
21
+ };
22
+ exports.formatTable = formatTable;
23
+ //# sourceMappingURL=table.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.cjs","sources":["../../../../../packages/cli-common/src/application/table.ts"],"sourcesContent":["import { stripVTControlCharacters } from 'node:util'\nimport { style } from './colors.js'\n\nexport interface TableColumn<Field extends string> {\n\treadonly field: Field\n\treadonly name: string\n}\n\nconst visibleLength = (text: string): number => stripVTControlCharacters(text).length\n\nconst pad = (text: string, width: number): string => text + ' '.repeat(Math.max(width - visibleLength(text), 0))\n\n/** Renders an ASCII table with bold headers; widths ignore ANSI styling in the cells. */\nexport const formatTable = <Field extends string>(\n\tcolumns: readonly TableColumn<Field>[],\n\trows: readonly Partial<Record<Field, string>>[],\n): string => {\n\tconst headers = columns.map(column => style('bold', column.name))\n\tconst widths = columns.map((column, index) =>\n\t\trows.reduce((width, row) => Math.max(width, visibleLength(row[column.field] ?? '')), visibleLength(headers[index]))\n\t)\n\tconst separator = `+${widths.map(width => '-'.repeat(width + 2)).join('+')}+`\n\tconst line = (cells: readonly string[]): string => `| ${cells.map((cell, index) => pad(cell, widths[index])).join(' | ')} |`\n\treturn [\n\t\tseparator,\n\t\tline(headers),\n\t\tseparator,\n\t\t...rows.map(row => line(columns.map(column => row[column.field] ?? ''))),\n\t\tseparator,\n\t].join('\\n')\n}\n"],"names":["stripVTControlCharacters","style"],"mappings":";;;;AAQA,MAAM,gBAAgB,CAAC,SAAyBA,mCAAyB,IAAI,EAAE;AAE/E,MAAM,MAAM,CAAC,MAAc,UAA0B,OAAO,IAAI,OAAO,KAAK,IAAI,QAAQ,cAAc,IAAI,GAAG,CAAC,CAAC;AAGxG,MAAM,cAAc,CAC1B,SACA,SACY;AACZ,QAAM,UAAU,QAAQ,IAAI,CAAA,WAAUC,OAAAA,MAAM,QAAQ,OAAO,IAAI,CAAC;AAChE,QAAM,SAAS,QAAQ;AAAA,IAAI,CAAC,QAAQ,UACnC,KAAK,OAAO,CAAC,OAAO,QAAQ,KAAK,IAAI,OAAO,cAAc,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC,GAAG,cAAc,QAAQ,KAAK,CAAC,CAAC;AAAA,EAAA;AAEnH,QAAM,YAAY,IAAI,OAAO,IAAI,CAAA,UAAS,IAAI,OAAO,QAAQ,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1E,QAAM,OAAO,CAAC,UAAqC,KAAK,MAAM,IAAI,CAAC,MAAM,UAAU,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC;AACxH,SAAO;AAAA,IACN;AAAA,IACA,KAAK,OAAO;AAAA,IACZ;AAAA,IACA,GAAG,KAAK,IAAI,CAAA,QAAO,KAAK,QAAQ,IAAI,CAAA,WAAU,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC;AAAA,IACvE;AAAA,EAAA,EACC,KAAK,IAAI;AACZ;;"}
@@ -0,0 +1,23 @@
1
+ import { stripVTControlCharacters } from "node:util";
2
+ import { style } from "./colors.js";
3
+ const visibleLength = (text) => stripVTControlCharacters(text).length;
4
+ const pad = (text, width) => text + " ".repeat(Math.max(width - visibleLength(text), 0));
5
+ const formatTable = (columns, rows) => {
6
+ const headers = columns.map((column) => style("bold", column.name));
7
+ const widths = columns.map(
8
+ (column, index) => rows.reduce((width, row) => Math.max(width, visibleLength(row[column.field] ?? "")), visibleLength(headers[index]))
9
+ );
10
+ const separator = `+${widths.map((width) => "-".repeat(width + 2)).join("+")}+`;
11
+ const line = (cells) => `| ${cells.map((cell, index) => pad(cell, widths[index])).join(" | ")} |`;
12
+ return [
13
+ separator,
14
+ line(headers),
15
+ separator,
16
+ ...rows.map((row) => line(columns.map((column) => row[column.field] ?? ""))),
17
+ separator
18
+ ].join("\n");
19
+ };
20
+ export {
21
+ formatTable
22
+ };
23
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.js","sources":["../../../../../packages/cli-common/src/application/table.ts"],"sourcesContent":["import { stripVTControlCharacters } from 'node:util'\nimport { style } from './colors.js'\n\nexport interface TableColumn<Field extends string> {\n\treadonly field: Field\n\treadonly name: string\n}\n\nconst visibleLength = (text: string): number => stripVTControlCharacters(text).length\n\nconst pad = (text: string, width: number): string => text + ' '.repeat(Math.max(width - visibleLength(text), 0))\n\n/** Renders an ASCII table with bold headers; widths ignore ANSI styling in the cells. */\nexport const formatTable = <Field extends string>(\n\tcolumns: readonly TableColumn<Field>[],\n\trows: readonly Partial<Record<Field, string>>[],\n): string => {\n\tconst headers = columns.map(column => style('bold', column.name))\n\tconst widths = columns.map((column, index) =>\n\t\trows.reduce((width, row) => Math.max(width, visibleLength(row[column.field] ?? '')), visibleLength(headers[index]))\n\t)\n\tconst separator = `+${widths.map(width => '-'.repeat(width + 2)).join('+')}+`\n\tconst line = (cells: readonly string[]): string => `| ${cells.map((cell, index) => pad(cell, widths[index])).join(' | ')} |`\n\treturn [\n\t\tseparator,\n\t\tline(headers),\n\t\tseparator,\n\t\t...rows.map(row => line(columns.map(column => row[column.field] ?? ''))),\n\t\tseparator,\n\t].join('\\n')\n}\n"],"names":[],"mappings":";;AAQA,MAAM,gBAAgB,CAAC,SAAyB,yBAAyB,IAAI,EAAE;AAE/E,MAAM,MAAM,CAAC,MAAc,UAA0B,OAAO,IAAI,OAAO,KAAK,IAAI,QAAQ,cAAc,IAAI,GAAG,CAAC,CAAC;AAGxG,MAAM,cAAc,CAC1B,SACA,SACY;AACZ,QAAM,UAAU,QAAQ,IAAI,CAAA,WAAU,MAAM,QAAQ,OAAO,IAAI,CAAC;AAChE,QAAM,SAAS,QAAQ;AAAA,IAAI,CAAC,QAAQ,UACnC,KAAK,OAAO,CAAC,OAAO,QAAQ,KAAK,IAAI,OAAO,cAAc,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC,GAAG,cAAc,QAAQ,KAAK,CAAC,CAAC;AAAA,EAAA;AAEnH,QAAM,YAAY,IAAI,OAAO,IAAI,CAAA,UAAS,IAAI,OAAO,QAAQ,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1E,QAAM,OAAO,CAAC,UAAqC,KAAK,MAAM,IAAI,CAAC,MAAM,UAAU,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC;AACxH,SAAO;AAAA,IACN;AAAA,IACA,KAAK,OAAO;AAAA,IACZ;AAAA,IACA,GAAG,KAAK,IAAI,CAAA,QAAO,KAAK,QAAQ,IAAI,CAAA,WAAU,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC;AAAA,IACvE;AAAA,EAAA,EACC,KAAK,IAAI;AACZ;"}