@akanjs/cli 2.4.0-rc.1 → 2.4.0-rc.3

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.
@@ -721,7 +721,14 @@ var WORKSPACE_BARREL_FACETS = ["ui", "webkit", "common", "client", "server"];
721
721
  var SSR_RUNTIME_PACKAGES = ["react", "react-dom", "react-server-dom-webpack"];
722
722
  var NATIVE_RUNTIME_PACKAGES = ["sharp"];
723
723
  var DEFAULT_BACKEND_RUNTIME_PACKAGES = ["croner"];
724
- var MOBILE_RUNTIME_PACKAGES = ["firebase"];
724
+ var MOBILE_RUNTIME_PACKAGES = [
725
+ "firebase",
726
+ "@capacitor/cli",
727
+ "@capacitor/core",
728
+ "@capacitor/ios",
729
+ "@capacitor/android",
730
+ "@capacitor/assets"
731
+ ];
725
732
  var DATABASE_MODE_RUNTIME_PACKAGES = {
726
733
  single: [],
727
734
  multiple: ["@libsql/client", "bullmq", "ioredis", "protobufjs"],
@@ -986,9 +993,15 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
986
993
  command
987
994
  };
988
995
  }
989
- static async from(app) {
996
+ static #importGeneration = 0;
997
+ static async importConfigModule(cwdPath, { bustImportCache = false } = {}) {
998
+ const configPath2 = `${cwdPath}/akan.config.ts`;
999
+ const importPath = bustImportCache ? `${configPath2}?akanConfigGeneration=${++AkanAppConfig.#importGeneration}` : configPath2;
1000
+ return await import(importPath).then((mod) => mod.default);
1001
+ }
1002
+ static async from(app, { bustImportCache = false } = {}) {
990
1003
  const [configImp, baseDevEnv, libs, rootPackageJson] = await Promise.all([
991
- import(`${app.cwdPath}/akan.config.ts`).then((mod) => mod.default),
1004
+ AkanAppConfig.importConfigModule(app.cwdPath, { bustImportCache }),
992
1005
  WorkspaceExecutor.getBaseDevEnv(path.join(app.workspace.workspaceRoot, ".env")),
993
1006
  app.workspace.getLibs(),
994
1007
  app.workspace.getPackageJson()
@@ -1408,8 +1421,8 @@ ${errorText}, ${warningText} found`];
1408
1421
  }
1409
1422
 
1410
1423
  // pkgs/@akanjs/devkit/scanInfo.ts
1411
- import path5 from "path";
1412
1424
  import { rm } from "fs/promises";
1425
+ import path5 from "path";
1413
1426
 
1414
1427
  // pkgs/@akanjs/devkit/dependencyScanner.ts
1415
1428
  import { builtinModules } from "module";
@@ -1746,7 +1759,8 @@ var appRootAllowedDirs = new Set([
1746
1759
  "ui",
1747
1760
  "srvkit",
1748
1761
  "webkit",
1749
- "common"
1762
+ "common",
1763
+ "secrets"
1750
1764
  ]);
1751
1765
  var libRootAllowedFiles = new Set([
1752
1766
  "cnst.ts",
@@ -3660,7 +3674,7 @@ class AppExecutor extends SysExecutor {
3660
3674
  async getConfig({ refresh } = {}) {
3661
3675
  if (this.#akanConfig && !refresh)
3662
3676
  return this.#akanConfig;
3663
- this.#akanConfig = await AkanAppConfig.from(this);
3677
+ this.#akanConfig = await AkanAppConfig.from(this, { bustImportCache: refresh });
3664
3678
  return this.#akanConfig;
3665
3679
  }
3666
3680
  #pageKeys = null;
@@ -4798,16 +4812,20 @@ ${this.#backendStderrTail.join(`
4798
4812
  }
4799
4813
  async#handleInvalidate(message) {
4800
4814
  this.#logDevPlan(message);
4801
- if (shouldRestartBuilderByDevPlan(message)) {
4815
+ if (shouldRestartDevHostByDevPlan(message)) {
4802
4816
  try {
4803
- await this.#restartDevChildren(message);
4817
+ await this.#restartDevHost(message);
4804
4818
  } catch (err) {
4805
- this.#recordDevHostRestartFailure(message, err);
4819
+ this.#recordDevHostRestartFailure(message, err, "Config");
4806
4820
  }
4807
4821
  return;
4808
4822
  }
4809
- if (shouldRestartDevHostByDevPlan(message)) {
4810
- this.#recordDevHostRestartRequired(message);
4823
+ if (shouldRestartBuilderByDevPlan(message)) {
4824
+ try {
4825
+ await this.#restartDevChildren(message);
4826
+ } catch (err) {
4827
+ this.#recordDevHostRestartFailure(message, err, "Runtime metadata");
4828
+ }
4811
4829
  return;
4812
4830
  }
4813
4831
  if (await this.#shouldRestartBackend(message)) {
@@ -4819,6 +4837,15 @@ ${this.#backendStderrTail.join(`
4819
4837
  async#restartDevChildren(message) {
4820
4838
  const generation = message.devPlan?.generation ?? message.generation;
4821
4839
  this.logger.warn(`[dev-host] recycling builder/backend for runtime metadata generation=${generation ?? "(unknown)"} files=${message.files.length}`);
4840
+ await this.#recycleDevChildren(message);
4841
+ }
4842
+ async#restartDevHost(message) {
4843
+ const generation = message.devPlan?.generation ?? message.generation;
4844
+ this.logger.warn(`[dev-host] config change detected; restarting dev host generation=${generation ?? "(unknown)"} files=${message.files.length}`);
4845
+ await this.#recycleDevChildren(message, { refreshConfig: true });
4846
+ }
4847
+ async#recycleDevChildren(message, { refreshConfig = false } = {}) {
4848
+ const generation = message.devPlan?.generation ?? message.generation;
4822
4849
  if (this.#restartTimer) {
4823
4850
  clearTimeout(this.#restartTimer);
4824
4851
  this.#restartTimer = null;
@@ -4833,6 +4860,11 @@ ${this.#backendStderrTail.join(`
4833
4860
  this.#pendingBuildStatusReplay = [];
4834
4861
  await this.#stopBackend();
4835
4862
  this.#stopBuilder();
4863
+ if (refreshConfig) {
4864
+ await this.app.getConfig({ refresh: true });
4865
+ const { env } = await this.app.prepareCommand("start");
4866
+ Object.assign(this.env, env);
4867
+ }
4836
4868
  await this.#backendGraph.refresh();
4837
4869
  await this.#startBuilder();
4838
4870
  this.#startBackend({ generation, files: message.files });
@@ -4850,32 +4882,16 @@ ${this.#backendStderrTail.join(`
4850
4882
  this.#lastGoodFrontend.css = message;
4851
4883
  this.logger.verbose(`[last-good] css generation=${message.data.generation ?? "(unknown)"} assets=${Object.keys(message.data.cssAssets).length}`);
4852
4884
  }
4853
- #recordDevHostRestartRequired(message) {
4854
- const generation = message.devPlan?.generation ?? message.generation;
4855
- const detail = `generation=${generation ?? "(unknown)"} files=${message.files.length}`;
4856
- this.logger.warn(`[dev-host] config change requires a manual restart until controlled dev-host restart is implemented (${detail})`);
4857
- if (typeof generation === "number") {
4858
- const status = {
4859
- generation,
4860
- phase: "scan",
4861
- ok: false,
4862
- files: message.files,
4863
- message: "Config change requires restarting `akan start` to apply."
4864
- };
4865
- this.#recordBuildStatus(status);
4866
- this.#sendOrQueueBuildStatus(status);
4867
- }
4868
- }
4869
- #recordDevHostRestartFailure(message, err) {
4885
+ #recordDevHostRestartFailure(message, err, kind) {
4870
4886
  const generation = message.devPlan?.generation ?? message.generation ?? this.#nextBackendBuildStatusGeneration();
4871
4887
  const detail = err instanceof Error ? err.message : String(err);
4872
- this.logger.warn(`[dev-host] runtime metadata restart failed generation=${generation}: ${detail}`);
4888
+ this.logger.warn(`[dev-host] ${kind.toLowerCase()} restart failed generation=${generation}: ${detail}`);
4873
4889
  const status = {
4874
4890
  generation,
4875
4891
  phase: "scan",
4876
4892
  ok: false,
4877
4893
  files: message.files,
4878
- message: `Runtime metadata change requires restarting \`akan start\` to apply: ${detail}`
4894
+ message: `${kind} change requires restarting \`akan start\` to apply: ${detail}`
4879
4895
  };
4880
4896
  this.#recordBuildStatus(status);
4881
4897
  this.#sendOrQueueBuildStatus(status);
@@ -17342,7 +17358,7 @@ ${cssText}`).toString(36);
17342
17358
  this.#sendBuildStatus("pages", { generation, ok: false, files, message });
17343
17359
  }
17344
17360
  }
17345
- if (kinds.includes("code") || kinds.includes("css")) {
17361
+ if (kinds.includes("css") || kinds.includes("code") && rebuildClient) {
17346
17362
  this.scheduleCssRebuild(artifactDir, { refresh: true, generation, changedFiles: files });
17347
17363
  this.#logger.verbose(`css-rebuild scheduled generation=${generation}`);
17348
17364
  }
package/index.js CHANGED
@@ -719,7 +719,14 @@ var WORKSPACE_BARREL_FACETS = ["ui", "webkit", "common", "client", "server"];
719
719
  var SSR_RUNTIME_PACKAGES = ["react", "react-dom", "react-server-dom-webpack"];
720
720
  var NATIVE_RUNTIME_PACKAGES = ["sharp"];
721
721
  var DEFAULT_BACKEND_RUNTIME_PACKAGES = ["croner"];
722
- var MOBILE_RUNTIME_PACKAGES = ["firebase"];
722
+ var MOBILE_RUNTIME_PACKAGES = [
723
+ "firebase",
724
+ "@capacitor/cli",
725
+ "@capacitor/core",
726
+ "@capacitor/ios",
727
+ "@capacitor/android",
728
+ "@capacitor/assets"
729
+ ];
723
730
  var DATABASE_MODE_RUNTIME_PACKAGES = {
724
731
  single: [],
725
732
  multiple: ["@libsql/client", "bullmq", "ioredis", "protobufjs"],
@@ -984,9 +991,15 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
984
991
  command
985
992
  };
986
993
  }
987
- static async from(app) {
994
+ static #importGeneration = 0;
995
+ static async importConfigModule(cwdPath, { bustImportCache = false } = {}) {
996
+ const configPath2 = `${cwdPath}/akan.config.ts`;
997
+ const importPath = bustImportCache ? `${configPath2}?akanConfigGeneration=${++AkanAppConfig.#importGeneration}` : configPath2;
998
+ return await import(importPath).then((mod) => mod.default);
999
+ }
1000
+ static async from(app, { bustImportCache = false } = {}) {
988
1001
  const [configImp, baseDevEnv, libs, rootPackageJson] = await Promise.all([
989
- import(`${app.cwdPath}/akan.config.ts`).then((mod) => mod.default),
1002
+ AkanAppConfig.importConfigModule(app.cwdPath, { bustImportCache }),
990
1003
  WorkspaceExecutor.getBaseDevEnv(path.join(app.workspace.workspaceRoot, ".env")),
991
1004
  app.workspace.getLibs(),
992
1005
  app.workspace.getPackageJson()
@@ -1406,8 +1419,8 @@ ${errorText}, ${warningText} found`];
1406
1419
  }
1407
1420
 
1408
1421
  // pkgs/@akanjs/devkit/scanInfo.ts
1409
- import path5 from "path";
1410
1422
  import { rm } from "fs/promises";
1423
+ import path5 from "path";
1411
1424
 
1412
1425
  // pkgs/@akanjs/devkit/dependencyScanner.ts
1413
1426
  import { builtinModules } from "module";
@@ -1744,7 +1757,8 @@ var appRootAllowedDirs = new Set([
1744
1757
  "ui",
1745
1758
  "srvkit",
1746
1759
  "webkit",
1747
- "common"
1760
+ "common",
1761
+ "secrets"
1748
1762
  ]);
1749
1763
  var libRootAllowedFiles = new Set([
1750
1764
  "cnst.ts",
@@ -3658,7 +3672,7 @@ class AppExecutor extends SysExecutor {
3658
3672
  async getConfig({ refresh } = {}) {
3659
3673
  if (this.#akanConfig && !refresh)
3660
3674
  return this.#akanConfig;
3661
- this.#akanConfig = await AkanAppConfig.from(this);
3675
+ this.#akanConfig = await AkanAppConfig.from(this, { bustImportCache: refresh });
3662
3676
  return this.#akanConfig;
3663
3677
  }
3664
3678
  #pageKeys = null;
@@ -4796,16 +4810,20 @@ ${this.#backendStderrTail.join(`
4796
4810
  }
4797
4811
  async#handleInvalidate(message) {
4798
4812
  this.#logDevPlan(message);
4799
- if (shouldRestartBuilderByDevPlan(message)) {
4813
+ if (shouldRestartDevHostByDevPlan(message)) {
4800
4814
  try {
4801
- await this.#restartDevChildren(message);
4815
+ await this.#restartDevHost(message);
4802
4816
  } catch (err) {
4803
- this.#recordDevHostRestartFailure(message, err);
4817
+ this.#recordDevHostRestartFailure(message, err, "Config");
4804
4818
  }
4805
4819
  return;
4806
4820
  }
4807
- if (shouldRestartDevHostByDevPlan(message)) {
4808
- this.#recordDevHostRestartRequired(message);
4821
+ if (shouldRestartBuilderByDevPlan(message)) {
4822
+ try {
4823
+ await this.#restartDevChildren(message);
4824
+ } catch (err) {
4825
+ this.#recordDevHostRestartFailure(message, err, "Runtime metadata");
4826
+ }
4809
4827
  return;
4810
4828
  }
4811
4829
  if (await this.#shouldRestartBackend(message)) {
@@ -4817,6 +4835,15 @@ ${this.#backendStderrTail.join(`
4817
4835
  async#restartDevChildren(message) {
4818
4836
  const generation = message.devPlan?.generation ?? message.generation;
4819
4837
  this.logger.warn(`[dev-host] recycling builder/backend for runtime metadata generation=${generation ?? "(unknown)"} files=${message.files.length}`);
4838
+ await this.#recycleDevChildren(message);
4839
+ }
4840
+ async#restartDevHost(message) {
4841
+ const generation = message.devPlan?.generation ?? message.generation;
4842
+ this.logger.warn(`[dev-host] config change detected; restarting dev host generation=${generation ?? "(unknown)"} files=${message.files.length}`);
4843
+ await this.#recycleDevChildren(message, { refreshConfig: true });
4844
+ }
4845
+ async#recycleDevChildren(message, { refreshConfig = false } = {}) {
4846
+ const generation = message.devPlan?.generation ?? message.generation;
4820
4847
  if (this.#restartTimer) {
4821
4848
  clearTimeout(this.#restartTimer);
4822
4849
  this.#restartTimer = null;
@@ -4831,6 +4858,11 @@ ${this.#backendStderrTail.join(`
4831
4858
  this.#pendingBuildStatusReplay = [];
4832
4859
  await this.#stopBackend();
4833
4860
  this.#stopBuilder();
4861
+ if (refreshConfig) {
4862
+ await this.app.getConfig({ refresh: true });
4863
+ const { env } = await this.app.prepareCommand("start");
4864
+ Object.assign(this.env, env);
4865
+ }
4834
4866
  await this.#backendGraph.refresh();
4835
4867
  await this.#startBuilder();
4836
4868
  this.#startBackend({ generation, files: message.files });
@@ -4848,32 +4880,16 @@ ${this.#backendStderrTail.join(`
4848
4880
  this.#lastGoodFrontend.css = message;
4849
4881
  this.logger.verbose(`[last-good] css generation=${message.data.generation ?? "(unknown)"} assets=${Object.keys(message.data.cssAssets).length}`);
4850
4882
  }
4851
- #recordDevHostRestartRequired(message) {
4852
- const generation = message.devPlan?.generation ?? message.generation;
4853
- const detail = `generation=${generation ?? "(unknown)"} files=${message.files.length}`;
4854
- this.logger.warn(`[dev-host] config change requires a manual restart until controlled dev-host restart is implemented (${detail})`);
4855
- if (typeof generation === "number") {
4856
- const status = {
4857
- generation,
4858
- phase: "scan",
4859
- ok: false,
4860
- files: message.files,
4861
- message: "Config change requires restarting `akan start` to apply."
4862
- };
4863
- this.#recordBuildStatus(status);
4864
- this.#sendOrQueueBuildStatus(status);
4865
- }
4866
- }
4867
- #recordDevHostRestartFailure(message, err) {
4883
+ #recordDevHostRestartFailure(message, err, kind) {
4868
4884
  const generation = message.devPlan?.generation ?? message.generation ?? this.#nextBackendBuildStatusGeneration();
4869
4885
  const detail = err instanceof Error ? err.message : String(err);
4870
- this.logger.warn(`[dev-host] runtime metadata restart failed generation=${generation}: ${detail}`);
4886
+ this.logger.warn(`[dev-host] ${kind.toLowerCase()} restart failed generation=${generation}: ${detail}`);
4871
4887
  const status = {
4872
4888
  generation,
4873
4889
  phase: "scan",
4874
4890
  ok: false,
4875
4891
  files: message.files,
4876
- message: `Runtime metadata change requires restarting \`akan start\` to apply: ${detail}`
4892
+ message: `${kind} change requires restarting \`akan start\` to apply: ${detail}`
4877
4893
  };
4878
4894
  this.#recordBuildStatus(status);
4879
4895
  this.#sendOrQueueBuildStatus(status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/cli",
3
- "version": "2.4.0-rc.1",
3
+ "version": "2.4.0-rc.3",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -34,7 +34,7 @@
34
34
  "@langchain/openai": "^1.4.6",
35
35
  "@tailwindcss/node": "^4.3.0",
36
36
  "@trapezedev/project": "^7.1.4",
37
- "akanjs": "2.4.0-rc.1",
37
+ "akanjs": "2.4.0-rc.3",
38
38
  "chalk": "^5.6.2",
39
39
  "commander": "^14.0.3",
40
40
  "daisyui": "5.5.23",
@@ -102,6 +102,7 @@ apps/*/common/index.ts
102
102
  apps/*/plugin/index.ts
103
103
  apps/*/client.ts
104
104
  apps/*/server.ts
105
+ apps/*/capacitor.config.json
105
106
  libs/*/lib/cnst.ts
106
107
  libs/*/lib/dict.ts
107
108
  libs/*/lib/db.ts