@akanjs/devkit 3.3.0-rc.61 → 3.3.0-rc.62

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.
@@ -11,6 +11,8 @@ import { AkanAppConfig, AkanLibConfig, deriveDefaultAppId } from "./akanConfig";
11
11
  import {
12
12
  BUN_IMAGE_PIN,
13
13
  DEFAULT_DOCKER_IMAGE,
14
+ DOCKER_BASE_PACKAGES,
15
+ DOCKER_BASE_RUNS,
14
16
  DOCKER_INIT,
15
17
  DOCKERFILE_FORMAT,
16
18
  dockerfileLayoutOf,
@@ -488,6 +490,7 @@ describe("AkanAppConfig", () => {
488
490
  postRuns: ["echo post"],
489
491
  command: ["bun", "main.js"],
490
492
  crossBuild: true,
493
+ baseSetup: true,
491
494
  env: { REGION: "seoul", EDGE_MODE: "camera", AKAN_PUBLIC_OPERATION_MODE: "edge" },
492
495
  },
493
496
  });
@@ -541,6 +544,34 @@ describe("AkanAppConfig", () => {
541
544
  expect(later?.sections.get("warm")).toEqual(["RUN true"]);
542
545
  });
543
546
 
547
+ test("baseSetup false leaves the base step to the image, which then has to be named for every architecture", () => {
548
+ const configOf = (docker: object) => new AkanAppConfig(app, [], packageJson, { docker }, baseDevEnv);
549
+ const baseOf = (docker: object) => dockerfileLayoutOf(configOf(docker).dockerfile)?.sections.get("base");
550
+
551
+ expect(baseOf({})).toEqual([
552
+ `FROM ${DEFAULT_DOCKER_IMAGE}`,
553
+ `RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends ${DOCKER_BASE_PACKAGES.join(" ")} && rm -rf /var/lib/apt/lists/*`,
554
+ "RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime",
555
+ "ARG TARGETARCH",
556
+ ]);
557
+ expect(baseOf({})?.slice(1, -1)).toEqual(DOCKER_BASE_RUNS.map((run) => `RUN ${run}`));
558
+ expect(baseOf({ image: "registry.example.com/akan-base:1", baseSetup: false })).toEqual([
559
+ "FROM registry.example.com/akan-base:1",
560
+ "ARG TARGETARCH",
561
+ ]);
562
+ const edge = configOf({ variants: { edge: { image: "registry.example.com/akan-base:1", baseSetup: false } } });
563
+ expect(edge.dockerfile).toContain("apt-get update");
564
+ expect(edge.dockerfileFor("main", { variant: "edge" })).not.toContain("apt-get");
565
+
566
+ expect(() => configOf({ baseSetup: false })).toThrow("docker.baseSetup is false, so docker.image has to name");
567
+ expect(() => configOf({ baseSetup: false, image: { amd64: "registry.example.com/akan-base:1" } })).toThrow(
568
+ "for every architecture",
569
+ );
570
+ expect(() => configOf({ variants: { edge: { baseSetup: false } } })).toThrow(
571
+ "docker.variants.edge.baseSetup is false",
572
+ );
573
+ });
574
+
544
575
  test("the akanConfig entry carries the generator, for a tool that checks its edits against the installed one", async () => {
545
576
  const entry = await import("./index");
546
577
  expect(entry.dockerfileOf).toBe(dockerfileOf);
@@ -568,6 +599,7 @@ describe("AkanAppConfig", () => {
568
599
  postRuns: [],
569
600
  command: ["bun", "main.js"],
570
601
  crossBuild: false,
602
+ baseSetup: true,
571
603
  env: {},
572
604
  });
573
605
  });
