@akanjs/cli 2.4.0-rc.1 → 2.4.0-rc.2
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/incrementalBuilder.proc.js +39 -30
- package/index.js +38 -29
- package/package.json +2 -2
- package/templates/workspaceRoot/.gitignore.template +1 -0
|
@@ -986,9 +986,15 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
|
|
|
986
986
|
command
|
|
987
987
|
};
|
|
988
988
|
}
|
|
989
|
-
static
|
|
989
|
+
static #importGeneration = 0;
|
|
990
|
+
static async importConfigModule(cwdPath, { bustImportCache = false } = {}) {
|
|
991
|
+
const configPath2 = `${cwdPath}/akan.config.ts`;
|
|
992
|
+
const importPath = bustImportCache ? `${configPath2}?akanConfigGeneration=${++AkanAppConfig.#importGeneration}` : configPath2;
|
|
993
|
+
return await import(importPath).then((mod) => mod.default);
|
|
994
|
+
}
|
|
995
|
+
static async from(app, { bustImportCache = false } = {}) {
|
|
990
996
|
const [configImp, baseDevEnv, libs, rootPackageJson] = await Promise.all([
|
|
991
|
-
|
|
997
|
+
AkanAppConfig.importConfigModule(app.cwdPath, { bustImportCache }),
|
|
992
998
|
WorkspaceExecutor.getBaseDevEnv(path.join(app.workspace.workspaceRoot, ".env")),
|
|
993
999
|
app.workspace.getLibs(),
|
|
994
1000
|
app.workspace.getPackageJson()
|
|
@@ -1408,8 +1414,8 @@ ${errorText}, ${warningText} found`];
|
|
|
1408
1414
|
}
|
|
1409
1415
|
|
|
1410
1416
|
// pkgs/@akanjs/devkit/scanInfo.ts
|
|
1411
|
-
import path5 from "path";
|
|
1412
1417
|
import { rm } from "fs/promises";
|
|
1418
|
+
import path5 from "path";
|
|
1413
1419
|
|
|
1414
1420
|
// pkgs/@akanjs/devkit/dependencyScanner.ts
|
|
1415
1421
|
import { builtinModules } from "module";
|
|
@@ -1746,7 +1752,8 @@ var appRootAllowedDirs = new Set([
|
|
|
1746
1752
|
"ui",
|
|
1747
1753
|
"srvkit",
|
|
1748
1754
|
"webkit",
|
|
1749
|
-
"common"
|
|
1755
|
+
"common",
|
|
1756
|
+
"secrets"
|
|
1750
1757
|
]);
|
|
1751
1758
|
var libRootAllowedFiles = new Set([
|
|
1752
1759
|
"cnst.ts",
|
|
@@ -3660,7 +3667,7 @@ class AppExecutor extends SysExecutor {
|
|
|
3660
3667
|
async getConfig({ refresh } = {}) {
|
|
3661
3668
|
if (this.#akanConfig && !refresh)
|
|
3662
3669
|
return this.#akanConfig;
|
|
3663
|
-
this.#akanConfig = await AkanAppConfig.from(this);
|
|
3670
|
+
this.#akanConfig = await AkanAppConfig.from(this, { bustImportCache: refresh });
|
|
3664
3671
|
return this.#akanConfig;
|
|
3665
3672
|
}
|
|
3666
3673
|
#pageKeys = null;
|
|
@@ -4798,16 +4805,20 @@ ${this.#backendStderrTail.join(`
|
|
|
4798
4805
|
}
|
|
4799
4806
|
async#handleInvalidate(message) {
|
|
4800
4807
|
this.#logDevPlan(message);
|
|
4801
|
-
if (
|
|
4808
|
+
if (shouldRestartDevHostByDevPlan(message)) {
|
|
4802
4809
|
try {
|
|
4803
|
-
await this.#
|
|
4810
|
+
await this.#restartDevHost(message);
|
|
4804
4811
|
} catch (err) {
|
|
4805
|
-
this.#recordDevHostRestartFailure(message, err);
|
|
4812
|
+
this.#recordDevHostRestartFailure(message, err, "Config");
|
|
4806
4813
|
}
|
|
4807
4814
|
return;
|
|
4808
4815
|
}
|
|
4809
|
-
if (
|
|
4810
|
-
|
|
4816
|
+
if (shouldRestartBuilderByDevPlan(message)) {
|
|
4817
|
+
try {
|
|
4818
|
+
await this.#restartDevChildren(message);
|
|
4819
|
+
} catch (err) {
|
|
4820
|
+
this.#recordDevHostRestartFailure(message, err, "Runtime metadata");
|
|
4821
|
+
}
|
|
4811
4822
|
return;
|
|
4812
4823
|
}
|
|
4813
4824
|
if (await this.#shouldRestartBackend(message)) {
|
|
@@ -4819,6 +4830,15 @@ ${this.#backendStderrTail.join(`
|
|
|
4819
4830
|
async#restartDevChildren(message) {
|
|
4820
4831
|
const generation = message.devPlan?.generation ?? message.generation;
|
|
4821
4832
|
this.logger.warn(`[dev-host] recycling builder/backend for runtime metadata generation=${generation ?? "(unknown)"} files=${message.files.length}`);
|
|
4833
|
+
await this.#recycleDevChildren(message);
|
|
4834
|
+
}
|
|
4835
|
+
async#restartDevHost(message) {
|
|
4836
|
+
const generation = message.devPlan?.generation ?? message.generation;
|
|
4837
|
+
this.logger.warn(`[dev-host] config change detected; restarting dev host generation=${generation ?? "(unknown)"} files=${message.files.length}`);
|
|
4838
|
+
await this.#recycleDevChildren(message, { refreshConfig: true });
|
|
4839
|
+
}
|
|
4840
|
+
async#recycleDevChildren(message, { refreshConfig = false } = {}) {
|
|
4841
|
+
const generation = message.devPlan?.generation ?? message.generation;
|
|
4822
4842
|
if (this.#restartTimer) {
|
|
4823
4843
|
clearTimeout(this.#restartTimer);
|
|
4824
4844
|
this.#restartTimer = null;
|
|
@@ -4833,6 +4853,11 @@ ${this.#backendStderrTail.join(`
|
|
|
4833
4853
|
this.#pendingBuildStatusReplay = [];
|
|
4834
4854
|
await this.#stopBackend();
|
|
4835
4855
|
this.#stopBuilder();
|
|
4856
|
+
if (refreshConfig) {
|
|
4857
|
+
await this.app.getConfig({ refresh: true });
|
|
4858
|
+
const { env } = await this.app.prepareCommand("start");
|
|
4859
|
+
Object.assign(this.env, env);
|
|
4860
|
+
}
|
|
4836
4861
|
await this.#backendGraph.refresh();
|
|
4837
4862
|
await this.#startBuilder();
|
|
4838
4863
|
this.#startBackend({ generation, files: message.files });
|
|
@@ -4850,32 +4875,16 @@ ${this.#backendStderrTail.join(`
|
|
|
4850
4875
|
this.#lastGoodFrontend.css = message;
|
|
4851
4876
|
this.logger.verbose(`[last-good] css generation=${message.data.generation ?? "(unknown)"} assets=${Object.keys(message.data.cssAssets).length}`);
|
|
4852
4877
|
}
|
|
4853
|
-
#
|
|
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) {
|
|
4878
|
+
#recordDevHostRestartFailure(message, err, kind) {
|
|
4870
4879
|
const generation = message.devPlan?.generation ?? message.generation ?? this.#nextBackendBuildStatusGeneration();
|
|
4871
4880
|
const detail = err instanceof Error ? err.message : String(err);
|
|
4872
|
-
this.logger.warn(`[dev-host]
|
|
4881
|
+
this.logger.warn(`[dev-host] ${kind.toLowerCase()} restart failed generation=${generation}: ${detail}`);
|
|
4873
4882
|
const status = {
|
|
4874
4883
|
generation,
|
|
4875
4884
|
phase: "scan",
|
|
4876
4885
|
ok: false,
|
|
4877
4886
|
files: message.files,
|
|
4878
|
-
message:
|
|
4887
|
+
message: `${kind} change requires restarting \`akan start\` to apply: ${detail}`
|
|
4879
4888
|
};
|
|
4880
4889
|
this.#recordBuildStatus(status);
|
|
4881
4890
|
this.#sendOrQueueBuildStatus(status);
|
|
@@ -17342,7 +17351,7 @@ ${cssText}`).toString(36);
|
|
|
17342
17351
|
this.#sendBuildStatus("pages", { generation, ok: false, files, message });
|
|
17343
17352
|
}
|
|
17344
17353
|
}
|
|
17345
|
-
if (kinds.includes("
|
|
17354
|
+
if (kinds.includes("css") || kinds.includes("code") && rebuildClient) {
|
|
17346
17355
|
this.scheduleCssRebuild(artifactDir, { refresh: true, generation, changedFiles: files });
|
|
17347
17356
|
this.#logger.verbose(`css-rebuild scheduled generation=${generation}`);
|
|
17348
17357
|
}
|
package/index.js
CHANGED
|
@@ -984,9 +984,15 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
|
|
|
984
984
|
command
|
|
985
985
|
};
|
|
986
986
|
}
|
|
987
|
-
static
|
|
987
|
+
static #importGeneration = 0;
|
|
988
|
+
static async importConfigModule(cwdPath, { bustImportCache = false } = {}) {
|
|
989
|
+
const configPath2 = `${cwdPath}/akan.config.ts`;
|
|
990
|
+
const importPath = bustImportCache ? `${configPath2}?akanConfigGeneration=${++AkanAppConfig.#importGeneration}` : configPath2;
|
|
991
|
+
return await import(importPath).then((mod) => mod.default);
|
|
992
|
+
}
|
|
993
|
+
static async from(app, { bustImportCache = false } = {}) {
|
|
988
994
|
const [configImp, baseDevEnv, libs, rootPackageJson] = await Promise.all([
|
|
989
|
-
|
|
995
|
+
AkanAppConfig.importConfigModule(app.cwdPath, { bustImportCache }),
|
|
990
996
|
WorkspaceExecutor.getBaseDevEnv(path.join(app.workspace.workspaceRoot, ".env")),
|
|
991
997
|
app.workspace.getLibs(),
|
|
992
998
|
app.workspace.getPackageJson()
|
|
@@ -1406,8 +1412,8 @@ ${errorText}, ${warningText} found`];
|
|
|
1406
1412
|
}
|
|
1407
1413
|
|
|
1408
1414
|
// pkgs/@akanjs/devkit/scanInfo.ts
|
|
1409
|
-
import path5 from "path";
|
|
1410
1415
|
import { rm } from "fs/promises";
|
|
1416
|
+
import path5 from "path";
|
|
1411
1417
|
|
|
1412
1418
|
// pkgs/@akanjs/devkit/dependencyScanner.ts
|
|
1413
1419
|
import { builtinModules } from "module";
|
|
@@ -1744,7 +1750,8 @@ var appRootAllowedDirs = new Set([
|
|
|
1744
1750
|
"ui",
|
|
1745
1751
|
"srvkit",
|
|
1746
1752
|
"webkit",
|
|
1747
|
-
"common"
|
|
1753
|
+
"common",
|
|
1754
|
+
"secrets"
|
|
1748
1755
|
]);
|
|
1749
1756
|
var libRootAllowedFiles = new Set([
|
|
1750
1757
|
"cnst.ts",
|
|
@@ -3658,7 +3665,7 @@ class AppExecutor extends SysExecutor {
|
|
|
3658
3665
|
async getConfig({ refresh } = {}) {
|
|
3659
3666
|
if (this.#akanConfig && !refresh)
|
|
3660
3667
|
return this.#akanConfig;
|
|
3661
|
-
this.#akanConfig = await AkanAppConfig.from(this);
|
|
3668
|
+
this.#akanConfig = await AkanAppConfig.from(this, { bustImportCache: refresh });
|
|
3662
3669
|
return this.#akanConfig;
|
|
3663
3670
|
}
|
|
3664
3671
|
#pageKeys = null;
|
|
@@ -4796,16 +4803,20 @@ ${this.#backendStderrTail.join(`
|
|
|
4796
4803
|
}
|
|
4797
4804
|
async#handleInvalidate(message) {
|
|
4798
4805
|
this.#logDevPlan(message);
|
|
4799
|
-
if (
|
|
4806
|
+
if (shouldRestartDevHostByDevPlan(message)) {
|
|
4800
4807
|
try {
|
|
4801
|
-
await this.#
|
|
4808
|
+
await this.#restartDevHost(message);
|
|
4802
4809
|
} catch (err) {
|
|
4803
|
-
this.#recordDevHostRestartFailure(message, err);
|
|
4810
|
+
this.#recordDevHostRestartFailure(message, err, "Config");
|
|
4804
4811
|
}
|
|
4805
4812
|
return;
|
|
4806
4813
|
}
|
|
4807
|
-
if (
|
|
4808
|
-
|
|
4814
|
+
if (shouldRestartBuilderByDevPlan(message)) {
|
|
4815
|
+
try {
|
|
4816
|
+
await this.#restartDevChildren(message);
|
|
4817
|
+
} catch (err) {
|
|
4818
|
+
this.#recordDevHostRestartFailure(message, err, "Runtime metadata");
|
|
4819
|
+
}
|
|
4809
4820
|
return;
|
|
4810
4821
|
}
|
|
4811
4822
|
if (await this.#shouldRestartBackend(message)) {
|
|
@@ -4817,6 +4828,15 @@ ${this.#backendStderrTail.join(`
|
|
|
4817
4828
|
async#restartDevChildren(message) {
|
|
4818
4829
|
const generation = message.devPlan?.generation ?? message.generation;
|
|
4819
4830
|
this.logger.warn(`[dev-host] recycling builder/backend for runtime metadata generation=${generation ?? "(unknown)"} files=${message.files.length}`);
|
|
4831
|
+
await this.#recycleDevChildren(message);
|
|
4832
|
+
}
|
|
4833
|
+
async#restartDevHost(message) {
|
|
4834
|
+
const generation = message.devPlan?.generation ?? message.generation;
|
|
4835
|
+
this.logger.warn(`[dev-host] config change detected; restarting dev host generation=${generation ?? "(unknown)"} files=${message.files.length}`);
|
|
4836
|
+
await this.#recycleDevChildren(message, { refreshConfig: true });
|
|
4837
|
+
}
|
|
4838
|
+
async#recycleDevChildren(message, { refreshConfig = false } = {}) {
|
|
4839
|
+
const generation = message.devPlan?.generation ?? message.generation;
|
|
4820
4840
|
if (this.#restartTimer) {
|
|
4821
4841
|
clearTimeout(this.#restartTimer);
|
|
4822
4842
|
this.#restartTimer = null;
|
|
@@ -4831,6 +4851,11 @@ ${this.#backendStderrTail.join(`
|
|
|
4831
4851
|
this.#pendingBuildStatusReplay = [];
|
|
4832
4852
|
await this.#stopBackend();
|
|
4833
4853
|
this.#stopBuilder();
|
|
4854
|
+
if (refreshConfig) {
|
|
4855
|
+
await this.app.getConfig({ refresh: true });
|
|
4856
|
+
const { env } = await this.app.prepareCommand("start");
|
|
4857
|
+
Object.assign(this.env, env);
|
|
4858
|
+
}
|
|
4834
4859
|
await this.#backendGraph.refresh();
|
|
4835
4860
|
await this.#startBuilder();
|
|
4836
4861
|
this.#startBackend({ generation, files: message.files });
|
|
@@ -4848,32 +4873,16 @@ ${this.#backendStderrTail.join(`
|
|
|
4848
4873
|
this.#lastGoodFrontend.css = message;
|
|
4849
4874
|
this.logger.verbose(`[last-good] css generation=${message.data.generation ?? "(unknown)"} assets=${Object.keys(message.data.cssAssets).length}`);
|
|
4850
4875
|
}
|
|
4851
|
-
#
|
|
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) {
|
|
4876
|
+
#recordDevHostRestartFailure(message, err, kind) {
|
|
4868
4877
|
const generation = message.devPlan?.generation ?? message.generation ?? this.#nextBackendBuildStatusGeneration();
|
|
4869
4878
|
const detail = err instanceof Error ? err.message : String(err);
|
|
4870
|
-
this.logger.warn(`[dev-host]
|
|
4879
|
+
this.logger.warn(`[dev-host] ${kind.toLowerCase()} restart failed generation=${generation}: ${detail}`);
|
|
4871
4880
|
const status = {
|
|
4872
4881
|
generation,
|
|
4873
4882
|
phase: "scan",
|
|
4874
4883
|
ok: false,
|
|
4875
4884
|
files: message.files,
|
|
4876
|
-
message:
|
|
4885
|
+
message: `${kind} change requires restarting \`akan start\` to apply: ${detail}`
|
|
4877
4886
|
};
|
|
4878
4887
|
this.#recordBuildStatus(status);
|
|
4879
4888
|
this.#sendOrQueueBuildStatus(status);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/cli",
|
|
3
|
-
"version": "2.4.0-rc.
|
|
3
|
+
"version": "2.4.0-rc.2",
|
|
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.
|
|
37
|
+
"akanjs": "2.4.0-rc.2",
|
|
38
38
|
"chalk": "^5.6.2",
|
|
39
39
|
"commander": "^14.0.3",
|
|
40
40
|
"daisyui": "5.5.23",
|