@outfitter/cli 0.2.0 → 0.4.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.
Files changed (261) hide show
  1. package/README.md +47 -4
  2. package/dist/actions.js +0 -2
  3. package/dist/cli.d.ts +1 -1
  4. package/dist/cli.js +1 -2
  5. package/dist/{render → colors}/colors.d.ts +1 -1
  6. package/dist/{render → colors}/colors.js +2 -6
  7. package/dist/colors/index.d.ts +1 -1
  8. package/dist/colors/index.js +3 -4
  9. package/dist/command.d.ts +1 -1
  10. package/dist/command.js +1 -2
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.js +4 -5
  13. package/dist/input.d.ts +3 -26
  14. package/dist/input.js +1 -31
  15. package/dist/output.d.ts +3 -3
  16. package/dist/output.js +4 -3
  17. package/dist/pagination.d.ts +1 -1
  18. package/dist/pagination.js +0 -2
  19. package/dist/shared/@outfitter/{cli-ttt7r0j7.d.ts → cli-02kyvj7h.d.ts} +2 -13
  20. package/dist/shared/@outfitter/{cli-8gg0hck1.js → cli-7wp5nj0s.js} +16 -12
  21. package/dist/shared/@outfitter/{cli-72kg550t.d.ts → cli-f79bwzsp.d.ts} +30 -2
  22. package/dist/shared/@outfitter/{cli-d9ad0rqj.js → cli-jbj78ac5.js} +1 -6
  23. package/dist/shared/@outfitter/{cli-5g6rkv3d.js → cli-rk9zagkm.js} +24 -32
  24. package/dist/shared/@outfitter/{cli-efy6jfcj.js → cli-zahqsaby.js} +33 -10
  25. package/dist/terminal/detection.js +1 -5
  26. package/dist/terminal/index.js +1 -6
  27. package/dist/{shared/@outfitter/cli-4cb5g831.d.ts → text.d.ts} +1 -1
  28. package/dist/{shared/@outfitter/cli-mwxsh3sr.js → text.js} +15 -14
  29. package/dist/types.d.ts +2 -2
  30. package/dist/types.js +0 -2
  31. package/package.json +35 -213
  32. package/dist/borders/index.d.ts +0 -3
  33. package/dist/borders/index.js +0 -13
  34. package/dist/box/index.d.ts +0 -4
  35. package/dist/box/index.js +0 -13
  36. package/dist/demo/index.d.ts +0 -78
  37. package/dist/demo/index.js +0 -148
  38. package/dist/demo/registry.d.ts +0 -7
  39. package/dist/demo/registry.js +0 -28
  40. package/dist/demo/renderers/borders.d.ts +0 -7
  41. package/dist/demo/renderers/borders.js +0 -17
  42. package/dist/demo/renderers/box.d.ts +0 -7
  43. package/dist/demo/renderers/box.js +0 -18
  44. package/dist/demo/renderers/colors.d.ts +0 -7
  45. package/dist/demo/renderers/colors.js +0 -18
  46. package/dist/demo/renderers/indicators.d.ts +0 -7
  47. package/dist/demo/renderers/indicators.js +0 -17
  48. package/dist/demo/renderers/list.d.ts +0 -7
  49. package/dist/demo/renderers/list.js +0 -19
  50. package/dist/demo/renderers/markdown.d.ts +0 -7
  51. package/dist/demo/renderers/markdown.js +0 -18
  52. package/dist/demo/renderers/progress.d.ts +0 -7
  53. package/dist/demo/renderers/progress.js +0 -17
  54. package/dist/demo/renderers/spinner.d.ts +0 -7
  55. package/dist/demo/renderers/spinner.js +0 -19
  56. package/dist/demo/renderers/table.d.ts +0 -7
  57. package/dist/demo/renderers/table.js +0 -19
  58. package/dist/demo/renderers/text.d.ts +0 -7
  59. package/dist/demo/renderers/text.js +0 -16
  60. package/dist/demo/renderers/tree.d.ts +0 -7
  61. package/dist/demo/renderers/tree.js +0 -18
  62. package/dist/demo/section.d.ts +0 -5
  63. package/dist/demo/section.js +0 -23
  64. package/dist/demo/templates.d.ts +0 -4
  65. package/dist/demo/templates.js +0 -10
  66. package/dist/demo/types.d.ts +0 -3
  67. package/dist/demo/types.js +0 -8
  68. package/dist/list/index.d.ts +0 -3
  69. package/dist/list/index.js +0 -9
  70. package/dist/preset/full.d.ts +0 -14
  71. package/dist/preset/full.js +0 -41
  72. package/dist/preset/standard.d.ts +0 -11
  73. package/dist/preset/standard.js +0 -30
  74. package/dist/prompt/confirm.d.ts +0 -4
  75. package/dist/prompt/confirm.js +0 -9
  76. package/dist/prompt/group.d.ts +0 -4
  77. package/dist/prompt/group.js +0 -9
  78. package/dist/prompt/index.d.ts +0 -7
  79. package/dist/prompt/index.js +0 -32
  80. package/dist/prompt/select.d.ts +0 -4
  81. package/dist/prompt/select.js +0 -11
  82. package/dist/prompt/text.d.ts +0 -4
  83. package/dist/prompt/text.js +0 -11
  84. package/dist/prompt/types.d.ts +0 -3
  85. package/dist/prompt/types.js +0 -8
  86. package/dist/prompt/validators.d.ts +0 -2
  87. package/dist/prompt/validators.js +0 -8
  88. package/dist/render/borders.d.ts +0 -2
  89. package/dist/render/borders.js +0 -15
  90. package/dist/render/box.d.ts +0 -3
  91. package/dist/render/box.js +0 -23
  92. package/dist/render/date.d.ts +0 -2
  93. package/dist/render/date.js +0 -12
  94. package/dist/render/format-relative.d.ts +0 -2
  95. package/dist/render/format-relative.js +0 -8
  96. package/dist/render/format.d.ts +0 -2
  97. package/dist/render/format.js +0 -10
  98. package/dist/render/heading.d.ts +0 -3
  99. package/dist/render/heading.js +0 -14
  100. package/dist/render/index.d.ts +0 -32
  101. package/dist/render/index.js +0 -235
  102. package/dist/render/indicators.d.ts +0 -2
  103. package/dist/render/indicators.js +0 -16
  104. package/dist/render/json.d.ts +0 -2
  105. package/dist/render/json.js +0 -10
  106. package/dist/render/layout.d.ts +0 -5
  107. package/dist/render/layout.js +0 -25
  108. package/dist/render/list.d.ts +0 -2
  109. package/dist/render/list.js +0 -8
  110. package/dist/render/markdown.d.ts +0 -2
  111. package/dist/render/markdown.js +0 -10
  112. package/dist/render/progress.d.ts +0 -2
  113. package/dist/render/progress.js +0 -8
  114. package/dist/render/separator.d.ts +0 -3
  115. package/dist/render/separator.js +0 -14
  116. package/dist/render/shapes.d.ts +0 -2
  117. package/dist/render/shapes.js +0 -35
  118. package/dist/render/spinner.d.ts +0 -2
  119. package/dist/render/spinner.js +0 -12
  120. package/dist/render/stack.d.ts +0 -3
  121. package/dist/render/stack.js +0 -38
  122. package/dist/render/table.d.ts +0 -3
  123. package/dist/render/table.js +0 -12
  124. package/dist/render/text.d.ts +0 -2
  125. package/dist/render/text.js +0 -27
  126. package/dist/render/tree.d.ts +0 -2
  127. package/dist/render/tree.js +0 -10
  128. package/dist/render/types.d.ts +0 -2
  129. package/dist/shared/@outfitter/cli-0djg8q91.js +0 -7
  130. package/dist/shared/@outfitter/cli-0w242qtv.d.ts +0 -48
  131. package/dist/shared/@outfitter/cli-1g8tt31a.d.ts +0 -119
  132. package/dist/shared/@outfitter/cli-1kwbnt86.d.ts +0 -45
  133. package/dist/shared/@outfitter/cli-1sb3xvnw.js +0 -95
  134. package/dist/shared/@outfitter/cli-1vy0vtga.js +0 -135
  135. package/dist/shared/@outfitter/cli-2g8bx1aq.d.ts +0 -50
  136. package/dist/shared/@outfitter/cli-33e97cjs.d.ts +0 -42
  137. package/dist/shared/@outfitter/cli-3b7ed3rm.d.ts +0 -97
  138. package/dist/shared/@outfitter/cli-3hk2xf3c.js +0 -82
  139. package/dist/shared/@outfitter/cli-3hp8qwx3.js +0 -11
  140. package/dist/shared/@outfitter/cli-47yw5h6a.js +0 -7
  141. package/dist/shared/@outfitter/cli-4b6tbp68.d.ts +0 -36
  142. package/dist/shared/@outfitter/cli-4fcz51qa.js +0 -70
  143. package/dist/shared/@outfitter/cli-4x6pqnez.js +0 -20
  144. package/dist/shared/@outfitter/cli-4zk2y4a2.d.ts +0 -61
  145. package/dist/shared/@outfitter/cli-60b5xh1r.js +0 -20
  146. package/dist/shared/@outfitter/cli-6bztk73z.d.ts +0 -51
  147. package/dist/shared/@outfitter/cli-6fxffp8k.js +0 -1
  148. package/dist/shared/@outfitter/cli-6hg0sg2d.d.ts +0 -93
  149. package/dist/shared/@outfitter/cli-6r3m2knf.js +0 -62
  150. package/dist/shared/@outfitter/cli-6ty1nvws.js +0 -179
  151. package/dist/shared/@outfitter/cli-7n610r63.js +0 -20
  152. package/dist/shared/@outfitter/cli-7na6p4fs.d.ts +0 -59
  153. package/dist/shared/@outfitter/cli-83jwvj1t.d.ts +0 -17
  154. package/dist/shared/@outfitter/cli-85fg2vr5.js +0 -123
  155. package/dist/shared/@outfitter/cli-8bwaw3pz.js +0 -7
  156. package/dist/shared/@outfitter/cli-8hngbjyr.d.ts +0 -164
  157. package/dist/shared/@outfitter/cli-8j5k6mr3.js +0 -71
  158. package/dist/shared/@outfitter/cli-8xsmsbbd.d.ts +0 -223
  159. package/dist/shared/@outfitter/cli-914d47mt.js +0 -20
  160. package/dist/shared/@outfitter/cli-9bcm4zhf.d.ts +0 -87
  161. package/dist/shared/@outfitter/cli-9khk3cbq.d.ts +0 -190
  162. package/dist/shared/@outfitter/cli-a4q87517.d.ts +0 -64
  163. package/dist/shared/@outfitter/cli-aem6v4c8.js +0 -146
  164. package/dist/shared/@outfitter/cli-b0tzqgnf.d.ts +0 -132
  165. package/dist/shared/@outfitter/cli-b5c2k0d7.js +0 -39
  166. package/dist/shared/@outfitter/cli-b5epywry.js +0 -1
  167. package/dist/shared/@outfitter/cli-bc17qeh2.js +0 -19
  168. package/dist/shared/@outfitter/cli-bcmcaz1b.js +0 -23
  169. package/dist/shared/@outfitter/cli-bv09nme3.d.ts +0 -56
  170. package/dist/shared/@outfitter/cli-c6pbxpw0.d.ts +0 -112
  171. package/dist/shared/@outfitter/cli-c8fqdaes.js +0 -117
  172. package/dist/shared/@outfitter/cli-c8q4f71g.js +0 -144
  173. package/dist/shared/@outfitter/cli-c9knfqn5.d.ts +0 -30
  174. package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +0 -53
  175. package/dist/shared/@outfitter/cli-cf2s94s1.d.ts +0 -42
  176. package/dist/shared/@outfitter/cli-cwgj6mcs.js +0 -214
  177. package/dist/shared/@outfitter/cli-d8ahdd9d.js +0 -272
  178. package/dist/shared/@outfitter/cli-dbyteh27.d.ts +0 -24
  179. package/dist/shared/@outfitter/cli-e5ms1y0x.d.ts +0 -91
  180. package/dist/shared/@outfitter/cli-en6zn6sj.js +0 -1
  181. package/dist/shared/@outfitter/cli-evx7qcp1.d.ts +0 -300
  182. package/dist/shared/@outfitter/cli-f6fsaayd.js +0 -94
  183. package/dist/shared/@outfitter/cli-fakncnjp.d.ts +0 -106
  184. package/dist/shared/@outfitter/cli-ffa0jwb7.js +0 -122
  185. package/dist/shared/@outfitter/cli-h20jc0bs.d.ts +0 -66
  186. package/dist/shared/@outfitter/cli-h3jz0bxz.js +0 -48
  187. package/dist/shared/@outfitter/cli-h4wpzb3f.js +0 -67
  188. package/dist/shared/@outfitter/cli-hda6mc28.js +0 -126
  189. package/dist/shared/@outfitter/cli-hnpbqmc8.d.ts +0 -328
  190. package/dist/shared/@outfitter/cli-j19a91ck.js +0 -30
  191. package/dist/shared/@outfitter/cli-jejfypgf.js +0 -85
  192. package/dist/shared/@outfitter/cli-jp0k3qd9.js +0 -279
  193. package/dist/shared/@outfitter/cli-k76e7173.js +0 -128
  194. package/dist/shared/@outfitter/cli-kc3ffp1v.d.ts +0 -23
  195. package/dist/shared/@outfitter/cli-kk5hnndk.d.ts +0 -128
  196. package/dist/shared/@outfitter/cli-ktqme80d.js +0 -7
  197. package/dist/shared/@outfitter/cli-mq0jp15z.js +0 -1
  198. package/dist/shared/@outfitter/cli-n0c33vba.js +0 -25
  199. package/dist/shared/@outfitter/cli-n17gt1dz.js +0 -19
  200. package/dist/shared/@outfitter/cli-n9dbh0hp.js +0 -51
  201. package/dist/shared/@outfitter/cli-ndem6tz8.js +0 -63
  202. package/dist/shared/@outfitter/cli-nj4nqy1h.d.ts +0 -24
  203. package/dist/shared/@outfitter/cli-nkns8p4r.js +0 -61
  204. package/dist/shared/@outfitter/cli-p3dqm1vd.js +0 -22
  205. package/dist/shared/@outfitter/cli-pndwprz8.js +0 -118
  206. package/dist/shared/@outfitter/cli-pvrwv6rb.js +0 -352
  207. package/dist/shared/@outfitter/cli-py02m79x.d.ts +0 -20
  208. package/dist/shared/@outfitter/cli-qj83y5wj.d.ts +0 -71
  209. package/dist/shared/@outfitter/cli-regjbef6.d.ts +0 -26
  210. package/dist/shared/@outfitter/cli-s1tx5kha.d.ts +0 -59
  211. package/dist/shared/@outfitter/cli-sam2sq50.js +0 -37
  212. package/dist/shared/@outfitter/cli-snxj55n6.js +0 -43
  213. package/dist/shared/@outfitter/cli-symyxb0z.js +0 -20
  214. package/dist/shared/@outfitter/cli-tvw1xrdj.js +0 -20
  215. package/dist/shared/@outfitter/cli-v1tzwxkt.js +0 -32
  216. package/dist/shared/@outfitter/cli-vd60dj65.js +0 -1
  217. package/dist/shared/@outfitter/cli-vfcrskfj.d.ts +0 -41
  218. package/dist/shared/@outfitter/cli-vstbkzky.d.ts +0 -74
  219. package/dist/shared/@outfitter/cli-vtg0sqk2.d.ts +0 -54
  220. package/dist/shared/@outfitter/cli-x4cavvc0.js +0 -1
  221. package/dist/shared/@outfitter/cli-xep6v2c0.js +0 -52
  222. package/dist/shared/@outfitter/cli-xg5y5fhk.js +0 -86
  223. package/dist/shared/@outfitter/cli-y7k1t81k.js +0 -30
  224. package/dist/shared/@outfitter/cli-yfyzy95c.js +0 -67
  225. package/dist/shared/@outfitter/cli-z78mkrc7.js +0 -59
  226. package/dist/shared/@outfitter/cli-znc47004.js +0 -134
  227. package/dist/shared/@outfitter/cli-zx598p8q.d.ts +0 -26
  228. package/dist/streaming/ansi.d.ts +0 -2
  229. package/dist/streaming/ansi.js +0 -8
  230. package/dist/streaming/index.d.ts +0 -4
  231. package/dist/streaming/index.js +0 -17
  232. package/dist/streaming/spinner.d.ts +0 -3
  233. package/dist/streaming/spinner.js +0 -10
  234. package/dist/streaming/writer.d.ts +0 -2
  235. package/dist/streaming/writer.js +0 -9
  236. package/dist/table/index.d.ts +0 -4
  237. package/dist/table/index.js +0 -13
  238. package/dist/theme/context.d.ts +0 -9
  239. package/dist/theme/context.js +0 -14
  240. package/dist/theme/create.d.ts +0 -8
  241. package/dist/theme/create.js +0 -12
  242. package/dist/theme/index.d.ts +0 -17
  243. package/dist/theme/index.js +0 -42
  244. package/dist/theme/presets/bold.d.ts +0 -8
  245. package/dist/theme/presets/bold.js +0 -12
  246. package/dist/theme/presets/default.d.ts +0 -8
  247. package/dist/theme/presets/default.js +0 -11
  248. package/dist/theme/presets/index.d.ts +0 -12
  249. package/dist/theme/presets/index.js +0 -24
  250. package/dist/theme/presets/minimal.d.ts +0 -8
  251. package/dist/theme/presets/minimal.js +0 -12
  252. package/dist/theme/presets/rounded.d.ts +0 -8
  253. package/dist/theme/presets/rounded.js +0 -12
  254. package/dist/theme/resolve.d.ts +0 -8
  255. package/dist/theme/resolve.js +0 -11
  256. package/dist/theme/types.d.ts +0 -7
  257. package/dist/theme/types.js +0 -1
  258. package/dist/tree/index.d.ts +0 -3
  259. package/dist/tree/index.js +0 -11
  260. /package/dist/shared/@outfitter/{cli-ykxn7rb2.d.ts → cli-xppg982q.d.ts} +0 -0
  261. /package/dist/{render/types.js → shared/@outfitter/cli-zw75pdk8.js} +0 -0