@@ -19,6 +19,12 @@ export const DEFAULT_DOCKER_IMAGE = `oven/bun:${BUN_IMAGE_PIN.version}-slim@${BU
19
19
  export const DOCKER_RUN_USER = "1000:1000";
20
20
  //? Bun as PID 1 never waits for a process re-parented to it, which stays defunct; `-s` reaps under another init too.
21
21
  export const DOCKER_INIT = ["tini", "-s", "--"];
22
+ export const DOCKER_BASE_PACKAGES = ["ca-certificates", "tzdata", "tini"] as const;
23
+ //? Every generated image runs these on its base; an image built with them is one `baseSetup: false` can start from.
24
+ export const DOCKER_BASE_RUNS = [
25
+ `apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends ${DOCKER_BASE_PACKAGES.join(" ")} && rm -rf /var/lib/apt/lists/*`,
26
+ "ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime",
27
+ ];
22
28
  //? The directories the server writes, its code staying read-only; an empty named volume mounted on one takes its owner.
23
29
  export const DOCKER_WRITE_DIRS = [
24
30
  "/workspace/sqlite",
@@ -100,7 +106,7 @@ const dockerfileSectionOf = (section: DockerfileSection, instructions: string[])
100
106
  instructions.length ? [`${DOCKERFILE_MARK}${section}`, ...instructions] : [];
101
107
 
102
108
  export const dockerfileOf = (docker: DockerImageConfig, { env, lockfile, guard }: DockerfileParts) => {
103
- const { image, preRuns, postRuns, command, crossBuild } = docker;
109
+ const { image, preRuns, postRuns, command, crossBuild, baseSetup } = docker;
104
110
  const install = dockerInstallScripts(docker, lockfile);
105
111
  return [
106
112
  `${DOCKERFILE_HEAD}${DOCKERFILE_FORMAT}`,
@@ -118,8 +124,7 @@ export const dockerfileOf = (docker: DockerImageConfig, { env, lockfile, guard }
118
124
  ...dockerfileSectionOf("base", [
119
125
  dockerImageScript(image),
120
126
  ...(guard ? [guard] : []),
121
- "RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends ca-certificates tzdata tini && rm -rf /var/lib/apt/lists/*",
122
- "RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime",
127
+ ...(baseSetup ? dockerRunScripts(DOCKER_BASE_RUNS) : []),
123
128
  "ARG TARGETARCH",
124
129
  ]),
125
130
  ...dockerfileSectionOf("pre-runs", dockerRunScripts(preRuns)),
@@ -173,29 +178,37 @@ const dockerVariantNamePattern = /^[a-z][a-z0-9-]*$/;
173
178
  const resolveDockerImage = (
174
179
  docker: Partial<DockerImageConfig>,
175
180
  libDocker: LibDockerConfig,
176
- envOwner: string,
181
+ owner: string,
177
182
  ): DockerImageConfig => {
178
183
  const env = docker.env ?? {};
179
184
  for (const [key, value] of Object.entries(env)) {
180
185
  if (!dockerEnvKeyPattern.test(key))
181
- throw new Error(`[docker] ${envOwner} names "${key}", which is not an environment variable name`);
186
+ throw new Error(`[docker] ${owner}.env names "${key}", which is not an environment variable name`);
182
187
  if (/[\r\n]/.test(value))
183
- throw new Error(`[docker] ${envOwner}.${key} holds a line break, which an ENV line cannot carry`);
188
+ throw new Error(`[docker] ${owner}.env.${key} holds a line break, which an ENV line cannot carry`);
184
189
  }
190
+ const { image } = docker;
191
+ const baseSetup = docker.baseSetup ?? true;
192
+ //? The pinned default has no tini, the entrypoint: an image skipping the base step without one never starts.
193
+ if (!baseSetup && (!image || (typeof image !== "string" && archs.some((arch) => !image[arch]))))
194
+ throw new Error(
195
+ `[docker] ${owner}.baseSetup is false, so ${owner}.image has to name an image built with the base step, for every architecture`,
196
+ );
185
197
  return {
186
- image: docker.image ?? DEFAULT_DOCKER_IMAGE,
198
+ image: image ?? DEFAULT_DOCKER_IMAGE,
187
199
  preRuns: dedupeDockerRuns([...libDocker.preRuns, ...(docker.preRuns ?? [])]),
188
200
  installRuns: dedupeDockerRuns([...libDocker.installRuns, ...(docker.installRuns ?? [])]),
189
201
  postRuns: dedupeDockerRuns([...libDocker.postRuns, ...(docker.postRuns ?? [])]),
190
202
  command: docker.command ?? ["bun", "main.js"],
191
203
  crossBuild: docker.crossBuild ?? false,
204
+ baseSetup,
192
205
  env,
193
206
  };
194
207
  };
195
208
 
196
209
  /** A declared Dockerfile string is verbatim, so a lib's steps are dropped rather than silently unapplied. */
