@akanjs/devkit 3.3.0-rc.5 → 3.3.0-rc.51
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 +686 -0
- package/DEV_RUNTIME_KNOBS.md +1 -1
- package/README.ko.md +3 -2
- package/README.md +3 -3
- package/akanApp/akanApp.host.test.ts +1 -1
- package/akanApp/akanApp.host.ts +11 -0
- package/akanConfig/akanBin.ts +4 -0
- package/akanConfig/akanConfig.test.ts +70 -10
- package/akanConfig/akanConfig.ts +71 -206
- package/akanConfig/akanWorkers.test.ts +73 -0
- package/akanConfig/akanWorkers.ts +61 -0
- package/akanConfig/desktopServerConfig.ts +96 -0
- package/akanConfig/dockerImage.ts +39 -0
- package/akanConfig/index.ts +1 -0
- package/akanConfig/nativeKeys.ts +52 -0
- package/akanConfig/types.ts +1 -0
- package/app/appBin.test.ts +63 -0
- package/app/appBin.ts +50 -0
- package/app/applicationBuildReporter.test.ts +49 -0
- package/app/applicationBuildReporter.ts +5 -0
- package/app/applicationBuildRunner.test.ts +279 -4
- package/app/applicationBuildRunner.ts +147 -12
- package/app/dictionarySizes.ts +91 -0
- package/app/routeFilesReport.test.ts +59 -0
- package/app/routeFilesReport.ts +46 -0
- package/app/routeJsBudget.ts +18 -4
- package/artifact/implicitRootLayout.test.ts +19 -0
- package/artifact/implicitRootLayout.ts +16 -2
- package/artifact/implicitRootLayoutRender.test.tsx +4 -1
- package/artifact/storeBootstrap.test.ts +28 -0
- package/artifact/storeBootstrap.ts +64 -8
- package/biome.base.json +7 -5
- 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-deps/SKILL.md +3 -2
- package/codeAgent/skills/akan-err/SKILL.md +13 -8
- package/codeAgent/skills/akan-mcp/SKILL.md +1 -1
- package/codeAgent/skills/akan-module/SKILL.md +2 -2
- package/codeAgent/skills/akan-page/SKILL.md +34 -26
- package/codeAgent/skills/akan-query/SKILL.md +13 -20
- package/codeAgent/skills/akan-runtime/SKILL.md +20 -0
- package/codeAgent/skills/akan-service/SKILL.md +10 -11
- package/codeAgent/skills/akan-transport/SKILL.md +5 -14
- package/codeAgent/skills/akan-ui/SKILL.md +2 -5
- package/context/akanContext.ts +2 -0
- package/csrE2e/devHmrLatency.e2e.test.ts +1 -1
- package/docs/apiReference.test.ts +9 -0
- package/docs/apiReference.ts +14 -0
- package/executors/appExecutor.ts +10 -5
- package/executors/clientRuntimeKeyOrder.fixture.json +682 -0
- package/executors/clientRuntimeKeys.fixture.json +393 -0
- package/executors/clientRuntimeKeys.test.ts +1690 -0
- package/executors/executor.ts +12 -4
- package/executors/executors.test.ts +24 -0
- package/executors/sysExecutor.ts +80 -5
- package/executors/workspaceExecutor.ts +7 -4
- package/frontendBuild/allRoutesBuilder.ts +99 -7
- package/frontendBuild/autoImportSync.ts +3 -2
- package/frontendBuild/buildRouteClient.test.ts +686 -13
- package/frontendBuild/clientBuildTypes.ts +26 -0
- package/frontendBuild/clientEntriesBundler.ts +49 -1
- package/frontendBuild/clientEntryDiscovery.test.ts +308 -1
- package/frontendBuild/clientEntryDiscovery.ts +136 -14
- package/frontendBuild/clientEntryGroups.test.ts +77 -0
- package/frontendBuild/clientEntryGroups.ts +61 -0
- package/frontendBuild/csrDevArtifactWriter.ts +2 -2
- package/frontendBuild/csrDevModuleCompiler.test.ts +86 -0
- package/frontendBuild/csrDevModuleCompiler.ts +44 -8
- package/frontendBuild/csrDevPatcher.test.ts +1 -1
- package/frontendBuild/csrDevPatcher.ts +33 -7
- package/frontendBuild/csrDevTypes.ts +9 -0
- package/frontendBuild/devBarrelImports.test.ts +154 -0
- package/frontendBuild/devBarrelImports.ts +83 -23
- package/frontendBuild/devRegistryBundler.ts +4 -2
- package/frontendBuild/devRouteRuntime.test.ts +492 -0
- package/frontendBuild/devRouteRuntime.ts +167 -0
- package/frontendBuild/dictionaryAssetBuilder.test.ts +329 -0
- package/frontendBuild/dictionaryAssetBuilder.ts +165 -16
- package/frontendBuild/dictionaryConstants.ts +136 -0
- package/frontendBuild/dictionaryPacking.test.ts +142 -0
- package/frontendBuild/dictionaryPacking.ts +135 -0
- package/frontendBuild/dictionaryRoutes.test.ts +251 -0
- package/frontendBuild/dictionaryRoutes.ts +227 -0
- package/frontendBuild/pagesBundleBuilder.test.ts +84 -0
- package/frontendBuild/pagesBundleBuilder.ts +81 -3
- package/frontendBuild/precompressArtifacts.test.ts +22 -0
- package/frontendBuild/precompressArtifacts.ts +22 -8
- package/frontendBuild/registryMetadataFingerprint.ts +3 -3
- package/frontendBuild/renderedEntries.ts +144 -0
- package/frontendBuild/routeClientBuilder.ts +407 -43
- package/frontendBuild/routeHandoffs.test.ts +155 -0
- package/frontendBuild/routeHandoffs.ts +117 -0
- package/frontendBuild/routeModulePreloads.test.ts +32 -0
- package/frontendBuild/routeModulePreloads.ts +20 -11
- package/frontendBuild/routeRuntimeCheck.test.ts +280 -0
- package/frontendBuild/routeRuntimeCheck.ts +248 -0
- package/frontendBuild/routeRuntimePays.test.ts +143 -0
- package/frontendBuild/routeRuntimePays.ts +117 -0
- package/frontendBuild/rscServerRendererGuard.test.ts +60 -0
- package/frontendBuild/rscServerRendererGuard.ts +68 -0
- package/frontendBuild/ssrBaseArtifactBuilder.ts +24 -34
- package/frontendBuild/ssrDevBundler.test.ts +150 -1
- package/frontendBuild/ssrDevBundler.ts +66 -11
- package/frontendBuild/vendorFileImports.test.ts +254 -0
- package/frontendBuild/vendorFileImports.ts +163 -0
- package/frontendBuild/vendorNarrowing.ts +28 -0
- package/frontendBuild/vendorSpecifiers.ts +2 -0
- package/incrementalBuilder/buildBatch.proc.ts +9 -9
- package/incrementalBuilder/buildBatchProtocol.ts +1 -1
- package/incrementalBuilder/builderBoot.ts +5 -5
- 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.proc.test.ts +79 -0
- package/incrementalBuilder/incrementalBuilder.proc.ts +27 -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/lint/__fixtures__/no-arbitrary-color/every-color-function/bad.tsx +11 -0
- package/lint/__fixtures__/no-arbitrary-color/every-color-function/good.tsx +2 -0
- package/lint/__fixtures__/no-daisyui-legacy-class/every-class/bad.tsx +34 -0
- package/lint/__fixtures__/no-daisyui-legacy-class/every-class/good.tsx +2 -0
- package/lint/__fixtures__/no-inline-color/every-color-function/bad.tsx +10 -0
- package/lint/__fixtures__/no-inline-color/every-color-function/good.tsx +2 -0
- package/lint/__fixtures__/no-raw-palette-class/every-palette/bad.tsx +22 -0
- package/lint/__fixtures__/no-raw-palette-class/every-palette/good.tsx +2 -0
- package/lint/biomeBase.test.ts +50 -3
- package/lint/biomeBase.ts +1 -1
- package/lint/biomeCheck.test.ts +162 -0
- package/lint/biomeCheck.ts +131 -0
- package/lint/linter.test.ts +16 -11
- package/lint/no-arbitrary-color.grit +5 -0
- package/lint/no-conditional-st-hook.grit +5 -1
- package/lint/no-daisyui-legacy-class.grit +8 -0
- package/lint/no-document-cookie.grit +3 -0
- package/lint/no-inline-color.grit +10 -2
- package/lint/no-oversized-list-limit.grit +2 -0
- package/lint/no-raw-palette-class.grit +7 -0
- package/lint/no-unpublished-form-setter.grit +2 -0
- package/lint/no-web-only-api-outside-webkit.grit +5 -0
- package/lint/no-web-storage.grit +3 -0
- package/lint/withheldEnvFile.ts +17 -0
- package/mobile/desktopBin.ts +2 -2
- package/mobile/desktopServerStage.test.ts +9 -2
- package/mobile/desktopServerStage.ts +1 -0
- package/mobile/nativeApp.test.ts +7 -5
- package/mobile/nativeApp.ts +2 -2
- package/mobile/nativeConfig.test.ts +96 -1
- package/mobile/nativeConfig.ts +46 -12
- package/mobile/nativePublicEnv.ts +1 -1
- package/mobile/serverBundleSecrets.ts +43 -0
- package/package.json +15 -169
- package/packageExports.test.ts +38 -24
- package/quality/dictionaryKeys.test.ts +356 -0
- package/quality/dictionaryKeys.ts +488 -0
- package/quality/objectImportReport.test.ts +36 -0
- package/quality/objectImportReport.ts +105 -0
- package/quality/qualityScanner.ts +1 -1
- package/quality/routeRuntimeReport.test.ts +91 -0
- package/quality/routeRuntimeReport.ts +121 -0
- package/quality/runtimeConstantFacts.ts +71 -0
- package/quality/runtimeConstantGraph.ts +123 -0
- package/quality/runtimeConstantReads.ts +116 -0
- package/quality/runtimeImports.test.ts +190 -0
- package/quality/runtimeImports.ts +233 -0
- package/quality/runtimeKeyNames.ts +46 -0
- package/quality/runtimeLexicalScope.ts +132 -0
- package/quality/runtimeMarkerReach.test.ts +84 -0
- package/quality/runtimeMarkerReach.ts +255 -0
- package/quality/runtimeModuleFacts.ts +290 -0
- package/quality/runtimeNameTable.test.ts +172 -0
- package/quality/runtimeNameTable.ts +477 -0
- package/quality/runtimeScopeReport.test.ts +123 -0
- package/quality/runtimeScopeReport.ts +167 -0
- package/quality/runtimeSliceKey.ts +269 -0
- package/quality/runtimeSyntax.ts +133 -0
- package/quality/runtimeTable.fixture.ts +189 -0
- package/quality/runtimeUse.test.ts +737 -0
- package/quality/runtimeUse.ts +696 -0
- package/quality/runtimeUseReadable.test.ts +393 -0
- package/quality/ssrScanner.test.ts +13 -0
- package/quality/ssrScanner.ts +1 -1
- package/quality/translatorBindings.ts +187 -0
- package/test/secretEnvFixture.ts +134 -0
- package/test/testHelpers.ts +11 -0
- package/transforms/barrelAnalyzer.ts +26 -4
- package/transforms/barrelImportsPlugin.ts +121 -32
- package/transforms/exportReach.test.ts +162 -0
- package/transforms/exportReach.ts +308 -0
- package/transforms/frameworkObjects.fixture.tsx +58 -0
- package/transforms/frameworkObjects.test.ts +54 -0
- package/transforms/modelReference.test.ts +196 -0
- package/transforms/modelReference.ts +39 -0
- package/transforms/moduleParts.test.ts +225 -0
- package/transforms/moduleParts.ts +418 -0
- package/transforms/objectImportEdits.ts +150 -0
- package/transforms/objectMemberImports.test.ts +633 -0
- package/transforms/objectMemberImports.ts +571 -0
- package/transforms/objectMemberLookup.ts +150 -0
- package/transforms/objectModule.test.ts +307 -0
- package/transforms/objectModule.ts +482 -0
- package/transforms/objectModuleAnalyzer.ts +104 -0
- package/transforms/partImports.test.ts +76 -0
- package/transforms/partImports.ts +110 -0
- package/transforms/partModules.test.ts +187 -0
- package/transforms/partModules.ts +90 -0
- package/transforms/partPurity.ts +124 -0
- package/transforms/reactIconImports.test.ts +231 -0
- package/transforms/reactIconImports.ts +325 -0
- package/transforms/routeConstants.ts +122 -0
- package/transforms/routeRuntime.test.ts +835 -0
- package/transforms/routeRuntime.ts +703 -0
- package/transforms/routeRuntimeEdits.ts +92 -0
- package/transforms/routeRuntimeGraph.ts +66 -0
- package/transforms/routeRuntimePlan.ts +244 -0
- package/transforms/secretEnvDeclaration.test.ts +208 -0
- package/transforms/secretEnvDeclaration.ts +213 -0
- package/transforms/secretEnvFile.test.ts +117 -0
- package/transforms/secretEnvFile.ts +113 -0
- package/transforms/secretEnvName.test.ts +54 -0
- package/transforms/secretEnvName.ts +29 -0
- package/transforms/secretEnvSource.test.ts +148 -0
- package/transforms/secretEnvSource.ts +166 -0
- package/transforms/serverEnvEvaluationError.ts +11 -0
- package/transforms/serverEnvPlugin.test.ts +2 -1
- package/transforms/serverEnvPlugin.ts +13 -0
- package/transforms/serverEnvProfile.test.ts +115 -2
- package/transforms/serverEnvProfile.ts +117 -40
- package/transforms/serverEnvSecrets.test.ts +292 -0
- package/transforms/signalDescriptors.test.ts +280 -0
- package/transforms/signalDescriptors.ts +227 -0
- package/transforms/thisFreeExports.ts +87 -0
- package/transforms/transforms.test.ts +180 -3
- package/transforms/tsconfigPackageResolver.test.ts +1 -0
- package/tunnel/createTunnel.test.ts +29 -8
- package/tunnel/createTunnel.ts +18 -11
- package/typecheck/projectTypecheck.test.ts +32 -1
- package/typecheck/projectTypecheck.ts +3 -3
- package/typecheck/typeChecker.test.ts +49 -0
- package/typecheck/typeChecker.ts +9 -7
- package/typecheck/withheldDiagnostics.ts +41 -0
- package/util/fileEditor.ts +1 -0
- package/util/selectModel.ts +1 -0
- package/workflow/executor.ts +6 -2
- package/workflow/index.ts +1 -0
- package/workflow/plan.ts +36 -7
- package/workflow/types.ts +1 -1
- package/workflow/uiTarget.ts +50 -0
- package/workspace/getRelatedCnsts.ts +7 -0
- package/workspace/scanInfo.test.ts +39 -0
- package/workspace/scanInfo.ts +55 -6
- package/workspace/slicePlanner.ts +1 -1
- package/workspace/workspaceLayout.test.ts +5 -1
- package/workspace/workspaceLayout.ts +3 -0
package/DEV_RUNTIME_KNOBS.md
CHANGED
|
@@ -83,7 +83,7 @@ reporting ready until the file it names exists.
|
|
|
83
83
|
|
|
84
84
|
| variable | default | what it does |
|
|
85
85
|
|---|---|---|
|
|
86
|
-
| `AKAN_MEMORY_LOG` | off | `=1` logs a periodic memory report from each server role. |
|
|
86
|
+
| `AKAN_MEMORY_LOG` | off | `=1` logs a periodic memory report from each server role, and adds `rscFirstRenderMemory` (each route's first-render growth and loaded modules) to the RSC worker's metrics. |
|
|
87
87
|
| `AKAN_MEMORY_LOG_INTERVAL_MS` | `60000` | How often that report is written. |
|
|
88
88
|
| `AKAN_MEMORY_GC_ON_REPORT` | off | `=1` forces a GC before each report, so the number is retained memory rather than garbage. Costs a full GC per report. |
|
|
89
89
|
|
package/README.ko.md
CHANGED
|
@@ -39,8 +39,9 @@ await runner.build();
|
|
|
39
39
|
|
|
40
40
|
값은 그것을 가진 facet에서 import합니다(`@akanjs/devkit/executors`, `@akanjs/devkit/akanConfig`,
|
|
41
41
|
`@akanjs/devkit/workflow` 등). 루트 `@akanjs/devkit` 진입점은 타입만 내보내므로, 도구 하나를 불러도 모든 facet이
|
|
42
|
-
프로세스에 올라오지 않습니다. facet
|
|
43
|
-
`
|
|
42
|
+
프로세스에 올라오지 않습니다. facet 외에는 `exports`가 이름을 붙인 몇몇 파일(`app/applicationBuildRunner`,
|
|
43
|
+
`cloud/cloudApi`, `mobile/desktopRelease` 등)만 공개되며, 그 밖의 파일은 `akan` 명령의 내부 구현이라 패키지 밖에서
|
|
44
|
+
resolve되지 않습니다.
|
|
44
45
|
|
|
45
46
|
## 제공하는 것
|
|
46
47
|
|
package/README.md
CHANGED
|
@@ -38,9 +38,9 @@ await runner.build();
|
|
|
38
38
|
|
|
39
39
|
Import values from the facet that owns them (`@akanjs/devkit/executors`, `@akanjs/devkit/akanConfig`,
|
|
40
40
|
`@akanjs/devkit/workflow`, …). The root `@akanjs/devkit` entry exports types only, so loading a tool does not pull
|
|
41
|
-
every facet into the process.
|
|
42
|
-
`
|
|
43
|
-
|
|
41
|
+
every facet into the process. Besides the facets, `exports` names a few files (`app/applicationBuildRunner`,
|
|
42
|
+
`cloud/cloudApi`, `mobile/desktopRelease`, …); any other file is internal to the `akan` command and does not resolve
|
|
43
|
+
from outside the package.
|
|
44
44
|
|
|
45
45
|
## What It Provides
|
|
46
46
|
|
|
@@ -52,7 +52,7 @@ describe("Redis tunnels during dev startup", () => {
|
|
|
52
52
|
const listener = Bun.listen({ hostname: "127.0.0.1", port: 0, socket: { data() {} } });
|
|
53
53
|
const port = listener.port;
|
|
54
54
|
listener.stop(true);
|
|
55
|
-
process.env
|
|
55
|
+
Object.assign(process.env, { SSH_TUNNEL_PORT: String(port), SSH_TUNNEL_PASSWORD: "test-password" });
|
|
56
56
|
if (mode === "local") process.env.AKAN_PUBLIC_ENV = "local";
|
|
57
57
|
const create = IncrementalBuilderHost.create;
|
|
58
58
|
IncrementalBuilderHost.create = async () =>
|
package/akanApp/akanApp.host.ts
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Logger } from "akanjs/common";
|
|
4
4
|
import type { BuilderMessage } from "akanjs/server";
|
|
5
|
+
import { AppBin } from "../app/appBin";
|
|
5
6
|
import type { App } from "../commandDecorators";
|
|
6
7
|
import { WorkspaceExecutor } from "../executors";
|
|
7
8
|
import type { DevStdioMode } from "../incrementalBuilder";
|
|
@@ -199,8 +200,18 @@ export class AkanAppHost {
|
|
|
199
200
|
}
|
|
200
201
|
if (!this.#backend.running) this.#backend.start();
|
|
201
202
|
this.#idle.arm();
|
|
203
|
+
void this.#warnMissingBin();
|
|
202
204
|
return this;
|
|
203
205
|
}
|
|
206
|
+
//? A bin two libs declare differently fails the build that carries it; a dev start has nothing to carry.
|
|
207
|
+
async #warnMissingBin() {
|
|
208
|
+
const names = await this.app
|
|
209
|
+
.getConfig()
|
|
210
|
+
.then((config) => new AppBin(this.app, config).names())
|
|
211
|
+
.catch(() => []);
|
|
212
|
+
const missing = AppBin.missing(names);
|
|
213
|
+
if (missing) this.logger.warn(missing);
|
|
214
|
+
}
|
|
204
215
|
async stop() {
|
|
205
216
|
//? Nothing reapplies once it stops: a pages ok received meanwhile would bring children back after it.
|
|
206
217
|
this.#stopping = true;
|
package/akanConfig/akanBin.ts
CHANGED
|
@@ -23,6 +23,10 @@ export class AkanBin {
|
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
static imagePath(binDir: string) {
|
|
27
|
+
return `/workspace/${binDir}/$TARGETARCH:$PATH`;
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
static isArchive(source: AkanBinSource): boolean {
|
|
27
31
|
return AkanBin.archive.test("url" in source ? new URL(source.url).pathname : source.path);
|
|
28
32
|
}
|
|
@@ -6,7 +6,9 @@ import { fileURLToPath } from "node:url";
|
|
|
6
6
|
import { AppExecutor, WorkspaceExecutor } from "../executors";
|
|
7
7
|
import { NativeConfig } from "../mobile/nativeConfig";
|
|
8
8
|
import type { PackageJson } from "../workspace/types";
|
|
9
|
+
import { AkanBin } from "./akanBin";
|
|
9
10
|
import { AkanAppConfig, AkanLibConfig, deriveDefaultAppId } from "./akanConfig";
|
|
11
|
+
import { BUN_IMAGE_PIN, DEFAULT_DOCKER_IMAGE } from "./dockerImage";
|
|
10
12
|
import type { LibConfigInput } from "./types";
|
|
11
13
|
|
|
12
14
|
const akanPackageJson = JSON.parse(
|
|
@@ -15,7 +17,14 @@ const akanPackageJson = JSON.parse(
|
|
|
15
17
|
const rootPackageJson = JSON.parse(
|
|
16
18
|
fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), "../../../../package.json"), "utf8"),
|
|
17
19
|
) as { engines: { bun: string } };
|
|
18
|
-
const
|
|
20
|
+
const writeDirsStep =
|
|
21
|
+
"RUN mkdir -p /workspace/sqlite /workspace/local /workspace/runtime /workspace/data /workspace/.akan/artifact/image-cache && chown 1000:1000 /workspace/sqlite /workspace/local /workspace/runtime /workspace/data /workspace/.akan/artifact/image-cache";
|
|
22
|
+
const setupActionBunVersion = /bun-version:\s*(\S+)/.exec(
|
|
23
|
+
fs.readFileSync(
|
|
24
|
+
path.join(path.dirname(fileURLToPath(import.meta.url)), "../../../../.github/actions/setup/action.yml"),
|
|
25
|
+
"utf8",
|
|
26
|
+
),
|
|
27
|
+
)?.[1];
|
|
19
28
|
|
|
20
29
|
const packageJson: PackageJson = {
|
|
21
30
|
name: "repo",
|
|
@@ -166,6 +175,16 @@ describe("AkanAppConfig", () => {
|
|
|
166
175
|
expect(unlocked).not.toContain("bun.lock");
|
|
167
176
|
});
|
|
168
177
|
|
|
178
|
+
test("a PATH the build hands in lands after the TARGETARCH it reads and the files it points at", () => {
|
|
179
|
+
const config = new AkanAppConfig(app, [], packageJson, {}, baseDevEnv);
|
|
180
|
+
const carrying = config.dockerfileFor("main", { env: { PATH: AkanBin.imagePath("bin") } });
|
|
181
|
+
|
|
182
|
+
expect(carrying).toContain("ENV PATH=/workspace/bin/$TARGETARCH:$PATH\n");
|
|
183
|
+
expect(carrying.indexOf("ARG TARGETARCH")).toBeLessThan(carrying.indexOf("ENV PATH="));
|
|
184
|
+
expect(carrying.indexOf("COPY . .")).toBeLessThan(carrying.indexOf("ENV PATH="));
|
|
185
|
+
expect(config.dockerfileFor("main")).not.toContain("ENV PATH=");
|
|
186
|
+
});
|
|
187
|
+
|
|
169
188
|
test.skipIf(process.platform === "win32")(
|
|
170
189
|
"writes a Dockerfile for a local build that refuses docker build without an explicit build arg",
|
|
171
190
|
() => {
|
|
@@ -180,7 +199,7 @@ describe("AkanAppConfig", () => {
|
|
|
180
199
|
env: { PATH: process.env.PATH ?? "", ...(allow ? { AKAN_ALLOW_LOCAL_IMAGE: allow } : {}) },
|
|
181
200
|
});
|
|
182
201
|
|
|
183
|
-
expect(local).toContain(`FROM ${
|
|
202
|
+
expect(local).toContain(`FROM ${DEFAULT_DOCKER_IMAGE}\nARG AKAN_ALLOW_LOCAL_IMAGE\nRUN if`);
|
|
184
203
|
expect(config.dockerfileFor("main")).not.toContain("AKAN_ALLOW_LOCAL_IMAGE");
|
|
185
204
|
expect(run().exitCode).toBe(1);
|
|
186
205
|
expect(run().stderr.toString()).toContain("--build-arg AKAN_ALLOW_LOCAL_IMAGE=1");
|
|
@@ -240,7 +259,9 @@ describe("AkanAppConfig", () => {
|
|
|
240
259
|
const envBlock = Object.entries(config.getProductionEnv())
|
|
241
260
|
.map(([key, value]) => `ENV ${key}=${value}`)
|
|
242
261
|
.join("\n");
|
|
243
|
-
expect(config.dockerfile).toContain(
|
|
262
|
+
expect(config.dockerfile).toContain(
|
|
263
|
+
`COPY . .\n${writeDirsStep}\n${envBlock}\nUSER 1000:1000\nENTRYPOINT ["tini","-s","--"]\nCMD ["bun","main.js"]`,
|
|
264
|
+
);
|
|
244
265
|
});
|
|
245
266
|
|
|
246
267
|
test('publishes localePrefix "as-needed" to the bundles and the image, and leaves the default out of the image', () => {
|
|
@@ -255,19 +276,19 @@ describe("AkanAppConfig", () => {
|
|
|
255
276
|
});
|
|
256
277
|
|
|
257
278
|
test("writes the Dockerfile instructions it wrote before its env came from getProductionEnv", () => {
|
|
258
|
-
//? 9adfb95c's output for this config, less the blank lines its empty interpolations left
|
|
279
|
+
//? 9adfb95c's output for this config, less the blank lines its empty interpolations left, its floating tag and root, plus the init.
|
|
259
280
|
const before = [
|
|
260
|
-
`FROM ${
|
|
261
|
-
"RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends ca-certificates tzdata && rm -rf /var/lib/apt/lists/*",
|
|
281
|
+
`FROM ${DEFAULT_DOCKER_IMAGE}`,
|
|
282
|
+
"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/*",
|
|
262
283
|
"RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime",
|
|
263
284
|
"ARG TARGETARCH",
|
|
264
285
|
"",
|
|
265
|
-
"RUN mkdir -p /workspace",
|
|
266
286
|
"WORKDIR /workspace",
|
|
267
287
|
"COPY ./package.json ./bun.lock ./",
|
|
268
288
|
"RUN bun install --production --frozen-lockfile",
|
|
269
289
|
"",
|
|
270
290
|
"COPY . .",
|
|
291
|
+
writeDirsStep,
|
|
271
292
|
"ENV PORT=8282",
|
|
272
293
|
"ENV NODE_ENV=production",
|
|
273
294
|
"ENV AKAN_PUBLIC_REPO_NAME=akanjs",
|
|
@@ -283,6 +304,8 @@ describe("AkanAppConfig", () => {
|
|
|
283
304
|
"ENV AKAN_DATABASE_MODES=single",
|
|
284
305
|
"ENV AKAN_LOG_TO_FILE=0",
|
|
285
306
|
"",
|
|
307
|
+
"USER 1000:1000",
|
|
308
|
+
'ENTRYPOINT ["tini","-s","--"]',
|
|
286
309
|
'CMD ["bun","main.js"]',
|
|
287
310
|
];
|
|
288
311
|
const lines = (text: string) => text.split("\n").filter((line) => line !== "");
|
|
@@ -296,17 +319,44 @@ describe("AkanAppConfig", () => {
|
|
|
296
319
|
).toThrow("the native apps ship that bundle");
|
|
297
320
|
});
|
|
298
321
|
|
|
299
|
-
test("installs only ca-certificates and
|
|
322
|
+
test("installs only ca-certificates, tzdata and the init in the default image", () => {
|
|
300
323
|
const config = new AkanAppConfig(app, [], packageJson, {}, baseDevEnv);
|
|
301
324
|
|
|
302
325
|
expect(config.dockerfile).toContain(
|
|
303
|
-
"RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends ca-certificates tzdata && rm -rf /var/lib/apt/lists/*",
|
|
326
|
+
"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/*",
|
|
304
327
|
);
|
|
305
328
|
// The Chromium/ffmpeg toolchain moved to per-app `preRuns`; keeping it here paid for it in every image.
|
|
306
329
|
for (const dropped of ["libnss3", "ffmpeg", "build-essential", "redis", "xdg-utils"])
|
|
307
330
|
expect(config.dockerfile).not.toContain(dropped);
|
|
308
331
|
});
|
|
309
332
|
|
|
333
|
+
test("pins the default image to the Bun release the repo runs, by the digest kept beside that version", () => {
|
|
334
|
+
expect(rootPackageJson.engines.bun).toBe(BUN_IMAGE_PIN.version);
|
|
335
|
+
expect(setupActionBunVersion).toBe(rootPackageJson.engines.bun);
|
|
336
|
+
expect(BUN_IMAGE_PIN.digest).toMatch(/^sha256:[0-9a-f]{64}$/);
|
|
337
|
+
expect(DEFAULT_DOCKER_IMAGE).toBe(`oven/bun:${BUN_IMAGE_PIN.version}-slim@${BUN_IMAGE_PIN.digest}`);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
test("runs the generated image as the bun user once every root step is done, owning only what it writes", () => {
|
|
341
|
+
const config = new AkanAppConfig(
|
|
342
|
+
app,
|
|
343
|
+
[],
|
|
344
|
+
packageJson,
|
|
345
|
+
{ docker: { preRuns: ["apt-get install -y ffmpeg"], postRuns: ["echo after"] } },
|
|
346
|
+
baseDevEnv,
|
|
347
|
+
);
|
|
348
|
+
const instructions = config.dockerfile.split("\n").filter((line) => line !== "");
|
|
349
|
+
const userAt = instructions.indexOf("USER 1000:1000");
|
|
350
|
+
|
|
351
|
+
expect(instructions.filter((line) => line.startsWith("USER "))).toEqual(["USER 1000:1000"]);
|
|
352
|
+
expect(instructions.slice(userAt + 1)).toEqual(['ENTRYPOINT ["tini","-s","--"]', 'CMD ["bun","main.js"]']);
|
|
353
|
+
for (const rootStep of ["apt-get update", "apt-get install -y ffmpeg", "bun install", "echo after"])
|
|
354
|
+
expect(instructions.findIndex((line) => line.includes(rootStep))).toBeLessThan(userAt);
|
|
355
|
+
expect(instructions.filter((line) => line.includes("--chown"))).toEqual([]);
|
|
356
|
+
expect(instructions[instructions.indexOf("COPY . .") + 1]).toBe(writeDirsStep);
|
|
357
|
+
expect(instructions.filter((line) => line.includes("chown") && / \/workspace( |$)/.test(line))).toEqual([]);
|
|
358
|
+
});
|
|
359
|
+
|
|
310
360
|
test("keeps a declared Dockerfile string verbatim", () => {
|
|
311
361
|
const dockerfile = 'FROM oven/bun:1-slim\nCOPY . .\nCMD ["bun","main.js"]';
|
|
312
362
|
const config = new AkanAppConfig(app, [], packageJson, { docker: dockerfile }, baseDevEnv);
|
|
@@ -319,7 +369,7 @@ describe("AkanAppConfig", () => {
|
|
|
319
369
|
const config = new AkanAppConfig(app, [], packageJson, { docker: { preRuns: ["echo hi"] } }, baseDevEnv);
|
|
320
370
|
|
|
321
371
|
expect(config.docker).toEqual({
|
|
322
|
-
image:
|
|
372
|
+
image: DEFAULT_DOCKER_IMAGE,
|
|
323
373
|
preRuns: ["echo hi"],
|
|
324
374
|
postRuns: [],
|
|
325
375
|
command: ["bun", "main.js"],
|
|
@@ -870,6 +920,16 @@ describe("AkanAppConfig", () => {
|
|
|
870
920
|
expect(make({ native: { desktop: { dmg: { backgroundImage: "bg.png" } } } })).toThrow(
|
|
871
921
|
"native.desktop.dmg.backgroundImage in apps/portal/akan.config.ts is not a native setting",
|
|
872
922
|
);
|
|
923
|
+
expect(make({ native: { desktop: { externalView: { origins: ["https://board.example"] } } } })).toThrow(
|
|
924
|
+
"native.desktop.externalView.origins in apps/portal/akan.config.ts is not a native setting. Known: allowOrigins, evaluate, sendKey.",
|
|
925
|
+
);
|
|
926
|
+
expect(
|
|
927
|
+
make({
|
|
928
|
+
native: {
|
|
929
|
+
desktop: { externalView: { allowOrigins: ["https://board.example"], evaluate: true, sendKey: true } },
|
|
930
|
+
},
|
|
931
|
+
}),
|
|
932
|
+
).not.toThrow();
|
|
873
933
|
});
|
|
874
934
|
|
|
875
935
|
test("derives a repo-scoped default appId and records an explicit native section", () => {
|
package/akanConfig/akanConfig.ts
CHANGED
|
@@ -4,39 +4,46 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
import type { AkanPlugin } from "akanjs";
|
|
5
5
|
import { DatabaseModes, normalizeRoutePrefix } from "akanjs/base";
|
|
6
6
|
import { type AkanI18nConfig, resolveAkanI18nConfig, trimSlashes } from "akanjs/common";
|
|
7
|
-
import type { ServerPolicy } from "akanjs/native/api";
|
|
8
7
|
import type { AkanImageConfig } from "akanjs/server";
|
|
9
8
|
import type { App, Lib } from "../commandDecorators";
|
|
10
9
|
import { WorkspaceExecutor } from "../executors/workspaceExecutor";
|
|
11
|
-
import { ServerEnvProfile } from "../transforms/serverEnvProfile";
|
|
12
10
|
import type { BaseDevEnv, PackageJson } from "../workspace/types";
|
|
13
11
|
import { AkanBin } from "./akanBin";
|
|
12
|
+
import { AkanWorkers, type LibWorkers } from "./akanWorkers";
|
|
13
|
+
import { DesktopServerConfig } from "./desktopServerConfig";
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
15
|
+
DEFAULT_DOCKER_IMAGE,
|
|
16
|
+
DOCKER_INIT,
|
|
17
|
+
DOCKER_RUN_USER,
|
|
18
|
+
DOCKER_WRITE_DIRS,
|
|
19
|
+
dockerImageScript,
|
|
20
|
+
dockerRunScripts,
|
|
21
|
+
} from "./dockerImage";
|
|
22
|
+
import { nativeKeys } from "./nativeKeys";
|
|
23
|
+
import type {
|
|
24
|
+
AkanApiConfig,
|
|
25
|
+
AkanAssetsConfig,
|
|
26
|
+
AkanBinConfig,
|
|
27
|
+
AkanDatabaseConfig,
|
|
28
|
+
AkanNativeAppConfig,
|
|
29
|
+
AkanNativeAppResult,
|
|
30
|
+
AkanNativeDeepLinks,
|
|
31
|
+
AkanNativeSettings,
|
|
32
|
+
AkanNativeTarget,
|
|
33
|
+
AkanNativeUpdatesConfig,
|
|
34
|
+
AkanRouteConfig,
|
|
35
|
+
AkanWebConfig,
|
|
36
|
+
AkanWebOption,
|
|
37
|
+
AkanWorkersConfig,
|
|
38
|
+
AppConfigResult,
|
|
39
|
+
DatabaseMode,
|
|
40
|
+
DeepPartial,
|
|
41
|
+
DockerConfig,
|
|
42
|
+
DockerOption,
|
|
43
|
+
DockerRun,
|
|
44
|
+
LibAssetsConfig,
|
|
45
|
+
LibConfigResult,
|
|
46
|
+
LibDockerConfig,
|
|
40
47
|
} from "./types";
|
|
41
48
|
|
|
42
49
|
const DEFAULT_BARREL_IMPORTS = ["akanjs/webkit", "akanjs/common", "akanjs/ui", "akanjs/server"];
|
|
@@ -47,8 +54,6 @@ const DEFAULT_OPTIMIZE_IMPORTS = [
|
|
|
47
54
|
"@material-ui/icons @tabler/icons-react mui-core react-icons/*",
|
|
48
55
|
].flatMap((line) => line.split(" "));
|
|
49
56
|
const WORKSPACE_BARREL_FACETS = ["ui", "webkit", "common", "client", "server"] as const;
|
|
50
|
-
// `1-slim` floats to whichever Bun is newest at build time, one the framework was never tested on.
|
|
51
|
-
const DEFAULT_DOCKER_IMAGE = "oven/bun:1.4.4-slim";
|
|
52
57
|
const SSR_RUNTIME_PACKAGES = ["react", "react-dom", "react-server-dom-webpack"] as const;
|
|
53
58
|
const DEFAULT_AKAN_IMAGE_CONFIG: AkanImageConfig = {
|
|
54
59
|
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
|
|
@@ -123,6 +128,7 @@ export interface LibContributions {
|
|
|
123
128
|
trustedDependencies?: string[];
|
|
124
129
|
/** Per lib, since an app carries only the entries of the libs it depends on. */
|
|
125
130
|
bin?: { lib: string; bin: AkanBinConfig }[];
|
|
131
|
+
workers?: LibWorkers[];
|
|
126
132
|
docker: LibDockerConfig;
|
|
127
133
|
/** Keep globs rewritten to the app's own `public/`, where `akan sync` mounts each lib's assets. */
|
|
128
134
|
keepFonts?: string[];
|
|
@@ -132,6 +138,7 @@ const emptyLibContributions = (): LibContributions => ({
|
|
|
132
138
|
externalLibs: [],
|
|
133
139
|
trustedDependencies: [],
|
|
134
140
|
bin: [],
|
|
141
|
+
workers: [],
|
|
135
142
|
docker: { preRuns: [], postRuns: [] },
|
|
136
143
|
keepFonts: [],
|
|
137
144
|
});
|
|
@@ -169,6 +176,8 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
169
176
|
/** The app's own entries; the libs' are in `libBins`. */
|
|
170
177
|
bin: AkanBinConfig;
|
|
171
178
|
libBins: { lib: string; bin: AkanBinConfig }[];
|
|
179
|
+
/** The app's own entries; `App.selectWorkers` adds those of the libs it depends on. */
|
|
180
|
+
workers: AkanWorkersConfig;
|
|
172
181
|
barrelImports: string[];
|
|
173
182
|
optimizeImports: string[];
|
|
174
183
|
images: AkanImageConfig;
|
|
@@ -216,6 +225,11 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
216
225
|
];
|
|
217
226
|
this.bin = AkanBin.parse(config?.bin, owner, app.cwdPath);
|
|
218
227
|
this.libBins = libContributions.bin ?? [];
|
|
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
|
+
);
|
|
219
233
|
this.barrelImports = [
|
|
220
234
|
...DEFAULT_BARREL_IMPORTS,
|
|
221
235
|
...WORKSPACE_BARREL_FACETS.map((facet) => `@apps/${app.name}/${facet}`),
|
|
@@ -323,7 +337,7 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
323
337
|
: {}),
|
|
324
338
|
...(merged.desktop
|
|
325
339
|
? {
|
|
326
|
-
desktop:
|
|
340
|
+
desktop: DesktopServerConfig.resolve(
|
|
327
341
|
AkanAppConfig.#platformIndexPath(merged.desktop),
|
|
328
342
|
`${where}.desktop.server`,
|
|
329
343
|
configPath,
|
|
@@ -341,93 +355,6 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
341
355
|
);
|
|
342
356
|
return { appName, appId, ...(root.fileName ? { fileName: root.fileName } : {}), version, buildNum, targets };
|
|
343
357
|
}
|
|
344
|
-
//? `true` or `{ omit, profile, modules }`: lists trimmed once, so two targets that agree on them stage one server.
|
|
345
|
-
static #desktopServer<T extends { server?: AkanNativeDesktopConfig["server"] }>(
|
|
346
|
-
desktop: T,
|
|
347
|
-
where: string,
|
|
348
|
-
configPath: string,
|
|
349
|
-
): T {
|
|
350
|
-
const { server } = desktop;
|
|
351
|
-
if (server === undefined || typeof server === "boolean") return desktop;
|
|
352
|
-
if (!AkanAppConfig.#isPlainObject(server))
|
|
353
|
-
throw new Error(`${where} in ${configPath} must be true or { omit, profile, modules }.`);
|
|
354
|
-
const names = (list: unknown, key: string, what: string) => {
|
|
355
|
-
if (list === undefined) return [];
|
|
356
|
-
if (!Array.isArray(list) || list.some((name) => typeof name !== "string" || !name.trim()))
|
|
357
|
-
throw new Error(`${where}.${key} in ${configPath} must be a list of ${what}.`);
|
|
358
|
-
return [...new Set(list.map((name: string) => name.trim()))].sort();
|
|
359
|
-
};
|
|
360
|
-
const { profile } = server;
|
|
361
|
-
if (profile !== undefined && (typeof profile !== "string" || !ServerEnvProfile.namePattern.test(profile)))
|
|
362
|
-
throw new Error(
|
|
363
|
-
`${where}.profile in ${configPath} names env/env.server.<env>.<profile>.ts: a lowercase-first name of letters, digits and dashes.`,
|
|
364
|
-
);
|
|
365
|
-
const modules = names(server.modules, "modules", "module names or @<operationMode> selectors");
|
|
366
|
-
const env = AkanAppConfig.#desktopServerEnv(server.env, where, configPath);
|
|
367
|
-
const { restart } = server;
|
|
368
|
-
if (restart !== undefined && restart !== "forever" && !(Number.isInteger(restart) && (restart as number) > 0))
|
|
369
|
-
throw new Error(`${where}.restart in ${configPath} must be "forever" or a count of crashes in a row from 1.`);
|
|
370
|
-
const watchdog = AkanAppConfig.#desktopServerWatchdog(server.watchdog, where, configPath);
|
|
371
|
-
return {
|
|
372
|
-
...desktop,
|
|
373
|
-
server: {
|
|
374
|
-
omit: names(server.omit, "omit", "package names"),
|
|
375
|
-
...(profile ? { profile } : {}),
|
|
376
|
-
...(modules.length ? { modules } : {}),
|
|
377
|
-
...(Object.keys(env).length ? { env } : {}),
|
|
378
|
-
...(restart !== undefined ? { restart } : {}),
|
|
379
|
-
...(watchdog ? { watchdog } : {}),
|
|
380
|
-
},
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
//? The stage owns these: the operation mode, the database mode, what is served and the shutdown budget the shell's
|
|
384
|
-
//? quit waits on are what make it the carried server.
|
|
385
|
-
static readonly #stagedServerEnv = new Set([
|
|
386
|
-
"AKAN_PUBLIC_OPERATION_MODE",
|
|
387
|
-
"AKAN_DATABASE_MODE",
|
|
388
|
-
"AKAN_DATABASE_MODES",
|
|
389
|
-
"AKAN_SSR",
|
|
390
|
-
"AKAN_CSR",
|
|
391
|
-
"AKAN_MCP",
|
|
392
|
-
"AKAN_SHUTDOWN_TIMEOUT_MS",
|
|
393
|
-
"AKAN_MODULES",
|
|
394
|
-
]);
|
|
395
|
-
static #desktopServerEnv(env: unknown, where: string, configPath: string): Record<string, string> {
|
|
396
|
-
if (env === undefined) return {};
|
|
397
|
-
if (!AkanAppConfig.#isPlainObject(env) || Object.values(env).some((value) => typeof value !== "string"))
|
|
398
|
-
throw new Error(`${where}.env in ${configPath} must be an object of strings.`);
|
|
399
|
-
const staged = Object.keys(env).filter((key) => AkanAppConfig.#stagedServerEnv.has(key.toUpperCase()));
|
|
400
|
-
if (staged.length)
|
|
401
|
-
throw new Error(
|
|
402
|
-
`${where}.env in ${configPath} sets ${staged.join(", ")}, which the carried server's stage owns (modules: desktop.server.modules).`,
|
|
403
|
-
);
|
|
404
|
-
const secrets = ServerEnvProfile.secretPaths(env);
|
|
405
|
-
if (secrets.length)
|
|
406
|
-
throw new Error(
|
|
407
|
-
`${where}.env in ${configPath} holds secret-named values (${secrets.join(", ")}), and the app carries its env where anyone on the computer reads it. Leave them out.`,
|
|
408
|
-
);
|
|
409
|
-
return env as Record<string, string>;
|
|
410
|
-
}
|
|
411
|
-
//? The akan.config.ts shape, which takes `true` and fills in what is left out; the launcher reads what this returns
|
|
412
|
-
//? with serverPolicyOf in @akanjs/native, which devkit cannot load while it reads a config.
|
|
413
|
-
static #desktopServerWatchdog(watchdog: unknown, where: string, configPath: string): ServerPolicy["watchdog"] | null {
|
|
414
|
-
if (watchdog === undefined || watchdog === false) return null;
|
|
415
|
-
const options = watchdog === true ? {} : watchdog;
|
|
416
|
-
const whole = (value: unknown) => value === undefined || (Number.isInteger(value) && (value as number) > 0);
|
|
417
|
-
if (
|
|
418
|
-
!AkanAppConfig.#isPlainObject(options) ||
|
|
419
|
-
Object.keys(options).some((key) => key !== "intervalMs" && key !== "failures") ||
|
|
420
|
-
!whole(options.intervalMs) ||
|
|
421
|
-
!whole(options.failures)
|
|
422
|
-
)
|
|
423
|
-
throw new Error(
|
|
424
|
-
`${where}.watchdog in ${configPath} must be true or { intervalMs, failures }, whole numbers from 1.`,
|
|
425
|
-
);
|
|
426
|
-
return {
|
|
427
|
-
intervalMs: (options.intervalMs as number | undefined) ?? 10_000,
|
|
428
|
-
failures: (options.failures as number | undefined) ?? 3,
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
358
|
static #platformIndexPath<T extends { indexPath?: string }>(section: T): T {
|
|
432
359
|
const { indexPath: rawIndexPath, ...rest } = section;
|
|
433
360
|
const indexPath = normalizeIndexPath(rawIndexPath);
|
|
@@ -452,56 +379,6 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
452
379
|
static #isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
453
380
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
454
381
|
}
|
|
455
|
-
static readonly #nativeKeys = {
|
|
456
|
-
native: [
|
|
457
|
-
"basePath",
|
|
458
|
-
"indexPath",
|
|
459
|
-
"appName",
|
|
460
|
-
"appId",
|
|
461
|
-
"fileName",
|
|
462
|
-
"version",
|
|
463
|
-
"buildNum",
|
|
464
|
-
"icon",
|
|
465
|
-
"splash",
|
|
466
|
-
"backgroundColor",
|
|
467
|
-
"permissions",
|
|
468
|
-
"plugins",
|
|
469
|
-
"deepLinks",
|
|
470
|
-
"updates",
|
|
471
|
-
"devtools",
|
|
472
|
-
"csp",
|
|
473
|
-
"openUrls",
|
|
474
|
-
"ios",
|
|
475
|
-
"android",
|
|
476
|
-
"desktop",
|
|
477
|
-
],
|
|
478
|
-
ios: ["indexPath", "teamId", "infoPlist", "entitlements", "privacy", "files", "hideFormAccessoryBar"],
|
|
479
|
-
android: [
|
|
480
|
-
"indexPath",
|
|
481
|
-
"sha256CertFingerprints",
|
|
482
|
-
"googleServices",
|
|
483
|
-
"push",
|
|
484
|
-
"autoplay",
|
|
485
|
-
"manifest",
|
|
486
|
-
"application",
|
|
487
|
-
"activity",
|
|
488
|
-
"files",
|
|
489
|
-
],
|
|
490
|
-
desktop: [
|
|
491
|
-
"indexPath",
|
|
492
|
-
"server",
|
|
493
|
-
"recovery",
|
|
494
|
-
"window",
|
|
495
|
-
"screenCapture",
|
|
496
|
-
"webview2",
|
|
497
|
-
"publisher",
|
|
498
|
-
"entitlements",
|
|
499
|
-
"dmg",
|
|
500
|
-
],
|
|
501
|
-
desktopServer: ["omit", "profile", "modules", "env", "restart", "watchdog"],
|
|
502
|
-
dmg: ["background", "background2x", "window", "iconSize", "textSize", "app", "applications"],
|
|
503
|
-
deepLinks: ["schemes", "domains"],
|
|
504
|
-
} as const;
|
|
505
382
|
//* Settings that moved when `mobile` became `native` are named with where they went, instead of "unknown".
|
|
506
383
|
static readonly #movedKeys: Readonly<Record<string, string>> = {
|
|
507
384
|
native: "the platform sections and plugins sit directly in the native section: ios, android, desktop, plugins",
|
|
@@ -526,19 +403,15 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
526
403
|
);
|
|
527
404
|
}
|
|
528
405
|
};
|
|
529
|
-
check(section,
|
|
406
|
+
check(section, nativeKeys.native, where, "native");
|
|
530
407
|
const settings = section as AkanNativeSettings;
|
|
531
|
-
check(settings.ios,
|
|
532
|
-
check(settings.android,
|
|
533
|
-
check(settings.desktop,
|
|
534
|
-
check(
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
"desktopServer",
|
|
539
|
-
);
|
|
540
|
-
check(settings.desktop?.dmg, AkanAppConfig.#nativeKeys.dmg, `${where}.desktop.dmg`, "dmg");
|
|
541
|
-
check(settings.deepLinks, AkanAppConfig.#nativeKeys.deepLinks, `${where}.deepLinks`, "deepLinks");
|
|
408
|
+
check(settings.ios, nativeKeys.ios, `${where}.ios`, "ios");
|
|
409
|
+
check(settings.android, nativeKeys.android, `${where}.android`, "android");
|
|
410
|
+
check(settings.desktop, nativeKeys.desktop, `${where}.desktop`, "desktop");
|
|
411
|
+
check(settings.desktop?.server, nativeKeys.desktopServer, `${where}.desktop.server`, "desktopServer");
|
|
412
|
+
check(settings.desktop?.dmg, nativeKeys.dmg, `${where}.desktop.dmg`, "dmg");
|
|
413
|
+
check(settings.desktop?.externalView, nativeKeys.externalView, `${where}.desktop.externalView`, "externalView");
|
|
414
|
+
check(settings.deepLinks, nativeKeys.deepLinks, `${where}.deepLinks`, "deepLinks");
|
|
542
415
|
}
|
|
543
416
|
static readonly #androidFilePattern = /^(?:res\/[^/]+\/[^/]+|assets\/.+)$/;
|
|
544
417
|
static #assertFiles(settings: AkanNativeSettings, where: string, configPath: string) {
|
|
@@ -587,23 +460,6 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
587
460
|
this.branches.forEach((domain) => void domains.add(`${basePath}-${domain}.${serveDomain}`));
|
|
588
461
|
});
|
|
589
462
|
}
|
|
590
|
-
#getDockerRunScripts(runs: DockerRun[]) {
|
|
591
|
-
return runs.map((run) => {
|
|
592
|
-
if (typeof run === "string") return `RUN ${run}`;
|
|
593
|
-
else
|
|
594
|
-
return Object.entries(run)
|
|
595
|
-
.map(
|
|
596
|
-
([arch, script]) => `RUN if [ "$TARGETARCH" = "${arch}" ]; then \
|
|
597
|
-
${script}; \
|
|
598
|
-
fi`,
|
|
599
|
-
)
|
|
600
|
-
.join("\n");
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
#getDockerImageScript(image: string | { [key in Arch]?: string }, defaultImage: string) {
|
|
604
|
-
if (typeof image === "string") return `FROM ${image}`;
|
|
605
|
-
else return archs.map((arch) => `FROM ${image[arch] ?? defaultImage} AS ${arch}`).join("\n");
|
|
606
|
-
}
|
|
607
463
|
/** A declared Dockerfile string is verbatim, so a lib's steps are dropped rather than silently unapplied. */
|
|
608
464
|
static #resolveDocker(docker: DockerOption | undefined, libDocker: LibDockerConfig): DockerConfig {
|
|
609
465
|
if (typeof docker === "string") return docker;
|
|
@@ -643,30 +499,32 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
643
499
|
"ARG AKAN_ALLOW_LOCAL_IMAGE",
|
|
644
500
|
`RUN if [ "$AKAN_ALLOW_LOCAL_IMAGE" != "1" ]; then echo "This build ran with AKAN_PUBLIC_ENV=local, so the server runs without endpoint rate limits and on local defaults for Redis and the database mode. Build for the environment it deploys to with akan build --env, or pass --build-arg AKAN_ALLOW_LOCAL_IMAGE=1." >&2; exit 1; fi`,
|
|
645
501
|
].join("\n");
|
|
646
|
-
dockerfileFor(environment: string,
|
|
647
|
-
return this.#makeDockerfile(environment, lockfile);
|
|
502
|
+
dockerfileFor(environment: string, options: { lockfile?: boolean; env?: Record<string, string> } = {}): string {
|
|
503
|
+
return this.#makeDockerfile(environment, options.lockfile ?? true, options.env);
|
|
648
504
|
}
|
|
649
|
-
#makeDockerfile(environment?: string, lockfile = true): string {
|
|
505
|
+
#makeDockerfile(environment?: string, lockfile = true, env = this.getProductionEnv(environment)): string {
|
|
650
506
|
if (typeof this.docker === "string") return this.docker;
|
|
651
507
|
const { image, preRuns, postRuns, command } = this.docker;
|
|
652
|
-
const preRunScripts =
|
|
653
|
-
const postRunScripts =
|
|
654
|
-
const imageScript =
|
|
508
|
+
const preRunScripts = dockerRunScripts(preRuns);
|
|
509
|
+
const postRunScripts = dockerRunScripts(postRuns);
|
|
510
|
+
const imageScript = dockerImageScript(image);
|
|
655
511
|
const isLocal = (environment ?? this.baseDevEnv.env) === "local";
|
|
656
|
-
const envLines = Object.entries(
|
|
512
|
+
const envLines = Object.entries(env).map(([key, value]) => `ENV ${key}=${value}`);
|
|
657
513
|
return `${imageScript}${isLocal ? `\n${AkanAppConfig.localImageGuard}` : ""}
|
|
658
|
-
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends ca-certificates tzdata && rm -rf /var/lib/apt/lists/*
|
|
514
|
+
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/*
|
|
659
515
|
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
|
|
660
516
|
ARG TARGETARCH
|
|
661
517
|
${preRunScripts.join("\n")}
|
|
662
|
-
RUN mkdir -p /workspace
|
|
663
518
|
WORKDIR /workspace
|
|
664
519
|
${lockfile ? "COPY ./package.json ./bun.lock ./" : "COPY ./package.json ./package.json"}
|
|
665
520
|
RUN bun install --production${lockfile ? " --frozen-lockfile" : ""}
|
|
666
521
|
${postRunScripts.join("\n")}
|
|
667
522
|
COPY . .
|
|
523
|
+
RUN mkdir -p ${DOCKER_WRITE_DIRS.join(" ")} && chown ${DOCKER_RUN_USER} ${DOCKER_WRITE_DIRS.join(" ")}
|
|
668
524
|
${envLines.join("\n")}
|
|
669
|
-
|
|
525
|
+
USER ${DOCKER_RUN_USER}
|
|
526
|
+
ENTRYPOINT ${JSON.stringify(DOCKER_INIT)}
|
|
527
|
+
CMD ${JSON.stringify(command)}`;
|
|
670
528
|
}
|
|
671
529
|
static #importGeneration = 0;
|
|
672
530
|
// Bun caches dynamic imports by path; a fresh query string re-evaluates the config module (its imports stay cached).
|
|
@@ -726,6 +584,11 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
|
|
|
726
584
|
bin: libConfigs.flatMap((libConfig) =>
|
|
727
585
|
libConfig && Object.keys(libConfig.bin).length ? [{ lib: libConfig.lib.name, bin: libConfig.bin }] : [],
|
|
728
586
|
),
|
|
587
|
+
workers: libConfigs.flatMap((libConfig) =>
|
|
588
|
+
libConfig && Object.keys(libConfig.workers).length
|
|
589
|
+
? [{ lib: libConfig.lib.name, workers: libConfig.workers }]
|
|
590
|
+
: [],
|
|
591
|
+
),
|
|
729
592
|
docker: {
|
|
730
593
|
preRuns: libConfigs.flatMap((libConfig) => libConfig?.docker.preRuns ?? []),
|
|
731
594
|
postRuns: libConfigs.flatMap((libConfig) => libConfig?.docker.postRuns ?? []),
|
|
@@ -864,6 +727,7 @@ export class AkanLibConfig implements LibConfigResult {
|
|
|
864
727
|
externalLibs: string[];
|
|
865
728
|
trustedDependencies: string[];
|
|
866
729
|
bin: AkanBinConfig;
|
|
730
|
+
workers: AkanWorkersConfig;
|
|
867
731
|
docker: LibDockerConfig;
|
|
868
732
|
assets: LibAssetsConfig;
|
|
869
733
|
/** Live-only: plugins declared in this lib's `akan.config.ts` (never serialized). */
|
|
@@ -874,6 +738,7 @@ export class AkanLibConfig implements LibConfigResult {
|
|
|
874
738
|
const owner = `libs/${lib.name}/akan.config.ts`;
|
|
875
739
|
this.trustedDependencies = normalizePackageNames(config?.trustedDependencies, owner);
|
|
876
740
|
this.bin = AkanBin.parse(config?.bin, owner, lib.cwdPath);
|
|
741
|
+
this.workers = AkanWorkers.parse(config?.workers, owner, lib.cwdPath);
|
|
877
742
|
this.docker = { preRuns: config?.docker?.preRuns ?? [], postRuns: config?.docker?.postRuns ?? [] };
|
|
878
743
|
this.assets = { keepFonts: normalizeKeepFonts(config?.assets?.keepFonts as string[] | undefined) };
|
|
879
744
|
this.plugins = plugins;
|