@@ -1,144 +0,0 @@
1
- // @bun
2
- // packages/cli/src/render/date.ts
3
- import { Result, ValidationError } from "@outfitter/contracts";
4
- var ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
5
- var NAMED_RANGES = ["today", "yesterday", "last week", "last month"];
6
- function startOfDay(date) {
7
- const result = new Date(date);
8
- result.setHours(0, 0, 0, 0);
9
- return result;
10
- }
11
- function endOfDay(date) {
12
- const result = new Date(date);
13
- result.setHours(23, 59, 59, 999);
14
- return result;
15
- }
16
- function isNamedRange(input) {
17
- return NAMED_RANGES.includes(input);
18
- }
19
- function parseNamedRange(name) {
20
- const now = new Date(Date.now());
21
- switch (name) {
22
- case "today": {
23
- return {
24
- start: startOfDay(now),
25
- end: endOfDay(now)
26
- };
27
- }
28
- case "yesterday": {
29
- const yesterday = new Date(now);
30
- yesterday.setDate(yesterday.getDate() - 1);
31
- return {
32
- start: startOfDay(yesterday),
33
- end: endOfDay(yesterday)
34
- };
35
- }
36
- case "last week": {
37
- const weekAgo = new Date(now);
38
- weekAgo.setDate(weekAgo.getDate() - 7);
39
- return {
40
- start: startOfDay(weekAgo),
41
- end: endOfDay(now)
42
- };
43
- }
44
- case "last month": {
45
- const monthAgo = new Date(now);
46
- monthAgo.setDate(monthAgo.getDate() - 30);
47
- return {
48
- start: startOfDay(monthAgo),
49
- end: endOfDay(now)
50
- };
51
- }
52
- default: {
53
- const _exhaustive = name;
54
- throw new Error(`Unhandled named range: ${_exhaustive}`);
55
- }
56
- }
57
- }
58
- function parseIsoDate(dateStr) {
59
- if (!ISO_DATE_REGEX.test(dateStr)) {
60
- return null;
61
- }
62
- const parts = dateStr.split("-");
63
- const yearStr = parts[0];
64
- const monthStr = parts[1];
65
- const dayStr = parts[2];
66
- if (yearStr === undefined || monthStr === undefined || dayStr === undefined) {
67
- return null;
68
- }
69
- const year = Number.parseInt(yearStr, 10);
70
- const month = Number.parseInt(monthStr, 10) - 1;
71
- const day = Number.parseInt(dayStr, 10);
72
- const date = new Date(year, month, day);
73
- if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) {
74
- return null;
75
- }
76
- return date;
77
- }
78
- function parseDateRange(input) {
79
- const trimmed = input.trim();
80
- if (trimmed === "") {
81
- return Result.err(new ValidationError({
82
- message: "Date range input cannot be empty",
83
- field: "dateRange"
84
- }));
85
- }
86
- const normalized = trimmed.toLowerCase();
87
- if (isNamedRange(normalized)) {
88
- return Result.ok(parseNamedRange(normalized));
89
- }
90
- if (trimmed.includes("..")) {
91
- const parts = trimmed.split("..");
92
- if (parts.length !== 2 || parts[0] === "" || parts[1] === "") {
93
- return Result.err(new ValidationError({
94
- message: 'Invalid date range format. Expected "YYYY-MM-DD..YYYY-MM-DD"',
95
- field: "dateRange"
96
- }));
97
- }
98
- const startStr = parts[0];
99
- const endStr = parts[1];
100
- if (startStr === undefined || endStr === undefined) {
101
- return Result.err(new ValidationError({
102
- message: 'Invalid date range format. Expected "YYYY-MM-DD..YYYY-MM-DD"',
103
- field: "dateRange"
104
- }));
105
- }
106
- const startDate = parseIsoDate(startStr);
107
- const endDate = parseIsoDate(endStr);
108
- if (startDate === null) {
109
- return Result.err(new ValidationError({
110
- message: `Invalid start date: "${startStr}". Expected format: YYYY-MM-DD`,
111
- field: "dateRange"
112
- }));
113
- }
114
- if (endDate === null) {
115
- return Result.err(new ValidationError({
116
- message: `Invalid end date: "${endStr}". Expected format: YYYY-MM-DD`,
117
- field: "dateRange"
118
- }));
119
- }
120
- if (startDate.getTime() > endDate.getTime()) {
121
- return Result.err(new ValidationError({
122
- message: "Invalid date range: start date must be before or equal to end date",
123
- field: "dateRange"
124
- }));
125
- }
126
- return Result.ok({
127
- start: startOfDay(startDate),
128
- end: endOfDay(endDate)
129
- });
130
- }
131
- const singleDate = parseIsoDate(trimmed);
132
- if (singleDate !== null) {
133
- return Result.ok({
134
- start: startOfDay(singleDate),
135
- end: endOfDay(singleDate)
136
- });
137
- }
138
- return Result.err(new ValidationError({
139
- message: `Unrecognized date range: "${trimmed}". Expected "today", "yesterday", "last week", "last month", "YYYY-MM-DD", or "YYYY-MM-DD..YYYY-MM-DD"`,
140
- field: "dateRange"
141
- }));
142
- }
143
-
144
- export { startOfDay, endOfDay, parseDateRange };
@@ -1,30 +0,0 @@
1
- /**
2
- * Renders markdown to terminal with ANSI styling.
3
- *
4
- * Supports the following markdown elements:
5
- * - Headings (`# Heading`) - rendered bold
6
- * - Bold (`**text**` or `__text__`) - rendered bold
7
- * - Italic (`*text*` or `_text_`) - rendered italic
8
- * - Inline code (`` `code` ``) - rendered cyan
9
- * - Code blocks (` ``` `) - rendered dim
10
- *
11
- * When colors are not supported, markdown syntax is stripped
12
- * but text content is preserved.
13
- *
14
- * @param markdown - Markdown text to render
15
- * @returns Terminal-formatted string with ANSI codes
16
- *
17
- * @example
18
- * ```typescript
19
- * const md = `# Heading
20
- *
21
- * Some **bold** and *italic* text.
22
- *
23
- * Use \`npm install\` to install.
24
- * `;
25
- *
26
- * console.log(renderMarkdown(md));
27
- * ```
28
- */
29
- declare function renderMarkdown(markdown: string): string;
30
- export { renderMarkdown };
@@ -1,53 +0,0 @@
1
- /**
2
- * Minimal writable stream interface.
3
- */
4
- interface WritableStream {
5
- write(str: string): boolean;
6
- isTTY?: boolean;
7
- }
8
- /**
9
- * Options for creating a stream writer.
10
- */
11
- interface StreamWriterOptions {
12
- /** Target stream (defaults to process.stdout) */
13
- stream?: WritableStream;
14
- }
15
- /**
16
- * Interface for managing in-place terminal output.
17
- */
18
- interface StreamWriter {
19
- /** Write content (replaces current content) */
20
- write(content: string): void;
21
- /** Update content in place */
22
- update(content: string): void;
23
- /** Persist current content and move to new line */
24
- persist(): void;
25
- /** Clear current content */
26
- clear(): void;
27
- }
28
- /**
29
- * Creates a stream writer for in-place terminal updates.
30
- *
31
- * The writer tracks the number of lines written and can update them in place.
32
- * In non-TTY mode, it falls back to simple line-by-line output.
33
- *
34
- * @param options - Writer configuration
35
- * @returns StreamWriter instance
36
- *
37
- * @example
38
- * ```typescript
39
- * import { createStreamWriter } from "@outfitter/cli/streaming";
40
- *
41
- * const writer = createStreamWriter();
42
- *
43
- * writer.write("Processing...");
44
- * // Do some work
45
- * writer.update("Processing... 50%");
46
- * // Do more work
47
- * writer.update("Processing... 100%");
48
- * writer.persist();
49
- * writer.write("Done!");
50
- * ```
51
- */
52
- declare function createStreamWriter(options?: StreamWriterOptions): StreamWriter;
53
- export { WritableStream, StreamWriterOptions, StreamWriter, createStreamWriter };
@@ -1,42 +0,0 @@
1
- /**
2
- * Formatting utilities for human-readable output.
3
- *
4
- * Provides functions to format durations and byte sizes.
5
- *
6
- * @packageDocumentation
7
- */
8
- /**
9
- * Formats milliseconds as human-readable duration.
10
- *
11
- * Converts milliseconds to a compact, human-friendly format using
12
- * h (hours), m (minutes), s (seconds), or ms (milliseconds).
13
- *
14
- * @param ms - Duration in milliseconds
15
- * @returns Human-friendly duration string
16
- *
17
- * @example
18
- * ```typescript
19
- * formatDuration(150) // "150ms"
20
- * formatDuration(45000) // "45s"
21
- * formatDuration(9015000) // "2h 30m 15s"
22
- * ```
23
- */
24
- declare function formatDuration(ms: number): string;
25
- /**
26
- * Formats bytes as human-readable size.
27
- *
28
- * Converts bytes to a compact format using appropriate units
29
- * (B, KB, MB, GB, TB). Uses 1024-based (binary) units.
30
- *
31
- * @param bytes - Size in bytes
32
- * @returns Human-friendly size string
33
- *
34
- * @example
35
- * ```typescript
36
- * formatBytes(500) // "500 B"
37
- * formatBytes(1536) // "1.5 KB"
38
- * formatBytes(1073741824) // "1 GB"
39
- * ```
40
- */
41
- declare function formatBytes(bytes: number): string;
42
- export { formatDuration, formatBytes };
@@ -1,214 +0,0 @@
1
- // @bun
2
- import {
3
- BORDER_STYLE_META,
4
- getBorderStyles
5
- } from "./cli-d8ahdd9d.js";
6
- import {
7
- getExample
8
- } from "./cli-xep6v2c0.js";
9
- import {
10
- demoSection
11
- } from "./cli-sam2sq50.js";
12
- import {
13
- createBox,
14
- init_box,
15
- renderBox
16
- } from "./cli-jp0k3qd9.js";
17
-
18
- // packages/cli/src/demo/renderers/box.ts
19
- init_box();
20
- function renderBoxDemo(config, theme) {
21
- const showCode = config.showCode ?? true;
22
- const showDescriptions = config.showDescriptions ?? true;
23
- const lines = [];
24
- lines.push(demoSection("Basic Box"));
25
- lines.push("");
26
- if (showCode) {
27
- lines.push('import { renderBox } from "@outfitter/cli/render";');
28
- lines.push("");
29
- }
30
- const content = getExample("boxContent", config.examples);
31
- if (showCode) {
32
- lines.push(`renderBox("${content}")`);
33
- lines.push("");
34
- }
35
- lines.push(renderBox(content));
36
- lines.push("");
37
- lines.push(demoSection("Box with Title"));
38
- lines.push("");
39
- const title = getExample("boxTitle", config.examples);
40
- if (showCode) {
41
- lines.push(`renderBox("${content}", { title: "${title}" })`);
42
- lines.push("");
43
- }
44
- lines.push(renderBox(content, { title }));
45
- lines.push("");
46
- lines.push(demoSection("Border Styles"));
47
- lines.push("");
48
- const styles = getBorderStyles().filter((s) => s !== "none");
49
- for (const style of styles) {
50
- const meta = BORDER_STYLE_META[style];
51
- lines.push(`${meta.label.toUpperCase()}`);
52
- if (showDescriptions) {
53
- lines.push(theme.muted(meta.description));
54
- }
55
- lines.push("");
56
- lines.push(renderBox("Content", { border: style }));
57
- lines.push("");
58
- }
59
- lines.push(demoSection("Alignment"));
60
- lines.push("");
61
- const alignments = [
62
- "left",
63
- "center",
64
- "right"
65
- ];
66
- for (const align of alignments) {
67
- if (showCode) {
68
- lines.push(`renderBox("${align}", { width: 30, align: "${align}" })`);
69
- }
70
- lines.push(renderBox(align, { width: 30, align }));
71
- lines.push("");
72
- }
73
- lines.push(demoSection("Multi-Line Content"));
74
- lines.push("");
75
- const multiLine = ["Line one", "Line two", "Line three"];
76
- if (showCode) {
77
- lines.push('renderBox(["Line one", "Line two", "Line three"])');
78
- lines.push("");
79
- }
80
- lines.push(renderBox(multiLine));
81
- lines.push("");
82
- lines.push(demoSection("Sections with Dividers"));
83
- lines.push("");
84
- if (showDescriptions) {
85
- lines.push(theme.muted("Use sections to separate content with internal dividers."));
86
- lines.push("");
87
- }
88
- if (showCode) {
89
- lines.push('renderBox("", {');
90
- lines.push(' sections: ["Header", ["Line 1", "Line 2"], "Footer"],');
91
- lines.push(' border: "rounded",');
92
- lines.push("})");
93
- lines.push("");
94
- }
95
- lines.push(renderBox("", {
96
- sections: ["Header", ["Line 1", "Line 2"], "Footer"],
97
- border: "rounded"
98
- }));
99
- lines.push("");
100
- if (showDescriptions) {
101
- lines.push(theme.muted("Example: Status panel with sections"));
102
- lines.push("");
103
- }
104
- if (showCode) {
105
- lines.push('renderBox("", {');
106
- lines.push(" sections: [");
107
- lines.push(' "System Status",');
108
- lines.push(' ["CPU: 45%", "Memory: 2.1 GB", "Disk: 120 GB free"],');
109
- lines.push(' "Updated: 2 min ago"');
110
- lines.push(" ],");
111
- lines.push(' border: "single",');
112
- lines.push(" width: 30,");
113
- lines.push("})");
114
- lines.push("");
115
- }
116
- lines.push(renderBox("", {
117
- sections: [
118
- "System Status",
119
- ["CPU: 45%", "Memory: 2.1 GB", "Disk: 120 GB free"],
120
- "Updated: 2 min ago"
121
- ],
122
- border: "single",
123
- width: 30
124
- }));
125
- lines.push("");
126
- lines.push(demoSection("Partial Borders"));
127
- lines.push("");
128
- if (showDescriptions) {
129
- lines.push(theme.muted("Control which borders to render with the borders option."));
130
- lines.push("");
131
- }
132
- if (showCode) {
133
- lines.push('renderBox("Top and bottom only", {');
134
- lines.push(" borders: { top: true, bottom: true, left: false, right: false }");
135
- lines.push("})");
136
- lines.push("");
137
- }
138
- lines.push(renderBox("Top and bottom only", {
139
- borders: { top: true, bottom: true, left: false, right: false }
140
- }));
141
- lines.push("");
142
- if (showCode) {
143
- lines.push('renderBox("Left and right only", {');
144
- lines.push(" borders: { top: false, bottom: false, left: true, right: true }");
145
- lines.push("})");
146
- lines.push("");
147
- }
148
- lines.push(renderBox("Left and right only", {
149
- borders: { top: false, bottom: false, left: true, right: true }
150
- }));
151
- lines.push("");
152
- lines.push(demoSection("Margin"));
153
- lines.push("");
154
- if (showDescriptions) {
155
- lines.push(theme.muted("Add spacing outside the box with margin."));
156
- lines.push("");
157
- }
158
- if (showCode) {
159
- lines.push('renderBox("With margin", { margin: { left: 4 } })');
160
- lines.push("");
161
- }
162
- lines.push(renderBox("With margin", { margin: { left: 4 } }));
163
- lines.push("");
164
- lines.push(demoSection("Individual Padding"));
165
- lines.push("");
166
- if (showDescriptions) {
167
- lines.push(theme.muted("Control padding per side with an object."));
168
- lines.push("");
169
- }
170
- if (showCode) {
171
- lines.push('renderBox("Custom padding", {');
172
- lines.push(" padding: { top: 1, bottom: 1, left: 3, right: 1 }");
173
- lines.push("})");
174
- lines.push("");
175
- }
176
- lines.push(renderBox("Custom padding", {
177
- padding: { top: 1, bottom: 1, left: 3, right: 1 }
178
- }));
179
- lines.push("");
180
- lines.push(demoSection("Nested Boxes"));
181
- lines.push("");
182
- if (showDescriptions) {
183
- lines.push(theme.muted("Use createBox() to create composable boxes with metadata."));
184
- lines.push("");
185
- }
186
- if (showCode) {
187
- lines.push('const inner = createBox("Inner content", { border: "rounded" });');
188
- lines.push('const outer = createBox(inner, { border: "double", title: "Container" });');
189
- lines.push("console.log(outer.output);");
190
- lines.push("");
191
- }
192
- const inner = createBox("Inner content", { border: "rounded" });
193
- const outer = createBox(inner, { border: "double", title: "Container" });
194
- lines.push(outer.output);
195
- lines.push("");
196
- if (showDescriptions) {
197
- lines.push(theme.muted("Boxes can be nested to any depth."));
198
- lines.push("");
199
- }
200
- if (showCode) {
201
- lines.push('const level1 = createBox("Core", { border: "single" });');
202
- lines.push('const level2 = createBox(level1, { border: "rounded", title: "Middle" });');
203
- lines.push('const level3 = createBox(level2, { border: "double", title: "Outer" });');
204
- lines.push("");
205
- }
206
- const level1 = createBox("Core", { border: "single" });
207
- const level2 = createBox(level1, { border: "rounded", title: "Middle" });
208
- const level3 = createBox(level2, { border: "double", title: "Outer" });
209
- lines.push(level3.output);
210
- return lines.join(`
211
- `);
212
- }
213
-
214
- export { renderBoxDemo };