intershell 0.3.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 (357) hide show
  1. package/README.md +301 -0
  2. package/dist/commands/ci/act.d.ts +13 -0
  3. package/dist/commands/ci/act.d.ts.map +1 -0
  4. package/dist/commands/ci/act.js +89 -0
  5. package/dist/commands/ci/act.js.map +1 -0
  6. package/dist/commands/ci/attach-affected.d.ts +12 -0
  7. package/dist/commands/ci/attach-affected.d.ts.map +1 -0
  8. package/dist/commands/ci/attach-affected.js +83 -0
  9. package/dist/commands/ci/attach-affected.js.map +1 -0
  10. package/dist/commands/ci/attach-service-ports.d.ts +10 -0
  11. package/dist/commands/ci/attach-service-ports.d.ts.map +1 -0
  12. package/dist/commands/ci/attach-service-ports.js +25 -0
  13. package/dist/commands/ci/attach-service-ports.js.map +1 -0
  14. package/dist/commands/commit-check.d.ts +13 -0
  15. package/dist/commands/commit-check.d.ts.map +1 -0
  16. package/dist/commands/commit-check.js +110 -0
  17. package/dist/commands/commit-check.js.map +1 -0
  18. package/dist/commands/commit.d.ts +16 -0
  19. package/dist/commands/commit.d.ts.map +1 -0
  20. package/dist/commands/commit.js +91 -0
  21. package/dist/commands/commit.js.map +1 -0
  22. package/dist/commands/dev/check.d.ts +13 -0
  23. package/dist/commands/dev/check.d.ts.map +1 -0
  24. package/dist/commands/dev/check.js +91 -0
  25. package/dist/commands/dev/check.js.map +1 -0
  26. package/dist/commands/dev/cleanup.d.ts +10 -0
  27. package/dist/commands/dev/cleanup.d.ts.map +1 -0
  28. package/dist/commands/dev/cleanup.js +28 -0
  29. package/dist/commands/dev/cleanup.js.map +1 -0
  30. package/dist/commands/dev/rm.d.ts +12 -0
  31. package/dist/commands/dev/rm.d.ts.map +1 -0
  32. package/dist/commands/dev/rm.js +49 -0
  33. package/dist/commands/dev/rm.js.map +1 -0
  34. package/dist/commands/dev/setup.d.ts +10 -0
  35. package/dist/commands/dev/setup.d.ts.map +1 -0
  36. package/dist/commands/dev/setup.js +40 -0
  37. package/dist/commands/dev/setup.js.map +1 -0
  38. package/dist/commands/local/cleanup.d.ts +12 -0
  39. package/dist/commands/local/cleanup.d.ts.map +1 -0
  40. package/dist/commands/local/cleanup.js +62 -0
  41. package/dist/commands/local/cleanup.js.map +1 -0
  42. package/dist/commands/local/setup.d.ts +11 -0
  43. package/dist/commands/local/setup.d.ts.map +1 -0
  44. package/dist/commands/local/setup.js +55 -0
  45. package/dist/commands/local/setup.js.map +1 -0
  46. package/dist/commands/local/vscode.d.ts +17 -0
  47. package/dist/commands/local/vscode.d.ts.map +1 -0
  48. package/dist/commands/local/vscode.js +94 -0
  49. package/dist/commands/local/vscode.js.map +1 -0
  50. package/dist/commands/update-package-json.d.ts +12 -0
  51. package/dist/commands/update-package-json.d.ts.map +1 -0
  52. package/dist/commands/update-package-json.js +82 -0
  53. package/dist/commands/update-package-json.js.map +1 -0
  54. package/dist/commands/version/apply.d.ts +16 -0
  55. package/dist/commands/version/apply.d.ts.map +1 -0
  56. package/dist/commands/version/apply.js +120 -0
  57. package/dist/commands/version/apply.js.map +1 -0
  58. package/dist/commands/version/ci.d.ts +12 -0
  59. package/dist/commands/version/ci.d.ts.map +1 -0
  60. package/dist/commands/version/ci.js +67 -0
  61. package/dist/commands/version/ci.js.map +1 -0
  62. package/dist/commands/version/prepare.d.ts +19 -0
  63. package/dist/commands/version/prepare.d.ts.map +1 -0
  64. package/dist/commands/version/prepare.js +153 -0
  65. package/dist/commands/version/prepare.js.map +1 -0
  66. package/dist/core/colorify.d.ts +21 -0
  67. package/dist/core/colorify.d.ts.map +1 -0
  68. package/dist/core/colorify.js +56 -0
  69. package/dist/core/colorify.js.map +1 -0
  70. package/dist/core/index.d.ts +4 -0
  71. package/dist/core/index.d.ts.map +1 -0
  72. package/dist/core/index.js +3 -0
  73. package/dist/core/index.js.map +1 -0
  74. package/dist/core/types.d.ts +181 -0
  75. package/dist/core/types.d.ts.map +1 -0
  76. package/dist/core/types.js +5 -0
  77. package/dist/core/types.js.map +1 -0
  78. package/dist/core/wrapshell.d.ts +19 -0
  79. package/dist/core/wrapshell.d.ts.map +1 -0
  80. package/dist/core/wrapshell.js +323 -0
  81. package/dist/core/wrapshell.js.map +1 -0
  82. package/dist/entities/affected/affected.d.ts +4 -0
  83. package/dist/entities/affected/affected.d.ts.map +1 -0
  84. package/dist/entities/affected/affected.js +20 -0
  85. package/dist/entities/affected/affected.js.map +1 -0
  86. package/dist/entities/affected/affected.test.d.ts +2 -0
  87. package/dist/entities/affected/affected.test.d.ts.map +1 -0
  88. package/dist/entities/affected/affected.test.js +305 -0
  89. package/dist/entities/affected/affected.test.js.map +1 -0
  90. package/dist/entities/affected/index.d.ts +2 -0
  91. package/dist/entities/affected/index.d.ts.map +1 -0
  92. package/dist/entities/affected/index.js +2 -0
  93. package/dist/entities/affected/index.js.map +1 -0
  94. package/dist/entities/branch/branch.d.ts +8 -0
  95. package/dist/entities/branch/branch.d.ts.map +1 -0
  96. package/dist/entities/branch/branch.js +74 -0
  97. package/dist/entities/branch/branch.js.map +1 -0
  98. package/dist/entities/branch/branch.test.d.ts +2 -0
  99. package/dist/entities/branch/branch.test.d.ts.map +1 -0
  100. package/dist/entities/branch/branch.test.js +316 -0
  101. package/dist/entities/branch/branch.test.js.map +1 -0
  102. package/dist/entities/branch/branch.types.d.ts +6 -0
  103. package/dist/entities/branch/branch.types.d.ts.map +1 -0
  104. package/dist/entities/branch/branch.types.js +2 -0
  105. package/dist/entities/branch/branch.types.js.map +1 -0
  106. package/dist/entities/branch/index.d.ts +3 -0
  107. package/dist/entities/branch/index.d.ts.map +1 -0
  108. package/dist/entities/branch/index.js +3 -0
  109. package/dist/entities/branch/index.js.map +1 -0
  110. package/dist/entities/commit/commit.d.ts +15 -0
  111. package/dist/entities/commit/commit.d.ts.map +1 -0
  112. package/dist/entities/commit/commit.js +196 -0
  113. package/dist/entities/commit/commit.js.map +1 -0
  114. package/dist/entities/commit/commit.test.d.ts +26 -0
  115. package/dist/entities/commit/commit.test.d.ts.map +1 -0
  116. package/dist/entities/commit/commit.test.js +550 -0
  117. package/dist/entities/commit/commit.test.js.map +1 -0
  118. package/dist/entities/commit/commit.types.d.ts +49 -0
  119. package/dist/entities/commit/commit.types.d.ts.map +1 -0
  120. package/dist/entities/commit/commit.types.js +31 -0
  121. package/dist/entities/commit/commit.types.js.map +1 -0
  122. package/dist/entities/commit/index.d.ts +3 -0
  123. package/dist/entities/commit/index.d.ts.map +1 -0
  124. package/dist/entities/commit/index.js +3 -0
  125. package/dist/entities/commit/index.js.map +1 -0
  126. package/dist/entities/commit/pr.d.ts +11 -0
  127. package/dist/entities/commit/pr.d.ts.map +1 -0
  128. package/dist/entities/commit/pr.js +201 -0
  129. package/dist/entities/commit/pr.js.map +1 -0
  130. package/dist/entities/commit/pr.test.d.ts +2 -0
  131. package/dist/entities/commit/pr.test.d.ts.map +1 -0
  132. package/dist/entities/commit/pr.test.js +782 -0
  133. package/dist/entities/commit/pr.test.js.map +1 -0
  134. package/dist/entities/compose/compose.d.ts +18 -0
  135. package/dist/entities/compose/compose.d.ts.map +1 -0
  136. package/dist/entities/compose/compose.js +197 -0
  137. package/dist/entities/compose/compose.js.map +1 -0
  138. package/dist/entities/compose/compose.test.d.ts +2 -0
  139. package/dist/entities/compose/compose.test.d.ts.map +1 -0
  140. package/dist/entities/compose/compose.test.js +406 -0
  141. package/dist/entities/compose/compose.test.js.map +1 -0
  142. package/dist/entities/compose/compose.types.d.ts +77 -0
  143. package/dist/entities/compose/compose.types.d.ts.map +1 -0
  144. package/dist/entities/compose/compose.types.js +2 -0
  145. package/dist/entities/compose/compose.types.js.map +1 -0
  146. package/dist/entities/compose/index.d.ts +3 -0
  147. package/dist/entities/compose/index.d.ts.map +1 -0
  148. package/dist/entities/compose/index.js +3 -0
  149. package/dist/entities/compose/index.js.map +1 -0
  150. package/dist/entities/entities.shell.d.ts +29 -0
  151. package/dist/entities/entities.shell.d.ts.map +1 -0
  152. package/dist/entities/entities.shell.js +27 -0
  153. package/dist/entities/entities.shell.js.map +1 -0
  154. package/dist/entities/entities.shell.test.d.ts +2 -0
  155. package/dist/entities/entities.shell.test.d.ts.map +1 -0
  156. package/dist/entities/entities.shell.test.js +23 -0
  157. package/dist/entities/entities.shell.test.js.map +1 -0
  158. package/dist/entities/index.d.ts +12 -0
  159. package/dist/entities/index.d.ts.map +1 -0
  160. package/dist/entities/index.js +12 -0
  161. package/dist/entities/index.js.map +1 -0
  162. package/dist/entities/intershell-config/intershell-config.d.ts +11 -0
  163. package/dist/entities/intershell-config/intershell-config.d.ts.map +1 -0
  164. package/dist/entities/intershell-config/intershell-config.default.d.ts +188 -0
  165. package/dist/entities/intershell-config/intershell-config.default.d.ts.map +1 -0
  166. package/dist/entities/intershell-config/intershell-config.default.js +225 -0
  167. package/dist/entities/intershell-config/intershell-config.default.js.map +1 -0
  168. package/dist/entities/intershell-config/intershell-config.js +132 -0
  169. package/dist/entities/intershell-config/intershell-config.js.map +1 -0
  170. package/dist/entities/intershell-config/intershell-config.test.d.ts +2 -0
  171. package/dist/entities/intershell-config/intershell-config.test.d.ts.map +1 -0
  172. package/dist/entities/intershell-config/intershell-config.test.js +102 -0
  173. package/dist/entities/intershell-config/intershell-config.test.js.map +1 -0
  174. package/dist/entities/intershell-config/intershell-config.types.d.ts +103 -0
  175. package/dist/entities/intershell-config/intershell-config.types.d.ts.map +1 -0
  176. package/dist/entities/intershell-config/intershell-config.types.js +2 -0
  177. package/dist/entities/intershell-config/intershell-config.types.js.map +1 -0
  178. package/dist/entities/package/index.d.ts +4 -0
  179. package/dist/entities/package/index.d.ts.map +1 -0
  180. package/dist/entities/package/index.js +4 -0
  181. package/dist/entities/package/index.js.map +1 -0
  182. package/dist/entities/package/package.d.ts +49 -0
  183. package/dist/entities/package/package.d.ts.map +1 -0
  184. package/dist/entities/package/package.js +234 -0
  185. package/dist/entities/package/package.js.map +1 -0
  186. package/dist/entities/package/package.shell.d.ts +48 -0
  187. package/dist/entities/package/package.shell.d.ts.map +1 -0
  188. package/dist/entities/package/package.shell.js +118 -0
  189. package/dist/entities/package/package.shell.js.map +1 -0
  190. package/dist/entities/package/package.test.d.ts +23 -0
  191. package/dist/entities/package/package.test.d.ts.map +1 -0
  192. package/dist/entities/package/package.test.js +637 -0
  193. package/dist/entities/package/package.test.js.map +1 -0
  194. package/dist/entities/package/package.types.d.ts +48 -0
  195. package/dist/entities/package/package.types.d.ts.map +1 -0
  196. package/dist/entities/package/package.types.js +2 -0
  197. package/dist/entities/package/package.types.js.map +1 -0
  198. package/dist/entities/package-changelog/index.d.ts +4 -0
  199. package/dist/entities/package-changelog/index.d.ts.map +1 -0
  200. package/dist/entities/package-changelog/index.js +4 -0
  201. package/dist/entities/package-changelog/index.js.map +1 -0
  202. package/dist/entities/package-changelog/package-changelog.d.ts +20 -0
  203. package/dist/entities/package-changelog/package-changelog.d.ts.map +1 -0
  204. package/dist/entities/package-changelog/package-changelog.js +59 -0
  205. package/dist/entities/package-changelog/package-changelog.js.map +1 -0
  206. package/dist/entities/package-changelog/package-changelog.types.d.ts +25 -0
  207. package/dist/entities/package-changelog/package-changelog.types.d.ts.map +1 -0
  208. package/dist/entities/package-changelog/package-changelog.types.js +2 -0
  209. package/dist/entities/package-changelog/package-changelog.types.js.map +1 -0
  210. package/dist/entities/package-changelog/template.d.ts +20 -0
  211. package/dist/entities/package-changelog/template.d.ts.map +1 -0
  212. package/dist/entities/package-changelog/template.default.d.ts +10 -0
  213. package/dist/entities/package-changelog/template.default.d.ts.map +1 -0
  214. package/dist/entities/package-changelog/template.default.js +85 -0
  215. package/dist/entities/package-changelog/template.default.js.map +1 -0
  216. package/dist/entities/package-changelog/template.js +90 -0
  217. package/dist/entities/package-changelog/template.js.map +1 -0
  218. package/dist/entities/package-commits/dependency-analyzer.d.ts +35 -0
  219. package/dist/entities/package-commits/dependency-analyzer.d.ts.map +1 -0
  220. package/dist/entities/package-commits/dependency-analyzer.js +169 -0
  221. package/dist/entities/package-commits/dependency-analyzer.js.map +1 -0
  222. package/dist/entities/package-commits/dependency-analyzer.test.d.ts +2 -0
  223. package/dist/entities/package-commits/dependency-analyzer.test.d.ts.map +1 -0
  224. package/dist/entities/package-commits/dependency-analyzer.test.js +25 -0
  225. package/dist/entities/package-commits/dependency-analyzer.test.js.map +1 -0
  226. package/dist/entities/package-commits/index.d.ts +3 -0
  227. package/dist/entities/package-commits/index.d.ts.map +1 -0
  228. package/dist/entities/package-commits/index.js +3 -0
  229. package/dist/entities/package-commits/index.js.map +1 -0
  230. package/dist/entities/package-commits/package-commits.d.ts +33 -0
  231. package/dist/entities/package-commits/package-commits.d.ts.map +1 -0
  232. package/dist/entities/package-commits/package-commits.js +149 -0
  233. package/dist/entities/package-commits/package-commits.js.map +1 -0
  234. package/dist/entities/package-commits/package-commits.test.d.ts +2 -0
  235. package/dist/entities/package-commits/package-commits.test.d.ts.map +1 -0
  236. package/dist/entities/package-commits/package-commits.test.js +40 -0
  237. package/dist/entities/package-commits/package-commits.test.js.map +1 -0
  238. package/dist/entities/package-tags/index.d.ts +2 -0
  239. package/dist/entities/package-tags/index.d.ts.map +1 -0
  240. package/dist/entities/package-tags/index.js +2 -0
  241. package/dist/entities/package-tags/index.js.map +1 -0
  242. package/dist/entities/package-tags/package-tags.d.ts +24 -0
  243. package/dist/entities/package-tags/package-tags.d.ts.map +1 -0
  244. package/dist/entities/package-tags/package-tags.js +197 -0
  245. package/dist/entities/package-tags/package-tags.js.map +1 -0
  246. package/dist/entities/package-tags/package-tags.test.d.ts +2 -0
  247. package/dist/entities/package-tags/package-tags.test.d.ts.map +1 -0
  248. package/dist/entities/package-tags/package-tags.test.js +60 -0
  249. package/dist/entities/package-tags/package-tags.test.js.map +1 -0
  250. package/dist/entities/package-version/index.d.ts +3 -0
  251. package/dist/entities/package-version/index.d.ts.map +1 -0
  252. package/dist/entities/package-version/index.js +3 -0
  253. package/dist/entities/package-version/index.js.map +1 -0
  254. package/dist/entities/package-version/package-version.d.ts +16 -0
  255. package/dist/entities/package-version/package-version.d.ts.map +1 -0
  256. package/dist/entities/package-version/package-version.js +166 -0
  257. package/dist/entities/package-version/package-version.js.map +1 -0
  258. package/dist/entities/package-version/package-version.test.d.ts +2 -0
  259. package/dist/entities/package-version/package-version.test.d.ts.map +1 -0
  260. package/dist/entities/package-version/package-version.test.js +113 -0
  261. package/dist/entities/package-version/package-version.test.js.map +1 -0
  262. package/dist/entities/package-version/package-version.types.d.ts +31 -0
  263. package/dist/entities/package-version/package-version.types.d.ts.map +1 -0
  264. package/dist/entities/package-version/package-version.types.js +2 -0
  265. package/dist/entities/package-version/package-version.types.js.map +1 -0
  266. package/dist/entities/tag/index.d.ts +3 -0
  267. package/dist/entities/tag/index.d.ts.map +1 -0
  268. package/dist/entities/tag/index.js +3 -0
  269. package/dist/entities/tag/index.js.map +1 -0
  270. package/dist/entities/tag/tag.d.ts +24 -0
  271. package/dist/entities/tag/tag.d.ts.map +1 -0
  272. package/dist/entities/tag/tag.js +168 -0
  273. package/dist/entities/tag/tag.js.map +1 -0
  274. package/dist/entities/tag/tag.test.d.ts +2 -0
  275. package/dist/entities/tag/tag.test.d.ts.map +1 -0
  276. package/dist/entities/tag/tag.test.js +638 -0
  277. package/dist/entities/tag/tag.test.js.map +1 -0
  278. package/dist/entities/tag/tag.types.d.ts +35 -0
  279. package/dist/entities/tag/tag.types.d.ts.map +1 -0
  280. package/dist/entities/tag/tag.types.js +2 -0
  281. package/dist/entities/tag/tag.types.js.map +1 -0
  282. package/dist/index.d.ts +3 -0
  283. package/dist/index.d.ts.map +1 -0
  284. package/dist/index.js +6 -0
  285. package/dist/index.js.map +1 -0
  286. package/package.json +73 -0
  287. package/src/commands/ci/act.ts +95 -0
  288. package/src/commands/ci/attach-affected.ts +93 -0
  289. package/src/commands/ci/attach-service-ports.ts +31 -0
  290. package/src/commands/commit-check.ts +124 -0
  291. package/src/commands/commit.ts +103 -0
  292. package/src/commands/dev/check.ts +117 -0
  293. package/src/commands/dev/cleanup.ts +34 -0
  294. package/src/commands/dev/rm.ts +66 -0
  295. package/src/commands/dev/setup.ts +48 -0
  296. package/src/commands/local/cleanup.ts +74 -0
  297. package/src/commands/local/setup.ts +68 -0
  298. package/src/commands/local/vscode.ts +118 -0
  299. package/src/commands/update-package-json.ts +104 -0
  300. package/src/commands/version/apply.ts +156 -0
  301. package/src/commands/version/ci.ts +85 -0
  302. package/src/commands/version/prepare.ts +217 -0
  303. package/src/core/colorify.ts +61 -0
  304. package/src/core/index.ts +3 -0
  305. package/src/core/types.ts +262 -0
  306. package/src/core/wrapshell.ts +388 -0
  307. package/src/entities/affected/affected.test.ts +427 -0
  308. package/src/entities/affected/affected.ts +22 -0
  309. package/src/entities/affected/index.ts +1 -0
  310. package/src/entities/branch/branch.test.ts +348 -0
  311. package/src/entities/branch/branch.ts +89 -0
  312. package/src/entities/branch/branch.types.ts +5 -0
  313. package/src/entities/branch/index.ts +2 -0
  314. package/src/entities/commit/commit.test.ts +769 -0
  315. package/src/entities/commit/commit.ts +245 -0
  316. package/src/entities/commit/commit.types.ts +81 -0
  317. package/src/entities/commit/index.ts +2 -0
  318. package/src/entities/commit/pr.test.ts +860 -0
  319. package/src/entities/commit/pr.ts +241 -0
  320. package/src/entities/compose/compose.test.ts +496 -0
  321. package/src/entities/compose/compose.ts +251 -0
  322. package/src/entities/compose/compose.types.ts +88 -0
  323. package/src/entities/compose/index.ts +2 -0
  324. package/src/entities/entities.shell.test.ts +35 -0
  325. package/src/entities/entities.shell.ts +81 -0
  326. package/src/entities/index.ts +11 -0
  327. package/src/entities/intershell-config/intershell-config.default.ts +229 -0
  328. package/src/entities/intershell-config/intershell-config.test.ts +117 -0
  329. package/src/entities/intershell-config/intershell-config.ts +143 -0
  330. package/src/entities/intershell-config/intershell-config.types.ts +118 -0
  331. package/src/entities/package/index.ts +3 -0
  332. package/src/entities/package/package.shell.ts +124 -0
  333. package/src/entities/package/package.test.ts +830 -0
  334. package/src/entities/package/package.ts +267 -0
  335. package/src/entities/package/package.types.ts +49 -0
  336. package/src/entities/package-changelog/index.ts +3 -0
  337. package/src/entities/package-changelog/package-changelog.ts +81 -0
  338. package/src/entities/package-changelog/package-changelog.types.ts +30 -0
  339. package/src/entities/package-changelog/template.default.ts +109 -0
  340. package/src/entities/package-changelog/template.ts +118 -0
  341. package/src/entities/package-commits/dependency-analyzer.test.ts +29 -0
  342. package/src/entities/package-commits/dependency-analyzer.ts +194 -0
  343. package/src/entities/package-commits/index.ts +2 -0
  344. package/src/entities/package-commits/package-commits.test.ts +44 -0
  345. package/src/entities/package-commits/package-commits.ts +191 -0
  346. package/src/entities/package-tags/index.ts +1 -0
  347. package/src/entities/package-tags/package-tags.test.ts +73 -0
  348. package/src/entities/package-tags/package-tags.ts +234 -0
  349. package/src/entities/package-version/index.ts +2 -0
  350. package/src/entities/package-version/package-version.test.ts +141 -0
  351. package/src/entities/package-version/package-version.ts +234 -0
  352. package/src/entities/package-version/package-version.types.ts +35 -0
  353. package/src/entities/tag/index.ts +2 -0
  354. package/src/entities/tag/tag.test.ts +844 -0
  355. package/src/entities/tag/tag.ts +208 -0
  356. package/src/entities/tag/tag.types.ts +37 -0
  357. package/src/index.ts +7 -0
