@akanjs/cli 0.9.20 → 0.9.22

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 (192) hide show
  1. package/cjs/index.js +274 -295
  2. package/esm/index.js +274 -295
  3. package/esm/src/templates/__scalar/__model__/__model__.constant.js +1 -0
  4. package/esm/src/templates/__scalar/__model__/__model__.dictionary.js +1 -0
  5. package/esm/src/templates/__scalar/__model__/__model__.document.js +1 -0
  6. package/esm/src/templates/app/akan.config.js +1 -0
  7. package/esm/src/templates/app/app/[lang]/(__appName__)/(public)/page.js +1 -0
  8. package/esm/src/templates/app/app/[lang]/(__appName__)/(public)/unknown/page.js +1 -0
  9. package/esm/src/templates/app/app/[lang]/(__appName__)/layout.js +1 -0
  10. package/esm/src/templates/app/app/[lang]/admin/layout.js +1 -0
  11. package/esm/src/templates/app/app/[lang]/admin/page.js +1 -0
  12. package/esm/src/templates/app/app/csr.js +1 -0
  13. package/esm/src/templates/app/app/layout.js +1 -0
  14. package/esm/src/templates/app/app/robots.js +1 -0
  15. package/esm/src/templates/app/app/sitemap.js +1 -0
  16. package/esm/src/templates/app/base/baseLogic.js +1 -0
  17. package/esm/src/templates/app/base/index.js +1 -0
  18. package/esm/src/templates/app/common/commonLogic.js +1 -0
  19. package/esm/src/templates/app/common/index.js +1 -0
  20. package/esm/src/templates/app/env/env.client.debug.ts.template +0 -0
  21. package/esm/src/templates/app/env/env.client.develop.ts.template +0 -0
  22. package/esm/src/templates/app/env/env.client.js +1 -0
  23. package/esm/src/templates/app/env/env.client.local.ts.template +0 -0
  24. package/esm/src/templates/app/env/env.client.main.ts.template +0 -0
  25. package/esm/src/templates/app/env/env.client.testing.ts.template +0 -0
  26. package/esm/src/templates/app/env/env.client.type.js +1 -0
  27. package/esm/src/templates/app/env/env.server.debug.ts.template +0 -0
  28. package/esm/src/templates/app/env/env.server.develop.ts.template +0 -0
  29. package/esm/src/templates/app/env/env.server.js +1 -0
  30. package/esm/src/templates/app/env/env.server.local.ts.template +0 -0
  31. package/esm/src/templates/app/env/env.server.main.ts.template +0 -0
  32. package/esm/src/templates/app/env/env.server.testing.ts.template +0 -0
  33. package/esm/src/templates/app/jest.config.js +1 -0
  34. package/esm/src/templates/app/lib/___appName__/__appName__.dictionary.js +1 -0
  35. package/esm/src/templates/app/lib/___appName__/__appName__.service.js +1 -0
  36. package/esm/src/templates/app/lib/___appName__/__appName__.store.js +1 -0
  37. package/esm/src/templates/app/lib/___appName__/_server.js +1 -0
  38. package/esm/src/templates/app/lib/option.js +1 -0
  39. package/esm/src/templates/app/lib/setting/Setting.Template.js +1 -0
  40. package/esm/src/templates/app/lib/setting/Setting.Unit.js +1 -0
  41. package/esm/src/templates/app/lib/setting/Setting.Util.js +1 -0
  42. package/esm/src/templates/app/lib/setting/Setting.View.js +1 -0
  43. package/esm/src/templates/app/lib/setting/Setting.Zone.js +1 -0
  44. package/esm/src/templates/app/lib/setting/_server.js +1 -0
  45. package/esm/src/templates/app/lib/setting/index.js +1 -0
  46. package/esm/src/templates/app/lib/setting/setting.constant.js +1 -0
  47. package/esm/src/templates/app/lib/setting/setting.dictionary.js +1 -0
  48. package/esm/src/templates/app/lib/setting/setting.document.js +1 -0
  49. package/esm/src/templates/app/lib/setting/setting.service.js +1 -0
  50. package/esm/src/templates/app/lib/setting/setting.signal.js +1 -0
  51. package/esm/src/templates/app/lib/setting/setting.store.js +1 -0
  52. package/esm/src/templates/app/lib/summary/Summary.Template.js +1 -0
  53. package/esm/src/templates/app/lib/summary/Summary.Unit.js +1 -0
  54. package/esm/src/templates/app/lib/summary/Summary.Util.js +1 -0
  55. package/esm/src/templates/app/lib/summary/Summary.View.js +1 -0
  56. package/esm/src/templates/app/lib/summary/Summary.Zone.js +1 -0
  57. package/esm/src/templates/app/lib/summary/_server.js +1 -0
  58. package/esm/src/templates/app/lib/summary/index.js +1 -0
  59. package/esm/src/templates/app/lib/summary/summary.constant.js +1 -0
  60. package/esm/src/templates/app/lib/summary/summary.dictionary.js +1 -0
  61. package/esm/src/templates/app/lib/summary/summary.document.js +1 -0
  62. package/esm/src/templates/app/lib/summary/summary.service.js +1 -0
  63. package/esm/src/templates/app/lib/summary/summary.signal.js +1 -0
  64. package/esm/src/templates/app/lib/summary/summary.store.js +1 -0
  65. package/esm/src/templates/app/lib/user/User.Template.js +1 -0
  66. package/esm/src/templates/app/lib/user/User.Unit.js +1 -0
  67. package/esm/src/templates/app/lib/user/User.Util.js +1 -0
  68. package/esm/src/templates/app/lib/user/User.View.js +1 -0
  69. package/esm/src/templates/app/lib/user/User.Zone.js +1 -0
  70. package/esm/src/templates/app/lib/user/_server.js +1 -0
  71. package/esm/src/templates/app/lib/user/index.js +1 -0
  72. package/esm/src/templates/app/lib/user/user.constant.js +1 -0
  73. package/esm/src/templates/app/lib/user/user.dictionary.js +1 -0
  74. package/esm/src/templates/app/lib/user/user.document.js +1 -0
  75. package/esm/src/templates/app/lib/user/user.service.js +1 -0
  76. package/esm/src/templates/app/lib/user/user.signal.js +1 -0
  77. package/esm/src/templates/app/lib/user/user.signal.spec.js +1 -0
  78. package/esm/src/templates/app/lib/user/user.signal.test.js +1 -0
  79. package/esm/src/templates/app/lib/user/user.store.js +1 -0
  80. package/esm/src/templates/app/main.js +1 -0
  81. package/esm/src/templates/app/middleware.js +1 -0
  82. package/esm/src/templates/app/nest/backendLogic.js +1 -0
  83. package/esm/src/templates/app/nest/index.js +1 -0
  84. package/esm/src/templates/app/next/frontendLogic.js +1 -0
  85. package/esm/src/templates/app/next/index.js +1 -0
  86. package/esm/src/templates/app/ui/UiComponent.js +1 -0
  87. package/esm/src/templates/app/ui/index.js +1 -0
  88. package/esm/src/templates/client.js +2 -1
  89. package/esm/src/templates/crudPages/[__model__Id]/edit/page.js +1 -0
  90. package/esm/src/templates/crudPages/[__model__Id]/page.js +1 -0
  91. package/esm/src/templates/crudPages/new/page.js +1 -0
  92. package/esm/src/templates/crudPages/page.js +1 -0
  93. package/esm/src/templates/index.js +1 -0
  94. package/esm/src/templates/lib/__lib/extends/summary.constant.js +2 -1
  95. package/esm/src/templates/lib/__lib/lib.constant.js +1 -0
  96. package/esm/src/templates/lib/__lib/lib.dictionary.js +1 -0
  97. package/esm/src/templates/lib/__lib/lib.document.js +1 -0
  98. package/esm/src/templates/lib/__lib/lib.service.js +2 -1
  99. package/esm/src/templates/lib/__lib/lib.signal.js +1 -0
  100. package/esm/src/templates/lib/__lib/lib.store.js +1 -0
  101. package/esm/src/templates/lib/__scalar/_server.js +2 -1
  102. package/esm/src/templates/lib/cnst.js +1 -0
  103. package/esm/src/templates/lib/cnst_.js +1 -0
  104. package/esm/src/templates/lib/db.js +1 -0
  105. package/esm/src/templates/lib/dict.js +1 -0
  106. package/esm/src/templates/lib/fetch.js +2 -1
  107. package/esm/src/templates/lib/sig.js +2 -1
  108. package/esm/src/templates/lib/srv.js +2 -1
  109. package/esm/src/templates/lib/st.js +1 -0
  110. package/esm/src/templates/lib/store.js +2 -1
  111. package/esm/src/templates/lib/usePage.js +1 -0
  112. package/esm/src/templates/libRoot/akan.config.js +1 -0
  113. package/esm/src/templates/libRoot/base/baseLogic.js +1 -0
  114. package/esm/src/templates/libRoot/base/index.js +1 -0
  115. package/esm/src/templates/libRoot/common/commonLogic.js +1 -0
  116. package/esm/src/templates/libRoot/common/index.js +1 -0
  117. package/esm/src/templates/libRoot/jest.config.js +1 -0
  118. package/esm/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +1 -0
  119. package/esm/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -0
  120. package/esm/src/templates/libRoot/lib/___libName__/__libName__.store.js +1 -0
  121. package/esm/src/templates/libRoot/lib/___libName__/_server.js +1 -0
  122. package/esm/src/templates/libRoot/lib/option.js +1 -0
  123. package/esm/src/templates/libRoot/lib/setting/Setting.Template.js +1 -0
  124. package/esm/src/templates/libRoot/lib/setting/Setting.Unit.js +1 -0
  125. package/esm/src/templates/libRoot/lib/setting/Setting.Util.js +1 -0
  126. package/esm/src/templates/libRoot/lib/setting/Setting.View.js +1 -0
  127. package/esm/src/templates/libRoot/lib/setting/Setting.Zone.js +1 -0
  128. package/esm/src/templates/libRoot/lib/setting/_server.js +1 -0
  129. package/esm/src/templates/libRoot/lib/setting/index.js +1 -0
  130. package/esm/src/templates/libRoot/lib/setting/setting.constant.js +1 -0
  131. package/esm/src/templates/libRoot/lib/setting/setting.dictionary.js +1 -0
  132. package/esm/src/templates/libRoot/lib/setting/setting.document.js +1 -0
  133. package/esm/src/templates/libRoot/lib/setting/setting.service.js +1 -0
  134. package/esm/src/templates/libRoot/lib/setting/setting.signal.js +1 -0
  135. package/esm/src/templates/libRoot/lib/setting/setting.store.js +1 -0
  136. package/esm/src/templates/libRoot/lib/summary/Summary.Template.js +1 -0
  137. package/esm/src/templates/libRoot/lib/summary/Summary.Unit.js +1 -0
  138. package/esm/src/templates/libRoot/lib/summary/Summary.Util.js +1 -0
  139. package/esm/src/templates/libRoot/lib/summary/Summary.View.js +1 -0
  140. package/esm/src/templates/libRoot/lib/summary/Summary.Zone.js +1 -0
  141. package/esm/src/templates/libRoot/lib/summary/_server.js +1 -0
  142. package/esm/src/templates/libRoot/lib/summary/index.js +1 -0
  143. package/esm/src/templates/libRoot/lib/summary/summary.constant.js +1 -0
  144. package/esm/src/templates/libRoot/lib/summary/summary.dictionary.js +1 -0
  145. package/esm/src/templates/libRoot/lib/summary/summary.document.js +1 -0
  146. package/esm/src/templates/libRoot/lib/summary/summary.service.js +1 -0
  147. package/esm/src/templates/libRoot/lib/summary/summary.signal.js +1 -0
  148. package/esm/src/templates/libRoot/lib/summary/summary.store.js +1 -0
  149. package/esm/src/templates/libRoot/lib/user/User.Template.js +1 -0
  150. package/esm/src/templates/libRoot/lib/user/User.Unit.js +1 -0
  151. package/esm/src/templates/libRoot/lib/user/User.Util.js +1 -0
  152. package/esm/src/templates/libRoot/lib/user/User.View.js +1 -0
  153. package/esm/src/templates/libRoot/lib/user/User.Zone.js +1 -0
  154. package/esm/src/templates/libRoot/lib/user/_server.js +1 -0
  155. package/esm/src/templates/libRoot/lib/user/index.js +1 -0
  156. package/esm/src/templates/libRoot/lib/user/user.constant.js +1 -0
  157. package/esm/src/templates/libRoot/lib/user/user.dictionary.js +1 -0
  158. package/esm/src/templates/libRoot/lib/user/user.document.js +1 -0
  159. package/esm/src/templates/libRoot/lib/user/user.service.js +1 -0
  160. package/esm/src/templates/libRoot/lib/user/user.signal.js +1 -0
  161. package/esm/src/templates/libRoot/lib/user/user.signal.spec.js +1 -0
  162. package/esm/src/templates/libRoot/lib/user/user.signal.test.js +1 -0
  163. package/esm/src/templates/libRoot/lib/user/user.store.js +1 -0
  164. package/esm/src/templates/libRoot/nest/backendLogic.js +1 -0
  165. package/esm/src/templates/libRoot/nest/index.js +1 -0
  166. package/esm/src/templates/libRoot/next/frontendLogic.js +1 -0
  167. package/esm/src/templates/libRoot/next/index.js +1 -0
  168. package/esm/src/templates/libRoot/ui/index.js +1 -0
  169. package/esm/src/templates/module/__Model__.Template.js +1 -0
  170. package/esm/src/templates/module/__Model__.Unit.js +1 -0
  171. package/esm/src/templates/module/__Model__.Util.js +1 -0
  172. package/esm/src/templates/module/__Model__.View.js +1 -0
  173. package/esm/src/templates/module/__Model__.Zone.js +1 -0
  174. package/esm/src/templates/module/__model__.constant.js +1 -0
  175. package/esm/src/templates/module/__model__.dictionary.js +1 -0
  176. package/esm/src/templates/module/__model__.document.js +1 -0
  177. package/esm/src/templates/module/__model__.service.js +1 -0
  178. package/esm/src/templates/module/__model__.signal.js +1 -0
  179. package/esm/src/templates/module/__model__.signal.spec.js +1 -0
  180. package/esm/src/templates/module/__model__.signal.test.js +1 -0
  181. package/esm/src/templates/module/__model__.store.js +1 -0
  182. package/esm/src/templates/module/_server.js +1 -0
  183. package/esm/src/templates/module/index.js +1 -0
  184. package/esm/src/templates/server.js +2 -1
  185. package/package.json +1 -1
  186. package/src/application/application.interface.d.ts +40 -0
  187. package/src/application/application.runner.d.ts +14 -7
  188. package/src/application/application.script.d.ts +12 -6
  189. package/ui/MultiScrollList.d.ts +2 -1
  190. package/src/application/appilcation.interface.d.ts +0 -11
  191. package/ui/ScrollList.d.ts +0 -7
  192. package/ui/index.d.ts +0 -1
