@akanjs/devkit 3.2.0-rc.2 → 3.2.0-rc.20
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 +315 -11
- 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 +257 -1
- package/akanApp/akanApp.host.ts +146 -1223
- 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/devHostPolicy.test.ts +11 -11
- package/akanApp/devHostPolicy.ts +2 -4
- 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 +24 -1
- package/akanConfig/akanConfig.ts +10 -10
- package/akanConfig/akanWorkspaceConfig.ts +1 -1
- package/akanConfig/productionLockfile.ts +1 -1
- package/apiReport/apiDeclarationPrinter.ts +120 -0
- package/apiReport/apiReport.test.ts +526 -0
- package/apiReport/apiReport.ts +232 -0
- package/apiReport/apiReportDiff.ts +160 -0
- package/apiReport/apiReportPolicy.ts +65 -0
- package/apiReport/apiTargets.ts +311 -0
- package/apiReport/changesetBump.ts +19 -0
- package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +21 -0
- package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +10 -49
- package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +74 -7
- package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +20 -15
- package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
- package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +48 -12
- package/{routeJsBudget.ts → app/routeJsBudget.ts} +90 -27
- 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 +21 -4
- 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/akanCodePaths.ts +1 -1
- package/codeAgent/agent/akanSystemPrompt.ts +1 -1
- package/codeAgent/agent/codeAgent.test.ts +1 -1
- package/codeAgent/skills/akan-debug/SKILL.md +10 -3
- package/codeAgent/skills/akan-err/SKILL.md +7 -0
- package/codeAgent/skills/akan-mcp/SKILL.md +10 -1
- package/codeAgent/skills/akan-scaffold/SKILL.md +2 -2
- package/codeAgent/skills/akan-transport/SKILL.md +2 -0
- package/codeAgent/skills/akan-validate/SKILL.md +1 -0
- package/codeAgent/tools/AkanCli.ts +1 -1
- package/codeAgent/tools/AkanToolPack.ts +1 -1
- package/codeAgent/tools/McpClient.ts +28 -6
- package/codeAgent/tools/McpToolPack.ts +1 -1
- package/codeAgent/tools/akanCodePlugins.test.ts +14 -2
- package/commandDecorators/argMeta.ts +4 -0
- package/commandDecorators/cliError.ts +72 -0
- package/commandDecorators/command.ts +165 -91
- package/commandDecorators/commandBuilder.ts +1 -1
- package/commandDecorators/commandDecorators.test.ts +191 -16
- package/commandDecorators/exitCodeError.ts +6 -7
- package/commandDecorators/index.ts +1 -0
- package/commandDecorators/targetMeta.ts +1 -0
- package/commandDecorators/workspaceVersionCheck.test.ts +1 -1
- package/commandDecorators/workspaceVersionCheck.ts +1 -1
- 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} +33 -263
- package/context/akanMcpToolError.ts +16 -0
- 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 +39 -0
- package/context/doctor/recipeIndexCheck.ts +87 -0
- package/context/doctor/rootShapeCheck.ts +55 -0
- package/context/doctor/workflowScope.ts +97 -0
- package/{constantFieldNames.test.ts → context/moduleFieldNames.test.ts} +24 -2
- package/context/moduleFieldNames.ts +25 -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 +17 -5
- package/frontendBuild/allRoutesBuilder.ts +24 -6
- package/frontendBuild/autoImportSync.test.ts +1 -1
- package/frontendBuild/autoImportSync.ts +1 -1
- package/frontendBuild/buildRouteClient.test.ts +1 -1
- package/frontendBuild/bundleDefine.ts +2 -0
- package/frontendBuild/clientBuildTypes.ts +5 -2
- package/frontendBuild/clientEntriesBundler.test.ts +1 -1
- package/frontendBuild/clientEntryDiscovery.test.ts +58 -0
- package/frontendBuild/clientEntryDiscovery.ts +25 -6
- package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
- package/frontendBuild/csrDevArtifactWriter.ts +1 -1
- package/frontendBuild/cssCompiler.test.ts +1 -1
- 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 +148 -0
- 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 +1 -1
- package/frontendBuild/serverGraphFile.ts +1 -1
- package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
- package/frontendBuild/ssrBaseArtifactBuilder.test.ts +26 -0
- package/frontendBuild/ssrBaseArtifactBuilder.ts +23 -19
- package/frontendBuild/ssrDevBundler.test.ts +1 -1
- package/frontendBuild/vendorImportScanner.test.ts +25 -4
- package/frontendBuild/vendorImportScanner.ts +25 -10
- 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 +108 -1
- 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.host.test.ts +30 -1
- package/incrementalBuilder/incrementalBuilder.host.ts +10 -22
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +93 -2
- package/incrementalBuilder/incrementalBuilder.proc.ts +81 -823
- package/incrementalBuilder/ssrRegistry.ts +278 -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/lint/no-web-only-api-outside-webkit.grit +3 -3
- 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 +167 -3
- 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/PlatformTestRun.test.ts +1 -1
- package/platformTest/TestSnapshot.test.ts +1 -1
- package/preview/PreviewView.ts +32 -11
- package/preview/previewView.test.ts +76 -9
- 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} +1 -1
- package/{qualityScanner.ts → quality/qualityScanner.ts} +8 -8
- package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
- package/{subspace.test.ts → subspace/subspace.test.ts} +9 -3
- 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 +26 -8
- 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 +29 -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 +1 -1
- package/typecheck/projectTypecheck.ts +6 -2
- package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
- package/{typeChecker.ts → typecheck/typeChecker.ts} +1 -1
- package/typecheck/typecheck.proc.ts +4 -3
- package/typecheck/typecheckFailure.ts +7 -2
- package/util/errorReport.ts +66 -0
- package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
- package/workflow/artifacts.ts +8 -7
- 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 +93 -0
- package/workflow/guardCatalog.test.ts +1 -1
- package/workflow/index.ts +2 -0
- 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/plainName.ts +28 -0
- package/workflow/plan.ts +15 -9
- 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 -1105
- 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} +85 -1
- package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +41 -6
- package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
- package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
- package/akanContext.ts +0 -1084
- package/constantFieldNames.ts +0 -18
- package/executors.ts +0 -1749
- /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
|
@@ -14,7 +14,12 @@ const slowChromeRuns = PreviewView.isAvailable("chrome") && process.platform !==
|
|
|
14
14
|
const withSlowChrome = async (body: string, startSeconds = 3) => {
|
|
15
15
|
const dir = await mkdtemp(path.join(tmpdir(), "akan-slow-chrome-"));
|
|
16
16
|
const chrome = path.join(dir, "chrome");
|
|
17
|
-
|
|
17
|
+
const chromeLog = path.join(dir, "chrome.log");
|
|
18
|
+
//? Bun.WebView sends the browser's stderr to /dev/null, which would hide why it died.
|
|
19
|
+
await writeFile(
|
|
20
|
+
chrome,
|
|
21
|
+
`#!/bin/sh\nexec 2>>"${chromeLog}"\nsleep ${startSeconds}\nexec "${PreviewChrome.executable()}" "$@"\n`,
|
|
22
|
+
);
|
|
18
23
|
await chmod(chrome, 0o755);
|
|
19
24
|
const script = `const { PreviewView } = await import(${JSON.stringify(path.join(import.meta.dir, "PreviewView.ts"))});\n${body}`;
|
|
20
25
|
//? Chrome is spawned once per process, so only a fresh process takes the slow executable.
|
|
@@ -30,7 +35,10 @@ const withSlowChrome = async (body: string, startSeconds = 3) => {
|
|
|
30
35
|
new Response(child.stderr).text(),
|
|
31
36
|
child.exited,
|
|
32
37
|
]);
|
|
33
|
-
|
|
38
|
+
const chromeErr = await Bun.file(chromeLog)
|
|
39
|
+
.text()
|
|
40
|
+
.catch(() => "");
|
|
41
|
+
return { code, out: out.trim(), log: `${err}\nChrome's stderr:\n${chromeErr}` };
|
|
34
42
|
} finally {
|
|
35
43
|
child.kill();
|
|
36
44
|
await rm(dir, { recursive: true, force: true });
|
|
@@ -112,12 +120,12 @@ describe("PreviewView", () => {
|
|
|
112
120
|
async () => {
|
|
113
121
|
const server = serve("<!doctype html><title>Up</title><body>up</body>");
|
|
114
122
|
try {
|
|
115
|
-
const { code, out,
|
|
123
|
+
const { code, out, log } = await withSlowChrome(
|
|
116
124
|
`const probe = await PreviewView.probe("http://localhost:${server.port}/", { engine: "chrome", timeoutMs: 1_500 });
|
|
117
125
|
console.log(probe.text);`,
|
|
118
126
|
);
|
|
119
|
-
expect(out
|
|
120
|
-
expect(code).toBe(0);
|
|
127
|
+
expect(out, log).toBe("up");
|
|
128
|
+
expect(code, log).toBe(0);
|
|
121
129
|
} finally {
|
|
122
130
|
server.stop(true);
|
|
123
131
|
}
|
|
@@ -128,7 +136,7 @@ console.log(probe.text);`,
|
|
|
128
136
|
test.skipIf(!slowChromeRuns)(
|
|
129
137
|
"gives a later page only its own bound for a browser that missed its start, and recovers once it is up",
|
|
130
138
|
async () => {
|
|
131
|
-
const { code, out,
|
|
139
|
+
const { code, out, log } = await withSlowChrome(
|
|
132
140
|
`const open = () =>
|
|
133
141
|
PreviewView.probe("about:blank", { engine: "chrome", startTimeoutMs: 1_500, timeoutMs: 1_000 }).then(
|
|
134
142
|
() => "opened",
|
|
@@ -137,7 +145,7 @@ console.log(probe.text);`,
|
|
|
137
145
|
console.log(await open());
|
|
138
146
|
console.log(await open());
|
|
139
147
|
let late = await open();
|
|
140
|
-
for (let tries = 0; late
|
|
148
|
+
for (let tries = 0; late.startsWith("Timed out starting") && tries < 100; tries++) late = await open();
|
|
141
149
|
console.log(late);
|
|
142
150
|
Bun.WebView.closeAll();
|
|
143
151
|
await Bun.sleep(500);
|
|
@@ -145,7 +153,7 @@ console.log(await open());
|
|
|
145
153
|
Bun.WebView.closeAll();`,
|
|
146
154
|
6,
|
|
147
155
|
);
|
|
148
|
-
expect(out
|
|
156
|
+
expect(out, log).toBe(
|
|
149
157
|
[
|
|
150
158
|
"Timed out starting the chrome browser after 1.5 s.",
|
|
151
159
|
"Timed out starting the chrome browser after 1 s.",
|
|
@@ -153,7 +161,66 @@ Bun.WebView.closeAll();`,
|
|
|
153
161
|
"Timed out starting the chrome browser after 1.5 s.",
|
|
154
162
|
].join("\n"),
|
|
155
163
|
);
|
|
156
|
-
expect(code).toBe(0);
|
|
164
|
+
expect(code, log).toBe(0);
|
|
165
|
+
},
|
|
166
|
+
browserTestMs,
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
test.skipIf(!slowChromeRuns)(
|
|
170
|
+
"gives a browser killed after it missed its start the full bound for its next start",
|
|
171
|
+
async () => {
|
|
172
|
+
const { code, out, log } = await withSlowChrome(
|
|
173
|
+
`const open = () =>
|
|
174
|
+
PreviewView.probe("about:blank", { engine: "chrome", startTimeoutMs: 1_500, timeoutMs: 1_000 }).then(
|
|
175
|
+
() => "opened",
|
|
176
|
+
(error) => error.message,
|
|
177
|
+
);
|
|
178
|
+
console.log(await open());
|
|
179
|
+
const killed = open();
|
|
180
|
+
Bun.WebView.closeAll();
|
|
181
|
+
console.log(await killed);
|
|
182
|
+
Bun.WebView.closeAll();`,
|
|
183
|
+
6,
|
|
184
|
+
);
|
|
185
|
+
expect(out, log).toBe(
|
|
186
|
+
[
|
|
187
|
+
"Timed out starting the chrome browser after 1.5 s.",
|
|
188
|
+
"Timed out starting the chrome browser after 1.5 s.",
|
|
189
|
+
].join("\n"),
|
|
190
|
+
);
|
|
191
|
+
expect(code, log).toBe(0);
|
|
192
|
+
},
|
|
193
|
+
browserTestMs,
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
test.skipIf(!slowChromeRuns)(
|
|
197
|
+
"starts a new browser for the page right after one that the browser died on",
|
|
198
|
+
async () => {
|
|
199
|
+
const { code, out, log } = await withSlowChrome(
|
|
200
|
+
`const { promise: loading, resolve } = Promise.withResolvers();
|
|
201
|
+
const server = Bun.serve({
|
|
202
|
+
port: 0,
|
|
203
|
+
fetch: (req) =>
|
|
204
|
+
new URL(req.url).pathname === "/hang"
|
|
205
|
+
? (resolve(), new Promise(() => undefined))
|
|
206
|
+
: new Response("<!doctype html><body>up</body>", { headers: { "content-type": "text/html" } }),
|
|
207
|
+
});
|
|
208
|
+
const open = (path) =>
|
|
209
|
+
PreviewView.probe(\`http://localhost:\${server.port}\${path}\`, { engine: "chrome" }).then(
|
|
210
|
+
(probe) => probe.text,
|
|
211
|
+
(error) => error.message,
|
|
212
|
+
);
|
|
213
|
+
const killed = open("/hang");
|
|
214
|
+
await loading;
|
|
215
|
+
Bun.WebView.closeAll();
|
|
216
|
+
console.error(await killed);
|
|
217
|
+
console.log(await open("/"));
|
|
218
|
+
server.stop(true);
|
|
219
|
+
Bun.WebView.closeAll();`,
|
|
220
|
+
0,
|
|
221
|
+
);
|
|
222
|
+
expect(out, log).toBe("up");
|
|
223
|
+
expect(code, log).toBe(0);
|
|
157
224
|
},
|
|
158
225
|
browserTestMs,
|
|
159
226
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { AppExecutor, WorkspaceExecutor } from "../executors";
|
|
4
|
+
import { tempDirs, writeText } from "../test/testHelpers";
|
|
3
5
|
import { AbstractDoc } from "./abstractDoc";
|
|
4
|
-
import { AppExecutor, WorkspaceExecutor } from "./executors";
|
|
5
|
-
import { tempDirs, writeText } from "./testHelpers";
|
|
6
6
|
|
|
7
7
|
const makeTempRoot = tempDirs("akan-abstract-doc-");
|
|
8
8
|
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
export class BareErrorScanner {
|
|
4
|
+
static readonly #builtins: ReadonlySet<string> = new Set([
|
|
5
|
+
"Error",
|
|
6
|
+
"TypeError",
|
|
7
|
+
"RangeError",
|
|
8
|
+
"SyntaxError",
|
|
9
|
+
"ReferenceError",
|
|
10
|
+
"EvalError",
|
|
11
|
+
"URIError",
|
|
12
|
+
"AggregateError",
|
|
13
|
+
]);
|
|
14
|
+
static readonly #globals: ReadonlySet<string> = new Set(["globalThis", "window", "self"]);
|
|
15
|
+
//? Without the lib and imports, a name the binder resolves is one this file declares, and an unresolved one is global.
|
|
16
|
+
static readonly #options: ts.CompilerOptions = { noLib: true, noResolve: true, noEmit: true, types: [] };
|
|
17
|
+
|
|
18
|
+
lines(sourceFile: ts.SourceFile): number[] {
|
|
19
|
+
const declared = BareErrorScanner.#declaredNamesOf(sourceFile);
|
|
20
|
+
const shadows = [...BareErrorScanner.#builtins, ...BareErrorScanner.#globals].some((name) => declared.has(name));
|
|
21
|
+
if (!shadows) return BareErrorScanner.#scan(sourceFile, () => true);
|
|
22
|
+
const rootName = sourceFile.fileName.endsWith(".tsx") ? "/scan.tsx" : "/scan.ts";
|
|
23
|
+
const scope = ts.createSourceFile(
|
|
24
|
+
rootName,
|
|
25
|
+
sourceFile.text,
|
|
26
|
+
ts.ScriptTarget.Latest,
|
|
27
|
+
true,
|
|
28
|
+
rootName.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS,
|
|
29
|
+
);
|
|
30
|
+
const checker = ts
|
|
31
|
+
.createProgram({
|
|
32
|
+
rootNames: [rootName],
|
|
33
|
+
options: BareErrorScanner.#options,
|
|
34
|
+
host: BareErrorScanner.#hostOf(scope),
|
|
35
|
+
})
|
|
36
|
+
.getTypeChecker();
|
|
37
|
+
return BareErrorScanner.#scan(
|
|
38
|
+
scope,
|
|
39
|
+
(identifier) =>
|
|
40
|
+
!checker
|
|
41
|
+
.getSymbolAtLocation(identifier)
|
|
42
|
+
?.declarations?.some((declaration) => declaration.getSourceFile() === scope),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static #scan(sourceFile: ts.SourceFile, isGlobal: (identifier: ts.Identifier) => boolean) {
|
|
47
|
+
const lines: number[] = [];
|
|
48
|
+
const visit = (node: ts.Node) => {
|
|
49
|
+
const constructed = ts.isNewExpression(node) || ts.isCallExpression(node) ? node.expression : null;
|
|
50
|
+
const extended =
|
|
51
|
+
ts.isClassDeclaration(node) || ts.isClassExpression(node)
|
|
52
|
+
? node.heritageClauses?.find((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword)?.types[0]?.expression
|
|
53
|
+
: null;
|
|
54
|
+
const target = constructed ?? extended;
|
|
55
|
+
if (target && BareErrorScanner.#namesBuiltin(target, isGlobal))
|
|
56
|
+
lines.push(sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1);
|
|
57
|
+
ts.forEachChild(node, visit);
|
|
58
|
+
};
|
|
59
|
+
ts.forEachChild(sourceFile, visit);
|
|
60
|
+
return lines;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static #declaredNamesOf(sourceFile: ts.SourceFile) {
|
|
64
|
+
const names = new Set<string>();
|
|
65
|
+
const visit = (node: ts.Node) => {
|
|
66
|
+
if (ts.isIdentifier(node) && BareErrorScanner.#declares(node.parent, node)) names.add(node.text);
|
|
67
|
+
ts.forEachChild(node, visit);
|
|
68
|
+
};
|
|
69
|
+
ts.forEachChild(sourceFile, visit);
|
|
70
|
+
return names;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static #declares(parent: ts.Node, identifier: ts.Identifier) {
|
|
74
|
+
return (
|
|
75
|
+
(ts.isVariableDeclaration(parent) ||
|
|
76
|
+
ts.isParameter(parent) ||
|
|
77
|
+
ts.isBindingElement(parent) ||
|
|
78
|
+
ts.isFunctionDeclaration(parent) ||
|
|
79
|
+
ts.isFunctionExpression(parent) ||
|
|
80
|
+
ts.isClassDeclaration(parent) ||
|
|
81
|
+
ts.isClassExpression(parent) ||
|
|
82
|
+
ts.isImportSpecifier(parent) ||
|
|
83
|
+
ts.isImportClause(parent) ||
|
|
84
|
+
ts.isNamespaceImport(parent) ||
|
|
85
|
+
ts.isImportEqualsDeclaration(parent) ||
|
|
86
|
+
ts.isEnumDeclaration(parent) ||
|
|
87
|
+
ts.isModuleDeclaration(parent)) &&
|
|
88
|
+
parent.name === identifier
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static #namesBuiltin(expression: ts.Expression, isGlobal: (identifier: ts.Identifier) => boolean) {
|
|
93
|
+
const callee = BareErrorScanner.#unwrapped(expression);
|
|
94
|
+
if (ts.isIdentifier(callee)) return BareErrorScanner.#builtins.has(callee.text) && isGlobal(callee);
|
|
95
|
+
if (!ts.isPropertyAccessExpression(callee) || !BareErrorScanner.#builtins.has(callee.name.text)) return false;
|
|
96
|
+
const owner = BareErrorScanner.#unwrapped(callee.expression);
|
|
97
|
+
return ts.isIdentifier(owner) && BareErrorScanner.#globals.has(owner.text) && isGlobal(owner);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static #unwrapped(expression: ts.Expression) {
|
|
101
|
+
let current = expression;
|
|
102
|
+
while (
|
|
103
|
+
ts.isParenthesizedExpression(current) ||
|
|
104
|
+
ts.isAsExpression(current) ||
|
|
105
|
+
ts.isSatisfiesExpression(current) ||
|
|
106
|
+
ts.isNonNullExpression(current) ||
|
|
107
|
+
ts.isTypeAssertionExpression(current)
|
|
108
|
+
)
|
|
109
|
+
current = current.expression;
|
|
110
|
+
return current;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static #hostOf(scope: ts.SourceFile): ts.CompilerHost {
|
|
114
|
+
return {
|
|
115
|
+
getSourceFile: (fileName) => (fileName === scope.fileName ? scope : undefined),
|
|
116
|
+
writeFile: () => undefined,
|
|
117
|
+
getDefaultLibFileName: () => "/lib.d.ts",
|
|
118
|
+
useCaseSensitiveFileNames: () => true,
|
|
119
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
120
|
+
getCurrentDirectory: () => "/",
|
|
121
|
+
getNewLine: () => "\n",
|
|
122
|
+
fileExists: (fileName) => fileName === scope.fileName,
|
|
123
|
+
readFile: () => undefined,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -39,6 +39,14 @@ const placementOf = (file: string, writes: string[]): MaintainabilityViolation =
|
|
|
39
39
|
line: 1,
|
|
40
40
|
writes,
|
|
41
41
|
});
|
|
42
|
+
const bareOf = (file: string, count: number): MaintainabilityViolation => ({
|
|
43
|
+
kind: "bareError",
|
|
44
|
+
rule: "akan.error.bare-error",
|
|
45
|
+
key: file,
|
|
46
|
+
file,
|
|
47
|
+
line: 1,
|
|
48
|
+
lines: Array.from({ length: count }, (_, idx) => idx + 1),
|
|
49
|
+
});
|
|
42
50
|
const baselineOf = (
|
|
43
51
|
sections: { [rule in DebtRuleId]?: Record<string, number> },
|
|
44
52
|
reasons: Record<string, string> = {},
|
|
@@ -217,6 +225,71 @@ describe("MaintainabilityBaseline", () => {
|
|
|
217
225
|
expect(baseline.tightenedBy([]).reasons.size).toBe(0);
|
|
218
226
|
});
|
|
219
227
|
|
|
228
|
+
test("moves a moved file's entries and reasons to its new path, matching the file before the first #", () => {
|
|
229
|
+
const reason = "The canvas is one pointer state machine.";
|
|
230
|
+
const baseline = baselineOf(
|
|
231
|
+
{
|
|
232
|
+
"akan.size.file": { "lib/a/A.Zone.tsx": 900, "lib/a/A.Zone.tsxx": 700 },
|
|
233
|
+
"akan.component.store-access": { "lib/a/A.Zone.tsx#Canvas": 30, "lib/a/A.Zone.tsx#Canvas#2": 25 },
|
|
234
|
+
},
|
|
235
|
+
{ "lib/a/A.Zone.tsx#Canvas": reason },
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
const moved = baseline.movedBy(new Map([["lib/a/A.Zone.tsx", "lib/b/A.Zone.tsx"]]));
|
|
239
|
+
|
|
240
|
+
expect([...(moved.sections.get("akan.size.file") ?? [])]).toEqual([
|
|
241
|
+
["lib/b/A.Zone.tsx", 900],
|
|
242
|
+
["lib/a/A.Zone.tsxx", 700],
|
|
243
|
+
]);
|
|
244
|
+
expect([...(moved.sections.get("akan.component.store-access") ?? [])]).toEqual([
|
|
245
|
+
["lib/b/A.Zone.tsx#Canvas", 30],
|
|
246
|
+
["lib/b/A.Zone.tsx#Canvas#2", 25],
|
|
247
|
+
]);
|
|
248
|
+
expect([...moved.reasons]).toEqual([["lib/b/A.Zone.tsx#Canvas", reason]]);
|
|
249
|
+
expect(baseline.movedBy(new Map())).toBe(baseline);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
test("holds a total rule to the sum of its section: a moved count passes, a raised sum names the files that rose", () => {
|
|
253
|
+
const baseline = baselineOf({ "akan.error.bare-error": { "server/a.ts": 2, "server/b.ts": 1 } });
|
|
254
|
+
|
|
255
|
+
expect(baseline.unallowed([bareOf("server/c.ts", 3)])).toEqual([]);
|
|
256
|
+
expect(baseline.unallowed([bareOf("server/a.ts", 3), bareOf("server/b.ts", 1)])).toEqual([
|
|
257
|
+
bareOf("server/a.ts", 3),
|
|
258
|
+
]);
|
|
259
|
+
expect(baseline.tightenedBy([bareOf("server/c.ts", 2)]).sections.get("akan.error.bare-error")).toEqual(
|
|
260
|
+
new Map([["server/c.ts", 2]]),
|
|
261
|
+
);
|
|
262
|
+
expect(baseline.tightenedBy([bareOf("server/a.ts", 4)]).sections.get("akan.error.bare-error")).toEqual(
|
|
263
|
+
new Map([
|
|
264
|
+
["server/a.ts", 2],
|
|
265
|
+
["server/b.ts", 1],
|
|
266
|
+
]),
|
|
267
|
+
);
|
|
268
|
+
expect(baselineOf({ "akan.error.bare-error": { "server/c.ts": 3 } }).grownFrom(baseline)).toEqual([]);
|
|
269
|
+
expect(baselineOf({ "akan.error.bare-error": { "server/c.ts": 4 } }).grownFrom(baseline)).toEqual([
|
|
270
|
+
{ rule: "akan.error.bare-error", key: MaintainabilityBaseline.totalKey, count: 4, committed: 3 },
|
|
271
|
+
]);
|
|
272
|
+
expect(baseline.grownFrom(new MaintainabilityBaseline())).toEqual([
|
|
273
|
+
{ rule: "akan.error.bare-error", key: MaintainabilityBaseline.totalKey, count: 3, committed: undefined },
|
|
274
|
+
]);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
test("names a total recorded above the code's and no other, on a total rule only", () => {
|
|
278
|
+
const baseline = baselineOf({
|
|
279
|
+
"akan.size.file": { "lib/a/A.Zone.tsx": 900 },
|
|
280
|
+
"akan.error.bare-error": { "server/a.ts": 2, "server/b.ts": 1 },
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
expect(baseline.staleTotals([bareOf("server/a.ts", 2)])).toEqual([
|
|
284
|
+
{ rule: "akan.error.bare-error", count: 2, recorded: 3 },
|
|
285
|
+
]);
|
|
286
|
+
expect(baseline.staleTotals([])).toEqual([{ rule: "akan.error.bare-error", count: 0, recorded: 3 }]);
|
|
287
|
+
expect(baseline.staleTotals([bareOf("server/c.ts", 3)])).toEqual([]);
|
|
288
|
+
expect(baseline.staleTotals([bareOf("server/c.ts", 4)])).toEqual([]);
|
|
289
|
+
expect(baseline.tightenedBy([bareOf("server/a.ts", 1)]).staleTotals([bareOf("server/a.ts", 1)])).toEqual([]);
|
|
290
|
+
expect(new MaintainabilityBaseline().staleTotals([])).toEqual([]);
|
|
291
|
+
});
|
|
292
|
+
|
|
220
293
|
test("prints the rule sections in rule order with sorted keys, as Biome would, and reprints them unchanged", () => {
|
|
221
294
|
const baseline = MaintainabilityBaseline.of([
|
|
222
295
|
writeOf("lib/z/z.store.ts#run"),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonFormatter } from "
|
|
1
|
+
import { JsonFormatter } from "../util/jsonFormatter";
|
|
2
2
|
import type { DebtRuleId, MaintainabilityViolation } from "./maintainabilityContract";
|
|
3
3
|
|
|
4
4
|
export interface BaselineEntryGrowth {
|
|
@@ -14,9 +14,16 @@ export interface BaselineEntry {
|
|
|
14
14
|
reason?: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export interface BaselineStaleTotal {
|
|
18
|
+
rule: DebtRuleId;
|
|
19
|
+
count: number;
|
|
20
|
+
recorded: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
type Counts = ReadonlyMap<string, number>;
|
|
18
24
|
|
|
19
|
-
//* One section per rule, each key holding what the gate measured: lines, members,
|
|
25
|
+
//* One section per rule, each key holding what the gate measured: lines, members, accesses, writes, calls or the
|
|
26
|
+
//* built-in Errors constructed or extended.
|
|
20
27
|
//* A count only falls, so a recorded entry cannot take on more of the debt it records.
|
|
21
28
|
export class MaintainabilityBaseline {
|
|
22
29
|
static readonly fileName = "akan.baseline.json";
|
|
@@ -32,7 +39,13 @@ export class MaintainabilityBaseline {
|
|
|
32
39
|
"akan.component.write-chain",
|
|
33
40
|
"akan.write.placement",
|
|
34
41
|
"akan.service.call-in-loop",
|
|
42
|
+
"akan.error.bare-error",
|
|
35
43
|
] as const satisfies readonly DebtRuleId[];
|
|
44
|
+
//* Added after baselines were committed: where the reference holds no section for one, its code there is the floor.
|
|
45
|
+
static readonly lateRules: ReadonlySet<DebtRuleId> = new Set(["akan.error.bare-error"]);
|
|
46
|
+
//* Held to the package's sum, so a moved or split file keeps its count; the per-file entries name the file that rose.
|
|
47
|
+
static readonly totalRules: ReadonlySet<DebtRuleId> = new Set(["akan.error.bare-error"]);
|
|
48
|
+
static readonly totalKey = "(total)";
|
|
36
49
|
static readonly reasonedRules: ReadonlySet<DebtRuleId> = new Set([
|
|
37
50
|
"akan.size.file",
|
|
38
51
|
"akan.size.component",
|
|
@@ -48,6 +61,7 @@ export class MaintainabilityBaseline {
|
|
|
48
61
|
if (violation.kind === "storeAccess") return violation.accessCount;
|
|
49
62
|
if (violation.kind === "multiWrite") return violation.writeCount;
|
|
50
63
|
if (violation.kind === "writePlacement") return violation.writes.length;
|
|
64
|
+
if (violation.kind === "bareError") return violation.lines.length;
|
|
51
65
|
return violation.calls.length;
|
|
52
66
|
}
|
|
53
67
|
|
|
@@ -116,6 +130,30 @@ export class MaintainabilityBaseline {
|
|
|
116
130
|
return recorded !== undefined && MaintainabilityBaseline.countOf(violation) <= recorded;
|
|
117
131
|
}
|
|
118
132
|
|
|
133
|
+
unallowed(violations: MaintainabilityViolation[]) {
|
|
134
|
+
const measured = MaintainabilityBaseline.of(violations);
|
|
135
|
+
return violations.filter(
|
|
136
|
+
(violation) =>
|
|
137
|
+
!(
|
|
138
|
+
MaintainabilityBaseline.totalRules.has(violation.rule) &&
|
|
139
|
+
measured.totalOf(violation.rule) <= this.totalOf(violation.rule)
|
|
140
|
+
) && !this.allows(violation),
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
staleTotals(violations: MaintainabilityViolation[]): BaselineStaleTotal[] {
|
|
145
|
+
const measured = MaintainabilityBaseline.of(violations);
|
|
146
|
+
return [...MaintainabilityBaseline.totalRules].flatMap((rule) => {
|
|
147
|
+
const count = measured.totalOf(rule);
|
|
148
|
+
const recorded = this.totalOf(rule);
|
|
149
|
+
return count < recorded ? [{ rule, count, recorded }] : [];
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
totalOf(rule: DebtRuleId) {
|
|
154
|
+
return [...(this.sections.get(rule)?.values() ?? [])].reduce((sum, count) => sum + count, 0);
|
|
155
|
+
}
|
|
156
|
+
|
|
119
157
|
recordedOf(violation: MaintainabilityViolation) {
|
|
120
158
|
return this.sections.get(violation.rule)?.get(violation.key);
|
|
121
159
|
}
|
|
@@ -140,13 +178,55 @@ export class MaintainabilityBaseline {
|
|
|
140
178
|
);
|
|
141
179
|
}
|
|
142
180
|
|
|
181
|
+
rulesOutside(other: MaintainabilityBaseline | null): DebtRuleId[] {
|
|
182
|
+
return [...this.sections]
|
|
183
|
+
.filter(
|
|
184
|
+
([rule, counts]) =>
|
|
185
|
+
counts.size && (other === null || (MaintainabilityBaseline.lateRules.has(rule) && !other.sections.has(rule))),
|
|
186
|
+
)
|
|
187
|
+
.map(([rule]) => rule);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
withSectionsOf(other: MaintainabilityBaseline | null, rules: ReadonlySet<DebtRuleId>) {
|
|
191
|
+
if (!other) return this;
|
|
192
|
+
const sections = new Map(this.sections);
|
|
193
|
+
for (const rule of rules) sections.set(rule, other.sections.get(rule) ?? new Map());
|
|
194
|
+
return new MaintainabilityBaseline(sections, this.reasons);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
movedBy(moves: ReadonlyMap<string, string>) {
|
|
198
|
+
if (!moves.size) return this;
|
|
199
|
+
const movedKey = (key: string) => {
|
|
200
|
+
const file = key.split("#", 1)[0] ?? key;
|
|
201
|
+
const to = moves.get(file);
|
|
202
|
+
return to === undefined ? key : `${to}${key.slice(file.length)}`;
|
|
203
|
+
};
|
|
204
|
+
const sections = new Map(
|
|
205
|
+
[...this.sections].map(([rule, counts]) => {
|
|
206
|
+
const moved = new Map<string, number>();
|
|
207
|
+
for (const [key, count] of counts) {
|
|
208
|
+
const to = movedKey(key);
|
|
209
|
+
moved.set(to, Math.max(moved.get(to) ?? 0, count));
|
|
210
|
+
}
|
|
211
|
+
return [rule, moved];
|
|
212
|
+
}),
|
|
213
|
+
);
|
|
214
|
+
return new MaintainabilityBaseline(
|
|
215
|
+
sections,
|
|
216
|
+
new Map([...this.reasons].map(([key, reason]) => [movedKey(key), reason])),
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
143
220
|
tightenedBy(violations: MaintainabilityViolation[]) {
|
|
144
221
|
const current = MaintainabilityBaseline.of(violations);
|
|
145
222
|
const sections = new Map(
|
|
146
|
-
[...this.sections].map(([rule, counts]) =>
|
|
147
|
-
rule,
|
|
148
|
-
MaintainabilityBaseline
|
|
149
|
-
|
|
223
|
+
[...this.sections].map(([rule, counts]) => {
|
|
224
|
+
const measured = current.sections.get(rule) ?? new Map<string, number>();
|
|
225
|
+
if (!MaintainabilityBaseline.totalRules.has(rule))
|
|
226
|
+
return [rule, MaintainabilityBaseline.#lowered(counts, measured)];
|
|
227
|
+
//? Over budget, a file that went down may only have moved its count; recording it would refuse that move later.
|
|
228
|
+
return [rule, current.totalOf(rule) > this.totalOf(rule) ? counts : measured];
|
|
229
|
+
}),
|
|
150
230
|
);
|
|
151
231
|
return new MaintainabilityBaseline(sections).#withReasonsOf(this.reasons);
|
|
152
232
|
}
|
|
@@ -161,12 +241,20 @@ export class MaintainabilityBaseline {
|
|
|
161
241
|
//* Only a shape entry grows with a reason: a write rule guards correctness, whatever the reason.
|
|
162
242
|
grownFrom(committed: MaintainabilityBaseline): BaselineEntryGrowth[] {
|
|
163
243
|
return [...this.sections].flatMap(([rule, counts]) =>
|
|
164
|
-
MaintainabilityBaseline
|
|
165
|
-
|
|
166
|
-
|
|
244
|
+
MaintainabilityBaseline.totalRules.has(rule)
|
|
245
|
+
? this.#totalGrownFrom(committed, rule)
|
|
246
|
+
: MaintainabilityBaseline.#raised(counts, committed.sections.get(rule) ?? new Map())
|
|
247
|
+
.filter(([key]) => !(MaintainabilityBaseline.reasonedRules.has(rule) && this.reasonOf(key)))
|
|
248
|
+
.map(([key, count, recorded]) => ({ rule, key, count, committed: recorded })),
|
|
167
249
|
);
|
|
168
250
|
}
|
|
169
251
|
|
|
252
|
+
#totalGrownFrom(committed: MaintainabilityBaseline, rule: DebtRuleId): BaselineEntryGrowth[] {
|
|
253
|
+
const count = this.totalOf(rule);
|
|
254
|
+
const recorded = committed.sections.has(rule) ? committed.totalOf(rule) : undefined;
|
|
255
|
+
return count > (recorded ?? 0) ? [{ rule, key: MaintainabilityBaseline.totalKey, count, committed: recorded }] : [];
|
|
256
|
+
}
|
|
257
|
+
|
|
170
258
|
stringify() {
|
|
171
259
|
const sections = MaintainabilityBaseline.debtRules.flatMap((rule) => {
|
|
172
260
|
const counts = this.sections.get(rule);
|