@akanjs/cli 0.9.41 → 0.9.42

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 (536) hide show
  1. package/cjs/index.js +925 -532
  2. package/cjs/src/guidelines/databaseModule/databaseModule.instruction.md +3 -50
  3. package/cjs/src/guidelines/modelService/modelService.generate.json +3 -10
  4. package/cjs/src/guidelines/scalarModule/scalarModule.instruction.md +0 -3
  5. package/cjs/src/templates/__scalar/__model__/__model__.constant.js +1 -1
  6. package/cjs/src/templates/__scalar/__model__/__model__.dictionary.js +1 -1
  7. package/cjs/src/templates/__scalar/__model__/__model__.document.js +1 -1
  8. package/cjs/src/templates/app/akan.config.js +1 -1
  9. package/cjs/src/templates/app/app/[lang]/admin/page.js +5 -5
  10. package/cjs/src/templates/app/app/[lang]/layout.js +1 -1
  11. package/cjs/src/templates/app/app/[lang]/page.js +1 -1
  12. package/cjs/src/templates/app/app/csr.js +1 -1
  13. package/cjs/src/templates/app/app/layout.js +1 -1
  14. package/cjs/src/templates/app/app/robots.js +1 -1
  15. package/cjs/src/templates/app/app/sitemap.js +1 -1
  16. package/cjs/src/templates/app/base/baseLogic.js +1 -1
  17. package/cjs/src/templates/app/base/index.js +1 -1
  18. package/cjs/src/templates/app/common/commonLogic.js +1 -1
  19. package/cjs/src/templates/app/common/index.js +1 -1
  20. package/cjs/src/templates/app/env/env.client.js +1 -1
  21. package/cjs/src/templates/app/env/env.client.type.js +1 -1
  22. package/cjs/src/templates/app/env/env.server.js +1 -1
  23. package/cjs/src/templates/app/jest.config.js +1 -1
  24. package/cjs/src/templates/app/lib/___appName__/__appName__.dictionary.js +1 -1
  25. package/cjs/src/templates/app/lib/___appName__/__appName__.service.js +1 -1
  26. package/cjs/src/templates/app/lib/___appName__/__appName__.store.js +1 -1
  27. package/cjs/src/templates/app/lib/option.js +1 -1
  28. package/cjs/src/templates/app/lib/setting/Setting.Template.js +6 -19
  29. package/cjs/src/templates/app/lib/setting/Setting.Unit.js +3 -3
  30. package/cjs/src/templates/app/lib/setting/Setting.Util.js +8 -2
  31. package/cjs/src/templates/app/lib/setting/Setting.View.js +4 -7
  32. package/cjs/src/templates/app/lib/setting/Setting.Zone.js +2 -8
  33. package/cjs/src/templates/app/lib/setting/setting.constant.js +1 -1
  34. package/cjs/src/templates/app/lib/setting/setting.dictionary.js +1 -1
  35. package/cjs/src/templates/app/lib/setting/setting.document.js +1 -1
  36. package/cjs/src/templates/app/lib/setting/setting.service.js +1 -1
  37. package/cjs/src/templates/app/lib/setting/setting.signal.js +1 -1
  38. package/cjs/src/templates/app/lib/setting/setting.store.js +1 -1
  39. package/cjs/src/templates/app/lib/summary/Summary.Template.js +5 -4
  40. package/cjs/src/templates/app/lib/summary/Summary.Unit.js +4 -5
  41. package/cjs/src/templates/app/lib/summary/Summary.Util.js +10 -3
  42. package/cjs/src/templates/app/lib/summary/Summary.View.js +5 -9
  43. package/cjs/src/templates/app/lib/summary/Summary.Zone.js +2 -4
  44. package/cjs/src/templates/app/lib/summary/summary.constant.js +1 -1
  45. package/cjs/src/templates/app/lib/summary/summary.dictionary.js +1 -1
  46. package/cjs/src/templates/app/lib/summary/summary.document.js +1 -1
  47. package/cjs/src/templates/app/lib/summary/summary.service.js +1 -1
  48. package/cjs/src/templates/app/lib/summary/summary.signal.js +1 -1
  49. package/cjs/src/templates/app/lib/summary/summary.store.js +1 -1
  50. package/cjs/src/templates/app/lib/user/User.Template.js +2 -3
  51. package/cjs/src/templates/app/lib/user/User.Unit.js +4 -5
  52. package/cjs/src/templates/app/lib/user/User.Util.js +8 -29
  53. package/cjs/src/templates/app/lib/user/User.View.js +2 -4
  54. package/cjs/src/templates/app/lib/user/User.Zone.js +6 -3
  55. package/cjs/src/templates/app/lib/user/user.constant.js +1 -1
  56. package/cjs/src/templates/app/lib/user/user.dictionary.js +1 -1
  57. package/cjs/src/templates/app/lib/user/user.document.js +1 -1
  58. package/cjs/src/templates/app/lib/user/user.service.js +1 -1
  59. package/cjs/src/templates/app/lib/user/user.signal.js +1 -1
  60. package/cjs/src/templates/app/lib/user/user.signal.spec.js +1 -1
  61. package/cjs/src/templates/app/lib/user/user.signal.test.js +1 -1
  62. package/cjs/src/templates/app/lib/user/user.store.js +1 -1
  63. package/cjs/src/templates/app/main.js +1 -1
  64. package/cjs/src/templates/app/middleware.js +1 -1
  65. package/cjs/src/templates/app/nest/backendLogic.js +1 -1
  66. package/cjs/src/templates/app/nest/index.js +1 -1
  67. package/cjs/src/templates/app/next/frontendLogic.js +1 -1
  68. package/cjs/src/templates/app/next/index.js +1 -1
  69. package/cjs/src/templates/app/ui/UiComponent.js +1 -1
  70. package/cjs/src/templates/app/ui/index.js +1 -1
  71. package/cjs/src/templates/client.js +11 -5
  72. package/cjs/src/templates/crudPages/[__model__Id]/edit/page.js +1 -1
  73. package/cjs/src/templates/crudPages/[__model__Id]/page.js +1 -1
  74. package/cjs/src/templates/crudPages/new/page.js +1 -1
  75. package/cjs/src/templates/crudPages/page.js +1 -1
  76. package/cjs/src/templates/crudSinglePage/page.js +1 -1
  77. package/cjs/src/templates/index.js +1 -1
  78. package/cjs/src/templates/lib/__lib/extends/summary.constant.js +7 -5
  79. package/cjs/src/templates/lib/__lib/lib.constant.js +7 -11
  80. package/cjs/src/templates/lib/__lib/lib.dictionary.js +4 -4
  81. package/cjs/src/templates/lib/__lib/lib.document.js +4 -4
  82. package/cjs/src/templates/lib/__lib/lib.service.js +19 -24
  83. package/cjs/src/templates/lib/__lib/lib.signal.js +5 -4
  84. package/cjs/src/templates/lib/__lib/lib.store.js +3 -3
  85. package/cjs/src/templates/lib/cnst.js +1 -1
  86. package/cjs/src/templates/lib/cnst_.js +5 -5
  87. package/cjs/src/templates/lib/db.js +5 -5
  88. package/cjs/src/templates/lib/dict.js +5 -5
  89. package/cjs/src/templates/lib/fetch.js +6 -6
  90. package/cjs/src/templates/lib/sig.js +4 -8
  91. package/cjs/src/templates/lib/srv.js +5 -8
  92. package/cjs/src/templates/lib/st.js +3 -3
  93. package/cjs/src/templates/lib/store.js +7 -9
  94. package/cjs/src/templates/lib/usePage.js +1 -1
  95. package/cjs/src/templates/libRoot/akan.config.js +1 -1
  96. package/cjs/src/templates/libRoot/base/baseLogic.js +1 -1
  97. package/cjs/src/templates/libRoot/base/index.js +1 -1
  98. package/cjs/src/templates/libRoot/common/commonLogic.js +1 -1
  99. package/cjs/src/templates/libRoot/common/index.js +1 -1
  100. package/cjs/src/templates/libRoot/jest.config.js +1 -1
  101. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +1 -1
  102. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -1
  103. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.store.js +1 -1
  104. package/cjs/src/templates/libRoot/lib/option.js +1 -1
  105. package/cjs/src/templates/libRoot/lib/setting/Setting.Template.js +6 -19
  106. package/cjs/src/templates/libRoot/lib/setting/Setting.Unit.js +3 -3
  107. package/cjs/src/templates/libRoot/lib/setting/Setting.Util.js +8 -2
  108. package/cjs/src/templates/libRoot/lib/setting/Setting.View.js +4 -7
  109. package/cjs/src/templates/libRoot/lib/setting/Setting.Zone.js +2 -8
  110. package/cjs/src/templates/libRoot/lib/setting/setting.constant.js +1 -1
  111. package/cjs/src/templates/libRoot/lib/setting/setting.dictionary.js +1 -1
  112. package/cjs/src/templates/libRoot/lib/setting/setting.document.js +1 -1
  113. package/cjs/src/templates/libRoot/lib/setting/setting.service.js +1 -1
  114. package/cjs/src/templates/libRoot/lib/setting/setting.signal.js +1 -1
  115. package/cjs/src/templates/libRoot/lib/setting/setting.store.js +1 -1
  116. package/cjs/src/templates/libRoot/lib/summary/Summary.Template.js +5 -4
  117. package/cjs/src/templates/libRoot/lib/summary/Summary.Unit.js +4 -5
  118. package/cjs/src/templates/libRoot/lib/summary/Summary.Util.js +10 -3
  119. package/cjs/src/templates/libRoot/lib/summary/Summary.View.js +5 -9
  120. package/cjs/src/templates/libRoot/lib/summary/Summary.Zone.js +2 -4
  121. package/cjs/src/templates/libRoot/lib/summary/summary.constant.js +1 -1
  122. package/cjs/src/templates/libRoot/lib/summary/summary.dictionary.js +1 -1
  123. package/cjs/src/templates/libRoot/lib/summary/summary.document.js +1 -1
  124. package/cjs/src/templates/libRoot/lib/summary/summary.service.js +1 -1
  125. package/cjs/src/templates/libRoot/lib/summary/summary.signal.js +1 -1
  126. package/cjs/src/templates/libRoot/lib/summary/summary.store.js +1 -1
  127. package/cjs/src/templates/libRoot/lib/user/User.Template.js +2 -3
  128. package/cjs/src/templates/libRoot/lib/user/User.Unit.js +4 -5
  129. package/cjs/src/templates/libRoot/lib/user/User.Util.js +8 -29
  130. package/cjs/src/templates/libRoot/lib/user/User.View.js +2 -4
  131. package/cjs/src/templates/libRoot/lib/user/User.Zone.js +6 -3
  132. package/cjs/src/templates/libRoot/lib/user/user.constant.js +1 -1
  133. package/cjs/src/templates/libRoot/lib/user/user.dictionary.js +1 -1
  134. package/cjs/src/templates/libRoot/lib/user/user.document.js +1 -1
  135. package/cjs/src/templates/libRoot/lib/user/user.service.js +1 -1
  136. package/cjs/src/templates/libRoot/lib/user/user.signal.js +1 -1
  137. package/cjs/src/templates/libRoot/lib/user/user.signal.spec.js +1 -1
  138. package/cjs/src/templates/libRoot/lib/user/user.signal.test.js +1 -1
  139. package/cjs/src/templates/libRoot/lib/user/user.store.js +1 -1
  140. package/cjs/src/templates/libRoot/nest/backendLogic.js +1 -1
  141. package/cjs/src/templates/libRoot/nest/index.js +1 -1
  142. package/cjs/src/templates/libRoot/next/frontendLogic.js +1 -1
  143. package/cjs/src/templates/libRoot/next/index.js +1 -1
  144. package/cjs/src/templates/libRoot/ui/index.js +1 -1
  145. package/cjs/src/templates/module/__Model__.Template.js +1 -1
  146. package/cjs/src/templates/module/__Model__.Unit.js +1 -1
  147. package/cjs/src/templates/module/__Model__.Util.js +1 -1
  148. package/cjs/src/templates/module/__Model__.View.js +1 -1
  149. package/cjs/src/templates/module/__Model__.Zone.js +1 -1
  150. package/cjs/src/templates/module/__model__.constant.js +1 -1
  151. package/cjs/src/templates/module/__model__.dictionary.js +1 -1
  152. package/cjs/src/templates/module/__model__.document.js +1 -1
  153. package/cjs/src/templates/module/__model__.service.js +1 -1
  154. package/cjs/src/templates/module/__model__.signal.js +1 -1
  155. package/cjs/src/templates/module/__model__.signal.spec.js +1 -1
  156. package/cjs/src/templates/module/__model__.signal.test.js +1 -1
  157. package/cjs/src/templates/module/__model__.store.js +1 -1
  158. package/cjs/src/templates/module/index.js +1 -1
  159. package/cjs/src/templates/{libRoot/lib/user → moduleRoot}/index.js +23 -35
  160. package/cjs/src/templates/server.js +31 -13
  161. package/cjs/src/templates/workspaceRoot/.gitignore.template +2 -2
  162. package/esm/index.js +926 -533
  163. package/esm/src/guidelines/databaseModule/databaseModule.instruction.md +3 -50
  164. package/esm/src/guidelines/modelService/modelService.generate.json +3 -10
  165. package/esm/src/guidelines/scalarModule/scalarModule.instruction.md +0 -3
  166. package/esm/src/templates/__scalar/__model__/__model__.constant.js +1 -1
  167. package/esm/src/templates/__scalar/__model__/__model__.dictionary.js +1 -1
  168. package/esm/src/templates/__scalar/__model__/__model__.document.js +1 -1
  169. package/esm/src/templates/app/akan.config.js +1 -1
  170. package/esm/src/templates/app/app/[lang]/admin/page.js +5 -5
  171. package/esm/src/templates/app/app/[lang]/layout.js +1 -1
  172. package/esm/src/templates/app/app/[lang]/page.js +1 -1
  173. package/esm/src/templates/app/app/csr.js +1 -1
  174. package/esm/src/templates/app/app/layout.js +1 -1
  175. package/esm/src/templates/app/app/robots.js +1 -1
  176. package/esm/src/templates/app/app/sitemap.js +1 -1
  177. package/esm/src/templates/app/base/baseLogic.js +1 -1
  178. package/esm/src/templates/app/base/index.js +1 -1
  179. package/esm/src/templates/app/common/commonLogic.js +1 -1
  180. package/esm/src/templates/app/common/index.js +1 -1
  181. package/esm/src/templates/app/env/env.client.js +1 -1
  182. package/esm/src/templates/app/env/env.client.type.js +1 -1
  183. package/esm/src/templates/app/env/env.server.js +1 -1
  184. package/esm/src/templates/app/jest.config.js +1 -1
  185. package/esm/src/templates/app/lib/___appName__/__appName__.dictionary.js +1 -1
  186. package/esm/src/templates/app/lib/___appName__/__appName__.service.js +1 -1
  187. package/esm/src/templates/app/lib/___appName__/__appName__.store.js +1 -1
  188. package/esm/src/templates/app/lib/option.js +1 -1
  189. package/esm/src/templates/app/lib/setting/Setting.Template.js +6 -19
  190. package/esm/src/templates/app/lib/setting/Setting.Unit.js +3 -3
  191. package/esm/src/templates/app/lib/setting/Setting.Util.js +8 -2
  192. package/esm/src/templates/app/lib/setting/Setting.View.js +4 -7
  193. package/esm/src/templates/app/lib/setting/Setting.Zone.js +2 -8
  194. package/esm/src/templates/app/lib/setting/setting.constant.js +1 -1
  195. package/esm/src/templates/app/lib/setting/setting.dictionary.js +1 -1
  196. package/esm/src/templates/app/lib/setting/setting.document.js +1 -1
  197. package/esm/src/templates/app/lib/setting/setting.service.js +1 -1
  198. package/esm/src/templates/app/lib/setting/setting.signal.js +1 -1
  199. package/esm/src/templates/app/lib/setting/setting.store.js +1 -1
  200. package/esm/src/templates/app/lib/summary/Summary.Template.js +5 -4
  201. package/esm/src/templates/app/lib/summary/Summary.Unit.js +4 -5
  202. package/esm/src/templates/app/lib/summary/Summary.Util.js +10 -3
  203. package/esm/src/templates/app/lib/summary/Summary.View.js +5 -9
  204. package/esm/src/templates/app/lib/summary/Summary.Zone.js +2 -4
  205. package/esm/src/templates/app/lib/summary/summary.constant.js +1 -1
  206. package/esm/src/templates/app/lib/summary/summary.dictionary.js +1 -1
  207. package/esm/src/templates/app/lib/summary/summary.document.js +1 -1
  208. package/esm/src/templates/app/lib/summary/summary.service.js +1 -1
  209. package/esm/src/templates/app/lib/summary/summary.signal.js +1 -1
  210. package/esm/src/templates/app/lib/summary/summary.store.js +1 -1
  211. package/esm/src/templates/app/lib/user/User.Template.js +2 -3
  212. package/esm/src/templates/app/lib/user/User.Unit.js +4 -5
  213. package/esm/src/templates/app/lib/user/User.Util.js +8 -29
  214. package/esm/src/templates/app/lib/user/User.View.js +2 -4
  215. package/esm/src/templates/app/lib/user/User.Zone.js +6 -3
  216. package/esm/src/templates/app/lib/user/user.constant.js +1 -1
  217. package/esm/src/templates/app/lib/user/user.dictionary.js +1 -1
  218. package/esm/src/templates/app/lib/user/user.document.js +1 -1
  219. package/esm/src/templates/app/lib/user/user.service.js +1 -1
  220. package/esm/src/templates/app/lib/user/user.signal.js +1 -1
  221. package/esm/src/templates/app/lib/user/user.signal.spec.js +1 -1
  222. package/esm/src/templates/app/lib/user/user.signal.test.js +1 -1
  223. package/esm/src/templates/app/lib/user/user.store.js +1 -1
  224. package/esm/src/templates/app/main.js +1 -1
  225. package/esm/src/templates/app/middleware.js +1 -1
  226. package/esm/src/templates/app/nest/backendLogic.js +1 -1
  227. package/esm/src/templates/app/nest/index.js +1 -1
  228. package/esm/src/templates/app/next/frontendLogic.js +1 -1
  229. package/esm/src/templates/app/next/index.js +1 -1
  230. package/esm/src/templates/app/ui/UiComponent.js +1 -1
  231. package/esm/src/templates/app/ui/index.js +1 -1
  232. package/esm/src/templates/client.js +11 -5
  233. package/esm/src/templates/crudPages/[__model__Id]/edit/page.js +1 -1
  234. package/esm/src/templates/crudPages/[__model__Id]/page.js +1 -1
  235. package/esm/src/templates/crudPages/new/page.js +1 -1
  236. package/esm/src/templates/crudPages/page.js +1 -1
  237. package/esm/src/templates/crudSinglePage/page.js +1 -1
  238. package/esm/src/templates/index.js +1 -1
  239. package/esm/src/templates/lib/__lib/extends/summary.constant.js +7 -5
  240. package/esm/src/templates/lib/__lib/lib.constant.js +7 -11
  241. package/esm/src/templates/lib/__lib/lib.dictionary.js +4 -4
  242. package/esm/src/templates/lib/__lib/lib.document.js +4 -4
  243. package/esm/src/templates/lib/__lib/lib.service.js +19 -24
  244. package/esm/src/templates/lib/__lib/lib.signal.js +5 -4
  245. package/esm/src/templates/lib/__lib/lib.store.js +3 -3
  246. package/esm/src/templates/lib/cnst.js +1 -1
  247. package/esm/src/templates/lib/cnst_.js +5 -5
  248. package/esm/src/templates/lib/db.js +5 -5
  249. package/esm/src/templates/lib/dict.js +5 -5
  250. package/esm/src/templates/lib/fetch.js +6 -6
  251. package/esm/src/templates/lib/sig.js +4 -8
  252. package/esm/src/templates/lib/srv.js +5 -8
  253. package/esm/src/templates/lib/st.js +3 -3
  254. package/esm/src/templates/lib/store.js +7 -9
  255. package/esm/src/templates/lib/usePage.js +1 -1
  256. package/esm/src/templates/libRoot/akan.config.js +1 -1
  257. package/esm/src/templates/libRoot/base/baseLogic.js +1 -1
  258. package/esm/src/templates/libRoot/base/index.js +1 -1
  259. package/esm/src/templates/libRoot/common/commonLogic.js +1 -1
  260. package/esm/src/templates/libRoot/common/index.js +1 -1
  261. package/esm/src/templates/libRoot/jest.config.js +1 -1
  262. package/esm/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +1 -1
  263. package/esm/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -1
  264. package/esm/src/templates/libRoot/lib/___libName__/__libName__.store.js +1 -1
  265. package/esm/src/templates/libRoot/lib/option.js +1 -1
  266. package/esm/src/templates/libRoot/lib/setting/Setting.Template.js +6 -19
  267. package/esm/src/templates/libRoot/lib/setting/Setting.Unit.js +3 -3
  268. package/esm/src/templates/libRoot/lib/setting/Setting.Util.js +8 -2
  269. package/esm/src/templates/libRoot/lib/setting/Setting.View.js +4 -7
  270. package/esm/src/templates/libRoot/lib/setting/Setting.Zone.js +2 -8
  271. package/esm/src/templates/libRoot/lib/setting/setting.constant.js +1 -1
  272. package/esm/src/templates/libRoot/lib/setting/setting.dictionary.js +1 -1
  273. package/esm/src/templates/libRoot/lib/setting/setting.document.js +1 -1
  274. package/esm/src/templates/libRoot/lib/setting/setting.service.js +1 -1
  275. package/esm/src/templates/libRoot/lib/setting/setting.signal.js +1 -1
  276. package/esm/src/templates/libRoot/lib/setting/setting.store.js +1 -1
  277. package/esm/src/templates/libRoot/lib/summary/Summary.Template.js +5 -4
  278. package/esm/src/templates/libRoot/lib/summary/Summary.Unit.js +4 -5
  279. package/esm/src/templates/libRoot/lib/summary/Summary.Util.js +10 -3
  280. package/esm/src/templates/libRoot/lib/summary/Summary.View.js +5 -9
  281. package/esm/src/templates/libRoot/lib/summary/Summary.Zone.js +2 -4
  282. package/esm/src/templates/libRoot/lib/summary/summary.constant.js +1 -1
  283. package/esm/src/templates/libRoot/lib/summary/summary.dictionary.js +1 -1
  284. package/esm/src/templates/libRoot/lib/summary/summary.document.js +1 -1
  285. package/esm/src/templates/libRoot/lib/summary/summary.service.js +1 -1
  286. package/esm/src/templates/libRoot/lib/summary/summary.signal.js +1 -1
  287. package/esm/src/templates/libRoot/lib/summary/summary.store.js +1 -1
  288. package/esm/src/templates/libRoot/lib/user/User.Template.js +2 -3
  289. package/esm/src/templates/libRoot/lib/user/User.Unit.js +4 -5
  290. package/esm/src/templates/libRoot/lib/user/User.Util.js +8 -29
  291. package/esm/src/templates/libRoot/lib/user/User.View.js +2 -4
  292. package/esm/src/templates/libRoot/lib/user/User.Zone.js +6 -3
  293. package/esm/src/templates/libRoot/lib/user/user.constant.js +1 -1
  294. package/esm/src/templates/libRoot/lib/user/user.dictionary.js +1 -1
  295. package/esm/src/templates/libRoot/lib/user/user.document.js +1 -1
  296. package/esm/src/templates/libRoot/lib/user/user.service.js +1 -1
  297. package/esm/src/templates/libRoot/lib/user/user.signal.js +1 -1
  298. package/esm/src/templates/libRoot/lib/user/user.signal.spec.js +1 -1
  299. package/esm/src/templates/libRoot/lib/user/user.signal.test.js +1 -1
  300. package/esm/src/templates/libRoot/lib/user/user.store.js +1 -1
  301. package/esm/src/templates/libRoot/nest/backendLogic.js +1 -1
  302. package/esm/src/templates/libRoot/nest/index.js +1 -1
  303. package/esm/src/templates/libRoot/next/frontendLogic.js +1 -1
  304. package/esm/src/templates/libRoot/next/index.js +1 -1
  305. package/esm/src/templates/libRoot/ui/index.js +1 -1
  306. package/esm/src/templates/module/__Model__.Template.js +1 -1
  307. package/esm/src/templates/module/__Model__.Unit.js +1 -1
  308. package/esm/src/templates/module/__Model__.Util.js +1 -1
  309. package/esm/src/templates/module/__Model__.View.js +1 -1
  310. package/esm/src/templates/module/__Model__.Zone.js +1 -1
  311. package/esm/src/templates/module/__model__.constant.js +1 -1
  312. package/esm/src/templates/module/__model__.dictionary.js +1 -1
  313. package/esm/src/templates/module/__model__.document.js +1 -1
  314. package/esm/src/templates/module/__model__.service.js +1 -1
  315. package/esm/src/templates/module/__model__.signal.js +1 -1
  316. package/esm/src/templates/module/__model__.signal.spec.js +1 -1
  317. package/esm/src/templates/module/__model__.signal.test.js +1 -1
  318. package/esm/src/templates/module/__model__.store.js +1 -1
  319. package/esm/src/templates/module/index.js +1 -1
  320. package/esm/src/templates/moduleRoot/index.js +29 -0
  321. package/esm/src/templates/server.js +31 -13
  322. package/esm/src/templates/workspaceRoot/.gitignore.template +2 -2
  323. package/package.json +1 -1
  324. package/src/application/application.runner.d.ts +2 -3
  325. package/src/application/application.script.d.ts +1 -1
  326. package/src/guidelines/databaseModule/databaseModule.instruction.md +3 -50
  327. package/src/guidelines/scalarModule/scalarModule.instruction.md +0 -3
  328. package/src/library/library.script.d.ts +1 -1
  329. package/src/package/package.runner.d.ts +1 -1
  330. package/src/package/package.script.d.ts +1 -1
  331. package/src/templates/__scalar/__model__/__model__.constant.d.ts +2 -2
  332. package/src/templates/__scalar/__model__/__model__.dictionary.d.ts +2 -2
  333. package/src/templates/__scalar/__model__/__model__.document.d.ts +2 -2
  334. package/src/templates/app/akan.config.d.ts +2 -2
  335. package/src/templates/app/app/[lang]/admin/page.d.ts +2 -2
  336. package/src/templates/app/app/[lang]/layout.d.ts +2 -2
  337. package/src/templates/app/app/[lang]/page.d.ts +2 -2
  338. package/src/templates/app/app/csr.d.ts +2 -2
  339. package/src/templates/app/app/layout.d.ts +2 -2
  340. package/src/templates/app/app/robots.d.ts +2 -2
  341. package/src/templates/app/app/sitemap.d.ts +2 -2
  342. package/src/templates/app/base/baseLogic.d.ts +2 -2
  343. package/src/templates/app/base/index.d.ts +2 -2
  344. package/src/templates/app/common/commonLogic.d.ts +2 -2
  345. package/src/templates/app/common/index.d.ts +2 -2
  346. package/src/templates/app/env/env.client.d.ts +2 -2
  347. package/src/templates/app/env/env.client.type.d.ts +2 -2
  348. package/src/templates/app/env/env.server.d.ts +2 -2
  349. package/src/templates/app/jest.config.d.ts +2 -2
  350. package/src/templates/app/lib/___appName__/__appName__.dictionary.d.ts +2 -2
  351. package/src/templates/app/lib/___appName__/__appName__.service.d.ts +2 -2
  352. package/src/templates/app/lib/___appName__/__appName__.store.d.ts +2 -2
  353. package/src/templates/app/lib/option.d.ts +2 -2
  354. package/src/templates/app/lib/setting/Setting.Template.d.ts +2 -2
  355. package/src/templates/app/lib/setting/Setting.Unit.d.ts +2 -2
  356. package/src/templates/app/lib/setting/Setting.Util.d.ts +2 -2
  357. package/src/templates/app/lib/setting/Setting.View.d.ts +2 -2
  358. package/src/templates/app/lib/setting/Setting.Zone.d.ts +2 -2
  359. package/src/templates/app/lib/setting/setting.constant.d.ts +2 -2
  360. package/src/templates/app/lib/setting/setting.dictionary.d.ts +2 -2
  361. package/src/templates/app/lib/setting/setting.document.d.ts +2 -2
  362. package/src/templates/app/lib/setting/setting.service.d.ts +2 -2
  363. package/src/templates/app/lib/setting/setting.signal.d.ts +2 -2
  364. package/src/templates/app/lib/setting/setting.store.d.ts +2 -2
  365. package/src/templates/app/lib/summary/Summary.Template.d.ts +2 -2
  366. package/src/templates/app/lib/summary/Summary.Unit.d.ts +2 -2
  367. package/src/templates/app/lib/summary/Summary.Util.d.ts +2 -2
  368. package/src/templates/app/lib/summary/Summary.View.d.ts +2 -2
  369. package/src/templates/app/lib/summary/Summary.Zone.d.ts +2 -2
  370. package/src/templates/app/lib/summary/summary.constant.d.ts +2 -2
  371. package/src/templates/app/lib/summary/summary.dictionary.d.ts +2 -2
  372. package/src/templates/app/lib/summary/summary.document.d.ts +2 -2
  373. package/src/templates/app/lib/summary/summary.service.d.ts +2 -2
  374. package/src/templates/app/lib/summary/summary.signal.d.ts +2 -2
  375. package/src/templates/app/lib/summary/summary.store.d.ts +2 -2
  376. package/src/templates/app/lib/user/User.Template.d.ts +2 -2
  377. package/src/templates/app/lib/user/User.Unit.d.ts +2 -2
  378. package/src/templates/app/lib/user/User.Util.d.ts +2 -2
  379. package/src/templates/app/lib/user/User.View.d.ts +2 -2
  380. package/src/templates/app/lib/user/User.Zone.d.ts +2 -2
  381. package/src/templates/app/lib/user/user.constant.d.ts +2 -2
  382. package/src/templates/app/lib/user/user.dictionary.d.ts +2 -2
  383. package/src/templates/app/lib/user/user.document.d.ts +2 -2
  384. package/src/templates/app/lib/user/user.service.d.ts +2 -2
  385. package/src/templates/app/lib/user/user.signal.d.ts +2 -2
  386. package/src/templates/app/lib/user/user.signal.spec.d.ts +2 -2
  387. package/src/templates/app/lib/user/user.signal.test.d.ts +2 -2
  388. package/src/templates/app/lib/user/user.store.d.ts +2 -2
  389. package/src/templates/app/main.d.ts +2 -2
  390. package/src/templates/app/middleware.d.ts +2 -2
  391. package/src/templates/app/nest/backendLogic.d.ts +2 -2
  392. package/src/templates/app/nest/index.d.ts +2 -2
  393. package/src/templates/app/next/frontendLogic.d.ts +2 -2
  394. package/src/templates/app/next/index.d.ts +2 -2
  395. package/src/templates/app/ui/UiComponent.d.ts +2 -2
  396. package/src/templates/app/ui/index.d.ts +2 -2
  397. package/src/templates/client.d.ts +2 -2
  398. package/src/templates/crudPages/[__model__Id]/edit/page.d.ts +2 -2
  399. package/src/templates/crudPages/[__model__Id]/page.d.ts +2 -2
  400. package/src/templates/crudPages/new/page.d.ts +2 -2
  401. package/src/templates/crudPages/page.d.ts +2 -2
  402. package/src/templates/crudSinglePage/page.d.ts +2 -2
  403. package/src/templates/index.d.ts +2 -2
  404. package/src/templates/lib/__lib/extends/summary.constant.d.ts +2 -2
  405. package/src/templates/lib/__lib/lib.constant.d.ts +2 -2
  406. package/src/templates/lib/__lib/lib.dictionary.d.ts +2 -2
  407. package/src/templates/lib/__lib/lib.document.d.ts +2 -2
  408. package/src/templates/lib/__lib/lib.service.d.ts +2 -2
  409. package/src/templates/lib/__lib/lib.signal.d.ts +2 -2
  410. package/src/templates/lib/__lib/lib.store.d.ts +2 -2
  411. package/src/templates/lib/cnst.d.ts +2 -2
  412. package/src/templates/lib/cnst_.d.ts +2 -2
  413. package/src/templates/lib/db.d.ts +2 -2
  414. package/src/templates/lib/dict.d.ts +2 -2
  415. package/src/templates/lib/fetch.d.ts +2 -2
  416. package/src/templates/lib/sig.d.ts +2 -2
  417. package/src/templates/lib/srv.d.ts +2 -2
  418. package/src/templates/lib/st.d.ts +2 -2
  419. package/src/templates/lib/store.d.ts +2 -2
  420. package/src/templates/lib/usePage.d.ts +2 -2
  421. package/src/templates/libRoot/akan.config.d.ts +1 -1
  422. package/src/templates/libRoot/base/baseLogic.d.ts +1 -1
  423. package/src/templates/libRoot/base/index.d.ts +1 -1
  424. package/src/templates/libRoot/common/commonLogic.d.ts +1 -1
  425. package/src/templates/libRoot/common/index.d.ts +1 -1
  426. package/src/templates/libRoot/jest.config.d.ts +2 -2
  427. package/src/templates/libRoot/lib/___libName__/__libName__.dictionary.d.ts +1 -1
  428. package/src/templates/libRoot/lib/___libName__/__libName__.service.d.ts +1 -1
  429. package/src/templates/libRoot/lib/___libName__/__libName__.store.d.ts +1 -1
  430. package/src/templates/libRoot/lib/option.d.ts +2 -2
  431. package/src/templates/libRoot/lib/setting/Setting.Template.d.ts +2 -2
  432. package/src/templates/libRoot/lib/setting/Setting.Unit.d.ts +2 -2
  433. package/src/templates/libRoot/lib/setting/Setting.Util.d.ts +2 -2
  434. package/src/templates/libRoot/lib/setting/Setting.View.d.ts +2 -2
  435. package/src/templates/libRoot/lib/setting/Setting.Zone.d.ts +2 -2
  436. package/src/templates/libRoot/lib/setting/setting.constant.d.ts +2 -2
  437. package/src/templates/libRoot/lib/setting/setting.dictionary.d.ts +2 -2
  438. package/src/templates/libRoot/lib/setting/setting.document.d.ts +2 -2
  439. package/src/templates/libRoot/lib/setting/setting.service.d.ts +2 -2
  440. package/src/templates/libRoot/lib/setting/setting.signal.d.ts +2 -2
  441. package/src/templates/libRoot/lib/setting/setting.store.d.ts +2 -2
  442. package/src/templates/libRoot/lib/summary/Summary.Template.d.ts +2 -2
  443. package/src/templates/libRoot/lib/summary/Summary.Unit.d.ts +2 -2
  444. package/src/templates/libRoot/lib/summary/Summary.Util.d.ts +2 -2
  445. package/src/templates/libRoot/lib/summary/Summary.View.d.ts +2 -2
  446. package/src/templates/libRoot/lib/summary/Summary.Zone.d.ts +2 -2
  447. package/src/templates/libRoot/lib/summary/summary.constant.d.ts +2 -2
  448. package/src/templates/libRoot/lib/summary/summary.dictionary.d.ts +2 -2
  449. package/src/templates/libRoot/lib/summary/summary.document.d.ts +2 -2
  450. package/src/templates/libRoot/lib/summary/summary.service.d.ts +2 -2
  451. package/src/templates/libRoot/lib/summary/summary.signal.d.ts +2 -2
  452. package/src/templates/libRoot/lib/summary/summary.store.d.ts +2 -2
  453. package/src/templates/libRoot/lib/user/User.Template.d.ts +2 -2
  454. package/src/templates/libRoot/lib/user/User.Unit.d.ts +2 -2
  455. package/src/templates/libRoot/lib/user/User.Util.d.ts +2 -2
  456. package/src/templates/libRoot/lib/user/User.View.d.ts +2 -2
  457. package/src/templates/libRoot/lib/user/User.Zone.d.ts +2 -2
  458. package/src/templates/libRoot/lib/user/user.constant.d.ts +2 -2
  459. package/src/templates/libRoot/lib/user/user.dictionary.d.ts +2 -2
  460. package/src/templates/libRoot/lib/user/user.document.d.ts +2 -2
  461. package/src/templates/libRoot/lib/user/user.service.d.ts +2 -2
  462. package/src/templates/libRoot/lib/user/user.signal.d.ts +2 -2
  463. package/src/templates/libRoot/lib/user/user.signal.spec.d.ts +2 -2
  464. package/src/templates/libRoot/lib/user/user.signal.test.d.ts +2 -2
  465. package/src/templates/libRoot/lib/user/user.store.d.ts +2 -2
  466. package/src/templates/libRoot/nest/backendLogic.d.ts +1 -1
  467. package/src/templates/libRoot/nest/index.d.ts +1 -1
  468. package/src/templates/libRoot/next/frontendLogic.d.ts +1 -1
  469. package/src/templates/libRoot/next/index.d.ts +1 -1
  470. package/src/templates/libRoot/ui/index.d.ts +1 -1
  471. package/src/templates/module/__Model__.Template.d.ts +2 -2
  472. package/src/templates/module/__Model__.Unit.d.ts +2 -2
  473. package/src/templates/module/__Model__.Util.d.ts +2 -2
  474. package/src/templates/module/__Model__.View.d.ts +2 -2
  475. package/src/templates/module/__Model__.Zone.d.ts +2 -2
  476. package/src/templates/module/__model__.constant.d.ts +2 -2
  477. package/src/templates/module/__model__.dictionary.d.ts +2 -2
  478. package/src/templates/module/__model__.document.d.ts +2 -2
  479. package/src/templates/module/__model__.service.d.ts +2 -2
  480. package/src/templates/module/__model__.signal.d.ts +2 -2
  481. package/src/templates/module/__model__.signal.spec.d.ts +2 -2
  482. package/src/templates/module/__model__.signal.test.d.ts +2 -2
  483. package/src/templates/module/__model__.store.d.ts +2 -2
  484. package/src/templates/module/index.d.ts +2 -2
  485. package/src/templates/moduleRoot/index.d.ts +11 -0
  486. package/src/templates/server.d.ts +2 -2
  487. package/cjs/src/templates/app/app/[lang]/unknown/page.js +0 -51
  488. package/cjs/src/templates/app/lib/___appName__/_server.js +0 -34
  489. package/cjs/src/templates/app/lib/setting/_server.js +0 -48
  490. package/cjs/src/templates/app/lib/setting/index.js +0 -61
  491. package/cjs/src/templates/app/lib/summary/_server.js +0 -48
  492. package/cjs/src/templates/app/lib/summary/index.js +0 -67
  493. package/cjs/src/templates/app/lib/user/_server.js +0 -48
  494. package/cjs/src/templates/app/lib/user/index.js +0 -61
  495. package/cjs/src/templates/lib/__scalar/_server.js +0 -39
  496. package/cjs/src/templates/libRoot/lib/___libName__/_server.js +0 -34
  497. package/cjs/src/templates/libRoot/lib/setting/_server.js +0 -48
  498. package/cjs/src/templates/libRoot/lib/setting/index.js +0 -61
  499. package/cjs/src/templates/libRoot/lib/summary/_server.js +0 -48
  500. package/cjs/src/templates/libRoot/lib/summary/index.js +0 -67
  501. package/cjs/src/templates/libRoot/lib/user/_server.js +0 -48
  502. package/cjs/src/templates/module/_server.js +0 -47
  503. package/esm/src/templates/app/app/[lang]/unknown/page.js +0 -31
  504. package/esm/src/templates/app/lib/___appName__/_server.js +0 -14
  505. package/esm/src/templates/app/lib/setting/_server.js +0 -28
  506. package/esm/src/templates/app/lib/setting/index.js +0 -41
  507. package/esm/src/templates/app/lib/summary/_server.js +0 -28
  508. package/esm/src/templates/app/lib/summary/index.js +0 -47
  509. package/esm/src/templates/app/lib/user/_server.js +0 -28
  510. package/esm/src/templates/app/lib/user/index.js +0 -41
  511. package/esm/src/templates/lib/__scalar/_server.js +0 -19
  512. package/esm/src/templates/libRoot/lib/___libName__/_server.js +0 -14
  513. package/esm/src/templates/libRoot/lib/setting/_server.js +0 -28
  514. package/esm/src/templates/libRoot/lib/setting/index.js +0 -41
  515. package/esm/src/templates/libRoot/lib/summary/_server.js +0 -28
  516. package/esm/src/templates/libRoot/lib/summary/index.js +0 -47
  517. package/esm/src/templates/libRoot/lib/user/_server.js +0 -28
  518. package/esm/src/templates/libRoot/lib/user/index.js +0 -41
  519. package/esm/src/templates/module/_server.js +0 -27
  520. package/src/templates/app/app/[lang]/unknown/page.d.ts +0 -9
  521. package/src/templates/app/lib/___appName__/_server.d.ts +0 -7
  522. package/src/templates/app/lib/setting/_server.d.ts +0 -6
  523. package/src/templates/app/lib/setting/index.d.ts +0 -9
  524. package/src/templates/app/lib/summary/_server.d.ts +0 -6
  525. package/src/templates/app/lib/summary/index.d.ts +0 -9
  526. package/src/templates/app/lib/user/_server.d.ts +0 -6
  527. package/src/templates/app/lib/user/index.d.ts +0 -9
  528. package/src/templates/lib/__scalar/_server.d.ts +0 -4
  529. package/src/templates/libRoot/lib/___libName__/_server.d.ts +0 -7
  530. package/src/templates/libRoot/lib/setting/_server.d.ts +0 -6
  531. package/src/templates/libRoot/lib/setting/index.d.ts +0 -9
  532. package/src/templates/libRoot/lib/summary/_server.d.ts +0 -6
  533. package/src/templates/libRoot/lib/summary/index.d.ts +0 -9
  534. package/src/templates/libRoot/lib/user/_server.d.ts +0 -6
  535. package/src/templates/libRoot/lib/user/index.d.ts +0 -9
  536. package/src/templates/module/_server.d.ts +0 -8
