@akanjs/devkit 3.3.0-rc.1 → 3.3.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +230 -2
- package/README.ko.md +3 -2
- package/README.md +3 -3
- package/akanApp/akanApp.host.test.ts +22 -5
- package/akanApp/akanApp.host.ts +46 -9
- package/akanApp/akanApp.host.wiring.test.ts +206 -2
- package/akanApp/devBackend.ts +3 -1
- package/akanApp/devBuilder.ts +5 -1
- package/akanApp/devStartTimeline.test.ts +115 -0
- package/akanApp/devStartTimeline.ts +69 -0
- package/akanConfig/akanConfig.test.ts +57 -8
- package/akanConfig/akanConfig.ts +12 -65
- package/akanConfig/dockerImage.ts +17 -0
- package/akanConfig/nativeKeys.ts +52 -0
- package/app/applicationBuildRunner.test.ts +49 -1
- package/app/applicationBuildRunner.ts +3 -1
- package/codeAgent/agent/CodeAgent.ts +36 -16
- package/codeAgent/agent/CodeAgentAllowed.ts +35 -0
- package/codeAgent/agent/CodeAgentCommandLine.ts +372 -0
- package/codeAgent/agent/CodeAgentGate.ts +23 -4
- package/codeAgent/agent/CodeAgentRpcHost.ts +1 -1
- package/codeAgent/agent/codeAgent.test.ts +62 -0
- package/codeAgent/agent/codeAgentCommandLine.test.ts +212 -0
- package/codeAgent/agent/codeAgentContract.test.ts +117 -5
- package/codeAgent/skills/akan-agent/SKILL.md +8 -1
- package/codeAgent/skills/akan-code/SKILL.md +38 -3
- package/codeAgent/skills/akan-page/SKILL.md +18 -13
- package/codeAgent/skills/akan-runtime/SKILL.md +21 -16
- package/codeAgent/skills/akan-service/SKILL.md +2 -2
- package/docs/apiReference.test.ts +5 -0
- package/docs/apiReference.ts +7 -3
- package/docs/declarationReader.ts +28 -1
- package/executors/appExecutor.ts +35 -11
- package/executors/executors.test.ts +30 -3
- package/frontendBuild/buildCacheStamp.test.ts +42 -0
- package/frontendBuild/buildCacheStamp.ts +23 -0
- package/frontendBuild/buildRouteClient.test.ts +2 -7
- package/frontendBuild/clientEntryDiscovery.ts +2 -2
- package/frontendBuild/cssCandidateCache.test.ts +70 -1
- package/frontendBuild/cssCandidateCache.ts +17 -10
- package/frontendBuild/cssCompiler.test.ts +112 -0
- package/frontendBuild/cssCompiler.ts +41 -21
- package/frontendBuild/devBarrelImports.test.ts +30 -0
- package/frontendBuild/devBarrelImports.ts +2 -2
- package/frontendBuild/fontOptimizer.test.ts +144 -3
- package/frontendBuild/fontOptimizer.ts +103 -18
- package/frontendBuild/pagesBundleBuilder.ts +3 -1
- package/frontendBuild/plainStylesheet.test.ts +155 -0
- package/frontendBuild/plainStylesheet.ts +197 -0
- package/frontendBuild/rscServerRendererGuard.test.ts +60 -0
- package/frontendBuild/rscServerRendererGuard.ts +68 -0
- package/frontendBuild/ssrBaseArtifactBuilder.test.ts +30 -1
- package/frontendBuild/ssrBaseArtifactBuilder.ts +40 -12
- package/guideline/agentAssets.test.ts +10 -0
- package/guideline/agentAssets.ts +52 -11
- package/incrementalBuilder/buildBatch.proc.ts +11 -10
- package/incrementalBuilder/buildBatchProtocol.ts +2 -1
- package/incrementalBuilder/builderBoot.ts +14 -7
- package/incrementalBuilder/builderChannel.ts +8 -2
- package/incrementalBuilder/builderGraphPayloads.ts +4 -4
- package/incrementalBuilder/builderLanes.ts +2 -2
- package/incrementalBuilder/builderWatch.ts +8 -8
- package/incrementalBuilder/csrRegistry.ts +4 -4
- package/incrementalBuilder/incrementalBuilder.host.test.ts +16 -0
- package/incrementalBuilder/incrementalBuilder.host.ts +7 -1
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +41 -0
- package/incrementalBuilder/incrementalBuilder.proc.ts +9 -8
- package/incrementalBuilder/ssrRegistry.ts +6 -6
- package/index.ts +1 -1
- package/integration/renderAdmissionSoak.test.ts +99 -0
- package/integration/renderAdmissionSoak.ts +609 -0
- package/mobile/nativeConfig.test.ts +100 -0
- package/mobile/nativeConfig.ts +55 -16
- package/mobile/nativePublicEnv.ts +2 -1
- package/package.json +14 -169
- package/packageExports.test.ts +38 -24
- package/transforms/barrelAnalyzer.ts +2 -2
- package/transforms/transforms.test.ts +3 -3
- package/tunnel/createTunnel.test.ts +29 -8
- package/tunnel/createTunnel.ts +18 -11
- package/util/fileEditor.ts +1 -0
- package/util/fileSys.test.ts +13 -0
- package/util/fileSys.ts +2 -2
- package/util/selectModel.ts +1 -0
- package/workspace/getRelatedCnsts.ts +7 -0
|
@@ -90,7 +90,7 @@ describe("createTunnel", () => {
|
|
|
90
90
|
const listener = Bun.listen({ hostname: "127.0.0.1", port: 0, socket: { data() {} } });
|
|
91
91
|
const port = listener.port;
|
|
92
92
|
listener.stop(true);
|
|
93
|
-
process.env
|
|
93
|
+
Object.assign(process.env, { SSH_TUNNEL_PORT: String(port), SSH_TUNNEL_PASSWORD: "test-password" });
|
|
94
94
|
|
|
95
95
|
let originalError: Error | undefined;
|
|
96
96
|
const connect = Client.prototype.connect;
|
|
@@ -193,7 +193,7 @@ describe("createTunnel", () => {
|
|
|
193
193
|
expect(ssh.methods.filter((method) => method !== "none")).toEqual(["password"]);
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
-
test("
|
|
196
|
+
test("a tunnel needs a configured credential and names the settings that provide one", async () => {
|
|
197
197
|
const { root, app } = track(await createTempApp("demo"));
|
|
198
198
|
const ssh = await startSshServer();
|
|
199
199
|
Object.assign(process.env, {
|
|
@@ -203,13 +203,34 @@ describe("createTunnel", () => {
|
|
|
203
203
|
//? `akan test` runs from the workspace root, whose dotenv may name a password; this case is the one with none.
|
|
204
204
|
delete process.env.SSH_TUNNEL_PASSWORD;
|
|
205
205
|
delete process.env.SSH_TUNNEL_PRIVATE_KEY_PATH;
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
const connect = spyOn(Client.prototype, "connect");
|
|
207
|
+
try {
|
|
208
|
+
await expect(createTunnel("redis", { app, environment: "testing", port: freePort() })).rejects.toThrow(
|
|
209
|
+
"The redis tunnel for demo-testing needs an SSH credential: export SSH_TUNNEL_PRIVATE_KEY_PATH",
|
|
210
|
+
);
|
|
211
|
+
await expect(createTunnel("postgres", { app, environment: "testing", port: freePort() })).rejects.toThrow(
|
|
212
|
+
"or set SSH_TUNNEL_PASSWORD",
|
|
213
|
+
);
|
|
214
|
+
expect(connect).not.toHaveBeenCalled();
|
|
215
|
+
} finally {
|
|
216
|
+
connect.mockRestore();
|
|
217
|
+
}
|
|
218
|
+
expect(ssh.methods).toEqual([]);
|
|
219
|
+
});
|
|
209
220
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
);
|
|
221
|
+
test("a key file the tunnel cannot read fails naming the tunnel, the setting and the path", async () => {
|
|
222
|
+
const { root, app } = track(await createTempApp("demo"));
|
|
223
|
+
const keyPath = path.join(root, "missing_key");
|
|
224
|
+
process.env.SSH_TUNNEL_PRIVATE_KEY_PATH = keyPath;
|
|
225
|
+
const connect = spyOn(Client.prototype, "connect");
|
|
226
|
+
try {
|
|
227
|
+
await expect(createTunnel("redis", { app, environment: "testing", port: freePort() })).rejects.toThrow(
|
|
228
|
+
`The redis tunnel for demo-testing could not read the key SSH_TUNNEL_PRIVATE_KEY_PATH names, ${keyPath} (ENOENT)`,
|
|
229
|
+
);
|
|
230
|
+
expect(connect).not.toHaveBeenCalled();
|
|
231
|
+
} finally {
|
|
232
|
+
connect.mockRestore();
|
|
233
|
+
}
|
|
213
234
|
});
|
|
214
235
|
|
|
215
236
|
test("listens where SSH_TUNNEL_BIND_HOST says and warns when that is not loopback", async () => {
|
package/tunnel/createTunnel.ts
CHANGED
|
@@ -20,19 +20,25 @@ interface TunnelOption {
|
|
|
20
20
|
port?: number;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const readTunnelKey = (purpose: string, keyPath: string) => {
|
|
24
|
+
try {
|
|
25
|
+
return readFileSync(keyPath);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
const reason = (error as NodeJS.ErrnoException).code ?? (error instanceof Error ? error.message : String(error));
|
|
28
|
+
throw new Error(`${purpose} could not read the key SSH_TUNNEL_PRIVATE_KEY_PATH names, ${keyPath} (${reason}).`, {
|
|
29
|
+
cause: error,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const tunnelAuth = (purpose: string): Pick<ConnectConfig, "privateKey" | "passphrase" | "password"> => {
|
|
27
35
|
const keyPath = tunnelEnv.get("SSH_TUNNEL_PRIVATE_KEY_PATH");
|
|
28
36
|
const passphrase = tunnelEnv.get("SSH_TUNNEL_PASSPHRASE");
|
|
29
|
-
if (keyPath) return { privateKey:
|
|
37
|
+
if (keyPath) return { privateKey: readTunnelKey(purpose, keyPath), ...(passphrase ? { passphrase } : {}) };
|
|
30
38
|
if (process.env.SSH_TUNNEL_PASSWORD) return { password: process.env.SSH_TUNNEL_PASSWORD };
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"Set SSH_TUNNEL_PRIVATE_KEY_PATH to a key (or SSH_TUNNEL_PASSWORD) once the cluster's tunnel endpoint accepts it.",
|
|
39
|
+
throw new Error(
|
|
40
|
+
`${purpose} needs an SSH credential: export SSH_TUNNEL_PRIVATE_KEY_PATH (with SSH_TUNNEL_PASSPHRASE if the key has one) in the shell, or set SSH_TUNNEL_PASSWORD.`,
|
|
34
41
|
);
|
|
35
|
-
return { password: repoName };
|
|
36
42
|
};
|
|
37
43
|
|
|
38
44
|
const tunnelHostVerifier = (app: AppExecutor, hostId: string, onRefusal: (reason: string) => void) => {
|
|
@@ -75,7 +81,8 @@ export const createTunnel = async (
|
|
|
75
81
|
const baseDevEnv = WorkspaceExecutor.getBaseDevEnv();
|
|
76
82
|
WorkspaceExecutor.assertDeployableEnv(baseDevEnv, environment, `The ${service} tunnel`);
|
|
77
83
|
for (const line of tunnelEnv.ignored()) app.logger.warn(line);
|
|
78
|
-
const
|
|
84
|
+
const auth = tunnelAuth(`The ${service} tunnel for ${app.name}-${environment}`);
|
|
85
|
+
const { serveDomain } = baseDevEnv;
|
|
79
86
|
const host = `${app.name}-${environment}.${serveDomain}`;
|
|
80
87
|
//? RFC 6761 makes *.localhost loopback, but only macOS resolves it; glibc without systemd-resolved and Windows answer ENOTFOUND
|
|
81
88
|
const sshHost = host.endsWith(".localhost") ? "localhost" : host;
|
|
@@ -101,7 +108,7 @@ export const createTunnel = async (
|
|
|
101
108
|
host: sshHost,
|
|
102
109
|
port: sshPort,
|
|
103
110
|
username: process.env.SSH_TUNNEL_USERNAME ?? "root",
|
|
104
|
-
...
|
|
111
|
+
...auth,
|
|
105
112
|
hostVerifier: tunnelHostVerifier(app, `${sshHost}:${sshPort}`, (reason) => {
|
|
106
113
|
refusal = reason;
|
|
107
114
|
}),
|
package/util/fileEditor.ts
CHANGED
package/util/fileSys.test.ts
CHANGED
|
@@ -47,3 +47,16 @@ describe("FileSys.ensurePrivateDir", () => {
|
|
|
47
47
|
},
|
|
48
48
|
);
|
|
49
49
|
});
|
|
50
|
+
|
|
51
|
+
describe("FileSys.writeTextAtomic", () => {
|
|
52
|
+
test("lands one whole write when two writes of one file start together", async () => {
|
|
53
|
+
const dir = mkdtempSync(path.join(tmpdir(), "akan-atomic-"));
|
|
54
|
+
try {
|
|
55
|
+
const file = path.join(dir, "cache.json");
|
|
56
|
+
await Promise.all([FileSys.writeTextAtomic(file, "first"), FileSys.writeTextAtomic(file, "second")]);
|
|
57
|
+
expect(["first", "second"]).toContain(await Bun.file(file).text());
|
|
58
|
+
} finally {
|
|
59
|
+
rmSync(dir, { recursive: true, force: true });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
package/util/fileSys.ts
CHANGED
|
@@ -46,8 +46,8 @@ export class FileSys {
|
|
|
46
46
|
}
|
|
47
47
|
// One `rename`, so a watcher never reads a half-written barrel as a user edit. The temp is a sibling (rename is atomic
|
|
48
48
|
// only within a filesystem), and its `.tmp` suffix is what `HmrChangeClassifier` ignores it by.
|
|
49
|
-
static async writeTextAtomic(filePath: string, content: string) {
|
|
50
|
-
const temp = `${filePath}.${process.pid}.${
|
|
49
|
+
static async writeTextAtomic(filePath: string, content: string | Uint8Array) {
|
|
50
|
+
const temp = `${filePath}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
51
51
|
try {
|
|
52
52
|
await Bun.write(temp, content);
|
|
53
53
|
await FileSys.replace(temp, filePath);
|
package/util/selectModel.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readdirSync } from "node:fs";
|
|
2
2
|
import { select } from "@inquirer/prompts";
|
|
3
3
|
|
|
4
|
+
/** @deprecated Nothing in akanjs uses it; removed in a later minor. */
|
|
4
5
|
export const selectModel = async (modulePath: string) => {
|
|
5
6
|
const modelNames = readdirSync(`${modulePath}/lib`).filter((dir) => !dir.includes(".") && !dir.startsWith("_"));
|
|
6
7
|
return await select({
|
|
@@ -41,6 +41,7 @@ const scanModuleSpecifiers = (source: string, filePath: string, includeExports:
|
|
|
41
41
|
return importSpecifiers;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
/** @deprecated Nothing in akanjs uses it; removed in a later minor. */
|
|
44
45
|
export const parseTsConfig = (tsConfigPath: string = "./tsconfig.json") => {
|
|
45
46
|
const configFile = ts.readConfigFile(tsConfigPath, (path) => {
|
|
46
47
|
return ts.sys.readFile(path);
|
|
@@ -73,12 +74,15 @@ const collectFiles = (constantFilePath: string, parsedConfig: ts.ParsedCommandLi
|
|
|
73
74
|
return { allFilesToAnalyze, analyzedFiles };
|
|
74
75
|
};
|
|
75
76
|
|
|
77
|
+
/** @deprecated Nothing in akanjs uses it; removed in a later minor. */
|
|
76
78
|
export const collectImportedFiles = (constantFilePath: string, parsedConfig: ts.ParsedCommandLine) =>
|
|
77
79
|
collectFiles(constantFilePath, parsedConfig, false);
|
|
78
80
|
|
|
81
|
+
/** @deprecated Nothing in akanjs uses it; removed in a later minor. */
|
|
79
82
|
export const collectExportedFiles = (constantFilePath: string, parsedConfig: ts.ParsedCommandLine) =>
|
|
80
83
|
collectFiles(constantFilePath, parsedConfig, true);
|
|
81
84
|
|
|
85
|
+
/** @deprecated Nothing in akanjs uses it; removed in a later minor. */
|
|
82
86
|
export const createTsProgram = (filePaths: Set<string>, options: ts.CompilerOptions) => {
|
|
83
87
|
const spinner = ora("Creating TypeScript program for all files...");
|
|
84
88
|
spinner.start();
|
|
@@ -94,6 +98,7 @@ export const createTsProgram = (filePaths: Set<string>, options: ts.CompilerOpti
|
|
|
94
98
|
};
|
|
95
99
|
};
|
|
96
100
|
|
|
101
|
+
/** @deprecated Nothing in akanjs uses it; removed in a later minor. */
|
|
97
102
|
export const createSymbolCache = (checker: ts.TypeChecker) => {
|
|
98
103
|
const symbolCache = new Map<string, ts.Symbol | undefined>();
|
|
99
104
|
|
|
@@ -108,6 +113,7 @@ export const createSymbolCache = (checker: ts.TypeChecker) => {
|
|
|
108
113
|
};
|
|
109
114
|
};
|
|
110
115
|
|
|
116
|
+
/** @deprecated Nothing in akanjs uses it; removed in a later minor. */
|
|
111
117
|
export const analyzeProperties = (filesToAnalyze: Set<string>, program: ts.Program, checker: ts.TypeChecker) => {
|
|
112
118
|
const propertyMap = new Map<
|
|
113
119
|
string,
|
|
@@ -226,6 +232,7 @@ export const analyzeProperties = (filesToAnalyze: Set<string>, program: ts.Progr
|
|
|
226
232
|
return propertyMap;
|
|
227
233
|
};
|
|
228
234
|
|
|
235
|
+
/** @deprecated Nothing in akanjs uses it; removed in a later minor. */
|
|
229
236
|
export const getRelatedCnsts = (constantFilePath: string) => {
|
|
230
237
|
const parsedConfig = parseTsConfig();
|
|
231
238
|
const { allFilesToAnalyze } = collectImportedFiles(constantFilePath, parsedConfig);
|