@akanjs/cli 0.9.41 → 0.9.43

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 (547) hide show
  1. package/cjs/index.js +941 -538
  2. package/cjs/src/guidelines/___library/sharedUiStructureDescription.en.md +0 -1
  3. package/cjs/src/guidelines/databaseModule/databaseModule.instruction.md +3 -50
  4. package/cjs/src/guidelines/modelService/modelService.generate.json +3 -40
  5. package/cjs/src/guidelines/modelService/modelService.instruction.md +0 -164
  6. package/cjs/src/guidelines/scalarModule/scalarModule.instruction.md +0 -3
  7. package/cjs/src/templates/__scalar/__model__/__model__.constant.js +1 -1
  8. package/cjs/src/templates/__scalar/__model__/__model__.dictionary.js +1 -1
  9. package/cjs/src/templates/__scalar/__model__/__model__.document.js +1 -1
  10. package/cjs/src/templates/app/akan.config.js +1 -1
  11. package/cjs/src/templates/app/app/[lang]/layout.js +1 -1
  12. package/cjs/src/templates/app/app/[lang]/page.js +1 -1
  13. package/cjs/src/templates/app/app/csr.js +1 -1
  14. package/cjs/src/templates/app/app/layout.js +1 -1
  15. package/cjs/src/templates/app/app/robots.js +1 -1
  16. package/cjs/src/templates/app/app/sitemap.js +1 -1
  17. package/cjs/src/templates/app/base/baseLogic.js +1 -1
  18. package/cjs/src/templates/app/base/index.js +1 -1
  19. package/cjs/src/templates/app/common/commonLogic.js +1 -1
  20. package/cjs/src/templates/app/common/index.js +1 -1
  21. package/cjs/src/templates/app/env/env.client.js +1 -1
  22. package/cjs/src/templates/app/env/env.client.type.js +1 -1
  23. package/cjs/src/templates/app/env/env.server.js +1 -1
  24. package/cjs/src/templates/app/jest.config.js +1 -1
  25. package/cjs/src/templates/app/lib/___appName__/__appName__.dictionary.js +7 -2
  26. package/cjs/src/templates/app/lib/___appName__/__appName__.service.js +2 -9
  27. package/cjs/src/templates/app/lib/___appName__/{_server.js → __appName__.signal.js} +9 -9
  28. package/cjs/src/templates/app/lib/___appName__/__appName__.store.js +1 -1
  29. package/cjs/src/templates/app/lib/option.js +1 -1
  30. package/cjs/src/templates/app/lib/setting/Setting.Template.js +6 -19
  31. package/cjs/src/templates/app/lib/setting/Setting.Unit.js +3 -3
  32. package/cjs/src/templates/app/lib/setting/Setting.Util.js +8 -2
  33. package/cjs/src/templates/app/lib/setting/Setting.View.js +4 -7
  34. package/cjs/src/templates/app/lib/setting/Setting.Zone.js +2 -8
  35. package/cjs/src/templates/app/lib/setting/setting.constant.js +1 -1
  36. package/cjs/src/templates/app/lib/setting/setting.dictionary.js +1 -1
  37. package/cjs/src/templates/app/lib/setting/setting.document.js +1 -1
  38. package/cjs/src/templates/app/lib/setting/setting.service.js +1 -1
  39. package/cjs/src/templates/app/lib/setting/setting.signal.js +1 -1
  40. package/cjs/src/templates/app/lib/setting/setting.store.js +1 -1
  41. package/cjs/src/templates/app/lib/summary/Summary.Template.js +5 -4
  42. package/cjs/src/templates/app/lib/summary/Summary.Unit.js +4 -5
  43. package/cjs/src/templates/app/lib/summary/Summary.Util.js +10 -3
  44. package/cjs/src/templates/app/lib/summary/Summary.View.js +5 -9
  45. package/cjs/src/templates/app/lib/summary/Summary.Zone.js +1 -23
  46. package/cjs/src/templates/app/lib/summary/summary.constant.js +1 -1
  47. package/cjs/src/templates/app/lib/summary/summary.dictionary.js +1 -1
  48. package/cjs/src/templates/app/lib/summary/summary.document.js +1 -1
  49. package/cjs/src/templates/app/lib/summary/summary.service.js +1 -1
  50. package/cjs/src/templates/app/lib/summary/summary.signal.js +1 -1
  51. package/cjs/src/templates/app/lib/summary/summary.store.js +1 -1
  52. package/cjs/src/templates/app/lib/user/User.Template.js +2 -3
  53. package/cjs/src/templates/app/lib/user/User.Unit.js +4 -5
  54. package/cjs/src/templates/app/lib/user/User.Util.js +6 -52
  55. package/cjs/src/templates/app/lib/user/User.View.js +2 -4
  56. package/cjs/src/templates/app/lib/user/User.Zone.js +8 -33
  57. package/cjs/src/templates/app/lib/user/user.constant.js +1 -1
  58. package/cjs/src/templates/app/lib/user/user.dictionary.js +1 -1
  59. package/cjs/src/templates/app/lib/user/user.document.js +2 -8
  60. package/cjs/src/templates/app/lib/user/user.service.js +3 -9
  61. package/cjs/src/templates/app/lib/user/user.signal.js +1 -1
  62. package/cjs/src/templates/app/lib/user/user.signal.spec.js +1 -1
  63. package/cjs/src/templates/app/lib/user/user.signal.test.js +1 -1
  64. package/cjs/src/templates/app/lib/user/user.store.js +1 -1
  65. package/cjs/src/templates/app/main.js +1 -1
  66. package/cjs/src/templates/app/middleware.js +1 -1
  67. package/cjs/src/templates/app/nest/backendLogic.js +1 -1
  68. package/cjs/src/templates/app/nest/index.js +1 -1
  69. package/cjs/src/templates/app/next/frontendLogic.js +1 -1
  70. package/cjs/src/templates/app/next/index.js +1 -1
  71. package/cjs/src/templates/app/ui/UiComponent.js +1 -1
  72. package/cjs/src/templates/app/ui/index.js +1 -1
  73. package/cjs/src/templates/client.js +11 -5
  74. package/cjs/src/templates/crudPages/[__model__Id]/edit/page.js +1 -1
  75. package/cjs/src/templates/crudPages/[__model__Id]/page.js +1 -1
  76. package/cjs/src/templates/crudPages/new/page.js +1 -1
  77. package/cjs/src/templates/crudPages/page.js +1 -1
  78. package/cjs/src/templates/crudSinglePage/page.js +1 -1
  79. package/cjs/src/templates/index.js +1 -1
  80. package/cjs/src/templates/lib/__lib/extends/summary.constant.js +7 -5
  81. package/cjs/src/templates/lib/__lib/lib.constant.js +7 -11
  82. package/cjs/src/templates/lib/__lib/lib.dictionary.js +4 -4
  83. package/cjs/src/templates/lib/__lib/lib.document.js +4 -4
  84. package/cjs/src/templates/lib/__lib/lib.service.js +19 -24
  85. package/cjs/src/templates/lib/__lib/lib.signal.js +5 -4
  86. package/cjs/src/templates/lib/__lib/lib.store.js +3 -3
  87. package/cjs/src/templates/lib/cnst.js +1 -1
  88. package/cjs/src/templates/lib/cnst_.js +10 -7
  89. package/cjs/src/templates/lib/db.js +5 -5
  90. package/cjs/src/templates/lib/dict.js +5 -5
  91. package/cjs/src/templates/lib/fetch.js +7 -7
  92. package/cjs/src/templates/lib/sig.js +4 -8
  93. package/cjs/src/templates/lib/srv.js +5 -8
  94. package/cjs/src/templates/lib/st.js +3 -3
  95. package/cjs/src/templates/lib/store.js +7 -10
  96. package/cjs/src/templates/lib/usePage.js +1 -1
  97. package/cjs/src/templates/libRoot/akan.config.js +1 -1
  98. package/cjs/src/templates/libRoot/base/baseLogic.js +1 -1
  99. package/cjs/src/templates/libRoot/base/index.js +1 -1
  100. package/cjs/src/templates/libRoot/common/commonLogic.js +1 -1
  101. package/cjs/src/templates/libRoot/common/index.js +1 -1
  102. package/cjs/src/templates/libRoot/jest.config.js +1 -1
  103. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +1 -1
  104. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -1
  105. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.store.js +1 -1
  106. package/cjs/src/templates/libRoot/lib/option.js +1 -1
  107. package/cjs/src/templates/libRoot/lib/setting/Setting.Template.js +6 -19
  108. package/cjs/src/templates/libRoot/lib/setting/Setting.Unit.js +3 -3
  109. package/cjs/src/templates/libRoot/lib/setting/Setting.Util.js +8 -2
  110. package/cjs/src/templates/libRoot/lib/setting/Setting.View.js +4 -7
  111. package/cjs/src/templates/libRoot/lib/setting/Setting.Zone.js +2 -8
  112. package/cjs/src/templates/libRoot/lib/setting/setting.constant.js +1 -1
  113. package/cjs/src/templates/libRoot/lib/setting/setting.dictionary.js +1 -1
  114. package/cjs/src/templates/libRoot/lib/setting/setting.document.js +1 -1
  115. package/cjs/src/templates/libRoot/lib/setting/setting.service.js +1 -1
  116. package/cjs/src/templates/libRoot/lib/setting/setting.signal.js +1 -1
  117. package/cjs/src/templates/libRoot/lib/setting/setting.store.js +1 -1
  118. package/cjs/src/templates/libRoot/lib/summary/Summary.Template.js +5 -4
  119. package/cjs/src/templates/libRoot/lib/summary/Summary.Unit.js +4 -5
  120. package/cjs/src/templates/libRoot/lib/summary/Summary.Util.js +10 -3
  121. package/cjs/src/templates/libRoot/lib/summary/Summary.View.js +5 -9
  122. package/cjs/src/templates/libRoot/lib/summary/Summary.Zone.js +1 -23
  123. package/cjs/src/templates/libRoot/lib/summary/summary.constant.js +1 -1
  124. package/cjs/src/templates/libRoot/lib/summary/summary.dictionary.js +1 -1
  125. package/cjs/src/templates/libRoot/lib/summary/summary.document.js +1 -1
  126. package/cjs/src/templates/libRoot/lib/summary/summary.service.js +1 -1
  127. package/cjs/src/templates/libRoot/lib/summary/summary.signal.js +1 -1
  128. package/cjs/src/templates/libRoot/lib/summary/summary.store.js +1 -1
  129. package/cjs/src/templates/libRoot/lib/user/User.Template.js +2 -3
  130. package/cjs/src/templates/libRoot/lib/user/User.Unit.js +4 -5
  131. package/cjs/src/templates/libRoot/lib/user/User.Util.js +6 -52
  132. package/cjs/src/templates/libRoot/lib/user/User.View.js +2 -4
  133. package/cjs/src/templates/libRoot/lib/user/User.Zone.js +8 -32
  134. package/cjs/src/templates/libRoot/lib/user/user.constant.js +1 -1
  135. package/cjs/src/templates/libRoot/lib/user/user.dictionary.js +1 -1
  136. package/cjs/src/templates/libRoot/lib/user/user.document.js +2 -8
  137. package/cjs/src/templates/libRoot/lib/user/user.service.js +3 -9
  138. package/cjs/src/templates/libRoot/lib/user/user.signal.js +1 -1
  139. package/cjs/src/templates/libRoot/lib/user/user.signal.spec.js +1 -1
  140. package/cjs/src/templates/libRoot/lib/user/user.signal.test.js +1 -1
  141. package/cjs/src/templates/libRoot/lib/user/user.store.js +1 -1
  142. package/cjs/src/templates/libRoot/nest/backendLogic.js +1 -1
  143. package/cjs/src/templates/libRoot/nest/index.js +1 -1
  144. package/cjs/src/templates/libRoot/next/frontendLogic.js +1 -1
  145. package/cjs/src/templates/libRoot/next/index.js +1 -1
  146. package/cjs/src/templates/libRoot/ui/index.js +1 -1
  147. package/cjs/src/templates/module/__Model__.Template.js +1 -1
  148. package/cjs/src/templates/module/__Model__.Unit.js +1 -1
  149. package/cjs/src/templates/module/__Model__.Util.js +7 -37
  150. package/cjs/src/templates/module/__Model__.View.js +1 -1
  151. package/cjs/src/templates/module/__Model__.Zone.js +3 -27
  152. package/cjs/src/templates/module/__model__.constant.js +1 -1
  153. package/cjs/src/templates/module/__model__.dictionary.js +1 -1
  154. package/cjs/src/templates/module/__model__.document.js +2 -8
  155. package/cjs/src/templates/module/__model__.service.js +2 -8
  156. package/cjs/src/templates/module/__model__.signal.js +1 -1
  157. package/cjs/src/templates/module/__model__.signal.spec.js +1 -1
  158. package/cjs/src/templates/module/__model__.signal.test.js +1 -1
  159. package/cjs/src/templates/module/__model__.store.js +1 -1
  160. package/cjs/src/templates/module/index.js +1 -1
  161. package/cjs/src/templates/{libRoot/lib/user → moduleRoot}/index.js +23 -35
  162. package/cjs/src/templates/server.js +31 -13
  163. package/cjs/src/templates/workspaceRoot/.gitignore.template +2 -2
  164. package/cjs/src/templates/workspaceRoot/.vscode/settings.json.template +0 -1
  165. package/esm/index.js +942 -539
  166. package/esm/src/guidelines/___library/sharedUiStructureDescription.en.md +0 -1
  167. package/esm/src/guidelines/databaseModule/databaseModule.instruction.md +3 -50
  168. package/esm/src/guidelines/modelService/modelService.generate.json +3 -40
  169. package/esm/src/guidelines/modelService/modelService.instruction.md +0 -164
  170. package/esm/src/guidelines/scalarModule/scalarModule.instruction.md +0 -3
  171. package/esm/src/templates/__scalar/__model__/__model__.constant.js +1 -1
  172. package/esm/src/templates/__scalar/__model__/__model__.dictionary.js +1 -1
  173. package/esm/src/templates/__scalar/__model__/__model__.document.js +1 -1
  174. package/esm/src/templates/app/akan.config.js +1 -1
  175. package/esm/src/templates/app/app/[lang]/layout.js +1 -1
  176. package/esm/src/templates/app/app/[lang]/page.js +1 -1
  177. package/esm/src/templates/app/app/csr.js +1 -1
  178. package/esm/src/templates/app/app/layout.js +1 -1
  179. package/esm/src/templates/app/app/robots.js +1 -1
  180. package/esm/src/templates/app/app/sitemap.js +1 -1
  181. package/esm/src/templates/app/base/baseLogic.js +1 -1
  182. package/esm/src/templates/app/base/index.js +1 -1
  183. package/esm/src/templates/app/common/commonLogic.js +1 -1
  184. package/esm/src/templates/app/common/index.js +1 -1
  185. package/esm/src/templates/app/env/env.client.js +1 -1
  186. package/esm/src/templates/app/env/env.client.type.js +1 -1
  187. package/esm/src/templates/app/env/env.server.js +1 -1
  188. package/esm/src/templates/app/jest.config.js +1 -1
  189. package/esm/src/templates/app/lib/___appName__/__appName__.dictionary.js +7 -2
  190. package/esm/src/templates/app/lib/___appName__/__appName__.service.js +2 -9
  191. package/esm/src/templates/app/lib/___appName__/__appName__.signal.js +14 -0
  192. package/esm/src/templates/app/lib/___appName__/__appName__.store.js +1 -1
  193. package/esm/src/templates/app/lib/option.js +1 -1
  194. package/esm/src/templates/app/lib/setting/Setting.Template.js +6 -19
  195. package/esm/src/templates/app/lib/setting/Setting.Unit.js +3 -3
  196. package/esm/src/templates/app/lib/setting/Setting.Util.js +8 -2
  197. package/esm/src/templates/app/lib/setting/Setting.View.js +4 -7
  198. package/esm/src/templates/app/lib/setting/Setting.Zone.js +2 -8
  199. package/esm/src/templates/app/lib/setting/setting.constant.js +1 -1
  200. package/esm/src/templates/app/lib/setting/setting.dictionary.js +1 -1
  201. package/esm/src/templates/app/lib/setting/setting.document.js +1 -1
  202. package/esm/src/templates/app/lib/setting/setting.service.js +1 -1
  203. package/esm/src/templates/app/lib/setting/setting.signal.js +1 -1
  204. package/esm/src/templates/app/lib/setting/setting.store.js +1 -1
  205. package/esm/src/templates/app/lib/summary/Summary.Template.js +5 -4
  206. package/esm/src/templates/app/lib/summary/Summary.Unit.js +4 -5
  207. package/esm/src/templates/app/lib/summary/Summary.Util.js +10 -3
  208. package/esm/src/templates/app/lib/summary/Summary.View.js +5 -9
  209. package/esm/src/templates/app/lib/summary/Summary.Zone.js +1 -23
  210. package/esm/src/templates/app/lib/summary/summary.constant.js +1 -1
  211. package/esm/src/templates/app/lib/summary/summary.dictionary.js +1 -1
  212. package/esm/src/templates/app/lib/summary/summary.document.js +1 -1
  213. package/esm/src/templates/app/lib/summary/summary.service.js +1 -1
  214. package/esm/src/templates/app/lib/summary/summary.signal.js +1 -1
  215. package/esm/src/templates/app/lib/summary/summary.store.js +1 -1
  216. package/esm/src/templates/app/lib/user/User.Template.js +2 -3
  217. package/esm/src/templates/app/lib/user/User.Unit.js +4 -5
  218. package/esm/src/templates/app/lib/user/User.Util.js +6 -52
  219. package/esm/src/templates/app/lib/user/User.View.js +2 -4
  220. package/esm/src/templates/app/lib/user/User.Zone.js +8 -33
  221. package/esm/src/templates/app/lib/user/user.constant.js +1 -1
  222. package/esm/src/templates/app/lib/user/user.dictionary.js +1 -1
  223. package/esm/src/templates/app/lib/user/user.document.js +2 -8
  224. package/esm/src/templates/app/lib/user/user.service.js +3 -9
  225. package/esm/src/templates/app/lib/user/user.signal.js +1 -1
  226. package/esm/src/templates/app/lib/user/user.signal.spec.js +1 -1
  227. package/esm/src/templates/app/lib/user/user.signal.test.js +1 -1
  228. package/esm/src/templates/app/lib/user/user.store.js +1 -1
  229. package/esm/src/templates/app/main.js +1 -1
  230. package/esm/src/templates/app/middleware.js +1 -1
  231. package/esm/src/templates/app/nest/backendLogic.js +1 -1
  232. package/esm/src/templates/app/nest/index.js +1 -1
  233. package/esm/src/templates/app/next/frontendLogic.js +1 -1
  234. package/esm/src/templates/app/next/index.js +1 -1
  235. package/esm/src/templates/app/ui/UiComponent.js +1 -1
  236. package/esm/src/templates/app/ui/index.js +1 -1
  237. package/esm/src/templates/client.js +11 -5
  238. package/esm/src/templates/crudPages/[__model__Id]/edit/page.js +1 -1
  239. package/esm/src/templates/crudPages/[__model__Id]/page.js +1 -1
  240. package/esm/src/templates/crudPages/new/page.js +1 -1
  241. package/esm/src/templates/crudPages/page.js +1 -1
  242. package/esm/src/templates/crudSinglePage/page.js +1 -1
  243. package/esm/src/templates/index.js +1 -1
  244. package/esm/src/templates/lib/__lib/extends/summary.constant.js +7 -5
  245. package/esm/src/templates/lib/__lib/lib.constant.js +7 -11
  246. package/esm/src/templates/lib/__lib/lib.dictionary.js +4 -4
  247. package/esm/src/templates/lib/__lib/lib.document.js +4 -4
  248. package/esm/src/templates/lib/__lib/lib.service.js +19 -24
  249. package/esm/src/templates/lib/__lib/lib.signal.js +5 -4
  250. package/esm/src/templates/lib/__lib/lib.store.js +3 -3
  251. package/esm/src/templates/lib/cnst.js +1 -1
  252. package/esm/src/templates/lib/cnst_.js +10 -7
  253. package/esm/src/templates/lib/db.js +5 -5
  254. package/esm/src/templates/lib/dict.js +5 -5
  255. package/esm/src/templates/lib/fetch.js +7 -7
  256. package/esm/src/templates/lib/sig.js +4 -8
  257. package/esm/src/templates/lib/srv.js +5 -8
  258. package/esm/src/templates/lib/st.js +3 -3
  259. package/esm/src/templates/lib/store.js +7 -10
  260. package/esm/src/templates/lib/usePage.js +1 -1
  261. package/esm/src/templates/libRoot/akan.config.js +1 -1
  262. package/esm/src/templates/libRoot/base/baseLogic.js +1 -1
  263. package/esm/src/templates/libRoot/base/index.js +1 -1
  264. package/esm/src/templates/libRoot/common/commonLogic.js +1 -1
  265. package/esm/src/templates/libRoot/common/index.js +1 -1
  266. package/esm/src/templates/libRoot/jest.config.js +1 -1
  267. package/esm/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +1 -1
  268. package/esm/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -1
  269. package/esm/src/templates/libRoot/lib/___libName__/__libName__.store.js +1 -1
  270. package/esm/src/templates/libRoot/lib/option.js +1 -1
  271. package/esm/src/templates/libRoot/lib/setting/Setting.Template.js +6 -19
  272. package/esm/src/templates/libRoot/lib/setting/Setting.Unit.js +3 -3
  273. package/esm/src/templates/libRoot/lib/setting/Setting.Util.js +8 -2
  274. package/esm/src/templates/libRoot/lib/setting/Setting.View.js +4 -7
  275. package/esm/src/templates/libRoot/lib/setting/Setting.Zone.js +2 -8
  276. package/esm/src/templates/libRoot/lib/setting/setting.constant.js +1 -1
  277. package/esm/src/templates/libRoot/lib/setting/setting.dictionary.js +1 -1
  278. package/esm/src/templates/libRoot/lib/setting/setting.document.js +1 -1
  279. package/esm/src/templates/libRoot/lib/setting/setting.service.js +1 -1
  280. package/esm/src/templates/libRoot/lib/setting/setting.signal.js +1 -1
  281. package/esm/src/templates/libRoot/lib/setting/setting.store.js +1 -1
  282. package/esm/src/templates/libRoot/lib/summary/Summary.Template.js +5 -4
  283. package/esm/src/templates/libRoot/lib/summary/Summary.Unit.js +4 -5
  284. package/esm/src/templates/libRoot/lib/summary/Summary.Util.js +10 -3
  285. package/esm/src/templates/libRoot/lib/summary/Summary.View.js +5 -9
  286. package/esm/src/templates/libRoot/lib/summary/Summary.Zone.js +1 -23
  287. package/esm/src/templates/libRoot/lib/summary/summary.constant.js +1 -1
  288. package/esm/src/templates/libRoot/lib/summary/summary.dictionary.js +1 -1
  289. package/esm/src/templates/libRoot/lib/summary/summary.document.js +1 -1
  290. package/esm/src/templates/libRoot/lib/summary/summary.service.js +1 -1
  291. package/esm/src/templates/libRoot/lib/summary/summary.signal.js +1 -1
  292. package/esm/src/templates/libRoot/lib/summary/summary.store.js +1 -1
  293. package/esm/src/templates/libRoot/lib/user/User.Template.js +2 -3
  294. package/esm/src/templates/libRoot/lib/user/User.Unit.js +4 -5
  295. package/esm/src/templates/libRoot/lib/user/User.Util.js +6 -52
  296. package/esm/src/templates/libRoot/lib/user/User.View.js +2 -4
  297. package/esm/src/templates/libRoot/lib/user/User.Zone.js +8 -32
  298. package/esm/src/templates/libRoot/lib/user/user.constant.js +1 -1
  299. package/esm/src/templates/libRoot/lib/user/user.dictionary.js +1 -1
  300. package/esm/src/templates/libRoot/lib/user/user.document.js +2 -8
  301. package/esm/src/templates/libRoot/lib/user/user.service.js +3 -9
  302. package/esm/src/templates/libRoot/lib/user/user.signal.js +1 -1
  303. package/esm/src/templates/libRoot/lib/user/user.signal.spec.js +1 -1
  304. package/esm/src/templates/libRoot/lib/user/user.signal.test.js +1 -1
  305. package/esm/src/templates/libRoot/lib/user/user.store.js +1 -1
  306. package/esm/src/templates/libRoot/nest/backendLogic.js +1 -1
  307. package/esm/src/templates/libRoot/nest/index.js +1 -1
  308. package/esm/src/templates/libRoot/next/frontendLogic.js +1 -1
  309. package/esm/src/templates/libRoot/next/index.js +1 -1
  310. package/esm/src/templates/libRoot/ui/index.js +1 -1
  311. package/esm/src/templates/module/__Model__.Template.js +1 -1
  312. package/esm/src/templates/module/__Model__.Unit.js +1 -1
  313. package/esm/src/templates/module/__Model__.Util.js +7 -37
  314. package/esm/src/templates/module/__Model__.View.js +1 -1
  315. package/esm/src/templates/module/__Model__.Zone.js +3 -27
  316. package/esm/src/templates/module/__model__.constant.js +1 -1
  317. package/esm/src/templates/module/__model__.dictionary.js +1 -1
  318. package/esm/src/templates/module/__model__.document.js +2 -8
  319. package/esm/src/templates/module/__model__.service.js +2 -8
  320. package/esm/src/templates/module/__model__.signal.js +1 -1
  321. package/esm/src/templates/module/__model__.signal.spec.js +1 -1
  322. package/esm/src/templates/module/__model__.signal.test.js +1 -1
  323. package/esm/src/templates/module/__model__.store.js +1 -1
  324. package/esm/src/templates/module/index.js +1 -1
  325. package/esm/src/templates/moduleRoot/index.js +29 -0
  326. package/esm/src/templates/server.js +31 -13
  327. package/esm/src/templates/workspaceRoot/.gitignore.template +2 -2
  328. package/esm/src/templates/workspaceRoot/.vscode/settings.json.template +0 -1
  329. package/package.json +1 -1
  330. package/src/application/application.runner.d.ts +2 -3
  331. package/src/application/application.script.d.ts +1 -1
  332. package/src/guidelines/___library/sharedUiStructureDescription.en.md +0 -1
  333. package/src/guidelines/databaseModule/databaseModule.instruction.md +3 -50
  334. package/src/guidelines/modelService/modelService.instruction.md +0 -164
  335. package/src/guidelines/scalarModule/scalarModule.instruction.md +0 -3
  336. package/src/library/library.script.d.ts +1 -1
  337. package/src/package/package.runner.d.ts +1 -1
  338. package/src/package/package.script.d.ts +1 -1
  339. package/src/templates/__scalar/__model__/__model__.constant.d.ts +2 -2
  340. package/src/templates/__scalar/__model__/__model__.dictionary.d.ts +2 -2
  341. package/src/templates/__scalar/__model__/__model__.document.d.ts +2 -2
  342. package/src/templates/app/akan.config.d.ts +2 -2
  343. package/src/templates/app/app/[lang]/layout.d.ts +2 -2
  344. package/src/templates/app/app/[lang]/page.d.ts +2 -2
  345. package/src/templates/app/app/csr.d.ts +2 -2
  346. package/src/templates/app/app/layout.d.ts +2 -2
  347. package/src/templates/app/app/robots.d.ts +2 -2
  348. package/src/templates/app/app/sitemap.d.ts +2 -2
  349. package/src/templates/app/base/baseLogic.d.ts +2 -2
  350. package/src/templates/app/base/index.d.ts +2 -2
  351. package/src/templates/app/common/commonLogic.d.ts +2 -2
  352. package/src/templates/app/common/index.d.ts +2 -2
  353. package/src/templates/app/env/env.client.d.ts +2 -2
  354. package/src/templates/app/env/env.client.type.d.ts +2 -2
  355. package/src/templates/app/env/env.server.d.ts +2 -2
  356. package/src/templates/app/jest.config.d.ts +2 -2
  357. package/src/templates/app/lib/___appName__/__appName__.dictionary.d.ts +2 -2
  358. package/src/templates/app/lib/___appName__/__appName__.service.d.ts +2 -2
  359. package/src/templates/app/lib/___appName__/__appName__.signal.d.ts +7 -0
  360. package/src/templates/app/lib/___appName__/__appName__.store.d.ts +2 -2
  361. package/src/templates/app/lib/option.d.ts +2 -2
  362. package/src/templates/app/lib/setting/Setting.Template.d.ts +2 -2
  363. package/src/templates/app/lib/setting/Setting.Unit.d.ts +2 -2
  364. package/src/templates/app/lib/setting/Setting.Util.d.ts +2 -2
  365. package/src/templates/app/lib/setting/Setting.View.d.ts +2 -2
  366. package/src/templates/app/lib/setting/Setting.Zone.d.ts +2 -2
  367. package/src/templates/app/lib/setting/setting.constant.d.ts +2 -2
  368. package/src/templates/app/lib/setting/setting.dictionary.d.ts +2 -2
  369. package/src/templates/app/lib/setting/setting.document.d.ts +2 -2
  370. package/src/templates/app/lib/setting/setting.service.d.ts +2 -2
  371. package/src/templates/app/lib/setting/setting.signal.d.ts +2 -2
  372. package/src/templates/app/lib/setting/setting.store.d.ts +2 -2
  373. package/src/templates/app/lib/summary/Summary.Template.d.ts +2 -2
  374. package/src/templates/app/lib/summary/Summary.Unit.d.ts +2 -2
  375. package/src/templates/app/lib/summary/Summary.Util.d.ts +2 -2
  376. package/src/templates/app/lib/summary/Summary.View.d.ts +2 -2
  377. package/src/templates/app/lib/summary/Summary.Zone.d.ts +2 -2
  378. package/src/templates/app/lib/summary/summary.constant.d.ts +2 -2
  379. package/src/templates/app/lib/summary/summary.dictionary.d.ts +2 -2
  380. package/src/templates/app/lib/summary/summary.document.d.ts +2 -2
  381. package/src/templates/app/lib/summary/summary.service.d.ts +2 -2
  382. package/src/templates/app/lib/summary/summary.signal.d.ts +2 -2
  383. package/src/templates/app/lib/summary/summary.store.d.ts +2 -2
  384. package/src/templates/app/lib/user/User.Template.d.ts +2 -2
  385. package/src/templates/app/lib/user/User.Unit.d.ts +2 -2
  386. package/src/templates/app/lib/user/User.Util.d.ts +2 -2
  387. package/src/templates/app/lib/user/User.View.d.ts +2 -2
  388. package/src/templates/app/lib/user/User.Zone.d.ts +2 -2
  389. package/src/templates/app/lib/user/user.constant.d.ts +2 -2
  390. package/src/templates/app/lib/user/user.dictionary.d.ts +2 -2
  391. package/src/templates/app/lib/user/user.document.d.ts +2 -2
  392. package/src/templates/app/lib/user/user.service.d.ts +2 -2
  393. package/src/templates/app/lib/user/user.signal.d.ts +2 -2
  394. package/src/templates/app/lib/user/user.signal.spec.d.ts +2 -2
  395. package/src/templates/app/lib/user/user.signal.test.d.ts +2 -2
  396. package/src/templates/app/lib/user/user.store.d.ts +2 -2
  397. package/src/templates/app/main.d.ts +2 -2
  398. package/src/templates/app/middleware.d.ts +2 -2
  399. package/src/templates/app/nest/backendLogic.d.ts +2 -2
  400. package/src/templates/app/nest/index.d.ts +2 -2
  401. package/src/templates/app/next/frontendLogic.d.ts +2 -2
  402. package/src/templates/app/next/index.d.ts +2 -2
  403. package/src/templates/app/ui/UiComponent.d.ts +2 -2
  404. package/src/templates/app/ui/index.d.ts +2 -2
  405. package/src/templates/client.d.ts +2 -2
  406. package/src/templates/crudPages/[__model__Id]/edit/page.d.ts +2 -2
  407. package/src/templates/crudPages/[__model__Id]/page.d.ts +2 -2
  408. package/src/templates/crudPages/new/page.d.ts +2 -2
  409. package/src/templates/crudPages/page.d.ts +2 -2
  410. package/src/templates/crudSinglePage/page.d.ts +2 -2
  411. package/src/templates/index.d.ts +2 -2
  412. package/src/templates/lib/__lib/extends/summary.constant.d.ts +2 -2
  413. package/src/templates/lib/__lib/lib.constant.d.ts +2 -2
  414. package/src/templates/lib/__lib/lib.dictionary.d.ts +2 -2
  415. package/src/templates/lib/__lib/lib.document.d.ts +2 -2
  416. package/src/templates/lib/__lib/lib.service.d.ts +2 -2
  417. package/src/templates/lib/__lib/lib.signal.d.ts +2 -2
  418. package/src/templates/lib/__lib/lib.store.d.ts +2 -2
  419. package/src/templates/lib/cnst.d.ts +2 -2
  420. package/src/templates/lib/cnst_.d.ts +2 -2
  421. package/src/templates/lib/db.d.ts +2 -2
  422. package/src/templates/lib/dict.d.ts +2 -2
  423. package/src/templates/lib/fetch.d.ts +2 -2
  424. package/src/templates/lib/sig.d.ts +2 -2
  425. package/src/templates/lib/srv.d.ts +2 -2
  426. package/src/templates/lib/st.d.ts +2 -2
  427. package/src/templates/lib/store.d.ts +2 -2
  428. package/src/templates/lib/usePage.d.ts +2 -2
  429. package/src/templates/libRoot/akan.config.d.ts +1 -1
  430. package/src/templates/libRoot/base/baseLogic.d.ts +1 -1
  431. package/src/templates/libRoot/base/index.d.ts +1 -1
  432. package/src/templates/libRoot/common/commonLogic.d.ts +1 -1
  433. package/src/templates/libRoot/common/index.d.ts +1 -1
  434. package/src/templates/libRoot/jest.config.d.ts +2 -2
  435. package/src/templates/libRoot/lib/___libName__/__libName__.dictionary.d.ts +1 -1
  436. package/src/templates/libRoot/lib/___libName__/__libName__.service.d.ts +1 -1
  437. package/src/templates/libRoot/lib/___libName__/__libName__.store.d.ts +1 -1
  438. package/src/templates/libRoot/lib/option.d.ts +2 -2
  439. package/src/templates/libRoot/lib/setting/Setting.Template.d.ts +2 -2
  440. package/src/templates/libRoot/lib/setting/Setting.Unit.d.ts +2 -2
  441. package/src/templates/libRoot/lib/setting/Setting.Util.d.ts +2 -2
  442. package/src/templates/libRoot/lib/setting/Setting.View.d.ts +2 -2
  443. package/src/templates/libRoot/lib/setting/Setting.Zone.d.ts +2 -2
  444. package/src/templates/libRoot/lib/setting/setting.constant.d.ts +2 -2
  445. package/src/templates/libRoot/lib/setting/setting.dictionary.d.ts +2 -2
  446. package/src/templates/libRoot/lib/setting/setting.document.d.ts +2 -2
  447. package/src/templates/libRoot/lib/setting/setting.service.d.ts +2 -2
  448. package/src/templates/libRoot/lib/setting/setting.signal.d.ts +2 -2
  449. package/src/templates/libRoot/lib/setting/setting.store.d.ts +2 -2
  450. package/src/templates/libRoot/lib/summary/Summary.Template.d.ts +2 -2
  451. package/src/templates/libRoot/lib/summary/Summary.Unit.d.ts +2 -2
  452. package/src/templates/libRoot/lib/summary/Summary.Util.d.ts +2 -2
  453. package/src/templates/libRoot/lib/summary/Summary.View.d.ts +2 -2
  454. package/src/templates/libRoot/lib/summary/Summary.Zone.d.ts +2 -2
  455. package/src/templates/libRoot/lib/summary/summary.constant.d.ts +2 -2
  456. package/src/templates/libRoot/lib/summary/summary.dictionary.d.ts +2 -2
  457. package/src/templates/libRoot/lib/summary/summary.document.d.ts +2 -2
  458. package/src/templates/libRoot/lib/summary/summary.service.d.ts +2 -2
  459. package/src/templates/libRoot/lib/summary/summary.signal.d.ts +2 -2
  460. package/src/templates/libRoot/lib/summary/summary.store.d.ts +2 -2
  461. package/src/templates/libRoot/lib/user/User.Template.d.ts +2 -2
  462. package/src/templates/libRoot/lib/user/User.Unit.d.ts +2 -2
  463. package/src/templates/libRoot/lib/user/User.Util.d.ts +2 -2
  464. package/src/templates/libRoot/lib/user/User.View.d.ts +2 -2
  465. package/src/templates/libRoot/lib/user/User.Zone.d.ts +2 -2
  466. package/src/templates/libRoot/lib/user/user.constant.d.ts +2 -2
  467. package/src/templates/libRoot/lib/user/user.dictionary.d.ts +2 -2
  468. package/src/templates/libRoot/lib/user/user.document.d.ts +2 -2
  469. package/src/templates/libRoot/lib/user/user.service.d.ts +2 -2
  470. package/src/templates/libRoot/lib/user/user.signal.d.ts +2 -2
  471. package/src/templates/libRoot/lib/user/user.signal.spec.d.ts +2 -2
  472. package/src/templates/libRoot/lib/user/user.signal.test.d.ts +2 -2
  473. package/src/templates/libRoot/lib/user/user.store.d.ts +2 -2
  474. package/src/templates/libRoot/nest/backendLogic.d.ts +1 -1
  475. package/src/templates/libRoot/nest/index.d.ts +1 -1
  476. package/src/templates/libRoot/next/frontendLogic.d.ts +1 -1
  477. package/src/templates/libRoot/next/index.d.ts +1 -1
  478. package/src/templates/libRoot/ui/index.d.ts +1 -1
  479. package/src/templates/module/__Model__.Template.d.ts +2 -2
  480. package/src/templates/module/__Model__.Unit.d.ts +2 -2
  481. package/src/templates/module/__Model__.Util.d.ts +2 -2
  482. package/src/templates/module/__Model__.View.d.ts +2 -2
  483. package/src/templates/module/__Model__.Zone.d.ts +2 -2
  484. package/src/templates/module/__model__.constant.d.ts +2 -2
  485. package/src/templates/module/__model__.dictionary.d.ts +2 -2
  486. package/src/templates/module/__model__.document.d.ts +2 -2
  487. package/src/templates/module/__model__.service.d.ts +2 -2
  488. package/src/templates/module/__model__.signal.d.ts +2 -2
  489. package/src/templates/module/__model__.signal.spec.d.ts +2 -2
  490. package/src/templates/module/__model__.signal.test.d.ts +2 -2
  491. package/src/templates/module/__model__.store.d.ts +2 -2
  492. package/src/templates/module/index.d.ts +2 -2
  493. package/src/templates/moduleRoot/index.d.ts +11 -0
  494. package/src/templates/server.d.ts +2 -2
  495. package/ui/MultiScrollList.d.ts +4 -1
  496. package/cjs/src/templates/app/app/[lang]/admin/page.js +0 -63
  497. package/cjs/src/templates/app/app/[lang]/unknown/page.js +0 -51
  498. package/cjs/src/templates/app/lib/setting/_server.js +0 -48
  499. package/cjs/src/templates/app/lib/setting/index.js +0 -61
  500. package/cjs/src/templates/app/lib/summary/_server.js +0 -48
  501. package/cjs/src/templates/app/lib/summary/index.js +0 -67
  502. package/cjs/src/templates/app/lib/user/_server.js +0 -48
  503. package/cjs/src/templates/app/lib/user/index.js +0 -61
  504. package/cjs/src/templates/lib/__scalar/_server.js +0 -39
  505. package/cjs/src/templates/libRoot/lib/___libName__/_server.js +0 -34
  506. package/cjs/src/templates/libRoot/lib/setting/_server.js +0 -48
  507. package/cjs/src/templates/libRoot/lib/setting/index.js +0 -61
  508. package/cjs/src/templates/libRoot/lib/summary/_server.js +0 -48
  509. package/cjs/src/templates/libRoot/lib/summary/index.js +0 -67
  510. package/cjs/src/templates/libRoot/lib/user/_server.js +0 -48
  511. package/cjs/src/templates/module/_server.js +0 -47
  512. package/esm/src/templates/app/app/[lang]/admin/page.js +0 -43
  513. package/esm/src/templates/app/app/[lang]/unknown/page.js +0 -31
  514. package/esm/src/templates/app/lib/___appName__/_server.js +0 -14
  515. package/esm/src/templates/app/lib/setting/_server.js +0 -28
  516. package/esm/src/templates/app/lib/setting/index.js +0 -41
  517. package/esm/src/templates/app/lib/summary/_server.js +0 -28
  518. package/esm/src/templates/app/lib/summary/index.js +0 -47
  519. package/esm/src/templates/app/lib/user/_server.js +0 -28
  520. package/esm/src/templates/app/lib/user/index.js +0 -41
  521. package/esm/src/templates/lib/__scalar/_server.js +0 -19
  522. package/esm/src/templates/libRoot/lib/___libName__/_server.js +0 -14
  523. package/esm/src/templates/libRoot/lib/setting/_server.js +0 -28
  524. package/esm/src/templates/libRoot/lib/setting/index.js +0 -41
  525. package/esm/src/templates/libRoot/lib/summary/_server.js +0 -28
  526. package/esm/src/templates/libRoot/lib/summary/index.js +0 -47
  527. package/esm/src/templates/libRoot/lib/user/_server.js +0 -28
  528. package/esm/src/templates/libRoot/lib/user/index.js +0 -41
  529. package/esm/src/templates/module/_server.js +0 -27
  530. package/src/templates/app/app/[lang]/admin/page.d.ts +0 -9
  531. package/src/templates/app/app/[lang]/unknown/page.d.ts +0 -9
  532. package/src/templates/app/lib/___appName__/_server.d.ts +0 -7
  533. package/src/templates/app/lib/setting/_server.d.ts +0 -6
  534. package/src/templates/app/lib/setting/index.d.ts +0 -9
  535. package/src/templates/app/lib/summary/_server.d.ts +0 -6
  536. package/src/templates/app/lib/summary/index.d.ts +0 -9
  537. package/src/templates/app/lib/user/_server.d.ts +0 -6
  538. package/src/templates/app/lib/user/index.d.ts +0 -9
  539. package/src/templates/lib/__scalar/_server.d.ts +0 -4
  540. package/src/templates/libRoot/lib/___libName__/_server.d.ts +0 -7
  541. package/src/templates/libRoot/lib/setting/_server.d.ts +0 -6
  542. package/src/templates/libRoot/lib/setting/index.d.ts +0 -9
  543. package/src/templates/libRoot/lib/summary/_server.d.ts +0 -6
  544. package/src/templates/libRoot/lib/summary/index.d.ts +0 -9
  545. package/src/templates/libRoot/lib/user/_server.d.ts +0 -6
  546. package/src/templates/libRoot/lib/user/index.d.ts +0 -9
  547. package/src/templates/module/_server.d.ts +0 -8
