@akanjs/cli 0.9.59 → 0.9.60-canary.1

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
@@ -593,7 +593,7 @@ var composePlugins = (...plugins) => {
593
593
  };
594
594
  var commandType = process.env.AKAN_COMMAND_TYPE?.includes("start") ? "start" : process.env.AKAN_COMMAND_TYPE?.includes("build") ? "build" : "deploy";
595
595
  var devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
596
- var withBase = (appName, config, libs, routes = []) => {
596
+ var withBase = (appName, config, optimizeLibs, routes = []) => {
597
597
  const withPWA = (0, import_next_pwa.default)({
598
598
  dest: "public",
599
599
  register: true,
@@ -617,8 +617,7 @@ var withBase = (appName, config, libs, routes = []) => {
617
617
  experimental: {
618
618
  ...config.experimental ?? {},
619
619
  optimizePackageImports: [
620
- ...[appName, ...libs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
621
- "@contract",
620
+ ...[appName, ...optimizeLibs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
622
621
  "@akanjs/next",
623
622
  "@akanjs/common",
624
623
  "@akanjs/ui"
@@ -639,7 +638,7 @@ var withBase = (appName, config, libs, routes = []) => {
639
638
  },
640
639
  webpack: (config2) => {
641
640
  const watchOptions = config2.watchOptions;
642
- const ignored = watchOptions?.ignored ? typeof watchOptions.ignored === "string" ? [watchOptions.ignored] : Array.isArray(watchOptions.ignored) ? watchOptions.ignored.filter((ignore) => typeof ignore === "string") : [] : [];
641
+ const ignored = watchOptions?.ignored ? typeof watchOptions.ignored === "string" ? [watchOptions.ignored] : Array.isArray(watchOptions.ignored) ? watchOptions.ignored.filter((ignore2) => typeof ignore2 === "string") : [] : [];
643
642
  config2.watchOptions = {
644
643
  ...config2.watchOptions ?? {},
645
644
  ...{ ignored: [...ignored, "**/node_modules/**", "**/.git/**", "**/.next/**", "**/dist/**", "**/local/**"] }
@@ -708,10 +707,9 @@ var archs = ["amd64", "arm64"];
708
707
 
709
708
  // pkgs/@akanjs/config/src/akanConfig.ts
710
709
  var import_meta = {};
711
- var makeAppConfig = (config, props) => {
710
+ var makeAppConfig = (config, props, optimizeLibs) => {
712
711
  const { name, repoName } = props;
713
712
  return {
714
- libs: config.libs ?? [],
715
713
  backend: {
716
714
  docker: makeDockerfile("backend", config.backend?.docker ?? {}, props),
717
715
  explicitDependencies: config.backend?.explicitDependencies ?? []
@@ -721,7 +719,7 @@ var makeAppConfig = (config, props) => {
721
719
  nextConfig: withBase(
722
720
  name,
723
721
  config.frontend?.nextConfig ? typeof config.frontend.nextConfig === "function" ? config.frontend.nextConfig() : config.frontend.nextConfig : {},
724
- config.libs ?? [],
722
+ optimizeLibs,
725
723
  config.frontend?.routes
726
724
  ),
727
725
  routes: config.frontend?.routes,
@@ -737,7 +735,7 @@ var makeAppConfig = (config, props) => {
737
735
  }
738
736
  };
739
737
  };
740
- var getAppConfig = async (appRoot, props) => {
738
+ var getAppConfig = async (appRoot, props, tsconfig) => {
741
739
  const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
742
740
  if (!import_fs3.default.existsSync(akanConfigPath))
743
741
  throw new Error(`application akan.config.ts is not found ${appRoot}`);
@@ -748,11 +746,13 @@ var getAppConfig = async (appRoot, props) => {
748
746
  });
749
747
  const configImp = (await jiti.import(akanConfigPath)).default;
750
748
  const config = typeof configImp === "function" ? configImp(props) : configImp;
751
- return makeAppConfig(config, props);
749
+ const optimizeLibs = Object.entries(tsconfig.compilerOptions.paths ?? {}).filter(
750
+ ([key, resolves]) => key.startsWith("@") && resolves.at(0)?.startsWith("libs/") && resolves.at(0)?.endsWith("/index.ts")
751
+ ).map(([key]) => key.slice(1));
752
+ return makeAppConfig(config, props, optimizeLibs);
752
753
  };
753
754
  var makeLibConfig = (config, props) => {
754
755
  return {
755
- libs: config.libs ?? [],
756
756
  backend: {
757
757
  explicitDependencies: config.backend?.explicitDependencies ?? []
758
758
  },
@@ -856,8 +856,8 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
856
856
  };
857
857
  }
858
858
  };
859
- var increaseBuildNum = async (appRoot, props) => {
860
- const appConfig = await getAppConfig(appRoot, props);
859
+ var increaseBuildNum = async (appRoot, props, tsconfig) => {
860
+ const appConfig = await getAppConfig(appRoot, props, tsconfig);
861
861
  const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
862
862
  const akanConfig = import_fs3.default.readFileSync(akanConfigPath, "utf8");
863
863
  const akanConfigContent = akanConfig.replace(
@@ -866,8 +866,8 @@ var increaseBuildNum = async (appRoot, props) => {
866
866
  );
867
867
  import_fs3.default.writeFileSync(akanConfigPath, akanConfigContent);
868
868
  };
869
- var decreaseBuildNum = async (appRoot, props) => {
870
- const appConfig = await getAppConfig(appRoot, props);
869
+ var decreaseBuildNum = async (appRoot, props, tsconfig) => {
870
+ const appConfig = await getAppConfig(appRoot, props, tsconfig);
871
871
  const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
872
872
  const akanConfig = import_fs3.default.readFileSync(akanConfigPath, "utf8");
873
873
  const akanConfigContent = akanConfig.replace(
@@ -1097,6 +1097,7 @@ var import_path3 = __toESM(require("path"));
1097
1097
 
1098
1098
  // pkgs/@akanjs/devkit/src/dependencyScanner.ts
1099
1099
  var fs6 = __toESM(require("fs"));
1100
+ var import_ignore = __toESM(require("ignore"));
1100
1101
  var path4 = __toESM(require("path"));
1101
1102
  var ts2 = __toESM(require("typescript"));
1102
1103
  var TypeScriptDependencyScanner = class {
@@ -1105,10 +1106,19 @@ var TypeScriptDependencyScanner = class {
1105
1106
  directory;
1106
1107
  tsconfig;
1107
1108
  rootPackageJson;
1108
- constructor(directory, { tsconfig, rootPackageJson }) {
1109
+ ig;
1110
+ workspaceRoot;
1111
+ constructor(directory, {
1112
+ workspaceRoot,
1113
+ tsconfig,
1114
+ rootPackageJson,
1115
+ gitignorePatterns = []
1116
+ }) {
1109
1117
  this.directory = directory;
1110
1118
  this.tsconfig = tsconfig;
1111
1119
  this.rootPackageJson = rootPackageJson;
1120
+ this.ig = (0, import_ignore.default)().add(gitignorePatterns);
1121
+ this.workspaceRoot = workspaceRoot;
1112
1122
  }
1113
1123
  async getMonorepoDependencies(projectName) {
1114
1124
  const npmSet = new Set(
@@ -1170,6 +1180,9 @@ var TypeScriptDependencyScanner = class {
1170
1180
  const entries = await fs6.promises.readdir(dir, { withFileTypes: true });
1171
1181
  for (const entry of entries) {
1172
1182
  const fullPath = path4.join(dir, entry.name);
1183
+ const relativePath = path4.relative(this.workspaceRoot, fullPath);
1184
+ if (this.ig.ignores(relativePath))
1185
+ continue;
1173
1186
  if (entry.isDirectory()) {
1174
1187
  if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
1175
1188
  await processDirectory(fullPath);
@@ -1298,7 +1311,13 @@ var ScanInfo = class {
1298
1311
  const akanConfig = await exec2.getConfig();
1299
1312
  const tsconfig = exec2.getTsConfig();
1300
1313
  const rootPackageJson = exec2.workspace.getPackageJson();
1301
- const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
1314
+ const gitignorePatterns = exec2.workspace.getGitignorePatterns();
1315
+ const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, {
1316
+ workspaceRoot: exec2.workspace.cwdPath,
1317
+ tsconfig,
1318
+ rootPackageJson,
1319
+ gitignorePatterns
1320
+ });
1302
1321
  const { pkgDeps, libDeps, npmDeps } = await scanner.getMonorepoDependencies(exec2.name);
1303
1322
  const files = {
1304
1323
  constant: { databases: [], scalars: [] },
@@ -1402,15 +1421,6 @@ var ScanInfo = class {
1402
1421
  });
1403
1422
  })
1404
1423
  ]);
1405
- const missingLibDeps = [];
1406
- libDeps.forEach((libName) => {
1407
- if (!akanConfig.libs.includes(libName))
1408
- missingLibDeps.push(libName);
1409
- });
1410
- if (missingLibDeps.length)
1411
- throw new Error(
1412
- `Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
1413
- );
1414
1424
  const scanResult = {
1415
1425
  name: exec2.name,
1416
1426
  type: exec2.type,
@@ -1500,7 +1510,7 @@ var AppInfo = class _AppInfo extends ScanInfo {
1500
1510
  if (this.#sortedLibs)
1501
1511
  return this.#sortedLibs;
1502
1512
  const libIndices = LibInfo.getSortedLibIndices();
1503
- this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
1513
+ this.#sortedLibs = this.getScanResult().libDeps.sort((libNameA, libNameB) => {
1504
1514
  const indexA = libIndices.get(libNameA);
1505
1515
  const indexB = libIndices.get(libNameB);
1506
1516
  if (indexA === void 0 || indexB === void 0)
@@ -1540,7 +1550,7 @@ var LibInfo = class _LibInfo extends ScanInfo {
1540
1550
  if (this.#sortedLibIndices)
1541
1551
  return this.#sortedLibIndices;
1542
1552
  this.#sortedLibIndices = new Map(
1543
- [...this.libInfos.entries()].sort(([_, libInfoA], [__, libInfoB]) => libInfoA.akanConfig.libs.includes(libInfoB.name) ? 1 : -1).map(([libName], index) => [libName, index])
1553
+ [...this.libInfos.entries()].sort(([_, libInfoA], [__, libInfoB]) => libInfoA.getScanResult().libDeps.includes(libInfoB.name) ? 1 : -1).map(([libName], index) => [libName, index])
1544
1554
  );
1545
1555
  return this.#sortedLibIndices;
1546
1556
  }
@@ -1574,7 +1584,7 @@ var LibInfo = class _LibInfo extends ScanInfo {
1574
1584
  if (this.#sortedLibs)
1575
1585
  return this.#sortedLibs;
1576
1586
  const libs = _LibInfo.getSortedLibIndices();
1577
- this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
1587
+ this.#sortedLibs = this.scanResult.libDeps.sort((libNameA, libNameB) => {
1578
1588
  const indexA = libs.get(libNameA);
1579
1589
  const indexB = libs.get(libNameB);
1580
1590
  if (indexA === void 0 || indexB === void 0)
@@ -1587,7 +1597,7 @@ var LibInfo = class _LibInfo extends ScanInfo {
1587
1597
  return this.#getSortedLibs();
1588
1598
  }
1589
1599
  getLibInfo(libName) {
1590
- if (!this.getScanResult().akanConfig.libs.includes(libName))
1600
+ if (!this.getScanResult().libDeps.includes(libName))
1591
1601
  return void 0;
1592
1602
  const libSet = new Set(this.#getSortedLibs());
1593
1603
  if (!libSet.has(libName))
@@ -1612,7 +1622,13 @@ var PkgInfo = class _PkgInfo {
1612
1622
  static async getScanResult(exec2) {
1613
1623
  const tsconfig = exec2.getTsConfig();
1614
1624
  const rootPackageJson = exec2.workspace.getPackageJson();
1615
- const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
1625
+ const gitignorePatterns = exec2.workspace.getGitignorePatterns();
1626
+ const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, {
1627
+ workspaceRoot: exec2.workspace.cwdPath,
1628
+ tsconfig,
1629
+ rootPackageJson,
1630
+ gitignorePatterns
1631
+ });
1616
1632
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
1617
1633
  const pkgPathSet = new Set(
1618
1634
  Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
@@ -2137,6 +2153,14 @@ var Executor = class _Executor {
2137
2153
  this.writeJson("package.json", packageJson);
2138
2154
  this.#packageJson = packageJson;
2139
2155
  }
2156
+ #gitignorePatterns = [];
2157
+ getGitignorePatterns() {
2158
+ if (this.#gitignorePatterns.length)
2159
+ return this.#gitignorePatterns;
2160
+ const gitignore = this.readFile(".gitignore");
2161
+ this.#gitignorePatterns = gitignore.split("\n").map((line) => line.trim()).filter((line) => !!line && !line.startsWith("#"));
2162
+ return this.#gitignorePatterns;
2163
+ }
2140
2164
  async #applyTemplateFile({
2141
2165
  templatePath,
2142
2166
  targetPath,
@@ -2432,7 +2456,12 @@ var SysExecutor = class extends Executor {
2432
2456
  async getConfig({ refresh } = {}) {
2433
2457
  if (this.#akanConfig && !refresh)
2434
2458
  return this.#akanConfig;
2435
- this.#akanConfig = this.type === "app" ? await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name }) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name });
2459
+ const tsconfig = this.getTsConfig();
2460
+ this.#akanConfig = this.type === "app" ? await getAppConfig(
2461
+ this.cwdPath,
2462
+ { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
2463
+ tsconfig
2464
+ ) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name });
2436
2465
  return this.#akanConfig;
2437
2466
  }
2438
2467
  async getModules() {
@@ -2586,11 +2615,11 @@ var SysExecutor = class extends Executor {
2586
2615
  return modules.map((module2) => this.getLocalFile(`lib/${module2}/${module2}.constant.ts`));
2587
2616
  }
2588
2617
  async getConstantFilesWithLibs() {
2589
- const config = await this.getConfig();
2618
+ const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this) : await LibInfo.fromExecutor(this);
2590
2619
  const sysContantFiles = await this.getConstantFiles();
2591
2620
  const sysScalarConstantFiles = await this.getScalarConstantFiles();
2592
2621
  const libConstantFiles = await Promise.all(
2593
- config.libs.map(async (lib) => [
2622
+ scanInfo.getLibs().map(async (lib) => [
2594
2623
  ...await LibExecutor.from(this, lib).getConstantFiles(),
2595
2624
  ...await LibExecutor.from(this, lib).getScalarConstantFiles()
2596
2625
  ])
@@ -2643,11 +2672,11 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2643
2672
  async getConfig({ refresh } = {}) {
2644
2673
  if (this.#akanConfig && !refresh)
2645
2674
  return this.#akanConfig;
2646
- this.#akanConfig = await getAppConfig(this.cwdPath, {
2647
- ...this.workspace.getBaseDevEnv(),
2648
- type: "app",
2649
- name: this.name
2650
- });
2675
+ this.#akanConfig = await getAppConfig(
2676
+ this.cwdPath,
2677
+ { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
2678
+ this.getTsConfig()
2679
+ );
2651
2680
  return this.#akanConfig;
2652
2681
  }
2653
2682
  async syncAssets(libDeps) {
@@ -2670,10 +2699,18 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2670
2699
  ]);
2671
2700
  }
2672
2701
  async increaseBuildNum() {
2673
- await increaseBuildNum(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name });
2702
+ await increaseBuildNum(
2703
+ this.cwdPath,
2704
+ { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
2705
+ this.getTsConfig()
2706
+ );
2674
2707
  }
2675
2708
  async decreaseBuildNum() {
2676
- await decreaseBuildNum(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name });
2709
+ await decreaseBuildNum(
2710
+ this.cwdPath,
2711
+ { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
2712
+ this.getTsConfig()
2713
+ );
2677
2714
  }
2678
2715
  };
2679
2716
  var LibExecutor = class _LibExecutor extends SysExecutor {
@@ -4476,7 +4513,7 @@ var ApplicationRunner = class {
4476
4513
  }
4477
4514
  async scanSync(app, { refresh = false } = {}) {
4478
4515
  const scanInfo = await app.scan({ refresh });
4479
- await app.syncAssets(scanInfo.getScanResult().akanConfig.libs);
4516
+ await app.syncAssets(scanInfo.getScanResult().libDeps);
4480
4517
  return scanInfo;
4481
4518
  }
4482
4519
  async getScriptFilename(app) {
@@ -5837,7 +5874,7 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
5837
5874
  const getNextVersion = async (prefix, tag2) => {
5838
5875
  try {
5839
5876
  const latestPublishedVersionOfBase = await (0, import_latest_version.default)("@akanjs/base", { version: tag2 });
5840
- const latestPatch = parseInt(latestPublishedVersionOfBase.split(".").at(-1) ?? "0");
5877
+ const latestPatch = latestPublishedVersionOfBase.startsWith(prefix) ? parseInt(latestPublishedVersionOfBase.split(".").at(-1) ?? "-1") : -1;
5841
5878
  const nextVersion2 = `${prefix}.${latestPatch + 1}`;
5842
5879
  return { nextVersion: nextVersion2, latestPublishedVersion: latestPublishedVersionOfBase };
5843
5880
  } catch (e) {
@@ -6688,7 +6725,7 @@ var import_latest_version2 = __toESM(require("latest-version"), 1);
6688
6725
  var import_path6 = __toESM(require("path"), 1);
6689
6726
  var import_uuid2 = require("uuid");
6690
6727
  var WorkspaceRunner = class {
6691
- async createWorkspace(repoName, appName, dirname3 = ".") {
6728
+ async createWorkspace(repoName, appName, { dirname: dirname3 = ".", tag = "latest" }) {
6692
6729
  const cwdPath = process.cwd();
6693
6730
  const workspaceRoot = import_path6.default.join(cwdPath, dirname3, repoName);
6694
6731
  const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
@@ -6718,7 +6755,7 @@ var WorkspaceRunner = class {
6718
6755
  "@akanjs/ui"
6719
6756
  ];
6720
6757
  const devDependencies = ["@akanjs/devkit", "@akanjs/lint", "@akanjs/test"];
6721
- const latestPublishedVersionOfBase = await (0, import_latest_version2.default)("@akanjs/base");
6758
+ const latestPublishedVersionOfBase = await (0, import_latest_version2.default)("@akanjs/base", { version: tag });
6722
6759
  const packageJson = {
6723
6760
  ...rootPackageJson,
6724
6761
  dependencies: {
@@ -6787,8 +6824,8 @@ var WorkspaceScript = class {
6787
6824
  #runner = new WorkspaceRunner();
6788
6825
  applicationScript = new ApplicationScript();
6789
6826
  libraryScript = new LibraryScript();
6790
- async createWorkspace(repoName, appName, dirname3 = ".", installLibs) {
6791
- const workspace = await this.#runner.createWorkspace(repoName, appName, dirname3);
6827
+ async createWorkspace(repoName, appName, { dirname: dirname3 = ".", installLibs = false, tag = "latest" }) {
6828
+ const workspace = await this.#runner.createWorkspace(repoName, appName, { dirname: dirname3, tag });
6792
6829
  if (installLibs) {
6793
6830
  await this.libraryScript.installLibrary(workspace, "util");
6794
6831
  await this.libraryScript.installLibrary(workspace, "shared");
@@ -6853,12 +6890,11 @@ var WorkspaceScript = class {
6853
6890
  // pkgs/@akanjs/cli/src/workspace/workspace.command.ts
6854
6891
  var WorkspaceCommand = class {
6855
6892
  workspaceScript = new WorkspaceScript();
6856
- async createWorkspace(workspaceName, app, dir, libs) {
6893
+ async createWorkspace(workspaceName, app, dir, libs, tag) {
6857
6894
  await this.workspaceScript.createWorkspace(
6858
6895
  workspaceName.toLowerCase().replace(/ /g, "-"),
6859
6896
  app.toLowerCase().replace(/ /g, "-"),
6860
- dir,
6861
- libs
6897
+ { dirname: dir, installLibs: libs, tag }
6862
6898
  );
6863
6899
  }
6864
6900
  async generateMongo(workspace) {
@@ -6895,6 +6931,11 @@ __decorateClass([
6895
6931
  value: true
6896
6932
  }
6897
6933
  ]
6934
+ })),
6935
+ __decorateParam(4, Option("tag", {
6936
+ desc: "tag of the update",
6937
+ default: "latest",
6938
+ enum: ["latest", "dev", "canary", "beta", "rc", "alpha"]
6898
6939
  }))
6899
6940
  ], WorkspaceCommand.prototype, "createWorkspace", 1);
6900
6941
  __decorateClass([
@@ -7310,7 +7351,7 @@ var ScalarPrompt = class extends Prompter {
7310
7351
  boilerplate,
7311
7352
  constantFiles
7312
7353
  }) {
7313
- const config = await this.sys.getConfig();
7354
+ const scanInfo = await this.sys.scan();
7314
7355
  const guideJson = await Prompter.getGuideJson("scalarConstant");
7315
7356
  const request = await this.makeTsFileUpdatePrompt({
7316
7357
  context: `
@@ -7323,7 +7364,7 @@ ${await this.getDocumentation("enumConstant")}
7323
7364
  3. How to write Fields in __scalar/<model>/<model>.constant.ts file
7324
7365
  ${await this.getDocumentation("fieldDecorator")}
7325
7366
 
7326
- 4. List of constant.ts files in other libraries connected to current ${this.sys.name} ${this.sys.type === "app" ? "Application" : "Library"} ${config.libs.map((lib) => lib).join(", ")}
7367
+ 4. List of constant.ts files in other libraries connected to current ${this.sys.name} ${this.sys.type === "app" ? "Application" : "Library"} ${scanInfo.getLibs().map((lib) => lib).join(", ")}
7327
7368
  Please understand the content and file patterns below, and feel free to reuse any constants or enums if available.
7328
7369
  ${constantFiles.map(
7329
7370
  (constant) => `
@@ -22,13 +22,11 @@ __export(akan_config_exports, {
22
22
  default: () => getContent
23
23
  });
24
24
  module.exports = __toCommonJS(akan_config_exports);
25
- function getContent(scanInfo, dict, options) {
25
+ function getContent(scanInfo, dict) {
26
26
  return `
27
27
  import type { AppConfig } from "@akanjs/config";
28
28
 
29
- const config: AppConfig = ${options.libs.length ? `{
30
- libs: ["util", "shared"],
31
- }` : "{}"};
29
+ const config: AppConfig = {};
32
30
 
33
31
  export default config;
34
32
  `;
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // pkgs/@akanjs/cli/src/templates/env/env.server.type.ts
19
+ // pkgs/@akanjs/cli/src/templates/env/_env.server.type.ts
20
20
  var env_server_type_exports = {};
21
21
  __export(env_server_type_exports, {
22
22
  default: () => getContent
@@ -26,11 +26,14 @@ function getContent(scanInfo, dict = {}) {
26
26
  if (!scanInfo)
27
27
  return null;
28
28
  const libs = scanInfo.getLibs();
29
- return `
29
+ return {
30
+ filename: "env.server.type.ts",
31
+ content: `
30
32
  ${libs.length ? libs.map((lib) => `import { env as ${lib}Option } from "@${lib}/server";`).join("\n") : 'import { baseEnv } from "@akanjs/base";'}
31
33
 
32
34
  export const libEnv = {
33
35
  ${libs.length ? libs.map((lib) => ` ...${lib}Option,`).join("\n") : " ...baseEnv,"}
34
36
  };
35
- `;
37
+ `
38
+ };
36
39
  }
@@ -27,7 +27,7 @@ function getContent(scanInfo, dict = {}) {
27
27
  if (!scanInfo)
28
28
  return null;
29
29
  const scanResult = scanInfo.getScanResult();
30
- const libs = scanResult.akanConfig.libs;
30
+ const libs = scanResult.libDeps;
31
31
  const libInfos = scanInfo.getLibInfos();
32
32
  const extendedModels = Object.fromEntries(
33
33
  [...scanInfo.file.constant.databases].map(
@@ -26,7 +26,7 @@ function getContent(scanInfo, dict = {}) {
26
26
  if (!scanInfo)
27
27
  return null;
28
28
  const scanResult = scanInfo.getScanResult();
29
- const libs = scanInfo.akanConfig.libs;
29
+ const libs = scanResult.libDeps;
30
30
  const libInfos = scanInfo.getLibInfos();
31
31
  const extendedModels = Object.fromEntries(
32
32
  [...scanInfo.file.dictionary.databases].map(
@@ -26,9 +26,7 @@ function getContent(scanInfo, dict) {
26
26
  return `
27
27
  import type { LibConfig } from "@akanjs/config";
28
28
 
29
- const config: LibConfig = {
30
- libs: ["util", "shared"],
31
- };
29
+ const config: LibConfig = {};
32
30
 
33
31
  export default config;
34
32
  `;
package/esm/index.js CHANGED
@@ -573,7 +573,7 @@ var composePlugins = (...plugins) => {
573
573
  };
574
574
  var commandType = process.env.AKAN_COMMAND_TYPE?.includes("start") ? "start" : process.env.AKAN_COMMAND_TYPE?.includes("build") ? "build" : "deploy";
575
575
  var devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
576
- var withBase = (appName, config, libs, routes = []) => {
576
+ var withBase = (appName, config, optimizeLibs, routes = []) => {
577
577
  const withPWA = pwa({
578
578
  dest: "public",
579
579
  register: true,
@@ -597,8 +597,7 @@ var withBase = (appName, config, libs, routes = []) => {
597
597
  experimental: {
598
598
  ...config.experimental ?? {},
599
599
  optimizePackageImports: [
600
- ...[appName, ...libs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
601
- "@contract",
600
+ ...[appName, ...optimizeLibs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
602
601
  "@akanjs/next",
603
602
  "@akanjs/common",
604
603
  "@akanjs/ui"
@@ -619,7 +618,7 @@ var withBase = (appName, config, libs, routes = []) => {
619
618
  },
620
619
  webpack: (config2) => {
621
620
  const watchOptions = config2.watchOptions;
622
- const ignored = watchOptions?.ignored ? typeof watchOptions.ignored === "string" ? [watchOptions.ignored] : Array.isArray(watchOptions.ignored) ? watchOptions.ignored.filter((ignore) => typeof ignore === "string") : [] : [];
621
+ const ignored = watchOptions?.ignored ? typeof watchOptions.ignored === "string" ? [watchOptions.ignored] : Array.isArray(watchOptions.ignored) ? watchOptions.ignored.filter((ignore2) => typeof ignore2 === "string") : [] : [];
623
622
  config2.watchOptions = {
624
623
  ...config2.watchOptions ?? {},
625
624
  ...{ ignored: [...ignored, "**/node_modules/**", "**/.git/**", "**/.next/**", "**/dist/**", "**/local/**"] }
@@ -687,10 +686,9 @@ export default getNextConfig(config, appInfo);
687
686
  var archs = ["amd64", "arm64"];
688
687
 
689
688
  // pkgs/@akanjs/config/src/akanConfig.ts
690
- var makeAppConfig = (config, props) => {
689
+ var makeAppConfig = (config, props, optimizeLibs) => {
691
690
  const { name, repoName } = props;
692
691
  return {
693
- libs: config.libs ?? [],
694
692
  backend: {
695
693
  docker: makeDockerfile("backend", config.backend?.docker ?? {}, props),
696
694
  explicitDependencies: config.backend?.explicitDependencies ?? []
@@ -700,7 +698,7 @@ var makeAppConfig = (config, props) => {
700
698
  nextConfig: withBase(
701
699
  name,
702
700
  config.frontend?.nextConfig ? typeof config.frontend.nextConfig === "function" ? config.frontend.nextConfig() : config.frontend.nextConfig : {},
703
- config.libs ?? [],
701
+ optimizeLibs,
704
702
  config.frontend?.routes
705
703
  ),
706
704
  routes: config.frontend?.routes,
@@ -716,7 +714,7 @@ var makeAppConfig = (config, props) => {
716
714
  }
717
715
  };
718
716
  };
719
- var getAppConfig = async (appRoot, props) => {
717
+ var getAppConfig = async (appRoot, props, tsconfig) => {
720
718
  const akanConfigPath = path.join(appRoot, "akan.config.ts");
721
719
  if (!fs4.existsSync(akanConfigPath))
722
720
  throw new Error(`application akan.config.ts is not found ${appRoot}`);
@@ -727,11 +725,13 @@ var getAppConfig = async (appRoot, props) => {
727
725
  });
728
726
  const configImp = (await jiti.import(akanConfigPath)).default;
729
727
  const config = typeof configImp === "function" ? configImp(props) : configImp;
730
- return makeAppConfig(config, props);
728
+ const optimizeLibs = Object.entries(tsconfig.compilerOptions.paths ?? {}).filter(
729
+ ([key, resolves]) => key.startsWith("@") && resolves.at(0)?.startsWith("libs/") && resolves.at(0)?.endsWith("/index.ts")
730
+ ).map(([key]) => key.slice(1));
731
+ return makeAppConfig(config, props, optimizeLibs);
731
732
  };
732
733
  var makeLibConfig = (config, props) => {
733
734
  return {
734
- libs: config.libs ?? [],
735
735
  backend: {
736
736
  explicitDependencies: config.backend?.explicitDependencies ?? []
737
737
  },
@@ -835,8 +835,8 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
835
835
  };
836
836
  }
837
837
  };
838
- var increaseBuildNum = async (appRoot, props) => {
839
- const appConfig = await getAppConfig(appRoot, props);
838
+ var increaseBuildNum = async (appRoot, props, tsconfig) => {
839
+ const appConfig = await getAppConfig(appRoot, props, tsconfig);
840
840
  const akanConfigPath = path.join(appRoot, "akan.config.ts");
841
841
  const akanConfig = fs4.readFileSync(akanConfigPath, "utf8");
842
842
  const akanConfigContent = akanConfig.replace(
@@ -845,8 +845,8 @@ var increaseBuildNum = async (appRoot, props) => {
845
845
  );
846
846
  fs4.writeFileSync(akanConfigPath, akanConfigContent);
847
847
  };
848
- var decreaseBuildNum = async (appRoot, props) => {
849
- const appConfig = await getAppConfig(appRoot, props);
848
+ var decreaseBuildNum = async (appRoot, props, tsconfig) => {
849
+ const appConfig = await getAppConfig(appRoot, props, tsconfig);
850
850
  const akanConfigPath = path.join(appRoot, "akan.config.ts");
851
851
  const akanConfig = fs4.readFileSync(akanConfigPath, "utf8");
852
852
  const akanConfigContent = akanConfig.replace(
@@ -1076,6 +1076,7 @@ import path5 from "path";
1076
1076
 
1077
1077
  // pkgs/@akanjs/devkit/src/dependencyScanner.ts
1078
1078
  import * as fs6 from "fs";
1079
+ import ignore from "ignore";
1079
1080
  import * as path4 from "path";
1080
1081
  import * as ts2 from "typescript";
1081
1082
  var TypeScriptDependencyScanner = class {
@@ -1084,10 +1085,19 @@ var TypeScriptDependencyScanner = class {
1084
1085
  directory;
1085
1086
  tsconfig;
1086
1087
  rootPackageJson;
1087
- constructor(directory, { tsconfig, rootPackageJson }) {
1088
+ ig;
1089
+ workspaceRoot;
1090
+ constructor(directory, {
1091
+ workspaceRoot,
1092
+ tsconfig,
1093
+ rootPackageJson,
1094
+ gitignorePatterns = []
1095
+ }) {
1088
1096
  this.directory = directory;
1089
1097
  this.tsconfig = tsconfig;
1090
1098
  this.rootPackageJson = rootPackageJson;
1099
+ this.ig = ignore().add(gitignorePatterns);
1100
+ this.workspaceRoot = workspaceRoot;
1091
1101
  }
1092
1102
  async getMonorepoDependencies(projectName) {
1093
1103
  const npmSet = new Set(
@@ -1149,6 +1159,9 @@ var TypeScriptDependencyScanner = class {
1149
1159
  const entries = await fs6.promises.readdir(dir, { withFileTypes: true });
1150
1160
  for (const entry of entries) {
1151
1161
  const fullPath = path4.join(dir, entry.name);
1162
+ const relativePath = path4.relative(this.workspaceRoot, fullPath);
1163
+ if (this.ig.ignores(relativePath))
1164
+ continue;
1152
1165
  if (entry.isDirectory()) {
1153
1166
  if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
1154
1167
  await processDirectory(fullPath);
@@ -1277,7 +1290,13 @@ var ScanInfo = class {
1277
1290
  const akanConfig = await exec2.getConfig();
1278
1291
  const tsconfig = exec2.getTsConfig();
1279
1292
  const rootPackageJson = exec2.workspace.getPackageJson();
1280
- const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
1293
+ const gitignorePatterns = exec2.workspace.getGitignorePatterns();
1294
+ const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, {
1295
+ workspaceRoot: exec2.workspace.cwdPath,
1296
+ tsconfig,
1297
+ rootPackageJson,
1298
+ gitignorePatterns
1299
+ });
1281
1300
  const { pkgDeps, libDeps, npmDeps } = await scanner.getMonorepoDependencies(exec2.name);
1282
1301
  const files = {
1283
1302
  constant: { databases: [], scalars: [] },
@@ -1381,15 +1400,6 @@ var ScanInfo = class {
1381
1400
  });
1382
1401
  })
1383
1402
  ]);
1384
- const missingLibDeps = [];
1385
- libDeps.forEach((libName) => {
1386
- if (!akanConfig.libs.includes(libName))
1387
- missingLibDeps.push(libName);
1388
- });
1389
- if (missingLibDeps.length)
1390
- throw new Error(
1391
- `Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
1392
- );
1393
1403
  const scanResult = {
1394
1404
  name: exec2.name,
1395
1405
  type: exec2.type,
@@ -1479,7 +1489,7 @@ var AppInfo = class _AppInfo extends ScanInfo {
1479
1489
  if (this.#sortedLibs)
1480
1490
  return this.#sortedLibs;
1481
1491
  const libIndices = LibInfo.getSortedLibIndices();
1482
- this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
1492
+ this.#sortedLibs = this.getScanResult().libDeps.sort((libNameA, libNameB) => {
1483
1493
  const indexA = libIndices.get(libNameA);
1484
1494
  const indexB = libIndices.get(libNameB);
1485
1495
  if (indexA === void 0 || indexB === void 0)
@@ -1519,7 +1529,7 @@ var LibInfo = class _LibInfo extends ScanInfo {
1519
1529
  if (this.#sortedLibIndices)
1520
1530
  return this.#sortedLibIndices;
1521
1531
  this.#sortedLibIndices = new Map(
1522
- [...this.libInfos.entries()].sort(([_, libInfoA], [__, libInfoB]) => libInfoA.akanConfig.libs.includes(libInfoB.name) ? 1 : -1).map(([libName], index) => [libName, index])
1532
+ [...this.libInfos.entries()].sort(([_, libInfoA], [__, libInfoB]) => libInfoA.getScanResult().libDeps.includes(libInfoB.name) ? 1 : -1).map(([libName], index) => [libName, index])
1523
1533
  );
1524
1534
  return this.#sortedLibIndices;
1525
1535
  }
@@ -1553,7 +1563,7 @@ var LibInfo = class _LibInfo extends ScanInfo {
1553
1563
  if (this.#sortedLibs)
1554
1564
  return this.#sortedLibs;
1555
1565
  const libs = _LibInfo.getSortedLibIndices();
1556
- this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
1566
+ this.#sortedLibs = this.scanResult.libDeps.sort((libNameA, libNameB) => {
1557
1567
  const indexA = libs.get(libNameA);
1558
1568
  const indexB = libs.get(libNameB);
1559
1569
  if (indexA === void 0 || indexB === void 0)
@@ -1566,7 +1576,7 @@ var LibInfo = class _LibInfo extends ScanInfo {
1566
1576
  return this.#getSortedLibs();
1567
1577
  }
1568
1578
  getLibInfo(libName) {
1569
- if (!this.getScanResult().akanConfig.libs.includes(libName))
1579
+ if (!this.getScanResult().libDeps.includes(libName))
1570
1580
  return void 0;
1571
1581
  const libSet = new Set(this.#getSortedLibs());
1572
1582
  if (!libSet.has(libName))
@@ -1591,7 +1601,13 @@ var PkgInfo = class _PkgInfo {
1591
1601
  static async getScanResult(exec2) {
1592
1602
  const tsconfig = exec2.getTsConfig();
1593
1603
  const rootPackageJson = exec2.workspace.getPackageJson();
1594
- const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
1604
+ const gitignorePatterns = exec2.workspace.getGitignorePatterns();
1605
+ const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, {
1606
+ workspaceRoot: exec2.workspace.cwdPath,
1607
+ tsconfig,
1608
+ rootPackageJson,
1609
+ gitignorePatterns
1610
+ });
1595
1611
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
1596
1612
  const pkgPathSet = new Set(
1597
1613
  Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
@@ -2115,6 +2131,14 @@ var Executor = class _Executor {
2115
2131
  this.writeJson("package.json", packageJson);
2116
2132
  this.#packageJson = packageJson;
2117
2133
  }
2134
+ #gitignorePatterns = [];
2135
+ getGitignorePatterns() {
2136
+ if (this.#gitignorePatterns.length)
2137
+ return this.#gitignorePatterns;
2138
+ const gitignore = this.readFile(".gitignore");
2139
+ this.#gitignorePatterns = gitignore.split("\n").map((line) => line.trim()).filter((line) => !!line && !line.startsWith("#"));
2140
+ return this.#gitignorePatterns;
2141
+ }
2118
2142
  async #applyTemplateFile({
2119
2143
  templatePath,
2120
2144
  targetPath,
@@ -2410,7 +2434,12 @@ var SysExecutor = class extends Executor {
2410
2434
  async getConfig({ refresh } = {}) {
2411
2435
  if (this.#akanConfig && !refresh)
2412
2436
  return this.#akanConfig;
2413
- this.#akanConfig = this.type === "app" ? await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name }) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name });
2437
+ const tsconfig = this.getTsConfig();
2438
+ this.#akanConfig = this.type === "app" ? await getAppConfig(
2439
+ this.cwdPath,
2440
+ { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
2441
+ tsconfig
2442
+ ) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name });
2414
2443
  return this.#akanConfig;
2415
2444
  }
2416
2445
  async getModules() {
@@ -2564,11 +2593,11 @@ var SysExecutor = class extends Executor {
2564
2593
  return modules.map((module) => this.getLocalFile(`lib/${module}/${module}.constant.ts`));
2565
2594
  }
2566
2595
  async getConstantFilesWithLibs() {
2567
- const config = await this.getConfig();
2596
+ const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this) : await LibInfo.fromExecutor(this);
2568
2597
  const sysContantFiles = await this.getConstantFiles();
2569
2598
  const sysScalarConstantFiles = await this.getScalarConstantFiles();
2570
2599
  const libConstantFiles = await Promise.all(
2571
- config.libs.map(async (lib) => [
2600
+ scanInfo.getLibs().map(async (lib) => [
2572
2601
  ...await LibExecutor.from(this, lib).getConstantFiles(),
2573
2602
  ...await LibExecutor.from(this, lib).getScalarConstantFiles()
2574
2603
  ])
@@ -2621,11 +2650,11 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2621
2650
  async getConfig({ refresh } = {}) {
2622
2651
  if (this.#akanConfig && !refresh)
2623
2652
  return this.#akanConfig;
2624
- this.#akanConfig = await getAppConfig(this.cwdPath, {
2625
- ...this.workspace.getBaseDevEnv(),
2626
- type: "app",
2627
- name: this.name
2628
- });
2653
+ this.#akanConfig = await getAppConfig(
2654
+ this.cwdPath,
2655
+ { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
2656
+ this.getTsConfig()
2657
+ );
2629
2658
  return this.#akanConfig;
2630
2659
  }
2631
2660
  async syncAssets(libDeps) {
@@ -2648,10 +2677,18 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2648
2677
  ]);
2649
2678
  }
2650
2679
  async increaseBuildNum() {
2651
- await increaseBuildNum(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name });
2680
+ await increaseBuildNum(
2681
+ this.cwdPath,
2682
+ { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
2683
+ this.getTsConfig()
2684
+ );
2652
2685
  }
2653
2686
  async decreaseBuildNum() {
2654
- await decreaseBuildNum(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name });
2687
+ await decreaseBuildNum(
2688
+ this.cwdPath,
2689
+ { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
2690
+ this.getTsConfig()
2691
+ );
2655
2692
  }
2656
2693
  };
2657
2694
  var LibExecutor = class _LibExecutor extends SysExecutor {
@@ -4457,7 +4494,7 @@ var ApplicationRunner = class {
4457
4494
  }
4458
4495
  async scanSync(app, { refresh = false } = {}) {
4459
4496
  const scanInfo = await app.scan({ refresh });
4460
- await app.syncAssets(scanInfo.getScanResult().akanConfig.libs);
4497
+ await app.syncAssets(scanInfo.getScanResult().libDeps);
4461
4498
  return scanInfo;
4462
4499
  }
4463
4500
  async getScriptFilename(app) {
@@ -5818,7 +5855,7 @@ ${chalk6.green("\u27A4")} Authentication Required`));
5818
5855
  const getNextVersion = async (prefix, tag2) => {
5819
5856
  try {
5820
5857
  const latestPublishedVersionOfBase = await latestVersion("@akanjs/base", { version: tag2 });
5821
- const latestPatch = parseInt(latestPublishedVersionOfBase.split(".").at(-1) ?? "0");
5858
+ const latestPatch = latestPublishedVersionOfBase.startsWith(prefix) ? parseInt(latestPublishedVersionOfBase.split(".").at(-1) ?? "-1") : -1;
5822
5859
  const nextVersion2 = `${prefix}.${latestPatch + 1}`;
5823
5860
  return { nextVersion: nextVersion2, latestPublishedVersion: latestPublishedVersionOfBase };
5824
5861
  } catch (e) {
@@ -6669,7 +6706,7 @@ import latestVersion2 from "latest-version";
6669
6706
  import path9 from "path";
6670
6707
  import { v5 as uuid } from "uuid";
6671
6708
  var WorkspaceRunner = class {
6672
- async createWorkspace(repoName, appName, dirname3 = ".") {
6709
+ async createWorkspace(repoName, appName, { dirname: dirname3 = ".", tag = "latest" }) {
6673
6710
  const cwdPath = process.cwd();
6674
6711
  const workspaceRoot = path9.join(cwdPath, dirname3, repoName);
6675
6712
  const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
@@ -6699,7 +6736,7 @@ var WorkspaceRunner = class {
6699
6736
  "@akanjs/ui"
6700
6737
  ];
6701
6738
  const devDependencies = ["@akanjs/devkit", "@akanjs/lint", "@akanjs/test"];
6702
- const latestPublishedVersionOfBase = await latestVersion2("@akanjs/base");
6739
+ const latestPublishedVersionOfBase = await latestVersion2("@akanjs/base", { version: tag });
6703
6740
  const packageJson = {
6704
6741
  ...rootPackageJson,
6705
6742
  dependencies: {
@@ -6768,8 +6805,8 @@ var WorkspaceScript = class {
6768
6805
  #runner = new WorkspaceRunner();
6769
6806
  applicationScript = new ApplicationScript();
6770
6807
  libraryScript = new LibraryScript();
6771
- async createWorkspace(repoName, appName, dirname3 = ".", installLibs) {
6772
- const workspace = await this.#runner.createWorkspace(repoName, appName, dirname3);
6808
+ async createWorkspace(repoName, appName, { dirname: dirname3 = ".", installLibs = false, tag = "latest" }) {
6809
+ const workspace = await this.#runner.createWorkspace(repoName, appName, { dirname: dirname3, tag });
6773
6810
  if (installLibs) {
6774
6811
  await this.libraryScript.installLibrary(workspace, "util");
6775
6812
  await this.libraryScript.installLibrary(workspace, "shared");
@@ -6834,12 +6871,11 @@ var WorkspaceScript = class {
6834
6871
  // pkgs/@akanjs/cli/src/workspace/workspace.command.ts
6835
6872
  var WorkspaceCommand = class {
6836
6873
  workspaceScript = new WorkspaceScript();
6837
- async createWorkspace(workspaceName, app, dir, libs) {
6874
+ async createWorkspace(workspaceName, app, dir, libs, tag) {
6838
6875
  await this.workspaceScript.createWorkspace(
6839
6876
  workspaceName.toLowerCase().replace(/ /g, "-"),
6840
6877
  app.toLowerCase().replace(/ /g, "-"),
6841
- dir,
6842
- libs
6878
+ { dirname: dir, installLibs: libs, tag }
6843
6879
  );
6844
6880
  }
6845
6881
  async generateMongo(workspace) {
@@ -6876,6 +6912,11 @@ __decorateClass([
6876
6912
  value: true
6877
6913
  }
6878
6914
  ]
6915
+ })),
6916
+ __decorateParam(4, Option("tag", {
6917
+ desc: "tag of the update",
6918
+ default: "latest",
6919
+ enum: ["latest", "dev", "canary", "beta", "rc", "alpha"]
6879
6920
  }))
6880
6921
  ], WorkspaceCommand.prototype, "createWorkspace", 1);
6881
6922
  __decorateClass([
@@ -7290,7 +7331,7 @@ var ScalarPrompt = class extends Prompter {
7290
7331
  boilerplate,
7291
7332
  constantFiles
7292
7333
  }) {
7293
- const config = await this.sys.getConfig();
7334
+ const scanInfo = await this.sys.scan();
7294
7335
  const guideJson = await Prompter.getGuideJson("scalarConstant");
7295
7336
  const request = await this.makeTsFileUpdatePrompt({
7296
7337
  context: `
@@ -7303,7 +7344,7 @@ ${await this.getDocumentation("enumConstant")}
7303
7344
  3. How to write Fields in __scalar/<model>/<model>.constant.ts file
7304
7345
  ${await this.getDocumentation("fieldDecorator")}
7305
7346
 
7306
- 4. List of constant.ts files in other libraries connected to current ${this.sys.name} ${this.sys.type === "app" ? "Application" : "Library"} ${config.libs.map((lib) => lib).join(", ")}
7347
+ 4. List of constant.ts files in other libraries connected to current ${this.sys.name} ${this.sys.type === "app" ? "Application" : "Library"} ${scanInfo.getLibs().map((lib) => lib).join(", ")}
7307
7348
  Please understand the content and file patterns below, and feel free to reuse any constants or enums if available.
7308
7349
  ${constantFiles.map(
7309
7350
  (constant) => `
@@ -1,11 +1,9 @@
1
1
  // pkgs/@akanjs/cli/src/templates/app/akan.config.ts
2
- function getContent(scanInfo, dict, options) {
2
+ function getContent(scanInfo, dict) {
3
3
  return `
4
4
  import type { AppConfig } from "@akanjs/config";
5
5
 
6
- const config: AppConfig = ${options.libs.length ? `{
7
- libs: ["util", "shared"],
8
- }` : "{}"};
6
+ const config: AppConfig = {};
9
7
 
10
8
  export default config;
11
9
  `;
@@ -1,15 +1,18 @@
1
- // pkgs/@akanjs/cli/src/templates/env/env.server.type.ts
1
+ // pkgs/@akanjs/cli/src/templates/env/_env.server.type.ts
2
2
  function getContent(scanInfo, dict = {}) {
3
3
  if (!scanInfo)
4
4
  return null;
5
5
  const libs = scanInfo.getLibs();
6
- return `
6
+ return {
7
+ filename: "env.server.type.ts",
8
+ content: `
7
9
  ${libs.length ? libs.map((lib) => `import { env as ${lib}Option } from "@${lib}/server";`).join("\n") : 'import { baseEnv } from "@akanjs/base";'}
8
10
 
9
11
  export const libEnv = {
10
12
  ${libs.length ? libs.map((lib) => ` ...${lib}Option,`).join("\n") : " ...baseEnv,"}
11
13
  };
12
- `;
14
+ `
15
+ };
13
16
  }
14
17
  export {
15
18
  getContent as default
@@ -4,7 +4,7 @@ function getContent(scanInfo, dict = {}) {
4
4
  if (!scanInfo)
5
5
  return null;
6
6
  const scanResult = scanInfo.getScanResult();
7
- const libs = scanResult.akanConfig.libs;
7
+ const libs = scanResult.libDeps;
8
8
  const libInfos = scanInfo.getLibInfos();
9
9
  const extendedModels = Object.fromEntries(
10
10
  [...scanInfo.file.constant.databases].map(
@@ -3,7 +3,7 @@ function getContent(scanInfo, dict = {}) {
3
3
  if (!scanInfo)
4
4
  return null;
5
5
  const scanResult = scanInfo.getScanResult();
6
- const libs = scanInfo.akanConfig.libs;
6
+ const libs = scanResult.libDeps;
7
7
  const libInfos = scanInfo.getLibInfos();
8
8
  const extendedModels = Object.fromEntries(
9
9
  [...scanInfo.file.dictionary.databases].map(
@@ -3,9 +3,7 @@ function getContent(scanInfo, dict) {
3
3
  return `
4
4
  import type { LibConfig } from "@akanjs/config";
5
5
 
6
- const config: LibConfig = {
7
- libs: ["util", "shared"],
8
- };
6
+ const config: LibConfig = {};
9
7
 
10
8
  export default config;
11
9
  `;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "sourceType": "module",
4
4
  "name": "@akanjs/cli",
5
- "version": "0.9.59",
5
+ "version": "0.9.60-canary.1",
6
6
  "bin": {
7
7
  "akan": "esm/index.js"
8
8
  },
@@ -36,6 +36,7 @@
36
36
  "esbuild-plugin-d.ts": "^1.3.1",
37
37
  "eslint": "^9.19.0",
38
38
  "form-data": "^4.0.1",
39
+ "ignore": "^7.0.5",
39
40
  "ink": "^6.1.0",
40
41
  "jiti": "^2.4.2",
41
42
  "js-yaml": "^4.1.0",
@@ -2,7 +2,5 @@ import type { AppInfo, LibInfo } from "@akanjs/devkit";
2
2
  interface Dict {
3
3
  appName: string;
4
4
  }
5
- export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict, options: {
6
- libs: string[];
7
- }): string;
5
+ export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): string;
8
6
  export {};
@@ -1,4 +1,7 @@
1
1
  import type { AppInfo, LibInfo } from "@akanjs/devkit";
2
2
  export default function getContent(scanInfo: AppInfo | LibInfo | null, dict?: {
3
3
  [key: string]: string;
4
- }): string | null;
4
+ }): {
5
+ filename: string;
6
+ content: string;
7
+ } | null;
@@ -2,7 +2,7 @@ import { Exec, Workspace } from "@akanjs/devkit";
2
2
  import { WorkspaceScript } from "./workspace.script";
3
3
  export declare class WorkspaceCommand {
4
4
  workspaceScript: WorkspaceScript;
5
- createWorkspace(workspaceName: string, app: string, dir: string, libs: boolean): Promise<void>;
5
+ createWorkspace(workspaceName: string, app: string, dir: string, libs: boolean, tag: string): Promise<void>;
6
6
  generateMongo(workspace: Workspace): Promise<void>;
7
7
  lint(exec: Exec, fix: boolean, workspace: Workspace): Promise<void>;
8
8
  lintAll(fix: boolean, workspace: Workspace): Promise<void>;
@@ -1,7 +1,10 @@
1
1
  import { Exec, type Workspace } from "@akanjs/devkit";
2
2
  import { WorkspaceExecutor } from "@akanjs/devkit";
3
3
  export declare class WorkspaceRunner {
4
- createWorkspace(repoName: string, appName: string, dirname?: string): Promise<WorkspaceExecutor>;
4
+ createWorkspace(repoName: string, appName: string, { dirname, tag }: {
5
+ dirname?: string;
6
+ tag?: string;
7
+ }): Promise<WorkspaceExecutor>;
5
8
  generateMongo(workspace: Workspace): Promise<void>;
6
9
  lint(exec: Exec, workspace: Workspace, { fix }?: {
7
10
  fix?: boolean;
@@ -5,7 +5,11 @@ export declare class WorkspaceScript {
5
5
  #private;
6
6
  applicationScript: ApplicationScript;
7
7
  libraryScript: LibraryScript;
8
- createWorkspace(repoName: string, appName: string, dirname: string | undefined, installLibs: boolean): Promise<void>;
8
+ createWorkspace(repoName: string, appName: string, { dirname, installLibs, tag }: {
9
+ dirname?: string;
10
+ installLibs?: boolean;
11
+ tag?: string;
12
+ }): Promise<void>;
9
13
  generateMongo(workspace: Workspace): Promise<void>;
10
14
  lint(exec: Exec, workspace: Workspace, { fix }?: {
11
15
  fix?: boolean;
@@ -1,27 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // pkgs/@akanjs/cli/src/templates/module/__model__.signal.spec.ts
20
- var model_signal_spec_exports = {};
21
- __export(model_signal_spec_exports, {
22
- default: () => getContent
23
- });
24
- module.exports = __toCommonJS(model_signal_spec_exports);
25
- function getContent(scanInfo, dict) {
26
- return null;
27
- }
@@ -1,27 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // pkgs/@akanjs/cli/src/templates/module/__model__.signal.test.ts
20
- var model_signal_test_exports = {};
21
- __export(model_signal_test_exports, {
22
- default: () => getContent
23
- });
24
- module.exports = __toCommonJS(model_signal_test_exports);
25
- function getContent(scanInfo, dict) {
26
- return null;
27
- }
@@ -1,7 +0,0 @@
1
- // pkgs/@akanjs/cli/src/templates/module/__model__.signal.spec.ts
2
- function getContent(scanInfo, dict) {
3
- return null;
4
- }
5
- export {
6
- getContent as default
7
- };
@@ -1,7 +0,0 @@
1
- // pkgs/@akanjs/cli/src/templates/module/__model__.signal.test.ts
2
- function getContent(scanInfo, dict) {
3
- return null;
4
- }
5
- export {
6
- getContent as default
7
- };
@@ -1,8 +0,0 @@
1
- import type { AppInfo, LibInfo } from "@akanjs/devkit";
2
- interface Dict {
3
- Model: string;
4
- model: string;
5
- sysName: string;
6
- }
7
- export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): null;
8
- export {};
@@ -1,8 +0,0 @@
1
- import type { AppInfo, LibInfo } from "@akanjs/devkit";
2
- interface Dict {
3
- Model: string;
4
- model: string;
5
- sysName: string;
6
- }
7
- export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): null;
8
- export {};