@akanjs/devkit 3.3.0-rc.50 → 3.3.0-rc.52
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 +36 -0
- package/akanConfig/akanConfig.ts +16 -2
- package/akanConfig/akanWorkers.test.ts +37 -3
- package/akanConfig/akanWorkers.ts +34 -5
- package/akanConfig/index.ts +1 -0
- package/app/applicationBuildRunner.test.ts +4 -4
- package/app/applicationBuildRunner.ts +5 -7
- package/biome.base.json +1 -3
- package/executors/appExecutor.ts +7 -4
- package/executors/executors.test.ts +22 -0
- package/executors/sysExecutor.ts +10 -1
- package/lint/biomeBase.test.ts +36 -8
- package/package.json +3 -3
- package/typecheck/projectTypecheck.test.ts +3 -1
- package/typecheck/projectTypecheck.ts +3 -3
- package/workspace/scanInfo.ts +7 -1
- package/workspace/workspaceLayout.test.ts +5 -1
- package/workspace/workspaceLayout.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -219,6 +219,27 @@
|
|
|
219
219
|
|
|
220
220
|
The guide's `runtimeRule-2.md` reference is 3987 bytes larger, and its budget is raised to match.
|
|
221
221
|
|
|
222
|
+
- 95a627a: A lib root takes a `script/` folder, for the tooling that makes the lib's own assets.
|
|
223
|
+
|
|
224
|
+
A lib had no folder that stays out of an image: the root allowlist refused `script/`, so a lib's build-time tooling (a model converter and its Dockerfile, say) could only sit under `private/`, which every app that mounts the lib ships as `private/libs/<lib>/`.
|
|
225
|
+
|
|
226
|
+
- **`libs/<lib>/script/` is allowed** by `akan sync`, `akan doctor` and the layout check. Nothing runs it and nothing copies it into an app, an image or a desktop build.
|
|
227
|
+
- **Its TypeScript is typechecked** with the lib's tests (`akan verify <lib>`, `akan typecheck <lib>`), as an app's `script/` is.
|
|
228
|
+
- **`libs/<lib>/script/migration` is refused** at sync, naming the folder: only an app's migrations are run, so one in a lib would never be applied.
|
|
229
|
+
|
|
230
|
+
The `app.md` agent rule grows by 246 bytes for the sentence that says so, and its budget is raised to match.
|
|
231
|
+
|
|
232
|
+
- 9c2a5d9: A lib's `akan.config.ts` takes `workers`, so a lib that spawns a worker declares it once.
|
|
233
|
+
|
|
234
|
+
Until now only an app's config took `workers`, and a lib whose adapter called `AppWorker.spawn("vision")` made every app that mounts it repeat `workers: { vision: "../../libs/<lib>/…" }`; an app without the line failed at run time with `workerNotDeclared`.
|
|
235
|
+
|
|
236
|
+
- **A lib declares its own workers.** `workers: { vision: "srvkit/vision.worker.ts" }` in `libs/<lib>/akan.config.ts`, the path relative to that config. Every app that depends on the lib builds `workers/vision.js` and resolves the name in `akan start` and `akan test`, with nothing in the app's config.
|
|
237
|
+
- **An app's own entry of the same name wins**, as with `bin`. Two libs an app depends on that name different files for one worker stop the start, the test run or the build, naming both configs, until the app's config picks one.
|
|
238
|
+
- **`akan test <lib>` knows the lib's workers** and those of the libs it depends on. A lib's own test run had no worker sources before.
|
|
239
|
+
- **A build carries only the workers of the libs the app depends on**, not those of every lib in the workspace.
|
|
240
|
+
|
|
241
|
+
Upgrade: an app that repeats a lib's worker can drop the line once the lib declares it; leaving it changes nothing. `LibConfigResult` gains a required `workers` field, which matters only to code that builds that object by hand. In `@akanjs/devkit`, `AkanWorkers.declare` is replaced by `AkanWorkers.select` and `AkanWorkers.publish`. The runtime guide's reference grows to five parts (`runtimeRule-5.md` is new, the budgets of `runtimeRule-4.md` and the `akan-runtime` `SKILL.md` are raised) because the new paragraph moved a part past the 28,000-character split.
|
|
242
|
+
|
|
222
243
|
- 8d75f2b: The public surface 3.2.0 deprecated is removed. `akanjs` and `@akanjs/devkit` publish only the subpaths their `exports` name, with no wildcard, so a file becomes public only when an entry names it.
|
|
223
244
|
|
|
224
245
|
- **`@akanjs/devkit` has no root aliases and no `./*` or `./*.ts`.** It publishes `@akanjs/devkit` (types only), `biome.base.json`, the facets `akanApp`, `akanConfig`, `artifact`, `cloud`, `codeAgent`, `commandDecorators`, `executors`, `frontendBuild`, `incrementalBuilder`, `mobile`, `pipeline`, `preview`, `transforms` and `workflow`, and the files `app/applicationBuildRunner`, `cloud/cloudApi`, `cloud/cloudUpdates`, `commandDecorators/exitCodeError`, `mobile/desktopRelease`, `mobile/serverBundleSecrets` and `transforms/serverEnvProfile`. `util/fileEditor`, `util/selectModel` and `workspace/getRelatedCnsts` are named too, and deprecated: nothing in akanjs uses them.
|
|
@@ -590,6 +611,14 @@
|
|
|
590
611
|
The port now answers from the start of the build. A request to `localhost` or an IP address, page or API, waits for the first artifact; a build longer than the 15 s the gateway holds a request ends the wait with a 503 "Backend is starting" page that reloads itself. A request to one of the app's own domains (a custom local domain) gets that 503 at once until the backend is ready, because the build has not written the app's hosts yet; after that it is served as before, and any other Host is refused as before.
|
|
591
612
|
|
|
592
613
|
- 1d8c8c2: `akan start` keeps `apps/<app>/.akan/cache` between runs, so a restart reuses the CSS class scan and the subset fonts instead of redoing them. Each entry names the akanjs and Bun versions and the build of the cache code that wrote it, and an entry another one wrote, or one cut short, is rebuilt.
|
|
614
|
+
- cb8ec71: `akan start` binds the port `PORT` names.
|
|
615
|
+
|
|
616
|
+
`PORT=28284 akan start face` started the dev server on the app's derived port (8282 plus its place in the app list) and said nothing about the value it dropped, while the built server (`bun main.js`) honours `PORT`. Only `AKAN_DEV_PORT` moved a dev server.
|
|
617
|
+
|
|
618
|
+
`AKAN_DEV_PORT` still wins. Without it, a usable `PORT` pins the dev port the same way, for every command that looks for the dev server (`akan start`, `--kill`, `akan preview`); several apps started together count upward from it. A workspace whose shell or root `.env` already sets `PORT` for another purpose now starts its dev server there: set `AKAN_DEV_PORT` to keep the old port.
|
|
619
|
+
|
|
620
|
+
The runtime guide gains three lines on the dev port, so the budget of `runtimeRule-1.md` is raised to 19287 bytes.
|
|
621
|
+
|
|
593
622
|
- 98931e4: `akan start` prints one line when the dev server is ready that says where the start's time went: what the CLI did before the builder, the base build and its parts, the backend's boot, and when the first artifact was on disk.
|
|
594
623
|
- 4795e71: `akan sync` lists an app's libs in one fixed order, and `akan.app.json` records the routes of the lib pages the same sync linked.
|
|
595
624
|
|
|
@@ -602,6 +631,12 @@
|
|
|
602
631
|
|
|
603
632
|
**Upgrading.** If `akan start` against a cluster environment opened its tunnel with neither setting, it now stops with that error in every database mode but `single`, where it logs the error and runs without Redis. Export `SSH_TUNNEL_PRIVATE_KEY_PATH` in the shell (a repository's dotenv file cannot set it), or set `SSH_TUNNEL_PASSWORD` to the password the cluster's tunnel endpoint expects. `SSH_TUNNEL_USERNAME` still defaults to `root`.
|
|
604
633
|
|
|
634
|
+
- 7d4c3c7: fix(lint): `noUnnecessaryConditions` is off in the base Biome config again
|
|
635
|
+
|
|
636
|
+
Biome reads a class field initialised with a literal as that literal for good: `#isBusy = false` stays `false` however many methods assign it, so `if (this.#isBusy)` gets "This condition is always falsy" and `if (!this.#hasFeeder)` "always truthy". Private, public and static fields, and boolean, number and string literals, all read this way; an explicit annotation (`#isBusy: boolean = false`) does not. It is biomejs/biome#11174, open since 2.5.6 and still there in 2.5.15 and 2.6.8, so the 2.5.15 bump that fixed the `RegExp.exec` misreading did not make the rule safe to show. In this repository 174 of its 607 warnings are checks on such a field.
|
|
637
|
+
|
|
638
|
+
`akan verify` prints the warning to agents, and the fix it suggests is to delete a guard that is live. So the base config turns the rule off, as it was from 3.3.0-rc.38 to rc.45. A workspace that wants it sets `"noUnnecessaryConditions": "warn"` under `linter.rules.suspicious` in its own `biome.json`; this repository's does. A test pins the misreading, so the rule can come back when Biome fixes it.
|
|
639
|
+
|
|
605
640
|
- 694444d: `akan verify` writes its build check to `dist/verify/<app>` and leaves `dist/apps/<app>` as `akan build` left it, so running `akan verify` after `akan build` no longer stops `cd dist/apps/<app> && bun main.js` from starting. The check no longer copies the app's `public/` and `private/` folders either.
|
|
606
641
|
- 86e2fe1: A workflow plan that lacks a required input now names the flag to pass and the inputs it was given but does not take.
|
|
607
642
|
|
|
@@ -650,6 +685,7 @@
|
|
|
650
685
|
- Updated dependencies [1885caf]
|
|
651
686
|
- Updated dependencies [45e3ffa]
|
|
652
687
|
- Updated dependencies [3032627]
|
|
688
|
+
- Updated dependencies [9c2a5d9]
|
|
653
689
|
- Updated dependencies [b6f1838]
|
|
654
690
|
- Updated dependencies [c10f7cf]
|
|
655
691
|
- Updated dependencies [c10f7cf]
|
package/akanConfig/akanConfig.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { App, Lib } from "../commandDecorators";
|
|
|
9
9
|
import { WorkspaceExecutor } from "../executors/workspaceExecutor";
|
|
10
10
|
import type { BaseDevEnv, PackageJson } from "../workspace/types";
|
|
11
11
|
import { AkanBin } from "./akanBin";
|
|
12
|
-
import { AkanWorkers } from "./akanWorkers";
|
|
12
|
+
import { AkanWorkers, type LibWorkers } from "./akanWorkers";
|
|
13
13
|
import { DesktopServerConfig } from "./desktopServerConfig";
|
|
14
14
|
import {
|
|
15
15
|
DEFAULT_DOCKER_IMAGE,
|
|
@@ -128,6 +128,7 @@ export interface LibContributions {
|
|
|
128
128
|
trustedDependencies?: string[];
|
|
129
129
|
/** Per lib, since an app carries only the entries of the libs it depends on. */
|
|
130
130
|
bin?: { lib: string; bin: AkanBinConfig }[];
|
|
131
|
+
workers?: LibWorkers[];
|
|
131
132
|
docker: LibDockerConfig;
|
|
132
133
|
/** Keep globs rewritten to the app's own `public/`, where `akan sync` mounts each lib's assets. */
|
|
133
134
|
keepFonts?: string[];
|
|
@@ -137,6 +138,7 @@ const emptyLibContributions = (): LibContributions => ({
|
|
|
137
138
|
externalLibs: [],
|
|
138
139
|
trustedDependencies: [],
|
|
139
140
|
bin: [],
|
|
141
|
+
workers: [],
|
|
140
142
|
docker: { preRuns: [], postRuns: [] },
|
|
141
143
|
keepFonts: [],
|
|
142
144
|
});
|
|
@@ -174,6 +176,7 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
174
176
|
/** The app's own entries; the libs' are in `libBins`. */
|
|
175
177
|
bin: AkanBinConfig;
|
|
176
178
|
libBins: { lib: string; bin: AkanBinConfig }[];
|
|
179
|
+
/** The app's own entries; `App.selectWorkers` adds those of the libs it depends on. */
|
|
177
180
|
workers: AkanWorkersConfig;
|
|
178
181
|
barrelImports: string[];
|
|
179
182
|
optimizeImports: string[];
|
|
@@ -222,7 +225,11 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
222
225
|
];
|
|
223
226
|
this.bin = AkanBin.parse(config?.bin, owner, app.cwdPath);
|
|
224
227
|
this.libBins = libContributions.bin ?? [];
|
|
225
|
-
this.workers = AkanWorkers.
|
|
228
|
+
this.workers = AkanWorkers.parse(config?.workers, owner, app.cwdPath);
|
|
229
|
+
//? The dependency scan reads this config, so every workspace lib's entry is published; a start, test or build names the mounted ones.
|
|
230
|
+
AkanWorkers.publish(
|
|
231
|
+
AkanWorkers.select({ owner, workers: this.workers }, libContributions.workers ?? [], libs, { strict: false }),
|
|
232
|
+
);
|
|
226
233
|
this.barrelImports = [
|
|
227
234
|
...DEFAULT_BARREL_IMPORTS,
|
|
228
235
|
...WORKSPACE_BARREL_FACETS.map((facet) => `@apps/${app.name}/${facet}`),
|
|
@@ -577,6 +584,11 @@ CMD ${JSON.stringify(command)}`;
|
|
|
577
584
|
bin: libConfigs.flatMap((libConfig) =>
|
|
578
585
|
libConfig && Object.keys(libConfig.bin).length ? [{ lib: libConfig.lib.name, bin: libConfig.bin }] : [],
|
|
579
586
|
),
|
|
587
|
+
workers: libConfigs.flatMap((libConfig) =>
|
|
588
|
+
libConfig && Object.keys(libConfig.workers).length
|
|
589
|
+
? [{ lib: libConfig.lib.name, workers: libConfig.workers }]
|
|
590
|
+
: [],
|
|
591
|
+
),
|
|
580
592
|
docker: {
|
|
581
593
|
preRuns: libConfigs.flatMap((libConfig) => libConfig?.docker.preRuns ?? []),
|
|
582
594
|
postRuns: libConfigs.flatMap((libConfig) => libConfig?.docker.postRuns ?? []),
|
|
@@ -715,6 +727,7 @@ export class AkanLibConfig implements LibConfigResult {
|
|
|
715
727
|
externalLibs: string[];
|
|
716
728
|
trustedDependencies: string[];
|
|
717
729
|
bin: AkanBinConfig;
|
|
730
|
+
workers: AkanWorkersConfig;
|
|
718
731
|
docker: LibDockerConfig;
|
|
719
732
|
assets: LibAssetsConfig;
|
|
720
733
|
/** Live-only: plugins declared in this lib's `akan.config.ts` (never serialized). */
|
|
@@ -725,6 +738,7 @@ export class AkanLibConfig implements LibConfigResult {
|
|
|
725
738
|
const owner = `libs/${lib.name}/akan.config.ts`;
|
|
726
739
|
this.trustedDependencies = normalizePackageNames(config?.trustedDependencies, owner);
|
|
727
740
|
this.bin = AkanBin.parse(config?.bin, owner, lib.cwdPath);
|
|
741
|
+
this.workers = AkanWorkers.parse(config?.workers, owner, lib.cwdPath);
|
|
728
742
|
this.docker = { preRuns: config?.docker?.preRuns ?? [], postRuns: config?.docker?.postRuns ?? [] };
|
|
729
743
|
this.assets = { keepFonts: normalizeKeepFonts(config?.assets?.keepFonts as string[] | undefined) };
|
|
730
744
|
this.plugins = plugins;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { AppWorkerPath } from "akanjs/server/appWorkerPath";
|
|
4
|
-
import { AkanWorkers } from "./akanWorkers";
|
|
4
|
+
import { AkanWorkers, type LibWorkers } from "./akanWorkers";
|
|
5
5
|
|
|
6
6
|
const owner = "apps/face/akan.config.ts";
|
|
7
7
|
const published = process.env[AppWorkerPath.envKey];
|
|
@@ -30,10 +30,44 @@ describe("AkanWorkers", () => {
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
test("publishes the sources a source run spawns from, and takes them back when none is declared", () => {
|
|
33
|
-
const workers = AkanWorkers.
|
|
33
|
+
const workers = AkanWorkers.parse({ vision: "visionWorker.ts" }, owner, "/repo/apps/face");
|
|
34
34
|
|
|
35
|
+
expect(AkanWorkers.publish(AkanWorkers.select({ owner, workers }, [], []))).toEqual(workers);
|
|
35
36
|
expect(AppWorkerPath.sources()).toEqual(workers);
|
|
36
|
-
AkanWorkers.
|
|
37
|
+
AkanWorkers.publish(AkanWorkers.select({ owner, workers: {} }, [], []));
|
|
37
38
|
expect(process.env[AppWorkerPath.envKey]).toBeUndefined();
|
|
38
39
|
});
|
|
40
|
+
|
|
41
|
+
test("adds the workers of the libs named, and the declarer's own entry wins a name", () => {
|
|
42
|
+
const libWorkers: LibWorkers[] = [
|
|
43
|
+
{
|
|
44
|
+
lib: "edge",
|
|
45
|
+
workers: { vision: "/repo/libs/edge/srvkit/vision.worker.ts", encode: "/repo/libs/edge/encode.ts" },
|
|
46
|
+
},
|
|
47
|
+
{ lib: "other", workers: { ocr: "/repo/libs/other/ocr.ts" } },
|
|
48
|
+
];
|
|
49
|
+
const chosen = AkanWorkers.select({ owner, workers: { vision: "/repo/apps/face/vision.ts" } }, libWorkers, [
|
|
50
|
+
"edge",
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
expect(Object.fromEntries(chosen)).toEqual({
|
|
54
|
+
vision: { owner, entry: "/repo/apps/face/vision.ts" },
|
|
55
|
+
encode: { owner: "libs/edge/akan.config.ts", entry: "/repo/libs/edge/encode.ts" },
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("refuses one name two of the named libs declare differently, unless told to keep the first", () => {
|
|
60
|
+
const libWorkers: LibWorkers[] = [
|
|
61
|
+
{ lib: "edge", workers: { vision: "/repo/libs/edge/vision.ts" } },
|
|
62
|
+
{ lib: "lab", workers: { vision: "/repo/libs/lab/vision.ts" } },
|
|
63
|
+
];
|
|
64
|
+
const select = (libs: string[], strict?: boolean) =>
|
|
65
|
+
AkanWorkers.select({ owner, workers: {} }, libWorkers, libs, { strict });
|
|
66
|
+
|
|
67
|
+
expect(() => select(["edge", "lab"])).toThrow(
|
|
68
|
+
`libs/edge/akan.config.ts and libs/lab/akan.config.ts declare workers.vision differently; declare it in ${owner} to pick one.`,
|
|
69
|
+
);
|
|
70
|
+
expect(select(["lab"]).get("vision")?.entry).toBe("/repo/libs/lab/vision.ts");
|
|
71
|
+
expect(select(["edge", "lab"], false).get("vision")?.entry).toBe("/repo/libs/edge/vision.ts");
|
|
72
|
+
});
|
|
39
73
|
});
|
|
@@ -2,15 +2,44 @@ import path from "node:path";
|
|
|
2
2
|
import { AppWorkerPath } from "akanjs/server/appWorkerPath";
|
|
3
3
|
import type { AkanWorkersConfig } from "./types";
|
|
4
4
|
|
|
5
|
+
export interface WorkerDeclarer {
|
|
6
|
+
owner: string;
|
|
7
|
+
workers: AkanWorkersConfig;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface LibWorkers {
|
|
11
|
+
lib: string;
|
|
12
|
+
workers: AkanWorkersConfig;
|
|
13
|
+
}
|
|
14
|
+
|
|
5
15
|
export class AkanWorkers {
|
|
6
16
|
static readonly entry = /\.(ts|mts|js|mjs)$/;
|
|
7
17
|
|
|
8
|
-
|
|
9
|
-
static
|
|
10
|
-
const
|
|
11
|
-
|
|
18
|
+
/** The declarer's own entries, then those of the libs named: its own wins a name, two libs may not differ on one. */
|
|
19
|
+
static select(own: WorkerDeclarer, libWorkers: LibWorkers[], libs: string[], { strict = true } = {}) {
|
|
20
|
+
const chosen = new Map<string, { owner: string; entry: string }>();
|
|
21
|
+
for (const [name, entry] of Object.entries(own.workers)) chosen.set(name, { owner: own.owner, entry });
|
|
22
|
+
for (const { lib, workers } of libWorkers) {
|
|
23
|
+
if (!libs.includes(lib)) continue;
|
|
24
|
+
const owner = `libs/${lib}/akan.config.ts`;
|
|
25
|
+
for (const [name, entry] of Object.entries(workers)) {
|
|
26
|
+
const held = chosen.get(name);
|
|
27
|
+
if (!held) chosen.set(name, { owner, entry });
|
|
28
|
+
else if (strict && held.owner !== own.owner && held.entry !== entry)
|
|
29
|
+
throw new Error(
|
|
30
|
+
`${held.owner} and ${owner} declare workers.${name} differently; declare it in ${own.owner} to pick one.`,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return chosen;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//? Published to `process.env`, as the route prefixes are: every process the CLI starts from source inherits it.
|
|
38
|
+
static publish(chosen: Map<string, { entry: string }>): AkanWorkersConfig {
|
|
39
|
+
const sources = Object.fromEntries([...chosen].map(([name, { entry }]) => [name, entry]));
|
|
40
|
+
if (chosen.size) process.env[AppWorkerPath.envKey] = JSON.stringify(sources);
|
|
12
41
|
else delete process.env[AppWorkerPath.envKey];
|
|
13
|
-
return
|
|
42
|
+
return sources;
|
|
14
43
|
}
|
|
15
44
|
|
|
16
45
|
static parse(declared: unknown, owner: string, baseDir: string): AkanWorkersConfig {
|
package/akanConfig/index.ts
CHANGED
|
@@ -654,16 +654,16 @@ console.info(new SampleService().name);
|
|
|
654
654
|
expect(order).toEqual(["routes"]);
|
|
655
655
|
});
|
|
656
656
|
|
|
657
|
-
test("akan typecheck
|
|
657
|
+
test("akan typecheck asks for the tests and script/ files nothing imports, and a build's typecheck does not", async () => {
|
|
658
658
|
const { root, app } = await createTempApp("portal");
|
|
659
659
|
const run = spyOn(ProjectTypecheck.prototype, "run").mockImplementation(async () => "");
|
|
660
660
|
try {
|
|
661
661
|
const runner = new ApplicationBuildRunner(app);
|
|
662
662
|
await runner.typecheck({ tests: true });
|
|
663
663
|
await runner.typecheck();
|
|
664
|
-
const [checked, built] = run.mock.calls.map(([
|
|
665
|
-
expect(checked).
|
|
666
|
-
expect(built).
|
|
664
|
+
const [checked, built] = run.mock.calls.map(([, options]) => options?.tests);
|
|
665
|
+
expect(checked).toBe(true);
|
|
666
|
+
expect(built).toBeUndefined();
|
|
667
667
|
} finally {
|
|
668
668
|
run.mockRestore();
|
|
669
669
|
await rm(root, { recursive: true, force: true });
|
|
@@ -6,7 +6,6 @@ import { SecretEnv } from "akanjs/server/lifecycle/secretEnv";
|
|
|
6
6
|
import type { BunPlugin } from "bun";
|
|
7
7
|
import { AkanBin } from "../akanConfig/akanBin";
|
|
8
8
|
import { ProductionLockfile } from "../akanConfig/productionLockfile";
|
|
9
|
-
import type { AkanWorkersConfig } from "../akanConfig/types";
|
|
10
9
|
import type { App } from "../commandDecorators";
|
|
11
10
|
import { parseEnvFile, WorkspaceExecutor } from "../executors";
|
|
12
11
|
import {
|
|
@@ -352,7 +351,6 @@ export class ApplicationBuildRunner {
|
|
|
352
351
|
"../../page/**/*.ts",
|
|
353
352
|
"../../page/**/*.tsx",
|
|
354
353
|
...libPageIncludes,
|
|
355
|
-
...(options.tests ? ["../../script/**/*.ts"] : []),
|
|
356
354
|
"../../../../pkgs/akanjs/*/types/**/*.d.ts",
|
|
357
355
|
],
|
|
358
356
|
options,
|
|
@@ -487,7 +485,7 @@ export class ApplicationBuildRunner {
|
|
|
487
485
|
}
|
|
488
486
|
|
|
489
487
|
async #buildBackend() {
|
|
490
|
-
const { externalLibs, web, baseDevEnv, branches
|
|
488
|
+
const { externalLibs, web, baseDevEnv, branches } = await this.#app.getConfig();
|
|
491
489
|
const backendEntryPoints = [`${this.#app.cwdPath}/main.ts`, `${this.#app.cwdPath}/server.ts`];
|
|
492
490
|
for (const entrypoint of backendEntryPoints) {
|
|
493
491
|
if (!(await Bun.file(entrypoint).exists())) throw new Error(`Backend entrypoint not found: ${entrypoint}`);
|
|
@@ -528,7 +526,7 @@ export class ApplicationBuildRunner {
|
|
|
528
526
|
naming: { entry: "console-runtime.[ext]", chunk: "chunk-[hash].[ext]" },
|
|
529
527
|
});
|
|
530
528
|
await this.#writeConsoleShim();
|
|
531
|
-
const workerResults = await this.#buildWorkers(
|
|
529
|
+
const workerResults = await this.#buildWorkers(backendConfig);
|
|
532
530
|
const results = [mainResult, serverResult, rscWorkerResult, consoleRuntimeResult, ...workerResults];
|
|
533
531
|
return {
|
|
534
532
|
entrypoints: backendEntryPoints.length + (rscWorkerResult ? 2 : 1) + workerResults.length,
|
|
@@ -537,12 +535,12 @@ export class ApplicationBuildRunner {
|
|
|
537
535
|
}
|
|
538
536
|
|
|
539
537
|
//* Never a chunk of server.js: the process that runs a worker loads nothing of the server, nor the server of it.
|
|
540
|
-
async #buildWorkers(
|
|
538
|
+
async #buildWorkers(backendConfig: Omit<Bun.BuildConfig, "entrypoints">) {
|
|
541
539
|
const results: Bun.BuildOutput[] = [];
|
|
542
|
-
for (const [name, entry] of
|
|
540
|
+
for (const [name, { owner, entry }] of await this.#app.selectWorkers()) {
|
|
543
541
|
if (!(await Bun.file(entry).exists()))
|
|
544
542
|
throw new Error(
|
|
545
|
-
|
|
543
|
+
`${owner}: workers.${name} names ${path.relative(this.#app.workspace.workspaceRoot, entry)}, which does not exist.`,
|
|
546
544
|
);
|
|
547
545
|
results.push(
|
|
548
546
|
await this.#buildOrThrow(`worker ${name}`, {
|
package/biome.base.json
CHANGED
package/executors/appExecutor.ts
CHANGED
|
@@ -3,7 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import type { AkanPlugin, AkanSyncContext } from "akanjs";
|
|
5
5
|
import { isRouteSourceFile, parseRouteModuleKey, validatePageSourceFile, validateSubRoutePageKey } from "akanjs/common";
|
|
6
|
-
import { AkanAppConfig, decreaseBuildNum, increaseBuildNum } from "../akanConfig";
|
|
6
|
+
import { AkanAppConfig, AkanWorkers, decreaseBuildNum, increaseBuildNum } from "../akanConfig";
|
|
7
7
|
import type { RouteSourceInfo } from "../app/routeSourceValidator";
|
|
8
8
|
import { getRootBoundarySegments, isRootBoundarySegments } from "../artifact/implicitRootLayout";
|
|
9
9
|
import { FileSys } from "../util/fileSys";
|
|
@@ -90,10 +90,12 @@ export class AppExecutor extends SysExecutor {
|
|
|
90
90
|
getEnv() {
|
|
91
91
|
return WorkspaceExecutor.getBaseDevEnv().env;
|
|
92
92
|
}
|
|
93
|
-
/** `AKAN_DEV_PORT` pins it
|
|
93
|
+
/** `AKAN_DEV_PORT` pins it, else `PORT`; the derived port moves whenever an app directory appears or disappears. */
|
|
94
94
|
async getDevPort() {
|
|
95
|
-
const
|
|
96
|
-
|
|
95
|
+
for (const declared of [process.env.AKAN_DEV_PORT, process.env.PORT]) {
|
|
96
|
+
const pinned = Number(declared);
|
|
97
|
+
if (Number.isInteger(pinned) && pinned > 0 && pinned <= 65_535) return pinned;
|
|
98
|
+
}
|
|
97
99
|
const basePort = 8282;
|
|
98
100
|
const appNames = (await this.workspace.getApps()).sort((a, b) => a.localeCompare(b));
|
|
99
101
|
const appIndex = Math.max(appNames.indexOf(this.name), 0);
|
|
@@ -132,6 +134,7 @@ export class AppExecutor extends SysExecutor {
|
|
|
132
134
|
...(await this.getDatabaseModeEnv()),
|
|
133
135
|
};
|
|
134
136
|
Object.assign(process.env, routeEnv);
|
|
137
|
+
if (this.hasScanInfo()) AkanWorkers.publish(await this.selectWorkers());
|
|
135
138
|
if (type === "build") {
|
|
136
139
|
//* `scanSync` read the route set unfiltered; drop the cache so build phases re-read it without dev-only routes.
|
|
137
140
|
this.#excludeDevOnlyPages = true;
|
|
@@ -963,6 +963,7 @@ describe("Workspace and app executor environment contracts", () => {
|
|
|
963
963
|
process.env.AKAN_PUBLIC_SERVE_DOMAIN = "example.com";
|
|
964
964
|
process.env.AKAN_PUBLIC_ENV = "local";
|
|
965
965
|
process.env.PORT_OFFSET = "0";
|
|
966
|
+
delete process.env.PORT;
|
|
966
967
|
await writeJson(path.join(root, "package.json"), rootPackageJson());
|
|
967
968
|
for (const name of names) {
|
|
968
969
|
await mkdir(path.join(root, "apps", name), { recursive: true });
|
|
@@ -1003,6 +1004,26 @@ describe("Workspace and app executor environment contracts", () => {
|
|
|
1003
1004
|
expect(await app.getDevPort()).toBe(12345);
|
|
1004
1005
|
});
|
|
1005
1006
|
|
|
1007
|
+
test("PORT pins it as it does a built server, and AKAN_DEV_PORT outranks it", async () => {
|
|
1008
|
+
const workspace = await makeWorkspaceWithApps(["env-a", "env-b"]);
|
|
1009
|
+
const app = AppExecutor.from(workspace, "env-b");
|
|
1010
|
+
delete process.env.AKAN_DEV_PORT;
|
|
1011
|
+
process.env.PORT = "28284";
|
|
1012
|
+
try {
|
|
1013
|
+
expect(await app.getDevPort()).toBe(28284);
|
|
1014
|
+
expect((await app.prepareCommand("start")).env.PORT).toBe("28284");
|
|
1015
|
+
|
|
1016
|
+
process.env.AKAN_DEV_PORT = "12345";
|
|
1017
|
+
expect(await app.getDevPort()).toBe(12345);
|
|
1018
|
+
|
|
1019
|
+
process.env.AKAN_DEV_PORT = "nope";
|
|
1020
|
+
expect(await app.getDevPort()).toBe(28284);
|
|
1021
|
+
} finally {
|
|
1022
|
+
delete process.env.PORT;
|
|
1023
|
+
delete process.env.AKAN_DEV_PORT;
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1006
1027
|
test("ignores an unusable AKAN_DEV_PORT rather than binding a nonsense port", async () => {
|
|
1007
1028
|
const workspace = await makeWorkspaceWithApps(["bad-a"]);
|
|
1008
1029
|
const app = AppExecutor.from(workspace, "bad-a");
|
|
@@ -1160,6 +1181,7 @@ describe("Workspace and app executor environment contracts", () => {
|
|
|
1160
1181
|
process.env.AKAN_PUBLIC_REPO_NAME = "repo";
|
|
1161
1182
|
process.env.AKAN_PUBLIC_SERVE_DOMAIN = "example.com";
|
|
1162
1183
|
process.env.AKAN_PUBLIC_ENV = "local";
|
|
1184
|
+
for (const key of ["PORT", "AKAN_DEV_PORT"]) delete process.env[key];
|
|
1163
1185
|
|
|
1164
1186
|
await writeJson(path.join(root, "package.json"), rootPackageJson());
|
|
1165
1187
|
for (const appName of ["minimal", "akan"]) {
|
package/executors/sysExecutor.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { capitalize, getPageSourceFileViolation } from "akanjs/common";
|
|
4
|
-
import { AkanAppConfig, AkanLibConfig } from "../akanConfig";
|
|
4
|
+
import { AkanAppConfig, AkanLibConfig, AkanWorkers } from "../akanConfig";
|
|
5
5
|
import {
|
|
6
6
|
renderScopeAgentBlock,
|
|
7
7
|
renderScopeAgentsMd,
|
|
@@ -76,6 +76,15 @@ export class SysExecutor extends Executor {
|
|
|
76
76
|
if (!this.hasScanInfo() && !allowEmpty) throw new Error("Scan info is not available");
|
|
77
77
|
return this.#scanInfo as AllowEmpty extends true ? AppInfo | LibInfo | null : AppInfo | LibInfo;
|
|
78
78
|
}
|
|
79
|
+
async selectWorkers() {
|
|
80
|
+
const scanInfo = this.#scanInfo ?? (await this.scan({ write: false }));
|
|
81
|
+
const own = { owner: `${this.type}s/${this.name}/akan.config.ts`, workers: (await this.getConfig()).workers };
|
|
82
|
+
const libWorkers = [...scanInfo.getLibInfos()].map(([lib, { akanConfig }]) => ({
|
|
83
|
+
lib,
|
|
84
|
+
workers: akanConfig.workers,
|
|
85
|
+
}));
|
|
86
|
+
return AkanWorkers.select(own, libWorkers, scanInfo.getLibs());
|
|
87
|
+
}
|
|
79
88
|
async #seedEnvFiles(): Promise<FileContent[]> {
|
|
80
89
|
const envDir = path.join(this.cwdPath, "env");
|
|
81
90
|
const missing = await new EnvSeed(envDir).missing();
|
package/lint/biomeBase.test.ts
CHANGED
|
@@ -31,6 +31,27 @@ export const always = (n: number) => {
|
|
|
31
31
|
};
|
|
32
32
|
`;
|
|
33
33
|
|
|
34
|
+
const fieldProbe = `export class Pump {
|
|
35
|
+
#isBusy = false;
|
|
36
|
+
static isOrphaned = false;
|
|
37
|
+
async run(frames: number[]) {
|
|
38
|
+
for (const frame of frames) {
|
|
39
|
+
if (Pump.isOrphaned) return;
|
|
40
|
+
if (this.#isBusy) continue;
|
|
41
|
+
void this.#infer(frame);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async #infer(frame: number) {
|
|
45
|
+
this.#isBusy = true;
|
|
46
|
+
await Promise.resolve(frame);
|
|
47
|
+
this.#isBusy = false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export const orphan = () => {
|
|
51
|
+
Pump.isOrphaned = true;
|
|
52
|
+
};
|
|
53
|
+
`;
|
|
54
|
+
|
|
34
55
|
const tempDirs: string[] = [];
|
|
35
56
|
|
|
36
57
|
afterAll(async () => {
|
|
@@ -48,14 +69,14 @@ const runBiome = (args: string[], cwd: string) =>
|
|
|
48
69
|
proc.on("close", () => resolve(stdout || stderr));
|
|
49
70
|
});
|
|
50
71
|
|
|
51
|
-
const lintWorkspace = async (files: string[], probe = hookProbe) => {
|
|
72
|
+
const lintWorkspace = async (files: string[], probe = hookProbe, config: object = { extends: [biomeBaseConfig] }) => {
|
|
52
73
|
const dir = await mkdtemp(path.join(os.tmpdir(), "biome-base-"));
|
|
53
74
|
tempDirs.push(dir);
|
|
54
75
|
//? The base config names its plugins as `./node_modules/@akanjs/devkit/…`, resolved from the extending config's
|
|
55
76
|
//? folder. A junction needs no privilege on Windows, and the type is ignored elsewhere.
|
|
56
77
|
await mkdir(path.join(dir, "node_modules", "@akanjs"), { recursive: true });
|
|
57
78
|
await symlink(devkitDir, path.join(dir, "node_modules", "@akanjs", "devkit"), "junction");
|
|
58
|
-
await writeFile(path.join(dir, "biome.json"), JSON.stringify(
|
|
79
|
+
await writeFile(path.join(dir, "biome.json"), JSON.stringify(config));
|
|
59
80
|
for (const file of files) {
|
|
60
81
|
await mkdir(path.dirname(path.join(dir, file)), { recursive: true });
|
|
61
82
|
await writeFile(path.join(dir, file), probe);
|
|
@@ -87,11 +108,18 @@ describe("biome.base.json", () => {
|
|
|
87
108
|
]);
|
|
88
109
|
});
|
|
89
110
|
|
|
90
|
-
test("
|
|
91
|
-
const
|
|
92
|
-
const unnecessary =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
111
|
+
test("leaves a check on a field another method assigns alone, which Biome reads as its first literal", async () => {
|
|
112
|
+
const ruleOnly = { linter: { rules: { recommended: false, suspicious: { noUnnecessaryConditions: "warn" } } } };
|
|
113
|
+
const unnecessary = async (probe: string, config?: object) =>
|
|
114
|
+
(await lintWorkspace(["apps/demo/common/probe.ts"], probe, config))
|
|
115
|
+
.filter((diagnostic) => diagnostic.category === "lint/suspicious/noUnnecessaryConditions")
|
|
116
|
+
.map((diagnostic) => `${diagnostic.location?.start?.line} ${diagnostic.severity}`);
|
|
117
|
+
|
|
118
|
+
expect(await unnecessary(fieldProbe)).toEqual([]);
|
|
119
|
+
expect(await unnecessary(execProbe)).toEqual([]);
|
|
120
|
+
|
|
121
|
+
//? Pins biomejs/biome#11174, open in 2.6.8: once the first list is empty, the base config can turn the rule back on.
|
|
122
|
+
expect(await unnecessary(fieldProbe, ruleOnly)).toEqual(["6 warning", "7 warning"]);
|
|
123
|
+
expect(await unnecessary(execProbe, ruleOnly)).toEqual(["8 warning"]);
|
|
96
124
|
});
|
|
97
125
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "3.3.0-rc.
|
|
3
|
+
"version": "3.3.0-rc.52",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"./workspace/getRelatedCnsts": "./workspace/getRelatedCnsts.ts"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@akanjs/language": "3.3.0-rc.
|
|
53
|
+
"@akanjs/language": "3.3.0-rc.52",
|
|
54
54
|
"@earendil-works/pi-agent-core": "1.5.2",
|
|
55
55
|
"@earendil-works/pi-ai": "1.5.2",
|
|
56
56
|
"@earendil-works/pi-codemode": "1.5.2",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@earendil-works/pi-tui": "1.5.2",
|
|
60
60
|
"@inquirer/prompts": "^8.7.3",
|
|
61
61
|
"@tailwindcss/node": "^4.3.3",
|
|
62
|
-
"akanjs": "3.3.0-rc.
|
|
62
|
+
"akanjs": "3.3.0-rc.52",
|
|
63
63
|
"chalk": "^6.0.1",
|
|
64
64
|
"commander": "^15.0.0",
|
|
65
65
|
"dayjs": "^1.11.23",
|
|
@@ -20,14 +20,16 @@ const project = async () => {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
describe("ProjectTypecheck", () => {
|
|
23
|
-
test("checks a test nothing imports only when asked, and leaves .akan out", async () => {
|
|
23
|
+
test("checks a test or a script file nothing imports only when asked, and leaves .akan out", async () => {
|
|
24
24
|
const { root, dir } = await project();
|
|
25
|
+
await write(path.join(dir, "script/rknn/convert.ts"), 'export const port: number = "8282";\n');
|
|
25
26
|
const typecheck = new ProjectTypecheck(dir, root, { ...process.env });
|
|
26
27
|
|
|
27
28
|
await typecheck.run(["../../server.ts"]);
|
|
28
29
|
const error = await typecheck.run(["../../server.ts"], { tests: true }).catch((e: Error) => e);
|
|
29
30
|
expect(error).toBeInstanceOf(Error);
|
|
30
31
|
expect((error as Error).message).toContain("lib/user/user.signal.test.ts");
|
|
32
|
+
expect((error as Error).message).toContain("script/rknn/convert.ts");
|
|
31
33
|
expect((error as Error).message).not.toContain("old.test.ts");
|
|
32
34
|
}, 60_000);
|
|
33
35
|
|
|
@@ -13,10 +13,10 @@ export interface ProjectTypecheckOptions {
|
|
|
13
13
|
report?: "pretty" | "records";
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
//* tsc checks what the entries import, and nothing imports a test, so
|
|
17
|
-
//* name. Each mode keeps a tsconfig and an incremental cache of its own, so one never invalidates the other.
|
|
16
|
+
//* tsc checks what the entries import, and nothing imports a test or a `script/` file, so each is checked only when
|
|
17
|
+
//* it is included by name. Each mode keeps a tsconfig and an incremental cache of its own, so one never invalidates the other.
|
|
18
18
|
export class ProjectTypecheck {
|
|
19
|
-
static readonly #testIncludes = ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"];
|
|
19
|
+
static readonly #testIncludes = ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx", "script/**/*.ts"];
|
|
20
20
|
static readonly #excludes = [".akan/**", "node_modules/**", "local/**"];
|
|
21
21
|
|
|
22
22
|
constructor(
|
package/workspace/scanInfo.ts
CHANGED
|
@@ -96,8 +96,14 @@ async function assertScanConvention(exec: AppExecutor | LibExecutor, libRoot: {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
//* A lib has no `getPageKeys`, so its own route files are validated here.
|
|
99
|
-
if (exec.type === "lib")
|
|
99
|
+
if (exec.type === "lib") {
|
|
100
100
|
for (const { relativePath, reason } of await exec.getPageConventionViolations()) addViolation(relativePath, reason);
|
|
101
|
+
if (await exec.exists(AppInfo.migrationDir))
|
|
102
|
+
addViolation(
|
|
103
|
+
AppInfo.migrationDir,
|
|
104
|
+
"a lib's migrations are never run; a migration goes in the script/migration of the app whose database it changes",
|
|
105
|
+
);
|
|
106
|
+
}
|
|
101
107
|
|
|
102
108
|
for (const filename of libRoot.files)
|
|
103
109
|
if (!isAllowedLibFacetRootFile(filename))
|
|
@@ -62,6 +62,10 @@ describe("lib root layout allowlist", () => {
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
test("admits a lib's own tooling folder, which nothing runs or ships", () => {
|
|
66
|
+
expect(libRootAllowedDirs.has("script")).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
|
|
65
69
|
test("rejects a lib root entry no facet owns", () => {
|
|
66
70
|
expect(libRootAllowedFiles.has("helper.ts")).toBe(false);
|
|
67
71
|
expect(libRootAllowedDirs.has("base")).toBe(false);
|
|
@@ -71,7 +75,7 @@ describe("lib root layout allowlist", () => {
|
|
|
71
75
|
for (const filename of ["main.ts", "akan.app.json"]) {
|
|
72
76
|
expect(libRootAllowedFiles.has(filename)).toBe(false);
|
|
73
77
|
}
|
|
74
|
-
for (const dirname of [".akan", "
|
|
78
|
+
for (const dirname of [".akan", "secrets"]) {
|
|
75
79
|
expect(libRootAllowedDirs.has(dirname)).toBe(false);
|
|
76
80
|
}
|
|
77
81
|
});
|
|
@@ -38,6 +38,7 @@ export const appRootAllowedDirs = new Set([
|
|
|
38
38
|
]);
|
|
39
39
|
|
|
40
40
|
// A library is never booted or packaged as an app, so the run/mobile entries are out; it is published, so README stays.
|
|
41
|
+
// Its `script/` holds the tooling that makes its own assets, which nothing runs or ships.
|
|
41
42
|
export const libRootAllowedFiles = new Set([
|
|
42
43
|
"AGENTS.md",
|
|
43
44
|
"CLAUDE.md",
|
|
@@ -63,6 +64,7 @@ export const libRootAllowedDirs = new Set([
|
|
|
63
64
|
"plugin",
|
|
64
65
|
"private",
|
|
65
66
|
"public",
|
|
67
|
+
"script",
|
|
66
68
|
"srvkit",
|
|
67
69
|
"ui",
|
|
68
70
|
"webkit",
|