teebot 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/teebot.js +21 -13
  2. package/package.json +1 -1
package/bin/teebot.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { execFile } from 'node:child_process'
4
4
 
5
- export const VERSION = '1.0.0'
5
+ export const VERSION = '1.0.2'
6
6
 
7
7
  const VALID_COLORS = ['black', 'white', 'navy', 'grey', 'red', 'asphalt', 'forest', 'gold', 'mauve', 'royal']
8
8
  const VALID_FONTS = ['mono', 'sans', 'serif', 'slab', 'hand']
@@ -51,7 +51,7 @@ export function parseArgs(args) {
51
51
  if (arg === '--color' && i + 1 < args.length) { result.color = args[++i]; i++; continue }
52
52
  if (arg === '--font' && i + 1 < args.length) { result.font = args[++i]; i++; continue }
53
53
  if (arg === '--align' && i + 1 < args.length) { result.align = args[++i]; i++; continue }
54
- if (arg.startsWith('--')) { i++; if (i < args.length && !args[i].startsWith('--')) i++; continue }
54
+ if (arg.startsWith('--') && result.text !== null) { i++; if (i < args.length && !args[i].startsWith('--')) i++; continue }
55
55
  if (result.text === null) result.text = arg
56
56
  i++
57
57
  }
@@ -65,9 +65,9 @@ export function parseArgs(args) {
65
65
  return result
66
66
  }
67
67
 
68
- const BODY_WIDTH = 16
68
+ const BODY_WIDTH = 24
69
69
  const BODY_ROWS = 5
70
- const WRAP_WIDTH = 13
70
+ const WRAP_WIDTH = 21
71
71
 
72
72
  export function wrapText(text, maxWidth) {
73
73
  const lines = []
@@ -85,7 +85,15 @@ export function wrapText(text, maxWidth) {
85
85
  }
86
86
  lines.push(current)
87
87
  }
88
- return lines
88
+ // Break lines that exceed maxWidth
89
+ const broken = []
90
+ for (const line of lines) {
91
+ if (line.length <= maxWidth) { broken.push(line); continue }
92
+ for (let i = 0; i < line.length; i += maxWidth) {
93
+ broken.push(line.slice(i, i + maxWidth))
94
+ }
95
+ }
96
+ return broken
89
97
  }
90
98
 
91
99
  export function centerPad(text, width) {
@@ -103,15 +111,15 @@ export function renderShirt(text) {
103
111
  while (textLines.length < BODY_ROWS) textLines.push('')
104
112
 
105
113
  const shirt = [
106
- ' ┌──────┐',
107
- ' ╭────┤ ├────╮',
108
- ' ╱ ╲ ╱ ╲',
109
- ' ╱ ╲ ╱ ╲',
110
- ' ╱ ╲╱ ╲',
111
- ' │ │',
112
- ' ╰──╮ ╭──╯',
114
+ ' ┌──────┐',
115
+ ' ╭────────┤ ├────────╮',
116
+ ' ╱ ╲ ╱ ╲',
117
+ ' ╱ ╲ ╱ ╲',
118
+ ' ╱ ╲╱ ╲',
119
+ ' │ │',
120
+ ' ╰──╮ ╭──╯',
113
121
  ...textLines.map(line => ' │' + centerPad(line, BODY_WIDTH) + '│'),
114
- ' ╰────────────────╯',
122
+ ' ╰────────────────────────╯',
115
123
  ]
116
124
 
117
125
  return shirt.join('\n')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teebot",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "Design a shirt from your terminal",
6
6
  "bin": {