package/esm/index.js CHANGED
@@ -3523,115 +3523,35 @@ var LibraryScript = class {
3523
3523
  }
3524
3524
  };
3525
3525
 
3526
- // pkgs/@akanjs/cli/src/application/application.runner.ts
3527
- import { confirm as confirm2, input as input4, select as select5 } from "@inquirer/prompts";
3528
- import { StringOutputParser } from "@langchain/core/output_parsers";
3529
- import { PromptTemplate as PromptTemplate2 } from "@langchain/core/prompts";
3530
- import { RunnableSequence as RunnableSequence2 } from "@langchain/core/runnables";
3531
- import { ChatOpenAI as ChatOpenAI3 } from "@langchain/openai";
3532
- import react from "@vitejs/plugin-react";
3533
- import dotenv3 from "dotenv";
3534
- import * as esbuild2 from "esbuild";
3535
- import fs14 from "fs";
3536
- import fsPromise3 from "fs/promises";
3537
- import yaml2 from "js-yaml";
3538
- import openBrowser from "open";
3539
- import ora3 from "ora";
3540
- import path7 from "path";
3541
- import * as vite from "vite";
3542
- import commonjs from "vite-plugin-commonjs";
3543
- import { nodePolyfills } from "vite-plugin-node-polyfills";
3544
- import tsconfigPaths from "vite-tsconfig-paths";
3545
-
3546
- // pkgs/@akanjs/cli/src/application/appilcation.interface.tsx
3547
- import { Box as Box3, render, Text as Text3 } from "ink";
3548
- import React3, { useEffect as useEffect4, useState as useState4 } from "react";
3526
+ // pkgs/@akanjs/cli/src/application/application.interface.tsx
3527
+ import { Box as Box2, render, Text as Text2, useApp } from "ink";
3528
+ import React2, { useEffect as useEffect3, useState as useState3 } from "react";
3549
3529
 