197
210
  export const resolveDocker = (docker: DockerOption | undefined, libDocker: LibDockerConfig): DockerConfig =>
198
- typeof docker === "string" ? docker : resolveDockerImage(docker ?? {}, libDocker, "docker.env");
211
+ typeof docker === "string" ? docker : resolveDockerImage(docker ?? {}, libDocker, "docker");
199
212
 
200
213
  export const resolveDockerVariants = (
201
214
  docker: DockerOption | undefined,
@@ -210,7 +223,7 @@ export const resolveDockerVariants = (
210
223
  `[docker] docker.variants names "${name}", which cannot end a file name: use lowercase letters, digits and "-"`,
211
224
  );
212
225
  const env = { ...base.env, ...variant.env };
213
- return [name, resolveDockerImage({ ...base, ...variant, env }, libDocker, `docker.variants.${name}.env`)];
226
+ return [name, resolveDockerImage({ ...base, ...variant, env }, libDocker, `docker.variants.${name}`)];
214
227
  }),
215
228
  );
216
229
  };
@@ -73,7 +73,7 @@ File names, stages, the `.render()` order and what a route file must never do ar
73
73
  locale under `i18n.localePrefix: "as-needed"`. It renders an `<a>` and takes its attributes; `activeClassName`
74
74
  marks the current one from the press, before its page arrives; an `active` prop from a layout's render is late.
75
75
  - An SSR page still loading: `pendingClassName` / `data-pending` on its `Link`, and `usePendingNavigation()`
76
- (`akanjs/client`) for its `{ path, searchParams }`, `null` once the page is drawn.
76
+ (`akanjs/client`) for its `{ path, searchParams }`, `null` once the page is drawn and for a page already held.
77
77
  - From a handler: `router.push(href)` / `router.replace(href)`; in a server stage, `router.redirect(href)`.
78
78
  - A page state a push opens in the query (a record in `?id=`): close it with `router.backOrReplace(href)`, never
79
79
  `router.back()` or a `renderMode` branch. A CSR or native stack rewrites a push that keeps the pathname rather than
@@ -15,7 +15,7 @@ the agent guide's Path Rules table.
15
15
  | --- | --- |
16
16
  | API only, or no CSR bundle for native apps | `web: false`, `web: { csr: false }` |
17
17
  | Move the API or websocket mount | `new AkanApp({ prefix, websocketPrefix })` in `main.ts`, mirrored in `api: { … }`; read with `getApiPrefix()` / `getWsPrefix()` |
18
- | The production image | `docker: string \| { image, preRuns, installRuns, postRuns, command, crossBuild, env, variants }` |
18
+ | The production image | `docker: string \| { image, preRuns, installRuns, postRuns, command, crossBuild, baseSetup, env, variants }` |
19
19
  | iOS, Android, desktop | the `native` section; `desktop: { server: true }` carries the server |
20
20
  | SQLite, several databases, a cluster | `database: { modes: [...] }` (`single`, `multiple`, `cluster`), picked by `AKAN_DATABASE_MODE` |
21
21
  | A secret of `env/env.server.<env>.ts` in a deployed server | nothing to declare: `akan build` leaves it out and the server reads it from a variable named after its key path; `akan secret-env <app> --env <env>` lists them |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "3.3.0-rc.61",
3
+ "version": "3.3.0-rc.62",
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.61",
53
+ "@akanjs/language": "3.3.0-rc.62",
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.61",
62
+ "akanjs": "3.3.0-rc.62",
63
63
  "chalk": "^6.0.1",
64
64
  "commander": "^15.0.0",
65
65
  "dayjs": "^1.11.23",