@akanjs/cli 0.9.11 → 0.9.13

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 (3) hide show
  1. package/cjs/index.js +84 -89
  2. package/esm/index.js +72 -76
  3. package/package.json +2 -2
package/cjs/index.js CHANGED
@@ -400,8 +400,8 @@ var fs3 = __toESM(require("fs"));
400
400
  var import_ora2 = __toESM(require("ora"));
401
401
  var ts = __toESM(require("typescript"));
402
402
  var parseTsConfig = (tsConfigPath = "./tsconfig.json") => {
403
- const configFile = ts.readConfigFile(tsConfigPath, (path10) => {
404
- return ts.sys.readFile(path10);
403
+ const configFile = ts.readConfigFile(tsConfigPath, (path9) => {
404
+ return ts.sys.readFile(path9);
405
405
  });
406
406
  return ts.parseJsonConfigFileContent(
407
407
  configFile.config,
@@ -564,14 +564,12 @@ var import_openai = require("@langchain/openai");
564
564
 
565
565
  // pkgs/@akanjs/config/src/akanConfig.ts
566
566
  var import_fs3 = __toESM(require("fs"));
567
- var import_path2 = __toESM(require("path"));
567
+ var import_path = __toESM(require("path"));
568
568
 
569
569
  // pkgs/@akanjs/config/src/nextConfig.ts
570
570
  var import_bundle_analyzer = __toESM(require("@next/bundle-analyzer"));
571
571
  var import_next_pwa = __toESM(require("next-pwa"));
572
572
  var import_cache = __toESM(require("next-pwa/cache.js"));
573
- var import_path = __toESM(require("path"));
574
- var import_meta = {};
575
573
  var composePlugins = (...plugins) => {
576
574
  return function(baseConfig) {
577
575
  return async function combined(phase, context2) {
@@ -591,7 +589,6 @@ var composePlugins = (...plugins) => {
591
589
  var commandType = process.env.AKAN_COMMAND_TYPE?.includes("start") ? "start" : process.env.AKAN_COMMAND_TYPE?.includes("build") ? "build" : "deploy";
592
590
  var devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
593
591
  var withBase = (appName, config, libs, routes = []) => {
594
- const __dirname = import_path.default.dirname(new URL(import_meta.url).pathname);
595
592
  const withPWA = (0, import_next_pwa.default)({
596
593
  dest: "public",
597
594
  register: true,
@@ -662,15 +659,13 @@ var withBase = (appName, config, libs, routes = []) => {
662
659
  webpack: (config2) => {
663
660
  config2.resolve.alias.canvas = false;
664
661
  config2.resolve.alias.encoding = false;
665
- if (process.env.USE_AKANJS_PKGS === "true")
666
- config2.resolve.alias["@akanjs/config"] = import_path.default.resolve(__dirname, "../../../../pkgs/@akanjs/config");
667
662
  return config2;
668
663
  },
669
664
  turbopack: {
670
665
  resolveAlias: {
671
666
  // canvas: false,
672
667
  // encoding: false,
673
- ...process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config": import_path.default.resolve(__dirname, "../../../../pkgs/@akanjs/config") } : {},
668
+ // ...(process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config": "../../pkgs/@akanjs/config" } : {}),
674
669
  ...config.turbopack?.resolveAlias ?? {}
675
670
  }
676
671
  },
@@ -784,7 +779,7 @@ CMD ["npm", "start"]`,
784
779
  };
785
780
  };
786
781
  var getAppConfig = async (appRoot, props) => {
787
- const akanConfigPath = import_path2.default.join(appRoot, "akan.config.ts");
782
+ const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
788
783
  if (!import_fs3.default.existsSync(akanConfigPath))
789
784
  throw new Error(`application akan.config.ts is not found ${appRoot}`);
790
785
  const configImp = (await import(`${appRoot}/akan.config.ts`)).default;
@@ -804,7 +799,7 @@ var makeLibConfig = (config, props) => {
804
799
  };
805
800
  };
806
801
  var getLibConfig = async (libRoot, props) => {
807
- const akanConfigPath = import_path2.default.join(libRoot, "akan.config.ts");
802
+ const akanConfigPath = import_path.default.join(libRoot, "akan.config.ts");
808
803
  if (!import_fs3.default.existsSync(akanConfigPath))
809
804
  throw new Error(`library akan.config.ts is not found ${libRoot}`);
810
805
  const configImp = (await import(`${libRoot}/akan.config.ts`)).default;
@@ -855,11 +850,11 @@ var import_child_process = require("child_process");
855
850
  var import_dotenv = __toESM(require("dotenv"));
856
851
  var import_fs4 = __toESM(require("fs"));
857
852
  var import_promises = __toESM(require("fs/promises"));
858
- var import_path4 = __toESM(require("path"));
853
+ var import_path3 = __toESM(require("path"));
859
854
 
860
855
  // pkgs/@akanjs/devkit/src/dependencyScanner.ts
861
856
  var fs5 = __toESM(require("fs"));
862
- var path3 = __toESM(require("path"));
857
+ var path2 = __toESM(require("path"));
863
858
  var ts2 = __toESM(require("typescript"));
864
859
  var TypeScriptDependencyScanner = class {
865
860
  constructor(directory) {
@@ -905,7 +900,7 @@ var TypeScriptDependencyScanner = class {
905
900
  const processDirectory = async (dir) => {
906
901
  const entries = await fs5.promises.readdir(dir, { withFileTypes: true });
907
902
  for (const entry of entries) {
908
- const fullPath = path3.join(dir, entry.name);
903
+ const fullPath = path2.join(dir, entry.name);
909
904
  if (entry.isDirectory()) {
910
905
  if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
911
906
  await processDirectory(fullPath);
@@ -925,12 +920,12 @@ var TypeScriptDependencyScanner = class {
925
920
  const imports = this.#extractImports(fileContent, filePath);
926
921
  const resolvedImports = imports.map((importPath) => {
927
922
  if (importPath.startsWith(".")) {
928
- const resolvedPath = "./" + path3.join(path3.relative(baseDir, filePath), importPath);
923
+ const resolvedPath = "./" + path2.join(path2.relative(baseDir, filePath), importPath);
929
924
  return this.#ensureExtension(resolvedPath);
930
925
  }
931
926
  return importPath;
932
927
  });
933
- const relativePath = path3.relative(baseDir, filePath);
928
+ const relativePath = path2.relative(baseDir, filePath);
934
929
  this.#fileDependencies.set(relativePath, resolvedImports);
935
930
  } catch (error) {
936
931
  }
@@ -1005,14 +1000,14 @@ var TypeScriptDependencyScanner = class {
1005
1000
  };
1006
1001
 
1007
1002
  // 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);
1003
+ var import_path2 = __toESM(require("path"));
1004
+ var getDirname = (url) => import_path2.default.dirname(new URL(url).pathname);
1010
1005
 
1011
1006
  // pkgs/@akanjs/devkit/src/linter.ts
1012
1007
  var import_chalk = __toESM(require("chalk"));
1013
1008
  var import_eslint = require("eslint");
1014
1009
  var fs6 = __toESM(require("fs"));
1015
- var path5 = __toESM(require("path"));
1010
+ var path4 = __toESM(require("path"));
1016
1011
  var Linter = class {
1017
1012
  #logger = new Logger("Linter");
1018
1013
  #eslint;
@@ -1022,10 +1017,10 @@ var Linter = class {
1022
1017
  this.#eslint = new import_eslint.ESLint({ cwd: this.lintRoot, errorOnUnmatchedPattern: false });
1023
1018
  }
1024
1019
  #findEslintRootPath(dir) {
1025
- const configPath2 = path5.join(dir, "eslint.config.ts");
1020
+ const configPath2 = path4.join(dir, "eslint.config.ts");
1026
1021
  if (fs6.existsSync(configPath2))
1027
1022
  return dir;
1028
- const parentDir = path5.dirname(dir);
1023
+ const parentDir = path4.dirname(dir);
1029
1024
  return this.#findEslintRootPath(parentDir);
1030
1025
  }
1031
1026
  async lint(filePath, { fix = false, dryRun = false } = {}) {
@@ -1214,7 +1209,7 @@ ${errorText}, ${warningText} found`];
1214
1209
  // pkgs/@akanjs/devkit/src/typeChecker.ts
1215
1210
  var import_chalk2 = __toESM(require("chalk"));
1216
1211
  var fs7 = __toESM(require("fs"));
1217
- var path6 = __toESM(require("path"));
1212
+ var path5 = __toESM(require("path"));
1218
1213
  var ts3 = __toESM(require("typescript"));
1219
1214
  var TypeChecker = class {
1220
1215
  configPath;
@@ -1229,7 +1224,7 @@ var TypeChecker = class {
1229
1224
  const parsedConfig = ts3.parseJsonConfigFileContent(
1230
1225
  this.configFile.config,
1231
1226
  ts3.sys,
1232
- path6.dirname(this.configPath),
1227
+ path5.dirname(this.configPath),
1233
1228
  void 0,
1234
1229
  this.configPath
1235
1230
  );
@@ -1384,7 +1379,7 @@ ${summary.join(", ")} found` + output.join("\n");
1384
1379
  };
1385
1380
 
1386
1381
  // pkgs/@akanjs/devkit/src/executors.ts
1387
- var import_meta2 = {};
1382
+ var import_meta = {};
1388
1383
  var execEmoji = {
1389
1384
  workspace: "\u{1F3E0}",
1390
1385
  app: "\u{1F680}",
@@ -1496,7 +1491,7 @@ var Executor = class _Executor {
1496
1491
  });
1497
1492
  }
1498
1493
  getPath(filePath) {
1499
- if (import_path4.default.isAbsolute(filePath))
1494
+ if (import_path3.default.isAbsolute(filePath))
1500
1495
  return filePath;
1501
1496
  const baseParts = this.cwdPath.split("/").filter(Boolean);
1502
1497
  const targetParts = filePath.split("/").filter(Boolean);
@@ -1549,7 +1544,7 @@ var Executor = class _Executor {
1549
1544
  }
1550
1545
  writeFile(filePath, content, { overwrite = true } = {}) {
1551
1546
  const writePath = this.getPath(filePath);
1552
- const dir = import_path4.default.dirname(writePath);
1547
+ const dir = import_path3.default.dirname(writePath);
1553
1548
  if (!import_fs4.default.existsSync(dir))
1554
1549
  import_fs4.default.mkdirSync(dir, { recursive: true });
1555
1550
  let contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
@@ -1573,7 +1568,7 @@ var Executor = class _Executor {
1573
1568
  return this;
1574
1569
  }
1575
1570
  getLocalFile(targetPath) {
1576
- const filePath = import_path4.default.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
1571
+ const filePath = import_path3.default.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
1577
1572
  const content = this.readFile(filePath);
1578
1573
  return { filePath, content };
1579
1574
  }
@@ -1624,11 +1619,11 @@ var Executor = class _Executor {
1624
1619
  const result = getContent.default(scanResult ?? null, dict);
1625
1620
  if (result === null)
1626
1621
  return null;
1627
- const filename = typeof result === "object" ? result.filename : import_path4.default.basename(targetPath).replace(".js", ".ts");
1622
+ const filename = typeof result === "object" ? result.filename : import_path3.default.basename(targetPath).replace(".js", ".ts");
1628
1623
  const content = typeof result === "object" ? result.content : result;
1629
- const dirname3 = import_path4.default.dirname(targetPath);
1624
+ const dirname3 = import_path3.default.dirname(targetPath);
1630
1625
  const convertedTargetPath = Object.entries(dict).reduce(
1631
- (path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
1626
+ (path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
1632
1627
  `${dirname3}/${filename}`
1633
1628
  );
1634
1629
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
@@ -1636,7 +1631,7 @@ var Executor = class _Executor {
1636
1631
  } else if (targetPath.endsWith(".template")) {
1637
1632
  const content = await import_promises.default.readFile(templatePath, "utf8");
1638
1633
  const convertedTargetPath = Object.entries(dict).reduce(
1639
- (path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
1634
+ (path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
1640
1635
  targetPath.slice(0, -9)
1641
1636
  );
1642
1637
  const convertedContent = Object.entries(dict).reduce(
@@ -1655,12 +1650,12 @@ var Executor = class _Executor {
1655
1650
  dict = {},
1656
1651
  overwrite = true
1657
1652
  }) {
1658
- const templatePath = `${getDirname(import_meta2.url)}/src/templates${template ? `/${template}` : ""}`;
1653
+ const templatePath = `${getDirname(import_meta.url)}/src/templates${template ? `/${template}` : ""}`;
1659
1654
  const prefixTemplatePath = templatePath.endsWith(".tsx") ? templatePath : templatePath.replace(".ts", ".js");
1660
1655
  if (import_fs4.default.statSync(prefixTemplatePath).isFile()) {
1661
- const filename = import_path4.default.basename(prefixTemplatePath);
1656
+ const filename = import_path3.default.basename(prefixTemplatePath);
1662
1657
  const fileContent = await this.#applyTemplateFile(
1663
- { templatePath: prefixTemplatePath, targetPath: import_path4.default.join(basePath2, filename), scanResult, overwrite },
1658
+ { templatePath: prefixTemplatePath, targetPath: import_path3.default.join(basePath2, filename), scanResult, overwrite },
1664
1659
  dict
1665
1660
  );
1666
1661
  return fileContent ? [fileContent] : [];
@@ -1668,17 +1663,17 @@ var Executor = class _Executor {
1668
1663
  const subdirs = await this.readdir(templatePath);
1669
1664
  const fileContents = (await Promise.all(
1670
1665
  subdirs.map(async (subdir) => {
1671
- const subpath = import_path4.default.join(templatePath, subdir);
1666
+ const subpath = import_path3.default.join(templatePath, subdir);
1672
1667
  if (import_fs4.default.statSync(subpath).isFile()) {
1673
1668
  const fileContent = await this.#applyTemplateFile(
1674
- { templatePath: subpath, targetPath: import_path4.default.join(basePath2, subdir), scanResult, overwrite },
1669
+ { templatePath: subpath, targetPath: import_path3.default.join(basePath2, subdir), scanResult, overwrite },
1675
1670
  dict
1676
1671
  );
1677
1672
  return fileContent ? [fileContent] : [];
1678
1673
  } else
1679
1674
  return await this._applyTemplate({
1680
- basePath: import_path4.default.join(basePath2, subdir),
1681
- template: import_path4.default.join(template, subdir),
1675
+ basePath: import_path3.default.join(basePath2, subdir),
1676
+ template: import_path3.default.join(template, subdir),
1682
1677
  scanResult,
1683
1678
  dict,
1684
1679
  overwrite
@@ -1702,9 +1697,9 @@ var Executor = class _Executor {
1702
1697
  return this.typeChecker;
1703
1698
  }
1704
1699
  typeCheck(filePath) {
1705
- const path10 = this.getPath(filePath);
1700
+ const path9 = this.getPath(filePath);
1706
1701
  const typeChecker = this.getTypeChecker();
1707
- const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path10);
1702
+ const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path9);
1708
1703
  const message = typeChecker.formatDiagnostics(fileDiagnostics);
1709
1704
  return { fileDiagnostics, fileErrors, fileWarnings, message };
1710
1705
  }
@@ -1713,9 +1708,9 @@ var Executor = class _Executor {
1713
1708
  return this.linter;
1714
1709
  }
1715
1710
  async lint(filePath, { fix = false, dryRun = false } = {}) {
1716
- const path10 = this.getPath(filePath);
1711
+ const path9 = this.getPath(filePath);
1717
1712
  const linter = this.getLinter();
1718
- const { results, errors, warnings } = await linter.lint(path10, { fix, dryRun });
1713
+ const { results, errors, warnings } = await linter.lint(path9, { fix, dryRun });
1719
1714
  const message = linter.formatLintResults(results);
1720
1715
  return { results, message, errors, warnings };
1721
1716
  }
@@ -1730,7 +1725,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1730
1725
  this.repoName = repoName;
1731
1726
  }
1732
1727
  static fromRoot() {
1733
- const repoName = import_path4.default.basename(process.cwd());
1728
+ const repoName = import_path3.default.basename(process.cwd());
1734
1729
  return new _WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
1735
1730
  }
1736
1731
  getBaseDevEnv() {
@@ -1839,7 +1834,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1839
1834
  dirs.map(async (dir) => {
1840
1835
  if (dir.includes("_") || AVOID_DIRS.includes(dir))
1841
1836
  return;
1842
- const dirPath = import_path4.default.join(dirname3, dir);
1837
+ const dirPath = import_path3.default.join(dirname3, dir);
1843
1838
  if (import_fs4.default.lstatSync(dirPath).isDirectory()) {
1844
1839
  results.push(`${prefix}${dir}`);
1845
1840
  if (maxDepth > 0)
@@ -1866,9 +1861,9 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1866
1861
  dirs.map(async (dir) => {
1867
1862
  if (AVOID_DIRS.includes(dir))
1868
1863
  return;
1869
- const dirPath = import_path4.default.join(dirname3, dir);
1864
+ const dirPath = import_path3.default.join(dirname3, dir);
1870
1865
  if (import_fs4.default.lstatSync(dirPath).isDirectory()) {
1871
- const hasTargetFile = import_fs4.default.existsSync(import_path4.default.join(dirPath, targetFilename));
1866
+ const hasTargetFile = import_fs4.default.existsSync(import_path3.default.join(dirPath, targetFilename));
1872
1867
  if (hasTargetFile)
1873
1868
  results.push(`${prefix}${dir}`);
1874
1869
  if (maxDepth > 0)
@@ -1929,8 +1924,8 @@ var SysExecutor = class extends Executor {
1929
1924
  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 });
1930
1925
  }
1931
1926
  async getModules() {
1932
- const path10 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
1933
- return await this.workspace.getDirInModule(path10, this.name);
1927
+ const path9 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
1928
+ return await this.workspace.getDirInModule(path9, this.name);
1934
1929
  }
1935
1930
  async scan({
1936
1931
  tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
@@ -1942,19 +1937,19 @@ var SysExecutor = class extends Executor {
1942
1937
  const scanner = new TypeScriptDependencyScanner(this.cwdPath);
1943
1938
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
1944
1939
  const pkgPathSet = new Set(
1945
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
1940
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
1946
1941
  );
1947
1942
  const libPathSet = new Set(
1948
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("libs/"))).map((path10) => path10.replace("/*", ""))
1943
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("libs/"))).map((path9) => path9.replace("/*", ""))
1949
1944
  );
1950
1945
  const [npmDepSet, pkgPathDepSet, libPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet, libPathSet]);
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("/");
1946
+ const pkgDeps = [...pkgPathDepSet].map((path9) => {
1947
+ const pathSplitLength = path9.split("/").length;
1948
+ return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1954
1949
  });
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("/");
1950
+ const libDeps = [...libPathDepSet].map((path9) => {
1951
+ const pathSplitLength = path9.split("/").length;
1952
+ return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1958
1953
  }).filter((libName) => libName !== this.name);
1959
1954
  if (!import_fs4.default.existsSync(`${this.cwdPath}/lib/__scalar`))
1960
1955
  import_fs4.default.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
@@ -1966,7 +1961,7 @@ var SysExecutor = class extends Executor {
1966
1961
  const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
1967
1962
  await Promise.all(
1968
1963
  databaseDirs.map(async (name) => {
1969
- const filenames = await this.readdir(import_path4.default.join("lib", name));
1964
+ const filenames = await this.readdir(import_path3.default.join("lib", name));
1970
1965
  filenames.forEach((filename) => {
1971
1966
  if (filename.endsWith(".constant.ts"))
1972
1967
  files.constants.databases.push(name);
@@ -1988,7 +1983,7 @@ var SysExecutor = class extends Executor {
1988
1983
  await Promise.all(
1989
1984
  serviceDirs.map(async (dirname3) => {
1990
1985
  const name = dirname3.slice(1);
1991
- const filenames = await this.readdir(import_path4.default.join("lib", dirname3));
1986
+ const filenames = await this.readdir(import_path3.default.join("lib", dirname3));
1992
1987
  filenames.forEach((filename) => {
1993
1988
  if (filename.endsWith(".dictionary.ts"))
1994
1989
  files.dictionary.services.push(name);
@@ -2006,7 +2001,7 @@ var SysExecutor = class extends Executor {
2006
2001
  const scalarDirs = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_"));
2007
2002
  await Promise.all(
2008
2003
  scalarDirs.map(async (name) => {
2009
- const filenames = await this.readdir(import_path4.default.join("lib/__scalar", name));
2004
+ const filenames = await this.readdir(import_path3.default.join("lib/__scalar", name));
2010
2005
  filenames.forEach((filename) => {
2011
2006
  if (filename.endsWith(".constant.ts"))
2012
2007
  files.constants.scalars.push(name);
@@ -2081,7 +2076,7 @@ var SysExecutor = class extends Executor {
2081
2076
  return scanResult;
2082
2077
  }
2083
2078
  getLocalFile(targetPath) {
2084
- const filePath = import_path4.default.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
2079
+ const filePath = import_path3.default.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
2085
2080
  const content = this.workspace.readFile(filePath);
2086
2081
  return { filePath, content };
2087
2082
  }
@@ -2256,12 +2251,12 @@ var PkgExecutor = class _PkgExecutor extends Executor {
2256
2251
  const scanner = new TypeScriptDependencyScanner(this.cwdPath);
2257
2252
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
2258
2253
  const pkgPathSet = new Set(
2259
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
2254
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
2260
2255
  );
2261
2256
  const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
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("/");
2257
+ const pkgDeps = [...pkgPathDepSet].map((path9) => {
2258
+ const pathSplitLength = path9.split("/").length;
2259
+ return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
2265
2260
  }).filter((pkg) => pkg !== this.name);
2266
2261
  const pkgScanResult = {
2267
2262
  name: this.name,
@@ -2572,7 +2567,7 @@ var extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =>
2572
2567
  ...pacakgeJson.devDependencies ?? {}
2573
2568
  };
2574
2569
  const requireRegex = /require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
2575
- for (const { text } of filepaths.filter(({ path: path10 }) => path10.endsWith(".js"))) {
2570
+ for (const { text } of filepaths.filter(({ path: path9 }) => path9.endsWith(".js"))) {
2576
2571
  let requireMatch;
2577
2572
  while ((requireMatch = requireRegex.exec(text)) !== null) {
2578
2573
  const moduleName = requireMatch[1];
@@ -2677,7 +2672,7 @@ var import_prompts3 = require("@inquirer/prompts");
2677
2672
  var import_chalk4 = __toESM(require("chalk"));
2678
2673
  var import_commander = require("commander");
2679
2674
  var import_fs7 = __toESM(require("fs"));
2680
- var import_meta3 = {};
2675
+ var import_meta2 = {};
2681
2676
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
2682
2677
  var handleOption = (programCommand, argMeta) => {
2683
2678
  const {
@@ -2853,7 +2848,7 @@ var runCommands = async (...commands) => {
2853
2848
  process.on("unhandledRejection", (error) => {
2854
2849
  process.exit(1);
2855
2850
  });
2856
- const __dirname = getDirname(import_meta3.url);
2851
+ const __dirname = getDirname(import_meta2.url);
2857
2852
  const hasPackageJson = import_fs7.default.existsSync(`${__dirname}/../package.json`);
2858
2853
  const version = hasPackageJson ? JSON.parse(import_fs7.default.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
2859
2854
  import_commander.program.version(version).description("Akan CLI");
@@ -3282,21 +3277,21 @@ var Builder = class {
3282
3277
  // pkgs/@akanjs/devkit/src/prompter.ts
3283
3278
  var import_prompts5 = require("@inquirer/prompts");
3284
3279
  var import_promises2 = __toESM(require("fs/promises"));
3285
- var import_meta4 = {};
3280
+ var import_meta3 = {};
3286
3281
  var Prompter = class {
3287
3282
  static async selectGuideline() {
3288
- const guideNames = (await import_promises2.default.readdir(`${getDirname(import_meta4.url)}/src/guidelines`)).filter(
3283
+ const guideNames = (await import_promises2.default.readdir(`${getDirname(import_meta3.url)}/src/guidelines`)).filter(
3289
3284
  (name) => !name.startsWith("_")
3290
3285
  );
3291
3286
  return await (0, import_prompts5.select)({ message: "Select a guideline", choices: guideNames.map((name) => ({ name, value: name })) });
3292
3287
  }
3293
3288
  static async getGuideJson(guideName) {
3294
- const filePath = `${getDirname(import_meta4.url)}/src/guidelines/${guideName}/${guideName}.generate.json`;
3289
+ const filePath = `${getDirname(import_meta3.url)}/src/guidelines/${guideName}/${guideName}.generate.json`;
3295
3290
  const guideJson = await import_promises2.default.readFile(filePath, "utf-8");
3296
3291
  return JSON.parse(guideJson);
3297
3292
  }
3298
3293
  static async getInstruction(guideName) {
3299
- const filePath = `${getDirname(import_meta4.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
3294
+ const filePath = `${getDirname(import_meta3.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
3300
3295
  const content = await import_promises2.default.readFile(filePath, "utf-8");
3301
3296
  return content;
3302
3297
  }
@@ -3320,7 +3315,7 @@ ${request}
3320
3315
  `;
3321
3316
  }
3322
3317
  async getDocumentation(guideName) {
3323
- const filePath = `${getDirname(import_meta4.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
3318
+ const filePath = `${getDirname(import_meta3.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
3324
3319
  const document = await import_promises2.default.readFile(filePath, "utf-8");
3325
3320
  return `\`\`\`markdown
3326
3321
  ${document}
@@ -3495,7 +3490,7 @@ var import_promises3 = __toESM(require("fs/promises"), 1);
3495
3490
  var import_js_yaml2 = __toESM(require("js-yaml"), 1);
3496
3491
  var import_open = __toESM(require("open"), 1);
3497
3492
  var import_ora3 = __toESM(require("ora"), 1);
3498
- var import_path5 = __toESM(require("path"), 1);
3493
+ var import_path4 = __toESM(require("path"), 1);
3499
3494
  var vite = __toESM(require("vite"), 1);
3500
3495
  var import_vite_plugin_commonjs = __toESM(require("vite-plugin-commonjs"), 1);
3501
3496
  var import_vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
@@ -3962,7 +3957,7 @@ var ApplicationRunner = class {
3962
3957
  dependencies
3963
3958
  };
3964
3959
  app.dist.writeJson("backend/package.json", appPackageJson);
3965
- app.dist.writeFile(import_path5.default.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.dockerfile);
3960
+ app.dist.writeFile(import_path4.default.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.dockerfile);
3966
3961
  }
3967
3962
  async startBackend(app, { open: open2 = false, onStart } = {}) {
3968
3963
  const { env } = await this.#prepareCommand(app, "start", "backend");
@@ -3973,7 +3968,7 @@ var ApplicationRunner = class {
3973
3968
  packages: "external",
3974
3969
  platform: "node",
3975
3970
  format: "cjs",
3976
- outdir: import_path5.default.join(app.dist.cwdPath, "backend"),
3971
+ outdir: import_path4.default.join(app.dist.cwdPath, "backend"),
3977
3972
  logLevel: "warning"
3978
3973
  });
3979
3974
  await ctx.watch();
@@ -4011,8 +4006,8 @@ var ApplicationRunner = class {
4011
4006
  };
4012
4007
  app.dist.writeJson("frontend/package.json", appPackageJson);
4013
4008
  await Promise.all([
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"))
4009
+ app.cp(".next", import_path4.default.join(app.dist.cwdPath, "frontend", ".next")),
4010
+ app.cp("public", import_path4.default.join(app.dist.cwdPath, "frontend", "public"))
4016
4011
  ]);
4017
4012
  app.dist.writeFile("frontend/Dockerfile", akanConfig.frontend.dockerfile);
4018
4013
  }
@@ -4274,8 +4269,8 @@ var ApplicationRunner = class {
4274
4269
  )
4275
4270
  );
4276
4271
  await Promise.all(
4277
- [".next", "ios", "android", "public/libs"].map(async (path10) => {
4278
- const targetPath = `${sourceRoot}/apps/${app.name}/${path10}`;
4272
+ [".next", "ios", "android", "public/libs"].map(async (path9) => {
4273
+ const targetPath = `${sourceRoot}/apps/${app.name}/${path9}`;
4279
4274
  if (import_fs10.default.existsSync(targetPath))
4280
4275
  await import_promises3.default.rm(targetPath, { recursive: true, force: true });
4281
4276
  })
@@ -4293,7 +4288,7 @@ var ApplicationRunner = class {
4293
4288
  ];
4294
4289
  await Promise.all(
4295
4290
  syncPaths.map(
4296
- (path10) => import_promises3.default.cp(`${app.workspace.cwdPath}/${path10}`, `${sourceRoot}/${path10}`, { recursive: true })
4291
+ (path9) => import_promises3.default.cp(`${app.workspace.cwdPath}/${path9}`, `${sourceRoot}/${path9}`, { recursive: true })
4297
4292
  )
4298
4293
  );
4299
4294
  const tsconfig = app.workspace.readJson("tsconfig.json");
@@ -5793,12 +5788,12 @@ PageCommand = __decorateClass([
5793
5788
 
5794
5789
  // pkgs/@akanjs/cli/src/workspace/workspace.runner.ts
5795
5790
  var import_latest_version2 = __toESM(require("latest-version"), 1);
5796
- var import_path6 = __toESM(require("path"), 1);
5791
+ var import_path5 = __toESM(require("path"), 1);
5797
5792
  var import_uuid2 = require("uuid");
5798
5793
  var WorkspaceRunner = class {
5799
5794
  async createWorkspace(repoName, appName, dirname3 = ".") {
5800
5795
  const cwdPath = process.cwd();
5801
- const workspaceRoot = import_path6.default.join(cwdPath, dirname3, repoName);
5796
+ const workspaceRoot = import_path5.default.join(cwdPath, dirname3, repoName);
5802
5797
  const workspace = new WorkspaceExecutor({ workspaceRoot, repoName });
5803
5798
  const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname3}/${repoName}...`);
5804
5799
  await workspace.applyTemplate({
@@ -5987,7 +5982,7 @@ WorkspaceCommand = __decorateClass([
5987
5982
  // pkgs/@akanjs/cli/src/guideline/guideline.prompt.ts
5988
5983
  var import_fs12 = __toESM(require("fs"), 1);
5989
5984
  var import_promises5 = __toESM(require("fs/promises"), 1);
5990
- var import_meta5 = {};
5985
+ var import_meta4 = {};
5991
5986
  var GuidelinePrompt = class extends Prompter {
5992
5987
  constructor(workspace, name) {
5993
5988
  super();
@@ -5997,15 +5992,15 @@ var GuidelinePrompt = class extends Prompter {
5997
5992
  async #getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
5998
5993
  const matchingPaths = import_promises5.default.glob(matchPattern, {
5999
5994
  cwd: this.workspace.workspaceRoot,
6000
- exclude: (path10) => avoidDirs.some((dir) => path10.includes(dir))
5995
+ exclude: (path9) => avoidDirs.some((dir) => path9.includes(dir))
6001
5996
  });
6002
5997
  const paths = [];
6003
- for await (const path10 of matchingPaths) {
6004
- const fileContent = import_fs12.default.readFileSync(path10, "utf-8");
5998
+ for await (const path9 of matchingPaths) {
5999
+ const fileContent = import_fs12.default.readFileSync(path9, "utf-8");
6005
6000
  const textFilter = filterText ? new RegExp(filterText) : null;
6006
6001
  if (filterText && !textFilter?.test(fileContent))
6007
6002
  continue;
6008
- paths.push(path10);
6003
+ paths.push(path9);
6009
6004
  }
6010
6005
  return paths;
6011
6006
  }
@@ -6018,7 +6013,7 @@ var GuidelinePrompt = class extends Prompter {
6018
6013
  const scanResult = targetFilePaths.map((filePath) => ({ ...scan, ...this.workspace.getLocalFile(filePath) }));
6019
6014
  scanFiles.push(...scanResult);
6020
6015
  }
6021
- const resultPath = `${getDirname(import_meta5.url)}/src/guidelines/${this.name}/${guideJson.update.filePath}`;
6016
+ const resultPath = `${getDirname(import_meta4.url)}/src/guidelines/${this.name}/${guideJson.update.filePath}`;
6022
6017
  const writePath = `${this.workspace.workspaceRoot}/pkgs/@akanjs/cli/src/guidelines/${this.name}/${guideJson.update.filePath}`;
6023
6018
  const isResultExists = this.workspace.exists(writePath);
6024
6019
  const existingResult = isResultExists ? this.workspace.readFile(resultPath) : null;
@@ -6060,7 +6055,7 @@ ${guideJson.update.rules.map((rule) => `- ${rule}`).join("\n")}
6060
6055
  }
6061
6056
  async requestUpdateInstruction(updateRequest) {
6062
6057
  const guideJson = await Prompter.getGuideJson(this.name);
6063
- const resultPath = `${getDirname(import_meta5.url)}/src/guidelines/${this.name}/${guideJson.update.filePath}`;
6058
+ const resultPath = `${getDirname(import_meta4.url)}/src/guidelines/${this.name}/${guideJson.update.filePath}`;
6064
6059
  const writePath = `${this.workspace.workspaceRoot}/pkgs/@akanjs/cli/src/guidelines/${this.name}/${guideJson.update.filePath}`;
6065
6060
  const isResultExists = this.workspace.exists(writePath);
6066
6061
  if (!isResultExists)
package/esm/index.js CHANGED
@@ -380,8 +380,8 @@ import * as fs3 from "fs";
380
380
  import ora2 from "ora";
381
381
  import * as ts from "typescript";
382
382
  var parseTsConfig = (tsConfigPath = "./tsconfig.json") => {
383
- const configFile = ts.readConfigFile(tsConfigPath, (path10) => {
384
- return ts.sys.readFile(path10);
383
+ const configFile = ts.readConfigFile(tsConfigPath, (path9) => {
384
+ return ts.sys.readFile(path9);
385
385
  });
386
386
  return ts.parseJsonConfigFileContent(
387
387
  configFile.config,
@@ -544,13 +544,12 @@ import { ChatOpenAI } from "@langchain/openai";
544
544
 
545
545
  // pkgs/@akanjs/config/src/akanConfig.ts
546
546
  import fs4 from "fs";
547
- import path2 from "path";
547
+ import path from "path";
548
548
 
549
549
  // pkgs/@akanjs/config/src/nextConfig.ts
550
550
  import withAnalyze from "@next/bundle-analyzer";
551
551
  import pwa from "next-pwa";
552
552
  import runtimeCaching from "next-pwa/cache.js";
553
- import path from "path";
554
553
  var composePlugins = (...plugins) => {
555
554
  return function(baseConfig) {
556
555
  return async function combined(phase, context2) {
@@ -570,7 +569,6 @@ var composePlugins = (...plugins) => {
570
569
  var commandType = process.env.AKAN_COMMAND_TYPE?.includes("start") ? "start" : process.env.AKAN_COMMAND_TYPE?.includes("build") ? "build" : "deploy";
571
570
  var devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
572
571
  var withBase = (appName, config, libs, routes = []) => {
573
- const __dirname = path.dirname(new URL(import.meta.url).pathname);
574
572
  const withPWA = pwa({
575
573
  dest: "public",
576
574
  register: true,
@@ -641,15 +639,13 @@ var withBase = (appName, config, libs, routes = []) => {
641
639
  webpack: (config2) => {
642
640
  config2.resolve.alias.canvas = false;
643
641
  config2.resolve.alias.encoding = false;
644
- if (process.env.USE_AKANJS_PKGS === "true")
645
- config2.resolve.alias["@akanjs/config"] = path.resolve(__dirname, "../../../../pkgs/@akanjs/config");
646
642
  return config2;
647
643
  },
648
644
  turbopack: {
649
645
  resolveAlias: {
650
646
  // canvas: false,
651
647
  // encoding: false,
652
- ...process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config": path.resolve(__dirname, "../../../../pkgs/@akanjs/config") } : {},
648
+ // ...(process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config": "../../pkgs/@akanjs/config" } : {}),
653
649
  ...config.turbopack?.resolveAlias ?? {}
654
650
  }
655
651
  },
@@ -763,7 +759,7 @@ CMD ["npm", "start"]`,
763
759
  };
764
760
  };
765
761
  var getAppConfig = async (appRoot, props) => {
766
- const akanConfigPath = path2.join(appRoot, "akan.config.ts");
762
+ const akanConfigPath = path.join(appRoot, "akan.config.ts");
767
763
  if (!fs4.existsSync(akanConfigPath))
768
764
  throw new Error(`application akan.config.ts is not found ${appRoot}`);
769
765
  const configImp = (await import(`${appRoot}/akan.config.ts`)).default;
@@ -783,7 +779,7 @@ var makeLibConfig = (config, props) => {
783
779
  };
784
780
  };
785
781
  var getLibConfig = async (libRoot, props) => {
786
- const akanConfigPath = path2.join(libRoot, "akan.config.ts");
782
+ const akanConfigPath = path.join(libRoot, "akan.config.ts");
787
783
  if (!fs4.existsSync(akanConfigPath))
788
784
  throw new Error(`library akan.config.ts is not found ${libRoot}`);
789
785
  const configImp = (await import(`${libRoot}/akan.config.ts`)).default;
@@ -834,11 +830,11 @@ import { exec, fork, spawn } from "child_process";
834
830
  import dotenv from "dotenv";
835
831
  import fs8 from "fs";
836
832
  import fsPromise from "fs/promises";
837
- import path7 from "path";
833
+ import path6 from "path";
838
834
 
839
835
  // pkgs/@akanjs/devkit/src/dependencyScanner.ts
840
836
  import * as fs5 from "fs";
841
- import * as path3 from "path";
837
+ import * as path2 from "path";
842
838
  import * as ts2 from "typescript";
843
839
  var TypeScriptDependencyScanner = class {
844
840
  constructor(directory) {
@@ -884,7 +880,7 @@ var TypeScriptDependencyScanner = class {
884
880
  const processDirectory = async (dir) => {
885
881
  const entries = await fs5.promises.readdir(dir, { withFileTypes: true });
886
882
  for (const entry of entries) {
887
- const fullPath = path3.join(dir, entry.name);
883
+ const fullPath = path2.join(dir, entry.name);
888
884
  if (entry.isDirectory()) {
889
885
  if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
890
886
  await processDirectory(fullPath);
@@ -904,12 +900,12 @@ var TypeScriptDependencyScanner = class {
904
900
  const imports = this.#extractImports(fileContent, filePath);
905
901
  const resolvedImports = imports.map((importPath) => {
906
902
  if (importPath.startsWith(".")) {
907
- const resolvedPath = "./" + path3.join(path3.relative(baseDir, filePath), importPath);
903
+ const resolvedPath = "./" + path2.join(path2.relative(baseDir, filePath), importPath);
908
904
  return this.#ensureExtension(resolvedPath);
909
905
  }
910
906
  return importPath;
911
907
  });
912
- const relativePath = path3.relative(baseDir, filePath);
908
+ const relativePath = path2.relative(baseDir, filePath);
913
909
  this.#fileDependencies.set(relativePath, resolvedImports);
914
910
  } catch (error) {
915
911
  }
@@ -984,14 +980,14 @@ var TypeScriptDependencyScanner = class {
984
980
  };
985
981
 
986
982
  // pkgs/@akanjs/devkit/src/getDirname.ts
987
- import path4 from "path";
988
- var getDirname = (url) => path4.dirname(new URL(url).pathname);
983
+ import path3 from "path";
984
+ var getDirname = (url) => path3.dirname(new URL(url).pathname);
989
985
 
990
986
  // pkgs/@akanjs/devkit/src/linter.ts
991
987
  import chalk from "chalk";
992
988
  import { ESLint } from "eslint";
993
989
  import * as fs6 from "fs";
994
- import * as path5 from "path";
990
+ import * as path4 from "path";
995
991
  var Linter = class {
996
992
  #logger = new Logger("Linter");
997
993
  #eslint;
@@ -1001,10 +997,10 @@ var Linter = class {
1001
997
  this.#eslint = new ESLint({ cwd: this.lintRoot, errorOnUnmatchedPattern: false });
1002
998
  }
1003
999
  #findEslintRootPath(dir) {
1004
- const configPath2 = path5.join(dir, "eslint.config.ts");
1000
+ const configPath2 = path4.join(dir, "eslint.config.ts");
1005
1001
  if (fs6.existsSync(configPath2))
1006
1002
  return dir;
1007
- const parentDir = path5.dirname(dir);
1003
+ const parentDir = path4.dirname(dir);
1008
1004
  return this.#findEslintRootPath(parentDir);
1009
1005
  }
1010
1006
  async lint(filePath, { fix = false, dryRun = false } = {}) {
@@ -1193,7 +1189,7 @@ ${errorText}, ${warningText} found`];
1193
1189
  // pkgs/@akanjs/devkit/src/typeChecker.ts
1194
1190
  import chalk2 from "chalk";
1195
1191
  import * as fs7 from "fs";
1196
- import * as path6 from "path";
1192
+ import * as path5 from "path";
1197
1193
  import * as ts3 from "typescript";
1198
1194
  var TypeChecker = class {
1199
1195
  configPath;
@@ -1208,7 +1204,7 @@ var TypeChecker = class {
1208
1204
  const parsedConfig = ts3.parseJsonConfigFileContent(
1209
1205
  this.configFile.config,
1210
1206
  ts3.sys,
1211
- path6.dirname(this.configPath),
1207
+ path5.dirname(this.configPath),
1212
1208
  void 0,
1213
1209
  this.configPath
1214
1210
  );
@@ -1474,7 +1470,7 @@ var Executor = class _Executor {
1474
1470
  });
1475
1471
  }
1476
1472
  getPath(filePath) {
1477
- if (path7.isAbsolute(filePath))
1473
+ if (path6.isAbsolute(filePath))
1478
1474
  return filePath;
1479
1475
  const baseParts = this.cwdPath.split("/").filter(Boolean);
1480
1476
  const targetParts = filePath.split("/").filter(Boolean);
@@ -1527,7 +1523,7 @@ var Executor = class _Executor {
1527
1523
  }
1528
1524
  writeFile(filePath, content, { overwrite = true } = {}) {
1529
1525
  const writePath = this.getPath(filePath);
1530
- const dir = path7.dirname(writePath);
1526
+ const dir = path6.dirname(writePath);
1531
1527
  if (!fs8.existsSync(dir))
1532
1528
  fs8.mkdirSync(dir, { recursive: true });
1533
1529
  let contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
@@ -1551,7 +1547,7 @@ var Executor = class _Executor {
1551
1547
  return this;
1552
1548
  }
1553
1549
  getLocalFile(targetPath) {
1554
- const filePath = path7.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
1550
+ const filePath = path6.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
1555
1551
  const content = this.readFile(filePath);
1556
1552
  return { filePath, content };
1557
1553
  }
@@ -1602,11 +1598,11 @@ var Executor = class _Executor {
1602
1598
  const result = getContent.default(scanResult ?? null, dict);
1603
1599
  if (result === null)
1604
1600
  return null;
1605
- const filename = typeof result === "object" ? result.filename : path7.basename(targetPath).replace(".js", ".ts");
1601
+ const filename = typeof result === "object" ? result.filename : path6.basename(targetPath).replace(".js", ".ts");
1606
1602
  const content = typeof result === "object" ? result.content : result;
1607
- const dirname3 = path7.dirname(targetPath);
1603
+ const dirname3 = path6.dirname(targetPath);
1608
1604
  const convertedTargetPath = Object.entries(dict).reduce(
1609
- (path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
1605
+ (path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
1610
1606
  `${dirname3}/${filename}`
1611
1607
  );
1612
1608
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
@@ -1614,7 +1610,7 @@ var Executor = class _Executor {
1614
1610
  } else if (targetPath.endsWith(".template")) {
1615
1611
  const content = await fsPromise.readFile(templatePath, "utf8");
1616
1612
  const convertedTargetPath = Object.entries(dict).reduce(
1617
- (path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
1613
+ (path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
1618
1614
  targetPath.slice(0, -9)
1619
1615
  );
1620
1616
  const convertedContent = Object.entries(dict).reduce(
@@ -1636,9 +1632,9 @@ var Executor = class _Executor {
1636
1632
  const templatePath = `${getDirname(import.meta.url)}/src/templates${template ? `/${template}` : ""}`;
1637
1633
  const prefixTemplatePath = templatePath.endsWith(".tsx") ? templatePath : templatePath.replace(".ts", ".js");
1638
1634
  if (fs8.statSync(prefixTemplatePath).isFile()) {
1639
- const filename = path7.basename(prefixTemplatePath);
1635
+ const filename = path6.basename(prefixTemplatePath);
1640
1636
  const fileContent = await this.#applyTemplateFile(
1641
- { templatePath: prefixTemplatePath, targetPath: path7.join(basePath2, filename), scanResult, overwrite },
1637
+ { templatePath: prefixTemplatePath, targetPath: path6.join(basePath2, filename), scanResult, overwrite },
1642
1638
  dict
1643
1639
  );
1644
1640
  return fileContent ? [fileContent] : [];
@@ -1646,17 +1642,17 @@ var Executor = class _Executor {
1646
1642
  const subdirs = await this.readdir(templatePath);
1647
1643
  const fileContents = (await Promise.all(
1648
1644
  subdirs.map(async (subdir) => {
1649
- const subpath = path7.join(templatePath, subdir);
1645
+ const subpath = path6.join(templatePath, subdir);
1650
1646
  if (fs8.statSync(subpath).isFile()) {
1651
1647
  const fileContent = await this.#applyTemplateFile(
1652
- { templatePath: subpath, targetPath: path7.join(basePath2, subdir), scanResult, overwrite },
1648
+ { templatePath: subpath, targetPath: path6.join(basePath2, subdir), scanResult, overwrite },
1653
1649
  dict
1654
1650
  );
1655
1651
  return fileContent ? [fileContent] : [];
1656
1652
  } else
1657
1653
  return await this._applyTemplate({
1658
- basePath: path7.join(basePath2, subdir),
1659
- template: path7.join(template, subdir),
1654
+ basePath: path6.join(basePath2, subdir),
1655
+ template: path6.join(template, subdir),
1660
1656
  scanResult,
1661
1657
  dict,
1662
1658
  overwrite
@@ -1680,9 +1676,9 @@ var Executor = class _Executor {
1680
1676
  return this.typeChecker;
1681
1677
  }
1682
1678
  typeCheck(filePath) {
1683
- const path10 = this.getPath(filePath);
1679
+ const path9 = this.getPath(filePath);
1684
1680
  const typeChecker = this.getTypeChecker();
1685
- const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path10);
1681
+ const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path9);
1686
1682
  const message = typeChecker.formatDiagnostics(fileDiagnostics);
1687
1683
  return { fileDiagnostics, fileErrors, fileWarnings, message };
1688
1684
  }
@@ -1691,9 +1687,9 @@ var Executor = class _Executor {
1691
1687
  return this.linter;
1692
1688
  }
1693
1689
  async lint(filePath, { fix = false, dryRun = false } = {}) {
1694
- const path10 = this.getPath(filePath);
1690
+ const path9 = this.getPath(filePath);
1695
1691
  const linter = this.getLinter();
1696
- const { results, errors, warnings } = await linter.lint(path10, { fix, dryRun });
1692
+ const { results, errors, warnings } = await linter.lint(path9, { fix, dryRun });
1697
1693
  const message = linter.formatLintResults(results);
1698
1694
  return { results, message, errors, warnings };
1699
1695
  }
@@ -1708,7 +1704,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1708
1704
  this.repoName = repoName;
1709
1705
  }
1710
1706
  static fromRoot() {
1711
- const repoName = path7.basename(process.cwd());
1707
+ const repoName = path6.basename(process.cwd());
1712
1708
  return new _WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
1713
1709
  }
1714
1710
  getBaseDevEnv() {
@@ -1817,7 +1813,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1817
1813
  dirs.map(async (dir) => {
1818
1814
  if (dir.includes("_") || AVOID_DIRS.includes(dir))
1819
1815
  return;
1820
- const dirPath = path7.join(dirname3, dir);
1816
+ const dirPath = path6.join(dirname3, dir);
1821
1817
  if (fs8.lstatSync(dirPath).isDirectory()) {
1822
1818
  results.push(`${prefix}${dir}`);
1823
1819
  if (maxDepth > 0)
@@ -1844,9 +1840,9 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1844
1840
  dirs.map(async (dir) => {
1845
1841
  if (AVOID_DIRS.includes(dir))
1846
1842
  return;
1847
- const dirPath = path7.join(dirname3, dir);
1843
+ const dirPath = path6.join(dirname3, dir);
1848
1844
  if (fs8.lstatSync(dirPath).isDirectory()) {
1849
- const hasTargetFile = fs8.existsSync(path7.join(dirPath, targetFilename));
1845
+ const hasTargetFile = fs8.existsSync(path6.join(dirPath, targetFilename));
1850
1846
  if (hasTargetFile)
1851
1847
  results.push(`${prefix}${dir}`);
1852
1848
  if (maxDepth > 0)
@@ -1907,8 +1903,8 @@ var SysExecutor = class extends Executor {
1907
1903
  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 });
1908
1904
  }
1909
1905
  async getModules() {
1910
- const path10 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
1911
- return await this.workspace.getDirInModule(path10, this.name);
1906
+ const path9 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
1907
+ return await this.workspace.getDirInModule(path9, this.name);
1912
1908
  }
1913
1909
  async scan({
1914
1910
  tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
@@ -1920,19 +1916,19 @@ var SysExecutor = class extends Executor {
1920
1916
  const scanner = new TypeScriptDependencyScanner(this.cwdPath);
1921
1917
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
1922
1918
  const pkgPathSet = new Set(
1923
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
1919
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
1924
1920
  );
1925
1921
  const libPathSet = new Set(
1926
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("libs/"))).map((path10) => path10.replace("/*", ""))
1922
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("libs/"))).map((path9) => path9.replace("/*", ""))
1927
1923
  );
1928
1924
  const [npmDepSet, pkgPathDepSet, libPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet, libPathSet]);
1929
- const pkgDeps = [...pkgPathDepSet].map((path10) => {
1930
- const pathSplitLength = path10.split("/").length;
1931
- return (tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1925
+ const pkgDeps = [...pkgPathDepSet].map((path9) => {
1926
+ const pathSplitLength = path9.split("/").length;
1927
+ return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1932
1928
  });
1933
- const libDeps = [...libPathDepSet].map((path10) => {
1934
- const pathSplitLength = path10.split("/").length;
1935
- return (tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1929
+ const libDeps = [...libPathDepSet].map((path9) => {
1930
+ const pathSplitLength = path9.split("/").length;
1931
+ return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
1936
1932
  }).filter((libName) => libName !== this.name);
1937
1933
  if (!fs8.existsSync(`${this.cwdPath}/lib/__scalar`))
1938
1934
  fs8.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
@@ -1944,7 +1940,7 @@ var SysExecutor = class extends Executor {
1944
1940
  const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
1945
1941
  await Promise.all(
1946
1942
  databaseDirs.map(async (name) => {
1947
- const filenames = await this.readdir(path7.join("lib", name));
1943
+ const filenames = await this.readdir(path6.join("lib", name));
1948
1944
  filenames.forEach((filename) => {
1949
1945
  if (filename.endsWith(".constant.ts"))
1950
1946
  files.constants.databases.push(name);
@@ -1966,7 +1962,7 @@ var SysExecutor = class extends Executor {
1966
1962
  await Promise.all(
1967
1963
  serviceDirs.map(async (dirname3) => {
1968
1964
  const name = dirname3.slice(1);
1969
- const filenames = await this.readdir(path7.join("lib", dirname3));
1965
+ const filenames = await this.readdir(path6.join("lib", dirname3));
1970
1966
  filenames.forEach((filename) => {
1971
1967
  if (filename.endsWith(".dictionary.ts"))
1972
1968
  files.dictionary.services.push(name);
@@ -1984,7 +1980,7 @@ var SysExecutor = class extends Executor {
1984
1980
  const scalarDirs = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_"));
1985
1981
  await Promise.all(
1986
1982
  scalarDirs.map(async (name) => {
1987
- const filenames = await this.readdir(path7.join("lib/__scalar", name));
1983
+ const filenames = await this.readdir(path6.join("lib/__scalar", name));
1988
1984
  filenames.forEach((filename) => {
1989
1985
  if (filename.endsWith(".constant.ts"))
1990
1986
  files.constants.scalars.push(name);
@@ -2059,7 +2055,7 @@ var SysExecutor = class extends Executor {
2059
2055
  return scanResult;
2060
2056
  }
2061
2057
  getLocalFile(targetPath) {
2062
- const filePath = path7.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
2058
+ const filePath = path6.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
2063
2059
  const content = this.workspace.readFile(filePath);
2064
2060
  return { filePath, content };
2065
2061
  }
@@ -2234,12 +2230,12 @@ var PkgExecutor = class _PkgExecutor extends Executor {
2234
2230
  const scanner = new TypeScriptDependencyScanner(this.cwdPath);
2235
2231
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
2236
2232
  const pkgPathSet = new Set(
2237
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
2233
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
2238
2234
  );
2239
2235
  const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
2240
- const pkgDeps = [...pkgPathDepSet].map((path10) => {
2241
- const pathSplitLength = path10.split("/").length;
2242
- return (tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
2236
+ const pkgDeps = [...pkgPathDepSet].map((path9) => {
2237
+ const pathSplitLength = path9.split("/").length;
2238
+ return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
2243
2239
  }).filter((pkg) => pkg !== this.name);
2244
2240
  const pkgScanResult = {
2245
2241
  name: this.name,
@@ -2550,7 +2546,7 @@ var extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =>
2550
2546
  ...pacakgeJson.devDependencies ?? {}
2551
2547
  };
2552
2548
  const requireRegex = /require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
2553
- for (const { text } of filepaths.filter(({ path: path10 }) => path10.endsWith(".js"))) {
2549
+ for (const { text } of filepaths.filter(({ path: path9 }) => path9.endsWith(".js"))) {
2554
2550
  let requireMatch;
2555
2551
  while ((requireMatch = requireRegex.exec(text)) !== null) {
2556
2552
  const moduleName = requireMatch[1];
@@ -3476,7 +3472,7 @@ import fsPromise3 from "fs/promises";
3476
3472
  import yaml2 from "js-yaml";
3477
3473
  import openBrowser from "open";
3478
3474
  import ora3 from "ora";
3479
- import path8 from "path";
3475
+ import path7 from "path";
3480
3476
  import * as vite from "vite";
3481
3477
  import commonjs from "vite-plugin-commonjs";
3482
3478
  import { nodePolyfills } from "vite-plugin-node-polyfills";
@@ -3943,7 +3939,7 @@ var ApplicationRunner = class {
3943
3939
  dependencies
3944
3940
  };
3945
3941
  app.dist.writeJson("backend/package.json", appPackageJson);
3946
- app.dist.writeFile(path8.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.dockerfile);
3942
+ app.dist.writeFile(path7.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.dockerfile);
3947
3943
  }
3948
3944
  async startBackend(app, { open: open2 = false, onStart } = {}) {
3949
3945
  const { env } = await this.#prepareCommand(app, "start", "backend");
@@ -3954,7 +3950,7 @@ var ApplicationRunner = class {
3954
3950
  packages: "external",
3955
3951
  platform: "node",
3956
3952
  format: "cjs",
3957
- outdir: path8.join(app.dist.cwdPath, "backend"),
3953
+ outdir: path7.join(app.dist.cwdPath, "backend"),
3958
3954
  logLevel: "warning"
3959
3955
  });
3960
3956
  await ctx.watch();
@@ -3992,8 +3988,8 @@ var ApplicationRunner = class {
3992
3988
  };
3993
3989
  app.dist.writeJson("frontend/package.json", appPackageJson);
3994
3990
  await Promise.all([
3995
- app.cp(".next", path8.join(app.dist.cwdPath, "frontend", ".next")),
3996
- app.cp("public", path8.join(app.dist.cwdPath, "frontend", "public"))
3991
+ app.cp(".next", path7.join(app.dist.cwdPath, "frontend", ".next")),
3992
+ app.cp("public", path7.join(app.dist.cwdPath, "frontend", "public"))
3997
3993
  ]);
3998
3994
  app.dist.writeFile("frontend/Dockerfile", akanConfig.frontend.dockerfile);
3999
3995
  }
@@ -4255,8 +4251,8 @@ var ApplicationRunner = class {
4255
4251
  )
4256
4252
  );
4257
4253
  await Promise.all(
4258
- [".next", "ios", "android", "public/libs"].map(async (path10) => {
4259
- const targetPath = `${sourceRoot}/apps/${app.name}/${path10}`;
4254
+ [".next", "ios", "android", "public/libs"].map(async (path9) => {
4255
+ const targetPath = `${sourceRoot}/apps/${app.name}/${path9}`;
4260
4256
  if (fs14.existsSync(targetPath))
4261
4257
  await fsPromise3.rm(targetPath, { recursive: true, force: true });
4262
4258
  })
@@ -4274,7 +4270,7 @@ var ApplicationRunner = class {
4274
4270
  ];
4275
4271
  await Promise.all(
4276
4272
  syncPaths.map(
4277
- (path10) => fsPromise3.cp(`${app.workspace.cwdPath}/${path10}`, `${sourceRoot}/${path10}`, { recursive: true })
4273
+ (path9) => fsPromise3.cp(`${app.workspace.cwdPath}/${path9}`, `${sourceRoot}/${path9}`, { recursive: true })
4278
4274
  )
4279
4275
  );
4280
4276
  const tsconfig = app.workspace.readJson("tsconfig.json");
@@ -5774,12 +5770,12 @@ PageCommand = __decorateClass([
5774
5770
 
5775
5771
  // pkgs/@akanjs/cli/src/workspace/workspace.runner.ts
5776
5772
  import latestVersion2 from "latest-version";
5777
- import path9 from "path";
5773
+ import path8 from "path";
5778
5774
  import { v5 as uuid } from "uuid";
5779
5775
  var WorkspaceRunner = class {
5780
5776
  async createWorkspace(repoName, appName, dirname3 = ".") {
5781
5777
  const cwdPath = process.cwd();
5782
- const workspaceRoot = path9.join(cwdPath, dirname3, repoName);
5778
+ const workspaceRoot = path8.join(cwdPath, dirname3, repoName);
5783
5779
  const workspace = new WorkspaceExecutor({ workspaceRoot, repoName });
5784
5780
  const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname3}/${repoName}...`);
5785
5781
  await workspace.applyTemplate({
@@ -5977,15 +5973,15 @@ var GuidelinePrompt = class extends Prompter {
5977
5973
  async #getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
5978
5974
  const matchingPaths = fsPromise5.glob(matchPattern, {
5979
5975
  cwd: this.workspace.workspaceRoot,
5980
- exclude: (path10) => avoidDirs.some((dir) => path10.includes(dir))
5976
+ exclude: (path9) => avoidDirs.some((dir) => path9.includes(dir))
5981
5977
  });
5982
5978
  const paths = [];
5983
- for await (const path10 of matchingPaths) {
5984
- const fileContent = fs16.readFileSync(path10, "utf-8");
5979
+ for await (const path9 of matchingPaths) {
5980
+ const fileContent = fs16.readFileSync(path9, "utf-8");
5985
5981
  const textFilter = filterText ? new RegExp(filterText) : null;
5986
5982
  if (filterText && !textFilter?.test(fileContent))
5987
5983
  continue;
5988
- paths.push(path10);
5984
+ paths.push(path9);
5989
5985
  }
5990
5986
  return paths;
5991
5987
  }
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "type": "module",
3
3
  "sourceType": "module",
4
4
  "name": "@akanjs/cli",
5
- "version": "0.9.11",
5
+ "version": "0.9.13",
6
6
  "bin": {
7
- "akan": "cjs/index.js"
7
+ "akan": "esm/index.js"
8
8
  },
9
9
  "publishConfig": {
10
10
  "access": "public"