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,194 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { entitiesShell } from "../entities.shell";
4
+ import { EntityPackage, type TsConfig, type TsConfigPaths } from "../package";
5
+
6
+ export class EntityDependencyAnalyzer {
7
+ private readonly package: EntityPackage;
8
+
9
+ constructor(packageInstance: EntityPackage) {
10
+ this.package = packageInstance;
11
+ }
12
+
13
+ /**
14
+ * Get internal monorepo dependencies for a package at a specific tag/commit
15
+ * Returns only dependencies within this monorepo
16
+ */
17
+ async getPackageDependenciesAtRef(reference: string): Promise<string[]> {
18
+ try {
19
+ // Get all internal packages in the monorepo
20
+ const allPackages = await EntityPackage.getAllPackages();
21
+
22
+ // Get package.json dependencies
23
+ const packageJsonDeps = await this.getPackageJsonDependencies(reference);
24
+
25
+ // Get tsconfig dependencies
26
+ const tsconfigDeps = await this.getTsConfigDependencies(reference);
27
+
28
+ // Combine and filter for internal dependencies only
29
+ const allDeps = [...new Set([...packageJsonDeps, ...tsconfigDeps])];
30
+
31
+ return allDeps.filter((dep) => allPackages.includes(dep));
32
+ } catch {
33
+ return [];
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Get package.json dependencies for a package at a specific reference
39
+ */
40
+ private async getPackageJsonDependencies(reference: string): Promise<string[]> {
41
+ try {
42
+ const result = await entitiesShell.gitShowPackageJsonAtTag(
43
+ reference,
44
+ this.package.getJsonPath(),
45
+ );
46
+
47
+ if (result.exitCode !== 0) {
48
+ return [];
49
+ }
50
+
51
+ const packageJson = JSON.parse(result.text()) as Record<string, unknown>;
52
+ const deps = [
53
+ ...(packageJson.dependencies
54
+ ? Object.keys(packageJson.dependencies as Record<string, string>)
55
+ : []),
56
+ ...(packageJson.devDependencies
57
+ ? Object.keys(packageJson.devDependencies as Record<string, string>)
58
+ : []),
59
+ ...(packageJson.peerDependencies
60
+ ? Object.keys(packageJson.peerDependencies as Record<string, string>)
61
+ : []),
62
+ ];
63
+
64
+ // Filter for @repo/ packages and return without @repo/ prefix
65
+ return deps.filter((dep) => dep.startsWith("@repo/")).map((dep) => dep.replace("@repo/", ""));
66
+ } catch {
67
+ return [];
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Get tsconfig dependencies by resolving paths to actual internal packages
73
+ */
74
+ private async getTsConfigDependencies(reference: string): Promise<string[]> {
75
+ try {
76
+ const packagePath = this.package.getPath();
77
+ const tsconfigPaths = await this.getTsConfigPaths(reference);
78
+
79
+ const deps: string[] = [];
80
+
81
+ for (const [alias, paths] of Object.entries(tsconfigPaths)) {
82
+ // Check if alias itself is an internal package
83
+ if (alias.startsWith("@repo/")) {
84
+ deps.push(alias.replace("@repo/", ""));
85
+ }
86
+
87
+ // Check if paths point to internal packages
88
+ if (Array.isArray(paths)) {
89
+ for (const path of paths) {
90
+ const resolvedPath = resolve(packagePath, path);
91
+ const internalPackage = this.findInternalPackageFromPath(resolvedPath);
92
+ if (internalPackage) {
93
+ deps.push(internalPackage);
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ return [...new Set(deps)];
100
+ } catch {
101
+ return [];
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Find internal package name from absolute path
107
+ */
108
+ private findInternalPackageFromPath(absolutePath: string): string | null {
109
+ // Check if path points to packages/ or apps/ directory
110
+ const packagesMatch = absolutePath.match(/\/packages\/([^/]+)/);
111
+ const appsMatch = absolutePath.match(/\/apps\/([^/]+)/);
112
+
113
+ if (packagesMatch) {
114
+ return `@repo/${packagesMatch[1]}`;
115
+ }
116
+
117
+ if (appsMatch) {
118
+ return appsMatch[1];
119
+ }
120
+
121
+ return null;
122
+ }
123
+
124
+ /**
125
+ * Get TypeScript configuration paths for a package at a specific git reference
126
+ */
127
+ private async getTsConfigPaths(reference: string): Promise<TsConfigPaths> {
128
+ try {
129
+ const tsconfig = await this.readTsconfigAtRef(reference);
130
+ const resolvedConfig = await this.resolveExtendedTsConfig(tsconfig, this.package.getPath());
131
+
132
+ return resolvedConfig.compilerOptions?.paths || {};
133
+ } catch {
134
+ return {};
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Read tsconfig.json at a specific git reference
140
+ */
141
+ private async readTsconfigAtRef(reference: string): Promise<TsConfig> {
142
+ try {
143
+ const result = await entitiesShell.gitShow(`${reference}:${this.package.getTsconfigPath()}`);
144
+ if (result.exitCode !== 0) {
145
+ // If tsconfig.json doesn't exist at this reference, return empty config
146
+ return {};
147
+ }
148
+
149
+ const content = result.text();
150
+ return JSON.parse(content);
151
+ } catch {
152
+ // If parsing fails, return empty config
153
+ return {};
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Resolve extended TypeScript configurations
159
+ */
160
+ private async resolveExtendedTsConfig(config: TsConfig, packagePath: string): Promise<TsConfig> {
161
+ if (!config.extends) {
162
+ return config;
163
+ }
164
+
165
+ const extendedPath = resolve(packagePath, config.extends);
166
+ if (!existsSync(extendedPath)) {
167
+ return config;
168
+ }
169
+
170
+ try {
171
+ const extendedContent = readFileSync(extendedPath, "utf-8");
172
+ const extendedConfig: TsConfig = JSON.parse(extendedContent);
173
+
174
+ // Recursively resolve extended configs
175
+ const resolvedExtended = await this.resolveExtendedTsConfig(extendedConfig, packagePath);
176
+
177
+ // Merge configurations
178
+ return {
179
+ ...resolvedExtended,
180
+ ...config,
181
+ compilerOptions: {
182
+ ...resolvedExtended.compilerOptions,
183
+ ...config.compilerOptions,
184
+ paths: {
185
+ ...(resolvedExtended.compilerOptions?.paths || {}),
186
+ ...(config.compilerOptions?.paths || {}),
187
+ },
188
+ },
189
+ };
190
+ } catch {
191
+ return config;
192
+ }
193
+ }
194
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./dependency-analyzer";
2
+ export * from "./package-commits";
@@ -0,0 +1,44 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { EntityPackage } from "../package";
3
+ import { EntityPackageCommits } from "./package-commits";
4
+
5
+ describe("EntityPackageCommits", () => {
6
+ test("should create instance", () => {
7
+ const packageInstance = new EntityPackage("api");
8
+ const commitPackage = new EntityPackageCommits(packageInstance);
9
+ expect(commitPackage).toBeDefined();
10
+ });
11
+
12
+ test("should create root instance", () => {
13
+ const packageInstance = new EntityPackage("root");
14
+ const rootCommitPackage = new EntityPackageCommits(packageInstance);
15
+ expect(rootCommitPackage).toBeDefined();
16
+ });
17
+
18
+ test("should have main method", () => {
19
+ const packageInstance = new EntityPackage("api");
20
+ const commitPackage = new EntityPackageCommits(packageInstance);
21
+ // Check that the main method exists
22
+ expect(typeof commitPackage.getCommitsInRange).toBe("function");
23
+ });
24
+
25
+ describe("getCommitsInRange", () => {
26
+ test("should return empty array when git operations fail", async () => {
27
+ const packageInstance = new EntityPackage("root");
28
+ const commitPackage = new EntityPackageCommits(packageInstance);
29
+ // Test with invalid range to trigger error handling
30
+ const result = await commitPackage.getCommitsInRange("invalid", "invalid");
31
+ expect(Array.isArray(result)).toBe(true);
32
+ expect(result.length).toBe(0);
33
+ });
34
+
35
+ test("should handle package-specific commits", async () => {
36
+ const packageInstance = new EntityPackage("api");
37
+ const commitPackage = new EntityPackageCommits(packageInstance);
38
+ // Test with invalid range to trigger error handling
39
+ const result = await commitPackage.getCommitsInRange("invalid", "invalid");
40
+ expect(Array.isArray(result)).toBe(true);
41
+ expect(result.length).toBe(0);
42
+ });
43
+ });
44
+ });
@@ -0,0 +1,191 @@
1
+ import type { ParsedCommitData } from "../commit";
2
+ import { EntityCommit } from "../commit";
3
+ import { entitiesShell } from "../entities.shell";
4
+ import { EntityPackage } from "../package";
5
+ import { EntityDependencyAnalyzer } from "./dependency-analyzer";
6
+
7
+ export class EntityPackageCommits {
8
+ private package: EntityPackage;
9
+ private commit: EntityCommit;
10
+ private dependencyAnalyzer: EntityDependencyAnalyzer;
11
+
12
+ constructor(packageInstance: EntityPackage) {
13
+ this.package = packageInstance;
14
+ this.commit = new EntityCommit();
15
+ this.dependencyAnalyzer = new EntityDependencyAnalyzer(this.package);
16
+ }
17
+
18
+ /**
19
+ * Get the first commit for this package
20
+ */
21
+ async getFirstCommitForPackage(): Promise<string> {
22
+ if (this.package.getName() === "root") {
23
+ // For root package, use the very first commit of the repository
24
+ const result = await entitiesShell.gitFirstCommit();
25
+ if (result.exitCode !== 0) {
26
+ throw new Error("Could not find first commit");
27
+ }
28
+ return result.text().trim();
29
+ }
30
+
31
+ // For sub-packages, find the first commit where the package directory was introduced
32
+ const packagePath = this.package.getPath();
33
+ const result = await entitiesShell.gitLogHashes([packagePath]);
34
+
35
+ if (result.exitCode !== 0 || !result.text().trim()) {
36
+ // If no commits found for this package path, fall back to first commit
37
+ const firstCommitResult = await entitiesShell.gitFirstCommit();
38
+ if (firstCommitResult.exitCode !== 0) {
39
+ throw new Error("Could not find first commit");
40
+ }
41
+ return firstCommitResult.text().trim();
42
+ }
43
+
44
+ // Get the last commit hash from the result (since git log returns newest first)
45
+ const commitHashes = result.text().trim().split("\n").filter(Boolean);
46
+ if (commitHashes.length === 0) {
47
+ const firstCommitResult = await entitiesShell.gitFirstCommit();
48
+ if (firstCommitResult.exitCode !== 0) {
49
+ throw new Error("Could not find first commit");
50
+ }
51
+ return firstCommitResult.text().trim();
52
+ }
53
+
54
+ // Return the last commit (which is the first chronologically)
55
+ return commitHashes[commitHashes.length - 1];
56
+ }
57
+
58
+ /**
59
+ * Get commits in a range for this package with dependency filtering
60
+ */
61
+ async getCommitsInRange(from: string, to: string): Promise<ParsedCommitData[]> {
62
+ const gitRange = from === "0.0.0" ? to : `${from}..${to}`;
63
+
64
+ try {
65
+ // Get all commit hashes (both regular and merge commits)
66
+ const [allHashesResult, mergeHashesResult] = await Promise.all([
67
+ entitiesShell.gitLogHashes([gitRange]),
68
+ entitiesShell.gitLogHashes([gitRange, "--merges"]),
69
+ ]);
70
+
71
+ const allHashes =
72
+ allHashesResult.exitCode === 0
73
+ ? allHashesResult.text().trim().split("\n").filter(Boolean)
74
+ : [];
75
+ const mergeHashes =
76
+ mergeHashesResult.exitCode === 0
77
+ ? mergeHashesResult.text().trim().split("\n").filter(Boolean)
78
+ : [];
79
+
80
+ // For non-root packages, filter merge commits by package path
81
+ const commitHashes = await this.filterMergeCommitsByPackage(allHashes, mergeHashes);
82
+
83
+ // Parse all commits
84
+ const allCommits = await Promise.all(
85
+ commitHashes.map((hash) => this.commit.parseByHash(hash)),
86
+ );
87
+
88
+ // Filter commits based on package dependencies at each commit
89
+ const relevantCommits: ParsedCommitData[] = [];
90
+ for (const commit of allCommits) {
91
+ // Check if commit affects this package or its dependencies
92
+ const affected = await this.getCommitAffectedPackages(commit);
93
+
94
+ // Include commit if it affects this package directly or any of its dependencies
95
+ if (affected.direct !== null || affected.dependencies.length > 0) {
96
+ relevantCommits.push(commit);
97
+ }
98
+ }
99
+
100
+ // Sort commits: merge commits first, then orphan commits, both by date
101
+ return this.sortCommits(relevantCommits);
102
+ } catch (error) {
103
+ console.warn("Failed to get commits in range:", error);
104
+ return [];
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Get which packages are affected by a commit (direct and dependencies)
110
+ * Analyzes the commit's file changes against package dependencies
111
+ */
112
+ async getCommitAffectedPackages(commit: ParsedCommitData): Promise<{
113
+ direct: string | null;
114
+ dependencies: string[];
115
+ }> {
116
+ if (!commit.files?.length) {
117
+ return { direct: null, dependencies: [] };
118
+ }
119
+
120
+ // Get package dependencies at the commit
121
+ const commitHash = commit.info?.hash || "HEAD";
122
+ const packageDeps = await this.dependencyAnalyzer.getPackageDependenciesAtRef(commitHash);
123
+
124
+ // Check if commit affects this package directly
125
+ const packagePath = this.package.getPath();
126
+ const affectsDirect = this.package.isRoot()
127
+ ? commit.files.length > 0 // For root package, any file change affects it
128
+ : commit.files.some((file) => file.startsWith(packagePath));
129
+
130
+ // Check if commit affects any dependencies
131
+ const affectedDependencies: string[] = [];
132
+ for (const dep of packageDeps) {
133
+ const depPackage = new EntityPackage(dep);
134
+ const depPath = depPackage.getPath();
135
+ if (commit.files.some((file) => file.startsWith(depPath))) {
136
+ affectedDependencies.push(dep);
137
+ }
138
+ }
139
+
140
+ return {
141
+ direct: affectsDirect ? this.package.getName() : null,
142
+ dependencies: affectedDependencies,
143
+ };
144
+ }
145
+
146
+ /**
147
+ * Deduplicate merge commits - remove hashes that are already included in merge commits
148
+ */
149
+ private async filterMergeCommitsByPackage(
150
+ allHashes: string[],
151
+ mergeHashes: string[],
152
+ ): Promise<string[]> {
153
+ // For each merge commit, get the individual commits inside it
154
+ const individualCommits = new Set<string>();
155
+
156
+ for (const mergeHash of mergeHashes) {
157
+ const prCommitsResult = await entitiesShell.gitLogHashes([`${mergeHash}^..${mergeHash}^2`]);
158
+ if (prCommitsResult.exitCode === 0) {
159
+ const prHashes = prCommitsResult.text().trim().split("\n").filter(Boolean);
160
+ prHashes.forEach((hash) => {
161
+ individualCommits.add(hash);
162
+ });
163
+ }
164
+ }
165
+
166
+ // Remove individual commits that are already included in merge commits
167
+ const filteredHashes = allHashes.filter((hash) => !individualCommits.has(hash));
168
+
169
+ // Return merge commits + filtered individual commits
170
+ return [...new Set([...filteredHashes, ...mergeHashes])];
171
+ }
172
+
173
+ /**
174
+ * Sort commits: merge commits first, then orphan commits, both by date (newest first)
175
+ */
176
+ private sortCommits(commits: ParsedCommitData[]): ParsedCommitData[] {
177
+ const mergeCommits = commits.filter((commit) => commit.message.isMerge);
178
+ const orphanCommits = commits.filter(
179
+ (commit) =>
180
+ !commit.message.isMerge &&
181
+ !mergeCommits.some((mergeCommit) =>
182
+ mergeCommit.pr?.prCommits?.some((prCommit) => prCommit.info?.hash === commit.info?.hash),
183
+ ),
184
+ );
185
+
186
+ const sortByDate = (a: ParsedCommitData, b: ParsedCommitData) =>
187
+ new Date(b.info?.date || "0").getTime() - new Date(a.info?.date || "0").getTime();
188
+
189
+ return [...mergeCommits.sort(sortByDate), ...orphanCommits.sort(sortByDate)];
190
+ }
191
+ }
@@ -0,0 +1 @@
1
+ export { EntityPackageTags } from "./package-tags";
@@ -0,0 +1,73 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { EntityPackage } from "../package";
3
+ import { EntityPackageTags } from "./package-tags";
4
+
5
+ describe("EntityPackageTags", () => {
6
+ test("should create instance", () => {
7
+ const packageInstance = new EntityPackage("api");
8
+ const tagPackage = new EntityPackageTags(packageInstance);
9
+ expect(tagPackage).toBeDefined();
10
+ });
11
+
12
+ test("should create root instance", () => {
13
+ const packageInstance = new EntityPackage("root");
14
+ const tagPackage = new EntityPackageTags(packageInstance);
15
+ expect(tagPackage).toBeDefined();
16
+ });
17
+
18
+ test("should detect tag prefix for root package", () => {
19
+ const packageInstance = new EntityPackage("root");
20
+ const tagPackage = new EntityPackageTags(packageInstance);
21
+
22
+ expect(tagPackage.detectTagPrefix("v1.0.0")).toBe("v");
23
+ expect(tagPackage.detectTagPrefix("v2.1.3")).toBe("v");
24
+ expect(tagPackage.detectTagPrefix("v0.0.1")).toBe("v");
25
+ });
26
+
27
+ test("should detect tag prefix for package-specific tags", () => {
28
+ const packageInstance = new EntityPackage("api");
29
+ const tagPackage = new EntityPackageTags(packageInstance);
30
+
31
+ expect(tagPackage.detectTagPrefix("api-v1.0.0")).toBe("api-v");
32
+ expect(tagPackage.detectTagPrefix("intershell-v2.1.3")).toBe("intershell-v");
33
+ expect(tagPackage.detectTagPrefix("ui-v0.0.1")).toBe("ui-v");
34
+ });
35
+
36
+ test("should return undefined for invalid tag formats", () => {
37
+ const packageInstance = new EntityPackage("api");
38
+ const tagPackage = new EntityPackageTags(packageInstance);
39
+
40
+ expect(tagPackage.detectTagPrefix("1.0.0")).toBeUndefined();
41
+ expect(tagPackage.detectTagPrefix("invalid")).toBeUndefined();
42
+ expect(tagPackage.detectTagPrefix("")).toBeUndefined();
43
+ });
44
+
45
+ test("should compare versions correctly", () => {
46
+ const packageInstance = new EntityPackage("api");
47
+ const tagPackage = new EntityPackageTags(packageInstance);
48
+
49
+ expect(tagPackage.compareVersions("1.0.0", "1.0.1")).toBe(-1);
50
+ expect(tagPackage.compareVersions("1.0.1", "1.0.0")).toBe(1);
51
+ expect(tagPackage.compareVersions("1.0.0", "1.0.0")).toBe(0);
52
+ expect(tagPackage.compareVersions("2.0.0", "1.9.9")).toBe(1);
53
+ expect(tagPackage.compareVersions("1.0.0", "2.0.0")).toBe(-1);
54
+ });
55
+
56
+ test("should handle version comparison with different lengths", () => {
57
+ const packageInstance = new EntityPackage("api");
58
+ const tagPackage = new EntityPackageTags(packageInstance);
59
+
60
+ expect(tagPackage.compareVersions("1.0", "1.0.0")).toBe(0);
61
+ expect(tagPackage.compareVersions("1.0.0", "1.0")).toBe(0);
62
+ expect(tagPackage.compareVersions("1", "1.0.0")).toBe(0);
63
+ });
64
+
65
+ test("should handle version comparison edge cases", () => {
66
+ const packageInstance = new EntityPackage("api");
67
+ const tagPackage = new EntityPackageTags(packageInstance);
68
+
69
+ expect(tagPackage.compareVersions("0.0.0", "0.0.1")).toBe(-1);
70
+ expect(tagPackage.compareVersions("0.1.0", "0.0.9")).toBe(1);
71
+ expect(tagPackage.compareVersions("1.0.0", "0.9.9")).toBe(1);
72
+ });
73
+ });