@akanjs/devkit 3.2.0-rc.9 → 3.2.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 +132 -3
- package/akanApp/akanApp.host.ts +146 -1216
- package/akanApp/akanApp.host.wiring.test.ts +727 -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 +392 -0
- package/akanApp/devBuildStatusBoard.ts +128 -0
- package/akanApp/devBuilder.ts +196 -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/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 +448 -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} +76 -15
- 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/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/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 +1 -1
- 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/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 +14 -4
- package/incrementalBuilder/buildBatchProtocol.ts +2 -0
- package/incrementalBuilder/buildBatchRunner.test.ts +122 -2
- package/incrementalBuilder/buildBatchRunner.ts +17 -4
- package/incrementalBuilder/builderBoot.ts +106 -0
- package/incrementalBuilder/builderBuildStatus.ts +23 -0
- package/incrementalBuilder/builderChannel.test.ts +1 -1
- package/incrementalBuilder/builderChannel.ts +11 -0
- 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.proc.test.ts +101 -7
- package/incrementalBuilder/incrementalBuilder.proc.ts +81 -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/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/{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/{fileSys.test.ts → util/fileSys.test.ts} +0 -0
- /package/{fileSys.ts → util/fileSys.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
|
@@ -3,7 +3,7 @@ import { mkdir, symlink } from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import type { BunPlugin } from "bun";
|
|
5
5
|
import { resolveSsrPageEntries } from "../artifact/implicitRootLayout";
|
|
6
|
-
import { tempDirs, writeText as write } from "../testHelpers";
|
|
6
|
+
import { tempDirs, writeText as write } from "../test/testHelpers";
|
|
7
7
|
import { CsrArtifactBuilder } from "./csrArtifactBuilder";
|
|
8
8
|
import { VENDOR_SPECIFIERS } from "./vendorSpecifiers";
|
|
9
9
|
|
|
@@ -69,19 +69,37 @@ const buildCsr = async (indexPage: string) => {
|
|
|
69
69
|
logger: { warn: () => undefined },
|
|
70
70
|
};
|
|
71
71
|
const reached: string[] = [];
|
|
72
|
+
const metafiles: Bun.BuildMetafile[] = [];
|
|
72
73
|
const build = Bun.build;
|
|
73
|
-
const recorded = spyOn(Bun, "build").mockImplementation((config) =>
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const recorded = spyOn(Bun, "build").mockImplementation(async (config) => {
|
|
75
|
+
const result = await build({
|
|
76
|
+
...config,
|
|
77
|
+
metafile: true,
|
|
78
|
+
plugins: [recordOptionalPeers(reached), ...(config.plugins ?? [])],
|
|
79
|
+
});
|
|
80
|
+
if (result.metafile) metafiles.push(result.metafile);
|
|
81
|
+
return result;
|
|
82
|
+
});
|
|
76
83
|
|
|
77
84
|
try {
|
|
78
85
|
await new CsrArtifactBuilder(app as never, "build").build();
|
|
79
86
|
} finally {
|
|
80
87
|
recorded.mockRestore();
|
|
81
88
|
}
|
|
82
|
-
return { root, reached };
|
|
89
|
+
return { root, reached, metafiles };
|
|
83
90
|
};
|
|
84
91
|
|
|
92
|
+
const mcpAppPage =
|
|
93
|
+
'import { page } from "akanjs/client";\nimport { Link } from "akanjs/ui";\n\nexport default page()\n .app("showHome", "Show the home link.", () => <Link href="/">home</Link>)\n .render(() => null);\n';
|
|
94
|
+
|
|
95
|
+
const bytesFrom = (metafiles: Bun.BuildMetafile[], entry: string, input: string) =>
|
|
96
|
+
metafiles
|
|
97
|
+
.flatMap((metafile) => Object.values(metafile.outputs))
|
|
98
|
+
.filter((output) => output.entryPoint?.endsWith(entry))
|
|
99
|
+
.flatMap((output) => Object.entries(output.inputs))
|
|
100
|
+
.filter(([file]) => file.endsWith(input))
|
|
101
|
+
.reduce((sum, [, { bytesInOutput }]) => sum + bytesInOutput, 0);
|
|
102
|
+
|
|
85
103
|
describe("optional peers of akanjs", () => {
|
|
86
104
|
test("the generated root layout, the _overrides.tsx wrapper and the runtime entries import none", async () => {
|
|
87
105
|
const { appDir, pageKeys } = await writeApp("export default function Page() {\n return null;\n}\n");
|
|
@@ -122,11 +140,21 @@ describe("optional peers of akanjs", () => {
|
|
|
122
140
|
});
|
|
123
141
|
|
|
124
142
|
test("the MCP App view build of a page drawing akanjs/ui components imports none", async () => {
|
|
125
|
-
const { root, reached } = await buildCsr(
|
|
126
|
-
'import { page } from "akanjs/client";\nimport { Link } from "akanjs/ui";\n\nexport default page()\n .app("showHome", "Show the home link.", () => <Link href="/">home</Link>)\n .render(() => null);\n',
|
|
127
|
-
);
|
|
143
|
+
const { root, reached } = await buildCsr(mcpAppPage);
|
|
128
144
|
|
|
129
145
|
expect(await Bun.file(path.join(root, "dist/apps/demo/mcp-apps/showHome.html")).exists()).toBe(true);
|
|
130
146
|
expect(reached).toEqual([]);
|
|
131
147
|
});
|
|
132
148
|
});
|
|
149
|
+
|
|
150
|
+
describe("the CSR shell and the MCP App view", () => {
|
|
151
|
+
test("leave out the route-level boundary class, which only a server render draws, and keep RenderFailure", async () => {
|
|
152
|
+
const { metafiles } = await buildCsr(mcpAppPage);
|
|
153
|
+
|
|
154
|
+
for (const entry of ["generated/csr/index.html", "generated/mcp-apps/showHome.html"]) {
|
|
155
|
+
expect(bytesFrom(metafiles, entry, "webkit/RenderFailure.tsx")).toBeGreaterThan(0);
|
|
156
|
+
//? What stays of the module is its React import binding; the class alone is several hundred bytes.
|
|
157
|
+
expect(bytesFrom(metafiles, entry, "webkit/RouteLevelBoundary.tsx")).toBeLessThan(40);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
});
|
|
@@ -2,11 +2,10 @@ import { describe, expect, test } from "bun:test";
|
|
|
2
2
|
import { PagesBundleBuilder } from "./pagesBundleBuilder";
|
|
3
3
|
|
|
4
4
|
const macroImport = `import { getSerializedSignal } from "./sig" with { type: "macro" };`;
|
|
5
|
-
const macroFetchProto =
|
|
6
|
-
"const fetchProto = FetchClient.build<typeof signal>(cnst, getSerializedSignal(), { Err: pageProto.Err });";
|
|
5
|
+
const macroFetchProto = "const fetchProto = FetchClient.build<typeof signal>(cnst, getSerializedSignal());";
|
|
7
6
|
const serverImport = `import { fetch as serverFetch } from "./sig";`;
|
|
8
7
|
const serverFetchProto =
|
|
9
|
-
"const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, {
|
|
8
|
+
"const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { base: serverFetch });";
|
|
10
9
|
|
|
11
10
|
const generatedUseClient = (lines: { importLine?: string; fetchProtoLine?: string } = {}) =>
|
|
12
11
|
[
|
|
@@ -196,7 +196,7 @@ export class PagesBundleBuilder {
|
|
|
196
196
|
edits.push({
|
|
197
197
|
start: tokens[fetchProtoAt].start,
|
|
198
198
|
end: fetchProtoEnd.end,
|
|
199
|
-
text: "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, {
|
|
199
|
+
text: "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { base: serverFetch });",
|
|
200
200
|
});
|
|
201
201
|
let transformed = source;
|
|
202
202
|
for (const { start, end, text } of edits.sort((a, b) => b.start - a.start))
|
|
@@ -3,7 +3,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import zlib from "node:zlib";
|
|
5
5
|
import type { App } from "../commandDecorators";
|
|
6
|
-
import { tempDirs } from "../testHelpers";
|
|
6
|
+
import { tempDirs } from "../test/testHelpers";
|
|
7
7
|
import { precompressArtifacts } from "./precompressArtifacts";
|
|
8
8
|
|
|
9
9
|
const tempRoot = tempDirs("akan-devkit-precompress-");
|
|
@@ -12,6 +12,11 @@ const MAX_BROTLI_QUALITY = 11;
|
|
|
12
12
|
const BROTLI_QUALITY_BY_EXT = { ".css": MAX_BROTLI_QUALITY } as const;
|
|
13
13
|
const DEFAULT_BROTLI_QUALITY = 9;
|
|
14
14
|
const GZIP_LEVEL = 9;
|
|
15
|
+
const ROOT_BROTLI_QUALITY: Record<string, number | undefined> = {
|
|
16
|
+
client: undefined,
|
|
17
|
+
styles: undefined,
|
|
18
|
+
dict: MAX_BROTLI_QUALITY,
|
|
19
|
+
};
|
|
15
20
|
const { formatBytes } = FontPruner;
|
|
16
21
|
|
|
17
22
|
export interface PrecompressArtifactsResult {
|
|
@@ -22,13 +27,12 @@ export interface PrecompressArtifactsResult {
|
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
export async function precompressArtifacts(app: App): Promise<PrecompressArtifactsResult> {
|
|
25
|
-
//* WebRouter serves client/, styles/ and dict/ through the same sidecar-aware
|
|
30
|
+
//* WebRouter serves client/, styles/ and dict/ through the same sidecar-aware WebRouteContext.fileResponse.
|
|
26
31
|
const artifactDir = path.join(app.dist.cwdPath, ".akan/artifact");
|
|
27
|
-
const roots = [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
];
|
|
32
|
+
const roots = Object.entries(ROOT_BROTLI_QUALITY).map(([dir, brotliQuality]) => ({
|
|
33
|
+
root: path.join(artifactDir, dir),
|
|
34
|
+
brotliQuality,
|
|
35
|
+
}));
|
|
32
36
|
const result: PrecompressArtifactsResult = { files: 0, inputBytes: 0, outputBytes: 0, brotliBytes: 0 };
|
|
33
37
|
|
|
34
38
|
await Promise.all(roots.map(({ root, brotliQuality }) => precompressRoot(root, result, brotliQuality)));
|
|
@@ -63,6 +67,15 @@ async function precompressRoot(
|
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
|
|
70
|
+
export async function servedBrotliBytesOf(artifactDir: string, filePath: string): Promise<number> {
|
|
71
|
+
const root = path.relative(artifactDir, filePath).split(path.sep)[0] ?? "";
|
|
72
|
+
if (!Object.hasOwn(ROOT_BROTLI_QUALITY, root) || !(await shouldPrecompress(filePath))) return Bun.file(filePath).size;
|
|
73
|
+
const bytes = await Bun.file(filePath).bytes();
|
|
74
|
+
const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer;
|
|
75
|
+
const quality = ROOT_BROTLI_QUALITY[root] ?? brotliQualityOf(path.extname(filePath).toLowerCase());
|
|
76
|
+
return brotliCompress(buffer, quality).byteLength;
|
|
77
|
+
}
|
|
78
|
+
|
|
66
79
|
function brotliQualityOf(ext: string): number {
|
|
67
80
|
return BROTLI_QUALITY_BY_EXT[ext as keyof typeof BROTLI_QUALITY_BY_EXT] ?? DEFAULT_BROTLI_QUALITY;
|
|
68
81
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { FileSys } from "../fileSys";
|
|
4
3
|
import { hasUseClientDirective, scanUseClientExports } from "../transforms/rscUseClientTransform";
|
|
4
|
+
import { FileSys } from "../util/fileSys";
|
|
5
5
|
import { CsrDevPaths } from "./csrDevPaths";
|
|
6
6
|
|
|
7
7
|
export interface ServerGraph {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { chmod, mkdir, readdir, rm, stat, utimes, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { tempDirs } from "../testHelpers";
|
|
4
|
+
import { tempDirs } from "../test/testHelpers";
|
|
5
5
|
import { SourceMtimeIndex } from "./sourceMtimeIndex";
|
|
6
6
|
|
|
7
7
|
const seed = async (root: string, rel: string, content = "export const x = 1;\n") => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { tempDirs, writeText as write } from "../testHelpers";
|
|
3
|
+
import { tempDirs, writeText as write } from "../test/testHelpers";
|
|
4
4
|
import { SsrDevBundler } from "./ssrDevBundler";
|
|
5
5
|
|
|
6
6
|
const makeTempRoot = tempDirs("akan-ssr-dev-bundler-");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { tempDirs, writeText as write } from "../testHelpers";
|
|
3
|
+
import { tempDirs, writeText as write } from "../test/testHelpers";
|
|
4
4
|
import { VendorImportScanner } from "./vendorImportScanner";
|
|
5
5
|
|
|
6
6
|
const makeTempRoot = tempDirs("akan-vendor-imports-");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { tempDirs, writeText as write } from "../testHelpers";
|
|
4
|
+
import { tempDirs, writeText as write } from "../test/testHelpers";
|
|
5
5
|
import { ClientEntriesBundler } from "./clientEntriesBundler";
|
|
6
6
|
import { VendorNarrowing } from "./vendorNarrowing";
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
|
|
|
2
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import type { App } from "../commandDecorators";
|
|
5
|
-
import { tempDirs } from "../testHelpers";
|
|
5
|
+
import { tempDirs } from "../test/testHelpers";
|
|
6
6
|
import { WatchRootResolver } from "./watchRootResolver";
|
|
7
7
|
|
|
8
8
|
const tempRoot = tempDirs("akan-watch-roots-");
|
|
@@ -49,7 +49,7 @@ describe("AgentAssets", () => {
|
|
|
49
49
|
test("names no rule or skill file that a new workspace's .gitignore would keep out of git", async () => {
|
|
50
50
|
const assets = [...(await AgentAssets.rules()), ...(await AgentAssets.skills())];
|
|
51
51
|
const root = await fsPromise.mkdtemp(path.join(os.tmpdir(), "akan-agent-ignore-"));
|
|
52
|
-
const template = path.join(import.meta.dir, "
|
|
52
|
+
const template = path.join(import.meta.dir, "../../cli/templates/workspaceRoot/.gitignore.template");
|
|
53
53
|
await fsPromise.copyFile(template, path.join(root, ".gitignore"));
|
|
54
54
|
Bun.spawnSync(["git", "init", "-q"], { cwd: root });
|
|
55
55
|
const proc = Bun.spawn(["git", "check-ignore", "--no-index", "--stdin"], {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fsPromise from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { akanCodePaths } from "
|
|
3
|
+
import { akanCodePaths } from "../codeAgent/agent/akanCodePaths";
|
|
4
4
|
import { type ConventionRule, ConventionSet } from "./conventionSet";
|
|
5
5
|
import { Prompter } from "./prompter";
|
|
6
6
|
|
|
@@ -45,7 +45,7 @@ export class AgentAssets {
|
|
|
45
45
|
"modelUtil",
|
|
46
46
|
"framework",
|
|
47
47
|
],
|
|
48
|
-
"akan-err": [],
|
|
48
|
+
"akan-err": ["errorCodes"],
|
|
49
49
|
"akan-deps": [],
|
|
50
50
|
"akan-debug": [],
|
|
51
51
|
"akan-page": ["pageRule", "akanApi"],
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import type { RecipeInfo } from "../context/recipeScanner";
|
|
4
|
+
import { tempDirs, writeText } from "../test/testHelpers";
|
|
3
5
|
import {
|
|
4
6
|
AGENT_BLOCK_END,
|
|
5
7
|
AGENT_BLOCK_START,
|
|
@@ -11,8 +13,6 @@ import {
|
|
|
11
13
|
renderScopeClaudeMd,
|
|
12
14
|
upsertAgentBlock,
|
|
13
15
|
} from "./agentsIndex";
|
|
14
|
-
import type { RecipeInfo } from "./recipeScanner";
|
|
15
|
-
import { tempDirs, writeText } from "./testHelpers";
|
|
16
16
|
|
|
17
17
|
const button: RecipeInfo = {
|
|
18
18
|
name: "buttonRecipe",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { RecipeInfo, RecipeSource } from "
|
|
1
|
+
import type { RecipeInfo, RecipeSource } from "../context/recipeScanner";
|
|
2
2
|
|
|
3
3
|
// Lazy: recipeScanner loads `typescript` (~65MB) and this module sits in the CLI entry graph (entryModuleGraph test).
|
|
4
|
-
let recipeScannerLoad: Promise<typeof import("
|
|
5
|
-
const loadRecipeScanner = () => (recipeScannerLoad ??= import("
|
|
4
|
+
let recipeScannerLoad: Promise<typeof import("../context/recipeScanner")> | null = null;
|
|
5
|
+
const loadRecipeScanner = () => (recipeScannerLoad ??= import("../context/recipeScanner"));
|
|
6
6
|
|
|
7
7
|
//* Split by ownership (root: framework recipes; each app/lib: what it may import), so always-loaded context does not
|
|
8
8
|
//* grow with the app count and no unimportable neighbour recipe is listed.
|
|
@@ -23,13 +23,16 @@ export const extractBlockVersion = (content: string): string | null =>
|
|
|
23
23
|
/** The running `@akanjs/devkit` version; null when its package.json is unreadable, which must not fail a doctor run. */
|
|
24
24
|
export const readDevkitVersion = async (): Promise<string | null> => {
|
|
25
25
|
const { readFile } = await import("node:fs/promises");
|
|
26
|
-
const { getDirname } = await import("
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const { getDirname } = await import("../util/fileSys");
|
|
27
|
+
const dirname = getDirname(import.meta.url);
|
|
28
|
+
for (const candidate of [`${dirname}/package.json`, `${dirname}/../package.json`]) {
|
|
29
|
+
try {
|
|
30
|
+
return (JSON.parse(await readFile(candidate, "utf-8")) as { version?: string }).version ?? null;
|
|
31
|
+
} catch {
|
|
32
|
+
//? The bundled CLI sits beside its own package.json; devkit's source sits one folder below its own.
|
|
33
|
+
}
|
|
32
34
|
}
|
|
35
|
+
return null;
|
|
33
36
|
};
|
|
34
37
|
|
|
35
38
|
export interface AgentsIndexScope {
|
|
@@ -45,7 +48,7 @@ export const upsertAgentBlock = (existing: string, block: string): string => {
|
|
|
45
48
|
if (startIndex >= 0 && endIndex > startIndex) {
|
|
46
49
|
return `${existing.slice(0, startIndex)}${managed}${existing.slice(endIndex + AGENT_BLOCK_END.length)}`;
|
|
47
50
|
}
|
|
48
|
-
return `${existing.
|
|
51
|
+
return `${existing.trimEnd()}\n\n${managed}\n`;
|
|
49
52
|
};
|
|
50
53
|
|
|
51
54
|
/** The content between the akan:agent markers, or null when the file carries no managed block. */
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import fsPromise from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { MaintainabilityContract } from "../quality/maintainabilityContract";
|
|
5
|
+
import { MaintainabilityLimits } from "../quality/maintainabilityLimits";
|
|
4
6
|
import { ConventionSet } from "./conventionSet";
|
|
5
|
-
import { MaintainabilityContract } from "./maintainabilityContract";
|
|
6
7
|
import { Prompter } from "./prompter";
|
|
7
8
|
|
|
8
9
|
describe("ConventionSet", () => {
|
|
@@ -49,17 +50,19 @@ describe("ConventionSet", () => {
|
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
|
|
52
|
-
test("names only checks that exist, and names every lint plugin and maintainability gate
|
|
53
|
+
test("names only checks that exist, and names every lint plugin and maintainability gate a workspace runs", async () => {
|
|
53
54
|
const set = await Prompter.getConventionSet();
|
|
54
55
|
const named = new Set(
|
|
55
56
|
[set.core, ...set.rules.map((rule) => rule.body)].flatMap((text) =>
|
|
56
57
|
[...text.matchAll(/`([^`\s]+)`/g)].map((match) => match[1] ?? ""),
|
|
57
58
|
),
|
|
58
59
|
);
|
|
59
|
-
const plugins = (await fsPromise.readdir(path.join(import.meta.dir, "lint")))
|
|
60
|
+
const plugins = (await fsPromise.readdir(path.join(import.meta.dir, "../lint")))
|
|
60
61
|
.filter((file) => file.endsWith(".grit"))
|
|
61
62
|
.map((file) => file.slice(0, -".grit".length));
|
|
62
|
-
const gates: readonly string[] = MaintainabilityContract.ruleIds
|
|
63
|
+
const gates: readonly string[] = MaintainabilityContract.ruleIds.filter(
|
|
64
|
+
(id) => !MaintainabilityLimits.repoOnlyRules.has(id),
|
|
65
|
+
);
|
|
63
66
|
const gateAreas = new Set(gates.map((id) => id.split(".").slice(0, 2).join(".")));
|
|
64
67
|
const isPluginName = (name: string) => /^non?-[a-z]+(-[a-z]+)+$/.test(name);
|
|
65
68
|
const isGateName = (name: string) =>
|
|
@@ -29,7 +29,7 @@ export class ConventionSet {
|
|
|
29
29
|
const match: RegExpExecArray | null = /^---\n([\s\S]*?)\n---\n/.exec(text);
|
|
30
30
|
if (!match) throw new Error(`Convention rule ${name} has no frontmatter`);
|
|
31
31
|
const front = match[1] ?? "";
|
|
32
|
-
const described: RegExpExecArray | null = /^description
|
|
32
|
+
const described: RegExpExecArray | null = /^description:(.*)$/m.exec(front);
|
|
33
33
|
const description = described?.[1]?.trim() ?? "";
|
|
34
34
|
const paths = [...front.matchAll(/^\s+-\s+"([^"]+)"$/gm)].map((entry) => entry[1] ?? "");
|
|
35
35
|
if (!description || paths.length === 0) throw new Error(`Convention rule ${name} needs a description and paths`);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import fsPromise from "node:fs/promises";
|
|
2
2
|
import { input, select } from "@inquirer/prompts";
|
|
3
|
-
|
|
3
|
+
import { getDirname } from "../util/fileSys";
|
|
4
4
|
import { ConventionSet } from "./conventionSet";
|
|
5
|
-
import { getDirname } from "./fileSys";
|
|
6
5
|
|
|
7
6
|
interface FileUpdateRequestProps {
|
|
8
7
|
context: string;
|
|
@@ -11,7 +10,7 @@ interface FileUpdateRequestProps {
|
|
|
11
10
|
export class Prompter {
|
|
12
11
|
static async #getGuidelineRoot() {
|
|
13
12
|
const dirname = getDirname(import.meta.url);
|
|
14
|
-
const candidates = [`${dirname}/guidelines`, `${dirname}
|
|
13
|
+
const candidates = [`${dirname}/guidelines`, `${dirname}/../../cli/guidelines`];
|
|
15
14
|
for (const candidate of candidates) {
|
|
16
15
|
try {
|
|
17
16
|
await fsPromise.access(candidate);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { ApplicationBuildReporter } from "@akanjs/devkit/applicationBuildReporter";
|
|
2
|
+
import { ApplicationBuildReporter } from "@akanjs/devkit/app/applicationBuildReporter";
|
|
3
3
|
import { resolveSsrPageEntriesForApp } from "@akanjs/devkit/artifact/implicitRootLayout";
|
|
4
4
|
import { computeRouteSeedIndex, saveRouteSeedIndex } from "@akanjs/devkit/artifact/routeSeedIndex";
|
|
5
5
|
import type { App } from "@akanjs/devkit/commandDecorators";
|
|
@@ -47,7 +47,7 @@ class BuildBatch {
|
|
|
47
47
|
return this.#result;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
// A bare `process.send` is safe only because
|
|
50
|
+
// A bare `process.send` is safe only because `main` exits once the runner has read the result sent after it;
|
|
51
51
|
// an explicit `process.exit` after an emit would silently drop payloads (route through BuilderChannel then).
|
|
52
52
|
#emit(message: BuilderMessage): void {
|
|
53
53
|
process.send?.(message);
|
|
@@ -294,6 +294,16 @@ class BuildBatch {
|
|
|
294
294
|
});
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
// Bounded, so a runner that never releases this process cannot keep the bundler arenas alive.
|
|
298
|
+
static #report(result: BuildBatchResult): Promise<void> {
|
|
299
|
+
if (!process.send) return Promise.resolve();
|
|
300
|
+
return new Promise((resolve) => {
|
|
301
|
+
process.once("disconnect", () => resolve());
|
|
302
|
+
process.send?.({ type: "build-batch-result", data: result });
|
|
303
|
+
setTimeout(() => process.disconnect?.(), 5_000).unref();
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
297
307
|
static async main(): Promise<void> {
|
|
298
308
|
const raw = process.argv[2];
|
|
299
309
|
if (!raw) throw new Error("[build-batch] missing request argument");
|
|
@@ -312,12 +322,12 @@ class BuildBatch {
|
|
|
312
322
|
// Seeded, not rediscovered: route discovery would be the largest cost of spawning this process.
|
|
313
323
|
if (request.pageKeys) app.setPageKeys(request.pageKeys);
|
|
314
324
|
//? Exits with the builder that spawned it (a kill, a crash, a restart for a metadata save): left running, it would
|
|
315
|
-
//? write a registry its replacement is rebuilding. Removed before
|
|
325
|
+
//? write a registry its replacement is rebuilding. Removed before reporting, as the runner's release is a disconnect.
|
|
316
326
|
const orphaned = () => process.exit(1);
|
|
317
327
|
process.on("disconnect", orphaned);
|
|
318
328
|
const result = await new BuildBatch(request, app).run();
|
|
319
|
-
process.send?.({ type: "build-batch-result", data: result });
|
|
320
329
|
process.off("disconnect", orphaned);
|
|
330
|
+
await BuildBatch.#report(result);
|
|
321
331
|
}
|
|
322
332
|
}
|
|
323
333
|
|
|
@@ -22,6 +22,8 @@ export interface BuildBatchRequest {
|
|
|
22
22
|
trace?: HmrTrace;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export type BatchWork = Pick<BuildBatchRequest, "generation" | "needs" | "changedFiles" | "trace">;
|
|
26
|
+
|
|
25
27
|
export type PagesBatchCssAssets = CssPayload["cssAssets"];
|
|
26
28
|
|
|
27
29
|
// Browser payloads stream as each need finishes; only state the next batch needs travels back here.
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { rm } from "node:fs/promises";
|
|
2
4
|
import path from "node:path";
|
|
3
|
-
import { createTempApp, tempRoots, writeText } from "../testHelpers";
|
|
5
|
+
import { createTempApp, tempRoots, writeText } from "../test/testHelpers";
|
|
6
|
+
import type { BuildBatchMessage, BuildBatchRequest, BuildBatchResult } from "./buildBatchProtocol";
|
|
4
7
|
import { BuildBatchRunner } from "./buildBatchRunner";
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
//? `run` returns on the result while the released worker may live on in its cwd, which Windows refuses to delete, and
|
|
10
|
+
//? Bun's `rm` ignores `maxRetries` there.
|
|
11
|
+
const removeOnceReleased = async (root: string) => {
|
|
12
|
+
for (let attempt = 1; ; attempt++) {
|
|
13
|
+
try {
|
|
14
|
+
return await rm(root, { recursive: true, force: true });
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if ((error as NodeJS.ErrnoException).code !== "EBUSY" || attempt >= 30) throw error;
|
|
17
|
+
await Bun.sleep(100);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const track = tempRoots(removeOnceReleased);
|
|
22
|
+
const isAlive = (pid: number) => {
|
|
23
|
+
try {
|
|
24
|
+
process.kill(pid, 0);
|
|
25
|
+
return true;
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
7
30
|
|
|
8
31
|
describe("BuildBatchRunner", () => {
|
|
9
32
|
test("reports a boot build the bundler refuses with where each reason sits in the workspace", async () => {
|
|
@@ -62,4 +85,101 @@ setTimeout(() => process.exit(1), 50);
|
|
|
62
85
|
expect(result.errors.css).toBe("css broke");
|
|
63
86
|
expect(result.errors.pages).toContain("exited with code 1");
|
|
64
87
|
}, 30_000);
|
|
88
|
+
|
|
89
|
+
test("releases a worker as soon as its result arrives, so one that holds its exit for that is not left waiting", async () => {
|
|
90
|
+
const { root } = track(await createTempApp("demo"));
|
|
91
|
+
const appDir = path.join(root, "apps/demo");
|
|
92
|
+
const released = path.join(root, "released");
|
|
93
|
+
await writeText(
|
|
94
|
+
path.join(root, "pkgs/@akanjs/devkit/incrementalBuilder/buildBatch.proc.ts"),
|
|
95
|
+
`import fs from "node:fs";
|
|
96
|
+
const { generation } = JSON.parse(process.argv[2]);
|
|
97
|
+
process.once("disconnect", () => fs.writeFileSync(${JSON.stringify(released)}, ""));
|
|
98
|
+
process.send({ type: "build-batch-result", data: { generation, errors: {} } });
|
|
99
|
+
setTimeout(() => process.exit(1), 2_000).unref();
|
|
100
|
+
`,
|
|
101
|
+
);
|
|
102
|
+
const result = await new BuildBatchRunner({ workspaceRoot: root, cwd: appDir }).run({
|
|
103
|
+
appName: "demo",
|
|
104
|
+
workspaceRoot: root,
|
|
105
|
+
repoName: "repo",
|
|
106
|
+
generation: 3,
|
|
107
|
+
needs: ["pages"],
|
|
108
|
+
changedFiles: [],
|
|
109
|
+
pageKeys: null,
|
|
110
|
+
optimizedFonts: null,
|
|
111
|
+
cssAssets: null,
|
|
112
|
+
artifactDir: path.join(appDir, ".akan/artifact"),
|
|
113
|
+
});
|
|
114
|
+
expect(result).toEqual({ generation: 3, errors: {} });
|
|
115
|
+
const deadline = Date.now() + 1_500;
|
|
116
|
+
while (!(await Bun.file(released).exists()) && Date.now() < deadline) await Bun.sleep(20);
|
|
117
|
+
expect(await Bun.file(released).exists()).toBe(true);
|
|
118
|
+
}, 30_000);
|
|
119
|
+
|
|
120
|
+
test("returns a result as it arrives from a worker the release never reaches, then kills that worker", async () => {
|
|
121
|
+
const { root } = track(await createTempApp("demo"));
|
|
122
|
+
const appDir = path.join(root, "apps/demo");
|
|
123
|
+
const sent = path.join(root, "sent");
|
|
124
|
+
await writeText(
|
|
125
|
+
path.join(root, "pkgs/@akanjs/devkit/incrementalBuilder/buildBatch.proc.ts"),
|
|
126
|
+
`import fs from "node:fs";
|
|
127
|
+
const { generation } = JSON.parse(process.argv[2]);
|
|
128
|
+
fs.writeFileSync(${JSON.stringify(sent)}, String(process.pid));
|
|
129
|
+
process.send({ type: "build-batch-result", data: { generation, errors: {} } });
|
|
130
|
+
setTimeout(() => process.exit(0), 5_000);
|
|
131
|
+
`,
|
|
132
|
+
);
|
|
133
|
+
const result = await new BuildBatchRunner({ workspaceRoot: root, cwd: appDir }).run({
|
|
134
|
+
appName: "demo",
|
|
135
|
+
workspaceRoot: root,
|
|
136
|
+
repoName: "repo",
|
|
137
|
+
generation: 5,
|
|
138
|
+
needs: ["pages"],
|
|
139
|
+
changedFiles: [],
|
|
140
|
+
pageKeys: null,
|
|
141
|
+
optimizedFonts: null,
|
|
142
|
+
cssAssets: null,
|
|
143
|
+
artifactDir: path.join(appDir, ".akan/artifact"),
|
|
144
|
+
});
|
|
145
|
+
//? Read before any await: the kill timer cannot fire until this turn's microtasks are done.
|
|
146
|
+
const pid = Number(readFileSync(sent, "utf8"));
|
|
147
|
+
const upAtReturn = isAlive(pid);
|
|
148
|
+
expect(result).toEqual({ generation: 5, errors: {} });
|
|
149
|
+
expect(upAtReturn).toBe(true);
|
|
150
|
+
const deadline = Date.now() + 3_000;
|
|
151
|
+
while (isAlive(pid) && Date.now() < deadline) await Bun.sleep(20);
|
|
152
|
+
expect(isAlive(pid)).toBe(false);
|
|
153
|
+
}, 30_000);
|
|
154
|
+
|
|
155
|
+
test("the build worker stays up after reporting its result until its runner releases it", async () => {
|
|
156
|
+
const { root } = track(await createTempApp("demo", path.join(import.meta.dir, "..", "local")));
|
|
157
|
+
const appDir = path.join(root, "apps/demo");
|
|
158
|
+
const request = {
|
|
159
|
+
appName: "demo",
|
|
160
|
+
workspaceRoot: root,
|
|
161
|
+
repoName: "repo",
|
|
162
|
+
generation: 4,
|
|
163
|
+
needs: [],
|
|
164
|
+
changedFiles: [],
|
|
165
|
+
pageKeys: [],
|
|
166
|
+
optimizedFonts: null,
|
|
167
|
+
cssAssets: null,
|
|
168
|
+
artifactDir: path.join(appDir, ".akan/artifact"),
|
|
169
|
+
} satisfies BuildBatchRequest;
|
|
170
|
+
const { promise: reported, resolve: report } = Promise.withResolvers<BuildBatchResult>();
|
|
171
|
+
const worker = Bun.spawn(["bun", path.join(import.meta.dir, "buildBatch.proc.ts"), JSON.stringify(request)], {
|
|
172
|
+
cwd: appDir,
|
|
173
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
174
|
+
serialization: "advanced",
|
|
175
|
+
ipc: (message: BuildBatchMessage) => {
|
|
176
|
+
if (message.type === "build-batch-result") report(message.data);
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
expect(await reported).toEqual({ generation: 4, errors: {} });
|
|
180
|
+
const unreleased = await Promise.race([worker.exited.then(() => "exited"), Bun.sleep(300).then(() => "running")]);
|
|
181
|
+
worker.disconnect();
|
|
182
|
+
expect(unreleased).toBe("running");
|
|
183
|
+
expect(await worker.exited).toBe(0);
|
|
184
|
+
}, 30_000);
|
|
65
185
|
});
|
|
@@ -7,6 +7,7 @@ import type { BuildBatchMessage, BuildBatchRequest, BuildBatchResult } from "./b
|
|
|
7
7
|
// their own work (the slow lane, the css queue, the SSR registry's boot build beside them), so a few can overlap.
|
|
8
8
|
// A worker that dies without reporting must not take the watcher down; its needs come back as errors.
|
|
9
9
|
export class BuildBatchRunner {
|
|
10
|
+
static readonly #exitGraceMs = 500;
|
|
10
11
|
#logger = new Logger("BuildBatchRunner");
|
|
11
12
|
#entry: string | null = null;
|
|
12
13
|
#workspaceRoot: string;
|
|
@@ -39,6 +40,7 @@ export class BuildBatchRunner {
|
|
|
39
40
|
const started = Date.now();
|
|
40
41
|
const entry = await this.#resolveEntry();
|
|
41
42
|
let result: BuildBatchResult | null = null;
|
|
43
|
+
const resultArrived = Promise.withResolvers<null>();
|
|
42
44
|
const reported = new Map<string, string | undefined>();
|
|
43
45
|
const payload = request.trace ? { ...request, trace: { ...request.trace, spawnAt: Date.now() } } : request;
|
|
44
46
|
// argv rather than IPC, so the worker starts on its first tick instead of waiting for a handshake.
|
|
@@ -47,16 +49,27 @@ export class BuildBatchRunner {
|
|
|
47
49
|
env: process.env,
|
|
48
50
|
stdio: ["ignore", "inherit", "inherit"],
|
|
49
51
|
serialization: "advanced",
|
|
50
|
-
ipc: (message: BuildBatchMessage | BuilderMessage) => {
|
|
52
|
+
ipc: (message: BuildBatchMessage | BuilderMessage, worker) => {
|
|
51
53
|
if (!message || typeof message !== "object") return;
|
|
52
|
-
if (message.type === "build-batch-result")
|
|
53
|
-
|
|
54
|
+
if (message.type === "build-batch-result") {
|
|
55
|
+
result = message.data;
|
|
56
|
+
// On Bun 1.4 a worker that exits within ms of spawning can lose everything it sent: it exits on this release.
|
|
57
|
+
worker.disconnect();
|
|
58
|
+
//? Bun on Windows may never deliver that release; the worker would hold its arenas for its own 5 s bound.
|
|
59
|
+
const lingering = setTimeout(() => {
|
|
60
|
+
this.#logger.verbose(`[build-batch] worker still up ${BuildBatchRunner.#exitGraceMs}ms after its result`);
|
|
61
|
+
worker.kill("SIGKILL");
|
|
62
|
+
}, BuildBatchRunner.#exitGraceMs);
|
|
63
|
+
void worker.exited.then(() => clearTimeout(lingering));
|
|
64
|
+
resultArrived.resolve(null);
|
|
65
|
+
} else {
|
|
54
66
|
if (message.type === "build-status") reported.set(message.data.phase, message.data.message);
|
|
55
67
|
onMessage(message);
|
|
56
68
|
}
|
|
57
69
|
},
|
|
58
70
|
});
|
|
59
|
-
|
|
71
|
+
//? On the result, not the exit: a worker the release never reaches would make each batch wait for the kill.
|
|
72
|
+
const exitCode = await Promise.race([proc.exited, resultArrived.promise]);
|
|
60
73
|
if (result) {
|
|
61
74
|
this.#logger.verbose(
|
|
62
75
|
`[build-batch] generation=${request.generation} needs=${request.needs.join(",")} done in ${Date.now() - started}ms`,
|