@akanjs/devkit 3.2.0-rc.9 → 3.2.1-rc.0
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 +0 -529
- package/DEV_RUNTIME_KNOBS.md +4 -3
- package/README.ko.md +3 -2
- package/README.md +4 -2
- package/akanApp/BackendImportGraph.test.ts +1 -1
- package/akanApp/akanApp.host.test.ts +152 -6
- package/akanApp/akanApp.host.ts +187 -1220
- package/akanApp/akanApp.host.wiring.test.ts +931 -0
- package/akanApp/builderGap.ts +68 -0
- package/akanApp/builderRequestRelay.test.ts +93 -0
- package/akanApp/builderRequestRelay.ts +100 -0
- package/akanApp/builderRssRecycler.ts +182 -0
- package/akanApp/devBackend.ts +394 -0
- package/akanApp/devBuildStatusBoard.ts +128 -0
- package/akanApp/devBuilder.ts +200 -0
- package/akanApp/devIdleSuspend.test.ts +221 -0
- package/akanApp/devIdleSuspend.ts +192 -0
- package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
- package/akanApp/devRecycler.test.ts +66 -0
- package/akanApp/devRecycler.ts +305 -0
- package/akanApp/devStartTimeline.test.ts +115 -0
- package/akanApp/devStartTimeline.ts +69 -0
- package/akanApp/processRss.ts +61 -0
- package/akanConfig/akanConfig.test.ts +45 -17
- package/akanConfig/akanConfig.ts +10 -10
- package/akanConfig/akanWorkspaceConfig.ts +1 -1
- package/akanConfig/productionLockfile.ts +1 -1
- package/apiReport/apiReport.test.ts +34 -3
- package/apiReport/apiReportDiff.ts +35 -1
- package/apiReport/apiReportPolicy.ts +3 -2
- package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +2 -49
- package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +71 -8
- package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +60 -21
- package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
- package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +17 -1
- package/{routeJsBudget.ts → app/routeJsBudget.ts} +9 -3
- package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
- package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
- package/artifact/implicitRootLayout.test.ts +71 -3
- package/artifact/implicitRootLayout.ts +9 -3
- package/artifact/implicitRootLayoutRender.test.tsx +297 -0
- package/biome.base.json +2 -1
- package/cloud/cloudApi.test.ts +1 -1
- package/cloud/configLock.test.ts +1 -1
- package/cloud/globalConfig.test.ts +1 -1
- package/cloud/globalConfig.ts +1 -1
- package/cloud/updatePackUpload.test.ts +1 -1
- package/codeAgent/agent/AkanCodeEnv.ts +1 -1
- package/codeAgent/agent/AkanCodeServices.ts +23 -0
- package/codeAgent/agent/akanCodePaths.ts +1 -1
- package/codeAgent/agent/akanCodeServices.test.ts +54 -0
- package/codeAgent/agent/akanSystemPrompt.ts +1 -1
- package/codeAgent/agent/codeAgent.test.ts +1 -1
- package/codeAgent/skills/akan-debug/SKILL.md +8 -5
- package/codeAgent/skills/akan-err/SKILL.md +7 -0
- package/codeAgent/skills/akan-mcp/SKILL.md +19 -1
- package/codeAgent/skills/akan-scaffold/SKILL.md +1 -1
- package/codeAgent/skills/akan-validate/SKILL.md +3 -3
- package/codeAgent/tools/AkanCli.ts +1 -1
- package/codeAgent/tools/AkanToolPack.ts +2 -2
- package/codeAgent/tools/akanCodePlugins.test.ts +1 -1
- package/commandDecorators/command.ts +35 -6
- package/commandDecorators/commandBuilder.ts +1 -1
- package/commandDecorators/commandDecorators.test.ts +107 -6
- package/commandDecorators/targetMeta.ts +2 -0
- package/commandDecorators/workspaceVersionCheck.test.ts +70 -1
- package/commandDecorators/workspaceVersionCheck.ts +64 -14
- package/context/akanContext.ts +576 -0
- package/context/akanContextInspection.ts +296 -0
- package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
- package/{akanMcpContract.ts → context/akanMcpContract.ts} +16 -256
- package/context/doctor/agentGuideCheck.ts +81 -0
- package/context/doctor/configLeftoverCheck.ts +35 -0
- package/context/doctor/doctorFindings.ts +70 -0
- package/context/doctor/generatedFreshness.ts +56 -0
- package/context/doctor/moduleShapeCheck.ts +88 -0
- package/context/doctor/recipeDuplicateCheck.ts +42 -0
- package/context/doctor/recipeIndexCheck.ts +87 -0
- package/context/doctor/rootShapeCheck.ts +55 -0
- package/context/doctor/workflowScope.ts +97 -0
- package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
- package/context/safeRead.ts +9 -0
- package/csrE2e/csrE2eHarness.fixture.ts +1 -1
- package/devkitUtils.test.ts +39 -5
- package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
- package/{apiReference.ts → docs/apiReference.ts} +2 -2
- package/docs/errorCodeReference.test.ts +282 -0
- package/docs/errorCodeReference.ts +71 -0
- package/docs/errorCodeScan.ts +551 -0
- package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
- package/executors/appExecutor.ts +463 -0
- package/executors/commandExecutionError.ts +53 -0
- package/executors/executor.ts +527 -0
- package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
- package/{executors.test.ts → executors/executors.test.ts} +106 -18
- package/executors/index.ts +8 -0
- package/executors/libExecutor.ts +23 -0
- package/executors/moduleExecutor.ts +18 -0
- package/executors/pkgExecutor.ts +129 -0
- package/executors/sysExecutor.ts +301 -0
- package/executors/workspaceExecutor.ts +277 -0
- package/frontendBuild/allRoutesBuilder.test.ts +1 -1
- package/frontendBuild/autoImportSync.test.ts +1 -1
- package/frontendBuild/autoImportSync.ts +1 -1
- package/frontendBuild/buildCacheStamp.test.ts +42 -0
- package/frontendBuild/buildCacheStamp.ts +23 -0
- package/frontendBuild/buildRouteClient.test.ts +1 -1
- package/frontendBuild/clientEntriesBundler.test.ts +1 -1
- package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
- package/frontendBuild/csrDevArtifactWriter.ts +1 -1
- package/frontendBuild/cssCandidateCache.test.ts +70 -1
- package/frontendBuild/cssCandidateCache.ts +17 -10
- package/frontendBuild/cssCompiler.test.ts +3 -2
- package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
- package/frontendBuild/devGeneratedIndexSync.ts +7 -38
- package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
- package/frontendBuild/fontOptimizer.test.ts +145 -4
- package/frontendBuild/fontOptimizer.ts +103 -18
- package/frontendBuild/fontPruner.test.ts +1 -1
- package/frontendBuild/frontendBuild.test.ts +3 -3
- package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
- package/frontendBuild/hmrWatcher.test.ts +1 -1
- package/frontendBuild/hmrWatcher.ts +22 -1
- package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
- package/frontendBuild/mcpAppViewBuilder.ts +1 -1
- package/frontendBuild/nativeCore.test.ts +1 -1
- package/frontendBuild/optionalPeers.test.ts +36 -8
- package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
- package/frontendBuild/pagesBundleBuilder.ts +1 -1
- package/frontendBuild/precompressArtifacts.test.ts +1 -1
- package/frontendBuild/precompressArtifacts.ts +19 -6
- package/frontendBuild/serverGraphFile.ts +1 -1
- package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
- package/frontendBuild/ssrBaseArtifactBuilder.test.ts +30 -1
- package/frontendBuild/ssrBaseArtifactBuilder.ts +40 -12
- package/frontendBuild/ssrDevBundler.test.ts +1 -1
- package/frontendBuild/vendorImportScanner.test.ts +1 -1
- package/frontendBuild/vendorNarrowing.test.ts +1 -1
- package/frontendBuild/watchRootResolver.test.ts +1 -1
- package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
- package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
- package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
- package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
- package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
- package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
- package/{prompter.ts → guideline/prompter.ts} +2 -3
- package/incrementalBuilder/buildBatch.proc.ts +16 -5
- package/incrementalBuilder/buildBatchProtocol.ts +3 -0
- package/incrementalBuilder/buildBatchRunner.test.ts +122 -2
- package/incrementalBuilder/buildBatchRunner.ts +17 -4
- package/incrementalBuilder/builderBoot.ts +113 -0
- package/incrementalBuilder/builderBuildStatus.ts +23 -0
- package/incrementalBuilder/builderChannel.test.ts +1 -1
- package/incrementalBuilder/builderChannel.ts +19 -2
- package/incrementalBuilder/builderGraphPayloads.ts +3 -3
- package/incrementalBuilder/builderLanes.ts +157 -0
- package/incrementalBuilder/builderWatch.ts +213 -0
- package/incrementalBuilder/csrRegistry.ts +234 -0
- package/incrementalBuilder/incrementalBuilder.host.test.ts +16 -0
- package/incrementalBuilder/incrementalBuilder.host.ts +7 -1
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +142 -7
- package/incrementalBuilder/incrementalBuilder.proc.ts +82 -823
- package/incrementalBuilder/ssrRegistry.ts +282 -0
- package/index.ts +22 -22
- package/integration/devStability.integration.test.ts +62 -56
- package/integration/devStabilityHarness.test.ts +1 -1
- package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
- package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
- package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
- package/lint/gritRules.test.ts +1 -1
- package/{linter.test.ts → lint/linter.test.ts} +1 -1
- package/lint/no-import-common-err.grit +31 -0
- package/lint/no-init-fetch-in-client.grit +1 -1
- package/mobile/desktopBin.test.ts +1 -1
- package/mobile/desktopRelease.test.ts +1 -1
- package/mobile/desktopServerStage.test.ts +2 -2
- package/mobile/desktopServerStage.ts +1 -1
- package/mobile/nativeApi.test.ts +1 -1
- package/mobile/nativeApp.test.ts +1 -1
- package/mobile/nativeConfig.test.ts +1 -1
- package/mobile/nativePluginFolders.test.ts +1 -1
- package/mobile/nativePublicEnv.test.ts +1 -1
- package/mobile/nativePublicEnv.ts +2 -1
- package/mobile/nativeWebDir.test.ts +1 -1
- package/mobile/serverBundleSecrets.test.ts +1 -1
- package/mobile/tarWriter.test.ts +1 -1
- package/mobile/updatePackFolder.test.ts +1 -1
- package/package.json +173 -9
- package/packageExports.test.ts +20 -2
- package/piDependencyPins.test.ts +1 -1
- package/pipeline/PipelineDefinition.ts +1 -1
- package/platformTest/IdleWatchedProcess.test.ts +1 -1
- package/platformTest/LinuxDockerTarget.ts +1 -1
- package/platformTest/PlatformTestRun.test.ts +1 -1
- package/platformTest/TestSnapshot.test.ts +1 -1
- package/platformTest/WindowsSshTarget.ts +1 -1
- package/preview/previewView.test.ts +23 -1
- package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
- package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
- package/quality/bareErrorScanner.ts +126 -0
- package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
- package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
- package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
- package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
- package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
- package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
- package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
- package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
- package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +41 -1
- package/{qualityScanner.ts → quality/qualityScanner.ts} +25 -91
- package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
- package/quality/workspaceSourceFiles.ts +82 -0
- package/{subspace.test.ts → subspace/subspace.test.ts} +25 -4
- package/{subspace.ts → subspace/subspace.ts} +5 -5
- package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
- package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
- package/{testHelpers.ts → test/testHelpers.ts} +37 -1
- package/transforms/barrelAnalyzer.ts +31 -10
- package/transforms/browserDirnamePlugin.test.ts +1 -1
- package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
- package/transforms/mcpAppPageTrimmer.test.ts +1 -1
- package/transforms/pureLazyMarker.test.ts +1 -1
- package/transforms/serverEnvPlugin.test.ts +1 -1
- package/transforms/serverEnvProfile.test.ts +1 -1
- package/transforms/sideEffectImportOrder.test.ts +1 -1
- package/transforms/transforms.test.ts +52 -2
- package/transforms/tsconfigPackageResolver.test.ts +1 -1
- package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
- package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
- package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
- package/typecheck/projectTypecheck.test.ts +23 -1
- package/typecheck/projectTypecheck.ts +10 -2
- package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
- package/{typeChecker.ts → typecheck/typeChecker.ts} +5 -4
- package/typecheck/typecheck.proc.ts +6 -2
- package/typecheck/typecheckFailure.ts +1 -1
- package/util/errorReport.ts +66 -0
- package/{fileSys.test.ts → util/fileSys.test.ts} +13 -0
- package/{fileSys.ts → util/fileSys.ts} +2 -2
- package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
- package/workflow/constantSource.ts +187 -0
- package/workflow/dictionarySource.ts +184 -0
- package/workflow/executor.ts +6 -9
- package/workflow/fieldExpression.ts +153 -0
- package/workflow/fieldLabel.ts +61 -0
- package/workflow/fieldOrder.ts +117 -0
- package/workflow/fieldType.ts +2 -1
- package/workflow/guardCatalog.test.ts +1 -1
- package/workflow/keyRename.ts +1 -1
- package/workflow/moduleIndex.test.ts +2 -2
- package/workflow/moduleIndex.ts +2 -2
- package/workflow/modulePaths.ts +27 -0
- package/workflow/mutationScaffold.ts +7 -15
- package/workflow/mutationSource.ts +2 -1
- package/workflow/plan.ts +2 -1
- package/workflow/primitiveReport.ts +78 -0
- package/workflow/rolloutGate.test.ts +1 -1
- package/workflow/rolloutGate.ts +1 -1
- package/workflow/serviceSource.ts +33 -0
- package/workflow/signalSource.ts +96 -0
- package/workflow/source.ts +50 -1100
- package/workflow/sourceAst.ts +30 -0
- package/workflow/sourceImports.ts +105 -0
- package/workflow/sourceText.ts +13 -0
- package/workflow/templateSource.ts +30 -0
- package/workflow/testSource.ts +31 -0
- package/workflow/types.ts +1 -1
- package/workflow/uiPolicy.ts +1 -1
- package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
- package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
- package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
- package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
- package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
- package/{envSeed.ts → workspace/envSeed.ts} +1 -1
- package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
- package/{libSource.ts → workspace/libSource.ts} +1 -1
- package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
- package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
- package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
- package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +1 -1
- package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +1 -1
- package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
- package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
- package/akanContext.ts +0 -1083
- package/executors.ts +0 -1749
- /package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +0 -0
- /package/{akanMcpToolError.ts → context/akanMcpToolError.ts} +0 -0
- /package/{moduleFieldNames.test.ts → context/moduleFieldNames.test.ts} +0 -0
- /package/{moduleFieldNames.ts → context/moduleFieldNames.ts} +0 -0
- /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
- /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
- /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
- /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
- /package/{linter.ts → lint/linter.ts} +0 -0
- /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
- /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
- /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
- /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
- /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
- /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
- /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
- /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
- /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
- /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
- /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
- /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
- /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
- /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
- /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
- /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
- /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
- /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
- /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
- /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
- /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
- /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
- /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
- /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
- /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
- /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
- /package/{storeSource.ts → quality/storeSource.ts} +0 -0
- /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
- /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
- /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
- /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
- /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
- /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
- /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
- /package/{writePath.ts → quality/writePath.ts} +0 -0
- /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
- /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
- /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
- /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
- /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
- /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
- /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
- /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
- /package/{selectModel.ts → util/selectModel.ts} +0 -0
- /package/{semver.test.ts → util/semver.test.ts} +0 -0
- /package/{semver.ts → util/semver.ts} +0 -0
- /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
- /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
- /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
- /package/{spinner.ts → util/spinner.ts} +0 -0
- /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
- /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
- /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
- /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
- /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
- /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
- /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
- /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
- /package/{types.ts → workspace/types.ts} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const PS_RSS_TIMEOUT_MS = 2_000;
|
|
2
|
+
|
|
3
|
+
export class ProcessRss {
|
|
4
|
+
static async bytesOf(pid: number): Promise<number | null> {
|
|
5
|
+
if (process.platform === "win32")
|
|
6
|
+
return await ProcessRss.#readRssKbVia(
|
|
7
|
+
["tasklist", "/FI", `PID eq ${pid}`, "/FO", "CSV", "/NH"],
|
|
8
|
+
ProcessRss.#tasklistRssKb,
|
|
9
|
+
);
|
|
10
|
+
if (process.platform === "darwin") {
|
|
11
|
+
const footprintBytes = await ProcessRss.#readRssKbVia(
|
|
12
|
+
["footprint", "-p", String(pid), "-f", "bytes"],
|
|
13
|
+
ProcessRss.#footprintKb,
|
|
14
|
+
);
|
|
15
|
+
if (footprintBytes !== null) return footprintBytes;
|
|
16
|
+
}
|
|
17
|
+
const status = await Bun.file(`/proc/${pid}/status`)
|
|
18
|
+
.text()
|
|
19
|
+
.catch(() => null);
|
|
20
|
+
const vmRssKb = status === null ? null : /VmRSS:\s+(\d+) kB/.exec(status)?.[1];
|
|
21
|
+
if (vmRssKb) return Number(vmRssKb) * 1024;
|
|
22
|
+
return await ProcessRss.#readRssKbVia(["ps", "-o", "rss=", "-p", String(pid)], (output) => Number(output.trim()));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Bounded: a `ps` that hangs under load would silently cancel the recycle awaiting it.
|
|
26
|
+
static async #readRssKbVia(
|
|
27
|
+
command: string[],
|
|
28
|
+
parseKb: (output: string) => number,
|
|
29
|
+
timeoutMs = PS_RSS_TIMEOUT_MS,
|
|
30
|
+
): Promise<number | null> {
|
|
31
|
+
let proc: Bun.Subprocess<"ignore", "pipe", "ignore">;
|
|
32
|
+
try {
|
|
33
|
+
proc = Bun.spawn(command, { stdio: ["ignore", "pipe", "ignore"] });
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const killer = setTimeout(() => proc.kill("SIGKILL"), timeoutMs);
|
|
38
|
+
try {
|
|
39
|
+
const output = await new Response(proc.stdout).text();
|
|
40
|
+
await proc.exited;
|
|
41
|
+
const rssKb = parseKb(output);
|
|
42
|
+
return Number.isFinite(rssKb) && rssKb > 0 ? rssKb * 1024 : null;
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
} finally {
|
|
46
|
+
clearTimeout(killer);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// `Mem Usage` is the working set (what `process.memoryUsage.rss()` reports on Windows) in locale-grouped KB.
|
|
51
|
+
static #tasklistRssKb(output: string): number {
|
|
52
|
+
const memUsage = /"([^"]*)"\s*$/m.exec(output)?.[1];
|
|
53
|
+
return memUsage ? Number(memUsage.replace(/\D/g, "")) : Number.NaN;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// The footprint is what `process.memoryUsage.rss()` reports on macOS; `ps` also counts pages freed for reuse.
|
|
57
|
+
static #footprintKb(output: string): number {
|
|
58
|
+
const bytes = /Footprint: (\d+) B\b/.exec(output)?.[1];
|
|
59
|
+
return bytes ? Number(bytes) / 1024 : Number.NaN;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -5,7 +5,7 @@ import path from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { AppExecutor, WorkspaceExecutor } from "../executors";
|
|
7
7
|
import { NativeConfig } from "../mobile/nativeConfig";
|
|
8
|
-
import type { PackageJson } from "../types";
|
|
8
|
+
import type { PackageJson } from "../workspace/types";
|
|
9
9
|
import { AkanAppConfig, AkanLibConfig, deriveDefaultAppId } from "./akanConfig";
|
|
10
10
|
import type { LibConfigInput } from "./types";
|
|
11
11
|
|
|
@@ -166,22 +166,27 @@ describe("AkanAppConfig", () => {
|
|
|
166
166
|
expect(unlocked).not.toContain("bun.lock");
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
-
test(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
169
|
+
test.skipIf(process.platform === "win32")(
|
|
170
|
+
"writes a Dockerfile for a local build that refuses docker build without an explicit build arg",
|
|
171
|
+
() => {
|
|
172
|
+
const config = new AkanAppConfig(app, [], packageJson, {}, baseDevEnv);
|
|
173
|
+
const local = config.dockerfileFor("local");
|
|
174
|
+
const guard = local
|
|
175
|
+
.split("\n")
|
|
176
|
+
.find((line) => line.includes("AKAN_ALLOW_LOCAL_IMAGE") && line.startsWith("RUN "));
|
|
177
|
+
if (!guard) throw new Error("expected the local image guard");
|
|
178
|
+
const run = (allow?: string) =>
|
|
179
|
+
Bun.spawnSync(["sh", "-c", guard.slice("RUN ".length)], {
|
|
180
|
+
env: { PATH: process.env.PATH ?? "", ...(allow ? { AKAN_ALLOW_LOCAL_IMAGE: allow } : {}) },
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
expect(local).toContain(`FROM ${pinnedBunImage}\nARG AKAN_ALLOW_LOCAL_IMAGE\nRUN if`);
|
|
184
|
+
expect(config.dockerfileFor("main")).not.toContain("AKAN_ALLOW_LOCAL_IMAGE");
|
|
185
|
+
expect(run().exitCode).toBe(1);
|
|
186
|
+
expect(run().stderr.toString()).toContain("--build-arg AKAN_ALLOW_LOCAL_IMAGE=1");
|
|
187
|
+
expect(run("1").exitCode).toBe(0);
|
|
188
|
+
},
|
|
189
|
+
);
|
|
185
190
|
|
|
186
191
|
test("defaults both web surfaces on and keeps the image free of web env overrides", () => {
|
|
187
192
|
const config = new AkanAppConfig(app, [], packageJson, {}, baseDevEnv);
|
|
@@ -1079,6 +1084,29 @@ describe("AkanAppConfig.importConfigModule", () => {
|
|
|
1079
1084
|
});
|
|
1080
1085
|
});
|
|
1081
1086
|
|
|
1087
|
+
describe("AkanAppConfig.from", () => {
|
|
1088
|
+
test("a busted reload re-reads an edited lib config", async () => {
|
|
1089
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "akan-config-lib-bust-"));
|
|
1090
|
+
try {
|
|
1091
|
+
const libConfigPath = path.join(root, "libs/extlib/akan.config.ts");
|
|
1092
|
+
fs.mkdirSync(path.join(root, "apps/extapp"), { recursive: true });
|
|
1093
|
+
fs.mkdirSync(path.join(root, "libs/extlib"), { recursive: true });
|
|
1094
|
+
fs.writeFileSync(path.join(root, "apps/extapp/akan.config.ts"), "export default {};\n");
|
|
1095
|
+
fs.writeFileSync(libConfigPath, "export default { externalLibs: ['first'] };\n");
|
|
1096
|
+
fs.writeFileSync(path.join(root, "package.json"), JSON.stringify({ name: "extrepo", version: "1.0.0" }));
|
|
1097
|
+
fs.writeFileSync(path.join(root, ".env"), "AKAN_PUBLIC_REPO_NAME=extrepo\nAKAN_PUBLIC_SERVE_DOMAIN=ext.test\n");
|
|
1098
|
+
const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot: root, repoName: "extrepo" });
|
|
1099
|
+
const app = AppExecutor.from(workspace, "extapp");
|
|
1100
|
+
expect((await AkanAppConfig.from(app)).externalLibs).toEqual(["first"]);
|
|
1101
|
+
|
|
1102
|
+
fs.writeFileSync(libConfigPath, "export default { externalLibs: ['second'] };\n");
|
|
1103
|
+
expect((await AkanAppConfig.from(app, { bustImportCache: true })).externalLibs).toEqual(["second"]);
|
|
1104
|
+
} finally {
|
|
1105
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
1106
|
+
}
|
|
1107
|
+
});
|
|
1108
|
+
});
|
|
1109
|
+
|
|
1082
1110
|
describe("pipeline and workspace keys in app and lib configs", () => {
|
|
1083
1111
|
test("an app's pipeline is dropped before the instance exists, so it never reaches akan.app.json", async () => {
|
|
1084
1112
|
const config = await loadExtAppConfig(
|
package/akanConfig/akanConfig.ts
CHANGED
|
@@ -7,9 +7,9 @@ import { type AkanI18nConfig, resolveAkanI18nConfig, trimSlashes } from "akanjs/
|
|
|
7
7
|
import type { ServerPolicy } from "akanjs/native/api";
|
|
8
8
|
import type { AkanImageConfig } from "akanjs/server";
|
|
9
9
|
import type { App, Lib } from "../commandDecorators";
|
|
10
|
-
import {
|
|
10
|
+
import { WorkspaceExecutor } from "../executors/workspaceExecutor";
|
|
11
11
|
import { ServerEnvProfile } from "../transforms/serverEnvProfile";
|
|
12
|
-
import type { BaseDevEnv, PackageJson } from "../types";
|
|
12
|
+
import type { BaseDevEnv, PackageJson } from "../workspace/types";
|
|
13
13
|
import { AkanBin } from "./akanBin";
|
|
14
14
|
import {
|
|
15
15
|
type AkanApiConfig,
|
|
@@ -708,16 +708,16 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
|
|
|
708
708
|
//* Every workspace lib is read, not just this app's lib deps: narrowing the set needs the dependency
|
|
709
709
|
//* scan, and the incremental page rebundle re-reads this config on every file change.
|
|
710
710
|
static async #collectLibContributions(app: App, libs: string[], bustImportCache: boolean): Promise<LibContributions> {
|
|
711
|
+
//? Imported on use: sysExecutor.ts imports this file, so a static import would load a SysExecutor subclass first.
|
|
712
|
+
const { LibExecutor } = await import("../executors/libExecutor");
|
|
711
713
|
const libConfigs = await Promise.all(
|
|
712
714
|
libs.map(async (libName) =>
|
|
713
|
-
LibExecutor.from(app, libName)
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
return null;
|
|
720
|
-
}),
|
|
715
|
+
AkanLibConfig.from(LibExecutor.from(app, libName), { bustImportCache }).catch((error: unknown) => {
|
|
716
|
+
//? Skipping a refused lib config would build the image without its docker steps, and the build would pass.
|
|
717
|
+
if (error instanceof LibConfigRefusal) throw error;
|
|
718
|
+
app.logger.warn(`Skipped libs/${libName}/akan.config.ts contributions: ${String(error)}`);
|
|
719
|
+
return null;
|
|
720
|
+
}),
|
|
721
721
|
),
|
|
722
722
|
);
|
|
723
723
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import type { SubspaceConfigInput, WorkspaceConfig, WorkspacePipelineConfig } from "akanjs";
|
|
3
3
|
import type { WorkspaceExecutor } from "../executors";
|
|
4
|
-
import { FileSys } from "../fileSys";
|
|
4
|
+
import { FileSys } from "../util/fileSys";
|
|
5
5
|
import { AkanAppConfig } from "./akanConfig";
|
|
6
6
|
|
|
7
7
|
/** The workspace root's own `akan.config.ts`: settings that belong to no app. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import type { PackageJson } from "../types";
|
|
4
|
+
import type { PackageJson } from "../workspace/types";
|
|
5
5
|
|
|
6
6
|
export class ProductionLockfile {
|
|
7
7
|
static readonly fileName = "bun.lock";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, setDefaultTimeout, test } from "bun:test";
|
|
2
2
|
import { rm } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { tempDirs, writeText } from "../testHelpers";
|
|
4
|
+
import { tempDirs, writeText } from "../test/testHelpers";
|
|
5
5
|
import { ApiReport } from "./apiReport";
|
|
6
6
|
import { ApiReportDiff } from "./apiReportDiff";
|
|
7
7
|
import { ApiReportPolicy } from "./apiReportPolicy";
|
|
@@ -108,8 +108,8 @@ describe("ApiReport", () => {
|
|
|
108
108
|
test("reads named TS entry points and lists wildcards apart", () => {
|
|
109
109
|
const { entries, wildcards } = ApiReport.entriesOf(JSON.parse(fixture["package.json"] ?? "{}"), "/pkg");
|
|
110
110
|
expect(entries.map(({ specifier, reportName, file }) => ({ specifier, reportName, file }))).toEqual([
|
|
111
|
-
{ specifier: "demo", reportName: "demo.api.md", file: "/pkg/index.ts" },
|
|
112
|
-
{ specifier: "demo/sub", reportName: "demo.sub.api.md", file: "/pkg/sub/index.ts" },
|
|
111
|
+
{ specifier: "demo", reportName: "demo.api.md", file: path.resolve("/pkg/index.ts") },
|
|
112
|
+
{ specifier: "demo/sub", reportName: "demo.sub.api.md", file: path.resolve("/pkg/sub/index.ts") },
|
|
113
113
|
]);
|
|
114
114
|
expect(wildcards).toEqual(["./parts/*"]);
|
|
115
115
|
});
|
|
@@ -383,6 +383,35 @@ describe("ApiReportDiff", () => {
|
|
|
383
383
|
{ report: "demo.old.api.md", name: "Old", kind: "removed", before: "export type Old = string;" },
|
|
384
384
|
]);
|
|
385
385
|
});
|
|
386
|
+
test("reads a union or an object type whose members only moved as the same declaration", () => {
|
|
387
|
+
const recipe = (first: string, second: string, sizes: string) =>
|
|
388
|
+
reportOf([
|
|
389
|
+
`export declare const recipe: (variants?: Omit<({\n size?: ${sizes} | undefined;\n ${first}\n ${second}\n} & {\n class?: string;\n}), "class">) => string;`,
|
|
390
|
+
]);
|
|
391
|
+
const before = new Map([["demo.api.md", recipe("variant?: boolean;", "outline?: boolean;", '"lg" | "sm"')]]);
|
|
392
|
+
const moved = new Map([["demo.api.md", recipe("outline?: boolean;", "variant?: boolean;", '"sm" | "lg"')]]);
|
|
393
|
+
const retyped = new Map([["demo.api.md", recipe("outline?: boolean;", "variant?: string;", '"sm" | "lg"')]]);
|
|
394
|
+
expect(ApiReportDiff.breaks(before, moved)).toEqual([]);
|
|
395
|
+
expect(ApiReportDiff.breaks(before, retyped).map(({ name, kind }) => `${kind} ${name}`)).toEqual([
|
|
396
|
+
"changed recipe",
|
|
397
|
+
]);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
test("compares a block that fails to parse as text, since parser recovery can drop what differs", () => {
|
|
401
|
+
const broken = (member: string) =>
|
|
402
|
+
new Map([["demo.api.md", reportOf([`export type T = {\n a: 1;\n @@@ ${member}\n};`])]]);
|
|
403
|
+
expect(ApiReportDiff.breaks(broken("b: 2;"), broken("c: 2;")).map(({ name, kind }) => `${kind} ${name}`)).toEqual([
|
|
404
|
+
"changed T",
|
|
405
|
+
]);
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
test("still reads reordered overloads as a change, since their order picks the signature", () => {
|
|
409
|
+
const overloads = (first: string, second: string) =>
|
|
410
|
+
new Map([["demo.api.md", reportOf([`export declare const on: {\n ${first}\n ${second}\n};`])]]);
|
|
411
|
+
const before = overloads("(value: string): string;", "(value: number): number;");
|
|
412
|
+
const after = overloads("(value: number): number;", "(value: string): string;");
|
|
413
|
+
expect(ApiReportDiff.breaks(before, after).map(({ name, kind }) => `${kind} ${name}`)).toEqual(["changed on"]);
|
|
414
|
+
});
|
|
386
415
|
});
|
|
387
416
|
|
|
388
417
|
describe("ChangesetBump", () => {
|
|
@@ -423,6 +452,8 @@ describe("ApiReportPolicy", () => {
|
|
|
423
452
|
"commit.gpgsign=false",
|
|
424
453
|
"-c",
|
|
425
454
|
"core.hooksPath=/dev/null",
|
|
455
|
+
"-c",
|
|
456
|
+
"core.autocrlf=false",
|
|
426
457
|
...args,
|
|
427
458
|
],
|
|
428
459
|
{ cwd: root, stdout: "pipe", stderr: "pipe" },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
1
2
|
import { ApiReport } from "./apiReport";
|
|
2
3
|
|
|
3
4
|
export interface ApiBreak {
|
|
@@ -22,6 +23,7 @@ export class ApiReportDiff {
|
|
|
22
23
|
static readonly #reexportPattern = /^export \{ (\S+)(?: as (\S+))? \} from /;
|
|
23
24
|
static readonly #namespaceReexportPattern = /^export \* as (\S+) from /;
|
|
24
25
|
static readonly #tagLine = /^\/\*\* (?:@\w+ ?)+\*\/$/;
|
|
26
|
+
static readonly #printer = ts.createPrinter({ removeComments: true, newLine: ts.NewLineKind.LineFeed });
|
|
25
27
|
static readonly #subpathPattern = /^- `(\S+)`$/gm;
|
|
26
28
|
static readonly #referencedSuffix = " (referenced)";
|
|
27
29
|
static readonly #referencedMark = " (referenced";
|
|
@@ -113,7 +115,39 @@ export class ApiReportDiff {
|
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
static #sameDeclaration(a: string, b: string) {
|
|
116
|
-
|
|
118
|
+
const [left, right] = [ApiReportDiff.#declarationOf(a), ApiReportDiff.#declarationOf(b)];
|
|
119
|
+
return left === right || ApiReportDiff.#unorderedOf(left) === ApiReportDiff.#unorderedOf(right);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//? The checker orders union members and mapped keys by first sight, so checking files in another order moves them.
|
|
123
|
+
static #unorderedOf(declaration: string) {
|
|
124
|
+
const source = ts.createSourceFile("block.d.ts", declaration, ts.ScriptTarget.Latest, false, ts.ScriptKind.TS);
|
|
125
|
+
//? `parseDiagnostics` is internal: parser recovery can drop tokens, so a block that failed to parse stays as text.
|
|
126
|
+
if ("parseDiagnostics" in source && Array.isArray(source.parseDiagnostics) && source.parseDiagnostics.length)
|
|
127
|
+
return declaration;
|
|
128
|
+
const textOf = (node: ts.Node) => ApiReportDiff.#printer.printNode(ts.EmitHint.Unspecified, node, source);
|
|
129
|
+
const byText = (a: ts.Node, b: ts.Node) => ApiReport.compare(textOf(a), textOf(b));
|
|
130
|
+
const byName = (a: ts.TypeElement, b: ts.TypeElement) =>
|
|
131
|
+
ApiReport.compare(a.name ? textOf(a.name) : "", b.name ? textOf(b.name) : "");
|
|
132
|
+
const sortMembers: ts.TransformerFactory<ts.SourceFile> = (context) => {
|
|
133
|
+
const visit = (node: ts.Node): ts.Node => {
|
|
134
|
+
const next = ts.visitEachChild(node, visit, context);
|
|
135
|
+
if (ts.isUnionTypeNode(next))
|
|
136
|
+
return context.factory.updateUnionTypeNode(
|
|
137
|
+
next,
|
|
138
|
+
context.factory.createNodeArray([...next.types].sort(byText)),
|
|
139
|
+
);
|
|
140
|
+
if (ts.isTypeLiteralNode(next))
|
|
141
|
+
return context.factory.updateTypeLiteralNode(
|
|
142
|
+
next,
|
|
143
|
+
context.factory.createNodeArray([...next.members].sort(byName)),
|
|
144
|
+
);
|
|
145
|
+
return next;
|
|
146
|
+
};
|
|
147
|
+
return (file) => ts.visitEachChild(file, visit, context);
|
|
148
|
+
};
|
|
149
|
+
const [sorted = source] = ts.transform(source, [sortMembers]).transformed;
|
|
150
|
+
return ApiReportDiff.#printer.printFile(sorted);
|
|
117
151
|
}
|
|
118
152
|
|
|
119
153
|
static #declarationOf(block: string) {
|
|
@@ -37,9 +37,10 @@ export class ApiReportPolicy {
|
|
|
37
37
|
const mergeBase = (await this.#git(["merge-base", base, "HEAD"]))?.trim();
|
|
38
38
|
if (!mergeBase) return null;
|
|
39
39
|
const before = new Map<string, string>();
|
|
40
|
-
const
|
|
40
|
+
const treeDir = this.#reportDir.split(path.sep).join("/");
|
|
41
|
+
const listed = (await this.#git(["ls-tree", "--name-only", `${mergeBase}:${treeDir}`])) ?? "";
|
|
41
42
|
for (const file of listed.split("\n").filter((name) => name.endsWith(ApiReport.extension)))
|
|
42
|
-
before.set(file, (await this.#git(["show", `${mergeBase}:${
|
|
43
|
+
before.set(file, (await this.#git(["show", `${mergeBase}:${treeDir}/${file}`])) ?? "");
|
|
43
44
|
const breaks = ApiReportDiff.breaks(before, await this.readReports());
|
|
44
45
|
if (!breaks.length) return { breaks, bumped: false };
|
|
45
46
|
const added = [
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { realpathSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
1
|
import { Logger } from "akanjs/common";
|
|
2
|
+
import { ErrorReport } from "../util/errorReport";
|
|
4
3
|
import { RouteJsBudget, type RouteJsBudgetWarning, type RouteJsSize } from "./routeJsBudget";
|
|
5
4
|
|
|
6
5
|
export interface ApplicationBuildPhaseResult {
|
|
@@ -58,53 +57,7 @@ export class ApplicationBuildReporter {
|
|
|
58
57
|
"Built for local: the server runs without endpoint rate limits, and boots on local defaults (Redis on localhost, the first database mode) where a deployment would stop to ask. For a host others can reach, run `akan build <app> --env main` with AKAN_PUBLIC_REPO_NAME and AKAN_PUBLIC_SERVE_DOMAIN set in the shell or the workspace .env.";
|
|
59
58
|
|
|
60
59
|
static formatError(error: unknown, workspaceRoot = process.cwd()): string {
|
|
61
|
-
|
|
62
|
-
const nestedMessages = error.errors
|
|
63
|
-
.map(
|
|
64
|
-
(nestedError, index) =>
|
|
65
|
-
ApplicationBuildReporter.formatError(nestedError, workspaceRoot).trim() || `Unknown error ${index + 1}`,
|
|
66
|
-
)
|
|
67
|
-
.map((message) => message.replace(/^/gm, " "))
|
|
68
|
-
.join("\n");
|
|
69
|
-
|
|
70
|
-
return nestedMessages ? `${error.message}\n${nestedMessages}` : error.message;
|
|
71
|
-
}
|
|
72
|
-
if (error instanceof Error) {
|
|
73
|
-
const causeMessage = error.cause
|
|
74
|
-
? `\nCaused by: ${ApplicationBuildReporter.formatError(error.cause, workspaceRoot)}`
|
|
75
|
-
: "";
|
|
76
|
-
return `${ApplicationBuildReporter.#withLocation(error.message, error, workspaceRoot)}${causeMessage}`;
|
|
77
|
-
}
|
|
78
|
-
if (typeof error === "object" && error !== null && "message" in error)
|
|
79
|
-
return ApplicationBuildReporter.#withLocation(String(error.message), error, workspaceRoot);
|
|
80
|
-
return String(error);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
static #withLocation(message: string, error: object, workspaceRoot: string): string {
|
|
84
|
-
const { position } = error as { position?: { file: string; line: number; column: number } | null };
|
|
85
|
-
if (!position?.file) return message;
|
|
86
|
-
const file = ApplicationBuildReporter.#relativeToWorkspace(position.file, workspaceRoot);
|
|
87
|
-
const location = position.line > 0 ? `${file}:${position.line}:${position.column}` : file;
|
|
88
|
-
return message.includes(location) ? message : message.replace(/^.*/, (headline) => `${headline} (${location})`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Bun names the file by its realpath, so a workspace root reached through a symlink is matched by its own too.
|
|
92
|
-
static #relativeToWorkspace(file: string, workspaceRoot: string): string {
|
|
93
|
-
if (!path.isAbsolute(file)) return file;
|
|
94
|
-
for (const root of [workspaceRoot, ApplicationBuildReporter.#realpathOf(workspaceRoot)]) {
|
|
95
|
-
const relative = path.relative(root, file);
|
|
96
|
-
if (!relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative))
|
|
97
|
-
return relative.replaceAll(path.sep, "/");
|
|
98
|
-
}
|
|
99
|
-
return file;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
static #realpathOf(dir: string): string {
|
|
103
|
-
try {
|
|
104
|
-
return realpathSync(dir);
|
|
105
|
-
} catch {
|
|
106
|
-
return dir;
|
|
107
|
-
}
|
|
60
|
+
return ErrorReport.format(error, workspaceRoot);
|
|
108
61
|
}
|
|
109
62
|
|
|
110
63
|
static formatDuration(ms: number): string {
|
|
@@ -2,15 +2,15 @@ import { describe, expect, spyOn, test } from "bun:test";
|
|
|
2
2
|
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { AkanAppConfig } from "
|
|
6
|
-
import { ProductionLockfile } from "
|
|
5
|
+
import { AkanAppConfig } from "../akanConfig";
|
|
6
|
+
import { ProductionLockfile } from "../akanConfig/productionLockfile";
|
|
7
|
+
import type { App } from "../commandDecorators";
|
|
8
|
+
import { AppExecutor, Executor } from "../executors";
|
|
9
|
+
import { AllRoutesBuilder, type BuildAllRoutesResult, VendorNarrowing } from "../frontendBuild";
|
|
10
|
+
import { bundleDefine } from "../frontendBuild/bundleDefine";
|
|
11
|
+
import { createTempApp } from "../test/testHelpers";
|
|
12
|
+
import { ProjectTypecheck } from "../typecheck/projectTypecheck";
|
|
7
13
|
import { AKAN_BACKEND_MINIFY, AKAN_OPTIONAL_BACKEND_EXTERNALS, ApplicationBuildRunner } from "./applicationBuildRunner";
|
|
8
|
-
import type { App } from "./commandDecorators";
|
|
9
|
-
import { AppExecutor, Executor } from "./executors";
|
|
10
|
-
import { AllRoutesBuilder, type BuildAllRoutesResult, VendorNarrowing } from "./frontendBuild";
|
|
11
|
-
import { bundleDefine } from "./frontendBuild/bundleDefine";
|
|
12
|
-
import { createTempApp } from "./testHelpers";
|
|
13
|
-
import { ProjectTypecheck } from "./typecheck/projectTypecheck";
|
|
14
14
|
|
|
15
15
|
describe("ApplicationBuildRunner", () => {
|
|
16
16
|
test("externalizes Akan optional backend dependencies", () => {
|
|
@@ -163,6 +163,9 @@ console.info(new SampleService().name);
|
|
|
163
163
|
test("builds for the shell's AKAN_PUBLIC_ENV over the root .env's, and for --env over both", async () => {
|
|
164
164
|
const { root, workspace } = await createTempApp("portal");
|
|
165
165
|
const shellEnv = process.env.AKAN_PUBLIC_ENV;
|
|
166
|
+
const otherShellEnv = { repo: process.env.AKAN_PUBLIC_REPO_NAME, domain: process.env.AKAN_PUBLIC_SERVE_DOMAIN };
|
|
167
|
+
delete process.env.AKAN_PUBLIC_REPO_NAME;
|
|
168
|
+
delete process.env.AKAN_PUBLIC_SERVE_DOMAIN;
|
|
166
169
|
const stoppedBeforePhases = (app: AppExecutor) => {
|
|
167
170
|
app.prepareCommand = async () => {
|
|
168
171
|
throw new Error("stopped before the phases");
|
|
@@ -206,6 +209,8 @@ console.info(new SampleService().name);
|
|
|
206
209
|
} finally {
|
|
207
210
|
if (shellEnv === undefined) delete process.env.AKAN_PUBLIC_ENV;
|
|
208
211
|
else process.env.AKAN_PUBLIC_ENV = shellEnv;
|
|
212
|
+
if (otherShellEnv.repo !== undefined) process.env.AKAN_PUBLIC_REPO_NAME = otherShellEnv.repo;
|
|
213
|
+
if (otherShellEnv.domain !== undefined) process.env.AKAN_PUBLIC_SERVE_DOMAIN = otherShellEnv.domain;
|
|
209
214
|
await rm(root, { recursive: true, force: true });
|
|
210
215
|
}
|
|
211
216
|
});
|
|
@@ -389,4 +394,62 @@ console.info(new SampleService().name);
|
|
|
389
394
|
await rm(root, { recursive: true, force: true });
|
|
390
395
|
}
|
|
391
396
|
});
|
|
397
|
+
|
|
398
|
+
test("a verify build stops after the backend and SSR route compile but still measures the route JS budget", async () => {
|
|
399
|
+
const { root, workspace } = await createTempApp("portal");
|
|
400
|
+
const keys = ["AKAN_PUBLIC_ENV", "AKAN_PUBLIC_REPO_NAME", "AKAN_PUBLIC_SERVE_DOMAIN"] as const;
|
|
401
|
+
const shellEnv = Object.fromEntries(keys.map((key) => [key, process.env[key]]));
|
|
402
|
+
await Promise.all(["main.ts", "server.ts"].map((file) => writeFile(path.join(root, "apps", "portal", file), "")));
|
|
403
|
+
const app = AppExecutor.from(workspace, "portal");
|
|
404
|
+
app.prepareCommand = async () => ({ env: {} });
|
|
405
|
+
const bundle = spyOn(Bun, "build").mockImplementation(
|
|
406
|
+
async () => ({ success: true, outputs: [], logs: [] }) as unknown as Bun.BuildOutput,
|
|
407
|
+
);
|
|
408
|
+
try {
|
|
409
|
+
const { phases } = await new ApplicationBuildRunner(app, { verify: true }).build();
|
|
410
|
+
expect(phases.map((phase) => phase.id)).toEqual(["prepare", "backend", "ssr", "budget"]);
|
|
411
|
+
expect(await Bun.file(path.join(app.dist.cwdPath, "package.json")).exists()).toBe(false);
|
|
412
|
+
} finally {
|
|
413
|
+
bundle.mockRestore();
|
|
414
|
+
for (const key of keys) {
|
|
415
|
+
if (shellEnv[key] === undefined) delete process.env[key];
|
|
416
|
+
else process.env[key] = shellEnv[key];
|
|
417
|
+
}
|
|
418
|
+
await rm(root, { recursive: true, force: true });
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
test("marks a verify build's output and makes its main.js refuse to boot", async () => {
|
|
423
|
+
const { root, workspace } = await createTempApp("portal");
|
|
424
|
+
const keys = ["AKAN_PUBLIC_ENV", "AKAN_PUBLIC_REPO_NAME", "AKAN_PUBLIC_SERVE_DOMAIN"] as const;
|
|
425
|
+
const shellEnv = Object.fromEntries(keys.map((key) => [key, process.env[key]]));
|
|
426
|
+
await Promise.all(["main.ts", "server.ts"].map((file) => writeFile(path.join(root, "apps", "portal", file), "")));
|
|
427
|
+
const app = AppExecutor.from(workspace, "portal");
|
|
428
|
+
app.prepareCommand = async () => ({ env: {} });
|
|
429
|
+
const bundle = spyOn(Bun, "build").mockImplementation(
|
|
430
|
+
async () => ({ success: true, outputs: [], logs: [] }) as unknown as Bun.BuildOutput,
|
|
431
|
+
);
|
|
432
|
+
try {
|
|
433
|
+
await new ApplicationBuildRunner(app, { verify: true }).build();
|
|
434
|
+
const main = bundle.mock.calls.find(([config]) => config.entrypoints.some((entry) => entry.endsWith("main.ts")));
|
|
435
|
+
const banner = main?.[0].banner ?? "";
|
|
436
|
+
const mainPath = path.join(root, "main.js");
|
|
437
|
+
await writeFile(mainPath, `${banner}\nconsole.log("booted");\n`);
|
|
438
|
+
const proc = Bun.spawnSync([process.execPath, mainPath], { stdout: "pipe", stderr: "pipe" });
|
|
439
|
+
|
|
440
|
+
expect(proc.exitCode).toBe(1);
|
|
441
|
+
expect(proc.stdout.toString()).toBe("");
|
|
442
|
+
expect(proc.stderr.toString()).toContain("Run `akan build portal` first.");
|
|
443
|
+
expect(await Bun.file(path.join(app.dist.cwdPath, "akan.build.json")).json()).toMatchObject({
|
|
444
|
+
profile: "verify",
|
|
445
|
+
});
|
|
446
|
+
} finally {
|
|
447
|
+
bundle.mockRestore();
|
|
448
|
+
for (const key of keys) {
|
|
449
|
+
if (shellEnv[key] === undefined) delete process.env[key];
|
|
450
|
+
else process.env[key] = shellEnv[key];
|
|
451
|
+
}
|
|
452
|
+
await rm(root, { recursive: true, force: true });
|
|
453
|
+
}
|
|
454
|
+
});
|
|
392
455
|
});
|