@akanjs/devkit 3.3.0-rc.5 → 3.3.0-rc.50
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 +650 -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 +57 -206
- package/akanConfig/akanWorkers.test.ts +39 -0
- package/akanConfig/akanWorkers.ts +32 -0
- package/akanConfig/desktopServerConfig.ts +96 -0
- package/akanConfig/dockerImage.ts +39 -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 +275 -0
- package/app/applicationBuildRunner.ts +149 -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 +6 -2
- 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 +3 -1
- 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 +2 -0
- package/executors/sysExecutor.ts +70 -4
- 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 +21 -2
- 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 +29 -0
- 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 +48 -5
- package/workspace/slicePlanner.ts +1 -1
- package/workspace/workspaceLayout.ts +1 -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 } 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],
|
|
@@ -169,6 +174,7 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
169
174
|
/** The app's own entries; the libs' are in `libBins`. */
|
|
170
175
|
bin: AkanBinConfig;
|
|
171
176
|
libBins: { lib: string; bin: AkanBinConfig }[];
|
|
177
|
+
workers: AkanWorkersConfig;
|
|
172
178
|
barrelImports: string[];
|
|
173
179
|
optimizeImports: string[];
|
|
174
180
|
images: AkanImageConfig;
|
|
@@ -216,6 +222,7 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
216
222
|
];
|
|
217
223
|
this.bin = AkanBin.parse(config?.bin, owner, app.cwdPath);
|
|
218
224
|
this.libBins = libContributions.bin ?? [];
|
|
225
|
+
this.workers = AkanWorkers.declare(config?.workers, owner, app.cwdPath);
|
|
219
226
|
this.barrelImports = [
|
|
220
227
|
...DEFAULT_BARREL_IMPORTS,
|
|
221
228
|
...WORKSPACE_BARREL_FACETS.map((facet) => `@apps/${app.name}/${facet}`),
|
|
@@ -323,7 +330,7 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
323
330
|
: {}),
|
|
324
331
|
...(merged.desktop
|
|
325
332
|
? {
|
|
326
|
-
desktop:
|
|
333
|
+
desktop: DesktopServerConfig.resolve(
|
|
327
334
|
AkanAppConfig.#platformIndexPath(merged.desktop),
|
|
328
335
|
`${where}.desktop.server`,
|
|
329
336
|
configPath,
|
|
@@ -341,93 +348,6 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
341
348
|
);
|
|
342
349
|
return { appName, appId, ...(root.fileName ? { fileName: root.fileName } : {}), version, buildNum, targets };
|
|
343
350
|
}
|
|
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
351
|
static #platformIndexPath<T extends { indexPath?: string }>(section: T): T {
|
|
432
352
|
const { indexPath: rawIndexPath, ...rest } = section;
|
|
433
353
|
const indexPath = normalizeIndexPath(rawIndexPath);
|
|
@@ -452,56 +372,6 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
452
372
|
static #isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
453
373
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
454
374
|
}
|
|
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
375
|
//* Settings that moved when `mobile` became `native` are named with where they went, instead of "unknown".
|
|
506
376
|
static readonly #movedKeys: Readonly<Record<string, string>> = {
|
|
507
377
|
native: "the platform sections and plugins sit directly in the native section: ios, android, desktop, plugins",
|
|
@@ -526,19 +396,15 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
526
396
|
);
|
|
527
397
|
}
|
|
528
398
|
};
|
|
529
|
-
check(section,
|
|
399
|
+
check(section, nativeKeys.native, where, "native");
|
|
530
400
|
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");
|
|
401
|
+
check(settings.ios, nativeKeys.ios, `${where}.ios`, "ios");
|
|
402
|
+
check(settings.android, nativeKeys.android, `${where}.android`, "android");
|
|
403
|
+
check(settings.desktop, nativeKeys.desktop, `${where}.desktop`, "desktop");
|
|
404
|
+
check(settings.desktop?.server, nativeKeys.desktopServer, `${where}.desktop.server`, "desktopServer");
|
|
405
|
+
check(settings.desktop?.dmg, nativeKeys.dmg, `${where}.desktop.dmg`, "dmg");
|
|
406
|
+
check(settings.desktop?.externalView, nativeKeys.externalView, `${where}.desktop.externalView`, "externalView");
|
|
407
|
+
check(settings.deepLinks, nativeKeys.deepLinks, `${where}.deepLinks`, "deepLinks");
|
|
542
408
|
}
|
|
543
409
|
static readonly #androidFilePattern = /^(?:res\/[^/]+\/[^/]+|assets\/.+)$/;
|
|
544
410
|
static #assertFiles(settings: AkanNativeSettings, where: string, configPath: string) {
|
|
@@ -587,23 +453,6 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
587
453
|
this.branches.forEach((domain) => void domains.add(`${basePath}-${domain}.${serveDomain}`));
|
|
588
454
|
});
|
|
589
455
|
}
|
|
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
456
|
/** A declared Dockerfile string is verbatim, so a lib's steps are dropped rather than silently unapplied. */
|
|
608
457
|
static #resolveDocker(docker: DockerOption | undefined, libDocker: LibDockerConfig): DockerConfig {
|
|
609
458
|
if (typeof docker === "string") return docker;
|
|
@@ -643,30 +492,32 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
643
492
|
"ARG AKAN_ALLOW_LOCAL_IMAGE",
|
|
644
493
|
`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
494
|
].join("\n");
|
|
646
|
-
dockerfileFor(environment: string,
|
|
647
|
-
return this.#makeDockerfile(environment, lockfile);
|
|
495
|
+
dockerfileFor(environment: string, options: { lockfile?: boolean; env?: Record<string, string> } = {}): string {
|
|
496
|
+
return this.#makeDockerfile(environment, options.lockfile ?? true, options.env);
|
|
648
497
|
}
|
|
649
|
-
#makeDockerfile(environment?: string, lockfile = true): string {
|
|
498
|
+
#makeDockerfile(environment?: string, lockfile = true, env = this.getProductionEnv(environment)): string {
|
|
650
499
|
if (typeof this.docker === "string") return this.docker;
|
|
651
500
|
const { image, preRuns, postRuns, command } = this.docker;
|
|
652
|
-
const preRunScripts =
|
|
653
|
-
const postRunScripts =
|
|
654
|
-
const imageScript =
|
|
501
|
+
const preRunScripts = dockerRunScripts(preRuns);
|
|
502
|
+
const postRunScripts = dockerRunScripts(postRuns);
|
|
503
|
+
const imageScript = dockerImageScript(image);
|
|
655
504
|
const isLocal = (environment ?? this.baseDevEnv.env) === "local";
|
|
656
|
-
const envLines = Object.entries(
|
|
505
|
+
const envLines = Object.entries(env).map(([key, value]) => `ENV ${key}=${value}`);
|
|
657
506
|
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/*
|
|
507
|
+
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
508
|
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
|
|
660
509
|
ARG TARGETARCH
|
|
661
510
|
${preRunScripts.join("\n")}
|
|
662
|
-
RUN mkdir -p /workspace
|
|
663
511
|
WORKDIR /workspace
|
|
664
512
|
${lockfile ? "COPY ./package.json ./bun.lock ./" : "COPY ./package.json ./package.json"}
|
|
665
513
|
RUN bun install --production${lockfile ? " --frozen-lockfile" : ""}
|
|
666
514
|
${postRunScripts.join("\n")}
|
|
667
515
|
COPY . .
|
|
516
|
+
RUN mkdir -p ${DOCKER_WRITE_DIRS.join(" ")} && chown ${DOCKER_RUN_USER} ${DOCKER_WRITE_DIRS.join(" ")}
|
|
668
517
|
${envLines.join("\n")}
|
|
669
|
-
|
|
518
|
+
USER ${DOCKER_RUN_USER}
|
|
519
|
+
ENTRYPOINT ${JSON.stringify(DOCKER_INIT)}
|
|
520
|
+
CMD ${JSON.stringify(command)}`;
|
|
670
521
|
}
|
|
671
522
|
static #importGeneration = 0;
|
|
672
523
|
// Bun caches dynamic imports by path; a fresh query string re-evaluates the config module (its imports stay cached).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { AppWorkerPath } from "akanjs/server/appWorkerPath";
|
|
4
|
+
import { AkanWorkers } from "./akanWorkers";
|
|
5
|
+
|
|
6
|
+
const owner = "apps/face/akan.config.ts";
|
|
7
|
+
const published = process.env[AppWorkerPath.envKey];
|
|
8
|
+
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
if (published === undefined) delete process.env[AppWorkerPath.envKey];
|
|
11
|
+
else process.env[AppWorkerPath.envKey] = published;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe("AkanWorkers", () => {
|
|
15
|
+
test("resolves each entry against the folder that declares it", () => {
|
|
16
|
+
expect(AkanWorkers.parse({ vision: "srvkit/_vision/visionWorker.ts" }, owner, "/repo/apps/face")).toEqual({
|
|
17
|
+
vision: path.resolve("/repo/apps/face/srvkit/_vision/visionWorker.ts"),
|
|
18
|
+
});
|
|
19
|
+
expect(AkanWorkers.parse(undefined, owner, "/repo/apps/face")).toEqual({});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("refuses a name that is no file name and an entry that is no relative source file", () => {
|
|
23
|
+
const parse = (declared: unknown) => () => AkanWorkers.parse(declared, owner, "/repo/apps/face");
|
|
24
|
+
|
|
25
|
+
expect(parse(["vision"])).toThrow(`${owner}: workers maps each worker's name to its entry file`);
|
|
26
|
+
expect(parse({ "../vision": "a.ts" })).toThrow("workers.../vision is not a name");
|
|
27
|
+
expect(parse({ vision: "/abs/visionWorker.ts" })).toThrow("workers.vision must be a .ts or .js file");
|
|
28
|
+
expect(parse({ vision: "srvkit/vision" })).toThrow("workers.vision must be a .ts or .js file");
|
|
29
|
+
expect(parse({ vision: 1 })).toThrow("workers.vision must be a .ts or .js file");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("publishes the sources a source run spawns from, and takes them back when none is declared", () => {
|
|
33
|
+
const workers = AkanWorkers.declare({ vision: "visionWorker.ts" }, owner, "/repo/apps/face");
|
|
34
|
+
|
|
35
|
+
expect(AppWorkerPath.sources()).toEqual(workers);
|
|
36
|
+
AkanWorkers.declare(undefined, owner, "/repo/apps/face");
|
|
37
|
+
expect(process.env[AppWorkerPath.envKey]).toBeUndefined();
|
|
38
|
+
});
|
|
39
|
+
});
|