@akanjs/devkit 3.3.0-rc.7 → 3.3.0-rc.70
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/DEV_RUNTIME_KNOBS.md +1 -1
- package/README.ko.md +10 -3
- package/README.md +10 -4
- package/akanApp/akanApp.host.test.ts +4 -2
- package/akanApp/akanApp.host.ts +26 -2
- package/akanApp/akanApp.host.wiring.test.ts +111 -0
- package/akanApp/devHostPolicy.ts +5 -0
- package/akanApp/devMetadataRestart.ts +93 -0
- package/akanApp/devRecycler.test.ts +2 -0
- package/akanApp/devRecycler.ts +9 -0
- package/akanConfig/akanBin.ts +4 -0
- package/akanConfig/akanConfig.test.ts +320 -21
- package/akanConfig/akanConfig.ts +113 -272
- package/akanConfig/akanPreview.test.ts +28 -0
- package/akanConfig/akanPreview.ts +24 -0
- package/akanConfig/akanWorkers.test.ts +73 -0
- package/akanConfig/akanWorkers.ts +61 -0
- package/akanConfig/desktopServerConfig.ts +96 -0
- package/akanConfig/dockerImage.ts +229 -0
- package/akanConfig/index.ts +3 -0
- package/akanConfig/nativeFileSettings.ts +33 -0
- package/akanConfig/nativeKeys.ts +52 -0
- package/akanConfig/types.ts +4 -0
- package/app/appBin.test.ts +63 -0
- package/app/appBin.ts +50 -0
- package/app/applicationBuildReporter.test.ts +51 -1
- package/app/applicationBuildReporter.ts +6 -1
- package/app/applicationBuildRunner.test.ts +358 -5
- package/app/applicationBuildRunner.ts +221 -31
- package/app/clientServerBoundary.test.ts +115 -0
- package/app/clientServerBoundary.ts +89 -0
- package/app/dictionarySizes.test.ts +40 -0
- package/app/dictionarySizes.ts +95 -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/index.ts +1 -34
- package/codeAgent/skills/akan-agent/SKILL.md +8 -1
- package/codeAgent/skills/akan-code/SKILL.md +38 -3
- package/codeAgent/skills/akan-debug/SKILL.md +8 -3
- package/codeAgent/skills/akan-deps/SKILL.md +10 -3
- 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 +65 -30
- package/codeAgent/skills/akan-query/SKILL.md +13 -20
- package/codeAgent/skills/akan-runtime/SKILL.md +21 -1
- package/codeAgent/skills/akan-service/SKILL.md +21 -20
- package/codeAgent/skills/akan-transport/SKILL.md +5 -14
- package/codeAgent/skills/akan-ui/SKILL.md +16 -21
- package/codeAgent/skills/akan-validate/SKILL.md +8 -2
- package/commandDecorators/command.ts +28 -12
- package/commandDecorators/commandBuilder.ts +8 -1
- package/commandDecorators/commandDecorators.test.ts +70 -3
- package/commandDecorators/helpFormatter.ts +14 -12
- package/context/akanContext.ts +2 -0
- package/csrE2e/devHmrLatency.e2e.test.ts +1 -1
- package/csrE2e/ssrRegistry.e2e.test.ts +108 -22
- package/docs/apiReference.test.ts +25 -0
- package/docs/apiReference.ts +38 -5
- package/docs/declarationReader.ts +30 -0
- package/executors/appExecutor.ts +26 -12
- 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 +14 -6
- package/executors/executors.test.ts +155 -1
- package/executors/pkgExecutor.ts +2 -1
- package/executors/sysExecutor.ts +112 -8
- 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 +4 -5
- package/frontendBuild/csrDevPatcher.ts +37 -11
- package/frontendBuild/csrDevTypes.ts +9 -0
- package/frontendBuild/devBarrelImports.test.ts +154 -0
- package/frontendBuild/devBarrelImports.ts +83 -23
- package/frontendBuild/devChangePlanner.ts +0 -1
- package/frontendBuild/devRegistryBundler.ts +4 -2
- package/frontendBuild/devRouteRuntime.test.ts +492 -0
- package/frontendBuild/devRouteRuntime.ts +167 -0
- package/frontendBuild/dictionaryAssetBuilder.test.ts +408 -0
- package/frontendBuild/dictionaryAssetBuilder.ts +185 -17
- package/frontendBuild/dictionaryConstants.ts +136 -0
- package/frontendBuild/dictionaryOwnParts.ts +88 -0
- package/frontendBuild/dictionaryPackState.ts +131 -0
- package/frontendBuild/dictionaryPacking.test.ts +207 -0
- package/frontendBuild/dictionaryPacking.ts +160 -0
- package/frontendBuild/dictionaryRoutes.test.ts +251 -0
- package/frontendBuild/dictionaryRoutes.ts +227 -0
- package/frontendBuild/frontendBuild.test.ts +5 -3
- package/frontendBuild/pagesBundleBuilder.test.ts +84 -0
- package/frontendBuild/pagesBundleBuilder.ts +78 -2
- package/frontendBuild/precompressArtifacts.test.ts +22 -0
- package/frontendBuild/precompressArtifacts.ts +34 -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/ssrBaseArtifactBuilder.ts +30 -35
- 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.test.ts +47 -3
- package/frontendBuild/vendorNarrowing.ts +38 -2
- package/frontendBuild/vendorSpecifiers.ts +2 -0
- package/guideline/agentAssets.ts +1 -1
- package/incrementalBuilder/buildBatch.proc.ts +35 -9
- package/incrementalBuilder/buildBatchProtocol.ts +2 -1
- package/incrementalBuilder/builderBoot.ts +5 -5
- package/incrementalBuilder/builderGraphPayloads.ts +4 -4
- package/incrementalBuilder/builderLanes.ts +2 -2
- package/incrementalBuilder/builderWatch.ts +19 -9
- package/incrementalBuilder/csrRegistry.ts +4 -4
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +159 -0
- package/incrementalBuilder/incrementalBuilder.proc.ts +38 -10
- package/incrementalBuilder/pendingMetadata.test.ts +27 -0
- package/incrementalBuilder/pendingMetadata.ts +19 -0
- package/incrementalBuilder/ssrRegistry.ts +6 -6
- package/index.ts +1 -1
- package/integration/devStability.integration.test.ts +46 -21
- 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 +18 -3
- package/mobile/desktopServerStage.ts +7 -2
- 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 +22 -178
- package/packageExports.test.ts +39 -24
- package/preview/PreviewView.ts +25 -3
- 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/fakeTerminal.ts +45 -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 +129 -2
- package/transforms/serverEnvProfile.ts +126 -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 +22 -11
- package/tunnel/ssh2Module.test.ts +37 -0
- package/tunnel/ssh2Module.ts +28 -0
- package/tunnel/sshTunnel.ts +4 -2
- 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/devInstallCommand.ts +7 -0
- package/util/fileEditor.ts +1 -0
- package/util/jsonFormatter.test.ts +13 -9
- 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/envSeed.test.ts +30 -1
- package/workspace/envSeed.ts +30 -1
- package/workspace/getRelatedCnsts.ts +7 -0
- package/workspace/mainCheckout.test.ts +55 -0
- package/workspace/mainCheckout.ts +38 -0
- package/workspace/scanInfo.test.ts +39 -0
- package/workspace/scanInfo.ts +55 -6
- package/workspace/slicePlanner.ts +2 -1
- package/workspace/workspaceLayout.test.ts +22 -1
- package/workspace/workspaceLayout.ts +3 -3
- package/CHANGELOG.md +0 -2718
- package/codeAgent/agent/AkanCodeCompaction.ts +0 -49
- package/codeAgent/agent/AkanCodeServices.ts +0 -122
- package/codeAgent/agent/AkanContextFiles.ts +0 -94
- package/codeAgent/agent/CodeAgent.ts +0 -606
- package/codeAgent/agent/CodeAgentAsks.ts +0 -66
- package/codeAgent/agent/CodeAgentEventMapper.ts +0 -225
- package/codeAgent/agent/CodeAgentGate.ts +0 -239
- package/codeAgent/agent/CodeAgentProxy.ts +0 -83
- package/codeAgent/agent/CodeAgentRpcHost.ts +0 -109
- package/codeAgent/agent/CodeAgentRpcListener.ts +0 -195
- package/codeAgent/agent/CodeAgentStreamPrinter.ts +0 -86
- package/codeAgent/agent/CodeAgentSuspended.ts +0 -85
- package/codeAgent/agent/CodeAgentUi.ts +0 -47
- package/codeAgent/agent/CodeMailbox.ts +0 -148
- package/codeAgent/agent/CodeSessionFork.ts +0 -56
- package/codeAgent/agent/CodeSessionIndex.ts +0 -78
- package/codeAgent/agent/SubagentPool.ts +0 -219
- package/codeAgent/agent/WorkspaceTrust.ts +0 -200
- package/codeAgent/agent/akanCodeCompaction.test.ts +0 -36
- package/codeAgent/agent/akanCodeModel.ts +0 -47
- package/codeAgent/agent/akanCodeServices.test.ts +0 -54
- package/codeAgent/agent/akanContextFiles.test.ts +0 -116
- package/codeAgent/agent/akanSystemPrompt.ts +0 -50
- package/codeAgent/agent/codeAgent.test.ts +0 -275
- package/codeAgent/agent/codeAgentContract.test.ts +0 -643
- package/codeAgent/agent/codeAgentHosts.ts +0 -30
- package/codeAgent/agent/codeAgentProxy.test.ts +0 -126
- package/codeAgent/agent/codeAgentRpcListener.test.ts +0 -215
- package/codeAgent/agent/codeAgentSuspended.test.ts +0 -47
- package/codeAgent/agent/codeMailbox.test.ts +0 -76
- package/codeAgent/agent/codeSessionFork.test.ts +0 -58
- package/codeAgent/agent/codeSessionIndex.test.ts +0 -77
- package/codeAgent/agent/consoleToStderr.ts +0 -8
- package/codeAgent/agent/jsonLines.ts +0 -29
- package/codeAgent/agent/stringArg.ts +0 -5
- package/codeAgent/feedback/DevLogFeedback.ts +0 -82
- package/codeAgent/feedback/PreviewFeedback.ts +0 -46
- package/codeAgent/feedback/TurnFeedback.ts +0 -98
- package/codeAgent/feedback/VerifyFeedback.ts +0 -39
- package/codeAgent/tools/AkanCli.ts +0 -51
- package/codeAgent/tools/AkanCodePlugins.ts +0 -142
- package/codeAgent/tools/AkanEditScope.ts +0 -53
- package/codeAgent/tools/AkanEnvKeys.ts +0 -50
- package/codeAgent/tools/AkanToolPack.ts +0 -86
- package/codeAgent/tools/AkanVerifier.ts +0 -30
- package/codeAgent/tools/AskToolPack.ts +0 -99
- package/codeAgent/tools/DeepSeekWeb.ts +0 -127
- package/codeAgent/tools/MailToolPack.ts +0 -76
- package/codeAgent/tools/McpClient.ts +0 -209
- package/codeAgent/tools/McpOAuth.ts +0 -233
- package/codeAgent/tools/McpOAuthLoopback.ts +0 -64
- package/codeAgent/tools/McpServerConfig.ts +0 -131
- package/codeAgent/tools/McpSignIn.ts +0 -158
- package/codeAgent/tools/McpTokenStore.ts +0 -128
- package/codeAgent/tools/McpToolPack.ts +0 -206
- package/codeAgent/tools/SessionToolPack.ts +0 -91
- package/codeAgent/tools/WebToolPack.ts +0 -315
- package/codeAgent/tools/akanCodePlugins.test.ts +0 -954
- package/codeAgent/tools/askToolPack.test.ts +0 -116
- package/codeAgent/tools/deepSeekWeb.test.ts +0 -113
- package/codeAgent/tools/mcpOAuth.test.ts +0 -648
- package/codeAgent/tools/mcpServerConfig.test.ts +0 -341
- package/piDependencyPins.test.ts +0 -45
package/akanConfig/akanConfig.ts
CHANGED
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import type { AkanPlugin } from "akanjs";
|
|
4
|
+
import type { AkanPlugin, AkanPreviewConfig } 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";
|
|
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
|
-
|
|
12
|
+
import { AkanPreview } from "./akanPreview";
|
|
13
|
+
import { AkanWorkers, type LibWorkers } from "./akanWorkers";
|
|
14
|
+
import { DesktopServerConfig } from "./desktopServerConfig";
|
|
15
|
+
import { dockerfileOf, resolveDocker, resolveDockerVariants } from "./dockerImage";
|
|
16
|
+
import { NativeFileSettings } from "./nativeFileSettings";
|
|
17
|
+
import { nativeKeys } from "./nativeKeys";
|
|
18
|
+
import type {
|
|
19
|
+
AkanApiConfig,
|
|
20
|
+
AkanAssetsConfig,
|
|
21
|
+
AkanBinConfig,
|
|
22
|
+
AkanDatabaseConfig,
|
|
23
|
+
AkanNativeAppConfig,
|
|
24
|
+
AkanNativeAppResult,
|
|
25
|
+
AkanNativeDeepLinks,
|
|
26
|
+
AkanNativeSettings,
|
|
27
|
+
AkanNativeTarget,
|
|
28
|
+
AkanNativeUpdatesConfig,
|
|
29
|
+
AkanRouteConfig,
|
|
30
|
+
AkanWebConfig,
|
|
31
|
+
AkanWebOption,
|
|
32
|
+
AkanWorkersConfig,
|
|
33
|
+
AppConfigResult,
|
|
34
|
+
DatabaseMode,
|
|
35
|
+
DeepPartial,
|
|
36
|
+
DockerConfig,
|
|
37
|
+
DockerImageConfig,
|
|
38
|
+
DockerOption,
|
|
39
|
+
LibAssetsConfig,
|
|
40
|
+
LibConfigResult,
|
|
41
|
+
LibDockerConfig,
|
|
40
42
|
} from "./types";
|
|
41
43
|
|
|
42
44
|
const DEFAULT_BARREL_IMPORTS = ["akanjs/webkit", "akanjs/common", "akanjs/ui", "akanjs/server"];
|
|
@@ -47,8 +49,6 @@ const DEFAULT_OPTIMIZE_IMPORTS = [
|
|
|
47
49
|
"@material-ui/icons @tabler/icons-react mui-core react-icons/*",
|
|
48
50
|
].flatMap((line) => line.split(" "));
|
|
49
51
|
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
52
|
const SSR_RUNTIME_PACKAGES = ["react", "react-dom", "react-server-dom-webpack"] as const;
|
|
53
53
|
const DEFAULT_AKAN_IMAGE_CONFIG: AkanImageConfig = {
|
|
54
54
|
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
|
|
@@ -123,6 +123,7 @@ export interface LibContributions {
|
|
|
123
123
|
trustedDependencies?: string[];
|
|
124
124
|
/** Per lib, since an app carries only the entries of the libs it depends on. */
|
|
125
125
|
bin?: { lib: string; bin: AkanBinConfig }[];
|
|
126
|
+
workers?: LibWorkers[];
|
|
126
127
|
docker: LibDockerConfig;
|
|
127
128
|
/** Keep globs rewritten to the app's own `public/`, where `akan sync` mounts each lib's assets. */
|
|
128
129
|
keepFonts?: string[];
|
|
@@ -132,7 +133,8 @@ const emptyLibContributions = (): LibContributions => ({
|
|
|
132
133
|
externalLibs: [],
|
|
133
134
|
trustedDependencies: [],
|
|
134
135
|
bin: [],
|
|
135
|
-
|
|
136
|
+
workers: [],
|
|
137
|
+
docker: { preRuns: [], installRuns: [], postRuns: [] },
|
|
136
138
|
keepFonts: [],
|
|
137
139
|
});
|
|
138
140
|
|
|
@@ -147,13 +149,6 @@ const normalizeKeepFonts = (keepFonts: string[] | undefined) => [
|
|
|
147
149
|
...new Set((keepFonts ?? []).map((glob) => glob.trim().replace(/^\/+/, "")).filter(Boolean)),
|
|
148
150
|
];
|
|
149
151
|
|
|
150
|
-
/** First occurrence wins, so a step a lib and its app both declare becomes one layer. */
|
|
151
|
-
const dedupeDockerRuns = (runs: DockerRun[]): DockerRun[] => {
|
|
152
|
-
const byKey = new Map<string, DockerRun>();
|
|
153
|
-
for (const run of runs) byKey.set(typeof run === "string" ? run : JSON.stringify(run), run);
|
|
154
|
-
return [...byKey.values()];
|
|
155
|
-
};
|
|
156
|
-
|
|
157
152
|
class LibConfigRefusal extends Error {}
|
|
158
153
|
|
|
159
154
|
export class AkanAppConfig implements AppConfigResult {
|
|
@@ -162,6 +157,8 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
162
157
|
docker: DockerConfig;
|
|
163
158
|
/** The Dockerfile `akan build` writes: the declared string verbatim, or one assembled from the parts. */
|
|
164
159
|
dockerfile: string;
|
|
160
|
+
/** Each is the app's `docker` with the variant's fields replaced; a lib's steps reach every one. */
|
|
161
|
+
dockerVariants: Record<string, DockerImageConfig>;
|
|
165
162
|
database: AkanDatabaseConfig;
|
|
166
163
|
web: AkanWebConfig;
|
|
167
164
|
externalLibs: string[];
|
|
@@ -169,6 +166,8 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
169
166
|
/** The app's own entries; the libs' are in `libBins`. */
|
|
170
167
|
bin: AkanBinConfig;
|
|
171
168
|
libBins: { lib: string; bin: AkanBinConfig }[];
|
|
169
|
+
/** The app's own entries; `App.selectWorkers` adds those of the libs it depends on. */
|
|
170
|
+
workers: AkanWorkersConfig;
|
|
172
171
|
barrelImports: string[];
|
|
173
172
|
optimizeImports: string[];
|
|
174
173
|
images: AkanImageConfig;
|
|
@@ -186,9 +185,12 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
186
185
|
libs: string[];
|
|
187
186
|
/** Live-only: plugins declared in this app's `akan.config.ts` (never serialized). */
|
|
188
187
|
plugins: AkanPlugin[];
|
|
188
|
+
/** Live-only: `akan preview` reads it from this app's `akan.config.ts` (never serialized). */
|
|
189
|
+
preview: AkanPreviewConfig = {};
|
|
189
190
|
domains = new Set<string>();
|
|
190
191
|
subRoutes = new Map<string, Set<string>>();
|
|
191
192
|
basePaths = new Set<string>();
|
|
193
|
+
routePageLibs = new Map<string, string[] | boolean>();
|
|
192
194
|
branches = new Set<string>(["debug", "develop", "main"]);
|
|
193
195
|
constructor(
|
|
194
196
|
app: App,
|
|
@@ -216,6 +218,11 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
216
218
|
];
|
|
217
219
|
this.bin = AkanBin.parse(config?.bin, owner, app.cwdPath);
|
|
218
220
|
this.libBins = libContributions.bin ?? [];
|
|
221
|
+
this.workers = AkanWorkers.parse(config?.workers, owner, app.cwdPath);
|
|
222
|
+
//? The dependency scan reads this config, so every workspace lib's entry is published; a start, test or build names the mounted ones.
|
|
223
|
+
AkanWorkers.publish(
|
|
224
|
+
AkanWorkers.select({ owner, workers: this.workers }, libContributions.workers ?? [], libs, { strict: false }),
|
|
225
|
+
);
|
|
219
226
|
this.barrelImports = [
|
|
220
227
|
...DEFAULT_BARREL_IMPORTS,
|
|
221
228
|
...WORKSPACE_BARREL_FACETS.map((facet) => `@apps/${app.name}/${facet}`),
|
|
@@ -251,7 +258,8 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
251
258
|
this.hasNativeConfig = Boolean(config.native);
|
|
252
259
|
this.native = this.#resolveNativeConfig(config.native);
|
|
253
260
|
this.web = this.#resolveWebConfig(config.web);
|
|
254
|
-
this.docker =
|
|
261
|
+
this.docker = resolveDocker(config.docker, libContributions.docker);
|
|
262
|
+
this.dockerVariants = resolveDockerVariants(config.docker, libContributions.docker);
|
|
255
263
|
this.dockerfile = this.#makeDockerfile();
|
|
256
264
|
}
|
|
257
265
|
#resolveWebConfig(web: AkanWebOption | undefined): AkanWebConfig {
|
|
@@ -267,7 +275,7 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
267
275
|
const configPath = `apps/${this.app.name}/akan.config.ts`;
|
|
268
276
|
const { targets: rawTargets, ...root } = native ?? {};
|
|
269
277
|
AkanAppConfig.#assertNativeKeys(root, "native", configPath);
|
|
270
|
-
|
|
278
|
+
NativeFileSettings.assert(root, "native", configPath);
|
|
271
279
|
const appName = root.appName ?? this.app.name;
|
|
272
280
|
const appId = root.appId ?? deriveDefaultAppId(this.baseDevEnv.repoName, this.app.name);
|
|
273
281
|
const version = root.version ?? "0.0.1";
|
|
@@ -295,7 +303,7 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
295
303
|
throw new Error(
|
|
296
304
|
`${where}.updates in ${configPath} has both publicKey and publicKeys${named ? ", native.updates merged in: give one, in native.updates' own form when overriding its keys" : ": give one"}.`,
|
|
297
305
|
);
|
|
298
|
-
|
|
306
|
+
NativeFileSettings.assert(own ?? {}, where, configPath);
|
|
299
307
|
const {
|
|
300
308
|
basePath: _basePath,
|
|
301
309
|
indexPath: rawIndexPath,
|
|
@@ -323,7 +331,7 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
323
331
|
: {}),
|
|
324
332
|
...(merged.desktop
|
|
325
333
|
? {
|
|
326
|
-
desktop:
|
|
334
|
+
desktop: DesktopServerConfig.resolve(
|
|
327
335
|
AkanAppConfig.#platformIndexPath(merged.desktop),
|
|
328
336
|
`${where}.desktop.server`,
|
|
329
337
|
configPath,
|
|
@@ -341,93 +349,6 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
341
349
|
);
|
|
342
350
|
return { appName, appId, ...(root.fileName ? { fileName: root.fileName } : {}), version, buildNum, targets };
|
|
343
351
|
}
|
|
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
352
|
static #platformIndexPath<T extends { indexPath?: string }>(section: T): T {
|
|
432
353
|
const { indexPath: rawIndexPath, ...rest } = section;
|
|
433
354
|
const indexPath = normalizeIndexPath(rawIndexPath);
|
|
@@ -452,56 +373,6 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
452
373
|
static #isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
453
374
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
454
375
|
}
|
|
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
376
|
//* Settings that moved when `mobile` became `native` are named with where they went, instead of "unknown".
|
|
506
377
|
static readonly #movedKeys: Readonly<Record<string, string>> = {
|
|
507
378
|
native: "the platform sections and plugins sit directly in the native section: ios, android, desktop, plugins",
|
|
@@ -526,53 +397,32 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
526
397
|
);
|
|
527
398
|
}
|
|
528
399
|
};
|
|
529
|
-
check(section,
|
|
400
|
+
check(section, nativeKeys.native, where, "native");
|
|
530
401
|
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");
|
|
542
|
-
}
|
|
543
|
-
static readonly #androidFilePattern = /^(?:res\/[^/]+\/[^/]+|assets\/.+)$/;
|
|
544
|
-
static #assertFiles(settings: AkanNativeSettings, where: string, configPath: string) {
|
|
545
|
-
const check = (
|
|
546
|
-
files: Record<string, string> | undefined,
|
|
547
|
-
at: string,
|
|
548
|
-
valid: (to: string) => boolean,
|
|
549
|
-
shape: string,
|
|
550
|
-
) => {
|
|
551
|
-
for (const [to, from] of Object.entries(files ?? {})) {
|
|
552
|
-
if (typeof from !== "string")
|
|
553
|
-
throw new Error(
|
|
554
|
-
`${at}["${to}"] in ${configPath} must name its source file, relative to the app folder, e.g. { "${shape}": "assets/chime.mp3" }.`,
|
|
555
|
-
);
|
|
556
|
-
if (!valid(to)) throw new Error(`${at}["${to}"] in ${configPath} must land at ${shape}.`);
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
check(
|
|
560
|
-
settings.ios?.files,
|
|
561
|
-
`${where}.ios.files`,
|
|
562
|
-
(to) => to.length > 0 && !to.startsWith("/") && !to.split("/").includes(".."),
|
|
563
|
-
"<path in the app bundle>",
|
|
564
|
-
);
|
|
565
|
-
check(
|
|
566
|
-
settings.android?.files,
|
|
567
|
-
`${where}.android.files`,
|
|
568
|
-
(to) => AkanAppConfig.#androidFilePattern.test(to),
|
|
569
|
-
"res/<type>/<file> or assets/<path>",
|
|
570
|
-
);
|
|
402
|
+
check(settings.ios, nativeKeys.ios, `${where}.ios`, "ios");
|
|
403
|
+
check(settings.android, nativeKeys.android, `${where}.android`, "android");
|
|
404
|
+
check(settings.desktop, nativeKeys.desktop, `${where}.desktop`, "desktop");
|
|
405
|
+
check(settings.desktop?.server, nativeKeys.desktopServer, `${where}.desktop.server`, "desktopServer");
|
|
406
|
+
check(settings.desktop?.dmg, nativeKeys.dmg, `${where}.desktop.dmg`, "dmg");
|
|
407
|
+
check(settings.desktop?.externalView, nativeKeys.externalView, `${where}.desktop.externalView`, "externalView");
|
|
408
|
+
check(settings.deepLinks, nativeKeys.deepLinks, `${where}.deepLinks`, "deepLinks");
|
|
571
409
|
}
|
|
572
410
|
#applyRoutes(routes: AkanRouteConfig[] = []) {
|
|
573
411
|
for (const route of routes) {
|
|
574
412
|
const basePath = route.basePath ? trimSlashes(route.basePath) : null;
|
|
575
413
|
if (basePath !== null) this.basePaths.add(basePath);
|
|
414
|
+
if (route.syncPageLibs !== undefined) {
|
|
415
|
+
if (basePath === null)
|
|
416
|
+
throw new Error(
|
|
417
|
+
`A route in apps/${this.app.name}/akan.config.ts sets syncPageLibs without a basePath: only a basePath has lib pages of its own, so set the app's syncPageLibs.`,
|
|
418
|
+
);
|
|
419
|
+
const earlier = this.routePageLibs.get(basePath);
|
|
420
|
+
if (earlier !== undefined && JSON.stringify(earlier) !== JSON.stringify(route.syncPageLibs))
|
|
421
|
+
throw new Error(
|
|
422
|
+
`Two routes in apps/${this.app.name}/akan.config.ts share basePath "${basePath}" and set different syncPageLibs: a basePath mounts one set of lib pages, so set it on one of them.`,
|
|
423
|
+
);
|
|
424
|
+
this.routePageLibs.set(basePath, route.syncPageLibs);
|
|
425
|
+
}
|
|
576
426
|
const domains = basePath !== null ? this.subRoutes.getOrInsert(basePath, new Set()) : this.domains;
|
|
577
427
|
for (const branch of Object.keys(route.domains)) this.branches.add(branch);
|
|
578
428
|
for (const domain of Object.values(route.domains).flat())
|
|
@@ -587,33 +437,6 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
587
437
|
this.branches.forEach((domain) => void domains.add(`${basePath}-${domain}.${serveDomain}`));
|
|
588
438
|
});
|
|
589
439
|
}
|
|
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
|
-
/** A declared Dockerfile string is verbatim, so a lib's steps are dropped rather than silently unapplied. */
|
|
608
|
-
static #resolveDocker(docker: DockerOption | undefined, libDocker: LibDockerConfig): DockerConfig {
|
|
609
|
-
if (typeof docker === "string") return docker;
|
|
610
|
-
return {
|
|
611
|
-
image: docker?.image ?? DEFAULT_DOCKER_IMAGE,
|
|
612
|
-
preRuns: dedupeDockerRuns([...libDocker.preRuns, ...(docker?.preRuns ?? [])]),
|
|
613
|
-
postRuns: dedupeDockerRuns([...libDocker.postRuns, ...(docker?.postRuns ?? [])]),
|
|
614
|
-
command: docker?.command ?? ["bun", "main.js"],
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
440
|
/** What the built server runs with in its image; a desktop app's carried server starts from the same values. */
|
|
618
441
|
getProductionEnv(environment: string = this.baseDevEnv.env): Record<string, string> {
|
|
619
442
|
return {
|
|
@@ -643,30 +466,24 @@ export class AkanAppConfig implements AppConfigResult {
|
|
|
643
466
|
"ARG AKAN_ALLOW_LOCAL_IMAGE",
|
|
644
467
|
`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
468
|
].join("\n");
|
|
646
|
-
dockerfileFor(
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
469
|
+
dockerfileFor(
|
|
470
|
+
environment: string,
|
|
471
|
+
options: { lockfile?: boolean; env?: Record<string, string>; variant?: string } = {},
|
|
472
|
+
): string {
|
|
473
|
+
return this.#makeDockerfile(environment, options.lockfile ?? true, options.env, options.variant);
|
|
474
|
+
}
|
|
475
|
+
#makeDockerfile(
|
|
476
|
+
environment?: string,
|
|
477
|
+
lockfile = true,
|
|
478
|
+
env = this.getProductionEnv(environment),
|
|
479
|
+
variant?: string,
|
|
480
|
+
): string {
|
|
650
481
|
if (typeof this.docker === "string") return this.docker;
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
const imageScript = this.#getDockerImageScript(image, DEFAULT_DOCKER_IMAGE);
|
|
482
|
+
const docker = variant === undefined ? this.docker : this.dockerVariants[variant];
|
|
483
|
+
if (!docker)
|
|
484
|
+
throw new Error(`[docker] apps/${this.app.name}/akan.config.ts declares no docker variant "${variant}"`);
|
|
655
485
|
const isLocal = (environment ?? this.baseDevEnv.env) === "local";
|
|
656
|
-
|
|
657
|
-
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/*
|
|
659
|
-
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
|
|
660
|
-
ARG TARGETARCH
|
|
661
|
-
${preRunScripts.join("\n")}
|
|
662
|
-
RUN mkdir -p /workspace
|
|
663
|
-
WORKDIR /workspace
|
|
664
|
-
${lockfile ? "COPY ./package.json ./bun.lock ./" : "COPY ./package.json ./package.json"}
|
|
665
|
-
RUN bun install --production${lockfile ? " --frozen-lockfile" : ""}
|
|
666
|
-
${postRunScripts.join("\n")}
|
|
667
|
-
COPY . .
|
|
668
|
-
${envLines.join("\n")}
|
|
669
|
-
CMD [${command.map((c) => `"${c}"`).join(",")}]`;
|
|
486
|
+
return dockerfileOf(docker, { env, lockfile, guard: isLocal ? AkanAppConfig.localImageGuard : undefined });
|
|
670
487
|
}
|
|
671
488
|
static #importGeneration = 0;
|
|
672
489
|
// Bun caches dynamic imports by path; a fresh query string re-evaluates the config module (its imports stay cached).
|
|
@@ -693,17 +510,29 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
|
|
|
693
510
|
const {
|
|
694
511
|
plugins,
|
|
695
512
|
pipeline: _pipeline,
|
|
513
|
+
preview,
|
|
696
514
|
...config
|
|
697
515
|
} = (resolved ?? {}) as AppConfigDeclaration & {
|
|
698
516
|
plugins?: AkanPlugin[];
|
|
699
517
|
pipeline?: unknown;
|
|
518
|
+
preview?: unknown;
|
|
700
519
|
};
|
|
701
520
|
if ("subspace" in config)
|
|
702
521
|
throw new Error(
|
|
703
522
|
`apps/${app.name}/akan.config.ts declares \`subspace\`, a workspace setting: it belongs in the workspace root akan.config.ts.`,
|
|
704
523
|
);
|
|
705
524
|
const libContributions = await AkanAppConfig.#collectLibContributions(app, libs, bustImportCache);
|
|
706
|
-
|
|
525
|
+
const appConfig = new AkanAppConfig(
|
|
526
|
+
app,
|
|
527
|
+
libs,
|
|
528
|
+
rootPackageJson,
|
|
529
|
+
config,
|
|
530
|
+
baseDevEnv,
|
|
531
|
+
plugins ?? [],
|
|
532
|
+
libContributions,
|
|
533
|
+
);
|
|
534
|
+
appConfig.preview = AkanPreview.parse(preview, `apps/${app.name}/akan.config.ts`);
|
|
535
|
+
return appConfig;
|
|
707
536
|
}
|
|
708
537
|
//* Every workspace lib is read, not just this app's lib deps: narrowing the set needs the dependency
|
|
709
538
|
//* scan, and the incremental page rebundle re-reads this config on every file change.
|
|
@@ -726,8 +555,14 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
|
|
|
726
555
|
bin: libConfigs.flatMap((libConfig) =>
|
|
727
556
|
libConfig && Object.keys(libConfig.bin).length ? [{ lib: libConfig.lib.name, bin: libConfig.bin }] : [],
|
|
728
557
|
),
|
|
558
|
+
workers: libConfigs.flatMap((libConfig) =>
|
|
559
|
+
libConfig && Object.keys(libConfig.workers).length
|
|
560
|
+
? [{ lib: libConfig.lib.name, workers: libConfig.workers }]
|
|
561
|
+
: [],
|
|
562
|
+
),
|
|
729
563
|
docker: {
|
|
730
564
|
preRuns: libConfigs.flatMap((libConfig) => libConfig?.docker.preRuns ?? []),
|
|
565
|
+
installRuns: libConfigs.flatMap((libConfig) => libConfig?.docker.installRuns ?? []),
|
|
731
566
|
postRuns: libConfigs.flatMap((libConfig) => libConfig?.docker.postRuns ?? []),
|
|
732
567
|
},
|
|
733
568
|
//* A lib writes the glob against its own `public/`; `akan sync` mounts that at `public/libs/<lib>`.
|
|
@@ -864,6 +699,7 @@ export class AkanLibConfig implements LibConfigResult {
|
|
|
864
699
|
externalLibs: string[];
|
|
865
700
|
trustedDependencies: string[];
|
|
866
701
|
bin: AkanBinConfig;
|
|
702
|
+
workers: AkanWorkersConfig;
|
|
867
703
|
docker: LibDockerConfig;
|
|
868
704
|
assets: LibAssetsConfig;
|
|
869
705
|
/** Live-only: plugins declared in this lib's `akan.config.ts` (never serialized). */
|
|
@@ -874,7 +710,12 @@ export class AkanLibConfig implements LibConfigResult {
|
|
|
874
710
|
const owner = `libs/${lib.name}/akan.config.ts`;
|
|
875
711
|
this.trustedDependencies = normalizePackageNames(config?.trustedDependencies, owner);
|
|
876
712
|
this.bin = AkanBin.parse(config?.bin, owner, lib.cwdPath);
|
|
877
|
-
this.
|
|
713
|
+
this.workers = AkanWorkers.parse(config?.workers, owner, lib.cwdPath);
|
|
714
|
+
this.docker = {
|
|
715
|
+
preRuns: config?.docker?.preRuns ?? [],
|
|
716
|
+
installRuns: config?.docker?.installRuns ?? [],
|
|
717
|
+
postRuns: config?.docker?.postRuns ?? [],
|
|
718
|
+
};
|
|
878
719
|
this.assets = { keepFonts: normalizeKeepFonts(config?.assets?.keepFonts as string[] | undefined) };
|
|
879
720
|
this.plugins = plugins;
|
|
880
721
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { AkanPreview } from "./akanPreview";
|
|
3
|
+
|
|
4
|
+
const owner = "apps/demo/akan.config.ts";
|
|
5
|
+
|
|
6
|
+
describe("AkanPreview.parse", () => {
|
|
7
|
+
test("keeps the sign-in function and the example paths, and reads a missing section as empty", () => {
|
|
8
|
+
const signIn = async () => ({ jwt: "token" });
|
|
9
|
+
expect(AkanPreview.parse(undefined, owner)).toEqual({});
|
|
10
|
+
expect(AkanPreview.parse({}, owner)).toEqual({});
|
|
11
|
+
expect(AkanPreview.parse({ signIn, examples: ["/chat/1?tab=files"] }, owner)).toEqual({
|
|
12
|
+
signIn,
|
|
13
|
+
examples: ["/chat/1?tab=files"],
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("refuses a section it cannot read, naming the file and the key", () => {
|
|
18
|
+
expect(() => AkanPreview.parse([], owner)).toThrow(`${owner} declares \`preview\`, which has to be an object`);
|
|
19
|
+
expect(() => AkanPreview.parse({ login: () => null }, owner)).toThrow(
|
|
20
|
+
"preview.login; it takes signIn and examples",
|
|
21
|
+
);
|
|
22
|
+
expect(() => AkanPreview.parse({ signIn: "/api/signin" }, owner)).toThrow(
|
|
23
|
+
"preview.signIn, which has to be a function",
|
|
24
|
+
);
|
|
25
|
+
for (const examples of ["/chat/1", ["chat/1"], ["//host/chat/1"], [1]])
|
|
26
|
+
expect(() => AkanPreview.parse({ examples }, owner)).toThrow("preview.examples, which has to list paths");
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AkanPreviewConfig } from "./types";
|
|
2
|
+
|
|
3
|
+
export class AkanPreview {
|
|
4
|
+
static parse(value: unknown, owner: string): AkanPreviewConfig {
|
|
5
|
+
if (value === undefined) return {};
|
|
6
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
7
|
+
throw new Error(`[preview] ${owner} declares \`preview\`, which has to be an object: { signIn, examples }`);
|
|
8
|
+
const { signIn, examples, ...unknown } = value as Record<string, unknown>;
|
|
9
|
+
const [stray] = Object.keys(unknown);
|
|
10
|
+
if (stray) throw new Error(`[preview] ${owner} declares preview.${stray}; it takes signIn and examples`);
|
|
11
|
+
if (signIn !== undefined && typeof signIn !== "function")
|
|
12
|
+
throw new Error(`[preview] ${owner} declares preview.signIn, which has to be a function`);
|
|
13
|
+
if (examples !== undefined && !(Array.isArray(examples) && examples.every(AkanPreview.#isPath)))
|
|
14
|
+
throw new Error(`[preview] ${owner} declares preview.examples, which has to list paths that start with "/"`);
|
|
15
|
+
return {
|
|
16
|
+
...(signIn ? { signIn: signIn as AkanPreviewConfig["signIn"] } : {}),
|
|
17
|
+
...(examples ? { examples: examples as string[] } : {}),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static #isPath(value: unknown) {
|
|
22
|
+
return typeof value === "string" && value.startsWith("/") && !value.startsWith("//");
|
|
23
|
+
}
|
|
24
|
+
}
|