@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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { mkdir, readFile, rename, rm } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { tempDirs, writeText } from "../test/testHelpers";
|
|
5
6
|
import { MaintainabilityBaseline } from "./maintainabilityBaseline";
|
|
6
7
|
import { MaintainabilityContract } from "./maintainabilityContract";
|
|
7
8
|
import { MaintainabilityLimits } from "./maintainabilityLimits";
|
|
8
|
-
import { tempDirs, writeText } from "./testHelpers";
|
|
9
9
|
|
|
10
10
|
const makeTempRoot = tempDirs("akan-maintainability-");
|
|
11
11
|
|
|
@@ -506,6 +506,7 @@ describe("MaintainabilityContract rules", () => {
|
|
|
506
506
|
"akan.component.store-access",
|
|
507
507
|
"akan.write.placement",
|
|
508
508
|
"akan.service.call-in-loop",
|
|
509
|
+
"akan.error.bare-error",
|
|
509
510
|
"akan.baseline.growth",
|
|
510
511
|
]);
|
|
511
512
|
const root = await makeWorkspace({
|
|
@@ -956,6 +957,386 @@ describe("MaintainabilityContract packages", () => {
|
|
|
956
957
|
" function: Split it by family into named functions or a collaborator class, each under the limit, keeping its signature for callers.",
|
|
957
958
|
);
|
|
958
959
|
});
|
|
960
|
+
|
|
961
|
+
test("keeps a moved file's entries under its new path, and still fails one that grew in the move", async () => {
|
|
962
|
+
const recordOf = (key: string, count: number, reason?: string) =>
|
|
963
|
+
`{\n "akan.size.function": {\n ${JSON.stringify(key)}: ${count}\n }${reason ? `,\n "reasons": {\n ${JSON.stringify(key)}: ${JSON.stringify(reason)}\n }` : ""}\n}\n`;
|
|
964
|
+
const reason = "boot reads every flag in one pass";
|
|
965
|
+
const root = await makeWorkspace({
|
|
966
|
+
"pkgs/@demo/core/server/host.ts": functionOf("boot", 200),
|
|
967
|
+
"pkgs/@demo/core/akan.baseline.json": recordOf("server/host.ts#boot", 200, reason),
|
|
968
|
+
});
|
|
969
|
+
await commitAll(root);
|
|
970
|
+
await mkdir(path.join(root, "pkgs/@demo/core/gateway"));
|
|
971
|
+
await git(root, "mv", "pkgs/@demo/core/server/host.ts", "pkgs/@demo/core/gateway/host.ts");
|
|
972
|
+
const baselinePath = path.join(root, "pkgs/@demo/core/akan.baseline.json");
|
|
973
|
+
|
|
974
|
+
expect(await packageOf(root).enforce({ fix: true })).toEqual([]);
|
|
975
|
+
expect(await readFile(baselinePath, "utf8")).toBe(recordOf("gateway/host.ts#boot", 200, reason));
|
|
976
|
+
|
|
977
|
+
expect(await packageOf(root).enforce({ fix: false })).toEqual([]);
|
|
978
|
+
|
|
979
|
+
await writeText(path.join(root, "pkgs/@demo/core/gateway/host.ts"), functionOf("boot", 210));
|
|
980
|
+
await writeText(baselinePath, recordOf("gateway/host.ts#boot", 210));
|
|
981
|
+
expect(await packageOf(root).enforce({ fix: false })).toMatchObject([
|
|
982
|
+
{ kind: "baselineGrowth", key: "gateway/host.ts#boot", count: 210, committed: 200 },
|
|
983
|
+
]);
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
test("follows a move git has not staged, without staging it, and reads an entry left at the old key as the reference's", async () => {
|
|
987
|
+
const recordOf = (key: string) => `{\n "akan.size.function": {\n ${JSON.stringify(key)}: 200\n }\n}\n`;
|
|
988
|
+
const root = await makeWorkspace({
|
|
989
|
+
"pkgs/@demo/core/server/host.ts": functionOf("boot", 200),
|
|
990
|
+
"pkgs/@demo/core/akan.baseline.json": recordOf("server/host.ts#boot"),
|
|
991
|
+
});
|
|
992
|
+
await commitAll(root);
|
|
993
|
+
await mkdir(path.join(root, "pkgs/@demo/core/gateway"));
|
|
994
|
+
await rename(path.join(root, "pkgs/@demo/core/server/host.ts"), path.join(root, "pkgs/@demo/core/gateway/host.ts"));
|
|
995
|
+
|
|
996
|
+
expect(await packageOf(root).enforce({ fix: false })).toMatchObject([
|
|
997
|
+
{ rule: "akan.size.function", key: "gateway/host.ts#boot" },
|
|
998
|
+
]);
|
|
999
|
+
expect(Bun.spawnSync(["git", "status", "--porcelain"], { cwd: root }).stdout.toString()).toBe(
|
|
1000
|
+
" D pkgs/@demo/core/server/host.ts\n?? pkgs/@demo/core/gateway/\n",
|
|
1001
|
+
);
|
|
1002
|
+
|
|
1003
|
+
await writeText(path.join(root, "pkgs/@demo/core/gateway/host.ts"), functionOf("boot", 120));
|
|
1004
|
+
expect(await packageOf(root).enforce({ fix: false })).toEqual([]);
|
|
1005
|
+
|
|
1006
|
+
await writeText(path.join(root, "pkgs/@demo/core/gateway/host.ts"), functionOf("boot", 200));
|
|
1007
|
+
expect(await packageOf(root).enforce({ fix: true })).toEqual([]);
|
|
1008
|
+
expect(await readFile(path.join(root, "pkgs/@demo/core/akan.baseline.json"), "utf8")).toBe(
|
|
1009
|
+
recordOf("gateway/host.ts#boot"),
|
|
1010
|
+
);
|
|
1011
|
+
});
|
|
1012
|
+
|
|
1013
|
+
test("still reads a staged move where it cannot stage, and stores no untracked file but a source", async () => {
|
|
1014
|
+
const recordOf = (key: string) => `{\n "akan.size.function": {\n ${JSON.stringify(key)}: 200\n }\n}\n`;
|
|
1015
|
+
const root = await makeWorkspace({
|
|
1016
|
+
"pkgs/@demo/core/server/host.ts": functionOf("boot", 200),
|
|
1017
|
+
"pkgs/@demo/core/akan.baseline.json": recordOf("server/host.ts#boot"),
|
|
1018
|
+
});
|
|
1019
|
+
await commitAll(root);
|
|
1020
|
+
await mkdir(path.join(root, "pkgs/@demo/core/gateway"));
|
|
1021
|
+
await git(root, "mv", "pkgs/@demo/core/server/host.ts", "pkgs/@demo/core/gateway/host.ts");
|
|
1022
|
+
await writeText(path.join(root, "pkgs/@demo/core/local.db"), "rows that change on every run");
|
|
1023
|
+
|
|
1024
|
+
const tmpdirBefore = process.env.TMPDIR;
|
|
1025
|
+
process.env.TMPDIR = path.join(root, "missing-tmp");
|
|
1026
|
+
try {
|
|
1027
|
+
expect(await packageOf(root).enforce({ fix: true })).toEqual([]);
|
|
1028
|
+
} finally {
|
|
1029
|
+
if (tmpdirBefore === undefined) delete process.env.TMPDIR;
|
|
1030
|
+
else process.env.TMPDIR = tmpdirBefore;
|
|
1031
|
+
}
|
|
1032
|
+
expect(await readFile(path.join(root, "pkgs/@demo/core/akan.baseline.json"), "utf8")).toBe(
|
|
1033
|
+
recordOf("gateway/host.ts#boot"),
|
|
1034
|
+
);
|
|
1035
|
+
|
|
1036
|
+
expect(await packageOf(root).enforce({ fix: false })).toEqual([]);
|
|
1037
|
+
const hash = Bun.spawnSync(["git", "hash-object", "pkgs/@demo/core/local.db"], { cwd: root }).stdout.toString();
|
|
1038
|
+
expect(Bun.spawnSync(["git", "cat-file", "-e", hash.trim()], { cwd: root }).exitCode).not.toBe(0);
|
|
1039
|
+
});
|
|
1040
|
+
});
|
|
1041
|
+
|
|
1042
|
+
describe("MaintainabilityContract bare errors", () => {
|
|
1043
|
+
const manifest = '{ "name": "akanjs" }\n';
|
|
1044
|
+
const akanjsOf = (root: string) => new MaintainabilityContract(root, { type: "pkg", name: "akanjs" });
|
|
1045
|
+
const failing = (count: number, prefix = "f") =>
|
|
1046
|
+
`${Array.from(
|
|
1047
|
+
{ length: count },
|
|
1048
|
+
(_, idx) => `export const ${prefix}${idx} = () => {\n throw new Error("${idx}");\n};`,
|
|
1049
|
+
).join("\n")}\n`;
|
|
1050
|
+
const shapes = `import { AkanError } from "akanjs/base";
|
|
1051
|
+
import { Err } from "akanjs/dictionary";
|
|
1052
|
+
export const a = () => {
|
|
1053
|
+
throw new globalThis.Error("1");
|
|
1054
|
+
};
|
|
1055
|
+
export const b = () => {
|
|
1056
|
+
throw Object.assign(new Error("2"), { statusCode: 400 });
|
|
1057
|
+
};
|
|
1058
|
+
export const c = (err?: Error) => {
|
|
1059
|
+
throw err ?? Error("3");
|
|
1060
|
+
};
|
|
1061
|
+
export const d = (x: boolean) => {
|
|
1062
|
+
throw x ? new TypeError("4a") : new RangeError("4b");
|
|
1063
|
+
};
|
|
1064
|
+
export const e = () => {
|
|
1065
|
+
const failure = new Error("5");
|
|
1066
|
+
throw failure;
|
|
1067
|
+
};
|
|
1068
|
+
export const f = () => {
|
|
1069
|
+
throw (<Error>new Error("6"))!;
|
|
1070
|
+
};
|
|
1071
|
+
export const g = () => new Promise((_, reject) => reject(new Error("7") satisfies Error));
|
|
1072
|
+
class LocalError extends Error {}
|
|
1073
|
+
export const h = () => {
|
|
1074
|
+
throw new LocalError("9");
|
|
1075
|
+
};
|
|
1076
|
+
export const i = (Error: ErrorConstructor) => {
|
|
1077
|
+
throw new Error("shadowed by a parameter");
|
|
1078
|
+
};
|
|
1079
|
+
export const j = () => {
|
|
1080
|
+
const TypeError = class {};
|
|
1081
|
+
throw new TypeError();
|
|
1082
|
+
};
|
|
1083
|
+
export const k = (input: unknown) => {
|
|
1084
|
+
if (input === 1) throw new AkanError("coded", "coded", { statusCode: 400 });
|
|
1085
|
+
if (input === 2) throw new Err.NotFound("base.error.missing");
|
|
1086
|
+
if (input instanceof Error) Error.captureStackTrace(input);
|
|
1087
|
+
throw new DOMException("aborted", "AbortError");
|
|
1088
|
+
};
|
|
1089
|
+
`;
|
|
1090
|
+
const baselineAt = async (root: string) =>
|
|
1091
|
+
MaintainabilityBaseline.parse(
|
|
1092
|
+
await readFile(path.join(root, "pkgs/akanjs/akan.baseline.json"), "utf8"),
|
|
1093
|
+
).sections.get("akan.error.bare-error");
|
|
1094
|
+
|
|
1095
|
+
test("counts each built-in Error constructed, rejected or extended under server/, service/ and signal/ of akanjs", async () => {
|
|
1096
|
+
const root = await makeWorkspace({
|
|
1097
|
+
"pkgs/akanjs/package.json": manifest,
|
|
1098
|
+
"pkgs/akanjs/server/shapes.ts": shapes,
|
|
1099
|
+
"pkgs/akanjs/signal/fail.ts": failing(1),
|
|
1100
|
+
"pkgs/akanjs/service/run.test.ts": failing(2),
|
|
1101
|
+
"pkgs/akanjs/client/run.ts": failing(2),
|
|
1102
|
+
"pkgs/akanjs/service/imported.ts": `import { Error } from "./errors";\nexport const fail = () => new Error("x");\n`,
|
|
1103
|
+
"pkgs/framework/package.json": manifest,
|
|
1104
|
+
"pkgs/framework/server/fail.ts": failing(1),
|
|
1105
|
+
"pkgs/other/package.json": '{ "name": "other" }\n',
|
|
1106
|
+
"pkgs/other/server/fail.ts": failing(1),
|
|
1107
|
+
});
|
|
1108
|
+
|
|
1109
|
+
expect(await akanjsOf(root).measure()).toEqual([
|
|
1110
|
+
{
|
|
1111
|
+
kind: "bareError",
|
|
1112
|
+
rule: "akan.error.bare-error",
|
|
1113
|
+
key: "server/shapes.ts",
|
|
1114
|
+
file: "server/shapes.ts",
|
|
1115
|
+
line: 4,
|
|
1116
|
+
lines: [4, 7, 10, 13, 13, 16, 20, 22, 23],
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
kind: "bareError",
|
|
1120
|
+
rule: "akan.error.bare-error",
|
|
1121
|
+
key: "signal/fail.ts",
|
|
1122
|
+
file: "signal/fail.ts",
|
|
1123
|
+
line: 2,
|
|
1124
|
+
lines: [2],
|
|
1125
|
+
},
|
|
1126
|
+
]);
|
|
1127
|
+
expect(await new MaintainabilityContract(root, { type: "pkg", name: "framework" }).measure()).toMatchObject([
|
|
1128
|
+
{ rule: "akan.error.bare-error", key: "server/fail.ts" },
|
|
1129
|
+
]);
|
|
1130
|
+
expect(await new MaintainabilityContract(root, { type: "pkg", name: "other" }).measure()).toEqual([]);
|
|
1131
|
+
});
|
|
1132
|
+
|
|
1133
|
+
test("holds the package's total, so a rename or a split passes and the entries follow the code", async () => {
|
|
1134
|
+
const root = await makeWorkspace({
|
|
1135
|
+
"pkgs/akanjs/package.json": manifest,
|
|
1136
|
+
"pkgs/akanjs/server/host.ts": failing(3),
|
|
1137
|
+
});
|
|
1138
|
+
await akanjsOf(root).seed();
|
|
1139
|
+
await commitAll(root);
|
|
1140
|
+
await git(root, "checkout", "-q", "-b", "feat");
|
|
1141
|
+
|
|
1142
|
+
await git(root, "mv", "pkgs/akanjs/server/host.ts", "pkgs/akanjs/server/moved.ts");
|
|
1143
|
+
expect(await akanjsOf(root).enforce({ fix: false })).toEqual([]);
|
|
1144
|
+
expect(await akanjsOf(root).enforce({ fix: true })).toEqual([]);
|
|
1145
|
+
expect(await baselineAt(root)).toEqual(new Map([["server/moved.ts", 3]]));
|
|
1146
|
+
|
|
1147
|
+
await writeText(path.join(root, "pkgs/akanjs/server/moved.ts"), failing(1));
|
|
1148
|
+
await writeText(path.join(root, "pkgs/akanjs/signal/extracted.ts"), failing(2, "g"));
|
|
1149
|
+
expect(await akanjsOf(root).enforce({ fix: false })).toEqual([]);
|
|
1150
|
+
expect(await akanjsOf(root).enforce({ fix: true })).toEqual([]);
|
|
1151
|
+
expect(await baselineAt(root)).toEqual(
|
|
1152
|
+
new Map([
|
|
1153
|
+
["server/moved.ts", 1],
|
|
1154
|
+
["signal/extracted.ts", 2],
|
|
1155
|
+
]),
|
|
1156
|
+
);
|
|
1157
|
+
|
|
1158
|
+
await writeText(path.join(root, "pkgs/akanjs/signal/extracted.ts"), failing(1, "g"));
|
|
1159
|
+
expect(await akanjsOf(root).enforce({ fix: true })).toEqual([]);
|
|
1160
|
+
expect(await baselineAt(root)).toEqual(
|
|
1161
|
+
new Map([
|
|
1162
|
+
["server/moved.ts", 1],
|
|
1163
|
+
["signal/extracted.ts", 1],
|
|
1164
|
+
]),
|
|
1165
|
+
);
|
|
1166
|
+
});
|
|
1167
|
+
|
|
1168
|
+
test("fails a new bare Error anywhere, naming the file whose count rose", async () => {
|
|
1169
|
+
const root = await makeWorkspace({
|
|
1170
|
+
"pkgs/akanjs/package.json": manifest,
|
|
1171
|
+
"pkgs/akanjs/server/host.ts": failing(3),
|
|
1172
|
+
});
|
|
1173
|
+
await akanjsOf(root).seed();
|
|
1174
|
+
await commitAll(root);
|
|
1175
|
+
await writeText(path.join(root, "pkgs/akanjs/service/fresh.ts"), failing(1));
|
|
1176
|
+
|
|
1177
|
+
const contract = akanjsOf(root);
|
|
1178
|
+
const failures = await contract.enforce({ fix: false });
|
|
1179
|
+
|
|
1180
|
+
expect(failures).toMatchObject([{ rule: "akan.error.bare-error", key: "service/fresh.ts", lines: [2] }]);
|
|
1181
|
+
expect(contract.describe(failures)).toBe(
|
|
1182
|
+
"[maintainability] 1 violation(s) in pkgs/akanjs:\n" +
|
|
1183
|
+
" pkgs/akanjs/service/fresh.ts:2 akan.error.bare-error constructs or extends 1 bare Error, on line 2, and the package's total grew\n" +
|
|
1184
|
+
"How to fix:\n" +
|
|
1185
|
+
" bare Error: Construct an `AkanError` subclass from `akanjs/base` with a code the caller can branch on, and a `statusCode` when it answers a request: an existing class whose code fits, or a new one beside the code that fails; a class extending a built-in Error extends `AkanError` instead. A failure another process reported travels as itself. The package's total is what is held, so moving a bare Error between files passes and `akan lint` rewrites the entries.",
|
|
1186
|
+
);
|
|
1187
|
+
|
|
1188
|
+
await writeText(path.join(root, "pkgs/akanjs/server/host.ts"), failing(4));
|
|
1189
|
+
await Bun.write(path.join(root, "pkgs/akanjs/service/fresh.ts"), "export const fine = 1;\n");
|
|
1190
|
+
expect(await akanjsOf(root).enforce({ fix: false })).toMatchObject([
|
|
1191
|
+
{ rule: "akan.error.bare-error", key: "server/host.ts", lines: [2, 5, 8, 11], recorded: 3 },
|
|
1192
|
+
]);
|
|
1193
|
+
});
|
|
1194
|
+
|
|
1195
|
+
test("refuses a working total raised over the fork point's, whatever file it is recorded under", async () => {
|
|
1196
|
+
const root = await makeWorkspace({
|
|
1197
|
+
"pkgs/akanjs/package.json": manifest,
|
|
1198
|
+
"pkgs/akanjs/server/host.ts": failing(2),
|
|
1199
|
+
});
|
|
1200
|
+
await akanjsOf(root).seed();
|
|
1201
|
+
await commitAll(root);
|
|
1202
|
+
await writeText(path.join(root, "pkgs/akanjs/server/host.ts"), failing(3));
|
|
1203
|
+
await akanjsOf(root).seed({ force: true });
|
|
1204
|
+
|
|
1205
|
+
const contract = akanjsOf(root);
|
|
1206
|
+
const failures = await contract.enforce({ fix: false });
|
|
1207
|
+
|
|
1208
|
+
expect(failures).toMatchObject([
|
|
1209
|
+
{ kind: "baselineGrowth", debtRule: "akan.error.bare-error", key: "(total)", count: 3, committed: 2, line: 2 },
|
|
1210
|
+
]);
|
|
1211
|
+
expect(contract.describe(failures)).toMatch(
|
|
1212
|
+
/akan\.baseline\.json:2 {2}akan\.baseline\.growth {2}akan\.error\.bare-error allows 3 bare Errors in all, above the 2 at [0-9a-f]{12}; the baseline may only shrink/,
|
|
1213
|
+
);
|
|
1214
|
+
});
|
|
1215
|
+
|
|
1216
|
+
test("refuses a paydown that keeps the baseline, so a later change cannot spend what it paid", async () => {
|
|
1217
|
+
const root = await makeWorkspace({
|
|
1218
|
+
"pkgs/akanjs/package.json": manifest,
|
|
1219
|
+
"pkgs/akanjs/server/a.ts": failing(3),
|
|
1220
|
+
});
|
|
1221
|
+
await akanjsOf(root).seed();
|
|
1222
|
+
await commitAll(root);
|
|
1223
|
+
await git(root, "checkout", "-q", "-b", "pr-1");
|
|
1224
|
+
await writeText(path.join(root, "pkgs/akanjs/server/a.ts"), failing(1));
|
|
1225
|
+
|
|
1226
|
+
const contract = akanjsOf(root);
|
|
1227
|
+
const failures = await contract.enforce({ fix: false });
|
|
1228
|
+
|
|
1229
|
+
expect(failures).toEqual([
|
|
1230
|
+
{
|
|
1231
|
+
kind: "staleTotal",
|
|
1232
|
+
rule: "akan.error.bare-error",
|
|
1233
|
+
key: "(total)",
|
|
1234
|
+
file: "akan.baseline.json",
|
|
1235
|
+
line: 2,
|
|
1236
|
+
count: 1,
|
|
1237
|
+
recorded: 3,
|
|
1238
|
+
},
|
|
1239
|
+
]);
|
|
1240
|
+
expect(contract.describe(failures)).toBe(
|
|
1241
|
+
"[maintainability] 1 violation(s) in pkgs/akanjs:\n" +
|
|
1242
|
+
" pkgs/akanjs/akan.baseline.json:2 akan.error.bare-error records 3 bare Errors in all, above the 1 the code holds\n" +
|
|
1243
|
+
"How to fix:\n" +
|
|
1244
|
+
" baseline total: Run `akan verify <package>`, which lowers the section, and commit `akan.baseline.json` in this change: a recorded total above the code is room for a new failure anywhere. A bare `akan verify` covers only uncommitted files.",
|
|
1245
|
+
);
|
|
1246
|
+
|
|
1247
|
+
expect(await akanjsOf(root).enforce({ fix: true })).toEqual([]);
|
|
1248
|
+
expect(await baselineAt(root)).toEqual(new Map([["server/a.ts", 1]]));
|
|
1249
|
+
expect(await akanjsOf(root).enforce({ fix: false })).toEqual([]);
|
|
1250
|
+
|
|
1251
|
+
await git(root, "add", "-A");
|
|
1252
|
+
await git(root, "commit", "-q", "-m", "pr 1");
|
|
1253
|
+
await git(root, "checkout", "-q", "main");
|
|
1254
|
+
await git(root, "merge", "-q", "--ff-only", "pr-1");
|
|
1255
|
+
await git(root, "checkout", "-q", "-b", "pr-2");
|
|
1256
|
+
await writeText(path.join(root, "pkgs/akanjs/signal/new.ts"), failing(2, "g"));
|
|
1257
|
+
|
|
1258
|
+
expect(await akanjsOf(root).enforce({ fix: false })).toMatchObject([
|
|
1259
|
+
{ rule: "akan.error.bare-error", key: "signal/new.ts", lines: [2, 5] },
|
|
1260
|
+
]);
|
|
1261
|
+
});
|
|
1262
|
+
|
|
1263
|
+
test("refuses a stale total in a scope with no reference to compare with", async () => {
|
|
1264
|
+
const root = await makeWorkspace({
|
|
1265
|
+
"pkgs/akanjs/package.json": manifest,
|
|
1266
|
+
"pkgs/akanjs/server/a.ts": failing(1),
|
|
1267
|
+
"pkgs/akanjs/akan.baseline.json": '{\n "akan.error.bare-error": {\n "server/a.ts": 3\n }\n}\n',
|
|
1268
|
+
});
|
|
1269
|
+
|
|
1270
|
+
expect(await akanjsOf(root).enforce({ fix: false })).toMatchObject([{ kind: "staleTotal", count: 1, recorded: 3 }]);
|
|
1271
|
+
});
|
|
1272
|
+
|
|
1273
|
+
test("leaves the section untouched while over budget, so a move survives a run that also added one", async () => {
|
|
1274
|
+
const root = await makeWorkspace({
|
|
1275
|
+
"pkgs/akanjs/package.json": manifest,
|
|
1276
|
+
"pkgs/akanjs/server/a.ts": failing(3),
|
|
1277
|
+
"pkgs/akanjs/server/b.ts": failing(1),
|
|
1278
|
+
});
|
|
1279
|
+
await akanjsOf(root).seed();
|
|
1280
|
+
await commitAll(root);
|
|
1281
|
+
await git(root, "checkout", "-q", "-b", "feat");
|
|
1282
|
+
await writeText(path.join(root, "pkgs/akanjs/server/a.ts"), failing(2));
|
|
1283
|
+
await writeText(path.join(root, "pkgs/akanjs/server/b.ts"), failing(2));
|
|
1284
|
+
await writeText(path.join(root, "pkgs/akanjs/server/c.ts"), failing(1));
|
|
1285
|
+
|
|
1286
|
+
expect(await akanjsOf(root).enforce({ fix: true })).toMatchObject([
|
|
1287
|
+
{ key: "server/b.ts", recorded: 1 },
|
|
1288
|
+
{ key: "server/c.ts" },
|
|
1289
|
+
]);
|
|
1290
|
+
expect(await baselineAt(root)).toEqual(
|
|
1291
|
+
new Map([
|
|
1292
|
+
["server/a.ts", 3],
|
|
1293
|
+
["server/b.ts", 1],
|
|
1294
|
+
]),
|
|
1295
|
+
);
|
|
1296
|
+
|
|
1297
|
+
await rm(path.join(root, "pkgs/akanjs/server/c.ts"));
|
|
1298
|
+
expect(await akanjsOf(root).enforce({ fix: true })).toEqual([]);
|
|
1299
|
+
expect(await baselineAt(root)).toEqual(
|
|
1300
|
+
new Map([
|
|
1301
|
+
["server/a.ts", 2],
|
|
1302
|
+
["server/b.ts", 2],
|
|
1303
|
+
]),
|
|
1304
|
+
);
|
|
1305
|
+
expect(await akanjsOf(root).enforce({ fix: false })).toEqual([]);
|
|
1306
|
+
});
|
|
1307
|
+
|
|
1308
|
+
test("adopts the rule in a baseline that predates it with the fork point's total, and no more", async () => {
|
|
1309
|
+
const root = await makeWorkspace({
|
|
1310
|
+
"pkgs/akanjs/package.json": manifest,
|
|
1311
|
+
"pkgs/akanjs/server/host.ts": failing(2),
|
|
1312
|
+
"pkgs/akanjs/akan.baseline.json": '{\n "akan.size.file": {\n "server/big.ts": 900\n }\n}\n',
|
|
1313
|
+
"pkgs/akanjs/server/big.ts": linesOf(900),
|
|
1314
|
+
});
|
|
1315
|
+
await commitAll(root);
|
|
1316
|
+
|
|
1317
|
+
await akanjsOf(root).seed({ force: true });
|
|
1318
|
+
expect(await baselineAt(root)).toEqual(new Map([["server/host.ts", 2]]));
|
|
1319
|
+
expect(await akanjsOf(root).enforce({ fix: false })).toEqual([]);
|
|
1320
|
+
|
|
1321
|
+
await writeText(path.join(root, "pkgs/akanjs/signal/fresh.ts"), failing(1));
|
|
1322
|
+
await akanjsOf(root).seed({ force: true });
|
|
1323
|
+
const contract = akanjsOf(root);
|
|
1324
|
+
const failures = await contract.enforce({ fix: false });
|
|
1325
|
+
|
|
1326
|
+
expect(failures).toMatchObject([
|
|
1327
|
+
{
|
|
1328
|
+
kind: "baselineGrowth",
|
|
1329
|
+
debtRule: "akan.error.bare-error",
|
|
1330
|
+
key: "(total)",
|
|
1331
|
+
count: 3,
|
|
1332
|
+
committed: 2,
|
|
1333
|
+
measured: true,
|
|
1334
|
+
},
|
|
1335
|
+
]);
|
|
1336
|
+
expect(contract.describe(failures)).toMatch(
|
|
1337
|
+
/akan\.error\.bare-error allows 3 bare Errors in all, above the 2 the code at [0-9a-f]{12} holds with no entry for its rule recorded there/,
|
|
1338
|
+
);
|
|
1339
|
+
});
|
|
959
1340
|
});
|
|
960
1341
|
|
|
961
1342
|
describe("MaintainabilityContract reference without a baseline", () => {
|