package/esm/index.js CHANGED
@@ -122,6 +122,9 @@ var Logger = class _Logger {
122
122
  this.level = level;
123
123
  this.#levelIdx = logLevels.findIndex((l) => l === level);
124
124
  }
125
+ static isVerbose() {
126
+ return this.#levelIdx <= 1;
127
+ }
125
128
  name;
126
129
  constructor(name) {
127
130
  this.name = name;
@@ -380,8 +383,8 @@ import * as fs3 from "fs";
380
383
  import ora2 from "ora";
381
384
  import * as ts from "typescript";
382
385
  var parseTsConfig = (tsConfigPath = "./tsconfig.json") => {
383
- const configFile = ts.readConfigFile(tsConfigPath, (path9) => {
384
- return ts.sys.readFile(path9);
386
+ const configFile = ts.readConfigFile(tsConfigPath, (path10) => {
387
+ return ts.sys.readFile(path10);
385
388
  });
386
389
  return ts.parseJsonConfigFileContent(
387
390
  configFile.config,
@@ -700,46 +703,11 @@ export default getNextConfig(config, appInfo);
700
703
 
701
704
  // pkgs/@akanjs/config/src/types.ts
702
705
  var archs = ["amd64", "arm64"];
703
- var getDefaultFileScan = () => ({
704
- constants: {
705
- databases: [],
706
- scalars: []
707
- },
708
- dictionary: {
709
- databases: [],
710
- services: [],
711
- scalars: []
712
- },
713
- documents: {
714
- databases: [],
715
- scalars: []
716
- },
717
- services: {
718
- databases: [],
719
- services: [],
720
- scalars: []
721
- },
722
- signal: {
723
- databases: [],
724
- services: [],
725
- scalars: []
726
- },
727
- store: {
728
- databases: [],
729
- services: [],
730
- scalars: []
731
- },
732
- components: {
733
- databases: [],
734
- services: [],
735
- scalars: []
736
- }
737
- });
738
706
 
739
707
  // pkgs/@akanjs/config/src/akanConfig.ts
740
708
  var jiti = createJiti(import.meta.url);
741
709
  var makeAppConfig = (config, props) => {
742
- const { name, repoName, serveDomain, env, command = "build" } = props;
710
+ const { name, repoName } = props;
743
711
  return {
744
712
  rootLib: config.rootLib,
745
713
  libs: config.libs ?? [],
@@ -885,18 +853,254 @@ import { exec, fork, spawn } from "child_process";
885
853
  import dotenv from "dotenv";
886
854
  import fs8 from "fs";
887
855
  import fsPromise from "fs/promises";
888
- import path6 from "path";
856
+ import path7 from "path";
889
857
 
890
- // pkgs/@akanjs/devkit/src/dependencyScanner.ts
858
+ // pkgs/@akanjs/devkit/src/getDirname.ts
859
+ import path2 from "path";
860
+ var getDirname = (url) => path2.dirname(new URL(url).pathname);
861
+
862
+ // pkgs/@akanjs/devkit/src/linter.ts
863
+ import chalk from "chalk";
864
+ import { ESLint } from "eslint";
891
865
  import * as fs5 from "fs";
892
- import * as path2 from "path";
866
+ import * as path3 from "path";
867
+ var Linter = class {
868
+ #logger = new Logger("Linter");
869
+ #eslint;
870
+ lintRoot;
871
+ constructor(cwdPath) {
872
+ this.lintRoot = this.#findEslintRootPath(cwdPath);
873
+ this.#eslint = new ESLint({ cwd: this.lintRoot, errorOnUnmatchedPattern: false });
874
+ }
875
+ #findEslintRootPath(dir) {
876
+ const configPath2 = path3.join(dir, "eslint.config.ts");
877
+ if (fs5.existsSync(configPath2))
878
+ return dir;
879
+ const parentDir = path3.dirname(dir);
880
+ return this.#findEslintRootPath(parentDir);
881
+ }
882
+ async lint(filePath, { fix = false, dryRun = false } = {}) {
883
+ if (fix)
884
+ return await this.fixFile(filePath, dryRun);
885
+ return await this.lintFile(filePath);
886
+ }
887
+ /**
888
+ * Lint a single file using ESLint
889
+ * @param filePath - Path to the file to lint
890
+ * @returns Array of ESLint results
891
+ */
892
+ async lintFile(filePath) {
893
+ if (!fs5.existsSync(filePath))
894
+ throw new Error(`File not found: ${filePath}`);
895
+ const isIgnored = await this.#eslint.isPathIgnored(filePath);
896
+ if (isIgnored) {
897
+ this.#logger.warn(`File ${filePath} is ignored by ESLint configuration`);
898
+ return { fixed: false, results: [], errors: [], warnings: [] };
899
+ }
900
+ const results = await this.#eslint.lintFiles([filePath]);
901
+ const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
902
+ const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
903
+ return { fixed: false, results, errors, warnings };
904
+ }
905
+ /**
906
+ * Format lint results for console output
907
+ * @param results - Array of ESLint results
908
+ * @returns Formatted string
909
+ */
910
+ formatLintResults(results) {
911
+ if (results.length === 0)
912
+ return "No files to lint";
913
+ const output = [];
914
+ let totalErrors = 0;
915
+ let totalWarnings = 0;
916
+ results.forEach((result) => {
917
+ totalErrors += result.errorCount;
918
+ totalWarnings += result.warningCount;
919
+ if (result.messages.length > 0) {
920
+ output.push(`
921
+ ${chalk.cyan(result.filePath)}`);
922
+ let sourceLines = [];
923
+ if (fs5.existsSync(result.filePath)) {
924
+ try {
925
+ const sourceContent = fs5.readFileSync(result.filePath, "utf8");
926
+ sourceLines = sourceContent.split("\n");
927
+ } catch (error) {
928
+ }
929
+ }
930
+ result.messages.forEach((message) => {
931
+ const type = message.severity === 2 ? "error" : "warning";
932
+ const typeColor = message.severity === 2 ? chalk.red : chalk.yellow;
933
+ const icon = message.severity === 2 ? "\u274C" : "\u26A0\uFE0F";
934
+ const ruleInfo = message.ruleId ? chalk.dim(` (${message.ruleId})`) : "";
935
+ output.push(`
936
+ ${icon} ${typeColor(type)}: ${message.message}${ruleInfo}`);
937
+ output.push(` ${chalk.gray("at")} ${result.filePath}:${chalk.bold(`${message.line}:${message.column}`)}`);
938
+ if (sourceLines.length > 0 && message.line <= sourceLines.length) {
939
+ const sourceLine = sourceLines[message.line - 1];
940
+ const lineNumber = message.line.toString().padStart(5, " ");
941
+ output.push(`
942
+ ${chalk.dim(lineNumber + " |")} ${sourceLine}`);
943
+ const underlinePrefix = " ".repeat(message.column - 1);
944
+ const underlineLength = message.endColumn ? message.endColumn - message.column : 1;
945
+ const underline = "^".repeat(Math.max(1, underlineLength));
946
+ output.push(`${chalk.dim(" ".repeat(lineNumber.length) + " |")} ${underlinePrefix}${typeColor(underline)}`);
947
+ }
948
+ });
949
+ }
950
+ });
951
+ if (totalErrors === 0 && totalWarnings === 0)
952
+ return chalk.bold("\u2705 No ESLint errors or warnings found");
953
+ const errorText = totalErrors > 0 ? chalk.red(`${totalErrors} error(s)`) : "0 errors";
954
+ const warningText = totalWarnings > 0 ? chalk.yellow(`${totalWarnings} warning(s)`) : "0 warnings";
955
+ const summary = [`
956
+ ${errorText}, ${warningText} found`];
957
+ return summary.concat(output).join("\n");
958
+ }
959
+ /**
960
+ * Get detailed lint information
961
+ * @param filePath - Path to the file to lint
962
+ * @returns Object containing detailed lint information
963
+ */
964
+ async getDetailedLintInfo(filePath) {
965
+ const { results } = await this.lintFile(filePath);
966
+ const details = results.flatMap(
967
+ (result) => result.messages.map((message) => ({
968
+ line: message.line,
969
+ column: message.column,
970
+ message: message.message,
971
+ ruleId: message.ruleId,
972
+ severity: message.severity === 2 ? "error" : "warning",
973
+ fix: message.fix,
974
+ suggestions: message.suggestions
975
+ }))
976
+ );
977
+ const stats = results.reduce(
978
+ (acc, result) => ({
979
+ errorCount: acc.errorCount + result.errorCount,
980
+ warningCount: acc.warningCount + result.warningCount,
981
+ fixableErrorCount: acc.fixableErrorCount + result.fixableErrorCount,
982
+ fixableWarningCount: acc.fixableWarningCount + result.fixableWarningCount
983
+ }),
984
+ { errorCount: 0, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0 }
985
+ );
986
+ return { results, details, stats };
987
+ }
988
+ /**
989
+ * Check if a file has lint errors
990
+ * @param filePath - Path to the file to check
991
+ * @returns true if there are no errors, false otherwise
992
+ */
993
+ async hasNoLintErrors(filePath) {
994
+ try {
995
+ const { results } = await this.lintFile(filePath);
996
+ return results.every((result) => result.errorCount === 0);
997
+ } catch (error) {
998
+ return false;
999
+ }
1000
+ }
1001
+ /**
1002
+ * Get only error messages (excluding warnings)
1003
+ * @param filePath - Path to the file to lint
1004
+ * @returns Array of error messages
1005
+ */
1006
+ async getErrors(filePath) {
1007
+ const { results } = await this.lintFile(filePath);
1008
+ return results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
1009
+ }
1010
+ /**
1011
+ * Get only warning messages
1012
+ * @param filePath - Path to the file to lint
1013
+ * @returns Array of warning messages
1014
+ */
1015
+ async getWarnings(filePath) {
1016
+ const { results } = await this.lintFile(filePath);
1017
+ return results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
1018
+ }
1019
+ /**
1020
+ * Fix lint errors automatically
1021
+ * @param filePath - Path to the file to fix
1022
+ * @param dryRun - If true, returns the fixed content without writing to file
1023
+ * @returns Fixed content and remaining issues
1024
+ */
1025
+ async fixFile(filePath, dryRun = false) {
1026
+ if (!fs5.existsSync(filePath))
1027
+ throw new Error(`File not found: ${filePath}`);
1028
+ const eslint = new ESLint({ cwd: this.lintRoot, fix: true });
1029
+ const results = await eslint.lintFiles([filePath]);
1030
+ const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
1031
+ const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
1032
+ if (!dryRun)
1033
+ await ESLint.outputFixes(results);
1034
+ const fixedResult = results[0];
1035
+ return { fixed: fixedResult.output !== void 0, output: fixedResult.output, results, errors, warnings };
1036
+ }
1037
+ /**
1038
+ * Get ESLint configuration for a file
1039
+ * @param filePath - Path to the file
1040
+ * @returns ESLint configuration object
1041
+ */
1042
+ async getConfigForFile(filePath) {
1043
+ const eslint = new ESLint();
1044
+ const config = await eslint.calculateConfigForFile(filePath);
1045
+ return config;
1046
+ }
1047
+ /**
1048
+ * Get rules that are causing errors in a file
1049
+ * @param filePath - Path to the file to check
1050
+ * @returns Object mapping rule IDs to their error counts
1051
+ */
1052
+ async getProblematicRules(filePath) {
1053
+ const { results } = await this.lintFile(filePath);
1054
+ const ruleCounts = {};
1055
+ results.forEach((result) => {
1056
+ result.messages.forEach((message) => {
1057
+ if (message.ruleId)
1058
+ ruleCounts[message.ruleId] = (ruleCounts[message.ruleId] || 0) + 1;
1059
+ });
1060
+ });
1061
+ return ruleCounts;
1062
+ }
1063
+ };
1064
+
1065
+ // pkgs/@akanjs/devkit/src/scanInfo.ts
1066
+ import path5 from "path";
1067
+
1068
+ // pkgs/@akanjs/devkit/src/dependencyScanner.ts
1069
+ import * as fs6 from "fs";
1070
+ import * as path4 from "path";
893
1071
  import * as ts2 from "typescript";
894
1072
  var TypeScriptDependencyScanner = class {
895
- constructor(directory) {
896
- this.directory = directory;
897
- }
898
1073
  #fileDependencies = /* @__PURE__ */ new Map();
899
1074
  #visitedFiles = /* @__PURE__ */ new Set();
1075
+ directory;
1076
+ tsconfig;
1077
+ rootPackageJson;
1078
+ constructor(directory, { tsconfig, rootPackageJson }) {
1079
+ this.directory = directory;
1080
+ this.tsconfig = tsconfig;
1081
+ this.rootPackageJson = rootPackageJson;
1082
+ }
1083
+ async getMonorepoDependencies(projectName) {
1084
+ const npmSet = new Set(
1085
+ Object.keys({ ...this.rootPackageJson.dependencies, ...this.rootPackageJson.devDependencies })
1086
+ );
1087
+ const pkgPathSet = new Set(
1088
+ Object.keys(this.tsconfig.compilerOptions.paths ?? {}).filter((path10) => this.tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
1089
+ );
1090
+ const libPathSet = new Set(
1091
+ Object.keys(this.tsconfig.compilerOptions.paths ?? {}).filter((path10) => this.tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("libs/"))).map((path10) => path10.replace("/*", ""))
1092
+ );
1093
+ const [npmDepSet, pkgPathDepSet, libPathDepSet] = await this.getImportSets([npmSet, pkgPathSet, libPathSet]);
1094
+ const pkgDeps = [...pkgPathDepSet].map((path10) => {
1095
+ const pathSplitLength = path10.split("/").length;
1096
+ return (this.tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1097
+ });
1098
+ const libDeps = [...libPathDepSet].map((path10) => {
1099
+ const pathSplitLength = path10.split("/").length;
1100
+ return (this.tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1101
+ }).filter((libName) => libName !== projectName);
1102
+ return { pkgDeps, libDeps, npmDeps: [...npmDepSet] };
1103
+ }
900
1104
  async getImportSets(depSets) {
901
1105
  const fileDependencies = await this.getDependencies();
902
1106
  const importedDepSets = new Array(depSets.length);
@@ -933,9 +1137,9 @@ var TypeScriptDependencyScanner = class {
933
1137
  async #findTypeScriptFiles(directory) {
934
1138
  const files = [];
935
1139
  const processDirectory = async (dir) => {
936
- const entries = await fs5.promises.readdir(dir, { withFileTypes: true });
1140
+ const entries = await fs6.promises.readdir(dir, { withFileTypes: true });
937
1141
  for (const entry of entries) {
938
- const fullPath = path2.join(dir, entry.name);
1142
+ const fullPath = path4.join(dir, entry.name);
939
1143
  if (entry.isDirectory()) {
940
1144
  if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
941
1145
  await processDirectory(fullPath);
@@ -951,26 +1155,26 @@ var TypeScriptDependencyScanner = class {
951
1155
  return;
952
1156
  this.#visitedFiles.add(filePath);
953
1157
  try {
954
- const fileContent = await fs5.promises.readFile(filePath, "utf-8");
1158
+ const fileContent = await fs6.promises.readFile(filePath, "utf-8");
955
1159
  const imports = this.#extractImports(fileContent, filePath);
956
1160
  const resolvedImports = imports.map((importPath) => {
957
1161
  if (importPath.startsWith(".")) {
958
- const resolvedPath = "./" + path2.join(path2.relative(baseDir, filePath), importPath);
1162
+ const resolvedPath = "./" + path4.join(path4.relative(baseDir, filePath), importPath);
959
1163
  return this.#ensureExtension(resolvedPath);
960
1164
  }
961
1165
  return importPath;
962
1166
  });
963
- const relativePath = path2.relative(baseDir, filePath);
1167
+ const relativePath = path4.relative(baseDir, filePath);
964
1168
  this.#fileDependencies.set(relativePath, resolvedImports);
965
1169
  } catch (error) {
966
1170
  }
967
1171
  }
968
1172
  #ensureExtension(filePath) {
969
- if (fs5.existsSync(`${filePath}.ts`))
1173
+ if (fs6.existsSync(`${filePath}.ts`))
970
1174
  return `${filePath}.ts`;
971
- else if (fs5.existsSync(`${filePath}.tsx`))
1175
+ else if (fs6.existsSync(`${filePath}.tsx`))
972
1176
  return `${filePath}.tsx`;
973
- else if (fs5.existsSync(filePath))
1177
+ else if (fs6.existsSync(filePath))
974
1178
  return filePath;
975
1179
  return `${filePath}.ts`;
976
1180
  }
@@ -1034,217 +1238,442 @@ var TypeScriptDependencyScanner = class {
1034
1238
  }
1035
1239
  };
1036
1240
 
1037
- // pkgs/@akanjs/devkit/src/getDirname.ts
1038
- import path3 from "path";
1039
- var getDirname = (url) => path3.dirname(new URL(url).pathname);
1040
-
1041
- // pkgs/@akanjs/devkit/src/linter.ts
1042
- import chalk from "chalk";
1043
- import { ESLint } from "eslint";
1044
- import * as fs6 from "fs";
1045
- import * as path4 from "path";
1046
- var Linter = class {
1047
- #logger = new Logger("Linter");
1048
- #eslint;
1049
- lintRoot;
1050
- constructor(cwdPath) {
1051
- this.lintRoot = this.#findEslintRootPath(cwdPath);
1052
- this.#eslint = new ESLint({ cwd: this.lintRoot, errorOnUnmatchedPattern: false });
1053
- }
1054
- #findEslintRootPath(dir) {
1055
- const configPath2 = path4.join(dir, "eslint.config.ts");
1056
- if (fs6.existsSync(configPath2))
1057
- return dir;
1058
- const parentDir = path4.dirname(dir);
1059
- return this.#findEslintRootPath(parentDir);
1060
- }
1061
- async lint(filePath, { fix = false, dryRun = false } = {}) {
1062
- if (fix)
1063
- return await this.fixFile(filePath, dryRun);
1064
- return await this.lintFile(filePath);
1065
- }
1066
- /**
1067
- * Lint a single file using ESLint
1068
- * @param filePath - Path to the file to lint
1069
- * @returns Array of ESLint results
1070
- */
1071
- async lintFile(filePath) {
1072
- if (!fs6.existsSync(filePath))
1073
- throw new Error(`File not found: ${filePath}`);
1074
- const isIgnored = await this.#eslint.isPathIgnored(filePath);
1075
- if (isIgnored) {
1076
- this.#logger.warn(`File ${filePath} is ignored by ESLint configuration`);
1077
- return { fixed: false, results: [], errors: [], warnings: [] };
1078
- }
1079
- const results = await this.#eslint.lintFiles([filePath]);
1080
- const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
1081
- const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
1082
- return { fixed: false, results, errors, warnings };
1083
- }
1084
- /**
1085
- * Format lint results for console output
1086
- * @param results - Array of ESLint results
1087
- * @returns Formatted string
1088
- */
1089
- formatLintResults(results) {
1090
- if (results.length === 0)
1091
- return "No files to lint";
1092
- const output = [];
1093
- let totalErrors = 0;
1094
- let totalWarnings = 0;
1095
- results.forEach((result) => {
1096
- totalErrors += result.errorCount;
1097
- totalWarnings += result.warningCount;
1098
- if (result.messages.length > 0) {
1099
- output.push(`
1100
- ${chalk.cyan(result.filePath)}`);
1101
- let sourceLines = [];
1102
- if (fs6.existsSync(result.filePath)) {
1103
- try {
1104
- const sourceContent = fs6.readFileSync(result.filePath, "utf8");
1105
- sourceLines = sourceContent.split("\n");
1106
- } catch (error) {
1107
- }
1108
- }
1109
- result.messages.forEach((message) => {
1110
- const type = message.severity === 2 ? "error" : "warning";
1111
- const typeColor = message.severity === 2 ? chalk.red : chalk.yellow;
1112
- const icon = message.severity === 2 ? "\u274C" : "\u26A0\uFE0F";
1113
- const ruleInfo = message.ruleId ? chalk.dim(` (${message.ruleId})`) : "";
1114
- output.push(`
1115
- ${icon} ${typeColor(type)}: ${message.message}${ruleInfo}`);
1116
- output.push(` ${chalk.gray("at")} ${result.filePath}:${chalk.bold(`${message.line}:${message.column}`)}`);
1117
- if (sourceLines.length > 0 && message.line <= sourceLines.length) {
1118
- const sourceLine = sourceLines[message.line - 1];
1119
- const lineNumber = message.line.toString().padStart(5, " ");
1120
- output.push(`
1121
- ${chalk.dim(lineNumber + " |")} ${sourceLine}`);
1122
- const underlinePrefix = " ".repeat(message.column - 1);
1123
- const underlineLength = message.endColumn ? message.endColumn - message.column : 1;
1124
- const underline = "^".repeat(Math.max(1, underlineLength));
1125
- output.push(`${chalk.dim(" ".repeat(lineNumber.length) + " |")} ${underlinePrefix}${typeColor(underline)}`);
1126
- }
1127
- });
1128
- }
1241
+ // pkgs/@akanjs/devkit/src/scanInfo.ts
1242
+ var databaseFileTypes = [
1243
+ "constant",
1244
+ "dictionary",
1245
+ "document",
1246
+ "service",
1247
+ "signal",
1248
+ "store",
1249
+ "template",
1250
+ "unit",
1251
+ "util",
1252
+ "view",
1253
+ "zone"
1254
+ ];
1255
+ var ScanInfo = class {
1256
+ scanResult;
1257
+ name;
1258
+ scalar = /* @__PURE__ */ new Map();
1259
+ service = /* @__PURE__ */ new Map();
1260
+ database = /* @__PURE__ */ new Map();
1261
+ file = Object.fromEntries(
1262
+ databaseFileTypes.map((type) => [
1263
+ type,
1264
+ { all: /* @__PURE__ */ new Set(), databases: /* @__PURE__ */ new Set(), services: /* @__PURE__ */ new Set(), scalars: /* @__PURE__ */ new Set() }
1265
+ ])
1266
+ );
1267
+ constants = /* @__PURE__ */ new Set();
1268
+ dictionaries = /* @__PURE__ */ new Set();
1269
+ documents = /* @__PURE__ */ new Set();
1270
+ services = /* @__PURE__ */ new Set();
1271
+ signals = /* @__PURE__ */ new Set();
1272
+ stores = /* @__PURE__ */ new Set();
1273
+ templates = /* @__PURE__ */ new Set();
1274
+ units = /* @__PURE__ */ new Set();
1275
+ utils = /* @__PURE__ */ new Set();
1276
+ views = /* @__PURE__ */ new Set();
1277
+ zones = /* @__PURE__ */ new Set();
1278
+ static async getScanResult(exec2) {
1279
+ const akanConfig = await exec2.getConfig();
1280
+ const tsconfig = exec2.getTsConfig();
1281
+ const rootPackageJson = exec2.workspace.getPackageJson();
1282
+ const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
1283
+ const { pkgDeps, libDeps, npmDeps } = await scanner.getMonorepoDependencies(exec2.name);
1284
+ const files = {
1285
+ constant: { databases: [], scalars: [] },
1286
+ dictionary: { databases: [], services: [], scalars: [] },
1287
+ document: { databases: [], scalars: [] },
1288
+ service: { databases: [], services: [] },
1289
+ signal: { databases: [], services: [] },
1290
+ store: { databases: [], services: [] },
1291
+ template: { databases: [], services: [], scalars: [] },
1292
+ unit: { databases: [], services: [], scalars: [] },
1293
+ util: { databases: [], services: [], scalars: [] },
1294
+ view: { databases: [], services: [], scalars: [] },
1295
+ zone: { databases: [], services: [], scalars: [] }
1296
+ };
1297
+ const [{ dirs: dirnames }, scalarDirs] = await Promise.all([
1298
+ exec2.getFilesAndDirs("lib"),
1299
+ exec2.readdir("lib/__scalar")
1300
+ ]);
1301
+ const databaseDirs = [];
1302
+ const serviceDirs = [];
1303
+ dirnames.forEach((name) => {
1304
+ if (name.startsWith("_")) {
1305
+ if (name.startsWith("__"))
1306
+ return;
1307
+ else
1308
+ serviceDirs.push(name);
1309
+ } else
1310
+ databaseDirs.push(name);
1129
1311
  });
1130
- if (totalErrors === 0 && totalWarnings === 0)
1131
- return chalk.bold("\u2705 No ESLint errors or warnings found");
1132
- const errorText = totalErrors > 0 ? chalk.red(`${totalErrors} error(s)`) : "0 errors";
1133
- const warningText = totalWarnings > 0 ? chalk.yellow(`${totalWarnings} warning(s)`) : "0 warnings";
1134
- const summary = [`
1135
- ${errorText}, ${warningText} found`];
1136
- return summary.concat(output).join("\n");
1137
- }
1138
- /**
1139
- * Get detailed lint information
1140
- * @param filePath - Path to the file to lint
1141
- * @returns Object containing detailed lint information
1142
- */
1143
- async getDetailedLintInfo(filePath) {
1144
- const { results } = await this.lintFile(filePath);
1145
- const details = results.flatMap(
1146
- (result) => result.messages.map((message) => ({
1147
- line: message.line,
1148
- column: message.column,
1149
- message: message.message,
1150
- ruleId: message.ruleId,
1151
- severity: message.severity === 2 ? "error" : "warning",
1152
- fix: message.fix,
1153
- suggestions: message.suggestions
1154
- }))
1155
- );
1156
- const stats = results.reduce(
1157
- (acc, result) => ({
1158
- errorCount: acc.errorCount + result.errorCount,
1159
- warningCount: acc.warningCount + result.warningCount,
1160
- fixableErrorCount: acc.fixableErrorCount + result.fixableErrorCount,
1161
- fixableWarningCount: acc.fixableWarningCount + result.fixableWarningCount
1312
+ await Promise.all([
1313
+ ...databaseDirs.map(async (name) => {
1314
+ const filenames = await exec2.readdir(path5.join("lib", name));
1315
+ filenames.forEach((filename) => {
1316
+ if (filename.endsWith(".constant.ts"))
1317
+ files.constant.databases.push(name);
1318
+ else if (filename.endsWith(".dictionary.ts"))
1319
+ files.dictionary.databases.push(name);
1320
+ else if (filename.endsWith(".document.ts"))
1321
+ files.document.databases.push(name);
1322
+ else if (filename.endsWith(".service.ts"))
1323
+ files.service.databases.push(name);
1324
+ else if (filename.endsWith(".signal.ts"))
1325
+ files.signal.databases.push(name);
1326
+ else if (filename.endsWith(".store.ts"))
1327
+ files.store.databases.push(name);
1328
+ else if (filename.endsWith(".Template.tsx"))
1329
+ files.template.databases.push(name);
1330
+ else if (filename.endsWith(".Unit.tsx"))
1331
+ files.unit.databases.push(name);
1332
+ else if (filename.endsWith(".Util.tsx"))
1333
+ files.util.databases.push(name);
1334
+ else if (filename.endsWith(".View.tsx"))
1335
+ files.view.databases.push(name);
1336
+ else if (filename.endsWith(".Zone.tsx"))
1337
+ files.zone.databases.push(name);
1338
+ });
1162
1339
  }),
1163
- { errorCount: 0, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0 }
1340
+ ...serviceDirs.map(async (dirname3) => {
1341
+ const name = dirname3.slice(1);
1342
+ const filenames = await exec2.readdir(path5.join("lib", dirname3));
1343
+ filenames.forEach((filename) => {
1344
+ if (filename.endsWith(".dictionary.ts"))
1345
+ files.dictionary.services.push(name);
1346
+ else if (filename.endsWith(".service.ts"))
1347
+ files.service.services.push(name);
1348
+ else if (filename.endsWith(".signal.ts"))
1349
+ files.signal.services.push(name);
1350
+ else if (filename.endsWith(".store.ts"))
1351
+ files.store.services.push(name);
1352
+ else if (filename.endsWith(".Template.tsx"))
1353
+ files.template.services.push(name);
1354
+ else if (filename.endsWith(".Unit.tsx"))
1355
+ files.unit.services.push(name);
1356
+ else if (filename.endsWith(".Util.tsx"))
1357
+ files.util.services.push(name);
1358
+ else if (filename.endsWith(".View.tsx"))
1359
+ files.view.services.push(name);
1360
+ else if (filename.endsWith(".Zone.tsx"))
1361
+ files.zone.services.push(name);
1362
+ });
1363
+ }),
1364
+ ...scalarDirs.map(async (name) => {
1365
+ const filenames = await exec2.readdir(path5.join("lib/__scalar", name));
1366
+ filenames.forEach((filename) => {
1367
+ if (filename.endsWith(".constant.ts"))
1368
+ files.constant.scalars.push(name);
1369
+ else if (filename.endsWith(".dictionary.ts"))
1370
+ files.dictionary.scalars.push(name);
1371
+ else if (filename.endsWith(".document.ts"))
1372
+ files.document.scalars.push(name);
1373
+ else if (filename.endsWith(".Template.tsx"))
1374
+ files.template.scalars.push(name);
1375
+ else if (filename.endsWith(".Unit.tsx"))
1376
+ files.unit.scalars.push(name);
1377
+ else if (filename.endsWith(".Util.tsx"))
1378
+ files.util.scalars.push(name);
1379
+ else if (filename.endsWith(".View.tsx"))
1380
+ files.view.scalars.push(name);
1381
+ else if (filename.endsWith(".Zone.tsx"))
1382
+ files.zone.scalars.push(name);
1383
+ });
1384
+ })
1385
+ ]);
1386
+ const missingLibDeps = [];
1387
+ libDeps.forEach((libName) => {
1388
+ if (!akanConfig.libs.includes(libName))
1389
+ missingLibDeps.push(libName);
1390
+ });
1391
+ if (missingLibDeps.length)
1392
+ throw new Error(
1393
+ `Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
1394
+ );
1395
+ const scanResult = {
1396
+ name: exec2.name,
1397
+ type: exec2.type,
1398
+ repoName: exec2.workspace.repoName,
1399
+ serveDomain: exec2.workspace.getBaseDevEnv().serveDomain,
1400
+ akanConfig,
1401
+ files,
1402
+ libDeps,
1403
+ pkgDeps,
1404
+ dependencies: npmDeps.filter((dep) => !dep.startsWith("@akanjs"))
1405
+ };
1406
+ return scanResult;
1407
+ }
1408
+ constructor(scanResult) {
1409
+ this.name = scanResult.name;
1410
+ this.scanResult = scanResult;
1411
+ Object.entries(scanResult.files).forEach(
1412
+ ([key, value]) => {
1413
+ const { databases, services, scalars } = value;
1414
+ databases.forEach((modelName) => {
1415
+ const model = this.database.get(modelName) ?? /* @__PURE__ */ new Set();
1416
+ model.add(key);
1417
+ this.database.set(modelName, model);
1418
+ this.file[key].all.add(modelName);
1419
+ this.file[key].databases.add(modelName);
1420
+ });
1421
+ services?.forEach((serviceName) => {
1422
+ const service = this.service.get(serviceName) ?? /* @__PURE__ */ new Set();
1423
+ service.add(key);
1424
+ this.service.set(serviceName, service);
1425
+ this.file[key].all.add(serviceName);
1426
+ this.file[key].services.add(serviceName);
1427
+ });
1428
+ scalars?.forEach((scalarName) => {
1429
+ const scalar = this.scalar.get(scalarName) ?? /* @__PURE__ */ new Set();
1430
+ scalar.add(key);
1431
+ this.scalar.set(scalarName, scalar);
1432
+ this.file[key].all.add(scalarName);
1433
+ this.file[key].scalars.add(scalarName);
1434
+ });
1435
+ }
1164
1436
  );
1165
- return { results, details, stats };
1166
1437
  }
1167
- /**
1168
- * Check if a file has lint errors
1169
- * @param filePath - Path to the file to check
1170
- * @returns true if there are no errors, false otherwise
1171
- */
1172
- async hasNoLintErrors(filePath) {
1173
- try {
1174
- const { results } = await this.lintFile(filePath);
1175
- return results.every((result) => result.errorCount === 0);
1176
- } catch (error) {
1177
- return false;
1178
- }
1438
+ getScanResult() {
1439
+ return this.scanResult;
1179
1440
  }
1180
- /**
1181
- * Get only error messages (excluding warnings)
1182
- * @param filePath - Path to the file to lint
1183
- * @returns Array of error messages
1184
- */
1185
- async getErrors(filePath) {
1186
- const { results } = await this.lintFile(filePath);
1187
- return results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
1441
+ getDatabaseModules() {
1442
+ return [...this.database.keys()];
1188
1443
  }
1189
- /**
1190
- * Get only warning messages
1191
- * @param filePath - Path to the file to lint
1192
- * @returns Array of warning messages
1193
- */
1194
- async getWarnings(filePath) {
1195
- const { results } = await this.lintFile(filePath);
1196
- return results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
1444
+ getServiceModules() {
1445
+ return [...this.service.keys()];
1197
1446
  }
1198
- /**
1199
- * Fix lint errors automatically
1200
- * @param filePath - Path to the file to fix
1201
- * @param dryRun - If true, returns the fixed content without writing to file
1202
- * @returns Fixed content and remaining issues
1203
- */
1204
- async fixFile(filePath, dryRun = false) {
1205
- if (!fs6.existsSync(filePath))
1206
- throw new Error(`File not found: ${filePath}`);
1207
- const eslint = new ESLint({ cwd: this.lintRoot, fix: true });
1208
- const results = await eslint.lintFiles([filePath]);
1209
- const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
1210
- const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
1211
- if (!dryRun)
1212
- await ESLint.outputFixes(results);
1213
- const fixedResult = results[0];
1214
- return { fixed: fixedResult.output !== void 0, output: fixedResult.output, results, errors, warnings };
1447
+ getScalarModules() {
1448
+ return [...this.scalar.keys()];
1215
1449
  }
1216
- /**
1217
- * Get ESLint configuration for a file
1218
- * @param filePath - Path to the file
1219
- * @returns ESLint configuration object
1220
- */
1221
- async getConfigForFile(filePath) {
1222
- const eslint = new ESLint();
1223
- const config = await eslint.calculateConfigForFile(filePath);
1224
- return config;
1450
+ };
1451
+ var AppInfo = class _AppInfo extends ScanInfo {
1452
+ type = "app";
1453
+ exec;
1454
+ akanConfig;
1455
+ static appInfos = /* @__PURE__ */ new Map();
1456
+ static async fromExecutor(exec2, options = {}) {
1457
+ const existingAppInfo = this.appInfos.get(exec2.name);
1458
+ if (existingAppInfo && !options.refresh)
1459
+ return existingAppInfo;
1460
+ const scanResult = await super.getScanResult(exec2);
1461
+ await Promise.all(
1462
+ scanResult.libDeps.map(async (libName) => {
1463
+ LibInfo.loadedLibs.add(libName);
1464
+ const libExecutor = LibExecutor.from(exec2, libName);
1465
+ LibInfo.libInfos.set(libName, await LibInfo.fromExecutor(libExecutor));
1466
+ })
1467
+ );
1468
+ const appInfo = new _AppInfo(exec2, scanResult);
1469
+ this.appInfos.set(exec2.name, appInfo);
1470
+ return appInfo;
1471
+ }
1472
+ constructor(exec2, scanResult) {
1473
+ super(scanResult);
1474
+ this.exec = exec2;
1475
+ this.akanConfig = scanResult.akanConfig;
1476
+ }
1477
+ getScanResult() {
1478
+ return this.scanResult;
1479
+ }
1480
+ #sortedLibs = null;
1481
+ #getSortedLibs() {
1482
+ if (this.#sortedLibs)
1483
+ return this.#sortedLibs;
1484
+ const libIndices = LibInfo.getSortedLibIndices();
1485
+ this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
1486
+ const indexA = libIndices.get(libNameA);
1487
+ const indexB = libIndices.get(libNameB);
1488
+ if (indexA === void 0 || indexB === void 0)
1489
+ throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
1490
+ return indexA - indexB;
1491
+ });
1492
+ return this.#sortedLibs;
1493
+ }
1494
+ getLibs() {
1495
+ return this.#getSortedLibs();
1496
+ }
1497
+ getLibInfo(libName) {
1498
+ const libSet = new Set(this.#getSortedLibs());
1499
+ if (!libSet.has(libName))
1500
+ throw new Error(`LibInfo is invalid: ${libName}`);
1501
+ return LibInfo.libInfos.get(libName);
1502
+ }
1503
+ getLibInfos() {
1504
+ return new Map(
1505
+ this.#getSortedLibs().map((libName) => {
1506
+ const libInfo = LibInfo.libInfos.get(libName);
1507
+ if (!libInfo)
1508
+ throw new Error(`LibInfo not found: ${libName}`);
1509
+ return [libName, libInfo];
1510
+ })
1511
+ );
1225
1512
  }
1226
- /**
1227
- * Get rules that are causing errors in a file
1228
- * @param filePath - Path to the file to check
1229
- * @returns Object mapping rule IDs to their error counts
1230
- */
1231
- async getProblematicRules(filePath) {
1232
- const { results } = await this.lintFile(filePath);
1233
- const ruleCounts = {};
1234
- results.forEach((result) => {
1235
- result.messages.forEach((message) => {
1236
- if (message.ruleId)
1237
- ruleCounts[message.ruleId] = (ruleCounts[message.ruleId] || 0) + 1;
1238
- });
1513
+ };
1514
+ var LibInfo = class _LibInfo extends ScanInfo {
1515
+ type = "lib";
1516
+ exec;
1517
+ akanConfig;
1518
+ static loadedLibs = /* @__PURE__ */ new Set();
1519
+ static libInfos = /* @__PURE__ */ new Map();
1520
+ static #sortedLibIndices = null;
1521
+ static getSortedLibIndices() {
1522
+ if (this.#sortedLibIndices)
1523
+ return this.#sortedLibIndices;
1524
+ this.#sortedLibIndices = new Map(
1525
+ [...this.libInfos.entries()].sort(([_, libInfoA], [__, libInfoB]) => libInfoA.akanConfig.libs.includes(libInfoB.name) ? 1 : -1).map(([libName], index) => [libName, index])
1526
+ );
1527
+ return this.#sortedLibIndices;
1528
+ }
1529
+ static async fromExecutor(exec2, { refresh } = {}) {
1530
+ const existingLibInfo = this.libInfos.get(exec2.name);
1531
+ if (existingLibInfo && !refresh)
1532
+ return existingLibInfo;
1533
+ const scanResult = await super.getScanResult(exec2);
1534
+ await Promise.all(
1535
+ scanResult.libDeps.filter((libName) => !this.loadedLibs.has(libName)).map(async (libName) => {
1536
+ this.loadedLibs.add(libName);
1537
+ this.libInfos.set(libName, await _LibInfo.fromExecutor(exec2));
1538
+ })
1539
+ );
1540
+ const libInfo = new _LibInfo(exec2, scanResult);
1541
+ this.libInfos.set(exec2.name, libInfo);
1542
+ this.#sortedLibIndices = null;
1543
+ return libInfo;
1544
+ }
1545
+ constructor(exec2, scanResult) {
1546
+ super(scanResult);
1547
+ this.exec = exec2;
1548
+ this.akanConfig = scanResult.akanConfig;
1549
+ }
1550
+ getScanResult() {
1551
+ return this.scanResult;
1552
+ }
1553
+ #sortedLibs = null;
1554
+ #getSortedLibs() {
1555
+ if (this.#sortedLibs)
1556
+ return this.#sortedLibs;
1557
+ const libs = _LibInfo.getSortedLibIndices();
1558
+ this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
1559
+ const indexA = libs.get(libNameA);
1560
+ const indexB = libs.get(libNameB);
1561
+ if (indexA === void 0 || indexB === void 0)
1562
+ throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
1563
+ return indexA - indexB;
1239
1564
  });
1240
- return ruleCounts;
1565
+ return this.#sortedLibs;
1566
+ }
1567
+ getLibs() {
1568
+ return this.#getSortedLibs();
1569
+ }
1570
+ getLibInfo(libName) {
1571
+ if (!this.getScanResult().akanConfig.libs.includes(libName))
1572
+ return void 0;
1573
+ const libSet = new Set(this.#getSortedLibs());
1574
+ if (!libSet.has(libName))
1575
+ throw new Error(`LibInfo is invalid: ${libName}`);
1576
+ return _LibInfo.libInfos.get(libName);
1577
+ }
1578
+ getLibInfos() {
1579
+ return new Map(
1580
+ this.#getSortedLibs().map((libName) => {
1581
+ const libInfo = _LibInfo.libInfos.get(libName);
1582
+ if (!libInfo)
1583
+ throw new Error(`LibInfo not found: ${libName}`);
1584
+ return [libName, libInfo];
1585
+ })
1586
+ );
1587
+ }
1588
+ };
1589
+ var PkgInfo = class _PkgInfo {
1590
+ exec;
1591
+ name;
1592
+ scanResult;
1593
+ static async getScanResult(exec2) {
1594
+ const tsconfig = exec2.getTsConfig();
1595
+ const rootPackageJson = exec2.workspace.getPackageJson();
1596
+ const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
1597
+ const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
1598
+ const pkgPathSet = new Set(
1599
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
1600
+ );
1601
+ const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
1602
+ const pkgDeps = [...pkgPathDepSet].map((path10) => {
1603
+ const pathSplitLength = path10.split("/").length;
1604
+ return (tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1605
+ }).filter((pkg) => pkg !== this.name);
1606
+ const pkgScanResult = {
1607
+ name: this.name,
1608
+ pkgDeps,
1609
+ dependencies: [...npmDepSet]
1610
+ };
1611
+ return pkgScanResult;
1612
+ }
1613
+ static #pkgInfos = /* @__PURE__ */ new Map();
1614
+ static async fromExecutor(exec2, options = {}) {
1615
+ const existingPkgInfo = this.#pkgInfos.get(exec2.name);
1616
+ if (existingPkgInfo && !options.refresh)
1617
+ return existingPkgInfo;
1618
+ const scanResult = await this.getScanResult(exec2);
1619
+ const pkgInfo = new _PkgInfo(exec2, scanResult);
1620
+ this.#pkgInfos.set(exec2.name, pkgInfo);
1621
+ return pkgInfo;
1622
+ }
1623
+ constructor(exec2, scanResult) {
1624
+ this.exec = exec2;
1625
+ this.name = exec2.name;
1626
+ this.scanResult = scanResult;
1627
+ }
1628
+ getScanResult() {
1629
+ return this.scanResult;
1630
+ }
1631
+ };
1632
+ var WorkspaceInfo = class _WorkspaceInfo {
1633
+ constructor(appInfos = /* @__PURE__ */ new Map(), libInfos = /* @__PURE__ */ new Map(), pkgInfos = /* @__PURE__ */ new Map()) {
1634
+ this.appInfos = appInfos;
1635
+ this.libInfos = libInfos;
1636
+ this.pkgInfos = pkgInfos;
1637
+ }
1638
+ static #workspaceInfos = /* @__PURE__ */ new Map();
1639
+ static async fromExecutor(exec2, options = {}) {
1640
+ const existingWorkspaceInfo = this.#workspaceInfos.get(exec2.name);
1641
+ if (existingWorkspaceInfo && !options.refresh)
1642
+ return existingWorkspaceInfo;
1643
+ const [appNames, libNames, pkgNames] = await Promise.all([exec2.getApps(), exec2.getLibs(), exec2.getPkgs()]);
1644
+ const [appInfos, libInfos, pkgInfos] = await Promise.all([
1645
+ Promise.all(
1646
+ appNames.map(async (appName) => {
1647
+ const app = AppExecutor.from(exec2, appName);
1648
+ return await app.scan();
1649
+ })
1650
+ ),
1651
+ Promise.all(
1652
+ libNames.map(async (libName) => {
1653
+ const lib = LibExecutor.from(exec2, libName);
1654
+ return await lib.scan();
1655
+ })
1656
+ ),
1657
+ Promise.all(
1658
+ pkgNames.map(async (pkgName) => {
1659
+ return await PkgExecutor.from(exec2, pkgName).scan();
1660
+ })
1661
+ )
1662
+ ]);
1663
+ const workspaceInfo = new _WorkspaceInfo(
1664
+ new Map(appInfos.map((app) => [app.exec.name, app])),
1665
+ new Map(libInfos.map((lib) => [lib.exec.name, lib])),
1666
+ new Map(pkgInfos.map((pkg) => [pkg.exec.name, pkg]))
1667
+ );
1668
+ this.#workspaceInfos.set(exec2.name, workspaceInfo);
1669
+ return workspaceInfo;
1241
1670
  }
1242
1671
  };
1243
1672
 
1244
1673
  // pkgs/@akanjs/devkit/src/typeChecker.ts
1245
1674
  import chalk2 from "chalk";
1246
1675
  import * as fs7 from "fs";
1247
- import * as path5 from "path";
1676
+ import * as path6 from "path";
1248
1677
  import * as ts3 from "typescript";
1249
1678
  var TypeChecker = class {
1250
1679
  configPath;
@@ -1259,7 +1688,7 @@ var TypeChecker = class {
1259
1688
  const parsedConfig = ts3.parseJsonConfigFileContent(
1260
1689
  this.configFile.config,
1261
1690
  ts3.sys,
1262
- path5.dirname(this.configPath),
1691
+ path6.dirname(this.configPath),
1263
1692
  void 0,
1264
1693
  this.configPath
1265
1694
  );
@@ -1525,7 +1954,7 @@ var Executor = class _Executor {
1525
1954
  });
1526
1955
  }
1527
1956
  getPath(filePath) {
1528
- if (path6.isAbsolute(filePath))
1957
+ if (path7.isAbsolute(filePath))
1529
1958
  return filePath;
1530
1959
  const baseParts = this.cwdPath.split("/").filter(Boolean);
1531
1960
  const targetParts = filePath.split("/").filter(Boolean);
@@ -1558,6 +1987,22 @@ var Executor = class _Executor {
1558
1987
  return [];
1559
1988
  }
1560
1989
  }
1990
+ async getFilesAndDirs(dirPath) {
1991
+ const paths = await this.readdir(dirPath);
1992
+ const files = [];
1993
+ const dirs = [];
1994
+ const fullDirPath = this.getPath(dirPath);
1995
+ await Promise.all(
1996
+ paths.map(async (p) => {
1997
+ const stats = await fsPromise.stat(path7.join(fullDirPath, p));
1998
+ if (stats.isDirectory())
1999
+ dirs.push(p);
2000
+ else
2001
+ files.push(p);
2002
+ })
2003
+ );
2004
+ return { files, dirs };
2005
+ }
1561
2006
  exists(filePath) {
1562
2007
  const readPath = this.getPath(filePath);
1563
2008
  return fs8.existsSync(readPath);
@@ -1578,7 +2023,7 @@ var Executor = class _Executor {
1578
2023
  }
1579
2024
  writeFile(filePath, content, { overwrite = true } = {}) {
1580
2025
  const writePath = this.getPath(filePath);
1581
- const dir = path6.dirname(writePath);
2026
+ const dir = path7.dirname(writePath);
1582
2027
  if (!fs8.existsSync(dir))
1583
2028
  fs8.mkdirSync(dir, { recursive: true });
1584
2029
  let contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
@@ -1589,11 +2034,12 @@ var Executor = class _Executor {
1589
2034
  contentStr = fs8.readFileSync(writePath, "utf-8");
1590
2035
  } else {
1591
2036
  fs8.writeFileSync(writePath, contentStr, "utf8");
1592
- this.logger.verbose(`File ${writePath} is changed`);
2037
+ if (Logger.isVerbose())
2038
+ this.logger.rawLog(chalk3.yellow(`File Update: ${filePath}`));
1593
2039
  }
1594
2040
  } else {
1595
2041
  fs8.writeFileSync(writePath, contentStr, "utf8");
1596
- this.logger.verbose(`File ${writePath} is created`);
2042
+ this.logger.rawLog(chalk3.green(`File Create: ${filePath}`));
1597
2043
  }
1598
2044
  return { filePath: writePath, content: contentStr };
1599
2045
  }
@@ -1602,7 +2048,7 @@ var Executor = class _Executor {
1602
2048
  return this;
1603
2049
  }
1604
2050
  getLocalFile(targetPath) {
1605
- const filePath = path6.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
2051
+ const filePath = path7.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
1606
2052
  const content = this.readFile(filePath);
1607
2053
  return { filePath, content };
1608
2054
  }
@@ -1630,7 +2076,10 @@ var Executor = class _Executor {
1630
2076
  spinning(msg, { prefix = `${this.emoji}${this.name}`, indent = 0, enableSpin = !_Executor.verbose } = {}) {
1631
2077
  return new Spinner(msg, { prefix, indent, enableSpin }).start();
1632
2078
  }
1633
- getTsConfig(pathname = "tsconfig.json") {
2079
+ #tsconfig = null;
2080
+ getTsConfig(pathname = "tsconfig.json", { refresh } = {}) {
2081
+ if (this.#tsconfig && !refresh)
2082
+ return this.#tsconfig;
1634
2083
  const tsconfig = this.readJson(pathname);
1635
2084
  if (tsconfig.extends) {
1636
2085
  const extendsTsconfig = this.getTsConfig(tsconfig.extends);
@@ -1640,24 +2089,41 @@ var Executor = class _Executor {
1640
2089
  compilerOptions: { ...extendsTsconfig.compilerOptions, ...tsconfig.compilerOptions }
1641
2090
  };
1642
2091
  }
2092
+ this.#tsconfig = tsconfig;
1643
2093
  return tsconfig;
1644
2094
  }
2095
+ setTsConfig(tsconfig) {
2096
+ this.writeJson("tsconfig.json", tsconfig);
2097
+ this.#tsconfig = tsconfig;
2098
+ }
2099
+ #packageJson = null;
2100
+ getPackageJson({ refresh } = {}) {
2101
+ if (this.#packageJson && !refresh)
2102
+ return this.#packageJson;
2103
+ const packageJson = this.readJson("package.json");
2104
+ this.#packageJson = packageJson;
2105
+ return packageJson;
2106
+ }
2107
+ setPackageJson(packageJson) {
2108
+ this.writeJson("package.json", packageJson);
2109
+ this.#packageJson = packageJson;
2110
+ }
1645
2111
  async #applyTemplateFile({
1646
2112
  templatePath,
1647
2113
  targetPath,
1648
- scanResult,
2114
+ scanInfo,
1649
2115
  overwrite = true
1650
2116
  }, dict = {}) {
1651
2117
  if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
1652
2118
  const getContent = await import(templatePath);
1653
- const result = getContent.default(scanResult ?? null, dict);
2119
+ const result = getContent.default(scanInfo ?? null, dict);
1654
2120
  if (result === null)
1655
2121
  return null;
1656
- const filename = typeof result === "object" ? result.filename : path6.basename(targetPath).replace(".js", ".ts");
2122
+ const filename = typeof result === "object" ? result.filename : path7.basename(targetPath).replace(".js", ".ts");
1657
2123
  const content = typeof result === "object" ? result.content : result;
1658
- const dirname3 = path6.dirname(targetPath);
2124
+ const dirname3 = path7.dirname(targetPath);
1659
2125
  const convertedTargetPath = Object.entries(dict).reduce(
1660
- (path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
2126
+ (path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
1661
2127
  `${dirname3}/${filename}`
1662
2128
  );
1663
2129
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
@@ -1665,7 +2131,7 @@ var Executor = class _Executor {
1665
2131
  } else if (targetPath.endsWith(".template")) {
1666
2132
  const content = await fsPromise.readFile(templatePath, "utf8");
1667
2133
  const convertedTargetPath = Object.entries(dict).reduce(
1668
- (path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
2134
+ (path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
1669
2135
  targetPath.slice(0, -9)
1670
2136
  );
1671
2137
  const convertedContent = Object.entries(dict).reduce(
@@ -1680,16 +2146,16 @@ var Executor = class _Executor {
1680
2146
  async _applyTemplate({
1681
2147
  basePath: basePath2,
1682
2148
  template,
1683
- scanResult,
2149
+ scanInfo,
1684
2150
  dict = {},
1685
2151
  overwrite = true
1686
2152
  }) {
1687
2153
  const templatePath = `${getDirname(import.meta.url)}/src/templates${template ? `/${template}` : ""}`;
1688
2154
  const prefixTemplatePath = templatePath.endsWith(".tsx") ? templatePath : templatePath.replace(".ts", ".js");
1689
2155
  if (fs8.statSync(prefixTemplatePath).isFile()) {
1690
- const filename = path6.basename(prefixTemplatePath);
2156
+ const filename = path7.basename(prefixTemplatePath);
1691
2157
  const fileContent = await this.#applyTemplateFile(
1692
- { templatePath: prefixTemplatePath, targetPath: path6.join(basePath2, filename), scanResult, overwrite },
2158
+ { templatePath: prefixTemplatePath, targetPath: path7.join(basePath2, filename), scanInfo, overwrite },
1693
2159
  dict
1694
2160
  );
1695
2161
  return fileContent ? [fileContent] : [];
@@ -1697,18 +2163,18 @@ var Executor = class _Executor {
1697
2163
  const subdirs = await this.readdir(templatePath);
1698
2164
  const fileContents = (await Promise.all(
1699
2165
  subdirs.map(async (subdir) => {
1700
- const subpath = path6.join(templatePath, subdir);
2166
+ const subpath = path7.join(templatePath, subdir);
1701
2167
  if (fs8.statSync(subpath).isFile()) {
1702
2168
  const fileContent = await this.#applyTemplateFile(
1703
- { templatePath: subpath, targetPath: path6.join(basePath2, subdir), scanResult, overwrite },
2169
+ { templatePath: subpath, targetPath: path7.join(basePath2, subdir), scanInfo, overwrite },
1704
2170
  dict
1705
2171
  );
1706
2172
  return fileContent ? [fileContent] : [];
1707
2173
  } else
1708
2174
  return await this._applyTemplate({
1709
- basePath: path6.join(basePath2, subdir),
1710
- template: path6.join(template, subdir),
1711
- scanResult,
2175
+ basePath: path7.join(basePath2, subdir),
2176
+ template: path7.join(template, subdir),
2177
+ scanInfo,
1712
2178
  dict,
1713
2179
  overwrite
1714
2180
  });
@@ -1731,9 +2197,9 @@ var Executor = class _Executor {
1731
2197
  return this.typeChecker;
1732
2198
  }
1733
2199
  typeCheck(filePath) {
1734
- const path9 = this.getPath(filePath);
2200
+ const path10 = this.getPath(filePath);
1735
2201
  const typeChecker = this.getTypeChecker();
1736
- const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path9);
2202
+ const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path10);
1737
2203
  const message = typeChecker.formatDiagnostics(fileDiagnostics);
1738
2204
  return { fileDiagnostics, fileErrors, fileWarnings, message };
1739
2205
  }
@@ -1742,9 +2208,9 @@ var Executor = class _Executor {
1742
2208
  return this.linter;
1743
2209
  }
1744
2210
  async lint(filePath, { fix = false, dryRun = false } = {}) {
1745
- const path9 = this.getPath(filePath);
2211
+ const path10 = this.getPath(filePath);
1746
2212
  const linter = this.getLinter();
1747
- const { results, errors, warnings } = await linter.lint(path9, { fix, dryRun });
2213
+ const { results, errors, warnings } = await linter.lint(path10, { fix, dryRun });
1748
2214
  const message = linter.formatLintResults(results);
1749
2215
  return { results, message, errors, warnings };
1750
2216
  }
@@ -1758,9 +2224,12 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1758
2224
  this.workspaceRoot = workspaceRoot;
1759
2225
  this.repoName = repoName;
1760
2226
  }
1761
- static fromRoot() {
1762
- const repoName = path6.basename(process.cwd());
1763
- return new _WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
2227
+ static #execs = /* @__PURE__ */ new Map();
2228
+ static fromRoot({
2229
+ workspaceRoot = process.cwd(),
2230
+ repoName = path7.basename(process.cwd())
2231
+ } = {}) {
2232
+ return this.#execs.get(repoName) ?? new _WorkspaceExecutor({ workspaceRoot, repoName });
1764
2233
  }
1765
2234
  getBaseDevEnv() {
1766
2235
  const envFile = dotenv.parse(this.readFile(".env"));
@@ -1778,36 +2247,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1778
2247
  return { ...appName ? { name: appName } : {}, repoName, serveDomain, env, portOffset };
1779
2248
  }
1780
2249
  async scan() {
1781
- const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
1782
- const [appScanResults, libScanResults, pkgScanResults] = await Promise.all([
1783
- Promise.all(
1784
- appNames.map(async (appName) => {
1785
- const app = AppExecutor.from(this, appName);
1786
- const akanConfig = await app.getConfig("scan");
1787
- return await app.scan({ akanConfig });
1788
- })
1789
- ),
1790
- Promise.all(
1791
- libNames.map(async (libName) => {
1792
- const lib = LibExecutor.from(this, libName);
1793
- const akanConfig = await lib.getConfig("scan");
1794
- return await lib.scan({ akanConfig });
1795
- })
1796
- ),
1797
- Promise.all(
1798
- pkgNames.map(async (pkgName) => {
1799
- return await PkgExecutor.from(this, pkgName).scan();
1800
- })
1801
- )
1802
- ]);
1803
- return {
1804
- appNames,
1805
- libNames,
1806
- pkgNames,
1807
- apps: Object.fromEntries(appScanResults.map((app) => [app.name, app])),
1808
- libs: Object.fromEntries(libScanResults.map((lib) => [lib.name, lib])),
1809
- pkgs: Object.fromEntries(pkgScanResults.map((pkg) => [pkg.name, pkg]))
1810
- };
2250
+ return await WorkspaceInfo.fromExecutor(this);
1811
2251
  }
1812
2252
  async getApps() {
1813
2253
  if (!fs8.existsSync(`${this.workspaceRoot}/apps`))
@@ -1869,7 +2309,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1869
2309
  dirs.map(async (dir) => {
1870
2310
  if (dir.includes("_") || AVOID_DIRS.includes(dir))
1871
2311
  return;
1872
- const dirPath = path6.join(dirname3, dir);
2312
+ const dirPath = path7.join(dirname3, dir);
1873
2313
  if (fs8.lstatSync(dirPath).isDirectory()) {
1874
2314
  results.push(`${prefix}${dir}`);
1875
2315
  if (maxDepth > 0)
@@ -1896,9 +2336,9 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1896
2336
  dirs.map(async (dir) => {
1897
2337
  if (AVOID_DIRS.includes(dir))
1898
2338
  return;
1899
- const dirPath = path6.join(dirname3, dir);
2339
+ const dirPath = path7.join(dirname3, dir);
1900
2340
  if (fs8.lstatSync(dirPath).isDirectory()) {
1901
- const hasTargetFile = fs8.existsSync(path6.join(dirPath, targetFilename));
2341
+ const hasTargetFile = fs8.existsSync(path7.join(dirPath, targetFilename));
1902
2342
  if (hasTargetFile)
1903
2343
  results.push(`${prefix}${dir}`);
1904
2344
  if (maxDepth > 0)
@@ -1955,163 +2395,106 @@ var SysExecutor = class extends Executor {
1955
2395
  this.type = type;
1956
2396
  this.emoji = execEmoji[type];
1957
2397
  }
1958
- async getConfig(command) {
1959
- return this.type === "app" ? await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name, command }) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name, command });
2398
+ #akanConfig = null;
2399
+ async getConfig({ refresh } = {}) {
2400
+ if (this.#akanConfig && !refresh)
2401
+ return this.#akanConfig;
2402
+ this.#akanConfig = this.type === "app" ? await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name }) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name });
2403
+ return this.#akanConfig;
1960
2404
  }
1961
2405
  async getModules() {
1962
- const path9 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
1963
- return await this.workspace.getDirInModule(path9, this.name);
2406
+ const path10 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
2407
+ return await this.workspace.getDirInModule(path10, this.name);
1964
2408
  }
2409
+ #scanInfo = null;
1965
2410
  async scan({
1966
- tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
1967
- akanConfig
1968
- }, libScanResults = {}) {
1969
- if (libScanResults[this.name])
1970
- return libScanResults[this.name];
1971
- const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
1972
- const scanner = new TypeScriptDependencyScanner(this.cwdPath);
1973
- const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
1974
- const pkgPathSet = new Set(
1975
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
1976
- );
1977
- const libPathSet = new Set(
1978
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("libs/"))).map((path9) => path9.replace("/*", ""))
1979
- );
1980
- const [npmDepSet, pkgPathDepSet, libPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet, libPathSet]);
1981
- const pkgDeps = [...pkgPathDepSet].map((path9) => {
1982
- const pathSplitLength = path9.split("/").length;
1983
- return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1984
- });
1985
- const libDeps = [...libPathDepSet].map((path9) => {
1986
- const pathSplitLength = path9.split("/").length;
1987
- return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1988
- }).filter((libName) => libName !== this.name);
1989
- if (!fs8.existsSync(`${this.cwdPath}/lib/__scalar`))
1990
- fs8.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
1991
- const files = getDefaultFileScan();
1992
- const dirnames = (await this.readdir("lib")).filter(
1993
- (name) => fs8.lstatSync(`${this.cwdPath}/lib/${name}`).isDirectory()
1994
- );
1995
- const databaseDirs = dirnames.filter((name) => !name.startsWith("_"));
1996
- const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
1997
- await Promise.all(
1998
- databaseDirs.map(async (name) => {
1999
- const filenames = await this.readdir(path6.join("lib", name));
2000
- filenames.forEach((filename) => {
2001
- if (filename.endsWith(".constant.ts"))
2002
- files.constants.databases.push(name);
2003
- else if (filename.endsWith(".dictionary.ts"))
2004
- files.dictionary.databases.push(name);
2005
- else if (filename.endsWith(".document.ts"))
2006
- files.documents.databases.push(name);
2007
- else if (filename.endsWith(".service.ts"))
2008
- files.services.databases.push(name);
2009
- else if (filename.endsWith(".signal.ts"))
2010
- files.signal.databases.push(name);
2011
- else if (filename.endsWith(".store.ts"))
2012
- files.store.databases.push(name);
2013
- else if (filename === "index.tsx")
2014
- files.components.databases.push(name);
2015
- });
2016
- })
2017
- );
2018
- await Promise.all(
2019
- serviceDirs.map(async (dirname3) => {
2020
- const name = dirname3.slice(1);
2021
- const filenames = await this.readdir(path6.join("lib", dirname3));
2022
- filenames.forEach((filename) => {
2023
- if (filename.endsWith(".dictionary.ts"))
2024
- files.dictionary.services.push(name);
2025
- else if (filename.endsWith(".service.ts"))
2026
- files.services.services.push(name);
2027
- else if (filename.endsWith(".signal.ts"))
2028
- files.signal.services.push(name);
2029
- else if (filename.endsWith(".store.ts"))
2030
- files.store.services.push(name);
2031
- else if (filename === "index.tsx")
2032
- files.components.services.push(name);
2033
- });
2034
- })
2035
- );
2036
- const scalarDirs = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_"));
2037
- await Promise.all(
2038
- scalarDirs.map(async (name) => {
2039
- const filenames = await this.readdir(path6.join("lib/__scalar", name));
2040
- filenames.forEach((filename) => {
2041
- if (filename.endsWith(".constant.ts"))
2042
- files.constants.scalars.push(name);
2043
- else if (filename.endsWith(".dictionary.ts"))
2044
- files.dictionary.scalars.push(name);
2045
- else if (filename.endsWith(".document.ts"))
2046
- files.documents.scalars.push(name);
2047
- else if (filename.endsWith(".service.ts"))
2048
- files.services.scalars.push(name);
2049
- else if (filename.endsWith(".signal.ts"))
2050
- files.signal.scalars.push(name);
2051
- else if (filename.endsWith(".store.ts"))
2052
- files.store.scalars.push(name);
2053
- else if (filename === "index.ts")
2054
- files.components.scalars.push(name);
2055
- });
2056
- })
2057
- );
2058
- const missingLibDeps = [];
2059
- libDeps.forEach((libName) => {
2060
- if (!akanConfig.libs.includes(libName))
2061
- missingLibDeps.push(libName);
2062
- });
2063
- if (missingLibDeps.length)
2064
- throw new Error(
2065
- `Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
2066
- );
2067
- for (const libName of akanConfig.libs) {
2068
- if (libScanResults[libName])
2069
- continue;
2070
- const lib = new LibExecutor({ workspace: this.workspace, name: libName });
2071
- const akanConfig2 = await lib.getConfig();
2072
- libScanResults[libName] = await lib.scan({ akanConfig: akanConfig2 }, libScanResults);
2411
+ refresh,
2412
+ write = true,
2413
+ writeLib = true
2414
+ } = {}) {
2415
+ if (this.#scanInfo && !refresh)
2416
+ return this.#scanInfo;
2417
+ const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this, { refresh }) : await LibInfo.fromExecutor(this, { refresh });
2418
+ if (write) {
2419
+ await Promise.all([
2420
+ this._applyTemplate({ basePath: "lib", template: "lib", scanInfo }),
2421
+ this._applyTemplate({ basePath: ".", template: "server.ts", scanInfo }),
2422
+ this._applyTemplate({ basePath: ".", template: "client.ts", scanInfo }),
2423
+ this.type === "lib" ? this._applyTemplate({ basePath: ".", template: "index.ts", scanInfo }) : null,
2424
+ ...scanInfo.getDatabaseModules().map(
2425
+ (model) => this._applyTemplate({
2426
+ basePath: `lib/${model}`,
2427
+ template: "moduleRoot",
2428
+ scanInfo,
2429
+ dict: { model, Model: capitalize(model) }
2430
+ })
2431
+ ),
2432
+ ...scanInfo.getServiceModules().map(
2433
+ (model) => this._applyTemplate({
2434
+ basePath: `lib/_${model}`,
2435
+ template: "moduleRoot",
2436
+ scanInfo,
2437
+ dict: { model, Model: capitalize(model) }
2438
+ })
2439
+ )
2440
+ ]);
2441
+ this.writeJson(`akan.${this.type}.json`, scanInfo.getScanResult());
2442
+ if (this.type === "lib")
2443
+ this.#updateDependencies(scanInfo);
2444
+ if (writeLib) {
2445
+ const libInfos = [...scanInfo.getLibInfos().values()];
2446
+ await Promise.all(
2447
+ libInfos.map((libInfo) => [
2448
+ libInfo.exec._applyTemplate({ basePath: "lib", template: "lib", scanInfo: libInfo }),
2449
+ libInfo.exec._applyTemplate({ basePath: ".", template: "server.ts", scanInfo: libInfo }),
2450
+ libInfo.exec._applyTemplate({ basePath: ".", template: "client.ts", scanInfo: libInfo }),
2451
+ libInfo.exec._applyTemplate({ basePath: ".", template: "index.ts", scanInfo: libInfo }),
2452
+ ...libInfo.getDatabaseModules().map(
2453
+ (model) => libInfo.exec._applyTemplate({
2454
+ basePath: `lib/${model}`,
2455
+ template: "moduleRoot",
2456
+ scanInfo: libInfo,
2457
+ dict: { model, Model: capitalize(model) }
2458
+ })
2459
+ ),
2460
+ ...libInfo.getServiceModules().map(
2461
+ (model) => libInfo.exec._applyTemplate({
2462
+ basePath: `lib/_${model}`,
2463
+ template: "moduleRoot",
2464
+ scanInfo: libInfo,
2465
+ dict: { model, Model: capitalize(model) }
2466
+ })
2467
+ )
2468
+ ]).flat()
2469
+ );
2470
+ }
2073
2471
  }
2074
- const scanResult = {
2075
- name: this.name,
2076
- type: this.type,
2077
- repoName: this.workspace.repoName,
2078
- serveDomain: this.workspace.getBaseDevEnv().serveDomain,
2079
- akanConfig,
2080
- files,
2081
- libDeps,
2082
- pkgDeps,
2083
- dependencies: [...npmDepSet].filter((dep) => !dep.startsWith("@akanjs")),
2084
- libs: Object.fromEntries(akanConfig.libs.map((libName) => [libName, libScanResults[libName]]))
2085
- };
2086
- await this._applyTemplate({ basePath: "lib", template: "lib", scanResult });
2087
- await this._applyTemplate({ basePath: ".", template: "server.ts", scanResult });
2088
- await this._applyTemplate({ basePath: ".", template: "client.ts", scanResult });
2089
- if (this.type === "lib")
2090
- await this._applyTemplate({ basePath: ".", template: "index.ts", scanResult });
2091
- this.writeJson(`akan.${this.type}.json`, scanResult);
2092
- if (this.type === "app")
2093
- return scanResult;
2094
- const libPackageJson = this.readJson("package.json");
2472
+ this.#scanInfo = scanInfo;
2473
+ return scanInfo;
2474
+ }
2475
+ #updateDependencies(scanInfo) {
2476
+ const rootPackageJson = this.workspace.getPackageJson();
2477
+ const libPackageJson = this.getPackageJson();
2478
+ const dependencies = scanInfo.getScanResult().dependencies;
2095
2479
  const libPkgJsonWithDeps = {
2096
2480
  ...libPackageJson,
2097
2481
  dependencies: {
2098
2482
  ...libPackageJson.dependencies,
2099
2483
  ...Object.fromEntries(
2100
- scanResult.dependencies.filter((dep) => rootPackageJson.dependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.dependencies?.[dep]])
2484
+ dependencies.filter((dep) => rootPackageJson.dependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.dependencies?.[dep]])
2101
2485
  )
2102
2486
  },
2103
2487
  devDependencies: {
2104
2488
  ...libPackageJson.devDependencies,
2105
2489
  ...Object.fromEntries(
2106
- scanResult.dependencies.filter((dep) => rootPackageJson.devDependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.devDependencies?.[dep]])
2490
+ dependencies.filter((dep) => rootPackageJson.devDependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.devDependencies?.[dep]])
2107
2491
  )
2108
2492
  }
2109
2493
  };
2110
- this.writeJson("package.json", libPkgJsonWithDeps);
2111
- return scanResult;
2494
+ this.setPackageJson(libPkgJsonWithDeps);
2112
2495
  }
2113
2496
  getLocalFile(targetPath) {
2114
- const filePath = path6.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
2497
+ const filePath = path7.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
2115
2498
  const content = this.workspace.readFile(filePath);
2116
2499
  return { filePath, content };
2117
2500
  }
@@ -2191,9 +2574,9 @@ var SysExecutor = class extends Executor {
2191
2574
  )
2192
2575
  };
2193
2576
  const akanConfig = await this.getConfig();
2194
- const scanResult = await this.scan({ akanConfig });
2195
- const fileContents = await this._applyTemplate({ ...options, scanResult, dict });
2196
- await this.scan({ akanConfig });
2577
+ const scanInfo = await this.scan();
2578
+ const fileContents = await this._applyTemplate({ ...options, scanInfo, dict });
2579
+ await this.scan();
2197
2580
  return fileContents;
2198
2581
  }
2199
2582
  setTsPaths() {
@@ -2208,21 +2591,29 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2208
2591
  super({ workspace, name, type: "app" });
2209
2592
  this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/apps/${name}`);
2210
2593
  }
2594
+ static #execs = /* @__PURE__ */ new Map();
2211
2595
  static from(executor, name) {
2212
- if (executor instanceof WorkspaceExecutor)
2596
+ const exec2 = this.#execs.get(name);
2597
+ if (exec2)
2598
+ return exec2;
2599
+ else if (executor instanceof WorkspaceExecutor)
2213
2600
  return new _AppExecutor({ workspace: executor, name });
2214
- return new _AppExecutor({ workspace: executor.workspace, name });
2601
+ else
2602
+ return new _AppExecutor({ workspace: executor.workspace, name });
2215
2603
  }
2216
2604
  getEnv() {
2217
2605
  return this.workspace.getBaseDevEnv().env;
2218
2606
  }
2219
- async getConfig(command) {
2220
- return await getAppConfig(this.cwdPath, {
2607
+ #akanConfig = null;
2608
+ async getConfig({ refresh } = {}) {
2609
+ if (this.#akanConfig && !refresh)
2610
+ return this.#akanConfig;
2611
+ this.#akanConfig = await getAppConfig(this.cwdPath, {
2221
2612
  ...this.workspace.getBaseDevEnv(),
2222
2613
  type: "app",
2223
- name: this.name,
2224
- command
2614
+ name: this.name
2225
2615
  });
2616
+ return this.#akanConfig;
2226
2617
  }
2227
2618
  async syncAssets(libDeps) {
2228
2619
  const projectPublicLibPath = `${this.cwdPath}/public/libs`;
@@ -2259,18 +2650,26 @@ var LibExecutor = class _LibExecutor extends SysExecutor {
2259
2650
  super({ workspace, name, type: "lib" });
2260
2651
  this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/libs/${name}`);
2261
2652
  }
2653
+ static #execs = /* @__PURE__ */ new Map();
2262
2654
  static from(executor, name) {
2263
- if (executor instanceof WorkspaceExecutor)
2655
+ const exec2 = this.#execs.get(name);
2656
+ if (exec2)
2657
+ return exec2;
2658
+ else if (executor instanceof WorkspaceExecutor)
2264
2659
  return new _LibExecutor({ workspace: executor, name });
2265
- return new _LibExecutor({ workspace: executor.workspace, name });
2660
+ else
2661
+ return new _LibExecutor({ workspace: executor.workspace, name });
2266
2662
  }
2267
- async getConfig(command) {
2268
- return await getLibConfig(this.cwdPath, {
2663
+ #akanConfig = null;
2664
+ async getConfig({ refresh } = {}) {
2665
+ if (this.#akanConfig && !refresh)
2666
+ return this.#akanConfig;
2667
+ this.#akanConfig = await getLibConfig(this.cwdPath, {
2269
2668
  ...this.workspace.getBaseDevEnv(),
2270
2669
  type: "lib",
2271
- name: this.name,
2272
- command
2670
+ name: this.name
2273
2671
  });
2672
+ return this.#akanConfig;
2274
2673
  }
2275
2674
  };
2276
2675
  var PkgExecutor = class _PkgExecutor extends Executor {
@@ -2289,27 +2688,13 @@ var PkgExecutor = class _PkgExecutor extends Executor {
2289
2688
  return new _PkgExecutor({ workspace: executor, name });
2290
2689
  return new _PkgExecutor({ workspace: executor.workspace, name });
2291
2690
  }
2292
- async scan({
2293
- packageJson = this.readJson(`${this.cwdPath}/package.json`),
2294
- tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`)
2295
- } = {}) {
2296
- const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
2297
- const scanner = new TypeScriptDependencyScanner(this.cwdPath);
2298
- const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
2299
- const pkgPathSet = new Set(
2300
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
2301
- );
2302
- const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
2303
- const pkgDeps = [...pkgPathDepSet].map((path9) => {
2304
- const pathSplitLength = path9.split("/").length;
2305
- return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
2306
- }).filter((pkg) => pkg !== this.name);
2307
- const pkgScanResult = {
2308
- name: this.name,
2309
- pkgDeps,
2310
- dependencies: [...npmDepSet]
2311
- };
2312
- return pkgScanResult;
2691
+ #scanInfo = null;
2692
+ async scan({ refresh } = {}) {
2693
+ if (this.#scanInfo && !refresh)
2694
+ return this.#scanInfo;
2695
+ const scanInfo = await PkgInfo.fromExecutor(this, { refresh });
2696
+ this.#scanInfo = scanInfo;
2697
+ return scanInfo;
2313
2698
  }
2314
2699
  };
2315
2700
  var ModuleExecutor = class _ModuleExecutor extends Executor {
@@ -2613,7 +2998,7 @@ var extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =>
2613
2998
  ...pacakgeJson.devDependencies ?? {}
2614
2999
  };
2615
3000
  const requireRegex = /(?:require\s*\(|import\s*(?:[\w\s{},*]*\s+from\s*)?|import\s*\()\s*['"`]([^'"`]+)['"`]/g;
2616
- for (const { text } of filepaths.filter(({ path: path9 }) => path9.endsWith(".js") || path9.endsWith(".ts"))) {
3001
+ for (const { text } of filepaths.filter(({ path: path10 }) => path10.endsWith(".js") || path10.endsWith(".ts"))) {
2617
3002
  let requireMatch;
2618
3003
  while ((requireMatch = requireRegex.exec(text)) !== null) {
2619
3004
  const moduleName = requireMatch[1];
@@ -2895,8 +3280,18 @@ var runCommands = async (...commands) => {
2895
3280
  });
2896
3281
  const __dirname = getDirname(import.meta.url);
2897
3282
  const hasPackageJson = fs11.existsSync(`${__dirname}/../package.json`);
2898
- const version = hasPackageJson ? JSON.parse(fs11.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
2899
- program.version(version).description("Akan CLI");
3283
+ process.env.AKAN_VERSION = hasPackageJson ? JSON.parse(fs11.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
3284
+ program.version(process.env.AKAN_VERSION).description("Akan CLI");
3285
+ const akanBasePackageJson = fs11.existsSync("./node_modules/@akanjs/base/package.json") ? JSON.parse(fs11.readFileSync("./node_modules/@akanjs/base/package.json", "utf8")) : null;
3286
+ if (akanBasePackageJson && akanBasePackageJson.version !== process.env.AKAN_VERSION) {
3287
+ Logger.rawLog(
3288
+ chalk4.yellow(
3289
+ `
3290
+ Akan CLI version is mismatch with installed package. ${process.env.AKAN_VERSION} (global) vs ${akanBasePackageJson.version} (base)
3291
+ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`
3292
+ )
3293
+ );
3294
+ }
2900
3295
  for (const command of commands) {
2901
3296
  const targetMetas = getTargetMetas(command);
2902
3297
  for (const targetMeta of targetMetas) {
@@ -2959,7 +3354,8 @@ var runCommands = async (...commands) => {
2959
3354
  Logger.rawLog();
2960
3355
  } catch (e) {
2961
3356
  const errMsg = e instanceof Error ? e.message : typeof e === "string" ? e : JSON.stringify(e);
2962
- Logger.error(`Command Error: ${chalk4.red(errMsg)}`);
3357
+ Logger.rawLog(`
3358
+ ${chalk4.red(errMsg)}`);
2963
3359
  throw e;
2964
3360
  }
2965
3361
  });
@@ -3319,8 +3715,8 @@ var Builder = class {
3319
3715
  }
3320
3716
  };
3321
3717
  buildResult.outputFiles.map((file) => this.#distExecutor.writeFile(file.path, file.text));
3322
- this.#distExecutor.writeJson("package.json", pkgPackageJson);
3323
- this.#executor.writeJson("package.json", pkgPackageJson);
3718
+ this.#distExecutor.setPackageJson(pkgPackageJson);
3719
+ this.#executor.setPackageJson(pkgPackageJson);
3324
3720
  }
3325
3721
  };
3326
3722
 
@@ -3414,8 +3810,8 @@ var LibraryRunner = class {
3414
3810
  return LibExecutor.from(workspace, libName);
3415
3811
  }
3416
3812
  async mergeLibraryDependencies(lib) {
3417
- const libPackageJson = lib.readJson("package.json");
3418
- const rootPackageJson = lib.workspace.readJson("package.json");
3813
+ const libPackageJson = lib.getPackageJson();
3814
+ const rootPackageJson = lib.workspace.getPackageJson();
3419
3815
  const dependencies = {};
3420
3816
  const devDependencies = {};
3421
3817
  const libDependencies = { ...libPackageJson.dependencies, ...libPackageJson.devDependencies };
@@ -3435,7 +3831,7 @@ var LibraryRunner = class {
3435
3831
  devDependencies[dep] = allDependencies[dep];
3436
3832
  });
3437
3833
  const newRootPackageJson = { ...rootPackageJson, dependencies, devDependencies };
3438
- lib.workspace.writeJson("package.json", newRootPackageJson);
3834
+ lib.workspace.setPackageJson(newRootPackageJson);
3439
3835
  await lib.workspace.spawn("pnpm", ["install", "--reporter=silent"]);
3440
3836
  await lib.workspace.commit(`Merge ${lib.name} library dependencies`);
3441
3837
  }
@@ -3481,10 +3877,9 @@ var LibraryScript = class {
3481
3877
  #runner = new LibraryRunner();
3482
3878
  async syncLibrary(lib) {
3483
3879
  const syncSpinner = lib.spinning("Syncing library...");
3484
- const akanConfig = await lib.getConfig();
3485
- const scanResult = await lib.scan({ akanConfig });
3880
+ const scanInfo = await lib.scan();
3486
3881
  syncSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) is synced`);
3487
- return scanResult;
3882
+ return scanInfo;
3488
3883
  }
3489
3884
  async createLibrary(libName, workspace) {
3490
3885
  const spinner = workspace.spinning(`Creating ${libName} library`);
@@ -3546,6 +3941,7 @@ var MultiScrollList = ({ logList, maxLength = 100 }) => {
3546
3941
  const [boxHeight, setBoxHeight] = useState2(
3547
3942
  height - HEADER_HEIGHT - OUTER_BORDER_HEIGHT - FOOTER_HEIGHT - BORDER_HEIGHT
3548
3943
  );
3944
+ const [boxWidth, setBoxWidth] = useState2(width - 28);
3549
3945
  const getLimitedLogs = (logs) => {
3550
3946
  return logs.length > maxLength ? logs.slice(logs.length - maxLength) : logs;
3551
3947
  };
@@ -3597,6 +3993,15 @@ var MultiScrollList = ({ logList, maxLength = 100 }) => {
3597
3993
  useEffect2(() => {
3598
3994
  const getLogsToRender = (logs, index) => {
3599
3995
  const limitedLogs = getLimitedLogs(logs);
3996
+ const logWidth = limitedLogs.reduce((acc, log) => acc + log.content.length, 0);
3997
+ if (logWidth > boxWidth) {
3998
+ return limitedLogs.map((log) => {
3999
+ return {
4000
+ type: log.type,
4001
+ content: log.content.slice(0, boxWidth)
4002
+ };
4003
+ });
4004
+ }
3600
4005
  if (scrollPos > 0 && tabIndex === index) {
3601
4006
  return limitedLogs.slice(limitedLogs.length - boxHeight - scrollPos, limitedLogs.length - scrollPos);
3602
4007
  } else if (limitedLogs.length > boxHeight) {
@@ -3637,9 +4042,9 @@ var MultiScrollList = ({ logList, maxLength = 100 }) => {
3637
4042
  height: "100%"
3638
4043
  },
3639
4044
  scrollPos > 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, focusLog.slice(0, focusLog.length - 1).map((log, index) => {
3640
- return /* @__PURE__ */ React.createElement(Text, { key: index }, log);
4045
+ return /* @__PURE__ */ React.createElement(Text, { color: log.type === "error" ? "red" : "white", key: index }, log.content);
3641
4046
  }), /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "Scrolling... +", scrollPos)) : focusLog.map((log, index) => {
3642
- return /* @__PURE__ */ React.createElement(Text, { key: index }, log);
4047
+ return /* @__PURE__ */ React.createElement(Text, { color: log.type === "error" ? "red" : "white", key: index }, log.content);
3643
4048
  })
3644
4049
  ))), /* @__PURE__ */ React.createElement(Box, { width: "100%", height: FOOTER_HEIGHT }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, /* @__PURE__ */ React.createElement(Text, null, "You can use the following shortcuts:"), /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "tab"), " to switch tab.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "up"), " and ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "down"), " to scroll.", " ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "shift"), " to scroll faster. (x10)", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "space"), " to scroll.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "escape"), " to stop scrolling.")));
3645
4050
  };
@@ -3762,17 +4167,17 @@ var Start = ({ appName, bcp, fcp, csr, maxLength = 100 }) => {
3762
4167
  logList: [
3763
4168
  {
3764
4169
  title: `${appName} frontend`,
3765
- logs: frontendLogs.map((log) => log.content),
4170
+ logs: frontendLogs,
3766
4171
  color: "#ff493b"
3767
4172
  },
3768
4173
  {
3769
4174
  title: `${appName} backend`,
3770
- logs: backendLogs.map((log) => log.content),
4175
+ logs: backendLogs,
3771
4176
  color: "#e535ab"
3772
4177
  },
3773
4178
  {
3774
4179
  title: `${appName} react`,
3775
- logs: csrLogs.map((log) => log.content),
4180
+ logs: csrLogs,
3776
4181
  color: "#7cc5d9"
3777
4182
  }
3778
4183
  ],
@@ -3837,7 +4242,7 @@ import fsPromise3 from "fs/promises";
3837
4242
  import yaml2 from "js-yaml";
3838
4243
  import openBrowser from "open";
3839
4244
  import ora3 from "ora";
3840
- import path7 from "path";
4245
+ import path8 from "path";
3841
4246
  import * as vite from "vite";
3842
4247
  import commonjs from "vite-plugin-commonjs";
3843
4248
  import { nodePolyfills } from "vite-plugin-node-polyfills";
@@ -3857,17 +4262,12 @@ var ApplicationRunner = class {
3857
4262
  app.workspace.unsetTsPaths("app", app.name);
3858
4263
  }
3859
4264
  async getConfig(app) {
3860
- return await getAppConfig(app.cwdPath, {
3861
- ...app.workspace.getBaseDevEnv(),
3862
- type: "app",
3863
- name: app.name,
3864
- command: "start"
3865
- });
4265
+ return await app.getConfig();
3866
4266
  }
3867
- async scanSync(app, akanConfig) {
3868
- const scanResult = await app.scan({ akanConfig });
3869
- await app.syncAssets(scanResult.akanConfig.libs);
3870
- return scanResult;
4267
+ async scanSync(app) {
4268
+ const scanInfo = await app.scan();
4269
+ await app.syncAssets(scanInfo.getScanResult().libDeps);
4270
+ return scanInfo;
3871
4271
  }
3872
4272
  async getScriptFilename(app) {
3873
4273
  if (!app.exists("scripts")) {
@@ -3923,12 +4323,12 @@ var ApplicationRunner = class {
3923
4323
  } else if (target === "csr")
3924
4324
  await app.workspace.exec(`rm -rf ${app.workspace.workspaceRoot}/node_modules/.vite/${app.name}`);
3925
4325
  else if (target === "backend")
3926
- await app.cp("assets", path7.join(app.dist.cwdPath, "backend", "assets"));
4326
+ await app.cp("assets", path8.join(app.dist.cwdPath, "backend", "assets"));
3927
4327
  return { env: this.#getEnv(app, target, { AKAN_COMMAND_TYPE: type }) };
3928
4328
  }
3929
4329
  async buildBackend(app) {
3930
4330
  await this.#prepareCommand(app, "start", "backend");
3931
- const akanConfig = await app.getConfig("build");
4331
+ const akanConfig = await app.getConfig();
3932
4332
  const buildResult = await esbuild2.build({
3933
4333
  write: false,
3934
4334
  entryPoints: [`${app.cwdPath}/main.ts`],
@@ -3939,7 +4339,7 @@ var ApplicationRunner = class {
3939
4339
  outdir: `${app.dist.cwdPath}/backend`,
3940
4340
  logLevel: "warning"
3941
4341
  });
3942
- const rootPackageJson = app.workspace.readJson("package.json");
4342
+ const rootPackageJson = app.workspace.getPackageJson();
3943
4343
  const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson);
3944
4344
  buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
3945
4345
  const appPackageJson = {
@@ -3952,7 +4352,7 @@ var ApplicationRunner = class {
3952
4352
  dependencies
3953
4353
  };
3954
4354
  app.dist.writeJson("backend/package.json", appPackageJson);
3955
- app.dist.writeFile(path7.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.docker.content);
4355
+ app.dist.writeFile(path8.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.docker.content);
3956
4356
  }
3957
4357
  async startBackend(app, { open: open2 = false, onStart, withInk = false } = {}) {
3958
4358
  const { env } = await this.#prepareCommand(app, "start", "backend");
@@ -3963,7 +4363,7 @@ var ApplicationRunner = class {
3963
4363
  packages: "external",
3964
4364
  platform: "node",
3965
4365
  format: "cjs",
3966
- outdir: path7.join(app.dist.cwdPath, "backend"),
4366
+ outdir: path8.join(app.dist.cwdPath, "backend"),
3967
4367
  logLevel: "warning"
3968
4368
  });
3969
4369
  await ctx.watch();
@@ -3979,7 +4379,7 @@ var ApplicationRunner = class {
3979
4379
  }
3980
4380
  async buildFrontend(app, { spawnOptions } = {}) {
3981
4381
  const { env } = await this.#prepareCommand(app, "build", "frontend");
3982
- const akanConfig = await app.getConfig("build");
4382
+ const akanConfig = await app.getConfig();
3983
4383
  await app.spawn("npx", ["next", "build", "--no-lint"], { env, ...spawnOptions });
3984
4384
  const buildResult = await esbuild2.build({
3985
4385
  entryPoints: [`${app.cwdPath}/next.config.ts`],
@@ -3991,7 +4391,7 @@ var ApplicationRunner = class {
3991
4391
  write: false,
3992
4392
  logLevel: "warning"
3993
4393
  });
3994
- const rootPackageJson = app.workspace.readJson("package.json");
4394
+ const rootPackageJson = app.workspace.getPackageJson();
3995
4395
  const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson, ["next", "react", "react-dom"]);
3996
4396
  buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
3997
4397
  const appPackageJson = {
@@ -4004,8 +4404,8 @@ var ApplicationRunner = class {
4004
4404
  };
4005
4405
  app.dist.writeJson("frontend/package.json", appPackageJson);
4006
4406
  await Promise.all([
4007
- app.cp(".next", path7.join(app.dist.cwdPath, "frontend", ".next")),
4008
- app.cp("public", path7.join(app.dist.cwdPath, "frontend", "public"))
4407
+ app.cp(".next", path8.join(app.dist.cwdPath, "frontend", ".next")),
4408
+ app.cp("public", path8.join(app.dist.cwdPath, "frontend", "public"))
4009
4409
  ]);
4010
4410
  app.dist.writeFile("frontend/Dockerfile", akanConfig.frontend.docker.content);
4011
4411
  }
@@ -4204,6 +4604,11 @@ var ApplicationRunner = class {
4204
4604
  ]);
4205
4605
  }
4206
4606
  async dbup(workspace) {
4607
+ try {
4608
+ await workspace.exec(`docker ps`);
4609
+ } catch (e) {
4610
+ throw new Error(`Docker daemon is not running. Please install docker or start docker daemon and try again.`);
4611
+ }
4207
4612
  await workspace.applyTemplate({
4208
4613
  basePath: "local",
4209
4614
  template: "localDev",
@@ -4280,8 +4685,8 @@ var ApplicationRunner = class {
4280
4685
  )
4281
4686
  );
4282
4687
  await Promise.all(
4283
- [".next", "ios", "android", "public/libs"].map(async (path9) => {
4284
- const targetPath = `${sourceRoot}/apps/${app.name}/${path9}`;
4688
+ [".next", "ios", "android", "public/libs"].map(async (path10) => {
4689
+ const targetPath = `${sourceRoot}/apps/${app.name}/${path10}`;
4285
4690
  if (fs14.existsSync(targetPath))
4286
4691
  await fsPromise3.rm(targetPath, { recursive: true, force: true });
4287
4692
  })
@@ -4299,7 +4704,7 @@ var ApplicationRunner = class {
4299
4704
  ];
4300
4705
  await Promise.all(
4301
4706
  syncPaths.map(
4302
- (path9) => fsPromise3.cp(`${app.workspace.cwdPath}/${path9}`, `${sourceRoot}/${path9}`, { recursive: true })
4707
+ (path10) => fsPromise3.cp(`${app.workspace.cwdPath}/${path10}`, `${sourceRoot}/${path10}`, { recursive: true })
4303
4708
  )
4304
4709
  );
4305
4710
  const tsconfig = app.workspace.readJson("tsconfig.json");
@@ -4422,10 +4827,9 @@ var ApplicationScript = class {
4422
4827
  }
4423
4828
  async syncApplication(app) {
4424
4829
  const spinner = app.spinning("Scanning application...");
4425
- const akanConfig = await this.#runner.getConfig(app);
4426
- const scanResult = await this.#runner.scanSync(app, akanConfig);
4830
+ const scanInfo = await this.#runner.scanSync(app);
4427
4831
  spinner.succeed("Application scanned");
4428
- return scanResult;
4832
+ return scanInfo;
4429
4833
  }
4430
4834
  async script(app, filename) {
4431
4835
  const scriptFilename = filename ?? await this.#runner.getScriptFilename(app);
@@ -4869,8 +5273,8 @@ var PackageRunner = class {
4869
5273
  return scanResult;
4870
5274
  }
4871
5275
  async buildPackage(pkg) {
4872
- const rootPackageJson = pkg.workspace.readJson("package.json");
4873
- const pkgJson = pkg.readJson("package.json");
5276
+ const rootPackageJson = pkg.workspace.getPackageJson();
5277
+ const pkgJson = pkg.getPackageJson();
4874
5278
  const builder = new Builder({ executor: pkg, distExecutor: pkg.dist, pkgJson, rootPackageJson });
4875
5279
  if (pkg.name === "@akanjs/cli")
4876
5280
  await builder.build({
@@ -5044,7 +5448,7 @@ ${chalk6.green("\u27A4")} Authentication Required`));
5044
5448
  }
5045
5449
  async #updateAkanPkgs(workspace) {
5046
5450
  const latestPublishedVersionOfBase = await latestVersion("@akanjs/base");
5047
- const rootPackageJson = workspace.readJson("package.json");
5451
+ const rootPackageJson = workspace.getPackageJson();
5048
5452
  if (!rootPackageJson.dependencies)
5049
5453
  throw new Error("No dependencies found in package.json");
5050
5454
  Object.keys(rootPackageJson.dependencies).forEach((dependency) => {
@@ -5055,7 +5459,7 @@ ${chalk6.green("\u27A4")} Authentication Required`));
5055
5459
  if (dependency.startsWith("@akanjs/"))
5056
5460
  Object.assign(rootPackageJson.devDependencies ?? {}, { [dependency]: latestPublishedVersionOfBase });
5057
5461
  });
5058
- workspace.writeJson("package.json", rootPackageJson);
5462
+ workspace.setPackageJson(rootPackageJson);
5059
5463
  await workspace.spawn("pnpm", ["install"]);
5060
5464
  }
5061
5465
  };
@@ -5611,8 +6015,7 @@ var ModuleScript = class {
5611
6015
  await this.#runner.createModuleTemplate(mod);
5612
6016
  if (page && sys3.type === "app")
5613
6017
  await this.pageScript.createCrudPage(mod, { app: sys3, basePath: null, single: false });
5614
- const akanConfig = await sys3.getConfig();
5615
- await sys3.scan({ akanConfig });
6018
+ await sys3.scan();
5616
6019
  }
5617
6020
  async createModule(sys3, name, description, schemaDescription) {
5618
6021
  const session = new AiSession("createModule", { workspace: sys3.workspace, cacheKey: name });
@@ -5843,13 +6246,13 @@ PageCommand = __decorateClass([
5843
6246
 
5844
6247
  // pkgs/@akanjs/cli/src/workspace/workspace.runner.ts
5845
6248
  import latestVersion2 from "latest-version";
5846
- import path8 from "path";
6249
+ import path9 from "path";
5847
6250
  import { v5 as uuid } from "uuid";
5848
6251
  var WorkspaceRunner = class {
5849
6252
  async createWorkspace(repoName, appName, dirname3 = ".") {
5850
6253
  const cwdPath = process.cwd();
5851
- const workspaceRoot = path8.join(cwdPath, dirname3, repoName);
5852
- const workspace = new WorkspaceExecutor({ workspaceRoot, repoName });
6254
+ const workspaceRoot = path9.join(cwdPath, dirname3, repoName);
6255
+ const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
5853
6256
  const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname3}/${repoName}...`);
5854
6257
  await workspace.applyTemplate({
5855
6258
  basePath: ".",
@@ -5857,7 +6260,7 @@ var WorkspaceRunner = class {
5857
6260
  dict: { repoName, appName, serveDomain: "localhost" }
5858
6261
  });
5859
6262
  templateSpinner.succeed(`Workspace files created in ${dirname3}/${repoName}`);
5860
- const rootPackageJson = workspace.readJson("package.json");
6263
+ const rootPackageJson = workspace.getPackageJson();
5861
6264
  const dependencies = [
5862
6265
  "@akanjs/base",
5863
6266
  "@akanjs/cli",
@@ -5888,7 +6291,7 @@ var WorkspaceRunner = class {
5888
6291
  ...Object.fromEntries(devDependencies.map((dependency) => [dependency, latestPublishedVersionOfBase]))
5889
6292
  }
5890
6293
  };
5891
- workspace.writeFile("package.json", packageJson);
6294
+ workspace.setPackageJson(packageJson);
5892
6295
  const installSpinner = workspace.spinning("Installing dependencies with pnpm...");
5893
6296
  await workspace.spawn("pnpm", ["install", "--reporter=silent"]);
5894
6297
  installSpinner.succeed("Dependencies installed with pnpm");
@@ -6046,15 +6449,15 @@ var GuidelinePrompt = class extends Prompter {
6046
6449
  async #getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
6047
6450
  const matchingPaths = fsPromise5.glob(matchPattern, {
6048
6451
  cwd: this.workspace.workspaceRoot,
6049
- exclude: (path9) => avoidDirs.some((dir) => path9.includes(dir))
6452
+ exclude: (path10) => avoidDirs.some((dir) => path10.includes(dir))
6050
6453
  });
6051
6454
  const paths = [];
6052
- for await (const path9 of matchingPaths) {
6053
- const fileContent = fs16.readFileSync(path9, "utf-8");
6455
+ for await (const path10 of matchingPaths) {
6456
+ const fileContent = fs16.readFileSync(path10, "utf-8");
6054
6457
  const textFilter = filterText ? new RegExp(filterText) : null;
6055
6458
  if (filterText && !textFilter?.test(fileContent))
6056
6459
  continue;
6057
- paths.push(path9);
6460
+ paths.push(path10);
6058
6461
  }
6059
6462
  return paths;
6060
6463
  }