@akanjs/cli 3.1.1 → 3.1.2-rc.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/.build-stamp +1 -1
- package/CodeAgent-dyc45f5w.js +11 -0
- package/{CodeAgentRpcHost-9g27hmer.js → CodeAgentRpcHost-6dzfkvsc.js} +1 -1
- package/CodeAgentRpcListener-tcwrdvst.js +182 -0
- package/{CodeTui-h6yz2kvq.js → CodeTui-q55b2zrn.js} +25 -8
- package/TunnelShare-hdq9h1hr.js +14 -0
- package/{agent.command-3r4jsck8.js → agent.command-20zaqe60.js} +18 -15
- package/akanCode.js +8 -7
- package/{application.command-g7xv6ad0.js → application.command-nd0fshsk.js} +11 -11
- package/{applicationBuildRunner-qvjnhr9j.js → applicationBuildRunner-s13x3zqb.js} +10 -9
- package/buildBatch.proc.js +6 -6
- package/{cloud.command-6ebygmhw.js → cloud.command-8kbddsz9.js} +25 -18
- package/cloud.script-hgvvajm3.js +27 -0
- package/code.command-625bg8s8.js +345 -0
- package/{context.command-svdh6b2w.js → context.command-p6haqjay.js} +19 -18
- package/context.runner-rsnqnk9j.js +27 -0
- package/{dependencyScanner-3afj2vt1.js → dependencyScanner-78sq8m4q.js} +2 -2
- package/{fileSys-wzzrntkw.js → fileSys-zpvt5gtf.js} +1 -1
- package/{guideline.command-qwp3tnjx.js → guideline.command-195g0h9a.js} +4 -4
- package/guidelines/agentRule/agentRule.instruction.md +22 -8
- package/guidelines/conventions/rules/auth.md +5 -4
- package/guidelines/conventions/rules/config.md +5 -1
- package/guidelines/conventions/rules/gates.md +2 -1
- package/guidelines/conventions/rules/module.md +1 -1
- package/guidelines/conventions/rules/server.md +8 -3
- package/guidelines/conventions/rules/ssr.md +2 -2
- package/guidelines/conventions/rules/tsx.md +2 -1
- package/guidelines/pageRule/pageRule.instruction.md +4 -4
- package/guidelines/runtimeRule/runtimeRule.instruction.md +35 -25
- package/guidelines/ssrRule/ssrRule.instruction.md +11 -10
- package/guidelines/transportRule/transportRule.instruction.md +5 -4
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +1 -1
- package/incrementalBuilder.proc.js +4 -4
- package/{index-w4k2ragk.js → index-00a7j05x.js} +7 -7
- package/{index-w7q6h97v.js → index-0j1t1h2b.js} +3 -1
- package/{index-payhwt51.js → index-1h2jc0x3.js} +141 -67
- package/{index-vxmy1p4f.js → index-1qsd8ft1.js} +63 -123
- package/{index-s6da8ta9.js → index-2mwjshz5.js} +158 -51
- package/index-2nxk8wgs.js +266 -0
- package/{index-k5jbcxyh.js → index-2phm56a1.js} +49 -8
- package/{index-jje9qzyq.js → index-35j83zkd.js} +37 -3
- package/{index-m5n3ka0p.js → index-4am4dvmf.js} +13 -2
- package/index-75y7bcz4.js +28 -0
- package/{index-b8c289dx.js → index-7apsdr5g.js} +55 -12
- package/{index-8559hsz4.js → index-84h43kg6.js} +6 -5
- package/{index-eja64h28.js → index-9zy8479y.js} +5 -3
- package/{index-96wzdhfh.js → index-a1vb3x7t.js} +209 -36
- package/{index-52w0fvh8.js → index-bns3wcpc.js} +15 -0
- package/{index-am36s3jh.js → index-cjmjvg4r.js} +157 -117
- package/{index-1p0qbq3m.js → index-defp4gmb.js} +1 -1
- package/{index-4pdts00b.js → index-ewbmfarf.js} +10 -8
- package/{index-9rvcs76p.js → index-fhw7yq2d.js} +10 -10
- package/{index-8scw1pjk.js → index-g500c5j9.js} +178 -82
- package/{index-qxzrp5xt.js → index-g841cap9.js} +4 -4
- package/{index-qkkdhjm6.js → index-gr9thy79.js} +5 -5
- package/{index-4pf8g7ff.js → index-h7hehkw6.js} +3 -0
- package/{index-4mj92tsh.js → index-hm0tn7qv.js} +73 -68
- package/{index-r2wedvqn.js → index-j6eeh5d7.js} +1 -1
- package/{index-tgt2fnd6.js → index-j7hwy56s.js} +3 -3
- package/{index-rnphv731.js → index-jc2zbwra.js} +2 -2
- package/{index-z4b84y6k.js → index-khk05tsf.js} +1 -1
- package/{index-tvehn2sp.js → index-qd7xn2bk.js} +1 -1
- package/{index-266dewjs.js → index-qw6814m4.js} +53 -15
- package/{index-zcf6k8a5.js → index-raz588b3.js} +47 -12
- package/{index-at7bz0xq.js → index-s4nvxpzm.js} +2 -0
- package/{index-3yz30c07.js → index-sp0qsr7a.js} +114 -12
- package/{index-1shvxzt0.js → index-sveq36gh.js} +39 -42
- package/{index-r2w2eh93.js → index-t1t9wq9a.js} +4 -4
- package/index-t78230d7.js +191 -0
- package/{index-r0k3ham2.js → index-tgqameyb.js} +4 -4
- package/{index-dd44g6vz.js → index-tp56652m.js} +5 -5
- package/index-w15mg3km.js +389 -0
- package/{index-xq543a5y.js → index-y4kcmbt2.js} +2 -2
- package/index-yf9wc28h.js +52 -0
- package/{index-xqgwjz7a.js → index-zbrwnmf1.js} +9 -7
- package/{index-xxfy1jp2.js → index-zttm13c3.js} +4 -4
- package/index.js +24 -24
- package/{library.command-2853y6mk.js → library.command-63hgt9te.js} +4 -4
- package/{localRegistry.command-76ds31p4.js → localRegistry.command-g3f8k25t.js} +43 -23
- package/{module.command-yfnb0abs.js → module.command-r4sa2khp.js} +7 -6
- package/{package.command-d9s86hp9.js → package.command-96eheyvd.js} +5 -5
- package/package.json +2 -2
- package/{page.command-6a8a8rd1.js → page.command-gs6d841d.js} +4 -4
- package/{pipeline.command-rt3rwd2z.js → pipeline.command-wdfvdbfj.js} +3 -3
- package/{primitive.command-emcebgrq.js → primitive.command-dfsv4mpe.js} +8 -7
- package/{projectTypecheck-51m7eh1f.js → projectTypecheck-kqj1t6hb.js} +1 -1
- package/{prompter-hgcta8pb.js → prompter-qrwx1p17.js} +2 -2
- package/{quality.command-xtrk0n3x.js → quality.command-webzxee2.js} +6 -4
- package/{repair.command-51szxnxx.js → repair.command-3r3j1xre.js} +7 -6
- package/{scalar.command-8qv27t82.js → scalar.command-e8y47j6d.js} +6 -5
- package/skills/akan-agent/SKILL.md +8 -1
- package/skills/akan-code/SKILL.md +37 -11
- package/skills/akan-debug/SKILL.md +2 -1
- package/skills/akan-err/SKILL.md +2 -1
- package/skills/akan-query/SKILL.md +3 -2
- package/skills/akan-runtime/SKILL.md +3 -0
- package/{subspace.command-pn56pnh8.js → subspace.command-a1sf9n5a.js} +12 -10
- package/templates/appSample/lib/task/task.signal.ts +14 -9
- package/templates/appSample/srvkit/guards.ts +11 -0
- package/templates/service/__model__.dictionary.ts +3 -5
- package/templates/workspaceRoot/.gitignore.template +1 -0
- package/{tunnel.command-q2h0j2en.js → tunnel.command-dcb0wg93.js} +25 -13
- package/{verify.command-z1dsbmrt.js → verify.command-yyepccbh.js} +13 -11
- package/{workflow.command-r3y67jeq.js → workflow.command-z5pg9ay0.js} +12 -11
- package/{workspace.command-t2f0xsrw.js → workspace.command-d7x5jttw.js} +74 -47
- package/CodeAgent-35wnb7w5.js +0 -9
- package/CodeAgentRpcListener-7p7z5dd7.js +0 -97
- package/TunnelShare-xyjpa7gx.js +0 -14
- package/cloud.script-0s1jybd5.js +0 -26
- package/code.command-mpkm2emr.js +0 -167
- package/context.runner-ch0z3a8g.js +0 -26
- package/index-c6eggbee.js +0 -123
- package/index-ksfgqq1x.js +0 -49
|
@@ -7,7 +7,10 @@ import {
|
|
|
7
7
|
AppExecutor,
|
|
8
8
|
LibExecutor,
|
|
9
9
|
PkgExecutor
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-g500c5j9.js";
|
|
11
|
+
import {
|
|
12
|
+
FileSys2
|
|
13
|
+
} from "./index-bns3wcpc.js";
|
|
11
14
|
import {
|
|
12
15
|
UNAVAILABLE_REDIS_HOST,
|
|
13
16
|
redisTunnelPolicy,
|
|
@@ -48,35 +51,91 @@ import {
|
|
|
48
51
|
runner,
|
|
49
52
|
ExitCodeError,
|
|
50
53
|
assertPromptable
|
|
51
|
-
} from "./index-
|
|
54
|
+
} from "./index-9zy8479y.js";
|
|
52
55
|
import {
|
|
53
56
|
UpdatePackFolder,
|
|
54
57
|
UpdateUploader,
|
|
55
58
|
NativePublicEnv,
|
|
56
59
|
NativeApp
|
|
57
|
-
} from "./index-
|
|
60
|
+
} from "./index-sp0qsr7a.js";
|
|
58
61
|
import {
|
|
59
62
|
DesktopServerStage
|
|
60
|
-
} from "./index-
|
|
63
|
+
} from "./index-0j1t1h2b.js";
|
|
61
64
|
import {
|
|
62
65
|
resolveMobileTargets,
|
|
63
66
|
resolveAppId
|
|
64
67
|
} from "./index-m9jj544v.js";
|
|
65
68
|
import {
|
|
66
69
|
SlicePlanner
|
|
67
|
-
} from "./index-
|
|
70
|
+
} from "./index-defp4gmb.js";
|
|
68
71
|
import {
|
|
69
72
|
openBrowser
|
|
70
73
|
} from "./index-9dp031by.js";
|
|
74
|
+
import {
|
|
75
|
+
ShellOnlyEnv
|
|
76
|
+
} from "./index-yf9wc28h.js";
|
|
77
|
+
import {
|
|
78
|
+
ConfigLock
|
|
79
|
+
} from "./index-bqbf654f.js";
|
|
71
80
|
|
|
72
81
|
// pkgs/@akanjs/cli/application/application.runner.ts
|
|
73
82
|
import { existsSync, realpathSync } from "fs";
|
|
74
|
-
import
|
|
83
|
+
import path6 from "path";
|
|
75
84
|
|
|
76
85
|
// pkgs/@akanjs/devkit/akanApp/akanApp.host.ts
|
|
77
|
-
import
|
|
86
|
+
import path4 from "path";
|
|
78
87
|
import { Logger as Logger2 } from "akanjs/common";
|
|
79
88
|
|
|
89
|
+
// pkgs/@akanjs/devkit/createTunnel.ts
|
|
90
|
+
import { readFileSync } from "fs";
|
|
91
|
+
|
|
92
|
+
// pkgs/@akanjs/devkit/sshHostKeys.ts
|
|
93
|
+
import { createHash } from "crypto";
|
|
94
|
+
import { mkdir, rm, writeFile } from "fs/promises";
|
|
95
|
+
import path from "path";
|
|
96
|
+
class SshHostKeys {
|
|
97
|
+
static defaultPath() {
|
|
98
|
+
return path.join(Bun.env.HOME ?? Bun.env.USERPROFILE ?? "", ".akan", "ssh_known_hosts.json");
|
|
99
|
+
}
|
|
100
|
+
static fingerprintOf(key) {
|
|
101
|
+
return `SHA256:${createHash("sha256").update(key).digest("base64").replace(/=+$/, "")}`;
|
|
102
|
+
}
|
|
103
|
+
static parsePinned(value) {
|
|
104
|
+
return (value ?? "").split(",").map((fingerprint) => fingerprint.trim()).filter(Boolean).map((fingerprint) => fingerprint.startsWith("SHA256:") ? fingerprint : `SHA256:${fingerprint}`);
|
|
105
|
+
}
|
|
106
|
+
filePath;
|
|
107
|
+
constructor(filePath = SshHostKeys.defaultPath()) {
|
|
108
|
+
this.filePath = filePath;
|
|
109
|
+
}
|
|
110
|
+
async verify(hostId, key, pinned = []) {
|
|
111
|
+
const fingerprint = SshHostKeys.fingerprintOf(key);
|
|
112
|
+
if (pinned.length)
|
|
113
|
+
return { trusted: pinned.includes(fingerprint), firstUse: false, fingerprint };
|
|
114
|
+
return await ConfigLock.run(`${this.filePath}.lock`, async () => {
|
|
115
|
+
const known = await this.#read();
|
|
116
|
+
const stored = known[hostId];
|
|
117
|
+
if (stored)
|
|
118
|
+
return { trusted: stored === fingerprint, firstUse: false, fingerprint };
|
|
119
|
+
await this.#write({ ...known, [hostId]: fingerprint });
|
|
120
|
+
return { trusted: true, firstUse: true, fingerprint };
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async#read() {
|
|
124
|
+
return await FileSys2.fileExists(this.filePath) ? await FileSys2.readJson(this.filePath) : {};
|
|
125
|
+
}
|
|
126
|
+
async#write(known) {
|
|
127
|
+
await mkdir(path.dirname(this.filePath), { recursive: true, mode: 448 });
|
|
128
|
+
const temp = `${this.filePath}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
129
|
+
try {
|
|
130
|
+
await writeFile(temp, JSON.stringify(known, null, 2), { mode: 384 });
|
|
131
|
+
await FileSys2.replace(temp, this.filePath);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
await rm(temp, { force: true });
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
80
139
|
// pkgs/@akanjs/devkit/sshTunnel.ts
|
|
81
140
|
import { Client } from "ssh2";
|
|
82
141
|
var closeQuietly = (close) => {
|
|
@@ -186,38 +245,86 @@ var closeBunSocket = (socket, error) => {
|
|
|
186
245
|
};
|
|
187
246
|
|
|
188
247
|
// pkgs/@akanjs/devkit/createTunnel.ts
|
|
248
|
+
var tunnelEnv = new ShellOnlyEnv([
|
|
249
|
+
"SSH_TUNNEL_PRIVATE_KEY_PATH",
|
|
250
|
+
"SSH_TUNNEL_PASSPHRASE",
|
|
251
|
+
"SSH_TUNNEL_HOST_FINGERPRINT",
|
|
252
|
+
"SSH_TUNNEL_KNOWN_HOSTS",
|
|
253
|
+
"SSH_TUNNEL_BIND_HOST"
|
|
254
|
+
]);
|
|
255
|
+
var tunnelAuth = (app, repoName) => {
|
|
256
|
+
const keyPath = tunnelEnv.get("SSH_TUNNEL_PRIVATE_KEY_PATH");
|
|
257
|
+
const passphrase = tunnelEnv.get("SSH_TUNNEL_PASSPHRASE");
|
|
258
|
+
if (keyPath)
|
|
259
|
+
return { privateKey: readFileSync(keyPath), ...passphrase ? { passphrase } : {} };
|
|
260
|
+
if (process.env.SSH_TUNNEL_PASSWORD)
|
|
261
|
+
return { password: process.env.SSH_TUNNEL_PASSWORD };
|
|
262
|
+
app.logger.warn("The SSH tunnel uses the default shared credential. " + "Set SSH_TUNNEL_PRIVATE_KEY_PATH to a key (or SSH_TUNNEL_PASSWORD) once the cluster's tunnel endpoint accepts it.");
|
|
263
|
+
return { password: repoName };
|
|
264
|
+
};
|
|
265
|
+
var tunnelHostVerifier = (app, hostId, onRefusal) => {
|
|
266
|
+
const pinned = SshHostKeys.parsePinned(tunnelEnv.get("SSH_TUNNEL_HOST_FINGERPRINT"));
|
|
267
|
+
const hostKeys = new SshHostKeys(tunnelEnv.get("SSH_TUNNEL_KNOWN_HOSTS") || undefined);
|
|
268
|
+
return (key, verify) => {
|
|
269
|
+
if (pinned.includes("SHA256:*")) {
|
|
270
|
+
app.logger.warn(`SSH_TUNNEL_HOST_FINGERPRINT=* accepts any host key ${hostId} shows.`);
|
|
271
|
+
verify(true);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
hostKeys.verify(hostId, key, pinned).then(({ trusted, firstUse, fingerprint }) => {
|
|
275
|
+
if (firstUse)
|
|
276
|
+
app.logger.warn(`Trusting the SSH host key ${fingerprint} of ${hostId} on first use; kept in ${hostKeys.filePath}.`);
|
|
277
|
+
if (!trusted)
|
|
278
|
+
onRefusal(pinned.length ? `the host key ${fingerprint} of ${hostId} is not one SSH_TUNNEL_HOST_FINGERPRINT pins` : `the host key ${fingerprint} of ${hostId} differs from the one ${hostKeys.filePath} keeps; if the host was rebuilt, remove its entry or pin the new key with SSH_TUNNEL_HOST_FINGERPRINT`);
|
|
279
|
+
verify(trusted);
|
|
280
|
+
}, (error) => {
|
|
281
|
+
onRefusal(`the host key store ${hostKeys.filePath} could not be read (${error instanceof Error ? error.message : String(error)})`);
|
|
282
|
+
verify(false);
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
};
|
|
189
286
|
var createTunnel = async (service, { app, environment, port = service === "postgres" ? 5432 : 6379 }) => {
|
|
190
287
|
const baseDevEnv = WorkspaceExecutor.getBaseDevEnv();
|
|
191
288
|
WorkspaceExecutor.assertDeployableEnv(baseDevEnv, environment, `The ${service} tunnel`);
|
|
289
|
+
for (const line of tunnelEnv.ignored())
|
|
290
|
+
app.logger.warn(line);
|
|
192
291
|
const { serveDomain, repoName } = baseDevEnv;
|
|
193
292
|
const host = `${app.name}-${environment}.${serveDomain}`;
|
|
293
|
+
const sshHost = host.endsWith(".localhost") ? "localhost" : host;
|
|
194
294
|
const sshPort = process.env.SSH_TUNNEL_PORT ? parseInt(process.env.SSH_TUNNEL_PORT) : 32767;
|
|
195
295
|
const dstHost = `${service}-0.${service}-svc.${app.name}-${environment}.svc.cluster.local`;
|
|
196
296
|
const dstPort = service === "postgres" ? 5432 : 6379;
|
|
297
|
+
const bindHost = tunnelEnv.get("SSH_TUNNEL_BIND_HOST") || "127.0.0.1";
|
|
298
|
+
if (!["127.0.0.1", "localhost", "::1"].includes(bindHost))
|
|
299
|
+
app.logger.warn(`The ${service} tunnel listens on ${bindHost} (SSH_TUNNEL_BIND_HOST), so other machines that reach it reach ${dstHost}.`);
|
|
300
|
+
let refusal = null;
|
|
197
301
|
try {
|
|
198
302
|
await createSshTunnel({
|
|
199
|
-
localHost:
|
|
303
|
+
localHost: bindHost,
|
|
200
304
|
localPort: port,
|
|
201
|
-
srcHost: "
|
|
305
|
+
srcHost: "127.0.0.1",
|
|
202
306
|
srcPort: port,
|
|
203
307
|
dstHost,
|
|
204
308
|
dstPort,
|
|
205
309
|
sshOptions: {
|
|
206
|
-
host:
|
|
310
|
+
host: sshHost,
|
|
207
311
|
port: sshPort,
|
|
208
312
|
username: process.env.SSH_TUNNEL_USERNAME ?? "root",
|
|
209
|
-
|
|
313
|
+
...tunnelAuth(app, repoName),
|
|
314
|
+
hostVerifier: tunnelHostVerifier(app, `${sshHost}:${sshPort}`, (reason) => {
|
|
315
|
+
refusal = reason;
|
|
316
|
+
})
|
|
210
317
|
}
|
|
211
318
|
});
|
|
212
319
|
} catch (error) {
|
|
213
320
|
const reasons = error instanceof AggregateError ? error.errors.map((reason) => reason instanceof Error ? reason.message : String(reason)).join("; ") : error instanceof Error ? error.message : String(error);
|
|
214
|
-
throw new Error(`Could not open the ${service} tunnel for ${app.name}-${environment}: SSH ${host}:${sshPort} -> ${dstHost}:${dstPort} failed (${reasons})`, { cause: error });
|
|
321
|
+
throw new Error(`Could not open the ${service} tunnel for ${app.name}-${environment}: SSH ${host}:${sshPort} -> ${dstHost}:${dstPort} failed (${refusal ?? reasons})`, { cause: error });
|
|
215
322
|
}
|
|
216
323
|
return `localhost:${port}`;
|
|
217
324
|
};
|
|
218
325
|
// pkgs/@akanjs/devkit/incrementalBuilder/incrementalBuilder.host.ts
|
|
219
326
|
import fs from "fs";
|
|
220
|
-
import
|
|
327
|
+
import path2 from "path";
|
|
221
328
|
import { Logger } from "akanjs/common";
|
|
222
329
|
import { CSR_DEV_DIRNAME, CSR_DEV_PATCHING_MARKER, SSR_DEV_DIRNAME } from "akanjs/server/hmr/csrDevManifest";
|
|
223
330
|
import { MemoryLimit } from "akanjs/server/memoryLimit";
|
|
@@ -364,7 +471,7 @@ class IncrementalBuilderHost {
|
|
|
364
471
|
this.logger.verbose(`builder spawned pid=${proc.pid} entry=${this.entry}${isRestart ? " restart=1" : ""}`);
|
|
365
472
|
}
|
|
366
473
|
#checkPatchingMarker(afterCrash) {
|
|
367
|
-
const markers = [CSR_DEV_DIRNAME, SSR_DEV_DIRNAME].map((dirName) =>
|
|
474
|
+
const markers = [CSR_DEV_DIRNAME, SSR_DEV_DIRNAME].map((dirName) => path2.join(this.app.cwdPath, ".akan/artifact", dirName, CSR_DEV_PATCHING_MARKER)).filter((marker) => fs.existsSync(marker));
|
|
368
475
|
if (markers.length === 0)
|
|
369
476
|
return;
|
|
370
477
|
if (afterCrash && !this.#patcherOff) {
|
|
@@ -483,10 +590,10 @@ class IncrementalBuilderHost {
|
|
|
483
590
|
patcherOff = false
|
|
484
591
|
} = {}) {
|
|
485
592
|
const candidates = [
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
593
|
+
path2.join(app.workspace.workspaceRoot, "pkgs/@akanjs/devkit/incrementalBuilder/incrementalBuilder.proc.ts"),
|
|
594
|
+
path2.join(app.workspace.workspaceRoot, "node_modules/@akanjs/devkit/incrementalBuilder/incrementalBuilder.proc.ts"),
|
|
595
|
+
path2.join(import.meta.dir, "incrementalBuilder.proc.js"),
|
|
596
|
+
path2.join(import.meta.dir, "incrementalBuilder.proc.ts")
|
|
490
597
|
];
|
|
491
598
|
for (const c of candidates)
|
|
492
599
|
if (await Bun.file(c).exists())
|
|
@@ -531,7 +638,7 @@ class BuilderRequestRouter {
|
|
|
531
638
|
|
|
532
639
|
// pkgs/@akanjs/devkit/akanApp/BackendImportGraph.ts
|
|
533
640
|
import { stat } from "fs/promises";
|
|
534
|
-
import
|
|
641
|
+
import path3 from "path";
|
|
535
642
|
var NON_SOURCE_EXT_RE = /\.(css|scss|sass|less|json|svg|png|jpe?g|webp|gif|avif|ico|woff2?|ttf|otf|mp3|mp4|wav|html)$/i;
|
|
536
643
|
var GRAPH_IMPORT_KINDS = new Set([
|
|
537
644
|
"import-statement",
|
|
@@ -562,7 +669,7 @@ class BackendImportGraph {
|
|
|
562
669
|
return this.#lastRefreshSucceeded;
|
|
563
670
|
}
|
|
564
671
|
has(file) {
|
|
565
|
-
return this.#files.has(
|
|
672
|
+
return this.#files.has(path3.resolve(file));
|
|
566
673
|
}
|
|
567
674
|
async fingerprint() {
|
|
568
675
|
const stamps = await Promise.all([...this.#files].map(async (file) => {
|
|
@@ -590,9 +697,9 @@ class BackendImportGraph {
|
|
|
590
697
|
const roots = await this.#entrypoints();
|
|
591
698
|
const files = new Set;
|
|
592
699
|
const queue = [...roots];
|
|
593
|
-
const workspaceRoot =
|
|
700
|
+
const workspaceRoot = path3.resolve(this.#app.workspace.workspaceRoot);
|
|
594
701
|
while (queue.length > 0) {
|
|
595
|
-
const current =
|
|
702
|
+
const current = path3.resolve(queue.pop());
|
|
596
703
|
if (files.has(current))
|
|
597
704
|
continue;
|
|
598
705
|
if (!this.#isWorkspaceSource(current, workspaceRoot))
|
|
@@ -601,7 +708,7 @@ class BackendImportGraph {
|
|
|
601
708
|
if (!imports)
|
|
602
709
|
continue;
|
|
603
710
|
files.add(current);
|
|
604
|
-
const importerDir =
|
|
711
|
+
const importerDir = path3.dirname(current);
|
|
605
712
|
for (const imp of imports) {
|
|
606
713
|
if (!GRAPH_IMPORT_KINDS.has(imp.kind) || !imp.path || NON_SOURCE_EXT_RE.test(imp.path))
|
|
607
714
|
continue;
|
|
@@ -632,7 +739,7 @@ class BackendImportGraph {
|
|
|
632
739
|
const roots = [`${this.#app.cwdPath}/main.ts`, `${this.#app.cwdPath}/server.ts`];
|
|
633
740
|
const existing = [];
|
|
634
741
|
for (const root of roots) {
|
|
635
|
-
const abs =
|
|
742
|
+
const abs = path3.resolve(root);
|
|
636
743
|
if (await Bun.file(abs).exists())
|
|
637
744
|
existing.push(abs);
|
|
638
745
|
}
|
|
@@ -641,25 +748,25 @@ class BackendImportGraph {
|
|
|
641
748
|
#resolve(specifier, importerDir) {
|
|
642
749
|
try {
|
|
643
750
|
const resolved = Bun.resolveSync(specifier, importerDir);
|
|
644
|
-
if (!
|
|
751
|
+
if (!path3.isAbsolute(resolved))
|
|
645
752
|
return null;
|
|
646
|
-
if (!SOURCE_EXTS.has(
|
|
753
|
+
if (!SOURCE_EXTS.has(path3.extname(resolved).toLowerCase()))
|
|
647
754
|
return null;
|
|
648
|
-
return
|
|
755
|
+
return path3.resolve(resolved);
|
|
649
756
|
} catch {
|
|
650
757
|
return null;
|
|
651
758
|
}
|
|
652
759
|
}
|
|
653
760
|
#isWorkspaceSource(file, workspaceRoot) {
|
|
654
|
-
const rel =
|
|
655
|
-
if (rel.startsWith("..") ||
|
|
761
|
+
const rel = path3.relative(workspaceRoot, file);
|
|
762
|
+
if (rel.startsWith("..") || path3.isAbsolute(rel))
|
|
656
763
|
return false;
|
|
657
|
-
if (rel.includes(`${
|
|
764
|
+
if (rel.includes(`${path3.sep}node_modules${path3.sep}`) || rel.includes(`${path3.sep}.akan${path3.sep}`))
|
|
658
765
|
return false;
|
|
659
|
-
return SOURCE_EXTS.has(
|
|
766
|
+
return SOURCE_EXTS.has(path3.extname(file).toLowerCase());
|
|
660
767
|
}
|
|
661
768
|
#scanImports(file, source) {
|
|
662
|
-
const ext =
|
|
769
|
+
const ext = path3.extname(file).toLowerCase();
|
|
663
770
|
if (ext === ".tsx")
|
|
664
771
|
return this.#tsxTranspiler.scanImports(source);
|
|
665
772
|
if (ext === ".jsx")
|
|
@@ -1693,7 +1800,7 @@ ${this.#backendStderrTail.join(`
|
|
|
1693
1800
|
const generation = message.devPlan?.generation ?? message.generation ?? this.#nextBackendBuildStatusGeneration();
|
|
1694
1801
|
const detail = err instanceof Error ? err.message : String(err);
|
|
1695
1802
|
this.logger.warn(`[dev-host] ${kind.toLowerCase()} restart failed generation=${generation}: ${detail}`);
|
|
1696
|
-
const names = message.files.slice(0, 3).map((file) =>
|
|
1803
|
+
const names = message.files.slice(0, 3).map((file) => path4.basename(file));
|
|
1697
1804
|
const saved = names.length > 0 ? names.join(", ") : "the changed file";
|
|
1698
1805
|
const status = {
|
|
1699
1806
|
generation,
|
|
@@ -1874,16 +1981,16 @@ ${this.#backendStderrTail.join(`
|
|
|
1874
1981
|
}
|
|
1875
1982
|
}
|
|
1876
1983
|
// pkgs/@akanjs/devkit/applicationTestPreload.ts
|
|
1877
|
-
import
|
|
1984
|
+
import path5 from "path";
|
|
1878
1985
|
var SIGNAL_TEST_PRELOAD_PATH = "test/signalTest.preload.ts";
|
|
1879
1986
|
async function resolveSignalTestPreloadPath(target) {
|
|
1880
1987
|
const candidates = [];
|
|
1881
|
-
for (const basePath of [target.cwdPath, process.cwd(),
|
|
1988
|
+
for (const basePath of [target.cwdPath, process.cwd(), path5.dirname(Bun.main), import.meta.dir]) {
|
|
1882
1989
|
try {
|
|
1883
|
-
candidates.push(
|
|
1990
|
+
candidates.push(path5.join(path5.dirname(Bun.resolveSync("akanjs/package.json", basePath)), SIGNAL_TEST_PRELOAD_PATH));
|
|
1884
1991
|
} catch {}
|
|
1885
1992
|
}
|
|
1886
|
-
candidates.push(
|
|
1993
|
+
candidates.push(path5.join(target.cwdPath, "../../node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path5.join(target.cwdPath, "../../pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path5.join(process.cwd(), "node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path5.join(process.cwd(), "pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path5.join(path5.dirname(Bun.main), "../../akanjs", SIGNAL_TEST_PRELOAD_PATH), path5.resolve(import.meta.dir, "../../akanjs", SIGNAL_TEST_PRELOAD_PATH));
|
|
1887
1994
|
const uniqueCandidates = [...new Set(candidates)];
|
|
1888
1995
|
for (const candidate of uniqueCandidates)
|
|
1889
1996
|
if (await Bun.file(candidate).exists())
|
|
@@ -1896,7 +2003,7 @@ ${uniqueCandidates.map((candidate) => ` - ${candidate}`).join(`
|
|
|
1896
2003
|
|
|
1897
2004
|
// pkgs/@akanjs/cli/application/application.runner.ts
|
|
1898
2005
|
import { Logger as Logger3, toError } from "akanjs/common";
|
|
1899
|
-
var loadBuildRunner = async () => (await import("./applicationBuildRunner-
|
|
2006
|
+
var loadBuildRunner = async () => (await import("./applicationBuildRunner-s13x3zqb.js")).ApplicationBuildRunner;
|
|
1900
2007
|
var loadPrompts = async () => await import("@inquirer/prompts");
|
|
1901
2008
|
|
|
1902
2009
|
class ApplicationRunner extends runner("application") {
|
|
@@ -1948,7 +2055,7 @@ class ApplicationRunner extends runner("application") {
|
|
|
1948
2055
|
});
|
|
1949
2056
|
}
|
|
1950
2057
|
static runtimeDirOf(app, override) {
|
|
1951
|
-
return
|
|
2058
|
+
return path6.resolve(override ?? process.env.AKAN_RUNTIME_DIR ?? path6.join(app.workspace.workspaceRoot, "local", "apps", app.name, "runtime"));
|
|
1952
2059
|
}
|
|
1953
2060
|
async runLogs(app, options) {
|
|
1954
2061
|
const { LogControlUnavailableError, LogTailClient } = await import("akanjs/server/logging/logTailClient");
|
|
@@ -1974,7 +2081,7 @@ class ApplicationRunner extends runner("application") {
|
|
|
1974
2081
|
});
|
|
1975
2082
|
} catch (error) {
|
|
1976
2083
|
if (error instanceof LogControlUnavailableError)
|
|
1977
|
-
throw new Error(`${app.name} is not running (no ${
|
|
2084
|
+
throw new Error(`${app.name} is not running (no ${path6.basename(socketPath)} in ${runtimeDir}). Start it with \`akan start ${app.name}\`, or pass --runtime-dir for a built app.`);
|
|
1978
2085
|
throw error;
|
|
1979
2086
|
}
|
|
1980
2087
|
const sinceMs = since ? LogQueryMatcher.parseSince(since) : undefined;
|
|
@@ -2036,7 +2143,7 @@ try {
|
|
|
2036
2143
|
const serverPath = `${app.cwdPath}/server.ts`;
|
|
2037
2144
|
if (!await app.exists("server.ts"))
|
|
2038
2145
|
throw new Error(`Server file not found: apps/${app.name}/server.ts`);
|
|
2039
|
-
const target =
|
|
2146
|
+
const target = path6.resolve(app.workspace.workspaceRoot, dir);
|
|
2040
2147
|
const code = `
|
|
2041
2148
|
const { server } = await import(${JSON.stringify(serverPath)});
|
|
2042
2149
|
const { DatabaseAdaptorRole, DocumentTransfer } = await import("akanjs/service");
|
|
@@ -2097,7 +2204,7 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2097
2204
|
await new (await loadBuildRunner())(app).typecheck(options);
|
|
2098
2205
|
}
|
|
2099
2206
|
async typecheckLibrary(lib, options = {}) {
|
|
2100
|
-
const { ProjectTypecheck } = await import("./projectTypecheck-
|
|
2207
|
+
const { ProjectTypecheck } = await import("./projectTypecheck-kqj1t6hb.js");
|
|
2101
2208
|
const root = lib.workspace.workspaceRoot;
|
|
2102
2209
|
await new ProjectTypecheck(lib.cwdPath, root, { ...process.env, AKAN_WORKSPACE_ROOT: root }).run([
|
|
2103
2210
|
"../../server.ts",
|
|
@@ -2110,15 +2217,15 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2110
2217
|
}
|
|
2111
2218
|
resolveTestPaths(exec, files) {
|
|
2112
2219
|
const root = exec instanceof SysExecutor || exec instanceof PkgExecutor ? exec.workspace.workspaceRoot : process.cwd();
|
|
2113
|
-
const target =
|
|
2114
|
-
const isInside = (relative) => relative !== ".." && !relative.startsWith(`..${
|
|
2220
|
+
const target = path6.relative(root, exec.cwdPath).split(path6.sep).join("/");
|
|
2221
|
+
const isInside = (relative) => relative !== ".." && !relative.startsWith(`..${path6.sep}`) && !path6.isAbsolute(relative);
|
|
2115
2222
|
return files.map((file) => {
|
|
2116
|
-
const candidates =
|
|
2117
|
-
const existing = candidates.filter((candidate) => existsSync(candidate)).map((candidate) =>
|
|
2223
|
+
const candidates = path6.isAbsolute(file) ? [file] : [path6.resolve(exec.cwdPath, file), path6.resolve(root, file)];
|
|
2224
|
+
const existing = candidates.filter((candidate) => existsSync(candidate)).map((candidate) => path6.relative(exec.cwdPath, candidate));
|
|
2118
2225
|
const found = existing.find(isInside);
|
|
2119
2226
|
if (found === undefined)
|
|
2120
2227
|
throw new Error(existing.length ? `${file} is outside ${target}: akan test ${exec.name} runs its own tests only` : `${file} names no file or folder in ${target}`);
|
|
2121
|
-
return `./${found.split(
|
|
2228
|
+
return `./${found.split(path6.sep).join("/")}`;
|
|
2122
2229
|
});
|
|
2123
2230
|
}
|
|
2124
2231
|
async test(exec, testPaths = []) {
|
|
@@ -2129,7 +2236,7 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2129
2236
|
AKAN_TEST_TARGET_TYPE: exec.type,
|
|
2130
2237
|
AKAN_TEST_TARGET_NAME: exec.name,
|
|
2131
2238
|
AKAN_TEST_LIBS: exec.getScanInfo({ allowEmpty: true })?.getLibs().join(",") ?? "",
|
|
2132
|
-
AKAN_RUNTIME_DIR:
|
|
2239
|
+
AKAN_RUNTIME_DIR: path6.join(exec.workspace.workspaceRoot, "local", `${exec.type}s`, exec.name, "runtime")
|
|
2133
2240
|
} : {};
|
|
2134
2241
|
const args = ["test", "--isolate", ...preloadPath ? ["--preload", preloadPath] : [], ...testPaths];
|
|
2135
2242
|
await exec.spawn("bun", args, {
|
|
@@ -2247,7 +2354,7 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2247
2354
|
try {
|
|
2248
2355
|
return realpathSync.native(root);
|
|
2249
2356
|
} catch {
|
|
2250
|
-
return
|
|
2357
|
+
return path6.resolve(root);
|
|
2251
2358
|
}
|
|
2252
2359
|
};
|
|
2253
2360
|
return canonical(reported) === canonical(own);
|
|
@@ -2271,13 +2378,13 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2271
2378
|
if (!mobileTarget || targets.length > 1)
|
|
2272
2379
|
throw new Error("pack-update packs one native target at a time; pass --target <name>.");
|
|
2273
2380
|
const nativeApp = new NativeApp(app, mobileTarget, env);
|
|
2274
|
-
await UpdatePackFolder.clear(
|
|
2381
|
+
await UpdatePackFolder.clear(path6.resolve(out ?? path6.join(nativeApp.updatesDir, platform)));
|
|
2275
2382
|
const pinned = publicEnv ? await NativePublicEnv.load(publicEnv) : against ? await NativePublicEnv.recordedIn(against) : null;
|
|
2276
2383
|
await this.#buildMobileCsr(app, env, undefined, pinned);
|
|
2277
2384
|
const { pack } = await nativeApp.packUpdate(platform, { out });
|
|
2278
2385
|
app.logger.info(`packed ${mobileTarget.name} ${platform} for channel '${pack.channel}' to ${pack.out}: ${pack.files} files, ${(pack.size / 1024).toFixed(0)} KiB, native API ${pack.nativeApi}`);
|
|
2279
2386
|
if (against) {
|
|
2280
|
-
const bundle =
|
|
2387
|
+
const bundle = path6.join(pack.out, UpdatePackFolder.bundleFile);
|
|
2281
2388
|
const compat = await NativeApp.compareBundles(app.cwdPath, against, bundle);
|
|
2282
2389
|
const envProblem = await NativePublicEnv.problemAgainst(against, bundle);
|
|
2283
2390
|
await UpdatePackFolder.writeCompat(pack, {
|