3550
- // pkgs/@akanjs/cli/ui/ScrollList.tsx
3530
+ // pkgs/@akanjs/cli/ui/MultiScrollList.tsx
3551
3531
  import { Box, Newline, Text, useInput } from "ink";
3552
3532
  import React, { useEffect as useEffect2, useState as useState2 } from "react";
3553
- var ScrollList = ({ list, ...props }) => {
3554
- const [renderLogs, setRenderLogs] = useState2(list);
3533
+ var HEADER_HEIGHT = 1;
3534
+ var FOOTER_HEIGHT = 5;
3535
+ var BORDER_HEIGHT = 2;
3536
+ var MultiScrollList = ({ logList, maxLength = 100 }) => {
3555
3537
  const [width, height] = useStdoutDimensions();
3538
+ const [focusLog, setFocusLog] = useState2([]);
3539
+ const [lengthMap, setLengthMap] = useState2(/* @__PURE__ */ new Map());
3556
3540
  const [scrollPos, setScrollPos] = useState2(0);
3541
+ const [tabIndex, setTabIndex] = useState2(0);
3557
3542
  const [isRunning, setIsRunning] = useState2(false);
3558
- const [boxHeight, setBoxHeight] = useState2(height - 3);
3543
+ const [boxHeight, setBoxHeight] = useState2(height - HEADER_HEIGHT - FOOTER_HEIGHT - BORDER_HEIGHT);
3544
+ const getLimitedLogs = (logs) => {
3545
+ return logs.length > maxLength ? logs.slice(logs.length - maxLength) : logs;
3546
+ };
3559
3547
  useInput((input6, key) => {
3560
- if (key.escape) {
3561
- setIsRunning(false);
3548
+ if (key.tab) {
3549
+ setTabIndex((prev) => (prev + 1) % logList.length);
3562
3550
  setScrollPos(0);
3563
- }
3564
- if (input6 === " " && isRunning) {
3565
3551
  setIsRunning(false);
3566
- setScrollPos(0);
3567
- }
3568
- if (key.downArrow && scrollPos > 0) {
3569
- if (key.shift) {
3570
- setScrollPos(scrollPos - 10);
3571
- } else {
3572
- setScrollPos(scrollPos - 1);
3573
- }
3574
- }
3575
- if (key.upArrow && scrollPos < list.length - boxHeight) {
3576
- if (key.shift) {
3577
- setScrollPos(scrollPos + 10);
3578
- } else {
3579
- setScrollPos(scrollPos + 1);
3580
- }
3581
- }
3582
- });
3583
- useEffect2(() => {
3584
- if (isRunning) {
3585
- setScrollPos(scrollPos + 1);
3586
- return;
3587
- }
3588
- if (list.length > boxHeight) {
3589
- setRenderLogs(list.slice(list.length - boxHeight, list.length));
3590
- } else {
3591
- setRenderLogs(list);
3592
- }
3593
- }, [list, isRunning]);
3594
- useEffect2(() => {
3595
- setBoxHeight(Math.floor(height * 0.9));
3596
- }, [height]);
3597
- useEffect2(() => {
3598
- if (scrollPos > 0) {
3599
- setRenderLogs(list.slice(list.length - boxHeight - scrollPos, list.length - scrollPos));
3600
- setIsRunning(true);
3601
- } else {
3602
- setRenderLogs(list.slice(list.length - boxHeight, list.length));
3603
- setIsRunning(false);
3604
- }
3605
- }, [scrollPos]);
3606
- return /* @__PURE__ */ React.createElement(Box, { ...props, width, height: "100%", flexDirection: "column" }, /* @__PURE__ */ React.createElement(Box, { borderStyle: "round", width, height: height - 3 }, /* @__PURE__ */ React.createElement(Newline, null), /* @__PURE__ */ React.createElement(Text, null, isRunning ? /* @__PURE__ */ React.createElement(React.Fragment, null, renderLogs.slice(0, renderLogs.length - 1).map((log, index) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { key: index }, log), /* @__PURE__ */ React.createElement(Newline, null))), /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "scrolling... + ", scrollPos)) : /* @__PURE__ */ React.createElement(React.Fragment, null, renderLogs.map((log, index) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { key: index }, log), /* @__PURE__ */ React.createElement(Newline, null)))))), /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "You can use the following shortcuts:", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "up"), " and ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "down"), " to scroll.", " ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "shift"), " to scroll faster.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "escape"), " to stop scrolling.")));
3607
- };
3608
-
3609
- // pkgs/@akanjs/cli/ui/MultiScrollList.tsx
3610
- import { Box as Box2, Newline as Newline2, Text as Text2, useInput as useInput2 } from "ink";
3611
- import React2, { useEffect as useEffect3, useState as useState3 } from "react";
3612
- var MultiScrollList = ({ logList }) => {
3613
- const [width, height] = useStdoutDimensions();
3614
- const [renderMultiLogs, setRenderMultiLogs] = useState3(
3615
- Array.from({ length: logList.length }, () => [])
3616
- );
3617
- const [lengthMap, setLengthMap] = useState3(/* @__PURE__ */ new Map());
3618
- const [scrollPos, setScrollPos] = useState3(0);
3619
- const [tabIndex, setTabIndex] = useState3(null);
3620
- const [isRunning, setIsRunning] = useState3(false);
3621
- const [boxHeight, setBoxHeight] = useState3(height - 7);
3622
- useInput2((input6, key) => {
3623
- if (key.tab) {
3624
- if (tabIndex === null) {
3625
- setTabIndex(0);
3626
- } else {
3627
- setTabIndex((prev) => (prev + 1) % logList.length);
3628
- setIsRunning(false);
3629
- }
3630
3552
  }
3631
3553
  if (key.escape) {
3632
3554
  setScrollPos(0);
3633
- if (tabIndex !== null)
3634
- setTabIndex(null);
3635
3555
  setIsRunning(false);
3636
3556
  }
3637
3557
  if (input6 === " ") {
@@ -3651,230 +3571,277 @@ var MultiScrollList = ({ logList }) => {
3651
3571
  setScrollPos(newScrollPos);
3652
3572
  }
3653
3573
  }
3654
- if (key.upArrow && tabIndex !== null && scrollPos < logList[tabIndex].logs.length - boxHeight) {
3655
- if (key.shift) {
3656
- const newScrollPos = scrollPos + 10;
3657
- if (newScrollPos > logList[tabIndex].logs.length - boxHeight) {
3658
- setScrollPos(logList[tabIndex].logs.length - boxHeight);
3574
+ if (key.upArrow && scrollPos < logList[tabIndex].logs.length - boxHeight) {
3575
+ const limitedLogs = getLimitedLogs(logList[tabIndex].logs);
3576
+ if (scrollPos < limitedLogs.length - boxHeight) {
3577
+ if (key.shift) {
3578
+ const newScrollPos = scrollPos + 10;
3579
+ if (newScrollPos > limitedLogs.length - boxHeight) {
3580
+ setScrollPos(limitedLogs.length - boxHeight);
3581
+ } else {
3582
+ setScrollPos(newScrollPos);
3583
+ }
3659
3584
  } else {
3660
- setScrollPos(newScrollPos);
3585
+ setScrollPos(scrollPos + 1);
3661
3586
  }
3662
- } else {
3663
- setScrollPos(scrollPos + 1);
3587
+ if (!isRunning)
3588
+ setIsRunning(true);
3664
3589
  }
3665
- if (!isRunning)
3666
- setIsRunning(true);
3667
3590
  }
3668
3591
  });
3669
- useEffect3(() => {
3592
+ useEffect2(() => {
3670
3593
  const getLogsToRender = (logs, index) => {
3594
+ const limitedLogs = getLimitedLogs(logs);
3671
3595
  if (scrollPos > 0 && tabIndex === index) {
3672
- return logs.slice(logs.length - boxHeight - scrollPos, logs.length - scrollPos);
3673
- } else if (logs.length > boxHeight) {
3674
- return logs.slice(logs.length - boxHeight, logs.length);
3596
+ return limitedLogs.slice(limitedLogs.length - boxHeight - scrollPos, limitedLogs.length - scrollPos);
3597
+ } else if (limitedLogs.length > boxHeight) {
3598
+ return limitedLogs.slice(limitedLogs.length - boxHeight, limitedLogs.length);
3675
3599
  } else {
3676
- return logs;
3600
+ return limitedLogs;
3677
3601
  }
3678
3602
  };
3679
3603
  if (isRunning) {
3680
- if (tabIndex !== null && lengthMap.has(tabIndex)) {
3604
+ if (lengthMap.has(tabIndex)) {
3681
3605
  const tabLength = lengthMap.get(tabIndex);
3682
- if (tabLength && tabLength < logList[tabIndex].logs.length) {
3606
+ const limitedLogsLength = Math.min(logList[tabIndex].logs.length, maxLength);
3607
+ if (tabLength && tabLength < limitedLogsLength) {
3683
3608
  setScrollPos(scrollPos + 1);
3684
- lengthMap.set(tabIndex, logList[tabIndex].logs.length);
3609
+ lengthMap.set(tabIndex, limitedLogsLength);
3685
3610
  }
3686
3611
  }
3687
- setRenderMultiLogs((prev) => {
3688
- const newState = [...prev];
3689
- logList.forEach((logData, index) => {
3690
- newState[index] = getLogsToRender(logData.logs, index);
3691
- });
3692
- return newState;
3693
- });
3612
+ setFocusLog(getLogsToRender(logList[tabIndex].logs, tabIndex));
3694
3613
  } else {
3695
- setRenderMultiLogs((prev) => {
3696
- const newState = [...prev];
3697
- logList.forEach((logData, index) => {
3698
- lengthMap.set(index, logData.logs.length);
3699
- newState[index] = getLogsToRender(logData.logs, index);
3700
- });
3701
- return newState;
3702
- });
3614
+ setFocusLog(getLogsToRender(logList[tabIndex].logs, tabIndex));
3703
3615
  }
3704
- }, [logList, isRunning, scrollPos, tabIndex, boxHeight]);
3705
- useEffect3(() => {
3706
- setBoxHeight(height - 7);
3616
+ }, [logList, isRunning, scrollPos, tabIndex, boxHeight, maxLength]);
3617
+ useEffect2(() => {
3618
+ setBoxHeight(height - HEADER_HEIGHT - FOOTER_HEIGHT - BORDER_HEIGHT);
3707
3619
  }, [height]);
3708
- useEffect3(() => {
3709
- setLengthMap(new Map(logList.map((log, index) => [index, log.logs.length])));
3710
- }, []);
3711
- return /* @__PURE__ */ React2.createElement(Box2, { width, height, flexDirection: "column" }, /* @__PURE__ */ React2.createElement(Box2, { width, height: "100%" }, renderMultiLogs.map((logData, index) => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Box2, { width, height: "100%", flexDirection: "column", key: index }, /* @__PURE__ */ React2.createElement(Box2, null, /* @__PURE__ */ React2.createElement(Text2, { color: logList[index].color }, logList[index].title)), /* @__PURE__ */ React2.createElement(
3712
- Box2,
3620
+ useEffect2(() => {
3621
+ setLengthMap(new Map(logList.map((log, index) => [index, Math.min(log.logs.length, maxLength)])));
3622
+ }, [logList, maxLength]);
3623
+ return /* @__PURE__ */ React.createElement(Box, { width, height, flexDirection: "column" }, /* @__PURE__ */ React.createElement(Box, { width, height: "80%", flexDirection: "row" }, /* @__PURE__ */ React.createElement(Box, { width: 30, height: "100%", flexDirection: "column" }, /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Text, null, "List ", tabIndex + 1, "/", logList.length)), /* @__PURE__ */ React.createElement(Box, { borderStyle: "round", borderColor: "blackBright", width: "100%", height: "100%", flexDirection: "column" }, logList.map((log, index) => {
3624
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { color: index === tabIndex ? "green" : "white" }, /* @__PURE__ */ React.createElement(Text, null, "\u25CF"), "\xA0", log.title.length > 25 ? log.title.slice(0, 25) + "..." : log.title));
3625
+ }))), /* @__PURE__ */ React.createElement(Box, { width, height: boxHeight + 3, flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, null, logList[tabIndex].title), /* @__PURE__ */ React.createElement(
3626
+ Box,
3713
3627
  {
3714
- flexWrap: "wrap",
3715
- height,
3716
- borderStyle: index === tabIndex ? "double" : "round",
3717
- borderDimColor: index !== tabIndex,
3718
- borderColor: index === tabIndex && isRunning ? "green" : logList[index].color
3628
+ borderStyle: isRunning ? "double" : "round",
3629
+ flexDirection: "column",
3630
+ borderColor: logList[tabIndex].color,
3631
+ width: "100%",
3632
+ height: "100%"
3719
3633
  },
3720
- /* @__PURE__ */ React2.createElement(Text2, null, isRunning && tabIndex === index ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, logData.slice(0, logData.length - 1).map((log, index2) => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Text2, { key: index2 }, log), /* @__PURE__ */ React2.createElement(Newline2, null))), /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "scrolling... +", scrollPos)) : /* @__PURE__ */ React2.createElement(React2.Fragment, null, logData.map((data, index2) => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Text2, { key: index2 }, data), /* @__PURE__ */ React2.createElement(Newline2, null)))))
3721
- ))))), /* @__PURE__ */ React2.createElement(Box2, { width, height: "auto" }, /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, /* @__PURE__ */ React2.createElement(Text2, null, "You can use the following shortcuts:"), /* @__PURE__ */ React2.createElement(Newline2, null), "* ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "tab"), " to switch tab.", /* @__PURE__ */ React2.createElement(Newline2, null), "* ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "space"), " to scroll.", /* @__PURE__ */ React2.createElement(Newline2, null), "* ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "up"), " and ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "down"), " to scroll.", " ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "shift"), " to scroll faster.", /* @__PURE__ */ React2.createElement(Newline2, null), "* ", /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "green" }, "escape"), " to stop scrolling.")));
3634
+ scrollPos > 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, focusLog.slice(0, focusLog.length - 1).map((log, index) => /* @__PURE__ */ React.createElement(Text, { key: index }, log)), /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "Scrolling... +", scrollPos)) : focusLog.map((log, index) => /* @__PURE__ */ React.createElement(Text, { key: index }, log))
3635
+ ))), /* @__PURE__ */ React.createElement(Box, { width }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, /* @__PURE__ */ React.createElement(Text, null, "You can use the following shortcuts:"), /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "tab"), " to switch tab.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "up"), " and ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "down"), " to scroll.", " ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "shift"), " to scroll faster.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "space"), " to scroll.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "escape"), " to stop scrolling.")));
3722
3636
  };
