@akanjs/cli 0.9.10 → 0.9.11

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.
package/cjs/index.js CHANGED
@@ -32,6 +32,9 @@ var __decorateClass = (decorators, target, key, kind) => {
32
32
  };
33
33
  var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
34
34
 
35
+ // pkgs/@akanjs/cli/index.ts
36
+ var import_dotenv4 = __toESM(require("dotenv"), 1);
37
+
35
38
  // pkgs/@akanjs/devkit/src/createTunnel.ts
36
39
  var import_tunnel_ssh = require("tunnel-ssh");
37
40
  var getSshTunnelOptions = (app, environment) => {
@@ -68,7 +71,8 @@ var getCredentials = (app, environment) => {
68
71
  };
69
72
 
70
73
  // pkgs/@akanjs/common/isDayjs.ts
71
- var import_dayjs = require("dayjs");
74
+ var import_dayjs = __toESM(require("dayjs"));
75
+ var isDayjs = import_dayjs.default.isDayjs;
72
76
 
73
77
  // pkgs/@akanjs/common/isQueryEqual.ts
74
78
  var import_dayjs2 = __toESM(require("dayjs"));
@@ -396,8 +400,8 @@ var fs3 = __toESM(require("fs"));
396
400
  var import_ora2 = __toESM(require("ora"));
397
401
  var ts = __toESM(require("typescript"));
398
402
  var parseTsConfig = (tsConfigPath = "./tsconfig.json") => {
399
- const configFile = ts.readConfigFile(tsConfigPath, (path9) => {
400
- return ts.sys.readFile(path9);
403
+ const configFile = ts.readConfigFile(tsConfigPath, (path10) => {
404
+ return ts.sys.readFile(path10);
401
405
  });
402
406
  return ts.parseJsonConfigFileContent(
403
407
  configFile.config,
@@ -565,8 +569,9 @@ var import_path2 = __toESM(require("path"));
565
569
  // pkgs/@akanjs/config/src/nextConfig.ts
566
570
  var import_bundle_analyzer = __toESM(require("@next/bundle-analyzer"));
567
571
  var import_next_pwa = __toESM(require("next-pwa"));
568
- var import_cache = __toESM(require("next-pwa/cache"));
572
+ var import_cache = __toESM(require("next-pwa/cache.js"));
569
573
  var import_path = __toESM(require("path"));
574
+ var import_meta = {};
570
575
  var composePlugins = (...plugins) => {
571
576
  return function(baseConfig) {
572
577
  return async function combined(phase, context2) {
@@ -584,16 +589,17 @@ var composePlugins = (...plugins) => {
584
589
  };
585
590
  };
586
591
  var commandType = process.env.AKAN_COMMAND_TYPE?.includes("start") ? "start" : process.env.AKAN_COMMAND_TYPE?.includes("build") ? "build" : "deploy";
587
- var withPWA = (0, import_next_pwa.default)({
588
- dest: "public",
589
- register: true,
590
- skipWaiting: true,
591
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
592
- runtimeCaching: import_cache.default,
593
- disable: commandType === "start"
594
- });
595
592
  var devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
596
593
  var withBase = (appName, config, libs, routes = []) => {
594
+ const __dirname = import_path.default.dirname(new URL(import_meta.url).pathname);
595
+ const withPWA = (0, import_next_pwa.default)({
596
+ dest: "public",
597
+ register: true,
598
+ skipWaiting: true,
599
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
600
+ runtimeCaching: import_cache.default,
601
+ disable: commandType === "start"
602
+ });
597
603
  return composePlugins(
598
604
  (0, import_bundle_analyzer.default)({ enabled: process.env.ANALYZE === "true" }),
599
605
  ...commandType !== "start" || process.env.USE_PWA === "true" ? [withPWA] : []
@@ -706,7 +712,7 @@ var withBase = (appName, config, libs, routes = []) => {
706
712
  }
707
713
  });
708
714
  };
709
- var defaultNextConfigFile = `import "tsconfig-paths/register";
715
+ var defaultNextConfigFile = `import "tsconfig-paths/register.js";
710
716
 
711
717
  import { getNextConfig } from "@akanjs/config";
712
718
 
@@ -849,7 +855,7 @@ var import_child_process = require("child_process");
849
855
  var import_dotenv = __toESM(require("dotenv"));
850
856
  var import_fs4 = __toESM(require("fs"));
851
857
  var import_promises = __toESM(require("fs/promises"));
852
- var import_path3 = __toESM(require("path"));
858
+ var import_path4 = __toESM(require("path"));
853
859
 
854
860
  // pkgs/@akanjs/devkit/src/dependencyScanner.ts
855
861
  var fs5 = __toESM(require("fs"));
@@ -998,11 +1004,15 @@ var TypeScriptDependencyScanner = class {
998
1004
  }
999
1005
  };
1000
1006
 
1007
+ // pkgs/@akanjs/devkit/src/getDirname.ts
1008
+ var import_path3 = __toESM(require("path"));
1009
+ var getDirname = (url) => import_path3.default.dirname(new URL(url).pathname);
1010
+
1001
1011
  // pkgs/@akanjs/devkit/src/linter.ts
1002
1012
  var import_chalk = __toESM(require("chalk"));
1003
1013
  var import_eslint = require("eslint");
1004
1014
  var fs6 = __toESM(require("fs"));
1005
- var path4 = __toESM(require("path"));
1015
+ var path5 = __toESM(require("path"));
1006
1016
  var Linter = class {
1007
1017
  #logger = new Logger("Linter");
1008
1018
  #eslint;
@@ -1012,10 +1022,10 @@ var Linter = class {
1012
1022
  this.#eslint = new import_eslint.ESLint({ cwd: this.lintRoot, errorOnUnmatchedPattern: false });
1013
1023
  }
1014
1024
  #findEslintRootPath(dir) {
1015
- const configPath2 = path4.join(dir, "eslint.config.ts");
1025
+ const configPath2 = path5.join(dir, "eslint.config.ts");
1016
1026
  if (fs6.existsSync(configPath2))
1017
1027
  return dir;
1018
- const parentDir = path4.dirname(dir);
1028
+ const parentDir = path5.dirname(dir);
1019
1029
  return this.#findEslintRootPath(parentDir);
1020
1030
  }
1021
1031
  async lint(filePath, { fix = false, dryRun = false } = {}) {
@@ -1204,7 +1214,7 @@ ${errorText}, ${warningText} found`];
1204
1214
  // pkgs/@akanjs/devkit/src/typeChecker.ts
1205
1215
  var import_chalk2 = __toESM(require("chalk"));
1206
1216
  var fs7 = __toESM(require("fs"));
1207
- var path5 = __toESM(require("path"));
1217
+ var path6 = __toESM(require("path"));
1208
1218
  var ts3 = __toESM(require("typescript"));
1209
1219
  var TypeChecker = class {
1210
1220
  configPath;
@@ -1219,7 +1229,7 @@ var TypeChecker = class {
1219
1229
  const parsedConfig = ts3.parseJsonConfigFileContent(
1220
1230
  this.configFile.config,
1221
1231
  ts3.sys,
1222
- path5.dirname(this.configPath),
1232
+ path6.dirname(this.configPath),
1223
1233
  void 0,
1224
1234
  this.configPath
1225
1235
  );
@@ -1374,6 +1384,7 @@ ${summary.join(", ")} found` + output.join("\n");
1374
1384
  };
1375
1385
 
1376
1386
  // pkgs/@akanjs/devkit/src/executors.ts
1387
+ var import_meta2 = {};
1377
1388
  var execEmoji = {
1378
1389
  workspace: "\u{1F3E0}",
1379
1390
  app: "\u{1F680}",
@@ -1391,6 +1402,7 @@ var Executor = class _Executor {
1391
1402
  }
1392
1403
  name;
1393
1404
  logger;
1405
+ logs;
1394
1406
  cwdPath;
1395
1407
  emoji = execEmoji.default;
1396
1408
  typeChecker = null;
@@ -1398,6 +1410,7 @@ var Executor = class _Executor {
1398
1410
  constructor(name, cwdPath) {
1399
1411
  this.name = name;
1400
1412
  this.logger = new Logger(name);
1413
+ this.logs = [];
1401
1414
  this.cwdPath = cwdPath;
1402
1415
  if (!import_fs4.default.existsSync(cwdPath))
1403
1416
  import_fs4.default.mkdirSync(cwdPath, { recursive: true });
@@ -1436,10 +1449,12 @@ var Executor = class _Executor {
1436
1449
  let stderr = "";
1437
1450
  proc.stdout?.on("data", (data) => {
1438
1451
  stdout += data;
1452
+ this.logs.push(data);
1439
1453
  this.#stdout(data);
1440
1454
  });
1441
1455
  proc.stderr?.on("data", (data) => {
1442
1456
  stderr += data;
1457
+ this.logs.push(data);
1443
1458
  this.#stdout(data);
1444
1459
  });
1445
1460
  return new Promise((resolve, reject) => {
@@ -1451,6 +1466,14 @@ var Executor = class _Executor {
1451
1466
  });
1452
1467
  });
1453
1468
  }
1469
+ spawnSync(command, args = [], options = {}) {
1470
+ const proc = (0, import_child_process.spawn)(command, args, {
1471
+ cwd: this.cwdPath,
1472
+ // stdio: "inherit",
1473
+ ...options
1474
+ });
1475
+ return proc;
1476
+ }
1454
1477
  fork(modulePath, args = [], options = {}) {
1455
1478
  const proc = (0, import_child_process.fork)(modulePath, args, {
1456
1479
  cwd: this.cwdPath,
@@ -1473,7 +1496,7 @@ var Executor = class _Executor {
1473
1496
  });
1474
1497
  }
1475
1498
  getPath(filePath) {
1476
- if (import_path3.default.isAbsolute(filePath))
1499
+ if (import_path4.default.isAbsolute(filePath))
1477
1500
  return filePath;
1478
1501
  const baseParts = this.cwdPath.split("/").filter(Boolean);
1479
1502
  const targetParts = filePath.split("/").filter(Boolean);
@@ -1526,7 +1549,7 @@ var Executor = class _Executor {
1526
1549
  }
1527
1550
  writeFile(filePath, content, { overwrite = true } = {}) {
1528
1551
  const writePath = this.getPath(filePath);
1529
- const dir = import_path3.default.dirname(writePath);
1552
+ const dir = import_path4.default.dirname(writePath);
1530
1553
  if (!import_fs4.default.existsSync(dir))
1531
1554
  import_fs4.default.mkdirSync(dir, { recursive: true });
1532
1555
  let contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
@@ -1550,7 +1573,7 @@ var Executor = class _Executor {
1550
1573
  return this;
1551
1574
  }
1552
1575
  getLocalFile(targetPath) {
1553
- const filePath = import_path3.default.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
1576
+ const filePath = import_path4.default.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
1554
1577
  const content = this.readFile(filePath);
1555
1578
  return { filePath, content };
1556
1579
  }
@@ -1597,15 +1620,15 @@ var Executor = class _Executor {
1597
1620
  overwrite = true
1598
1621
  }, dict = {}) {
1599
1622
  if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
1600
- const getContent = require(templatePath);
1623
+ const getContent = await import(templatePath);
1601
1624
  const result = getContent.default(scanResult ?? null, dict);
1602
1625
  if (result === null)
1603
1626
  return null;
1604
- const filename = typeof result === "object" ? result.filename : import_path3.default.basename(targetPath).replace(".js", ".ts");
1627
+ const filename = typeof result === "object" ? result.filename : import_path4.default.basename(targetPath).replace(".js", ".ts");
1605
1628
  const content = typeof result === "object" ? result.content : result;
1606
- const dirname3 = import_path3.default.dirname(targetPath);
1629
+ const dirname3 = import_path4.default.dirname(targetPath);
1607
1630
  const convertedTargetPath = Object.entries(dict).reduce(
1608
- (path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
1631
+ (path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
1609
1632
  `${dirname3}/${filename}`
1610
1633
  );
1611
1634
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
@@ -1613,7 +1636,7 @@ var Executor = class _Executor {
1613
1636
  } else if (targetPath.endsWith(".template")) {
1614
1637
  const content = await import_promises.default.readFile(templatePath, "utf8");
1615
1638
  const convertedTargetPath = Object.entries(dict).reduce(
1616
- (path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
1639
+ (path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
1617
1640
  targetPath.slice(0, -9)
1618
1641
  );
1619
1642
  const convertedContent = Object.entries(dict).reduce(
@@ -1632,12 +1655,12 @@ var Executor = class _Executor {
1632
1655
  dict = {},
1633
1656
  overwrite = true
1634
1657
  }) {
1635
- const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`;
1658
+ const templatePath = `${getDirname(import_meta2.url)}/src/templates${template ? `/${template}` : ""}`;
1636
1659
  const prefixTemplatePath = templatePath.endsWith(".tsx") ? templatePath : templatePath.replace(".ts", ".js");
1637
1660
  if (import_fs4.default.statSync(prefixTemplatePath).isFile()) {
1638
- const filename = import_path3.default.basename(prefixTemplatePath);
1661
+ const filename = import_path4.default.basename(prefixTemplatePath);
1639
1662
  const fileContent = await this.#applyTemplateFile(
1640
- { templatePath: prefixTemplatePath, targetPath: import_path3.default.join(basePath2, filename), scanResult, overwrite },
1663
+ { templatePath: prefixTemplatePath, targetPath: import_path4.default.join(basePath2, filename), scanResult, overwrite },
1641
1664
  dict
1642
1665
  );
1643
1666
  return fileContent ? [fileContent] : [];
@@ -1645,17 +1668,17 @@ var Executor = class _Executor {
1645
1668
  const subdirs = await this.readdir(templatePath);
1646
1669
  const fileContents = (await Promise.all(
1647
1670
  subdirs.map(async (subdir) => {
1648
- const subpath = import_path3.default.join(templatePath, subdir);
1671
+ const subpath = import_path4.default.join(templatePath, subdir);
1649
1672
  if (import_fs4.default.statSync(subpath).isFile()) {
1650
1673
  const fileContent = await this.#applyTemplateFile(
1651
- { templatePath: subpath, targetPath: import_path3.default.join(basePath2, subdir), scanResult, overwrite },
1674
+ { templatePath: subpath, targetPath: import_path4.default.join(basePath2, subdir), scanResult, overwrite },
1652
1675
  dict
1653
1676
  );
1654
1677
  return fileContent ? [fileContent] : [];
1655
1678
  } else
1656
1679
  return await this._applyTemplate({
1657
- basePath: import_path3.default.join(basePath2, subdir),
1658
- template: import_path3.default.join(template, subdir),
1680
+ basePath: import_path4.default.join(basePath2, subdir),
1681
+ template: import_path4.default.join(template, subdir),
1659
1682
  scanResult,
1660
1683
  dict,
1661
1684
  overwrite
@@ -1679,9 +1702,9 @@ var Executor = class _Executor {
1679
1702
  return this.typeChecker;
1680
1703
  }
1681
1704
  typeCheck(filePath) {
1682
- const path9 = this.getPath(filePath);
1705
+ const path10 = this.getPath(filePath);
1683
1706
  const typeChecker = this.getTypeChecker();
1684
- const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path9);
1707
+ const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path10);
1685
1708
  const message = typeChecker.formatDiagnostics(fileDiagnostics);
1686
1709
  return { fileDiagnostics, fileErrors, fileWarnings, message };
1687
1710
  }
@@ -1690,9 +1713,9 @@ var Executor = class _Executor {
1690
1713
  return this.linter;
1691
1714
  }
1692
1715
  async lint(filePath, { fix = false, dryRun = false } = {}) {
1693
- const path9 = this.getPath(filePath);
1716
+ const path10 = this.getPath(filePath);
1694
1717
  const linter = this.getLinter();
1695
- const { results, errors, warnings } = await linter.lint(path9, { fix, dryRun });
1718
+ const { results, errors, warnings } = await linter.lint(path10, { fix, dryRun });
1696
1719
  const message = linter.formatLintResults(results);
1697
1720
  return { results, message, errors, warnings };
1698
1721
  }
@@ -1707,7 +1730,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1707
1730
  this.repoName = repoName;
1708
1731
  }
1709
1732
  static fromRoot() {
1710
- const repoName = import_path3.default.basename(process.cwd());
1733
+ const repoName = import_path4.default.basename(process.cwd());
1711
1734
  return new _WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
1712
1735
  }
1713
1736
  getBaseDevEnv() {
@@ -1816,7 +1839,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1816
1839
  dirs.map(async (dir) => {
1817
1840
  if (dir.includes("_") || AVOID_DIRS.includes(dir))
1818
1841
  return;
1819
- const dirPath = import_path3.default.join(dirname3, dir);
1842
+ const dirPath = import_path4.default.join(dirname3, dir);
1820
1843
  if (import_fs4.default.lstatSync(dirPath).isDirectory()) {
1821
1844
  results.push(`${prefix}${dir}`);
1822
1845
  if (maxDepth > 0)
@@ -1843,9 +1866,9 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1843
1866
  dirs.map(async (dir) => {
1844
1867
  if (AVOID_DIRS.includes(dir))
1845
1868
  return;
1846
- const dirPath = import_path3.default.join(dirname3, dir);
1869
+ const dirPath = import_path4.default.join(dirname3, dir);
1847
1870
  if (import_fs4.default.lstatSync(dirPath).isDirectory()) {
1848
- const hasTargetFile = import_fs4.default.existsSync(import_path3.default.join(dirPath, targetFilename));
1871
+ const hasTargetFile = import_fs4.default.existsSync(import_path4.default.join(dirPath, targetFilename));
1849
1872
  if (hasTargetFile)
1850
1873
  results.push(`${prefix}${dir}`);
1851
1874
  if (maxDepth > 0)
@@ -1906,8 +1929,8 @@ var SysExecutor = class extends Executor {
1906
1929
  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 });
1907
1930
  }
1908
1931
  async getModules() {
1909
- const path9 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
1910
- return await this.workspace.getDirInModule(path9, this.name);
1932
+ const path10 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
1933
+ return await this.workspace.getDirInModule(path10, this.name);
1911
1934
  }
1912
1935
  async scan({
1913
1936
  tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
@@ -1919,19 +1942,19 @@ var SysExecutor = class extends Executor {
1919
1942
  const scanner = new TypeScriptDependencyScanner(this.cwdPath);
1920
1943
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
1921
1944
  const pkgPathSet = new Set(
1922
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
1945
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
1923
1946
  );
1924
1947
  const libPathSet = new Set(
1925
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("libs/"))).map((path9) => path9.replace("/*", ""))
1948
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("libs/"))).map((path10) => path10.replace("/*", ""))
1926
1949
  );
1927
1950
  const [npmDepSet, pkgPathDepSet, libPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet, libPathSet]);
1928
- const pkgDeps = [...pkgPathDepSet].map((path9) => {
1929
- const pathSplitLength = path9.split("/").length;
1930
- return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1951
+ const pkgDeps = [...pkgPathDepSet].map((path10) => {
1952
+ const pathSplitLength = path10.split("/").length;
1953
+ return (tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1931
1954
  });
1932
- const libDeps = [...libPathDepSet].map((path9) => {
1933
- const pathSplitLength = path9.split("/").length;
1934
- return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1955
+ const libDeps = [...libPathDepSet].map((path10) => {
1956
+ const pathSplitLength = path10.split("/").length;
1957
+ return (tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1935
1958
  }).filter((libName) => libName !== this.name);
1936
1959
  if (!import_fs4.default.existsSync(`${this.cwdPath}/lib/__scalar`))
1937
1960
  import_fs4.default.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
@@ -1943,7 +1966,7 @@ var SysExecutor = class extends Executor {
1943
1966
  const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
1944
1967
  await Promise.all(
1945
1968
  databaseDirs.map(async (name) => {
1946
- const filenames = await this.readdir(import_path3.default.join("lib", name));
1969
+ const filenames = await this.readdir(import_path4.default.join("lib", name));
1947
1970
  filenames.forEach((filename) => {
1948
1971
  if (filename.endsWith(".constant.ts"))
1949
1972
  files.constants.databases.push(name);
@@ -1965,7 +1988,7 @@ var SysExecutor = class extends Executor {
1965
1988
  await Promise.all(
1966
1989
  serviceDirs.map(async (dirname3) => {
1967
1990
  const name = dirname3.slice(1);
1968
- const filenames = await this.readdir(import_path3.default.join("lib", dirname3));
1991
+ const filenames = await this.readdir(import_path4.default.join("lib", dirname3));
1969
1992
  filenames.forEach((filename) => {
1970
1993
  if (filename.endsWith(".dictionary.ts"))
1971
1994
  files.dictionary.services.push(name);
@@ -1983,7 +2006,7 @@ var SysExecutor = class extends Executor {
1983
2006
  const scalarDirs = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_"));
1984
2007
  await Promise.all(
1985
2008
  scalarDirs.map(async (name) => {
1986
- const filenames = await this.readdir(import_path3.default.join("lib/__scalar", name));
2009
+ const filenames = await this.readdir(import_path4.default.join("lib/__scalar", name));
1987
2010
  filenames.forEach((filename) => {
1988
2011
  if (filename.endsWith(".constant.ts"))
1989
2012
  files.constants.scalars.push(name);
@@ -2058,7 +2081,7 @@ var SysExecutor = class extends Executor {
2058
2081
  return scanResult;
2059
2082
  }
2060
2083
  getLocalFile(targetPath) {
2061
- const filePath = import_path3.default.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
2084
+ const filePath = import_path4.default.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
2062
2085
  const content = this.workspace.readFile(filePath);
2063
2086
  return { filePath, content };
2064
2087
  }
@@ -2173,28 +2196,17 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2173
2196
  }
2174
2197
  async syncAssets(libDeps) {
2175
2198
  const projectPublicLibPath = `${this.cwdPath}/public/libs`;
2176
- const projectAssetsLibPath = `${this.cwdPath}/assets/libs`;
2177
- await Promise.all([
2178
- import_fs4.default.existsSync(projectPublicLibPath) && import_promises.default.rm(projectPublicLibPath, { recursive: true }),
2179
- import_fs4.default.existsSync(projectAssetsLibPath) && import_promises.default.rm(projectAssetsLibPath, { recursive: true })
2180
- ]);
2199
+ if (import_fs4.default.existsSync(projectPublicLibPath))
2200
+ await import_promises.default.rm(projectPublicLibPath, { recursive: true });
2181
2201
  const targetDeps = libDeps.filter((dep) => import_fs4.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
2182
- await Promise.all([
2183
- ...targetDeps.map((dep) => import_promises.default.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })),
2184
- ...targetDeps.map((dep) => import_promises.default.mkdir(`${projectAssetsLibPath}/${dep}`, { recursive: true }))
2185
- ]);
2186
- await Promise.all([
2187
- ...targetDeps.map(
2188
- (dep) => import_fs4.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`) && import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
2189
- recursive: true
2190
- })
2191
- ),
2192
- ...targetDeps.map(
2193
- (dep) => import_fs4.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/assets`) && import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`, {
2202
+ await Promise.all(targetDeps.map((dep) => import_promises.default.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })));
2203
+ await Promise.all(
2204
+ targetDeps.map(
2205
+ (dep) => import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
2194
2206
  recursive: true
2195
2207
  })
2196
2208
  )
2197
- ]);
2209
+ );
2198
2210
  }
2199
2211
  };
2200
2212
  var LibExecutor = class _LibExecutor extends SysExecutor {
@@ -2244,12 +2256,12 @@ var PkgExecutor = class _PkgExecutor extends Executor {
2244
2256
  const scanner = new TypeScriptDependencyScanner(this.cwdPath);
2245
2257
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
2246
2258
  const pkgPathSet = new Set(
2247
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
2259
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
2248
2260
  );
2249
2261
  const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
2250
- const pkgDeps = [...pkgPathDepSet].map((path9) => {
2251
- const pathSplitLength = path9.split("/").length;
2252
- return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
2262
+ const pkgDeps = [...pkgPathDepSet].map((path10) => {
2263
+ const pathSplitLength = path10.split("/").length;
2264
+ return (tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
2253
2265
  }).filter((pkg) => pkg !== this.name);
2254
2266
  const pkgScanResult = {
2255
2267
  name: this.name,
@@ -2560,7 +2572,7 @@ var extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =>
2560
2572
  ...pacakgeJson.devDependencies ?? {}
2561
2573
  };
2562
2574
  const requireRegex = /require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
2563
- for (const { text } of filepaths.filter(({ path: path9 }) => path9.endsWith(".js"))) {
2575
+ for (const { text } of filepaths.filter(({ path: path10 }) => path10.endsWith(".js"))) {
2564
2576
  let requireMatch;
2565
2577
  while ((requireMatch = requireRegex.exec(text)) !== null) {
2566
2578
  const moduleName = requireMatch[1];
@@ -2665,6 +2677,7 @@ var import_prompts3 = require("@inquirer/prompts");
2665
2677
  var import_chalk4 = __toESM(require("chalk"));
2666
2678
  var import_commander = require("commander");
2667
2679
  var import_fs7 = __toESM(require("fs"));
2680
+ var import_meta3 = {};
2668
2681
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
2669
2682
  var handleOption = (programCommand, argMeta) => {
2670
2683
  const {
@@ -2840,6 +2853,7 @@ var runCommands = async (...commands) => {
2840
2853
  process.on("unhandledRejection", (error) => {
2841
2854
  process.exit(1);
2842
2855
  });
2856
+ const __dirname = getDirname(import_meta3.url);
2843
2857
  const hasPackageJson = import_fs7.default.existsSync(`${__dirname}/../package.json`);
2844
2858
  const version = hasPackageJson ? JSON.parse(import_fs7.default.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
2845
2859
  import_commander.program.version(version).description("Akan CLI");
@@ -3268,18 +3282,21 @@ var Builder = class {
3268
3282
  // pkgs/@akanjs/devkit/src/prompter.ts
3269
3283
  var import_prompts5 = require("@inquirer/prompts");
3270
3284
  var import_promises2 = __toESM(require("fs/promises"));
3285
+ var import_meta4 = {};
3271
3286
  var Prompter = class {
3272
3287
  static async selectGuideline() {
3273
- const guideNames = (await import_promises2.default.readdir(`${__dirname}/src/guidelines`)).filter((name) => !name.startsWith("_"));
3288
+ const guideNames = (await import_promises2.default.readdir(`${getDirname(import_meta4.url)}/src/guidelines`)).filter(
3289
+ (name) => !name.startsWith("_")
3290
+ );
3274
3291
  return await (0, import_prompts5.select)({ message: "Select a guideline", choices: guideNames.map((name) => ({ name, value: name })) });
3275
3292
  }
3276
3293
  static async getGuideJson(guideName) {
3277
- const filePath = `${__dirname}/src/guidelines/${guideName}/${guideName}.generate.json`;
3294
+ const filePath = `${getDirname(import_meta4.url)}/src/guidelines/${guideName}/${guideName}.generate.json`;
3278
3295
  const guideJson = await import_promises2.default.readFile(filePath, "utf-8");
3279
3296
  return JSON.parse(guideJson);
3280
3297
  }
3281
3298
  static async getInstruction(guideName) {
3282
- const filePath = `${__dirname}/src/guidelines/${guideName}/${guideName}.instruction.md`;
3299
+ const filePath = `${getDirname(import_meta4.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
3283
3300
  const content = await import_promises2.default.readFile(filePath, "utf-8");
3284
3301
  return content;
3285
3302
  }
@@ -3303,7 +3320,7 @@ ${request}
3303
3320
  `;
3304
3321
  }
3305
3322
  async getDocumentation(guideName) {
3306
- const filePath = `${__dirname}/src/guidelines/${guideName}/${guideName}.instruction.md`;
3323
+ const filePath = `${getDirname(import_meta4.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
3307
3324
  const document = await import_promises2.default.readFile(filePath, "utf-8");
3308
3325
  return `\`\`\`markdown
3309
3326
  ${document}
@@ -3312,9 +3329,27 @@ ${document}
3312
3329
  }
3313
3330
  };
3314
3331
 
3332
+ // pkgs/@akanjs/devkit/src/useStdoutDimensions.ts
3333
+ var import_ink = require("ink");
3334
+ var import_react = require("react");
3335
+ var useStdoutDimensions = () => {
3336
+ const { stdout } = (0, import_ink.useStdout)();
3337
+ const [dimensions, setDimensions] = (0, import_react.useState)([stdout.columns, stdout.rows]);
3338
+ (0, import_react.useEffect)(() => {
3339
+ const handler = () => {
3340
+ setDimensions([stdout.columns, stdout.rows]);
3341
+ };
3342
+ stdout.on("resize", handler);
3343
+ return () => {
3344
+ stdout.off("resize", handler);
3345
+ };
3346
+ }, [stdout]);
3347
+ return dimensions;
3348
+ };
3349
+
3315
3350
  // pkgs/@akanjs/cli/src/library/library.runner.ts
3316
3351
  var import_compare_versions = require("compare-versions");
3317
- var import_dotenv2 = __toESM(require("dotenv"));
3352
+ var import_dotenv2 = __toESM(require("dotenv"), 1);
3318
3353
  var LibraryRunner = class {
3319
3354
  async createLibrary(libName, workspace) {
3320
3355
  await workspace.exec(`mkdir -p libs/${libName}`);
@@ -3452,19 +3487,351 @@ var import_output_parsers = require("@langchain/core/output_parsers");
3452
3487
  var import_prompts7 = require("@langchain/core/prompts");
3453
3488
  var import_runnables2 = require("@langchain/core/runnables");
3454
3489
  var import_openai3 = require("@langchain/openai");
3455
- var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
3456
- var import_dotenv3 = __toESM(require("dotenv"));
3457
- var esbuild2 = __toESM(require("esbuild"));
3458
- var import_fs10 = __toESM(require("fs"));
3459
- var import_promises3 = __toESM(require("fs/promises"));
3460
- var import_js_yaml2 = __toESM(require("js-yaml"));
3461
- var import_open = __toESM(require("open"));
3462
- var import_ora3 = __toESM(require("ora"));
3463
- var import_path4 = __toESM(require("path"));
3464
- var vite = __toESM(require("vite"));
3465
- var import_vite_plugin_commonjs = __toESM(require("vite-plugin-commonjs"));
3490
+ var import_plugin_react = __toESM(require("@vitejs/plugin-react"), 1);
3491
+ var import_dotenv3 = __toESM(require("dotenv"), 1);
3492
+ var esbuild2 = __toESM(require("esbuild"), 1);
3493
+ var import_fs10 = __toESM(require("fs"), 1);
3494
+ var import_promises3 = __toESM(require("fs/promises"), 1);
3495
+ var import_js_yaml2 = __toESM(require("js-yaml"), 1);
3496
+ var import_open = __toESM(require("open"), 1);
3497
+ var import_ora3 = __toESM(require("ora"), 1);
3498
+ var import_path5 = __toESM(require("path"), 1);
3499
+ var vite = __toESM(require("vite"), 1);
3500
+ var import_vite_plugin_commonjs = __toESM(require("vite-plugin-commonjs"), 1);
3466
3501
  var import_vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
3467
- var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"));
3502
+ var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
3503
+
3504
+ // pkgs/@akanjs/cli/src/application/appilcation.interface.tsx
3505
+ var import_ink4 = require("ink");
3506
+ var import_react4 = __toESM(require("react"), 1);
3507
+
3508
+ // pkgs/@akanjs/cli/ui/ScrollList.tsx
3509
+ var import_ink2 = require("ink");
3510
+ var import_react2 = __toESM(require("react"), 1);
3511
+ var ScrollList = ({ list, ...props }) => {
3512
+ const [renderLogs, setRenderLogs] = (0, import_react2.useState)(list);
3513
+ const [width, height] = useStdoutDimensions();
3514
+ const [scrollPos, setScrollPos] = (0, import_react2.useState)(0);
3515
+ const [isRunning, setIsRunning] = (0, import_react2.useState)(false);
3516
+ const [boxHeight, setBoxHeight] = (0, import_react2.useState)(height - 3);
3517
+ (0, import_ink2.useInput)((input6, key) => {
3518
+ if (key.escape) {
3519
+ setIsRunning(false);
3520
+ setScrollPos(0);
3521
+ }
3522
+ if (input6 === " " && isRunning) {
3523
+ setIsRunning(false);
3524
+ setScrollPos(0);
3525
+ }
3526
+ if (key.downArrow && scrollPos > 0) {
3527
+ if (key.shift) {
3528
+ setScrollPos(scrollPos - 10);
3529
+ } else {
3530
+ setScrollPos(scrollPos - 1);
3531
+ }
3532
+ }
3533
+ if (key.upArrow && scrollPos < list.length - boxHeight) {
3534
+ if (key.shift) {
3535
+ setScrollPos(scrollPos + 10);
3536
+ } else {
3537
+ setScrollPos(scrollPos + 1);
3538
+ }
3539
+ }
3540
+ });
3541
+ (0, import_react2.useEffect)(() => {
3542
+ if (isRunning) {
3543
+ setScrollPos(scrollPos + 1);
3544
+ return;
3545
+ }
3546
+ if (list.length > boxHeight) {
3547
+ setRenderLogs(list.slice(list.length - boxHeight, list.length));
3548
+ } else {
3549
+ setRenderLogs(list);
3550
+ }
3551
+ }, [list, isRunning]);
3552
+ (0, import_react2.useEffect)(() => {
3553
+ setBoxHeight(Math.floor(height * 0.9));
3554
+ }, [height]);
3555
+ (0, import_react2.useEffect)(() => {
3556
+ if (scrollPos > 0) {
3557
+ setRenderLogs(list.slice(list.length - boxHeight - scrollPos, list.length - scrollPos));
3558
+ setIsRunning(true);
3559
+ } else {
3560
+ setRenderLogs(list.slice(list.length - boxHeight, list.length));
3561
+ setIsRunning(false);
3562
+ }
3563
+ }, [scrollPos]);
3564
+ return /* @__PURE__ */ import_react2.default.createElement(import_ink2.Box, { ...props, width, height: "100%", flexDirection: "column" }, /* @__PURE__ */ import_react2.default.createElement(import_ink2.Box, { borderStyle: "round", width, height: height - 3 }, /* @__PURE__ */ import_react2.default.createElement(import_ink2.Newline, null), /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, null, isRunning ? /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, renderLogs.slice(0, renderLogs.length - 1).map((log, index) => /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { key: index }, log), /* @__PURE__ */ import_react2.default.createElement(import_ink2.Newline, null))), /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "scrolling... + ", scrollPos)) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, renderLogs.map((log, index) => /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { key: index }, log), /* @__PURE__ */ import_react2.default.createElement(import_ink2.Newline, null)))))), /* @__PURE__ */ import_react2.default.createElement(import_ink2.Box, null, /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { dimColor: true }, "You can use the following shortcuts:", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Newline, null), "* ", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "up"), " and ", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "down"), " to scroll.", " ", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "shift"), " to scroll faster.", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Newline, null), "* ", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "escape"), " to stop scrolling.")));
3565
+ };
3566
+
3567
+ // pkgs/@akanjs/cli/ui/MultiScrollList.tsx
3568
+ var import_ink3 = require("ink");
3569
+ var import_react3 = __toESM(require("react"), 1);
3570
+ var MultiScrollList = ({ logList }) => {
3571
+ const [width, height] = useStdoutDimensions();
3572
+ const [renderMultiLogs, setRenderMultiLogs] = (0, import_react3.useState)(
3573
+ Array.from({ length: logList.length }, () => [])
3574
+ );
3575
+ const [lengthMap, setLengthMap] = (0, import_react3.useState)(/* @__PURE__ */ new Map());
3576
+ const [scrollPos, setScrollPos] = (0, import_react3.useState)(0);
3577
+ const [tabIndex, setTabIndex] = (0, import_react3.useState)(null);
3578
+ const [isRunning, setIsRunning] = (0, import_react3.useState)(false);
3579
+ const [boxHeight, setBoxHeight] = (0, import_react3.useState)(height - 7);
3580
+ (0, import_ink3.useInput)((input6, key) => {
3581
+ if (key.tab) {
3582
+ if (tabIndex === null) {
3583
+ setTabIndex(0);
3584
+ } else {
3585
+ setTabIndex((prev) => (prev + 1) % logList.length);
3586
+ setIsRunning(false);
3587
+ }
3588
+ }
3589
+ if (key.escape) {
3590
+ setScrollPos(0);
3591
+ if (tabIndex !== null)
3592
+ setTabIndex(null);
3593
+ setIsRunning(false);
3594
+ }
3595
+ if (input6 === " ") {
3596
+ setScrollPos(0);
3597
+ setIsRunning(false);
3598
+ }
3599
+ if (key.downArrow && scrollPos > 0) {
3600
+ if (key.shift) {
3601
+ const newScrollPos = scrollPos - 10;
3602
+ if (newScrollPos < 0) {
3603
+ setScrollPos(0);
3604
+ } else {
3605
+ setScrollPos(newScrollPos);
3606
+ }
3607
+ } else {
3608
+ const newScrollPos = scrollPos - 1;
3609
+ setScrollPos(newScrollPos);
3610
+ }
3611
+ }
3612
+ if (key.upArrow && tabIndex !== null && scrollPos < logList[tabIndex].logs.length - boxHeight) {
3613
+ if (key.shift) {
3614
+ const newScrollPos = scrollPos + 10;
3615
+ if (newScrollPos > logList[tabIndex].logs.length - boxHeight) {
3616
+ setScrollPos(logList[tabIndex].logs.length - boxHeight);
3617
+ } else {
3618
+ setScrollPos(newScrollPos);
3619
+ }
3620
+ } else {
3621
+ setScrollPos(scrollPos + 1);
3622
+ }
3623
+ if (!isRunning)
3624
+ setIsRunning(true);
3625
+ }
3626
+ });
3627
+ (0, import_react3.useEffect)(() => {
3628
+ const getLogsToRender = (logs, index) => {
3629
+ if (scrollPos > 0 && tabIndex === index) {
3630
+ return logs.slice(logs.length - boxHeight - scrollPos, logs.length - scrollPos);
3631
+ } else if (logs.length > boxHeight) {
3632
+ return logs.slice(logs.length - boxHeight, logs.length);
3633
+ } else {
3634
+ return logs;
3635
+ }
3636
+ };
3637
+ if (isRunning) {
3638
+ if (tabIndex !== null && lengthMap.has(tabIndex)) {
3639
+ const tabLength = lengthMap.get(tabIndex);
3640
+ if (tabLength && tabLength < logList[tabIndex].logs.length) {
3641
+ setScrollPos(scrollPos + 1);
3642
+ lengthMap.set(tabIndex, logList[tabIndex].logs.length);
3643
+ }
3644
+ }
3645
+ setRenderMultiLogs((prev) => {
3646
+ const newState = [...prev];
3647
+ logList.forEach((logData, index) => {
3648
+ newState[index] = getLogsToRender(logData.logs, index);
3649
+ });
3650
+ return newState;
3651
+ });
3652
+ } else {
3653
+ setRenderMultiLogs((prev) => {
3654
+ const newState = [...prev];
3655
+ logList.forEach((logData, index) => {
3656
+ lengthMap.set(index, logData.logs.length);
3657
+ newState[index] = getLogsToRender(logData.logs, index);
3658
+ });
3659
+ return newState;
3660
+ });
3661
+ }
3662
+ }, [logList, isRunning, scrollPos, tabIndex, boxHeight]);
3663
+ (0, import_react3.useEffect)(() => {
3664
+ setBoxHeight(height - 7);
3665
+ }, [height]);
3666
+ (0, import_react3.useEffect)(() => {
3667
+ setLengthMap(new Map(logList.map((log, index) => [index, log.logs.length])));
3668
+ }, []);
3669
+ return /* @__PURE__ */ import_react3.default.createElement(import_ink3.Box, { width, height, flexDirection: "column" }, /* @__PURE__ */ import_react3.default.createElement(import_ink3.Box, { width, height: "100%" }, renderMultiLogs.map((logData, index) => /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(import_ink3.Box, { width, height: "100%", flexDirection: "column", key: index }, /* @__PURE__ */ import_react3.default.createElement(import_ink3.Box, null, /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, { color: logList[index].color }, logList[index].title)), /* @__PURE__ */ import_react3.default.createElement(
3670
+ import_ink3.Box,
3671
+ {
3672
+ flexWrap: "wrap",
3673
+ height,
3674
+ borderStyle: index === tabIndex ? "double" : "round",
3675
+ borderDimColor: index !== tabIndex,
3676
+ borderColor: index === tabIndex && isRunning ? "green" : logList[index].color
3677
+ },
3678
+ /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, null, isRunning && tabIndex === index ? /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, logData.slice(0, logData.length - 1).map((log, index2) => /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, { key: index2 }, log), /* @__PURE__ */ import_react3.default.createElement(import_ink3.Newline, null))), /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, { backgroundColor: "green" }, "scrolling... +", scrollPos)) : /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, logData.map((data, index2) => /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, { key: index2 }, data), /* @__PURE__ */ import_react3.default.createElement(import_ink3.Newline, null)))))
3679
+ ))))), /* @__PURE__ */ import_react3.default.createElement(import_ink3.Box, { width, height: "auto" }, /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, { dimColor: true }, /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, null, "You can use the following shortcuts:"), /* @__PURE__ */ import_react3.default.createElement(import_ink3.Newline, null), "* ", /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, { backgroundColor: "green" }, "tab"), " to switch tab.", /* @__PURE__ */ import_react3.default.createElement(import_ink3.Newline, null), "* ", /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, { backgroundColor: "green" }, "space"), " to scroll.", /* @__PURE__ */ import_react3.default.createElement(import_ink3.Newline, null), "* ", /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, { backgroundColor: "green" }, "up"), " and ", /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, { backgroundColor: "green" }, "down"), " to scroll.", " ", /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, { backgroundColor: "green" }, "shift"), " to scroll faster.", /* @__PURE__ */ import_react3.default.createElement(import_ink3.Newline, null), "* ", /* @__PURE__ */ import_react3.default.createElement(import_ink3.Text, { backgroundColor: "green" }, "escape"), " to stop scrolling.")));
3680
+ };
3681
+
3682
+ // pkgs/@akanjs/cli/src/application/appilcation.interface.tsx
3683
+ var Backend = ({ app, env }) => {
3684
+ const [logs, setLogs] = (0, import_react4.useState)([]);
3685
+ const [width, height] = useStdoutDimensions();
3686
+ (0, import_react4.useEffect)(() => {
3687
+ const proc = app.dist.spawnSync("node", ["--watch", "backend/main.js"], {
3688
+ env,
3689
+ stdio: "pipe"
3690
+ });
3691
+ proc.stdout?.on("data", (data) => {
3692
+ const newOutput = data.toString().split("\n");
3693
+ setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3694
+ });
3695
+ proc.stderr?.on("data", (data) => {
3696
+ const newOutput = data.toString().split("\n");
3697
+ setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3698
+ });
3699
+ return () => {
3700
+ proc.kill();
3701
+ };
3702
+ }, []);
3703
+ return /* @__PURE__ */ import_react4.default.createElement(import_ink4.Box, { width, height }, /* @__PURE__ */ import_react4.default.createElement(import_ink4.Text, { bold: true }, "Akan.JS Backend"));
3704
+ };
3705
+ var Frontend = ({ app, env }) => {
3706
+ const [logs, setLogs] = (0, import_react4.useState)([]);
3707
+ const [width, height] = useStdoutDimensions();
3708
+ (0, import_react4.useEffect)(() => {
3709
+ const proc = app.spawnSync("npx", ["next", "dev", "-p", "4200"], {
3710
+ env,
3711
+ stdio: ["ignore", "pipe", "pipe"],
3712
+ detached: true
3713
+ });
3714
+ proc.stdout?.on("data", (data) => {
3715
+ const newOutput = data.toString().split("\n");
3716
+ setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3717
+ });
3718
+ proc.stderr?.on("data", (data) => {
3719
+ const newOutput = data.toString().split("\n");
3720
+ setLogs((prevLogs) => [...prevLogs, ...newOutput]);
3721
+ });
3722
+ return () => {
3723
+ proc.kill();
3724
+ };
3725
+ }, []);
3726
+ return /* @__PURE__ */ import_react4.default.createElement(import_ink4.Box, { width, height, flexDirection: "column" }, /* @__PURE__ */ import_react4.default.createElement(import_ink4.Text, { bold: true }, "Akan.JS Frontend"), logs.map((log) => /* @__PURE__ */ import_react4.default.createElement(import_ink4.Text, { key: log }, log)));
3727
+ };
3728
+ var Csr = ({
3729
+ app,
3730
+ onLoad
3731
+ }) => {
3732
+ const [logs, setLogs] = (0, import_react4.useState)([]);
3733
+ const [width, height] = useStdoutDimensions();
3734
+ (0, import_react4.useEffect)(() => {
3735
+ void onLoad({
3736
+ onLog: (log) => {
3737
+ setLogs((prevLogs) => [...prevLogs, log]);
3738
+ }
3739
+ });
3740
+ }, []);
3741
+ return /* @__PURE__ */ import_react4.default.createElement(import_ink4.Box, { width, height, flexDirection: "column" }, /* @__PURE__ */ import_react4.default.createElement(import_ink4.Text, { bold: true }, "Akan.JS CSR"), /* @__PURE__ */ import_react4.default.createElement(ScrollList, { list: logs }));
3742
+ };
3743
+ var Start = ({
3744
+ app,
3745
+ backendEnv,
3746
+ frontendEnv,
3747
+ onLoadCsr
3748
+ }) => {
3749
+ const [width, height] = useStdoutDimensions();
3750
+ const [csrLogs, setCsrLogs] = (0, import_react4.useState)([]);
3751
+ const [backendLogs, setBackendLogs] = (0, import_react4.useState)([]);
3752
+ const [frontendLogs, setFrontendLogs] = (0, import_react4.useState)([]);
3753
+ (0, import_react4.useEffect)(() => {
3754
+ const backend = app.dist.spawnSync("node", ["--watch", "backend/main.js"], {
3755
+ stdio: ["ignore", "pipe", "pipe"],
3756
+ // stdin은 무시
3757
+ env: backendEnv,
3758
+ detached: true
3759
+ });
3760
+ const frontend = app.spawnSync("npx", ["next", "dev", "-p", "4200"], {
3761
+ stdio: ["ignore", "pipe", "pipe"],
3762
+ // stdin은 무시
3763
+ env: frontendEnv,
3764
+ detached: true
3765
+ });
3766
+ backend.stdout?.on("data", (data) => {
3767
+ const newOutput = data.toString().split("\n");
3768
+ setBackendLogs((currentLogs) => [
3769
+ ...currentLogs,
3770
+ ...newOutput.map((line) => ({ type: "stdout", content: line }))
3771
+ ]);
3772
+ });
3773
+ backend.stderr?.on("data", (data) => {
3774
+ const newOutput = data.toString().split("\n");
3775
+ setBackendLogs((currentLogs) => [
3776
+ ...currentLogs,
3777
+ ...newOutput.map((line) => ({ type: "stderr", content: line }))
3778
+ ]);
3779
+ });
3780
+ frontend.stdout?.on("data", (data) => {
3781
+ const newOutput = data.toString().split("\n");
3782
+ setFrontendLogs((currentLogs) => [
3783
+ ...currentLogs,
3784
+ ...newOutput.map((line) => ({ type: "stdout", content: line }))
3785
+ ]);
3786
+ });
3787
+ frontend.stderr?.on("data", (data) => {
3788
+ const newOutput = data.toString().split("\n");
3789
+ setFrontendLogs((currentLogs) => [
3790
+ ...currentLogs,
3791
+ ...newOutput.map((line) => ({ type: "stderr", content: line }))
3792
+ ]);
3793
+ });
3794
+ void onLoadCsr({
3795
+ onLog: (log) => {
3796
+ setCsrLogs((prevLogs) => [...prevLogs, { type: "stdout", content: log }]);
3797
+ }
3798
+ });
3799
+ return () => {
3800
+ backend.kill();
3801
+ frontend.kill();
3802
+ };
3803
+ }, []);
3804
+ return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(import_ink4.Box, { borderColor: "#ff493b", height, width, flexDirection: "row" }, /* @__PURE__ */ import_react4.default.createElement(
3805
+ MultiScrollList,
3806
+ {
3807
+ logList: [
3808
+ {
3809
+ title: `${app.name} frontend`,
3810
+ logs: frontendLogs.map((log) => log.content),
3811
+ color: "#ff493b"
3812
+ },
3813
+ {
3814
+ title: `${app.name} backend`,
3815
+ logs: backendLogs.map((log) => log.content),
3816
+ color: "#e535ab"
3817
+ },
3818
+ {
3819
+ title: `${app.name} react`,
3820
+ logs: csrLogs.map((log) => log.content),
3821
+ color: "#7cc5d9"
3822
+ }
3823
+ ]
3824
+ }
3825
+ )));
3826
+ };
3827
+ var Interface = {
3828
+ Csr: (app, onLoad) => (0, import_ink4.render)(/* @__PURE__ */ import_react4.default.createElement(Csr, { app, onLoad })),
3829
+ Backend: (app, env) => (0, import_ink4.render)(/* @__PURE__ */ import_react4.default.createElement(Backend, { app, env })),
3830
+ Frontend: (app, env) => (0, import_ink4.render)(/* @__PURE__ */ import_react4.default.createElement(Frontend, { app, env })),
3831
+ Start: (app, backendEnv, frontendEnv, onLoadCsr) => (0, import_ink4.render)(/* @__PURE__ */ import_react4.default.createElement(Start, { app, backendEnv, frontendEnv, onLoadCsr }))
3832
+ };
3833
+
3834
+ // pkgs/@akanjs/cli/src/application/application.runner.ts
3468
3835
  var ApplicationRunner = class {
3469
3836
  async createApplication(appName, workspace) {
3470
3837
  await workspace.applyTemplate({
@@ -3492,6 +3859,34 @@ var ApplicationRunner = class {
3492
3859
  await app.syncAssets(scanResult.akanConfig.libs);
3493
3860
  return scanResult;
3494
3861
  }
3862
+ async start(app) {
3863
+ const { env: frontendEnv } = await this.#prepareCommand(app, "start", "frontend");
3864
+ const { env: backendEnv } = await this.#prepareCommand(app, "start", "backend");
3865
+ Interface.Start(app, backendEnv, frontendEnv, async ({ onLog }) => {
3866
+ const config = await this.#getViteConfig(app, "start", {
3867
+ customLogger: {
3868
+ info: (msg) => {
3869
+ onLog(msg);
3870
+ },
3871
+ warn: (msg) => {
3872
+ },
3873
+ warnOnce: (msg) => {
3874
+ },
3875
+ error: (msg) => {
3876
+ onLog(msg);
3877
+ },
3878
+ clearScreen: (type) => {
3879
+ },
3880
+ hasErrorLogged: (error) => {
3881
+ return false;
3882
+ },
3883
+ hasWarned: false
3884
+ }
3885
+ });
3886
+ const server = await vite.createServer(config);
3887
+ await server.listen(4201);
3888
+ });
3889
+ }
3495
3890
  async getScriptFilename(app) {
3496
3891
  if (!app.exists("scripts")) {
3497
3892
  app.mkdir("scripts");
@@ -3539,8 +3934,6 @@ var ApplicationRunner = class {
3539
3934
  app.writeFile("next.config.ts", defaultNextConfigFile);
3540
3935
  } else if (target === "csr")
3541
3936
  await app.workspace.exec("rm -rf node_modules/.vite");
3542
- else if (target === "backend")
3543
- await app.cp("assets", import_path4.default.join(app.dist.cwdPath, "backend", "assets"));
3544
3937
  return { env: this.#getEnv(app, { AKAN_COMMAND_TYPE: type }) };
3545
3938
  }
3546
3939
  async buildBackend(app) {
@@ -3569,7 +3962,7 @@ var ApplicationRunner = class {
3569
3962
  dependencies
3570
3963
  };
3571
3964
  app.dist.writeJson("backend/package.json", appPackageJson);
3572
- app.dist.writeFile(import_path4.default.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.dockerfile);
3965
+ app.dist.writeFile(import_path5.default.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.dockerfile);
3573
3966
  }
3574
3967
  async startBackend(app, { open: open2 = false, onStart } = {}) {
3575
3968
  const { env } = await this.#prepareCommand(app, "start", "backend");
@@ -3580,7 +3973,7 @@ var ApplicationRunner = class {
3580
3973
  packages: "external",
3581
3974
  platform: "node",
3582
3975
  format: "cjs",
3583
- outdir: import_path4.default.join(app.dist.cwdPath, "backend"),
3976
+ outdir: import_path5.default.join(app.dist.cwdPath, "backend"),
3584
3977
  logLevel: "warning"
3585
3978
  });
3586
3979
  await ctx.watch();
@@ -3588,7 +3981,7 @@ var ApplicationRunner = class {
3588
3981
  onStart?.();
3589
3982
  if (open2)
3590
3983
  setTimeout(() => (0, import_open.default)("http://localhost:8080/backend/graphql"), 3e3);
3591
- await app.dist.spawn("node", ["--watch", "main.js"], { env, stdio: "inherit", cwd: `${app.dist.cwdPath}/backend` });
3984
+ await app.dist.spawn("node", ["--watch", "backend/main.js"], { env, stdio: "inherit" });
3592
3985
  }
3593
3986
  async buildFrontend(app, { spawnOptions } = {}) {
3594
3987
  const { env } = await this.#prepareCommand(app, "build", "frontend");
@@ -3600,10 +3993,10 @@ var ApplicationRunner = class {
3600
3993
  bundle: true,
3601
3994
  packages: "external",
3602
3995
  platform: "node",
3603
- format: "cjs",
3996
+ format: "esm",
3604
3997
  write: false,
3605
- logLevel: "warning",
3606
- footer: { js: "module.exports = module.exports.default;" }
3998
+ logLevel: "warning"
3999
+ // footer: { js: "module.exports = module.exports.default;" },
3607
4000
  });
3608
4001
  const rootPackageJson = app.workspace.readJson("package.json");
3609
4002
  const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson, ["next", "react", "react-dom"]);
@@ -3618,8 +4011,8 @@ var ApplicationRunner = class {
3618
4011
  };
3619
4012
  app.dist.writeJson("frontend/package.json", appPackageJson);
3620
4013
  await Promise.all([
3621
- app.cp(".next", import_path4.default.join(app.dist.cwdPath, "frontend", ".next")),
3622
- app.cp("public", import_path4.default.join(app.dist.cwdPath, "frontend", "public"))
4014
+ app.cp(".next", import_path5.default.join(app.dist.cwdPath, "frontend", ".next")),
4015
+ app.cp("public", import_path5.default.join(app.dist.cwdPath, "frontend", "public"))
3623
4016
  ]);
3624
4017
  app.dist.writeFile("frontend/Dockerfile", akanConfig.frontend.dockerfile);
3625
4018
  }
@@ -3630,7 +4023,7 @@ var ApplicationRunner = class {
3630
4023
  onStart?.();
3631
4024
  await app.spawn("npx", ["next", "dev", "-p", "4200", ...turbo ? ["--turbo"] : []], { env, stdio: "inherit" });
3632
4025
  }
3633
- async #getViteConfig(app, command) {
4026
+ async #getViteConfig(app, command, viteConfig = {}) {
3634
4027
  const { env } = await this.#prepareCommand(app, command, "csr");
3635
4028
  const tsconfig = app.workspace.getTsConfig();
3636
4029
  const akanConfig = await app.getConfig();
@@ -3638,6 +4031,7 @@ var ApplicationRunner = class {
3638
4031
  const processEnv = env;
3639
4032
  const akanjsPrefix = process.env.USE_AKANJS_PKGS === "true" ? `${app.workspace.workspaceRoot}/pkgs/` : "";
3640
4033
  const config = vite.defineConfig({
4034
+ ...viteConfig,
3641
4035
  root: `${app.cwdPath}/app`,
3642
4036
  base: "/",
3643
4037
  build: {
@@ -3655,6 +4049,8 @@ var ApplicationRunner = class {
3655
4049
  (0, import_plugin_react.default)(),
3656
4050
  (0, import_vite_tsconfig_paths.default)(),
3657
4051
  (0, import_vite_plugin_commonjs.default)(),
4052
+ //? A postCSS 어쩌구 에러 제거하는 방법인데 적용시 tailwind가 망가져버림.
4053
+ // tailwindcss(),
3658
4054
  (0, import_vite_plugin_node_polyfills.nodePolyfills)({
3659
4055
  exclude: ["fs"],
3660
4056
  include: ["crypto", "process", "stream", "util"],
@@ -3713,12 +4109,36 @@ var ApplicationRunner = class {
3713
4109
  const config = await this.#getViteConfig(app, "build");
3714
4110
  await vite.build(config);
3715
4111
  }
3716
- async startCsr(app, { open: open2 = false, onStart } = {}) {
3717
- const config = await this.#getViteConfig(app, "start");
3718
- const server = await vite.createServer(config);
3719
- await server.listen(4201);
4112
+ startCsr(app, { open: open2 = false, onStart } = {}) {
4113
+ Interface.Csr(app, async ({ onLog }) => {
4114
+ const config = await this.#getViteConfig(app, "start", {
4115
+ customLogger: {
4116
+ info: (msg) => {
4117
+ onLog(msg);
4118
+ },
4119
+ warn: (msg) => {
4120
+ onLog(msg);
4121
+ },
4122
+ warnOnce: (msg) => {
4123
+ onLog(msg);
4124
+ },
4125
+ error: (msg) => {
4126
+ onLog(msg);
4127
+ },
4128
+ clearScreen: (type) => {
4129
+ onLog(type);
4130
+ },
4131
+ hasErrorLogged: (error) => {
4132
+ return false;
4133
+ },
4134
+ hasWarned: false
4135
+ }
4136
+ });
4137
+ const env = this.#prepareCommand(app, "start", "csr");
4138
+ const server = await vite.createServer(config);
4139
+ await server.listen(4201);
4140
+ });
3720
4141
  onStart?.();
3721
- app.log(`CSR server is running on http://localhost:4201`);
3722
4142
  if (open2)
3723
4143
  setTimeout(() => (0, import_open.default)("http://localhost:4201"), 3e3);
3724
4144
  }
@@ -3854,8 +4274,8 @@ var ApplicationRunner = class {
3854
4274
  )
3855
4275
  );
3856
4276
  await Promise.all(
3857
- [".next", "ios", "android", "public/libs"].map(async (path9) => {
3858
- const targetPath = `${sourceRoot}/apps/${app.name}/${path9}`;
4277
+ [".next", "ios", "android", "public/libs"].map(async (path10) => {
4278
+ const targetPath = `${sourceRoot}/apps/${app.name}/${path10}`;
3859
4279
  if (import_fs10.default.existsSync(targetPath))
3860
4280
  await import_promises3.default.rm(targetPath, { recursive: true, force: true });
3861
4281
  })
@@ -3873,7 +4293,7 @@ var ApplicationRunner = class {
3873
4293
  ];
3874
4294
  await Promise.all(
3875
4295
  syncPaths.map(
3876
- (path9) => import_promises3.default.cp(`${app.workspace.cwdPath}/${path9}`, `${sourceRoot}/${path9}`, { recursive: true })
4296
+ (path10) => import_promises3.default.cp(`${app.workspace.cwdPath}/${path10}`, `${sourceRoot}/${path10}`, { recursive: true })
3877
4297
  )
3878
4298
  );
3879
4299
  const tsconfig = app.workspace.readJson("tsconfig.json");
@@ -4014,11 +4434,7 @@ var ApplicationScript = class {
4014
4434
  await this.syncApplication(app);
4015
4435
  if (app.workspace.getBaseDevEnv().env === "local")
4016
4436
  await this.dbup(app.workspace);
4017
- await Promise.all([
4018
- this.startBackend(app, { open: open2, sync: false }),
4019
- this.startFrontend(app, { open: open2, sync: false }),
4020
- this.startCsr(app, { open: open2, sync: false })
4021
- ]);
4437
+ await this.#runner.start(app);
4022
4438
  }
4023
4439
  async buildBackend(app, { sync = true } = {}) {
4024
4440
  if (sync)
@@ -4078,11 +4494,9 @@ var ApplicationScript = class {
4078
4494
  async startCsr(app, { open: open2 = false, sync = true } = {}) {
4079
4495
  if (sync)
4080
4496
  await this.syncApplication(app);
4081
- const spinner = app.spinning("Preparing CSR...");
4082
- await this.#runner.startCsr(app, {
4497
+ this.#runner.startCsr(app, {
4083
4498
  open: open2,
4084
4499
  onStart: () => {
4085
- spinner.succeed(`CSR prepared, ready to start`);
4086
4500
  }
4087
4501
  });
4088
4502
  }
@@ -4250,6 +4664,10 @@ var ApplicationCommand = class {
4250
4664
  async test(sys3) {
4251
4665
  await this.applicationScript.testSys(sys3);
4252
4666
  }
4667
+ // @Target.Public()
4668
+ // ink(@Workspace() workspace: Workspace) {
4669
+ // run();
4670
+ // }
4253
4671
  };
4254
4672
  __decorateClass([
4255
4673
  Target.Public(),
@@ -4394,7 +4812,7 @@ ApplicationCommand = __decorateClass([
4394
4812
  ], ApplicationCommand);
4395
4813
 
4396
4814
  // pkgs/@akanjs/cli/src/package/package.runner.ts
4397
- var import_promises4 = __toESM(require("fs/promises"));
4815
+ var import_promises4 = __toESM(require("fs/promises"), 1);
4398
4816
  var PackageRunner = class {
4399
4817
  async version(workspace) {
4400
4818
  const pkgJson = JSON.parse(await import_promises4.default.readFile("package.json", "utf-8"));
@@ -4458,10 +4876,10 @@ var PackageScript = class {
4458
4876
 
4459
4877
  // pkgs/@akanjs/cli/src/cloud/cloud.runner.ts
4460
4878
  var import_prompts8 = require("@inquirer/prompts");
4461
- var import_chalk6 = __toESM(require("chalk"));
4462
- var import_latest_version = __toESM(require("latest-version"));
4463
- var import_open2 = __toESM(require("open"));
4464
- var QRcode = __toESM(require("qrcode"));
4879
+ var import_chalk6 = __toESM(require("chalk"), 1);
4880
+ var import_latest_version = __toESM(require("latest-version"), 1);
4881
+ var import_open2 = __toESM(require("open"), 1);
4882
+ var QRcode = __toESM(require("qrcode"), 1);
4465
4883
  var import_uuid = require("uuid");
4466
4884
  var CloudRunner = class {
4467
4885
  async login() {
@@ -4579,15 +4997,6 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
4579
4997
  Logger.info("All libraries are published to npm");
4580
4998
  }
4581
4999
  async update(workspace) {
4582
- if (!workspace.exists("package.json"))
4583
- await workspace.spawn("npm", ["update", "-g", "@akanjs/cli", "--latest"]);
4584
- else
4585
- await Promise.all([
4586
- workspace.spawn("npm", ["update", "-g", "@akanjs/cli", "--latest"]),
4587
- this.#updateAkanPkgs(workspace)
4588
- ]);
4589
- }
4590
- async #updateAkanPkgs(workspace) {
4591
5000
  const latestPublishedVersionOfBase = await (0, import_latest_version.default)("@akanjs/base");
4592
5001
  const rootPackageJson = workspace.readJson("package.json");
4593
5002
  if (!rootPackageJson.dependencies)
@@ -4601,7 +5010,10 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
4601
5010
  Object.assign(rootPackageJson.devDependencies ?? {}, { [dependency]: latestPublishedVersionOfBase });
4602
5011
  });
4603
5012
  workspace.writeJson("package.json", rootPackageJson);
4604
- await workspace.spawn("pnpm", ["install"]);
5013
+ await Promise.all([
5014
+ workspace.spawn("npm", ["update", "-g", "@akanjs/cli", "--latest"]),
5015
+ workspace.spawn("pnpm", ["install"])
5016
+ ]);
4605
5017
  }
4606
5018
  };
4607
5019
 
@@ -4754,7 +5166,7 @@ LibraryCommand = __decorateClass([
4754
5166
  ], LibraryCommand);
4755
5167
 
4756
5168
  // pkgs/@akanjs/cli/src/module/module.script.ts
4757
- var import_fs11 = __toESM(require("fs"));
5169
+ var import_fs11 = __toESM(require("fs"), 1);
4758
5170
 
4759
5171
  // pkgs/@akanjs/cli/src/module/module.prompt.ts
4760
5172
  var componentDefaultDescription = ({
@@ -5257,9 +5669,13 @@ var ModuleScript = class {
5257
5669
  // pkgs/@akanjs/cli/src/module/module.command.ts
5258
5670
  var ModuleCommand = class {
5259
5671
  moduleScript = new ModuleScript();
5260
- async createModule(moduleName, sys3) {
5672
+ async createModule(sys3, moduleName, description, schemaDescription, ai) {
5261
5673
  const name = lowerlize(moduleName.replace(/ /g, ""));
5262
- await this.moduleScript.createModuleTemplate(sys3, name);
5674
+ if (ai) {
5675
+ await this.moduleScript.createModule(sys3, name, description, schemaDescription);
5676
+ } else {
5677
+ await this.moduleScript.createModuleTemplate(sys3, name);
5678
+ }
5263
5679
  }
5264
5680
  removeModule(module2) {
5265
5681
  this.moduleScript.removeModule(module2);
@@ -5276,8 +5692,11 @@ var ModuleCommand = class {
5276
5692
  };
5277
5693
  __decorateClass([
5278
5694
  Target.Public(),
5279
- __decorateParam(0, Argument("moduleName", { desc: "name of module" })),
5280
- __decorateParam(1, Sys())
5695
+ __decorateParam(0, Sys()),
5696
+ __decorateParam(1, Argument("moduleName", { desc: "name of module" })),
5697
+ __decorateParam(2, Option("description", { desc: "description of module" })),
5698
+ __decorateParam(3, Option("schemaDescription", { desc: "schema description of module" })),
5699
+ __decorateParam(4, Option("ai", { type: "boolean", default: false, desc: "use ai to create module" }))
5281
5700
  ], ModuleCommand.prototype, "createModule", 1);
5282
5701
  __decorateClass([
5283
5702
  Target.Public(),
@@ -5373,13 +5792,13 @@ PageCommand = __decorateClass([
5373
5792
  ], PageCommand);
5374
5793
 
5375
5794
  // pkgs/@akanjs/cli/src/workspace/workspace.runner.ts
5376
- var import_latest_version2 = __toESM(require("latest-version"));
5377
- var import_path5 = __toESM(require("path"));
5795
+ var import_latest_version2 = __toESM(require("latest-version"), 1);
5796
+ var import_path6 = __toESM(require("path"), 1);
5378
5797
  var import_uuid2 = require("uuid");
5379
5798
  var WorkspaceRunner = class {
5380
5799
  async createWorkspace(repoName, appName, dirname3 = ".") {
5381
5800
  const cwdPath = process.cwd();
5382
- const workspaceRoot = import_path5.default.join(cwdPath, dirname3, repoName);
5801
+ const workspaceRoot = import_path6.default.join(cwdPath, dirname3, repoName);
5383
5802
  const workspace = new WorkspaceExecutor({ workspaceRoot, repoName });
5384
5803
  const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname3}/${repoName}...`);
5385
5804
  await workspace.applyTemplate({
@@ -5566,8 +5985,9 @@ WorkspaceCommand = __decorateClass([
5566
5985
  ], WorkspaceCommand);
5567
5986
 
5568
5987
  // pkgs/@akanjs/cli/src/guideline/guideline.prompt.ts
5569
- var import_fs12 = __toESM(require("fs"));
5570
- var import_promises5 = __toESM(require("fs/promises"));
5988
+ var import_fs12 = __toESM(require("fs"), 1);
5989
+ var import_promises5 = __toESM(require("fs/promises"), 1);
5990
+ var import_meta5 = {};
5571
5991
  var GuidelinePrompt = class extends Prompter {
5572
5992
  constructor(workspace, name) {
5573
5993
  super();
@@ -5577,15 +5997,15 @@ var GuidelinePrompt = class extends Prompter {
5577
5997
  async #getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
5578
5998
  const matchingPaths = import_promises5.default.glob(matchPattern, {
5579
5999
  cwd: this.workspace.workspaceRoot,
5580
- exclude: (path9) => avoidDirs.some((dir) => path9.includes(dir))
6000
+ exclude: (path10) => avoidDirs.some((dir) => path10.includes(dir))
5581
6001
  });
5582
6002
  const paths = [];
5583
- for await (const path9 of matchingPaths) {
5584
- const fileContent = import_fs12.default.readFileSync(path9, "utf-8");
6003
+ for await (const path10 of matchingPaths) {
6004
+ const fileContent = import_fs12.default.readFileSync(path10, "utf-8");
5585
6005
  const textFilter = filterText ? new RegExp(filterText) : null;
5586
6006
  if (filterText && !textFilter?.test(fileContent))
5587
6007
  continue;
5588
- paths.push(path9);
6008
+ paths.push(path10);
5589
6009
  }
5590
6010
  return paths;
5591
6011
  }
@@ -5598,7 +6018,7 @@ var GuidelinePrompt = class extends Prompter {
5598
6018
  const scanResult = targetFilePaths.map((filePath) => ({ ...scan, ...this.workspace.getLocalFile(filePath) }));
5599
6019
  scanFiles.push(...scanResult);
5600
6020
  }
5601
- const resultPath = `${__dirname}/src/guidelines/${this.name}/${guideJson.update.filePath}`;
6021
+ const resultPath = `${getDirname(import_meta5.url)}/src/guidelines/${this.name}/${guideJson.update.filePath}`;
5602
6022
  const writePath = `${this.workspace.workspaceRoot}/pkgs/@akanjs/cli/src/guidelines/${this.name}/${guideJson.update.filePath}`;
5603
6023
  const isResultExists = this.workspace.exists(writePath);
5604
6024
  const existingResult = isResultExists ? this.workspace.readFile(resultPath) : null;
@@ -5640,7 +6060,7 @@ ${guideJson.update.rules.map((rule) => `- ${rule}`).join("\n")}
5640
6060
  }
5641
6061
  async requestUpdateInstruction(updateRequest) {
5642
6062
  const guideJson = await Prompter.getGuideJson(this.name);
5643
- const resultPath = `${__dirname}/src/guidelines/${this.name}/${guideJson.update.filePath}`;
6063
+ const resultPath = `${getDirname(import_meta5.url)}/src/guidelines/${this.name}/${guideJson.update.filePath}`;
5644
6064
  const writePath = `${this.workspace.workspaceRoot}/pkgs/@akanjs/cli/src/guidelines/${this.name}/${guideJson.update.filePath}`;
5645
6065
  const isResultExists = this.workspace.exists(writePath);
5646
6066
  if (!isResultExists)
@@ -5893,7 +6313,7 @@ GuidelineCommand = __decorateClass([
5893
6313
  ], GuidelineCommand);
5894
6314
 
5895
6315
  // pkgs/@akanjs/cli/src/scalar/scalar.runner.ts
5896
- var import_pluralize3 = __toESM(require("pluralize"));
6316
+ var import_pluralize3 = __toESM(require("pluralize"), 1);
5897
6317
 
5898
6318
  // pkgs/@akanjs/cli/src/scalar/scalar.prompt.ts
5899
6319
  var import_prompts9 = require("@inquirer/prompts");
@@ -6087,7 +6507,7 @@ ScalarCommand = __decorateClass([
6087
6507
  ], ScalarCommand);
6088
6508
 
6089
6509
  // pkgs/@akanjs/cli/index.ts
6090
- require("dotenv").config({ path: `${process.cwd()}/.env` });
6510
+ import_dotenv4.default.config({ path: `${process.cwd()}/.env` });
6091
6511
  void runCommands(
6092
6512
  WorkspaceCommand,
6093
6513
  ApplicationCommand,