@@ -0,0 +1,262 @@
1
+ /**
2
+ * Core type definitions for the InterShell CLI framework
3
+ */
4
+
5
+ // Basic CLI types
6
+ export interface KeyPress {
7
+ sequence: string;
8
+ name?: string;
9
+ ctrl: boolean;
10
+ meta: boolean;
11
+ shift: boolean;
12
+ }
13
+
14
+ export interface ValidationResult<T = unknown> {
15
+ isValid: boolean;
16
+ value?: T;
17
+ error?: string;
18
+ warnings?: string[];
19
+ }
20
+
21
+ export interface ValidationError {
22
+ message: string;
23
+ field?: string;
24
+ code?: string;
25
+ }
26
+
27
+ // Event system types
28
+ export type EventHandler<T = unknown> = (data: T) => void | Promise<void>;
29
+
30
+ export interface EventEmitter<TEvents extends Record<string, unknown> = Record<string, unknown>> {
31
+ on<K extends keyof TEvents>(event: K, handler: EventHandler<TEvents[K]>): void;
32
+ off<K extends keyof TEvents>(event: K, handler: EventHandler<TEvents[K]>): void;
33
+ emit<K extends keyof TEvents>(event: K, data: TEvents[K]): void;
34
+ }
35
+
36
+ // State management types
37
+ export type StateListener<TState> = (state: TState, prevState: TState) => void;
38
+
39
+ export interface StateManager<TState> {
40
+ getState(): TState;
41
+ setState(newState: TState): void;
42
+ subscribe(listener: StateListener<TState>): () => void;
43
+ }
44
+
45
+ // Script configuration types
46
+ export type ArgOption = {
47
+ short?: string; // pay attention, this turned optional! in affects the logic
48
+ long: string;
49
+ description: string;
50
+ examples?: string[];
51
+ } & (
52
+ | {
53
+ required: true;
54
+ type: "string" | "boolean" | "number";
55
+ validator: (value: string) => boolean | string | Promise<boolean | string>;
56
+ }
57
+ | {
58
+ required: false;
59
+ type: "string" | "boolean" | "number";
60
+ defaultValue?: string | boolean | number;
61
+ validator: (value: string) => boolean | string | Promise<boolean | string>;
62
+ }
63
+ | {
64
+ required: true;
65
+ type: "string[]" | "number[]"; // there is no multi boolean anymore, we must use type conditionals
66
+ validator: (value: string[]) => boolean | string | Promise<boolean | string>;
67
+ }
68
+ | {
69
+ required: false;
70
+ type: "string[]" | "number[]";
71
+ defaultValue?: string[] | number[];
72
+ validator: (value: string[]) => boolean | string | Promise<boolean | string>;
73
+ }
74
+ );
75
+
76
+ export interface ScriptConfig {
77
+ name: string;
78
+ description: string;
79
+ usage?: string;
80
+ examples?: string[];
81
+ options: ArgOption[];
82
+ }
83
+
84
+ export type ScriptHandler<TConfig extends ScriptConfig> = (
85
+ args: InferArgs<TConfig>,
86
+ console: Console,
87
+ ) => Promise<void> | void;
88
+
89
+ export interface ScriptInstance<TConfig extends ScriptConfig> {
90
+ config: TConfig;
91
+ handler: ScriptHandler<TConfig>;
92
+ run(args?: Partial<InferArgs<TConfig>>): Promise<void>;
93
+ }
94
+
95
+ // Utility type to infer argument types from config
96
+ export type InferArgs<TConfig extends ScriptConfig> = {
97
+ [K in TConfig["options"][number] as K["long"] extends `--${infer Name}`
98
+ ? Name
99
+ : never]: K extends { required: true; type: infer T }
100
+ ? T extends "string[]" | "number[]"
101
+ ? string[] | number[]
102
+ : T extends "string"
103
+ ? string
104
+ : T extends "boolean"
105
+ ? boolean
106
+ : T extends "number"
107
+ ? number
108
+ : never
109
+ : K extends { required: false; type: infer T; defaultValue: infer D }
110
+ ? T extends "string[]" | "number[]"
111
+ ? (string[] | number[]) | D
112
+ : T extends "string"
113
+ ? string | D
114
+ : T extends "boolean"
115
+ ? boolean | D
116
+ : T extends "number"
117
+ ? number | D
118
+ : never
119
+ : K extends { required: false; type: infer T }
120
+ ? T extends "string[]" | "number[]"
121
+ ? (string[] | number[]) | undefined
122
+ : T extends "string"
123
+ ? string | undefined
124
+ : T extends "boolean"
125
+ ? boolean | undefined
126
+ : T extends "number"
127
+ ? number | undefined
128
+ : never
129
+ : never;
130
+ } & {
131
+ verbose?: boolean;
132
+ quiet?: boolean;
133
+ "dry-run"?: boolean;
134
+ help?: boolean;
135
+ debug?: boolean;
136
+ };
137
+
138
+ // Hook system types
139
+ export interface HookContext<TConfig extends ScriptConfig> {
140
+ script: ScriptInstance<TConfig>;
141
+ args: InferArgs<TConfig>;
142
+ startTime: number;
143
+ error?: Error;
144
+ }
145
+
146
+ export type Hook<TConfig extends ScriptConfig, TReturn = void> = (
147
+ context: HookContext<TConfig>,
148
+ ) => Promise<TReturn> | TReturn;
149
+
150
+ export interface HookSystem<TConfig extends ScriptConfig> {
151
+ beforeRun: Hook<TConfig>[];
152
+ afterRun: Hook<TConfig, unknown>[];
153
+ onError: Hook<TConfig>[];
154
+ onValidation: Hook<TConfig, ValidationResult>[];
155
+ }
156
+
157
+ // Color system types
158
+ export type ColorFunction = (text: string) => string;
159
+
160
+ export interface ColorSystem {
161
+ // Basic colors
162
+ red: ColorFunction;
163
+ green: ColorFunction;
164
+ blue: ColorFunction;
165
+ yellow: ColorFunction;
166
+ cyan: ColorFunction;
167
+ magenta: ColorFunction;
168
+ white: ColorFunction;
169
+ black: ColorFunction;
170
+ gray: ColorFunction;
171
+ grey: ColorFunction;
172
+
173
+ // Styles
174
+ bold: ColorFunction;
175
+ italic: ColorFunction;
176
+ underline: ColorFunction;
177
+ strikethrough: ColorFunction;
178
+
179
+ // Advanced colors
180
+ rgb(r: number, g: number, b: number): ColorFunction;
181
+ hsl(h: number, s: number, l: number): ColorFunction;
182
+ hex(color: string): ColorFunction;
183
+
184
+ // Effects
185
+ gradient(colors: string[]): ColorFunction;
186
+ rainbow: ColorFunction;
187
+
188
+ // Utilities
189
+ strip(text: string): string;
190
+ supportsColor(): boolean;
191
+ enable(): void;
192
+ disable(): void;
193
+ }
194
+
195
+ // CLI Tools types
196
+ export interface QuickAction {
197
+ key: string;
198
+ label: string;
199
+ description: string;
200
+ shortcut?: string;
201
+ action: () => void | Promise<void>;
202
+ }
203
+
204
+ export interface SelectConfig {
205
+ multiple?: boolean;
206
+ clearScreen?: boolean;
207
+ showCursor?: boolean;
208
+ exitOnCtrlC?: boolean;
209
+ quickActions?: QuickAction[];
210
+ }
211
+
212
+ export interface PromptConfig {
213
+ clearScreen?: boolean;
214
+ allowEmpty?: boolean;
215
+ showCursor?: boolean;
216
+ exitOnCtrlC?: boolean;
217
+ quickActions?: QuickAction[];
218
+ onLeft?: () => void;
219
+ }
220
+
221
+ export interface ConfirmConfig {
222
+ clearScreen?: boolean;
223
+ defaultValue?: boolean;
224
+ exitOnCtrlC?: boolean;
225
+ }
226
+
227
+ // Interactive CLI types
228
+ export interface InteractiveCLIOptions {
229
+ enableRawMode?: boolean;
230
+ exitOnCtrlC?: boolean;
231
+ clearOnExit?: boolean;
232
+ }
233
+
234
+ export interface InteractiveCLI {
235
+ // Core methods
236
+ select(question: string, options: string[], config?: SelectConfig): Promise<string[]>;
237
+ prompt(question: string, config?: PromptConfig): Promise<string>;
238
+ confirm(question: string, config?: ConfirmConfig): Promise<boolean>;
239
+
240
+ // Screen management
241
+ clearScreen(): void;
242
+ showCursor(): void;
243
+ hideCursor(): void;
244
+
245
+ // Event handling
246
+ onKeyPress(callback: (key: KeyPress) => void): void;
247
+ offKeyPress(callback: (key: KeyPress) => void): void;
248
+
249
+ // Lifecycle
250
+ cleanup(): void;
251
+ }
252
+
253
+ // Framework-specific types (will be extended by interactive package)
254
+ export interface FrameworkOptions {
255
+ debug?: boolean;
256
+ logLevel?: "error" | "warn" | "info" | "debug";
257
+ enableHotkeys?: boolean;
258
+ enableHistory?: boolean;
259
+ maxHistorySize?: number;
260
+ renderMode?: "immediate" | "debounced" | "throttled";
261
+ renderDelay?: number;
262
+ }
@@ -0,0 +1,388 @@
1
+ import { existsSync, statSync } from "node:fs";
2
+ import { colorify } from "./colorify";
3
+ import type {
4
+ ArgOption,
5
+ HookContext,
6
+ HookSystem,
7
+ InferArgs,
8
+ ScriptConfig,
9
+ ScriptHandler,
10
+ ScriptInstance,
11
+ } from "./types";
12
+
13
+ const validators = {
14
+ nonEmpty: (value: string): boolean | string => {
15
+ if (value.trim().length === 0) {
16
+ return "Value cannot be empty";
17
+ }
18
+ return true;
19
+ },
20
+ boolean: (value: string): boolean | string => {
21
+ const lowerValue = value.toLowerCase();
22
+ if (lowerValue === "true" || lowerValue === "1" || lowerValue === "yes") {
23
+ return true;
24
+ }
25
+ if (lowerValue === "false" || lowerValue === "0" || lowerValue === "no") {
26
+ return true;
27
+ }
28
+ return "Value must be a boolean (true/false, 1/0, yes/no)";
29
+ },
30
+ number: (value: string): boolean | string => {
31
+ const num = Number(value);
32
+ if (Number.isNaN(num) || !Number.isFinite(num)) {
33
+ return "Value must be a valid number";
34
+ }
35
+ return true;
36
+ },
37
+ integer: (value: string): boolean | string => {
38
+ const num = Number(value);
39
+ if (Number.isNaN(num) || !Number.isFinite(num) || !Number.isInteger(num)) {
40
+ return "Value must be an integer";
41
+ }
42
+ return true;
43
+ },
44
+ fileExists: (filePath: string): boolean | string => {
45
+ try {
46
+ const file = Bun.file(filePath);
47
+ if (!file.size) {
48
+ return `File "${filePath}" not found.`;
49
+ }
50
+ return true;
51
+ } catch {
52
+ return `File "${filePath}" not found.`;
53
+ }
54
+ },
55
+ directoryExists: (path: string): boolean | string => {
56
+ try {
57
+ const exists = existsSync(path) && statSync(path).isDirectory();
58
+ if (!exists) {
59
+ return `Directory does not exist: ${path}`;
60
+ }
61
+ return true;
62
+ } catch (error) {
63
+ return `Error checking directory: ${error instanceof Error ? error.message : String(error)}`;
64
+ }
65
+ },
66
+ enum:
67
+ (allowedValues: string[]) =>
68
+ (value: string): boolean | string => {
69
+ if (!allowedValues.includes(value)) {
70
+ return `Invalid value "${value}". Valid values: ${allowedValues.join(", ")}`;
71
+ }
72
+ return true;
73
+ },
74
+ regex:
75
+ (pattern: RegExp, message?: string) =>
76
+ (value: string): boolean | string => {
77
+ if (!pattern.test(value)) {
78
+ return message || `Value must match pattern: ${pattern}`;
79
+ }
80
+ return true;
81
+ },
82
+ custom:
83
+ <T>(validator: (value: string) => T | string) =>
84
+ (value: string): boolean | string => {
85
+ try {
86
+ const result = validator(value);
87
+ if (typeof result === "string") {
88
+ return result;
89
+ }
90
+ return true;
91
+ } catch (error) {
92
+ return error instanceof Error ? error.message : String(error);
93
+ }
94
+ },
95
+ url: (value: string): boolean | string => {
96
+ try {
97
+ new URL(value);
98
+ return true;
99
+ } catch {
100
+ return "Value must be a valid URL";
101
+ }
102
+ },
103
+ email: (value: string): boolean | string => {
104
+ const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
105
+ if (!emailRegex.test(value)) {
106
+ return "Value must be a valid email address";
107
+ }
108
+ return true;
109
+ },
110
+ semver: (value: string): boolean | string => {
111
+ const semverRegex =
112
+ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
113
+ if (!semverRegex.test(value)) {
114
+ return "Value must be a valid semantic version (e.g., 1.0.0)";
115
+ }
116
+ return true;
117
+ },
118
+ } as const;
119
+
120
+ const defaultConfig = {
121
+ name: "Script",
122
+ description: "A CLI script",
123
+ options: [
124
+ {
125
+ short: "-v",
126
+ long: "--verbose",
127
+ description: "Enable verbose logging",
128
+ required: false,
129
+ type: "boolean" as const,
130
+ defaultValue: true,
131
+ validator: validators.boolean,
132
+ },
133
+ {
134
+ short: "-q",
135
+ long: "--quiet",
136
+ description: "Suppress output",
137
+ required: false,
138
+ type: "boolean" as const,
139
+ defaultValue: false,
140
+ validator: validators.boolean,
141
+ },
142
+ {
143
+ short: "",
144
+ long: "--dry-run",
145
+ description: "Show what would happen without executing",
146
+ required: false,
147
+ type: "boolean" as const,
148
+ defaultValue: false,
149
+ validator: validators.boolean,
150
+ },
151
+ {
152
+ short: "-h",
153
+ long: "--help",
154
+ description: "Show help information",
155
+ required: false,
156
+ type: "boolean" as const,
157
+ defaultValue: false,
158
+ validator: validators.boolean,
159
+ },
160
+ ],
161
+ } as const satisfies ScriptConfig;
162
+
163
+ class WrapShell<TConfig extends ScriptConfig> {
164
+ private config: TConfig;
165
+ private hooks: Partial<HookSystem<TConfig>> = {};
166
+
167
+ constructor(config: TConfig) {
168
+ this.config = config;
169
+ }
170
+
171
+ static createScript<TConfig extends ScriptConfig>(
172
+ config: TConfig,
173
+ handler: ScriptHandler<TConfig>,
174
+ ): ScriptInstance<TConfig> {
175
+ const wrapShell = new WrapShell(config);
176
+
177
+ return {
178
+ config,
179
+ handler,
180
+ run: async (passedArgs?: InferArgs<TConfig>) => {
181
+ const context: HookContext<TConfig> = {
182
+ startTime: Date.now(),
183
+ args:
184
+ passedArgs ||
185
+ (await wrapShell.parseArgs().catch((e) => {
186
+ wrapShell.showHelp(null);
187
+ console.error(e);
188
+ process.exit(1);
189
+ })),
190
+ script: { config, handler, run: async () => {} },
191
+ };
192
+
193
+ try {
194
+ if (wrapShell.hooks.beforeRun) {
195
+ for (const hook of wrapShell.hooks.beforeRun) {
196
+ await hook(context);
197
+ }
198
+ }
199
+
200
+ const enhancedConsole = wrapShell.createEnhancedConsole(context.args);
201
+ const result = await handler(context.args, enhancedConsole);
202
+
203
+ if (wrapShell.hooks.afterRun) {
204
+ for (const hook of wrapShell.hooks.afterRun) {
205
+ await hook(context);
206
+ }
207
+ }
208
+
209
+ return result;
210
+ } catch (error) {
211
+ if (wrapShell.hooks.onError) {
212
+ for (const hook of wrapShell.hooks.onError) {
213
+ await hook({ ...context, error: error as Error });
214
+ }
215
+ }
216
+
217
+ if (!context.args.debug) {
218
+ (error as Error).stack = undefined;
219
+ }
220
+
221
+ throw error;
222
+ }
223
+ },
224
+ };
225
+ }
226
+
227
+ private async parseArgs(): Promise<InferArgs<TConfig>> {
228
+ const args = process.argv.slice(2);
229
+ const result: Record<string, unknown> = {};
230
+ const allOptions = [...defaultConfig.options, ...this.config.options];
231
+
232
+ allOptions.forEach((option) => {
233
+ const key = option.long.replace("--", "");
234
+ if (
235
+ option.required === false &&
236
+ "defaultValue" in option &&
237
+ option.defaultValue !== undefined
238
+ ) {
239
+ result[key] = option.defaultValue;
240
+ }
241
+ });
242
+
243
+ for (let i = 0; i < args.length; i++) {
244
+ const arg = args[i];
245
+ const nextArg = args[i + 1];
246
+
247
+ if (arg === "-h" || arg === "--help") {
248
+ this.showHelp(result as InferArgs<TConfig>);
249
+ process.exit(0);
250
+ }
251
+
252
+ const option = allOptions.find((opt) => opt.short === arg || opt.long === arg);
253
+ if (option) {
254
+ const key = option.long.replace("--", "");
255
+
256
+ if (option.type === "boolean") {
257
+ result[key] = true;
258
+ } else if (nextArg && !nextArg.startsWith("-")) {
259
+ result[key] = nextArg;
260
+ i++;
261
+ }
262
+ }
263
+ }
264
+
265
+ await this.validateParsedArgs(result, allOptions);
266
+
267
+ return result as InferArgs<TConfig>;
268
+ }
269
+
270
+ private async validateParsedArgs(
271
+ args: Record<string, unknown>,
272
+ options: readonly ArgOption[],
273
+ ): Promise<void> {
274
+ for (const option of options) {
275
+ const key = option.long.replace("--", "");
276
+ const value = args[key];
277
+
278
+ if (option.required && (value === undefined || value === null || value === "")) {
279
+ throw new Error(`Required option ${option.long} is missing`);
280
+ }
281
+
282
+ if (value !== undefined && option.validator) {
283
+ let validation: boolean | string | Promise<boolean | string>;
284
+
285
+ if (option.type === "string[]" || option.type === "number[]") {
286
+ // For array types, pass the array directly
287
+ if (Array.isArray(value)) {
288
+ validation = await (
289
+ option.validator as (value: string[]) => boolean | string | Promise<boolean | string>
290
+ )(value);
291
+ } else {
292
+ throw new Error(`Expected array for ${option.long}, got ${typeof value}`);
293
+ }
294
+ } else {
295
+ // For single value types, convert to string
296
+ validation = await (
297
+ option.validator as (value: string) => boolean | string | Promise<boolean | string>
298
+ )(String(value));
299
+ }
300
+
301
+ if (typeof validation === "string") {
302
+ throw new Error(`Invalid value for ${option.long}: ${validation}`);
303
+ }
304
+ }
305
+ }
306
+ }
307
+
308
+ private createEnhancedConsole(args: InferArgs<TConfig>): Console {
309
+ const originalConsole = console;
310
+
311
+ return Object.assign({}, originalConsole, {
312
+ log: (...props: Parameters<typeof console.log>) => {
313
+ if (!("quiet" in args) || !args.quiet) {
314
+ originalConsole.log(...props);
315
+ }
316
+ },
317
+ info: (...props: Parameters<typeof console.info>) => {
318
+ if (!("quiet" in args) || !args.quiet) {
319
+ originalConsole.warn(...props);
320
+ }
321
+ },
322
+ warn: (...props: Parameters<typeof console.warn>) => {
323
+ if (!("quiet" in args) || !args.quiet) {
324
+ originalConsole.warn(...props);
325
+ }
326
+ },
327
+ error: (...props: Parameters<typeof console.error>) => {
328
+ originalConsole.error(...props);
329
+ },
330
+ });
331
+ }
332
+
333
+ private showHelp(args: InferArgs<TConfig> | null): void {
334
+ const xConsole = this.createEnhancedConsole(args || ({} as InferArgs<TConfig>));
335
+ xConsole.log(colorify.blue(this.config.name));
336
+ xConsole.log(this.config.description);
337
+ xConsole.log();
338
+
339
+ if (this.config.usage) {
340
+ xConsole.log("Usage:");
341
+ xConsole.log(` ${this.config.usage}\n`);
342
+ }
343
+
344
+ const allOptions = [...defaultConfig.options, ...this.config.options];
345
+ if (allOptions.length > 0) {
346
+ xConsole.log("Options:");
347
+ allOptions.forEach((option) => {
348
+ const shortFlag = option.short ? `${option.short}, ` : " ";
349
+ const required = option.required ? colorify.red(" (required)") : "";
350
+ xConsole.log(` ${shortFlag}${option.long}${required}`);
351
+ xConsole.log(` ${option.description}`);
352
+ });
353
+ xConsole.log();
354
+ }
355
+
356
+ if (this.config.examples && this.config.examples.length > 0) {
357
+ xConsole.log("Examples:");
358
+ this.config.examples.forEach((example) => {
359
+ xConsole.log(` ${colorify.gray(example)}`);
360
+ });
361
+ }
362
+ }
363
+
364
+ static hooks = {
365
+ beforeRun: <TConfig extends ScriptConfig>(
366
+ hook: (context: HookContext<TConfig>) => Promise<void> | void,
367
+ ) => hook,
368
+ afterRun: <TConfig extends ScriptConfig>(
369
+ hook: (context: HookContext<TConfig>) => Promise<void> | void,
370
+ ) => hook,
371
+ onError: <TConfig extends ScriptConfig>(
372
+ hook: (context: HookContext<TConfig> & { error: Error }) => Promise<void> | void,
373
+ ) => hook,
374
+ onValidation: <TConfig extends ScriptConfig>(
375
+ hook: (context: HookContext<TConfig>) => Promise<void> | void,
376
+ ) => hook,
377
+ };
378
+
379
+ static validators = validators;
380
+ }
381
+
382
+ export function createScript<TConfig extends ScriptConfig>(
383
+ config: TConfig,
384
+ handler: ScriptHandler<TConfig>,
385
+ ): ScriptInstance<TConfig> {
386
+ return WrapShell.createScript(config, handler);
387
+ }
388
+ createScript.validators = validators;