package/cjs/index.js CHANGED
@@ -142,6 +142,9 @@ var Logger = class _Logger {
142
142
  this.level = level;
143
143
  this.#levelIdx = logLevels.findIndex((l) => l === level);
144
144
  }
145
+ static isVerbose() {
146
+ return this.#levelIdx <= 1;
147
+ }
145
148
  name;
146
149
  constructor(name) {
147
150
  this.name = name;
@@ -400,8 +403,8 @@ var fs3 = __toESM(require("fs"));
400
403
  var import_ora2 = __toESM(require("ora"));
401
404
  var ts = __toESM(require("typescript"));
402
405
  var parseTsConfig = (tsConfigPath = "./tsconfig.json") => {
403
- const configFile = ts.readConfigFile(tsConfigPath, (path9) => {
404
- return ts.sys.readFile(path9);
406
+ const configFile = ts.readConfigFile(tsConfigPath, (path10) => {
407
+ return ts.sys.readFile(path10);
405
408
  });
406
409
  return ts.parseJsonConfigFileContent(
407
410
  configFile.config,
@@ -720,47 +723,12 @@ export default getNextConfig(config, appInfo);
720
723
 
721
724
  // pkgs/@akanjs/config/src/types.ts
722
725
  var archs = ["amd64", "arm64"];
723
- var getDefaultFileScan = () => ({
724
- constants: {
725
- databases: [],
726
- scalars: []
727
- },
728
- dictionary: {
729
- databases: [],
730
- services: [],
731
- scalars: []
732
- },
733
- documents: {
734
- databases: [],
735
- scalars: []
736
- },
737
- services: {
738
- databases: [],
739
- services: [],
740
- scalars: []
741
- },
742
- signal: {
743
- databases: [],
744
- services: [],
745
- scalars: []
746
- },
747
- store: {
748
- databases: [],
749
- services: [],
750
- scalars: []
751
- },
752
- components: {
753
- databases: [],
754
- services: [],
755
- scalars: []
756
- }
757
- });
758
726
 
759
727
  // pkgs/@akanjs/config/src/akanConfig.ts
760
728
  var import_meta = {};
761
729
  var jiti = (0, import_jiti.createJiti)(import_meta.url);
762
730
  var makeAppConfig = (config, props) => {
763
- const { name, repoName, serveDomain, env, command = "build" } = props;
731
+ const { name, repoName } = props;
764
732
  return {
765
733
  rootLib: config.rootLib,
766
734
  libs: config.libs ?? [],
@@ -906,18 +874,254 @@ var import_child_process = require("child_process");
906
874
  var import_dotenv = __toESM(require("dotenv"));
907
875
  var import_fs4 = __toESM(require("fs"));
908
876
  var import_promises = __toESM(require("fs/promises"));
877
+ var import_path4 = __toESM(require("path"));
878
+
879
+ // pkgs/@akanjs/devkit/src/getDirname.ts
880
+ var import_path2 = __toESM(require("path"));
881
+ var getDirname = (url) => import_path2.default.dirname(new URL(url).pathname);
882
+
883
+ // pkgs/@akanjs/devkit/src/linter.ts
884
+ var import_chalk = __toESM(require("chalk"));
885
+ var import_eslint = require("eslint");
886
+ var fs5 = __toESM(require("fs"));
887
+ var path3 = __toESM(require("path"));
888
+ var Linter = class {
889
+ #logger = new Logger("Linter");
890
+ #eslint;
891
+ lintRoot;
892
+ constructor(cwdPath) {
893
+ this.lintRoot = this.#findEslintRootPath(cwdPath);
894
+ this.#eslint = new import_eslint.ESLint({ cwd: this.lintRoot, errorOnUnmatchedPattern: false });
895
+ }
896
+ #findEslintRootPath(dir) {
897
+ const configPath2 = path3.join(dir, "eslint.config.ts");
898
+ if (fs5.existsSync(configPath2))
899
+ return dir;
900
+ const parentDir = path3.dirname(dir);
901
+ return this.#findEslintRootPath(parentDir);
902
+ }
903
+ async lint(filePath, { fix = false, dryRun = false } = {}) {
904
+ if (fix)
905
+ return await this.fixFile(filePath, dryRun);
906
+ return await this.lintFile(filePath);
907
+ }
908
+ /**
909
+ * Lint a single file using ESLint
910
+ * @param filePath - Path to the file to lint
911
+ * @returns Array of ESLint results
912
+ */
913
+ async lintFile(filePath) {
914
+ if (!fs5.existsSync(filePath))
915
+ throw new Error(`File not found: ${filePath}`);
916
+ const isIgnored = await this.#eslint.isPathIgnored(filePath);
917
+ if (isIgnored) {
918
+ this.#logger.warn(`File ${filePath} is ignored by ESLint configuration`);
919
+ return { fixed: false, results: [], errors: [], warnings: [] };
920
+ }
921
+ const results = await this.#eslint.lintFiles([filePath]);
922
+ const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
923
+ const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
924
+ return { fixed: false, results, errors, warnings };
925
+ }
926
+ /**
927
+ * Format lint results for console output
928
+ * @param results - Array of ESLint results
929
+ * @returns Formatted string
930
+ */
931
+ formatLintResults(results) {
932
+ if (results.length === 0)
933
+ return "No files to lint";
934
+ const output = [];
935
+ let totalErrors = 0;
936
+ let totalWarnings = 0;
937
+ results.forEach((result) => {
938
+ totalErrors += result.errorCount;
939
+ totalWarnings += result.warningCount;
940
+ if (result.messages.length > 0) {
941
+ output.push(`
942
+ ${import_chalk.default.cyan(result.filePath)}`);
943
+ let sourceLines = [];
944
+ if (fs5.existsSync(result.filePath)) {
945
+ try {
946
+ const sourceContent = fs5.readFileSync(result.filePath, "utf8");
947
+ sourceLines = sourceContent.split("\n");
948
+ } catch (error) {
949
+ }
950
+ }
951
+ result.messages.forEach((message) => {
952
+ const type = message.severity === 2 ? "error" : "warning";
953
+ const typeColor = message.severity === 2 ? import_chalk.default.red : import_chalk.default.yellow;
954
+ const icon = message.severity === 2 ? "\u274C" : "\u26A0\uFE0F";
955
+ const ruleInfo = message.ruleId ? import_chalk.default.dim(` (${message.ruleId})`) : "";
956
+ output.push(`
957
+ ${icon} ${typeColor(type)}: ${message.message}${ruleInfo}`);
958
+ output.push(` ${import_chalk.default.gray("at")} ${result.filePath}:${import_chalk.default.bold(`${message.line}:${message.column}`)}`);
959
+ if (sourceLines.length > 0 && message.line <= sourceLines.length) {
960
+ const sourceLine = sourceLines[message.line - 1];
961
+ const lineNumber = message.line.toString().padStart(5, " ");
962
+ output.push(`
963
+ ${import_chalk.default.dim(lineNumber + " |")} ${sourceLine}`);
964
+ const underlinePrefix = " ".repeat(message.column - 1);
965
+ const underlineLength = message.endColumn ? message.endColumn - message.column : 1;
966
+ const underline = "^".repeat(Math.max(1, underlineLength));
967
+ output.push(`${import_chalk.default.dim(" ".repeat(lineNumber.length) + " |")} ${underlinePrefix}${typeColor(underline)}`);
968
+ }
969
+ });
970
+ }
971
+ });
972
+ if (totalErrors === 0 && totalWarnings === 0)
973
+ return import_chalk.default.bold("\u2705 No ESLint errors or warnings found");
974
+ const errorText = totalErrors > 0 ? import_chalk.default.red(`${totalErrors} error(s)`) : "0 errors";
975
+ const warningText = totalWarnings > 0 ? import_chalk.default.yellow(`${totalWarnings} warning(s)`) : "0 warnings";
976
+ const summary = [`
977
+ ${errorText}, ${warningText} found`];
978
+ return summary.concat(output).join("\n");
979
+ }
980
+ /**
981
+ * Get detailed lint information
982
+ * @param filePath - Path to the file to lint
983
+ * @returns Object containing detailed lint information
984
+ */
985
+ async getDetailedLintInfo(filePath) {
986
+ const { results } = await this.lintFile(filePath);
987
+ const details = results.flatMap(
988
+ (result) => result.messages.map((message) => ({
989
+ line: message.line,
990
+ column: message.column,
991
+ message: message.message,
992
+ ruleId: message.ruleId,
993
+ severity: message.severity === 2 ? "error" : "warning",
994
+ fix: message.fix,
995
+ suggestions: message.suggestions
996
+ }))
997
+ );
998
+ const stats = results.reduce(
999
+ (acc, result) => ({
1000
+ errorCount: acc.errorCount + result.errorCount,
1001
+ warningCount: acc.warningCount + result.warningCount,
1002
+ fixableErrorCount: acc.fixableErrorCount + result.fixableErrorCount,
1003
+ fixableWarningCount: acc.fixableWarningCount + result.fixableWarningCount
1004
+ }),
1005
+ { errorCount: 0, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0 }
1006
+ );
1007
+ return { results, details, stats };
1008
+ }
1009
+ /**
1010
+ * Check if a file has lint errors
1011
+ * @param filePath - Path to the file to check
1012
+ * @returns true if there are no errors, false otherwise
1013
+ */
1014
+ async hasNoLintErrors(filePath) {
1015
+ try {
1016
+ const { results } = await this.lintFile(filePath);
1017
+ return results.every((result) => result.errorCount === 0);
1018
+ } catch (error) {
1019
+ return false;
1020
+ }
1021
+ }
1022
+ /**
1023
+ * Get only error messages (excluding warnings)
1024
+ * @param filePath - Path to the file to lint
1025
+ * @returns Array of error messages
1026
+ */
1027
+ async getErrors(filePath) {
1028
+ const { results } = await this.lintFile(filePath);
1029
+ return results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
1030
+ }
1031
+ /**
1032
+ * Get only warning messages
1033
+ * @param filePath - Path to the file to lint
1034
+ * @returns Array of warning messages
1035
+ */
1036
+ async getWarnings(filePath) {
1037
+ const { results } = await this.lintFile(filePath);
1038
+ return results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
1039
+ }
1040
+ /**
1041
+ * Fix lint errors automatically
1042
+ * @param filePath - Path to the file to fix
1043
+ * @param dryRun - If true, returns the fixed content without writing to file
1044
+ * @returns Fixed content and remaining issues
1045
+ */
1046
+ async fixFile(filePath, dryRun = false) {
1047
+ if (!fs5.existsSync(filePath))
1048
+ throw new Error(`File not found: ${filePath}`);
1049
+ const eslint = new import_eslint.ESLint({ cwd: this.lintRoot, fix: true });
1050
+ const results = await eslint.lintFiles([filePath]);
1051
+ const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
1052
+ const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
1053
+ if (!dryRun)
1054
+ await import_eslint.ESLint.outputFixes(results);
1055
+ const fixedResult = results[0];
1056
+ return { fixed: fixedResult.output !== void 0, output: fixedResult.output, results, errors, warnings };
1057
+ }
1058
+ /**
1059
+ * Get ESLint configuration for a file
1060
+ * @param filePath - Path to the file
1061
+ * @returns ESLint configuration object
1062
+ */
1063
+ async getConfigForFile(filePath) {
1064
+ const eslint = new import_eslint.ESLint();
1065
+ const config = await eslint.calculateConfigForFile(filePath);
1066
+ return config;
1067
+ }
1068
+ /**
1069
+ * Get rules that are causing errors in a file
1070
+ * @param filePath - Path to the file to check
1071
+ * @returns Object mapping rule IDs to their error counts
1072
+ */
1073
+ async getProblematicRules(filePath) {
1074
+ const { results } = await this.lintFile(filePath);
1075
+ const ruleCounts = {};
1076
+ results.forEach((result) => {
1077
+ result.messages.forEach((message) => {
1078
+ if (message.ruleId)
1079
+ ruleCounts[message.ruleId] = (ruleCounts[message.ruleId] || 0) + 1;
1080
+ });
1081
+ });
1082
+ return ruleCounts;
1083
+ }
1084
+ };
1085
+
1086
+ // pkgs/@akanjs/devkit/src/scanInfo.ts
909
1087
  var import_path3 = __toESM(require("path"));
910
1088
 
911
1089
  // pkgs/@akanjs/devkit/src/dependencyScanner.ts
912
- var fs5 = __toESM(require("fs"));
913
- var path2 = __toESM(require("path"));
1090
+ var fs6 = __toESM(require("fs"));
1091
+ var path4 = __toESM(require("path"));
914
1092
  var ts2 = __toESM(require("typescript"));
915
1093
  var TypeScriptDependencyScanner = class {
916
- constructor(directory) {
917
- this.directory = directory;
918
- }
919
1094
  #fileDependencies = /* @__PURE__ */ new Map();
920
1095
  #visitedFiles = /* @__PURE__ */ new Set();
1096
+ directory;
1097
+ tsconfig;
1098
+ rootPackageJson;
1099
+ constructor(directory, { tsconfig, rootPackageJson }) {
1100
+ this.directory = directory;
1101
+ this.tsconfig = tsconfig;
1102
+ this.rootPackageJson = rootPackageJson;
1103
+ }
1104
+ async getMonorepoDependencies(projectName) {
1105
+ const npmSet = new Set(
1106
+ Object.keys({ ...this.rootPackageJson.dependencies, ...this.rootPackageJson.devDependencies })
1107
+ );
1108
+ const pkgPathSet = new Set(
1109
+ Object.keys(this.tsconfig.compilerOptions.paths ?? {}).filter((path10) => this.tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
1110
+ );
1111
+ const libPathSet = new Set(
1112
+ Object.keys(this.tsconfig.compilerOptions.paths ?? {}).filter((path10) => this.tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("libs/"))).map((path10) => path10.replace("/*", ""))
1113
+ );
1114
+ const [npmDepSet, pkgPathDepSet, libPathDepSet] = await this.getImportSets([npmSet, pkgPathSet, libPathSet]);
1115
+ const pkgDeps = [...pkgPathDepSet].map((path10) => {
1116
+ const pathSplitLength = path10.split("/").length;
1117
+ return (this.tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1118
+ });
1119
+ const libDeps = [...libPathDepSet].map((path10) => {
1120
+ const pathSplitLength = path10.split("/").length;
1121
+ return (this.tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1122
+ }).filter((libName) => libName !== projectName);
1123
+ return { pkgDeps, libDeps, npmDeps: [...npmDepSet] };
1124
+ }
921
1125
  async getImportSets(depSets) {
922
1126
  const fileDependencies = await this.getDependencies();
923
1127
  const importedDepSets = new Array(depSets.length);
@@ -954,9 +1158,9 @@ var TypeScriptDependencyScanner = class {
954
1158
  async #findTypeScriptFiles(directory) {
955
1159
  const files = [];
956
1160
  const processDirectory = async (dir) => {
957
- const entries = await fs5.promises.readdir(dir, { withFileTypes: true });
1161
+ const entries = await fs6.promises.readdir(dir, { withFileTypes: true });
958
1162
  for (const entry of entries) {
959
- const fullPath = path2.join(dir, entry.name);
1163
+ const fullPath = path4.join(dir, entry.name);
960
1164
  if (entry.isDirectory()) {
961
1165
  if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
962
1166
  await processDirectory(fullPath);
@@ -972,26 +1176,26 @@ var TypeScriptDependencyScanner = class {
972
1176
  return;
973
1177
  this.#visitedFiles.add(filePath);
974
1178
  try {
975
- const fileContent = await fs5.promises.readFile(filePath, "utf-8");
1179
+ const fileContent = await fs6.promises.readFile(filePath, "utf-8");
976
1180
  const imports = this.#extractImports(fileContent, filePath);
977
1181
  const resolvedImports = imports.map((importPath) => {
978
1182
  if (importPath.startsWith(".")) {
979
- const resolvedPath = "./" + path2.join(path2.relative(baseDir, filePath), importPath);
1183
+ const resolvedPath = "./" + path4.join(path4.relative(baseDir, filePath), importPath);
980
1184
  return this.#ensureExtension(resolvedPath);
981
1185
  }
982
1186
  return importPath;
983
1187
  });
984
- const relativePath = path2.relative(baseDir, filePath);
1188
+ const relativePath = path4.relative(baseDir, filePath);
985
1189
  this.#fileDependencies.set(relativePath, resolvedImports);
986
1190
  } catch (error) {
987
1191
  }
988
1192
  }
989
1193
  #ensureExtension(filePath) {
990
- if (fs5.existsSync(`${filePath}.ts`))
1194
+ if (fs6.existsSync(`${filePath}.ts`))
991
1195
  return `${filePath}.ts`;
992
- else if (fs5.existsSync(`${filePath}.tsx`))
1196
+ else if (fs6.existsSync(`${filePath}.tsx`))
993
1197
  return `${filePath}.tsx`;
994
- else if (fs5.existsSync(filePath))
1198
+ else if (fs6.existsSync(filePath))
995
1199
  return filePath;
996
1200
  return `${filePath}.ts`;
997
1201
  }
@@ -1055,217 +1259,442 @@ var TypeScriptDependencyScanner = class {
1055
1259
  }
1056
1260
  };
1057
1261
 
1058
- // pkgs/@akanjs/devkit/src/getDirname.ts
1059
- var import_path2 = __toESM(require("path"));
1060
- var getDirname = (url) => import_path2.default.dirname(new URL(url).pathname);
1061
-
1062
- // pkgs/@akanjs/devkit/src/linter.ts
1063
- var import_chalk = __toESM(require("chalk"));
1064
- var import_eslint = require("eslint");
1065
- var fs6 = __toESM(require("fs"));
1066
- var path4 = __toESM(require("path"));
1067
- var Linter = class {
1068
- #logger = new Logger("Linter");
1069
- #eslint;
1070
- lintRoot;
1071
- constructor(cwdPath) {
1072
- this.lintRoot = this.#findEslintRootPath(cwdPath);
1073
- this.#eslint = new import_eslint.ESLint({ cwd: this.lintRoot, errorOnUnmatchedPattern: false });
1074
- }
1075
- #findEslintRootPath(dir) {
1076
- const configPath2 = path4.join(dir, "eslint.config.ts");
1077
- if (fs6.existsSync(configPath2))
1078
- return dir;
1079
- const parentDir = path4.dirname(dir);
1080
- return this.#findEslintRootPath(parentDir);
1081
- }
1082
- async lint(filePath, { fix = false, dryRun = false } = {}) {
1083
- if (fix)
1084
- return await this.fixFile(filePath, dryRun);
1085
- return await this.lintFile(filePath);
1086
- }
1087
- /**
1088
- * Lint a single file using ESLint
1089
- * @param filePath - Path to the file to lint
1090
- * @returns Array of ESLint results
1091
- */
1092
- async lintFile(filePath) {
1093
- if (!fs6.existsSync(filePath))
1094
- throw new Error(`File not found: ${filePath}`);
1095
- const isIgnored = await this.#eslint.isPathIgnored(filePath);
1096
- if (isIgnored) {
1097
- this.#logger.warn(`File ${filePath} is ignored by ESLint configuration`);
1098
- return { fixed: false, results: [], errors: [], warnings: [] };
1099
- }
1100
- const results = await this.#eslint.lintFiles([filePath]);
1101
- const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
1102
- const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
1103
- return { fixed: false, results, errors, warnings };
1104
- }
1105
- /**
1106
- * Format lint results for console output
1107
- * @param results - Array of ESLint results
1108
- * @returns Formatted string
1109
- */
1110
- formatLintResults(results) {
1111
- if (results.length === 0)
1112
- return "No files to lint";
1113
- const output = [];
1114
- let totalErrors = 0;
1115
- let totalWarnings = 0;
1116
- results.forEach((result) => {
1117
- totalErrors += result.errorCount;
1118
- totalWarnings += result.warningCount;
1119
- if (result.messages.length > 0) {
1120
- output.push(`
1121
- ${import_chalk.default.cyan(result.filePath)}`);
1122
- let sourceLines = [];
1123
- if (fs6.existsSync(result.filePath)) {
1124
- try {
1125
- const sourceContent = fs6.readFileSync(result.filePath, "utf8");
1126
- sourceLines = sourceContent.split("\n");
1127
- } catch (error) {
1128
- }
1129
- }
1130
- result.messages.forEach((message) => {
1131
- const type = message.severity === 2 ? "error" : "warning";
1132
- const typeColor = message.severity === 2 ? import_chalk.default.red : import_chalk.default.yellow;
1133
- const icon = message.severity === 2 ? "\u274C" : "\u26A0\uFE0F";
1134
- const ruleInfo = message.ruleId ? import_chalk.default.dim(` (${message.ruleId})`) : "";
1135
- output.push(`
1136
- ${icon} ${typeColor(type)}: ${message.message}${ruleInfo}`);
1137
- output.push(` ${import_chalk.default.gray("at")} ${result.filePath}:${import_chalk.default.bold(`${message.line}:${message.column}`)}`);
1138
- if (sourceLines.length > 0 && message.line <= sourceLines.length) {
1139
- const sourceLine = sourceLines[message.line - 1];
1140
- const lineNumber = message.line.toString().padStart(5, " ");
1141
- output.push(`
1142
- ${import_chalk.default.dim(lineNumber + " |")} ${sourceLine}`);
1143
- const underlinePrefix = " ".repeat(message.column - 1);
1144
- const underlineLength = message.endColumn ? message.endColumn - message.column : 1;
1145
- const underline = "^".repeat(Math.max(1, underlineLength));
1146
- output.push(`${import_chalk.default.dim(" ".repeat(lineNumber.length) + " |")} ${underlinePrefix}${typeColor(underline)}`);
1147
- }
1148
- });
1149
- }
1262
+ // pkgs/@akanjs/devkit/src/scanInfo.ts
1263
+ var databaseFileTypes = [
1264
+ "constant",
1265
+ "dictionary",
1266
+ "document",
1267
+ "service",
1268
+ "signal",
1269
+ "store",
1270
+ "template",
1271
+ "unit",
1272
+ "util",
1273
+ "view",
1274
+ "zone"
1275
+ ];
1276
+ var ScanInfo = class {
1277
+ scanResult;
1278
+ name;
1279
+ scalar = /* @__PURE__ */ new Map();
1280
+ service = /* @__PURE__ */ new Map();
1281
+ database = /* @__PURE__ */ new Map();
1282
+ file = Object.fromEntries(
1283
+ databaseFileTypes.map((type) => [
1284
+ type,
1285
+ { all: /* @__PURE__ */ new Set(), databases: /* @__PURE__ */ new Set(), services: /* @__PURE__ */ new Set(), scalars: /* @__PURE__ */ new Set() }
1286
+ ])
1287
+ );
1288
+ constants = /* @__PURE__ */ new Set();
1289
+ dictionaries = /* @__PURE__ */ new Set();
1290
+ documents = /* @__PURE__ */ new Set();
1291
+ services = /* @__PURE__ */ new Set();
1292
+ signals = /* @__PURE__ */ new Set();
1293
+ stores = /* @__PURE__ */ new Set();
1294
+ templates = /* @__PURE__ */ new Set();
1295
+ units = /* @__PURE__ */ new Set();
1296
+ utils = /* @__PURE__ */ new Set();
1297
+ views = /* @__PURE__ */ new Set();
1298
+ zones = /* @__PURE__ */ new Set();
1299
+ static async getScanResult(exec2) {
1300
+ const akanConfig = await exec2.getConfig();
1301
+ const tsconfig = exec2.getTsConfig();
1302
+ const rootPackageJson = exec2.workspace.getPackageJson();
1303
+ const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
1304
+ const { pkgDeps, libDeps, npmDeps } = await scanner.getMonorepoDependencies(exec2.name);
1305
+ const files = {
1306
+ constant: { databases: [], scalars: [] },
1307
+ dictionary: { databases: [], services: [], scalars: [] },
1308
+ document: { databases: [], scalars: [] },
1309
+ service: { databases: [], services: [] },
1310
+ signal: { databases: [], services: [] },
1311
+ store: { databases: [], services: [] },
1312
+ template: { databases: [], services: [], scalars: [] },
1313
+ unit: { databases: [], services: [], scalars: [] },
1314
+ util: { databases: [], services: [], scalars: [] },
1315
+ view: { databases: [], services: [], scalars: [] },
1316
+ zone: { databases: [], services: [], scalars: [] }
1317
+ };
1318
+ const [{ dirs: dirnames }, scalarDirs] = await Promise.all([
1319
+ exec2.getFilesAndDirs("lib"),
1320
+ exec2.readdir("lib/__scalar")
1321
+ ]);
1322
+ const databaseDirs = [];
1323
+ const serviceDirs = [];
1324
+ dirnames.forEach((name) => {
1325
+ if (name.startsWith("_")) {
1326
+ if (name.startsWith("__"))
1327
+ return;
1328
+ else
1329
+ serviceDirs.push(name);
1330
+ } else
1331
+ databaseDirs.push(name);
1150
1332
  });
1151
- if (totalErrors === 0 && totalWarnings === 0)
1152
- return import_chalk.default.bold("\u2705 No ESLint errors or warnings found");
1153
- const errorText = totalErrors > 0 ? import_chalk.default.red(`${totalErrors} error(s)`) : "0 errors";
1154
- const warningText = totalWarnings > 0 ? import_chalk.default.yellow(`${totalWarnings} warning(s)`) : "0 warnings";
1155
- const summary = [`
1156
- ${errorText}, ${warningText} found`];
1157
- return summary.concat(output).join("\n");
1158
- }
1159
- /**
1160
- * Get detailed lint information
1161
- * @param filePath - Path to the file to lint
1162
- * @returns Object containing detailed lint information
1163
- */
1164
- async getDetailedLintInfo(filePath) {
1165
- const { results } = await this.lintFile(filePath);
1166
- const details = results.flatMap(
1167
- (result) => result.messages.map((message) => ({
1168
- line: message.line,
1169
- column: message.column,
1170
- message: message.message,
1171
- ruleId: message.ruleId,
1172
- severity: message.severity === 2 ? "error" : "warning",
1173
- fix: message.fix,
1174
- suggestions: message.suggestions
1175
- }))
1176
- );
1177
- const stats = results.reduce(
1178
- (acc, result) => ({
1179
- errorCount: acc.errorCount + result.errorCount,
1180
- warningCount: acc.warningCount + result.warningCount,
1181
- fixableErrorCount: acc.fixableErrorCount + result.fixableErrorCount,
1182
- fixableWarningCount: acc.fixableWarningCount + result.fixableWarningCount
1333
+ await Promise.all([
1334
+ ...databaseDirs.map(async (name) => {
1335
+ const filenames = await exec2.readdir(import_path3.default.join("lib", name));
1336
+ filenames.forEach((filename) => {
1337
+ if (filename.endsWith(".constant.ts"))
1338
+ files.constant.databases.push(name);
1339
+ else if (filename.endsWith(".dictionary.ts"))
1340
+ files.dictionary.databases.push(name);
1341
+ else if (filename.endsWith(".document.ts"))
1342
+ files.document.databases.push(name);
1343
+ else if (filename.endsWith(".service.ts"))
1344
+ files.service.databases.push(name);
1345
+ else if (filename.endsWith(".signal.ts"))
1346
+ files.signal.databases.push(name);
1347
+ else if (filename.endsWith(".store.ts"))
1348
+ files.store.databases.push(name);
1349
+ else if (filename.endsWith(".Template.tsx"))
1350
+ files.template.databases.push(name);
1351
+ else if (filename.endsWith(".Unit.tsx"))
1352
+ files.unit.databases.push(name);
1353
+ else if (filename.endsWith(".Util.tsx"))
1354
+ files.util.databases.push(name);
1355
+ else if (filename.endsWith(".View.tsx"))
1356
+ files.view.databases.push(name);
1357
+ else if (filename.endsWith(".Zone.tsx"))
1358
+ files.zone.databases.push(name);
1359
+ });
1183
1360
  }),
1184
- { errorCount: 0, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0 }
1361
+ ...serviceDirs.map(async (dirname3) => {
1362
+ const name = dirname3.slice(1);
1363
+ const filenames = await exec2.readdir(import_path3.default.join("lib", dirname3));
1364
+ filenames.forEach((filename) => {
1365
+ if (filename.endsWith(".dictionary.ts"))
1366
+ files.dictionary.services.push(name);
1367
+ else if (filename.endsWith(".service.ts"))
1368
+ files.service.services.push(name);
1369
+ else if (filename.endsWith(".signal.ts"))
1370
+ files.signal.services.push(name);
1371
+ else if (filename.endsWith(".store.ts"))
1372
+ files.store.services.push(name);
1373
+ else if (filename.endsWith(".Template.tsx"))
1374
+ files.template.services.push(name);
1375
+ else if (filename.endsWith(".Unit.tsx"))
1376
+ files.unit.services.push(name);
1377
+ else if (filename.endsWith(".Util.tsx"))
1378
+ files.util.services.push(name);
1379
+ else if (filename.endsWith(".View.tsx"))
1380
+ files.view.services.push(name);
1381
+ else if (filename.endsWith(".Zone.tsx"))
1382
+ files.zone.services.push(name);
1383
+ });
1384
+ }),
1385
+ ...scalarDirs.map(async (name) => {
1386
+ const filenames = await exec2.readdir(import_path3.default.join("lib/__scalar", name));
1387
+ filenames.forEach((filename) => {
1388
+ if (filename.endsWith(".constant.ts"))
1389
+ files.constant.scalars.push(name);
1390
+ else if (filename.endsWith(".dictionary.ts"))
1391
+ files.dictionary.scalars.push(name);
1392
+ else if (filename.endsWith(".document.ts"))
1393
+ files.document.scalars.push(name);
1394
+ else if (filename.endsWith(".Template.tsx"))
1395
+ files.template.scalars.push(name);
1396
+ else if (filename.endsWith(".Unit.tsx"))
1397
+ files.unit.scalars.push(name);
1398
+ else if (filename.endsWith(".Util.tsx"))
1399
+ files.util.scalars.push(name);
1400
+ else if (filename.endsWith(".View.tsx"))
1401
+ files.view.scalars.push(name);
1402
+ else if (filename.endsWith(".Zone.tsx"))
1403
+ files.zone.scalars.push(name);
1404
+ });
1405
+ })
1406
+ ]);
1407
+ const missingLibDeps = [];
1408
+ libDeps.forEach((libName) => {
1409
+ if (!akanConfig.libs.includes(libName))
1410
+ missingLibDeps.push(libName);
1411
+ });
1412
+ if (missingLibDeps.length)
1413
+ throw new Error(
1414
+ `Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
1415
+ );
1416
+ const scanResult = {
1417
+ name: exec2.name,
1418
+ type: exec2.type,
1419
+ repoName: exec2.workspace.repoName,
1420
+ serveDomain: exec2.workspace.getBaseDevEnv().serveDomain,
1421
+ akanConfig,
1422
+ files,
1423
+ libDeps,
1424
+ pkgDeps,
1425
+ dependencies: npmDeps.filter((dep) => !dep.startsWith("@akanjs"))
1426
+ };
1427
+ return scanResult;
1428
+ }
1429
+ constructor(scanResult) {
1430
+ this.name = scanResult.name;
1431
+ this.scanResult = scanResult;
1432
+ Object.entries(scanResult.files).forEach(
1433
+ ([key, value]) => {
1434
+ const { databases, services, scalars } = value;
1435
+ databases.forEach((modelName) => {
1436
+ const model = this.database.get(modelName) ?? /* @__PURE__ */ new Set();
1437
+ model.add(key);
1438
+ this.database.set(modelName, model);
1439
+ this.file[key].all.add(modelName);
1440
+ this.file[key].databases.add(modelName);
1441
+ });
1442
+ services?.forEach((serviceName) => {
1443
+ const service = this.service.get(serviceName) ?? /* @__PURE__ */ new Set();
1444
+ service.add(key);
1445
+ this.service.set(serviceName, service);
1446
+ this.file[key].all.add(serviceName);
1447
+ this.file[key].services.add(serviceName);
1448
+ });
1449
+ scalars?.forEach((scalarName) => {
1450
+ const scalar = this.scalar.get(scalarName) ?? /* @__PURE__ */ new Set();
1451
+ scalar.add(key);
1452
+ this.scalar.set(scalarName, scalar);
1453
+ this.file[key].all.add(scalarName);
1454
+ this.file[key].scalars.add(scalarName);
1455
+ });
1456
+ }
1185
1457
  );
1186
- return { results, details, stats };
1187
1458
  }
1188
- /**
1189
- * Check if a file has lint errors
1190
- * @param filePath - Path to the file to check
1191
- * @returns true if there are no errors, false otherwise
1192
- */
1193
- async hasNoLintErrors(filePath) {
1194
- try {
1195
- const { results } = await this.lintFile(filePath);
1196
- return results.every((result) => result.errorCount === 0);
1197
- } catch (error) {
1198
- return false;
1199
- }
1459
+ getScanResult() {
1460
+ return this.scanResult;
1200
1461
  }
1201
- /**
1202
- * Get only error messages (excluding warnings)
1203
- * @param filePath - Path to the file to lint
1204
- * @returns Array of error messages
1205
- */
1206
- async getErrors(filePath) {
1207
- const { results } = await this.lintFile(filePath);
1208
- return results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
1462
+ getDatabaseModules() {
1463
+ return [...this.database.keys()];
1209
1464
  }
1210
- /**
1211
- * Get only warning messages
1212
- * @param filePath - Path to the file to lint
1213
- * @returns Array of warning messages
1214
- */
1215
- async getWarnings(filePath) {
1216
- const { results } = await this.lintFile(filePath);
1217
- return results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
1465
+ getServiceModules() {
1466
+ return [...this.service.keys()];
1218
1467
  }
1219
- /**
1220
- * Fix lint errors automatically
1221
- * @param filePath - Path to the file to fix
1222
- * @param dryRun - If true, returns the fixed content without writing to file
1223
- * @returns Fixed content and remaining issues
1224
- */
1225
- async fixFile(filePath, dryRun = false) {
1226
- if (!fs6.existsSync(filePath))
1227
- throw new Error(`File not found: ${filePath}`);
1228
- const eslint = new import_eslint.ESLint({ cwd: this.lintRoot, fix: true });
1229
- const results = await eslint.lintFiles([filePath]);
1230
- const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
1231
- const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
1232
- if (!dryRun)
1233
- await import_eslint.ESLint.outputFixes(results);
1234
- const fixedResult = results[0];
1235
- return { fixed: fixedResult.output !== void 0, output: fixedResult.output, results, errors, warnings };
1468
+ getScalarModules() {
1469
+ return [...this.scalar.keys()];
1236
1470
  }
1237
- /**
1238
- * Get ESLint configuration for a file
1239
- * @param filePath - Path to the file
1240
- * @returns ESLint configuration object
1241
- */
1242
- async getConfigForFile(filePath) {
1243
- const eslint = new import_eslint.ESLint();
1244
- const config = await eslint.calculateConfigForFile(filePath);
1245
- return config;
1471
+ };
1472
+ var AppInfo = class _AppInfo extends ScanInfo {
1473
+ type = "app";
1474
+ exec;
1475
+ akanConfig;
1476
+ static appInfos = /* @__PURE__ */ new Map();
1477
+ static async fromExecutor(exec2, options = {}) {
1478
+ const existingAppInfo = this.appInfos.get(exec2.name);
1479
+ if (existingAppInfo && !options.refresh)
1480
+ return existingAppInfo;
1481
+ const scanResult = await super.getScanResult(exec2);
1482
+ await Promise.all(
1483
+ scanResult.libDeps.map(async (libName) => {
1484
+ LibInfo.loadedLibs.add(libName);
1485
+ const libExecutor = LibExecutor.from(exec2, libName);
1486
+ LibInfo.libInfos.set(libName, await LibInfo.fromExecutor(libExecutor));
1487
+ })
1488
+ );
1489
+ const appInfo = new _AppInfo(exec2, scanResult);
1490
+ this.appInfos.set(exec2.name, appInfo);
1491
+ return appInfo;
1492
+ }
1493
+ constructor(exec2, scanResult) {
1494
+ super(scanResult);
1495
+ this.exec = exec2;
1496
+ this.akanConfig = scanResult.akanConfig;
1497
+ }
1498
+ getScanResult() {
1499
+ return this.scanResult;
1500
+ }
1501
+ #sortedLibs = null;
1502
+ #getSortedLibs() {
1503
+ if (this.#sortedLibs)
1504
+ return this.#sortedLibs;
1505
+ const libIndices = LibInfo.getSortedLibIndices();
1506
+ this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
1507
+ const indexA = libIndices.get(libNameA);
1508
+ const indexB = libIndices.get(libNameB);
1509
+ if (indexA === void 0 || indexB === void 0)
1510
+ throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
1511
+ return indexA - indexB;
1512
+ });
1513
+ return this.#sortedLibs;
1514
+ }
1515
+ getLibs() {
1516
+ return this.#getSortedLibs();
1517
+ }
1518
+ getLibInfo(libName) {
1519
+ const libSet = new Set(this.#getSortedLibs());
1520
+ if (!libSet.has(libName))
1521
+ throw new Error(`LibInfo is invalid: ${libName}`);
1522
+ return LibInfo.libInfos.get(libName);
1523
+ }
1524
+ getLibInfos() {
1525
+ return new Map(
1526
+ this.#getSortedLibs().map((libName) => {
1527
+ const libInfo = LibInfo.libInfos.get(libName);
1528
+ if (!libInfo)
1529
+ throw new Error(`LibInfo not found: ${libName}`);
1530
+ return [libName, libInfo];
1531
+ })
1532
+ );
1246
1533
  }
1247
- /**
1248
- * Get rules that are causing errors in a file
1249
- * @param filePath - Path to the file to check
1250
- * @returns Object mapping rule IDs to their error counts
1251
- */
1252
- async getProblematicRules(filePath) {
1253
- const { results } = await this.lintFile(filePath);
1254
- const ruleCounts = {};
1255
- results.forEach((result) => {
1256
- result.messages.forEach((message) => {
1257
- if (message.ruleId)
1258
- ruleCounts[message.ruleId] = (ruleCounts[message.ruleId] || 0) + 1;
1259
- });
1534
+ };
1535
+ var LibInfo = class _LibInfo extends ScanInfo {
1536
+ type = "lib";
1537
+ exec;
1538
+ akanConfig;
1539
+ static loadedLibs = /* @__PURE__ */ new Set();
1540
+ static libInfos = /* @__PURE__ */ new Map();
1541
+ static #sortedLibIndices = null;
1542
+ static getSortedLibIndices() {
1543
+ if (this.#sortedLibIndices)
1544
+ return this.#sortedLibIndices;
1545
+ this.#sortedLibIndices = new Map(
1546
+ [...this.libInfos.entries()].sort(([_, libInfoA], [__, libInfoB]) => libInfoA.akanConfig.libs.includes(libInfoB.name) ? 1 : -1).map(([libName], index) => [libName, index])
1547
+ );
1548
+ return this.#sortedLibIndices;
1549
+ }
1550
+ static async fromExecutor(exec2, { refresh } = {}) {
1551
+ const existingLibInfo = this.libInfos.get(exec2.name);
1552
+ if (existingLibInfo && !refresh)
1553
+ return existingLibInfo;
1554
+ const scanResult = await super.getScanResult(exec2);
1555
+ await Promise.all(
1556
+ scanResult.libDeps.filter((libName) => !this.loadedLibs.has(libName)).map(async (libName) => {
1557
+ this.loadedLibs.add(libName);
1558
+ this.libInfos.set(libName, await _LibInfo.fromExecutor(exec2));
1559
+ })
1560
+ );
1561
+ const libInfo = new _LibInfo(exec2, scanResult);
1562
+ this.libInfos.set(exec2.name, libInfo);
1563
+ this.#sortedLibIndices = null;
1564
+ return libInfo;
1565
+ }
1566
+ constructor(exec2, scanResult) {
1567
+ super(scanResult);
1568
+ this.exec = exec2;
1569
+ this.akanConfig = scanResult.akanConfig;
1570
+ }
1571
+ getScanResult() {
1572
+ return this.scanResult;
1573
+ }
1574
+ #sortedLibs = null;
1575
+ #getSortedLibs() {
1576
+ if (this.#sortedLibs)
1577
+ return this.#sortedLibs;
1578
+ const libs = _LibInfo.getSortedLibIndices();
1579
+ this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
1580
+ const indexA = libs.get(libNameA);
1581
+ const indexB = libs.get(libNameB);
1582
+ if (indexA === void 0 || indexB === void 0)
1583
+ throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
1584
+ return indexA - indexB;
1260
1585
  });
1261
- return ruleCounts;
1586
+ return this.#sortedLibs;
1587
+ }
1588
+ getLibs() {
1589
+ return this.#getSortedLibs();
1590
+ }
1591
+ getLibInfo(libName) {
1592
+ if (!this.getScanResult().akanConfig.libs.includes(libName))
1593
+ return void 0;
1594
+ const libSet = new Set(this.#getSortedLibs());
1595
+ if (!libSet.has(libName))
1596
+ throw new Error(`LibInfo is invalid: ${libName}`);
1597
+ return _LibInfo.libInfos.get(libName);
1598
+ }
1599
+ getLibInfos() {
1600
+ return new Map(
1601
+ this.#getSortedLibs().map((libName) => {
1602
+ const libInfo = _LibInfo.libInfos.get(libName);
1603
+ if (!libInfo)
1604
+ throw new Error(`LibInfo not found: ${libName}`);
1605
+ return [libName, libInfo];
1606
+ })
1607
+ );
1608
+ }
1609
+ };
1610
+ var PkgInfo = class _PkgInfo {
1611
+ exec;
1612
+ name;
1613
+ scanResult;
1614
+ static async getScanResult(exec2) {
1615
+ const tsconfig = exec2.getTsConfig();
1616
+ const rootPackageJson = exec2.workspace.getPackageJson();
1617
+ const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
1618
+ const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
1619
+ const pkgPathSet = new Set(
1620
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
1621
+ );
1622
+ const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
1623
+ const pkgDeps = [...pkgPathDepSet].map((path10) => {
1624
+ const pathSplitLength = path10.split("/").length;
1625
+ return (tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1626
+ }).filter((pkg) => pkg !== this.name);
1627
+ const pkgScanResult = {
1628
+ name: this.name,
1629
+ pkgDeps,
1630
+ dependencies: [...npmDepSet]
1631
+ };
1632
+ return pkgScanResult;
1633
+ }
1634
+ static #pkgInfos = /* @__PURE__ */ new Map();
1635
+ static async fromExecutor(exec2, options = {}) {
1636
+ const existingPkgInfo = this.#pkgInfos.get(exec2.name);
1637
+ if (existingPkgInfo && !options.refresh)
1638
+ return existingPkgInfo;
1639
+ const scanResult = await this.getScanResult(exec2);
1640
+ const pkgInfo = new _PkgInfo(exec2, scanResult);
1641
+ this.#pkgInfos.set(exec2.name, pkgInfo);
1642
+ return pkgInfo;
1643
+ }
1644
+ constructor(exec2, scanResult) {
1645
+ this.exec = exec2;
1646
+ this.name = exec2.name;
1647
+ this.scanResult = scanResult;
1648
+ }
1649
+ getScanResult() {
1650
+ return this.scanResult;
1651
+ }
1652
+ };
1653
+ var WorkspaceInfo = class _WorkspaceInfo {
1654
+ constructor(appInfos = /* @__PURE__ */ new Map(), libInfos = /* @__PURE__ */ new Map(), pkgInfos = /* @__PURE__ */ new Map()) {
1655
+ this.appInfos = appInfos;
1656
+ this.libInfos = libInfos;
1657
+ this.pkgInfos = pkgInfos;
1658
+ }
1659
+ static #workspaceInfos = /* @__PURE__ */ new Map();
1660
+ static async fromExecutor(exec2, options = {}) {
1661
+ const existingWorkspaceInfo = this.#workspaceInfos.get(exec2.name);
1662
+ if (existingWorkspaceInfo && !options.refresh)
1663
+ return existingWorkspaceInfo;
1664
+ const [appNames, libNames, pkgNames] = await Promise.all([exec2.getApps(), exec2.getLibs(), exec2.getPkgs()]);
1665
+ const [appInfos, libInfos, pkgInfos] = await Promise.all([
1666
+ Promise.all(
1667
+ appNames.map(async (appName) => {
1668
+ const app = AppExecutor.from(exec2, appName);
1669
+ return await app.scan();
1670
+ })
1671
+ ),
1672
+ Promise.all(
1673
+ libNames.map(async (libName) => {
1674
+ const lib = LibExecutor.from(exec2, libName);
1675
+ return await lib.scan();
1676
+ })
1677
+ ),
1678
+ Promise.all(
1679
+ pkgNames.map(async (pkgName) => {
1680
+ return await PkgExecutor.from(exec2, pkgName).scan();
1681
+ })
1682
+ )
1683
+ ]);
1684
+ const workspaceInfo = new _WorkspaceInfo(
1685
+ new Map(appInfos.map((app) => [app.exec.name, app])),
1686
+ new Map(libInfos.map((lib) => [lib.exec.name, lib])),
1687
+ new Map(pkgInfos.map((pkg) => [pkg.exec.name, pkg]))
1688
+ );
1689
+ this.#workspaceInfos.set(exec2.name, workspaceInfo);
1690
+ return workspaceInfo;
1262
1691
  }
1263
1692
  };
1264
1693
 
1265
1694
  // pkgs/@akanjs/devkit/src/typeChecker.ts
1266
1695
  var import_chalk2 = __toESM(require("chalk"));
1267
1696
  var fs7 = __toESM(require("fs"));
1268
- var path5 = __toESM(require("path"));
1697
+ var path6 = __toESM(require("path"));
1269
1698
  var ts3 = __toESM(require("typescript"));
1270
1699
  var TypeChecker = class {
1271
1700
  configPath;
@@ -1280,7 +1709,7 @@ var TypeChecker = class {
1280
1709
  const parsedConfig = ts3.parseJsonConfigFileContent(
1281
1710
  this.configFile.config,
1282
1711
  ts3.sys,
1283
- path5.dirname(this.configPath),
1712
+ path6.dirname(this.configPath),
1284
1713
  void 0,
1285
1714
  this.configPath
1286
1715
  );
@@ -1547,7 +1976,7 @@ var Executor = class _Executor {
1547
1976
  });
1548
1977
  }
1549
1978
  getPath(filePath) {
1550
- if (import_path3.default.isAbsolute(filePath))
1979
+ if (import_path4.default.isAbsolute(filePath))
1551
1980
  return filePath;
1552
1981
  const baseParts = this.cwdPath.split("/").filter(Boolean);
1553
1982
  const targetParts = filePath.split("/").filter(Boolean);
@@ -1580,6 +2009,22 @@ var Executor = class _Executor {
1580
2009
  return [];
1581
2010
  }
1582
2011
  }
2012
+ async getFilesAndDirs(dirPath) {
2013
+ const paths = await this.readdir(dirPath);
2014
+ const files = [];
2015
+ const dirs = [];
2016
+ const fullDirPath = this.getPath(dirPath);
2017
+ await Promise.all(
2018
+ paths.map(async (p) => {
2019
+ const stats = await import_promises.default.stat(import_path4.default.join(fullDirPath, p));
2020
+ if (stats.isDirectory())
2021
+ dirs.push(p);
2022
+ else
2023
+ files.push(p);
2024
+ })
2025
+ );
2026
+ return { files, dirs };
2027
+ }
1583
2028
  exists(filePath) {
1584
2029
  const readPath = this.getPath(filePath);
1585
2030
  return import_fs4.default.existsSync(readPath);
@@ -1600,7 +2045,7 @@ var Executor = class _Executor {
1600
2045
  }
1601
2046
  writeFile(filePath, content, { overwrite = true } = {}) {
1602
2047
  const writePath = this.getPath(filePath);
1603
- const dir = import_path3.default.dirname(writePath);
2048
+ const dir = import_path4.default.dirname(writePath);
1604
2049
  if (!import_fs4.default.existsSync(dir))
1605
2050
  import_fs4.default.mkdirSync(dir, { recursive: true });
1606
2051
  let contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
@@ -1611,11 +2056,12 @@ var Executor = class _Executor {
1611
2056
  contentStr = import_fs4.default.readFileSync(writePath, "utf-8");
1612
2057
  } else {
1613
2058
  import_fs4.default.writeFileSync(writePath, contentStr, "utf8");
1614
- this.logger.verbose(`File ${writePath} is changed`);
2059
+ if (Logger.isVerbose())
2060
+ this.logger.rawLog(import_chalk3.default.yellow(`File Update: ${filePath}`));
1615
2061
  }
1616
2062
  } else {
1617
2063
  import_fs4.default.writeFileSync(writePath, contentStr, "utf8");
1618
- this.logger.verbose(`File ${writePath} is created`);
2064
+ this.logger.rawLog(import_chalk3.default.green(`File Create: ${filePath}`));
1619
2065
  }
1620
2066
  return { filePath: writePath, content: contentStr };
1621
2067
  }
@@ -1624,7 +2070,7 @@ var Executor = class _Executor {
1624
2070
  return this;
1625
2071
  }
1626
2072
  getLocalFile(targetPath) {
1627
- const filePath = import_path3.default.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
2073
+ const filePath = import_path4.default.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
1628
2074
  const content = this.readFile(filePath);
1629
2075
  return { filePath, content };
1630
2076
  }
@@ -1652,7 +2098,10 @@ var Executor = class _Executor {
1652
2098
  spinning(msg, { prefix = `${this.emoji}${this.name}`, indent = 0, enableSpin = !_Executor.verbose } = {}) {
1653
2099
  return new Spinner(msg, { prefix, indent, enableSpin }).start();
1654
2100
  }
1655
- getTsConfig(pathname = "tsconfig.json") {
2101
+ #tsconfig = null;
2102
+ getTsConfig(pathname = "tsconfig.json", { refresh } = {}) {
2103
+ if (this.#tsconfig && !refresh)
2104
+ return this.#tsconfig;
1656
2105
  const tsconfig = this.readJson(pathname);
1657
2106
  if (tsconfig.extends) {
1658
2107
  const extendsTsconfig = this.getTsConfig(tsconfig.extends);
@@ -1662,24 +2111,41 @@ var Executor = class _Executor {
1662
2111
  compilerOptions: { ...extendsTsconfig.compilerOptions, ...tsconfig.compilerOptions }
1663
2112
  };
1664
2113
  }
2114
+ this.#tsconfig = tsconfig;
1665
2115
  return tsconfig;
1666
2116
  }
2117
+ setTsConfig(tsconfig) {
2118
+ this.writeJson("tsconfig.json", tsconfig);
2119
+ this.#tsconfig = tsconfig;
2120
+ }
2121
+ #packageJson = null;
2122
+ getPackageJson({ refresh } = {}) {
2123
+ if (this.#packageJson && !refresh)
2124
+ return this.#packageJson;
2125
+ const packageJson = this.readJson("package.json");
2126
+ this.#packageJson = packageJson;
2127
+ return packageJson;
2128
+ }
2129
+ setPackageJson(packageJson) {
2130
+ this.writeJson("package.json", packageJson);
2131
+ this.#packageJson = packageJson;
2132
+ }
1667
2133
  async #applyTemplateFile({
1668
2134
  templatePath,
1669
2135
  targetPath,
1670
- scanResult,
2136
+ scanInfo,
1671
2137
  overwrite = true
1672
2138
  }, dict = {}) {
1673
2139
  if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
1674
2140
  const getContent = await import(templatePath);
1675
- const result = getContent.default(scanResult ?? null, dict);
2141
+ const result = getContent.default(scanInfo ?? null, dict);
1676
2142
  if (result === null)
1677
2143
  return null;
1678
- const filename = typeof result === "object" ? result.filename : import_path3.default.basename(targetPath).replace(".js", ".ts");
2144
+ const filename = typeof result === "object" ? result.filename : import_path4.default.basename(targetPath).replace(".js", ".ts");
1679
2145
  const content = typeof result === "object" ? result.content : result;
1680
- const dirname3 = import_path3.default.dirname(targetPath);
2146
+ const dirname3 = import_path4.default.dirname(targetPath);
1681
2147
  const convertedTargetPath = Object.entries(dict).reduce(
1682
- (path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
2148
+ (path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
1683
2149
  `${dirname3}/${filename}`
1684
2150
  );
1685
2151
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
@@ -1687,7 +2153,7 @@ var Executor = class _Executor {
1687
2153
  } else if (targetPath.endsWith(".template")) {
1688
2154
  const content = await import_promises.default.readFile(templatePath, "utf8");
1689
2155
  const convertedTargetPath = Object.entries(dict).reduce(
1690
- (path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
2156
+ (path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
1691
2157
  targetPath.slice(0, -9)
1692
2158
  );
1693
2159
  const convertedContent = Object.entries(dict).reduce(
@@ -1702,16 +2168,16 @@ var Executor = class _Executor {
1702
2168
  async _applyTemplate({
1703
2169
  basePath: basePath2,
1704
2170
  template,
1705
- scanResult,
2171
+ scanInfo,
1706
2172
  dict = {},
1707
2173
  overwrite = true
1708
2174
  }) {
1709
2175
  const templatePath = `${getDirname(import_meta2.url)}/src/templates${template ? `/${template}` : ""}`;
1710
2176
  const prefixTemplatePath = templatePath.endsWith(".tsx") ? templatePath : templatePath.replace(".ts", ".js");
1711
2177
  if (import_fs4.default.statSync(prefixTemplatePath).isFile()) {
1712
- const filename = import_path3.default.basename(prefixTemplatePath);
2178
+ const filename = import_path4.default.basename(prefixTemplatePath);
1713
2179
  const fileContent = await this.#applyTemplateFile(
1714
- { templatePath: prefixTemplatePath, targetPath: import_path3.default.join(basePath2, filename), scanResult, overwrite },
2180
+ { templatePath: prefixTemplatePath, targetPath: import_path4.default.join(basePath2, filename), scanInfo, overwrite },
1715
2181
  dict
1716
2182
  );
1717
2183
  return fileContent ? [fileContent] : [];
@@ -1719,18 +2185,18 @@ var Executor = class _Executor {
1719
2185
  const subdirs = await this.readdir(templatePath);
1720
2186
  const fileContents = (await Promise.all(
1721
2187
  subdirs.map(async (subdir) => {
1722
- const subpath = import_path3.default.join(templatePath, subdir);
2188
+ const subpath = import_path4.default.join(templatePath, subdir);
1723
2189
  if (import_fs4.default.statSync(subpath).isFile()) {
1724
2190
  const fileContent = await this.#applyTemplateFile(
1725
- { templatePath: subpath, targetPath: import_path3.default.join(basePath2, subdir), scanResult, overwrite },
2191
+ { templatePath: subpath, targetPath: import_path4.default.join(basePath2, subdir), scanInfo, overwrite },
1726
2192
  dict
1727
2193
  );
1728
2194
  return fileContent ? [fileContent] : [];
1729
2195
  } else
1730
2196
  return await this._applyTemplate({
1731
- basePath: import_path3.default.join(basePath2, subdir),
1732
- template: import_path3.default.join(template, subdir),
1733
- scanResult,
2197
+ basePath: import_path4.default.join(basePath2, subdir),
2198
+ template: import_path4.default.join(template, subdir),
2199
+ scanInfo,
1734
2200
  dict,
1735
2201
  overwrite
1736
2202
  });
@@ -1753,9 +2219,9 @@ var Executor = class _Executor {
1753
2219
  return this.typeChecker;
1754
2220
  }
1755
2221
  typeCheck(filePath) {
1756
- const path9 = this.getPath(filePath);
2222
+ const path10 = this.getPath(filePath);
1757
2223
  const typeChecker = this.getTypeChecker();
1758
- const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path9);
2224
+ const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path10);
1759
2225
  const message = typeChecker.formatDiagnostics(fileDiagnostics);
1760
2226
  return { fileDiagnostics, fileErrors, fileWarnings, message };
1761
2227
  }
@@ -1764,9 +2230,9 @@ var Executor = class _Executor {
1764
2230
  return this.linter;
1765
2231
  }
1766
2232
  async lint(filePath, { fix = false, dryRun = false } = {}) {
1767
- const path9 = this.getPath(filePath);
2233
+ const path10 = this.getPath(filePath);
1768
2234
  const linter = this.getLinter();
1769
- const { results, errors, warnings } = await linter.lint(path9, { fix, dryRun });
2235
+ const { results, errors, warnings } = await linter.lint(path10, { fix, dryRun });
1770
2236
  const message = linter.formatLintResults(results);
1771
2237
  return { results, message, errors, warnings };
1772
2238
  }
@@ -1780,9 +2246,12 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1780
2246
  this.workspaceRoot = workspaceRoot;
1781
2247
  this.repoName = repoName;
1782
2248
  }
1783
- static fromRoot() {
1784
- const repoName = import_path3.default.basename(process.cwd());
1785
- return new _WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
2249
+ static #execs = /* @__PURE__ */ new Map();
2250
+ static fromRoot({
2251
+ workspaceRoot = process.cwd(),
2252
+ repoName = import_path4.default.basename(process.cwd())
2253
+ } = {}) {
2254
+ return this.#execs.get(repoName) ?? new _WorkspaceExecutor({ workspaceRoot, repoName });
1786
2255
  }
1787
2256
  getBaseDevEnv() {
1788
2257
  const envFile = import_dotenv.default.parse(this.readFile(".env"));
@@ -1800,36 +2269,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1800
2269
  return { ...appName ? { name: appName } : {}, repoName, serveDomain, env, portOffset };
1801
2270
  }
1802
2271
  async scan() {
1803
- const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
1804
- const [appScanResults, libScanResults, pkgScanResults] = await Promise.all([
1805
- Promise.all(
1806
- appNames.map(async (appName) => {
1807
- const app = AppExecutor.from(this, appName);
1808
- const akanConfig = await app.getConfig("scan");
1809
- return await app.scan({ akanConfig });
1810
- })
1811
- ),
1812
- Promise.all(
1813
- libNames.map(async (libName) => {
1814
- const lib = LibExecutor.from(this, libName);
1815
- const akanConfig = await lib.getConfig("scan");
1816
- return await lib.scan({ akanConfig });
1817
- })
1818
- ),
1819
- Promise.all(
1820
- pkgNames.map(async (pkgName) => {
1821
- return await PkgExecutor.from(this, pkgName).scan();
1822
- })
1823
- )
1824
- ]);
1825
- return {
1826
- appNames,
1827
- libNames,
1828
- pkgNames,
1829
- apps: Object.fromEntries(appScanResults.map((app) => [app.name, app])),
1830
- libs: Object.fromEntries(libScanResults.map((lib) => [lib.name, lib])),
1831
- pkgs: Object.fromEntries(pkgScanResults.map((pkg) => [pkg.name, pkg]))
1832
- };
2272
+ return await WorkspaceInfo.fromExecutor(this);
1833
2273
  }
1834
2274
  async getApps() {
1835
2275
  if (!import_fs4.default.existsSync(`${this.workspaceRoot}/apps`))
@@ -1891,7 +2331,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1891
2331
  dirs.map(async (dir) => {
1892
2332
  if (dir.includes("_") || AVOID_DIRS.includes(dir))
1893
2333
  return;
1894
- const dirPath = import_path3.default.join(dirname3, dir);
2334
+ const dirPath = import_path4.default.join(dirname3, dir);
1895
2335
  if (import_fs4.default.lstatSync(dirPath).isDirectory()) {
1896
2336
  results.push(`${prefix}${dir}`);
1897
2337
  if (maxDepth > 0)
@@ -1918,9 +2358,9 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1918
2358
  dirs.map(async (dir) => {
1919
2359
  if (AVOID_DIRS.includes(dir))
1920
2360
  return;
1921
- const dirPath = import_path3.default.join(dirname3, dir);
2361
+ const dirPath = import_path4.default.join(dirname3, dir);
1922
2362
  if (import_fs4.default.lstatSync(dirPath).isDirectory()) {
1923
- const hasTargetFile = import_fs4.default.existsSync(import_path3.default.join(dirPath, targetFilename));
2363
+ const hasTargetFile = import_fs4.default.existsSync(import_path4.default.join(dirPath, targetFilename));
1924
2364
  if (hasTargetFile)
1925
2365
  results.push(`${prefix}${dir}`);
1926
2366
  if (maxDepth > 0)
@@ -1977,163 +2417,106 @@ var SysExecutor = class extends Executor {
1977
2417
  this.type = type;
1978
2418
  this.emoji = execEmoji[type];
1979
2419
  }
1980
- async getConfig(command) {
1981
- 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 });
2420
+ #akanConfig = null;
2421
+ async getConfig({ refresh } = {}) {
2422
+ if (this.#akanConfig && !refresh)
2423
+ return this.#akanConfig;
2424
+ 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 });
2425
+ return this.#akanConfig;
1982
2426
  }
1983
2427
  async getModules() {
1984
- const path9 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
1985
- return await this.workspace.getDirInModule(path9, this.name);
2428
+ const path10 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
2429
+ return await this.workspace.getDirInModule(path10, this.name);
1986
2430
  }
2431
+ #scanInfo = null;
1987
2432
  async scan({
1988
- tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
1989
- akanConfig
1990
- }, libScanResults = {}) {
1991
- if (libScanResults[this.name])
1992
- return libScanResults[this.name];
1993
- const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
1994
- const scanner = new TypeScriptDependencyScanner(this.cwdPath);
1995
- const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
1996
- const pkgPathSet = new Set(
1997
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
1998
- );
1999
- const libPathSet = new Set(
2000
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("libs/"))).map((path9) => path9.replace("/*", ""))
2001
- );
2002
- const [npmDepSet, pkgPathDepSet, libPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet, libPathSet]);
2003
- const pkgDeps = [...pkgPathDepSet].map((path9) => {
2004
- const pathSplitLength = path9.split("/").length;
2005
- return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
2006
- });
2007
- const libDeps = [...libPathDepSet].map((path9) => {
2008
- const pathSplitLength = path9.split("/").length;
2009
- return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
2010
- }).filter((libName) => libName !== this.name);
2011
- if (!import_fs4.default.existsSync(`${this.cwdPath}/lib/__scalar`))
2012
- import_fs4.default.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
2013
- const files = getDefaultFileScan();
2014
- const dirnames = (await this.readdir("lib")).filter(
2015
- (name) => import_fs4.default.lstatSync(`${this.cwdPath}/lib/${name}`).isDirectory()
2016
- );
2017
- const databaseDirs = dirnames.filter((name) => !name.startsWith("_"));
2018
- const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
2019
- await Promise.all(
2020
- databaseDirs.map(async (name) => {
2021
- const filenames = await this.readdir(import_path3.default.join("lib", name));
2022
- filenames.forEach((filename) => {
2023
- if (filename.endsWith(".constant.ts"))
2024
- files.constants.databases.push(name);
2025
- else if (filename.endsWith(".dictionary.ts"))
2026
- files.dictionary.databases.push(name);
2027
- else if (filename.endsWith(".document.ts"))
2028
- files.documents.databases.push(name);
2029
- else if (filename.endsWith(".service.ts"))
2030
- files.services.databases.push(name);
2031
- else if (filename.endsWith(".signal.ts"))
2032
- files.signal.databases.push(name);
2033
- else if (filename.endsWith(".store.ts"))
2034
- files.store.databases.push(name);
2035
- else if (filename === "index.tsx")
2036
- files.components.databases.push(name);
2037
- });
2038
- })
2039
- );
2040
- await Promise.all(
2041
- serviceDirs.map(async (dirname3) => {
2042
- const name = dirname3.slice(1);
2043
- const filenames = await this.readdir(import_path3.default.join("lib", dirname3));
2044
- filenames.forEach((filename) => {
2045
- if (filename.endsWith(".dictionary.ts"))
2046
- files.dictionary.services.push(name);
2047
- else if (filename.endsWith(".service.ts"))
2048
- files.services.services.push(name);
2049
- else if (filename.endsWith(".signal.ts"))
2050
- files.signal.services.push(name);
2051
- else if (filename.endsWith(".store.ts"))
2052
- files.store.services.push(name);
2053
- else if (filename === "index.tsx")
2054
- files.components.services.push(name);
2055
- });
2056
- })
2057
- );
2058
- const scalarDirs = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_"));
2059
- await Promise.all(
2060
- scalarDirs.map(async (name) => {
2061
- const filenames = await this.readdir(import_path3.default.join("lib/__scalar", name));
2062
- filenames.forEach((filename) => {
2063
- if (filename.endsWith(".constant.ts"))
2064
- files.constants.scalars.push(name);
2065
- else if (filename.endsWith(".dictionary.ts"))
2066
- files.dictionary.scalars.push(name);
2067
- else if (filename.endsWith(".document.ts"))
2068
- files.documents.scalars.push(name);
2069
- else if (filename.endsWith(".service.ts"))
2070
- files.services.scalars.push(name);
2071
- else if (filename.endsWith(".signal.ts"))
2072
- files.signal.scalars.push(name);
2073
- else if (filename.endsWith(".store.ts"))
2074
- files.store.scalars.push(name);
2075
- else if (filename === "index.ts")
2076
- files.components.scalars.push(name);
2077
- });
2078
- })
2079
- );
2080
- const missingLibDeps = [];
2081
- libDeps.forEach((libName) => {
2082
- if (!akanConfig.libs.includes(libName))
2083
- missingLibDeps.push(libName);
2084
- });
2085
- if (missingLibDeps.length)
2086
- throw new Error(
2087
- `Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
2088
- );
2089
- for (const libName of akanConfig.libs) {
2090
- if (libScanResults[libName])
2091
- continue;
2092
- const lib = new LibExecutor({ workspace: this.workspace, name: libName });
2093
- const akanConfig2 = await lib.getConfig();
2094
- libScanResults[libName] = await lib.scan({ akanConfig: akanConfig2 }, libScanResults);
2433
+ refresh,
2434
+ write = true,
2435
+ writeLib = true
2436
+ } = {}) {
2437
+ if (this.#scanInfo && !refresh)
2438
+ return this.#scanInfo;
2439
+ const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this, { refresh }) : await LibInfo.fromExecutor(this, { refresh });
2440
+ if (write) {
2441
+ await Promise.all([
2442
+ this._applyTemplate({ basePath: "lib", template: "lib", scanInfo }),
2443
+ this._applyTemplate({ basePath: ".", template: "server.ts", scanInfo }),
2444
+ this._applyTemplate({ basePath: ".", template: "client.ts", scanInfo }),
2445
+ this.type === "lib" ? this._applyTemplate({ basePath: ".", template: "index.ts", scanInfo }) : null,
2446
+ ...scanInfo.getDatabaseModules().map(
2447
+ (model) => this._applyTemplate({
2448
+ basePath: `lib/${model}`,
2449
+ template: "moduleRoot",
2450
+ scanInfo,
2451
+ dict: { model, Model: capitalize(model) }
2452
+ })
2453
+ ),
2454
+ ...scanInfo.getServiceModules().map(
2455
+ (model) => this._applyTemplate({
2456
+ basePath: `lib/_${model}`,
2457
+ template: "moduleRoot",
2458
+ scanInfo,
2459
+ dict: { model, Model: capitalize(model) }
2460
+ })
2461
+ )
2462
+ ]);
2463
+ this.writeJson(`akan.${this.type}.json`, scanInfo.getScanResult());
2464
+ if (this.type === "lib")
2465
+ this.#updateDependencies(scanInfo);
2466
+ if (writeLib) {
2467
+ const libInfos = [...scanInfo.getLibInfos().values()];
2468
+ await Promise.all(
2469
+ libInfos.map((libInfo) => [
2470
+ libInfo.exec._applyTemplate({ basePath: "lib", template: "lib", scanInfo: libInfo }),
2471
+ libInfo.exec._applyTemplate({ basePath: ".", template: "server.ts", scanInfo: libInfo }),
2472
+ libInfo.exec._applyTemplate({ basePath: ".", template: "client.ts", scanInfo: libInfo }),
2473
+ libInfo.exec._applyTemplate({ basePath: ".", template: "index.ts", scanInfo: libInfo }),
2474
+ ...libInfo.getDatabaseModules().map(
2475
+ (model) => libInfo.exec._applyTemplate({
2476
+ basePath: `lib/${model}`,
2477
+ template: "moduleRoot",
2478
+ scanInfo: libInfo,
2479
+ dict: { model, Model: capitalize(model) }
2480
+ })
2481
+ ),
2482
+ ...libInfo.getServiceModules().map(
2483
+ (model) => libInfo.exec._applyTemplate({
2484
+ basePath: `lib/_${model}`,
2485
+ template: "moduleRoot",
2486
+ scanInfo: libInfo,
2487
+ dict: { model, Model: capitalize(model) }
2488
+ })
2489
+ )
2490
+ ]).flat()
2491
+ );
2492
+ }
2095
2493
  }
2096
- const scanResult = {
2097
- name: this.name,
2098
- type: this.type,
2099
- repoName: this.workspace.repoName,
2100
- serveDomain: this.workspace.getBaseDevEnv().serveDomain,
2101
- akanConfig,
2102
- files,
2103
- libDeps,
2104
- pkgDeps,
2105
- dependencies: [...npmDepSet].filter((dep) => !dep.startsWith("@akanjs")),
2106
- libs: Object.fromEntries(akanConfig.libs.map((libName) => [libName, libScanResults[libName]]))
2107
- };
2108
- await this._applyTemplate({ basePath: "lib", template: "lib", scanResult });
2109
- await this._applyTemplate({ basePath: ".", template: "server.ts", scanResult });
2110
- await this._applyTemplate({ basePath: ".", template: "client.ts", scanResult });
2111
- if (this.type === "lib")
2112
- await this._applyTemplate({ basePath: ".", template: "index.ts", scanResult });
2113
- this.writeJson(`akan.${this.type}.json`, scanResult);
2114
- if (this.type === "app")
2115
- return scanResult;
2116
- const libPackageJson = this.readJson("package.json");
2494
+ this.#scanInfo = scanInfo;
2495
+ return scanInfo;
2496
+ }
2497
+ #updateDependencies(scanInfo) {
2498
+ const rootPackageJson = this.workspace.getPackageJson();
2499
+ const libPackageJson = this.getPackageJson();
2500
+ const dependencies = scanInfo.getScanResult().dependencies;
2117
2501
  const libPkgJsonWithDeps = {
2118
2502
  ...libPackageJson,
2119
2503
  dependencies: {
2120
2504
  ...libPackageJson.dependencies,
2121
2505
  ...Object.fromEntries(
2122
- scanResult.dependencies.filter((dep) => rootPackageJson.dependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.dependencies?.[dep]])
2506
+ dependencies.filter((dep) => rootPackageJson.dependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.dependencies?.[dep]])
2123
2507
  )
2124
2508
  },
2125
2509
  devDependencies: {
2126
2510
  ...libPackageJson.devDependencies,
2127
2511
  ...Object.fromEntries(
2128
- scanResult.dependencies.filter((dep) => rootPackageJson.devDependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.devDependencies?.[dep]])
2512
+ dependencies.filter((dep) => rootPackageJson.devDependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.devDependencies?.[dep]])
2129
2513
  )
2130
2514
  }
2131
2515
  };
2132
- this.writeJson("package.json", libPkgJsonWithDeps);
2133
- return scanResult;
2516
+ this.setPackageJson(libPkgJsonWithDeps);
2134
2517
  }
2135
2518
  getLocalFile(targetPath) {
2136
- const filePath = import_path3.default.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
2519
+ const filePath = import_path4.default.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
2137
2520
  const content = this.workspace.readFile(filePath);
2138
2521
  return { filePath, content };
2139
2522
  }
@@ -2213,9 +2596,9 @@ var SysExecutor = class extends Executor {
2213
2596
  )
2214
2597
  };
2215
2598
  const akanConfig = await this.getConfig();
2216
- const scanResult = await this.scan({ akanConfig });
2217
- const fileContents = await this._applyTemplate({ ...options, scanResult, dict });
2218
- await this.scan({ akanConfig });
2599
+ const scanInfo = await this.scan();
2600
+ const fileContents = await this._applyTemplate({ ...options, scanInfo, dict });
2601
+ await this.scan();
2219
2602
  return fileContents;
2220
2603
  }
2221
2604
  setTsPaths() {
@@ -2230,21 +2613,29 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2230
2613
  super({ workspace, name, type: "app" });
2231
2614
  this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/apps/${name}`);
2232
2615
  }
2616
+ static #execs = /* @__PURE__ */ new Map();
2233
2617
  static from(executor, name) {
2234
- if (executor instanceof WorkspaceExecutor)
2618
+ const exec2 = this.#execs.get(name);
2619
+ if (exec2)
2620
+ return exec2;
2621
+ else if (executor instanceof WorkspaceExecutor)
2235
2622
  return new _AppExecutor({ workspace: executor, name });
2236
- return new _AppExecutor({ workspace: executor.workspace, name });
2623
+ else
2624
+ return new _AppExecutor({ workspace: executor.workspace, name });
2237
2625
  }
2238
2626
  getEnv() {
2239
2627
  return this.workspace.getBaseDevEnv().env;
2240
2628
  }
2241
- async getConfig(command) {
2242
- return await getAppConfig(this.cwdPath, {
2629
+ #akanConfig = null;
2630
+ async getConfig({ refresh } = {}) {
2631
+ if (this.#akanConfig && !refresh)
2632
+ return this.#akanConfig;
2633
+ this.#akanConfig = await getAppConfig(this.cwdPath, {
2243
2634
  ...this.workspace.getBaseDevEnv(),
2244
2635
  type: "app",
2245
- name: this.name,
2246
- command
2636
+ name: this.name
2247
2637
  });
2638
+ return this.#akanConfig;
2248
2639
  }
2249
2640
  async syncAssets(libDeps) {
2250
2641
  const projectPublicLibPath = `${this.cwdPath}/public/libs`;
@@ -2281,18 +2672,26 @@ var LibExecutor = class _LibExecutor extends SysExecutor {
2281
2672
  super({ workspace, name, type: "lib" });
2282
2673
  this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/libs/${name}`);
2283
2674
  }
2675
+ static #execs = /* @__PURE__ */ new Map();
2284
2676
  static from(executor, name) {
2285
- if (executor instanceof WorkspaceExecutor)
2677
+ const exec2 = this.#execs.get(name);
2678
+ if (exec2)
2679
+ return exec2;
2680
+ else if (executor instanceof WorkspaceExecutor)
2286
2681
  return new _LibExecutor({ workspace: executor, name });
2287
- return new _LibExecutor({ workspace: executor.workspace, name });
2682
+ else
2683
+ return new _LibExecutor({ workspace: executor.workspace, name });
2288
2684
  }
2289
- async getConfig(command) {
2290
- return await getLibConfig(this.cwdPath, {
2685
+ #akanConfig = null;
2686
+ async getConfig({ refresh } = {}) {
2687
+ if (this.#akanConfig && !refresh)
2688
+ return this.#akanConfig;
2689
+ this.#akanConfig = await getLibConfig(this.cwdPath, {
2291
2690
  ...this.workspace.getBaseDevEnv(),
2292
2691
  type: "lib",
2293
- name: this.name,
2294
- command
2692
+ name: this.name
2295
2693
  });
2694
+ return this.#akanConfig;
2296
2695
  }
2297
2696
  };
2298
2697
  var PkgExecutor = class _PkgExecutor extends Executor {
@@ -2311,27 +2710,13 @@ var PkgExecutor = class _PkgExecutor extends Executor {
2311
2710
  return new _PkgExecutor({ workspace: executor, name });
2312
2711
  return new _PkgExecutor({ workspace: executor.workspace, name });
2313
2712
  }
2314
- async scan({
2315
- packageJson = this.readJson(`${this.cwdPath}/package.json`),
2316
- tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`)
2317
- } = {}) {
2318
- const rootPackageJson = this.readJson(`${this.workspace.workspaceRoot}/package.json`);
2319
- const scanner = new TypeScriptDependencyScanner(this.cwdPath);
2320
- const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
2321
- const pkgPathSet = new Set(
2322
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
2323
- );
2324
- const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
2325
- const pkgDeps = [...pkgPathDepSet].map((path9) => {
2326
- const pathSplitLength = path9.split("/").length;
2327
- return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
2328
- }).filter((pkg) => pkg !== this.name);
2329
- const pkgScanResult = {
2330
- name: this.name,
2331
- pkgDeps,
2332
- dependencies: [...npmDepSet]
2333
- };
2334
- return pkgScanResult;
2713
+ #scanInfo = null;
2714
+ async scan({ refresh } = {}) {
2715
+ if (this.#scanInfo && !refresh)
2716
+ return this.#scanInfo;
2717
+ const scanInfo = await PkgInfo.fromExecutor(this, { refresh });
2718
+ this.#scanInfo = scanInfo;
2719
+ return scanInfo;
2335
2720
  }
2336
2721
  };
2337
2722
  var ModuleExecutor = class _ModuleExecutor extends Executor {
@@ -2635,7 +3020,7 @@ var extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =>
2635
3020
  ...pacakgeJson.devDependencies ?? {}
2636
3021
  };
2637
3022
  const requireRegex = /(?:require\s*\(|import\s*(?:[\w\s{},*]*\s+from\s*)?|import\s*\()\s*['"`]([^'"`]+)['"`]/g;
2638
- for (const { text } of filepaths.filter(({ path: path9 }) => path9.endsWith(".js") || path9.endsWith(".ts"))) {
3023
+ for (const { text } of filepaths.filter(({ path: path10 }) => path10.endsWith(".js") || path10.endsWith(".ts"))) {
2639
3024
  let requireMatch;
2640
3025
  while ((requireMatch = requireRegex.exec(text)) !== null) {
2641
3026
  const moduleName = requireMatch[1];
@@ -2918,8 +3303,18 @@ var runCommands = async (...commands) => {
2918
3303
  });
2919
3304
  const __dirname = getDirname(import_meta3.url);
2920
3305
  const hasPackageJson = import_fs7.default.existsSync(`${__dirname}/../package.json`);
2921
- const version = hasPackageJson ? JSON.parse(import_fs7.default.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
2922
- import_commander.program.version(version).description("Akan CLI");
3306
+ process.env.AKAN_VERSION = hasPackageJson ? JSON.parse(import_fs7.default.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
3307
+ import_commander.program.version(process.env.AKAN_VERSION).description("Akan CLI");
3308
+ const akanBasePackageJson = import_fs7.default.existsSync("./node_modules/@akanjs/base/package.json") ? JSON.parse(import_fs7.default.readFileSync("./node_modules/@akanjs/base/package.json", "utf8")) : null;
3309
+ if (akanBasePackageJson && akanBasePackageJson.version !== process.env.AKAN_VERSION) {
3310
+ Logger.rawLog(
3311
+ import_chalk4.default.yellow(
3312
+ `
3313
+ Akan CLI version is mismatch with installed package. ${process.env.AKAN_VERSION} (global) vs ${akanBasePackageJson.version} (base)
3314
+ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`
3315
+ )
3316
+ );
3317
+ }
2923
3318
  for (const command of commands) {
2924
3319
  const targetMetas = getTargetMetas(command);
2925
3320
  for (const targetMeta of targetMetas) {
@@ -2982,7 +3377,8 @@ var runCommands = async (...commands) => {
2982
3377
  Logger.rawLog();
2983
3378
  } catch (e) {
2984
3379
  const errMsg = e instanceof Error ? e.message : typeof e === "string" ? e : JSON.stringify(e);
2985
- Logger.error(`Command Error: ${import_chalk4.default.red(errMsg)}`);
3380
+ Logger.rawLog(`
3381
+ ${import_chalk4.default.red(errMsg)}`);
2986
3382
  throw e;
2987
3383
  }
2988
3384
  });
@@ -3337,8 +3733,8 @@ var Builder = class {
3337
3733
  }
3338
3734
  };
3339
3735
  buildResult.outputFiles.map((file) => this.#distExecutor.writeFile(file.path, file.text));
3340
- this.#distExecutor.writeJson("package.json", pkgPackageJson);
3341
- this.#executor.writeJson("package.json", pkgPackageJson);
3736
+ this.#distExecutor.setPackageJson(pkgPackageJson);
3737
+ this.#executor.setPackageJson(pkgPackageJson);
3342
3738
  }
3343
3739
  };
3344
3740
 
@@ -3433,8 +3829,8 @@ var LibraryRunner = class {
3433
3829
  return LibExecutor.from(workspace, libName);
3434
3830
  }
3435
3831
  async mergeLibraryDependencies(lib) {
3436
- const libPackageJson = lib.readJson("package.json");
3437
- const rootPackageJson = lib.workspace.readJson("package.json");
3832
+ const libPackageJson = lib.getPackageJson();
3833
+ const rootPackageJson = lib.workspace.getPackageJson();
3438
3834
  const dependencies = {};
3439
3835
  const devDependencies = {};
3440
3836
  const libDependencies = { ...libPackageJson.dependencies, ...libPackageJson.devDependencies };
@@ -3454,7 +3850,7 @@ var LibraryRunner = class {
3454
3850
  devDependencies[dep] = allDependencies[dep];
3455
3851
  });
3456
3852
  const newRootPackageJson = { ...rootPackageJson, dependencies, devDependencies };
3457
- lib.workspace.writeJson("package.json", newRootPackageJson);
3853
+ lib.workspace.setPackageJson(newRootPackageJson);
3458
3854
  await lib.workspace.spawn("pnpm", ["install", "--reporter=silent"]);
3459
3855
  await lib.workspace.commit(`Merge ${lib.name} library dependencies`);
3460
3856
  }
@@ -3500,10 +3896,9 @@ var LibraryScript = class {
3500
3896
  #runner = new LibraryRunner();
3501
3897
  async syncLibrary(lib) {
3502
3898
  const syncSpinner = lib.spinning("Syncing library...");
3503
- const akanConfig = await lib.getConfig();
3504
- const scanResult = await lib.scan({ akanConfig });
3899
+ const scanInfo = await lib.scan();
3505
3900
  syncSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) is synced`);
3506
- return scanResult;
3901
+ return scanInfo;
3507
3902
  }
3508
3903
  async createLibrary(libName, workspace) {
3509
3904
  const spinner = workspace.spinning(`Creating ${libName} library`);
@@ -3856,7 +4251,7 @@ var import_promises3 = __toESM(require("fs/promises"), 1);
3856
4251
  var import_js_yaml2 = __toESM(require("js-yaml"), 1);
3857
4252
  var import_open = __toESM(require("open"), 1);
3858
4253
  var import_ora3 = __toESM(require("ora"), 1);
3859
- var import_path4 = __toESM(require("path"), 1);
4254
+ var import_path5 = __toESM(require("path"), 1);
3860
4255
  var vite = __toESM(require("vite"), 1);
3861
4256
  var import_vite_plugin_commonjs = __toESM(require("vite-plugin-commonjs"), 1);
3862
4257
  var import_vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
@@ -3876,17 +4271,12 @@ var ApplicationRunner = class {
3876
4271
  app.workspace.unsetTsPaths("app", app.name);
3877
4272
  }
3878
4273
  async getConfig(app) {
3879
- return await getAppConfig(app.cwdPath, {
3880
- ...app.workspace.getBaseDevEnv(),
3881
- type: "app",
3882
- name: app.name,
3883
- command: "start"
3884
- });
4274
+ return await app.getConfig();
3885
4275
  }
3886
- async scanSync(app, akanConfig) {
3887
- const scanResult = await app.scan({ akanConfig });
3888
- await app.syncAssets(scanResult.akanConfig.libs);
3889
- return scanResult;
4276
+ async scanSync(app) {
4277
+ const scanInfo = await app.scan();
4278
+ await app.syncAssets(scanInfo.getScanResult().libDeps);
4279
+ return scanInfo;
3890
4280
  }
3891
4281
  async getScriptFilename(app) {
3892
4282
  if (!app.exists("scripts")) {
@@ -3942,12 +4332,12 @@ var ApplicationRunner = class {
3942
4332
  } else if (target === "csr")
3943
4333
  await app.workspace.exec(`rm -rf ${app.workspace.workspaceRoot}/node_modules/.vite/${app.name}`);
3944
4334
  else if (target === "backend")
3945
- await app.cp("assets", import_path4.default.join(app.dist.cwdPath, "backend", "assets"));
4335
+ await app.cp("assets", import_path5.default.join(app.dist.cwdPath, "backend", "assets"));
3946
4336
  return { env: this.#getEnv(app, target, { AKAN_COMMAND_TYPE: type }) };
3947
4337
  }
3948
4338
  async buildBackend(app) {
3949
4339
  await this.#prepareCommand(app, "start", "backend");
3950
- const akanConfig = await app.getConfig("build");
4340
+ const akanConfig = await app.getConfig();
3951
4341
  const buildResult = await esbuild2.build({
3952
4342
  write: false,
3953
4343
  entryPoints: [`${app.cwdPath}/main.ts`],
@@ -3958,7 +4348,7 @@ var ApplicationRunner = class {
3958
4348
  outdir: `${app.dist.cwdPath}/backend`,
3959
4349
  logLevel: "warning"
3960
4350
  });
3961
- const rootPackageJson = app.workspace.readJson("package.json");
4351
+ const rootPackageJson = app.workspace.getPackageJson();
3962
4352
  const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson);
3963
4353
  buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
3964
4354
  const appPackageJson = {
@@ -3971,7 +4361,7 @@ var ApplicationRunner = class {
3971
4361
  dependencies
3972
4362
  };
3973
4363
  app.dist.writeJson("backend/package.json", appPackageJson);
3974
- app.dist.writeFile(import_path4.default.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.docker.content);
4364
+ app.dist.writeFile(import_path5.default.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.docker.content);
3975
4365
  }
3976
4366
  async startBackend(app, { open: open2 = false, onStart, withInk = false } = {}) {
3977
4367
  const { env } = await this.#prepareCommand(app, "start", "backend");
@@ -3982,7 +4372,7 @@ var ApplicationRunner = class {
3982
4372
  packages: "external",
3983
4373
  platform: "node",
3984
4374
  format: "cjs",
3985
- outdir: import_path4.default.join(app.dist.cwdPath, "backend"),
4375
+ outdir: import_path5.default.join(app.dist.cwdPath, "backend"),
3986
4376
  logLevel: "warning"
3987
4377
  });
3988
4378
  await ctx.watch();
@@ -3998,7 +4388,7 @@ var ApplicationRunner = class {
3998
4388
  }
3999
4389
  async buildFrontend(app, { spawnOptions } = {}) {
4000
4390
  const { env } = await this.#prepareCommand(app, "build", "frontend");
4001
- const akanConfig = await app.getConfig("build");
4391
+ const akanConfig = await app.getConfig();
4002
4392
  await app.spawn("npx", ["next", "build", "--no-lint"], { env, ...spawnOptions });
4003
4393
  const buildResult = await esbuild2.build({
4004
4394
  entryPoints: [`${app.cwdPath}/next.config.ts`],
@@ -4010,7 +4400,7 @@ var ApplicationRunner = class {
4010
4400
  write: false,
4011
4401
  logLevel: "warning"
4012
4402
  });
4013
- const rootPackageJson = app.workspace.readJson("package.json");
4403
+ const rootPackageJson = app.workspace.getPackageJson();
4014
4404
  const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson, ["next", "react", "react-dom"]);
4015
4405
  buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
4016
4406
  const appPackageJson = {
@@ -4023,8 +4413,8 @@ var ApplicationRunner = class {
4023
4413
  };
4024
4414
  app.dist.writeJson("frontend/package.json", appPackageJson);
4025
4415
  await Promise.all([
4026
- app.cp(".next", import_path4.default.join(app.dist.cwdPath, "frontend", ".next")),
4027
- app.cp("public", import_path4.default.join(app.dist.cwdPath, "frontend", "public"))
4416
+ app.cp(".next", import_path5.default.join(app.dist.cwdPath, "frontend", ".next")),
4417
+ app.cp("public", import_path5.default.join(app.dist.cwdPath, "frontend", "public"))
4028
4418
  ]);
4029
4419
  app.dist.writeFile("frontend/Dockerfile", akanConfig.frontend.docker.content);
4030
4420
  }
@@ -4223,6 +4613,11 @@ var ApplicationRunner = class {
4223
4613
  ]);
4224
4614
  }
4225
4615
  async dbup(workspace) {
4616
+ try {
4617
+ await workspace.exec(`docker ps`);
4618
+ } catch (e) {
4619
+ throw new Error(`Docker daemon is not running. Please install docker or start docker daemon and try again.`);
4620
+ }
4226
4621
  await workspace.applyTemplate({
4227
4622
  basePath: "local",
4228
4623
  template: "localDev",
@@ -4299,8 +4694,8 @@ var ApplicationRunner = class {
4299
4694
  )
4300
4695
  );
4301
4696
  await Promise.all(
4302
- [".next", "ios", "android", "public/libs"].map(async (path9) => {
4303
- const targetPath = `${sourceRoot}/apps/${app.name}/${path9}`;
4697
+ [".next", "ios", "android", "public/libs"].map(async (path10) => {
4698
+ const targetPath = `${sourceRoot}/apps/${app.name}/${path10}`;
4304
4699
  if (import_fs10.default.existsSync(targetPath))
4305
4700
  await import_promises3.default.rm(targetPath, { recursive: true, force: true });
4306
4701
  })
@@ -4318,7 +4713,7 @@ var ApplicationRunner = class {
4318
4713
  ];
4319
4714
  await Promise.all(
4320
4715
  syncPaths.map(
4321
- (path9) => import_promises3.default.cp(`${app.workspace.cwdPath}/${path9}`, `${sourceRoot}/${path9}`, { recursive: true })
4716
+ (path10) => import_promises3.default.cp(`${app.workspace.cwdPath}/${path10}`, `${sourceRoot}/${path10}`, { recursive: true })
4322
4717
  )
4323
4718
  );
4324
4719
  const tsconfig = app.workspace.readJson("tsconfig.json");
@@ -4441,10 +4836,9 @@ var ApplicationScript = class {
4441
4836
  }
4442
4837
  async syncApplication(app) {
4443
4838
  const spinner = app.spinning("Scanning application...");
4444
- const akanConfig = await this.#runner.getConfig(app);
4445
- const scanResult = await this.#runner.scanSync(app, akanConfig);
4839
+ const scanInfo = await this.#runner.scanSync(app);
4446
4840
  spinner.succeed("Application scanned");
4447
- return scanResult;
4841
+ return scanInfo;
4448
4842
  }
4449
4843
  async script(app, filename) {
4450
4844
  const scriptFilename = filename ?? await this.#runner.getScriptFilename(app);
@@ -4888,8 +5282,8 @@ var PackageRunner = class {
4888
5282
  return scanResult;
4889
5283
  }
4890
5284
  async buildPackage(pkg) {
4891
- const rootPackageJson = pkg.workspace.readJson("package.json");
4892
- const pkgJson = pkg.readJson("package.json");
5285
+ const rootPackageJson = pkg.workspace.getPackageJson();
5286
+ const pkgJson = pkg.getPackageJson();
4893
5287
  const builder = new Builder({ executor: pkg, distExecutor: pkg.dist, pkgJson, rootPackageJson });
4894
5288
  if (pkg.name === "@akanjs/cli")
4895
5289
  await builder.build({
@@ -5063,7 +5457,7 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
5063
5457
  }
5064
5458
  async #updateAkanPkgs(workspace) {
5065
5459
  const latestPublishedVersionOfBase = await (0, import_latest_version.default)("@akanjs/base");
5066
- const rootPackageJson = workspace.readJson("package.json");
5460
+ const rootPackageJson = workspace.getPackageJson();
5067
5461
  if (!rootPackageJson.dependencies)
5068
5462
  throw new Error("No dependencies found in package.json");
5069
5463
  Object.keys(rootPackageJson.dependencies).forEach((dependency) => {
@@ -5074,7 +5468,7 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
5074
5468
  if (dependency.startsWith("@akanjs/"))
5075
5469
  Object.assign(rootPackageJson.devDependencies ?? {}, { [dependency]: latestPublishedVersionOfBase });
5076
5470
  });
5077
- workspace.writeJson("package.json", rootPackageJson);
5471
+ workspace.setPackageJson(rootPackageJson);
5078
5472
  await workspace.spawn("pnpm", ["install"]);
5079
5473
  }
5080
5474
  };
@@ -5630,8 +6024,7 @@ var ModuleScript = class {
5630
6024
  await this.#runner.createModuleTemplate(mod);
5631
6025
  if (page && sys3.type === "app")
5632
6026
  await this.pageScript.createCrudPage(mod, { app: sys3, basePath: null, single: false });
5633
- const akanConfig = await sys3.getConfig();
5634
- await sys3.scan({ akanConfig });
6027
+ await sys3.scan();
5635
6028
  }
5636
6029
  async createModule(sys3, name, description, schemaDescription) {
5637
6030
  const session = new AiSession("createModule", { workspace: sys3.workspace, cacheKey: name });
@@ -5862,13 +6255,13 @@ PageCommand = __decorateClass([
5862
6255
 
5863
6256
  // pkgs/@akanjs/cli/src/workspace/workspace.runner.ts
5864
6257
  var import_latest_version2 = __toESM(require("latest-version"), 1);
5865
- var import_path5 = __toESM(require("path"), 1);
6258
+ var import_path6 = __toESM(require("path"), 1);
5866
6259
  var import_uuid2 = require("uuid");
5867
6260
  var WorkspaceRunner = class {
5868
6261
  async createWorkspace(repoName, appName, dirname3 = ".") {
5869
6262
  const cwdPath = process.cwd();
5870
- const workspaceRoot = import_path5.default.join(cwdPath, dirname3, repoName);
5871
- const workspace = new WorkspaceExecutor({ workspaceRoot, repoName });
6263
+ const workspaceRoot = import_path6.default.join(cwdPath, dirname3, repoName);
6264
+ const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
5872
6265
  const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname3}/${repoName}...`);
5873
6266
  await workspace.applyTemplate({
5874
6267
  basePath: ".",
@@ -5876,7 +6269,7 @@ var WorkspaceRunner = class {
5876
6269
  dict: { repoName, appName, serveDomain: "localhost" }
5877
6270
  });
5878
6271
  templateSpinner.succeed(`Workspace files created in ${dirname3}/${repoName}`);
5879
- const rootPackageJson = workspace.readJson("package.json");
6272
+ const rootPackageJson = workspace.getPackageJson();
5880
6273
  const dependencies = [
5881
6274
  "@akanjs/base",
5882
6275
  "@akanjs/cli",
@@ -6066,15 +6459,15 @@ var GuidelinePrompt = class extends Prompter {
6066
6459
  async #getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
6067
6460
  const matchingPaths = import_promises5.default.glob(matchPattern, {
6068
6461
  cwd: this.workspace.workspaceRoot,
6069
- exclude: (path9) => avoidDirs.some((dir) => path9.includes(dir))
6462
+ exclude: (path10) => avoidDirs.some((dir) => path10.includes(dir))
6070
6463
  });
6071
6464
  const paths = [];
6072
- for await (const path9 of matchingPaths) {
6073
- const fileContent = import_fs12.default.readFileSync(path9, "utf-8");
6465
+ for await (const path10 of matchingPaths) {
6466
+ const fileContent = import_fs12.default.readFileSync(path10, "utf-8");
6074
6467
  const textFilter = filterText ? new RegExp(filterText) : null;
6075
6468
  if (filterText && !textFilter?.test(fileContent))
6076
6469
  continue;
6077
- paths.push(path9);
6470
+ paths.push(path10);
6078
6471
  }
6079
6472
  return paths;
6080
6473
  }