3723
3637
 
3724
- // pkgs/@akanjs/cli/src/application/appilcation.interface.tsx
3725
- var Backend = ({ app, env }) => {
3726
- const [logs, setLogs] = useState4([]);
3638
+ // pkgs/@akanjs/cli/src/application/application.interface.tsx
3639
+ var Backend = ({ appName, childProcess, onExit }) => {
3640
+ const [logs, setLogs] = useState3([]);
3727
3641
  const [width, height] = useStdoutDimensions();
3728
- useEffect4(() => {
3729
- const proc = app.dist.spawnSync("node", ["--watch", "main.js"], {
3730
- env,
3731
- stdio: "pipe",
3732
- cwd: `${app.dist.cwdPath}/backend`
3733
- });
3734
- proc.stdout?.on("data", (data) => {
3642
+ useEffect3(() => {
3643
+ childProcess.stdout?.on("data", (data) => {
3735
3644
  const newOutput = data.toString().split("\n");
3736
3645
  setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3737
3646
  });
3738
- proc.stderr?.on("data", (data) => {
3647
+ childProcess.stderr?.on("data", (data) => {
3739
3648
  const newOutput = data.toString().split("\n");
3740
3649
  setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3741
3650
  });
3742
3651
  return () => {
3743
- proc.kill();
3652
+ childProcess.kill();
3653
+ onExit();
3744
3654
  };
3745
3655
  }, []);
3746
- return /* @__PURE__ */ React3.createElement(Box3, { width, height }, /* @__PURE__ */ React3.createElement(Text3, { bold: true }, "Akan.JS Backend"));
3656
+ return /* @__PURE__ */ React2.createElement(Box2, { width, height }, /* @__PURE__ */ React2.createElement(Text2, { bold: true }, "Akan.JS Backend"));
3747
3657
  };
3748
- var Frontend = ({ app, env }) => {
3749
- const [logs, setLogs] = useState4([]);
3658
+ var Frontend = ({ appName, childProcess, onExit }) => {
3659
+ const [logs, setLogs] = useState3([]);
3750
3660
  const [width, height] = useStdoutDimensions();
3751
- useEffect4(() => {
3752
- const proc = app.spawnSync("npx", ["next", "dev", "-p", "4200"], {
3753
- env,
3754
- stdio: ["ignore", "pipe", "pipe"],
3755
- detached: true
3756
- });
3757
- proc.stdout?.on("data", (data) => {
3661
+ useEffect3(() => {
3662
+ childProcess.stdout?.on("data", (data) => {
3758
3663
  const newOutput = data.toString().split("\n");
3759
3664
  setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3760
3665
  });
3761
- proc.stderr?.on("data", (data) => {
3666
+ childProcess.stderr?.on("data", (data) => {
3762
3667
  const newOutput = data.toString().split("\n");
3763
3668
  setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3764
3669
  });
3765
3670
  return () => {
3766
- proc.kill();
3671
+ childProcess.kill();
3672
+ onExit();
3767
3673
  };
3768
3674
  }, []);
3769
- return /* @__PURE__ */ React3.createElement(Box3, { width, height, flexDirection: "column" }, /* @__PURE__ */ React3.createElement(Text3, { bold: true }, "Akan.JS Frontend"), logs.map((log) => /* @__PURE__ */ React3.createElement(Text3, { key: log }, log)));
3675
+ return /* @__PURE__ */ React2.createElement(Box2, { width, height, flexDirection: "column" }, /* @__PURE__ */ React2.createElement(Text2, { bold: true }, appName, " Frontend"), logs.map((log) => /* @__PURE__ */ React2.createElement(Text2, { key: log }, log)));
3770
3676
  };
3771
- var Csr = ({
3772
- app,
3773
- onLoad
3774
- }) => {
3775
- const [logs, setLogs] = useState4([]);
3677
+ var Csr = ({ app, event, onExit }) => {
3678
+ const [logs, setLogs] = useState3([]);
3776
3679
  const [width, height] = useStdoutDimensions();
3777
- useEffect4(() => {
3778
- void onLoad({
3779
- onLog: (log) => {
3780
- setLogs((prevLogs) => [...prevLogs, log]);
3781
- }
3680
+ const [test, setTest] = useState3(false);
3681
+ useEffect3(() => {
3682
+ event.on("info", (msg) => {
3683
+ setLogs((prevLogs) => [...prevLogs, msg]);
3684
+ });
3685
+ event.on("warn", (msg) => {
3686
+ setLogs((prevLogs) => [...prevLogs, msg]);
3687
+ });
3688
+ event.on("warnOnce", (msg) => {
3689
+ setLogs((prevLogs) => [...prevLogs, msg]);
3690
+ });
3691
+ event.on("error", (msg) => {
3692
+ setLogs((prevLogs) => [...prevLogs, msg]);
3693
+ });
3694
+ event.on("clearScreen", (type) => {
3695
+ setLogs((prevLogs) => [...prevLogs, type]);
3782
3696
  });
3783
3697
  }, []);
3784
- return /* @__PURE__ */ React3.createElement(Box3, { width, height, flexDirection: "column" }, /* @__PURE__ */ React3.createElement(Text3, { bold: true }, "Akan.JS CSR"), /* @__PURE__ */ React3.createElement(ScrollList, { list: logs }));
3698
+ return /* @__PURE__ */ React2.createElement(Box2, { width, height, flexDirection: "column" }, /* @__PURE__ */ React2.createElement(Text2, null, test ? "true" : "false"), /* @__PURE__ */ React2.createElement(Text2, { bold: true }, "Akan.JS CSR"), /* @__PURE__ */ React2.createElement(Text2, null, logs));
3785
3699
  };
3786
- var Start = ({
3787
- app,
3788
- backendEnv,
3789
- frontendEnv,
3790
- onLoadCsr
3791
- }) => {
3700
+ var Start = ({ appName, bcp, fcp, csr, onExit, maxLength = 100 }) => {
3792
3701
  const [width, height] = useStdoutDimensions();
3793
- const [csrLogs, setCsrLogs] = useState4([]);
3794
- const [backendLogs, setBackendLogs] = useState4([]);
3795
- const [frontendLogs, setFrontendLogs] = useState4([]);
3796
- useEffect4(() => {
3797
- const backend = app.dist.spawnSync("node", ["--watch", "backend/main.js"], {
3798
- stdio: ["ignore", "pipe", "pipe"],
3799
- // stdin은 무시
3800
- env: backendEnv,
3801
- detached: true
3702
+ const [csrLogs, setCsrLogs] = useState3([]);
3703
+ const [backendLogs, setBackendLogs] = useState3([]);
3704
+ const [frontendLogs, setFrontendLogs] = useState3([]);
3705
+ const { exit } = useApp();
3706
+ const filterLogData = (data) => {
3707
+ return typeof data === "string" ? data.split(/\r?\n/).filter((line) => line !== "") : data.toString().split(/\r?\n/).filter((line) => line !== "");
3708
+ };
3709
+ const saveLog = (type, data, setLog) => {
3710
+ const newOutput = filterLogData(data);
3711
+ const logs = newOutput.map((line) => ({ type, content: line }));
3712
+ setLog((currentLogs) => {
3713
+ if (currentLogs.length >= maxLength) {
3714
+ return [...currentLogs.slice(logs.length, maxLength), ...logs];
3715
+ } else if (currentLogs.length < maxLength && currentLogs.length + logs.length > maxLength) {
3716
+ return [...currentLogs.slice(Math.abs(maxLength - currentLogs.length - logs.length), maxLength), ...logs];
3717
+ } else
3718
+ return [...currentLogs, ...logs];
3802
3719
  });
3803
- const frontend = app.spawnSync("npx", ["next", "dev", "-p", "4200"], {
3804
- stdio: ["ignore", "pipe", "pipe"],
3805
- // stdin은 무시
3806
- env: frontendEnv,
3807
- detached: true
3720
+ };
3721
+ useEffect3(() => {
3722
+ bcp.stdout?.on("data", (data) => {
3723
+ saveLog("stdout", data, setBackendLogs);
3808
3724
  });
3809
- backend.stdout?.on("data", (data) => {
3810
- const newOutput = data.toString().split("\n");
3811
- setBackendLogs((currentLogs) => [
3812
- ...currentLogs,
3813
- ...newOutput.map((line) => ({ type: "stdout", content: line }))
3814
- ]);
3725
+ bcp.stderr?.on("data", (data) => {
3726
+ saveLog("stderr", data, setBackendLogs);
3815
3727
  });
3816
- backend.stderr?.on("data", (data) => {
3817
- const newOutput = data.toString().split("\n");
3818
- setBackendLogs((currentLogs) => [
3819
- ...currentLogs,
3820
- ...newOutput.map((line) => ({ type: "stderr", content: line }))
3821
- ]);
3728
+ fcp.stdout?.on("data", (data) => {
3729
+ saveLog("stdout", data, setFrontendLogs);
3822
3730
  });
3823
- frontend.stdout?.on("data", (data) => {
3824
- const newOutput = data.toString().split("\n");
3825
- setFrontendLogs((currentLogs) => [
3826
- ...currentLogs,
3827
- ...newOutput.map((line) => ({ type: "stdout", content: line }))
3828
- ]);
3731
+ fcp.stderr?.on("data", (data) => {
3732
+ saveLog("stderr", data, setFrontendLogs);
3829
3733
  });
3830
- frontend.stderr?.on("data", (data) => {
3831
- const newOutput = data.toString().split("\n");
3832
- setFrontendLogs((currentLogs) => [
3833
- ...currentLogs,
3834
- ...newOutput.map((line) => ({ type: "stderr", content: line }))
3835
- ]);
3734
+ csr.on("info", (msg) => {
3735
+ saveLog("info", msg, setCsrLogs);
3836
3736
  });
3837
- void onLoadCsr({
3838
- onLog: (log) => {
3839
- setCsrLogs((prevLogs) => [...prevLogs, { type: "stdout", content: log }]);
3840
- }
3737
+ csr.on("warn", (msg) => {
3738
+ saveLog("warn", msg, setCsrLogs);
3739
+ });
3740
+ csr.on("error", (msg) => {
3741
+ saveLog("error", msg, setCsrLogs);
3742
+ });
3743
+ csr.on("clearScreen", (type) => {
3744
+ saveLog("clearScreen", type, setCsrLogs);
3841
3745
  });
3842
3746
  return () => {
3843
- backend.kill();
3844
- frontend.kill();
3747
+ bcp.kill();
3748
+ fcp.kill();
3749
+ bcp.stdin?.end();
3750
+ fcp.stdin?.end();
3751
+ csr.removeAllListeners();
3752
+ void (async () => {
3753
+ await onExit();
3754
+ exit();
3755
+ process.exit(0);
3756
+ })();
3845
3757
  };
3846
3758
  }, []);
3847
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Box3, { borderColor: "#ff493b", height, width, flexDirection: "row" }, /* @__PURE__ */ React3.createElement(
3759
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Box2, { borderColor: "#ff493b", height, width, flexDirection: "row" }, /* @__PURE__ */ React2.createElement(
3848
3760
  MultiScrollList,
3849
3761
  {
3850
3762
  logList: [
3851
3763
  {
3852
- title: `${app.name} frontend`,
3764
+ title: `${appName} frontend`,
3853
3765
  logs: frontendLogs.map((log) => log.content),
3854
3766
  color: "#ff493b"
3855
3767
  },
3856
3768
  {
3857
- title: `${app.name} backend`,
3769
+ title: `${appName} backend`,
3858
3770
  logs: backendLogs.map((log) => log.content),
3859
3771
  color: "#e535ab"
3860
3772
  },
3861
3773
  {
3862
- title: `${app.name} react`,
3774
+ title: `${appName} react`,
3863
3775
  logs: csrLogs.map((log) => log.content),
3864
3776
  color: "#7cc5d9"
3865
3777
  }
3866
- ]
3778
+ ],
3779
+ maxLength
3867
3780
  }
3868
3781
  )));
3869
3782
  };
3870
3783
  var Interface = {
3871
- Csr: (app, onLoad) => render(/* @__PURE__ */ React3.createElement(Csr, { app, onLoad })),
3872
- Backend: (app, env) => render(/* @__PURE__ */ React3.createElement(Backend, { app, env })),
3873
- Frontend: (app, env) => render(/* @__PURE__ */ React3.createElement(Frontend, { app, env })),
3874
- Start: (app, backendEnv, frontendEnv, onLoadCsr) => render(/* @__PURE__ */ React3.createElement(Start, { app, backendEnv, frontendEnv, onLoadCsr }))
3784
+ /**
3785
+ * Akan CSR 실행 컴포넌트
3786
+ *
3787
+ * @param app 정보
3788
+ * @param event CSR 이벤트 발생기
3789
+ * @param onExit 종료 함수
3790
+ */
3791
+ Csr: (app, event, onExit) => renderManager(/* @__PURE__ */ React2.createElement(Csr, { app, event, onExit })),
3792
+ /**
3793
+ * Akan Backend 실행 컴포넌트
3794
+ *
3795
+ * @param appName 앱 이름
3796
+ * @param childProcess 백엔드 차일드 프로세스
3797
+ * @param onExit 종료 함수
3798
+ */
3799
+ Backend: (appName, childProcess, onExit) => renderManager(/* @__PURE__ */ React2.createElement(Backend, { appName, childProcess, onExit })),
3800
+ /**
3801
+ * Akan Frontend 실행 컴포넌트
3802
+ *
3803
+ * @param appName 앱 이름
3804
+ * @param childProcess 프론트엔드 차일드 프로세스
3805
+ * @param onExit 종료 함수
3806
+ */
3807
+ Frontend: (appName, childProcess, onExit) => renderManager(/* @__PURE__ */ React2.createElement(Frontend, { appName, childProcess, onExit })),
3808
+ /**
3809
+ * Akan application 통합 실행 컴포넌트 (백엔드, 프론트엔드, React(CSR))
3810
+ *
3811
+ * @param maxLength 로그 최대 길이
3812
+ * @param appName 앱 이름
3813
+ * @param bcp 백엔드 차일드 프로세스
3814
+ * @param fcp 프론트엔드 차일드 프로세스
3815
+ * @param csr CSR 이벤트 발생기
3816
+ * @param onExit 종료 함수
3817
+ */
3818
+ Start: (appName, bcp, fcp, csr, onExit) => renderManager(/* @__PURE__ */ React2.createElement(Start, { appName, bcp, fcp, csr, onExit }))
3819
+ };
3820
+ var renderManager = (component) => {
3821
+ const renderFn = render(component);
3822
+ return renderFn;
3875
3823
  };
3876
3824
 
3877
3825
  // pkgs/@akanjs/cli/src/application/application.runner.ts
3826
+ import EventEmitter from "node:events";
3827
+ import { confirm as confirm2, input as input4, select as select5 } from "@inquirer/prompts";
3828
+ import { StringOutputParser } from "@langchain/core/output_parsers";
3829
+ import { PromptTemplate as PromptTemplate2 } from "@langchain/core/prompts";
3830
+ import { RunnableSequence as RunnableSequence2 } from "@langchain/core/runnables";
3831
+ import { ChatOpenAI as ChatOpenAI3 } from "@langchain/openai";
3832
+ import react from "@vitejs/plugin-react";
3833
+ import dotenv3 from "dotenv";
3834
+ import * as esbuild2 from "esbuild";
3835
+ import fs14 from "fs";
3836
+ import fsPromise3 from "fs/promises";
3837
+ import yaml2 from "js-yaml";
3838
+ import openBrowser from "open";
3839
+ import ora3 from "ora";
3840
+ import path7 from "path";
3841
+ import * as vite from "vite";
3842
+ import commonjs from "vite-plugin-commonjs";
3843
+ import { nodePolyfills } from "vite-plugin-node-polyfills";
3844
+ import tsconfigPaths from "vite-tsconfig-paths";
3878
3845
  var ApplicationRunner = class {
3879
3846
  async createApplication(appName, workspace) {
3880
3847
  await workspace.applyTemplate({
@@ -3902,34 +3869,6 @@ var ApplicationRunner = class {
3902
3869
  await app.syncAssets(scanResult.akanConfig.libs);
3903
3870
  return scanResult;
3904
3871
  }
3905
- async start(app) {
3906
- const { env: frontendEnv } = await this.#prepareCommand(app, "start", "frontend");
3907
- const { env: backendEnv } = await this.#prepareCommand(app, "start", "backend");
3908
- Interface.Start(app, backendEnv, frontendEnv, async ({ onLog }) => {
3909
- const config = await this.#getViteConfig(app, "start", {
3910
- customLogger: {
3911
- info: (msg) => {
3912
- onLog(msg);
3913
- },
3914
- warn: (msg) => {
3915
- },
3916
- warnOnce: (msg) => {
3917
- },
3918
- error: (msg) => {
3919
- onLog(msg);
3920
- },
3921
- clearScreen: (type) => {
3922
- },
3923
- hasErrorLogged: (error) => {
3924
- return false;
3925
- },
3926
- hasWarned: false
3927
- }
3928
- });
3929
- const server = await vite.createServer(config);
3930
- await server.listen(4201);
3931
- });
3932
- }
3933
3872
  async getScriptFilename(app) {
3934
3873
  if (!app.exists("scripts")) {
3935
3874
  app.mkdir("scripts");
@@ -4009,7 +3948,7 @@ var ApplicationRunner = class {
4009
3948
  app.dist.writeJson("backend/package.json", appPackageJson);
4010
3949
  app.dist.writeFile(path7.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.docker.content);
4011
3950
  }
4012
- async startBackend(app, { open: open2 = false, onStart } = {}) {
3951
+ async startBackend(app, { open: open2 = false, onStart, withInk = false } = {}) {
4013
3952
  const { env } = await this.#prepareCommand(app, "start", "backend");
4014
3953
  const ctx = await esbuild2.context({
4015
3954
  write: true,
@@ -4026,7 +3965,11 @@ var ApplicationRunner = class {
4026
3965
  onStart?.();
4027
3966
  if (open2)
4028
3967
  setTimeout(() => openBrowser("http://localhost:8080/backend/graphql"), 3e3);
4029
- await app.dist.spawn("node", ["--watch", "main.js"], { env, stdio: "inherit", cwd: `${app.dist.cwdPath}/backend` });
3968
+ return app.dist.spawnSync("node", ["--watch", "main.js"], {
3969
+ env,
3970
+ stdio: withInk ? ["ignore", "pipe", "pipe"] : "inherit",
3971
+ cwd: `${app.dist.cwdPath}/backend`
3972
+ });
4030
3973
  }
4031
3974
  async buildFrontend(app, { spawnOptions } = {}) {
4032
3975
  const { env } = await this.#prepareCommand(app, "build", "frontend");
@@ -4060,12 +4003,20 @@ var ApplicationRunner = class {
4060
4003
  ]);
4061
4004
  app.dist.writeFile("frontend/Dockerfile", akanConfig.frontend.docker.content);
4062
4005
  }
4063
- async startFrontend(app, { open: open2 = false, turbo = true, onStart } = {}) {
4006
+ async startFrontend(app, {
4007
+ open: open2 = false,
4008
+ turbo = true,
4009
+ onStart,
4010
+ withInk = false
4011
+ } = {}) {
4064
4012
  const { env } = await this.#prepareCommand(app, "start", "frontend");
4065
4013
  if (open2)
4066
4014
  setTimeout(() => openBrowser("http://localhost:4200"), 3e3);
4067
4015
  onStart?.();
4068
- await app.spawn("npx", ["next", "dev", "-p", "4200", ...turbo ? ["--turbo"] : []], { env, stdio: "inherit" });
4016
+ return app.spawnSync("npx", ["next", "dev", "-p", "4200", ...turbo ? ["--turbo"] : []], {
4017
+ env,
4018
+ stdio: withInk ? ["ignore", "pipe", "pipe"] : "inherit"
4019
+ });
4069
4020
  }
4070
4021
  async #getViteConfig(app, command, viteConfig = {}) {
4071
4022
  const { env } = await this.#prepareCommand(app, command, "csr");
@@ -4153,38 +4104,41 @@ var ApplicationRunner = class {
4153
4104
  const config = await this.#getViteConfig(app, "build");
4154
4105
  await vite.build(config);
4155
4106
  }
4156
- startCsr(app, { open: open2 = false, onStart } = {}) {
4157
- Interface.Csr(app, async ({ onLog }) => {
4158
- const config = await this.#getViteConfig(app, "start", {
4107
+ async startCsr(app, { open: open2 = false, onStart, withInk = false } = {}) {
4108
+ const eventEmitter = new EventEmitter();
4109
+ const config = await this.#getViteConfig(
4110
+ app,
4111
+ "start",
4112
+ withInk ? {
4159
4113
  customLogger: {
4160
4114
  info: (msg) => {
4161
- onLog(msg);
4115
+ eventEmitter.emit("info", msg);
4162
4116
  },
4163
4117
  warn: (msg) => {
4164
- onLog(msg);
4118
+ eventEmitter.emit("warn", msg);
4165
4119
  },
4166
4120
  warnOnce: (msg) => {
4167
- onLog(msg);
4121
+ eventEmitter.emit("warnOnce", msg);
4168
4122
  },
4169
4123
  error: (msg) => {
4170
- onLog(msg);
4124
+ eventEmitter.emit("error", msg);
4171
4125
  },
4172
4126
  clearScreen: (type) => {
4173
- onLog(type);
4127
+ eventEmitter.emit("clearScreen", type);
4174
4128
  },
4175
4129
  hasErrorLogged: (error) => {
4176
4130
  return false;
4177
4131
  },
4178
4132
  hasWarned: false
4179
4133
  }
4180
- });
4181
- const env = this.#prepareCommand(app, "start", "csr");
4182
- const server = await vite.createServer(config);
4183
- await server.listen(4201);
4184
- });
4134
+ } : {}
4135
+ );
4136
+ const server = await vite.createServer(config);
4137
+ await server.listen(4201);
4185
4138
  onStart?.();
4186
4139
  if (open2)
4187
4140
  setTimeout(() => openBrowser("http://localhost:4201"), 3e3);
4141
+ return { server, eventEmitter };
4188
4142
  }
4189
4143
  async buildIos(app) {
4190
4144
  const capacitorApp = await new CapacitorApp(app).init();
@@ -4478,7 +4432,16 @@ var ApplicationScript = class {
4478
4432
  await this.syncApplication(app);
4479
4433
  if (app.workspace.getBaseDevEnv().env === "local")
4480
4434
  await this.dbup(app.workspace);
4481
- await this.#runner.start(app);
4435
+ const backend = await this.startBackend(app, { open: open2, withInk: true });
4436
+ const frontend = await this.startFrontend(app, { open: open2, withInk: true });
4437
+ const { server: csrServer, eventEmitter: csr } = await this.startCsr(app, { open: open2, withInk: true });
4438
+ Interface.Start(app.name, backend, frontend, csr, async () => {
4439
+ await csrServer.close();
4440
+ backend.kill();
4441
+ frontend.kill();
4442
+ csr.removeAllListeners();
4443
+ process.exit(0);
4444
+ });
4482
4445
  }
4483
4446
  async buildBackend(app, { sync = true } = {}) {
4484
4447
  if (sync)
@@ -4487,7 +4450,12 @@ var ApplicationScript = class {
4487
4450
  await this.#runner.buildBackend(app);
4488
4451
  spinner.succeed(`Backend built in dist/apps/${app.name}/backend`);
4489
4452
  }
4490
- async startBackend(app, { open: open2 = false, dbup = true, sync = true } = {}) {
4453
+ async startBackend(app, {
4454
+ open: open2 = false,
4455
+ dbup = true,
4456
+ sync = true,
4457
+ withInk = false
4458
+ } = {}) {
4491
4459
  if (app.getEnv() === "local" && dbup) {
4492
4460
  await this.dbup(app.workspace);
4493
4461
  process.on("SIGINT", async () => {
@@ -4498,12 +4466,14 @@ var ApplicationScript = class {
4498
4466
  if (sync)
4499
4467
  await this.syncApplication(app);
4500
4468
  const spinner = app.spinning("Preparing backend...");
4501
- await this.#runner.startBackend(app, {
4469
+ const childProcess = await this.#runner.startBackend(app, {
4502
4470
  open: open2,
4503
4471
  onStart: () => {
4504
4472
  spinner.succeed(`Backend prepared, ready to start`);
4505
- }
4473
+ },
4474
+ withInk
4506
4475
  });
4476
+ return childProcess;
4507
4477
  }
4508
4478
  async buildFrontend(app, { sync = true, standalone = false } = {}) {
4509
4479
  if (sync)
@@ -4516,17 +4486,24 @@ var ApplicationScript = class {
4516
4486
  spinner.succeed(`Frontend built in dist/apps/${app.name}/frontend`);
4517
4487
  }
4518
4488
  }
4519
- async startFrontend(app, { open: open2 = false, turbo = false, sync = true } = {}) {
4489
+ async startFrontend(app, {
4490
+ open: open2 = false,
4491
+ turbo = false,
4492
+ sync = true,
4493
+ withInk = false
4494
+ } = {}) {
4520
4495
  if (sync)
4521
4496
  await this.syncApplication(app);
4522
4497
  const spinner = app.spinning("Preparing frontend...");
4523
- await this.#runner.startFrontend(app, {
4498
+ const childProcess = await this.#runner.startFrontend(app, {
4524
4499
  open: open2,
4525
4500
  turbo,
4526
4501
  onStart: () => {
4527
4502
  spinner.succeed(`Frontend prepared, ready to start`);
4528
- }
4503
+ },
4504
+ withInk
4529
4505
  });
4506
+ return childProcess;
4530
4507
  }
4531
4508
  async buildCsr(app, { sync = true } = {}) {
4532
4509
  if (sync)
@@ -4535,14 +4512,16 @@ var ApplicationScript = class {
4535
4512
  await this.#runner.buildCsr(app);
4536
4513
  spinner.succeed(`Successfully built in dist/apps/${app.name}/csr`);
4537
4514
  }
4538
- async startCsr(app, { open: open2 = false, sync = true } = {}) {
4515
+ async startCsr(app, { open: open2 = false, sync = true, withInk = false } = {}) {
4539
4516
  if (sync)
4540
4517
  await this.syncApplication(app);
4541
- this.#runner.startCsr(app, {
4518
+ const { eventEmitter, server } = await this.#runner.startCsr(app, {
4542
4519
  open: open2,
4543
4520
  onStart: () => {
4544
- }
4521
+ },
4522
+ withInk
4545
4523
  });
4524
+ return { eventEmitter, server };
4546
4525
  }
4547
4526
  async buildIos(app, { sync = true } = {}) {
4548
4527
  if (sync)