@akanjs/devkit 3.2.0-rc.3 → 3.2.0-rc.30
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 +367 -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 +14 -2
- 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} +32 -262
- 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 +28 -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 -13
- package/preview/previewView.test.ts +33 -3
- 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} +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 +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 +1 -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 +16 -3
- package/workflow/plan.ts +14 -2
- 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} +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 -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
|
@@ -129,7 +129,43 @@ export const writeJson = async (filePath: string, value: object) => {
|
|
|
129
129
|
await writeText(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
-
const
|
|
132
|
+
export const heldMtimeIndex = () => {
|
|
133
|
+
const primes: PromiseWithResolvers<void>[] = [];
|
|
134
|
+
const scans: PromiseWithResolvers<string[]>[] = [];
|
|
135
|
+
class SourceMtimeIndex {
|
|
136
|
+
#primed = false;
|
|
137
|
+
readonly trackedFileCount = 0;
|
|
138
|
+
readonly coverageGaps: { path: string; code: string }[] = [];
|
|
139
|
+
readonly hasUnsettledDirs = false;
|
|
140
|
+
get primed() {
|
|
141
|
+
return this.#primed;
|
|
142
|
+
}
|
|
143
|
+
async prime() {
|
|
144
|
+
const gate = Promise.withResolvers<void>();
|
|
145
|
+
primes.push(gate);
|
|
146
|
+
await gate.promise;
|
|
147
|
+
this.#primed = true;
|
|
148
|
+
}
|
|
149
|
+
collectChanges() {
|
|
150
|
+
const scan = Promise.withResolvers<string[]>();
|
|
151
|
+
scans.push(scan);
|
|
152
|
+
return scan.promise;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return { SourceMtimeIndex, primes, scans };
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
//? FSEvents drops what lands before its stream is up, so the save repeats until the watcher has acted on one.
|
|
159
|
+
export const saveUntil = async (file: string, seen: () => boolean, timeoutMs = 5_000) => {
|
|
160
|
+
const deadline = Date.now() + timeoutMs;
|
|
161
|
+
for (let n = 0; !seen() && Date.now() < deadline; n++) {
|
|
162
|
+
await writeFile(file, `export const x = ${n};\n`);
|
|
163
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
164
|
+
}
|
|
165
|
+
return seen();
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const repoRoot = path.resolve(import.meta.dir, "../../../..");
|
|
133
169
|
const biomeBin = path.join(repoRoot, "node_modules", ".bin", process.platform === "win32" ? "biome.exe" : "biome");
|
|
134
170
|
export const hasBiome = existsSync(biomeBin);
|
|
135
171
|
|
|
@@ -36,8 +36,17 @@ const REEXPORT_RE =
|
|
|
36
36
|
// cannot also match `export type { X } from "./y"`.
|
|
37
37
|
const LOCAL_NAMED_RE = /(?:^|\n)\s*export\s+\{\s*([^}]*?)\s*\}(?!\s*from)/g;
|
|
38
38
|
|
|
39
|
+
// `Transpiler.scan` has no file path to resolve a macro import from, so a module calling one fails as "Parse error".
|
|
40
|
+
const MACRO_ATTR_RE = /\swith\s*\{\s*type\s*:\s*["']macro["']\s*\}/g;
|
|
41
|
+
|
|
39
42
|
const CANDIDATE_EXTS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
40
43
|
|
|
44
|
+
interface BarrelWalk {
|
|
45
|
+
visited: Set<string>;
|
|
46
|
+
read: Set<string>;
|
|
47
|
+
following: Set<string>;
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
export class BarrelAnalyzer {
|
|
42
51
|
readonly #logger = new Logger("BarrelAnalyzer");
|
|
43
52
|
readonly #opts: BarrelAnalyzerOptions;
|
|
@@ -96,7 +105,7 @@ export class BarrelAnalyzer {
|
|
|
96
105
|
const map: BarrelExportMap = new Map();
|
|
97
106
|
const read = new Set<string>();
|
|
98
107
|
this.#read.set(pkgName, read);
|
|
99
|
-
await this.#walk(pkg.entryFile, pkg, map, read);
|
|
108
|
+
await this.#walk(pkg.entryFile, pkg, map, { visited: new Set(), read, following: new Set([pkg.entryFile]) });
|
|
100
109
|
return map;
|
|
101
110
|
} catch (err) {
|
|
102
111
|
this.#logger.error(`analyze failed for ${pkgName}: ${(err as Error).message}`);
|
|
@@ -104,9 +113,10 @@ export class BarrelAnalyzer {
|
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
115
|
|
|
107
|
-
async #walk(absFile: string, pkg: PackageEntry, map: BarrelExportMap,
|
|
108
|
-
if (visited.has(absFile)) return;
|
|
109
|
-
visited.add(absFile);
|
|
116
|
+
async #walk(absFile: string, pkg: PackageEntry, map: BarrelExportMap, walk: BarrelWalk): Promise<void> {
|
|
117
|
+
if (walk.visited.has(absFile)) return;
|
|
118
|
+
walk.visited.add(absFile);
|
|
119
|
+
walk.read.add(absFile);
|
|
110
120
|
const file = Bun.file(absFile);
|
|
111
121
|
if (!(await file.exists())) return;
|
|
112
122
|
const source = await file.text();
|
|
@@ -119,11 +129,12 @@ export class BarrelAnalyzer {
|
|
|
119
129
|
authoritative.delete("default");
|
|
120
130
|
|
|
121
131
|
const attributed = new Set<string>();
|
|
122
|
-
const attribute = (listBody: string, subpath: string) => {
|
|
132
|
+
const attribute = (listBody: string, subpath: string, source?: BarrelExportMap | null) => {
|
|
123
133
|
for (const item of parseNamedList(listBody)) {
|
|
124
134
|
if (item.isType || item.imported === "default" || !authoritative.has(item.local)) continue;
|
|
125
135
|
attributed.add(item.local);
|
|
126
|
-
if (
|
|
136
|
+
if (map.has(item.local)) continue;
|
|
137
|
+
map.set(item.local, source?.get(item.imported) ?? { subpath, originalName: item.imported });
|
|
127
138
|
}
|
|
128
139
|
};
|
|
129
140
|
|
|
@@ -152,7 +163,7 @@ export class BarrelAnalyzer {
|
|
|
152
163
|
const targetAbs = await this.#resolveRel(absFile, spec);
|
|
153
164
|
if (!targetAbs) continue;
|
|
154
165
|
const targetSubpath = this.#subpathFor(pkg, targetAbs);
|
|
155
|
-
if (targetSubpath) attribute(namedList, targetSubpath);
|
|
166
|
+
if (targetSubpath) attribute(namedList, targetSubpath, await this.#exportsOf(targetAbs, pkg, walk));
|
|
156
167
|
}
|
|
157
168
|
}
|
|
158
169
|
|
|
@@ -172,17 +183,27 @@ export class BarrelAnalyzer {
|
|
|
172
183
|
|
|
173
184
|
for (const spec of starSpecs) {
|
|
174
185
|
const targetAbs = await this.#resolveRel(absFile, spec);
|
|
175
|
-
if (targetAbs) await this.#walk(targetAbs, pkg, map,
|
|
186
|
+
if (targetAbs) await this.#walk(targetAbs, pkg, map, walk);
|
|
176
187
|
}
|
|
177
188
|
}
|
|
178
189
|
|
|
190
|
+
//? A name re-exported by name from a barrel is mapped to the file that declares it, as a star walk would map it:
|
|
191
|
+
//? a rewrite to the barrel itself would load every module behind it.
|
|
192
|
+
async #exportsOf(absFile: string, pkg: PackageEntry, walk: BarrelWalk): Promise<BarrelExportMap | null> {
|
|
193
|
+
if (walk.following.has(absFile)) return null;
|
|
194
|
+
const map: BarrelExportMap = new Map();
|
|
195
|
+
const following = new Set([...walk.following, absFile]);
|
|
196
|
+
await this.#walk(absFile, pkg, map, { visited: new Set(), read: walk.read, following });
|
|
197
|
+
return map;
|
|
198
|
+
}
|
|
199
|
+
|
|
179
200
|
#scanExports(source: string, absFile: string): Set<string> {
|
|
180
201
|
try {
|
|
181
202
|
const transpiler = [".tsx", ".jsx"].includes(path.extname(absFile)) ? this.#tsxTranspiler : this.#tsTranspiler;
|
|
182
|
-
const { exports } = transpiler.scan(source);
|
|
203
|
+
const { exports } = transpiler.scan(source.replaceAll(MACRO_ATTR_RE, ""));
|
|
183
204
|
return new Set(exports);
|
|
184
205
|
} catch (err) {
|
|
185
|
-
this.#logger.error(`scan failed: ${(err as Error).message}`);
|
|
206
|
+
this.#logger.error(`scan failed for ${absFile}: ${(err as Error).message}`);
|
|
186
207
|
return new Set();
|
|
187
208
|
}
|
|
188
209
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { realpathSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { tempDirs, writeText } from "../testHelpers";
|
|
4
|
+
import { tempDirs, writeText } from "../test/testHelpers";
|
|
5
5
|
import { createBrowserDirnamePlugin } from "./browserDirnamePlugin";
|
|
6
6
|
|
|
7
7
|
const makeTempRoot = tempDirs("akan-devkit-browser-dirname-");
|
|
@@ -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 { createExternalizeFrameworkPlugin } from "./externalizeFrameworkPlugin";
|
|
5
5
|
|
|
6
6
|
const makeTempRoot = tempDirs("akan-devkit-externalize-");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { symlink } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { tempDirs, writeText } from "../testHelpers";
|
|
4
|
+
import { tempDirs, writeText } from "../test/testHelpers";
|
|
5
5
|
import { createBarrelImportsPlugin } from "./barrelImportsPlugin";
|
|
6
6
|
import { McpAppPageTrimmer } from "./mcpAppPageTrimmer";
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { tempDirs, writeText } from "../testHelpers";
|
|
3
|
+
import { tempDirs, writeText } from "../test/testHelpers";
|
|
4
4
|
import { PureLazyMarker } from "./pureLazyMarker";
|
|
5
5
|
|
|
6
6
|
const makeTempRoot = tempDirs("akan-pure-lazy-");
|
|
@@ -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 { createServerEnvPlugin } from "./serverEnvPlugin";
|
|
5
5
|
|
|
6
6
|
const makeTempRoot = tempDirs("akan-devkit-server-env-");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Logger } from "akanjs/common";
|
|
4
|
-
import { tempDirs, writeText as write } from "../testHelpers";
|
|
4
|
+
import { tempDirs, writeText as write } from "../test/testHelpers";
|
|
5
5
|
import { ServerEnvProfile } from "./serverEnvProfile";
|
|
6
6
|
|
|
7
7
|
const makeTempRoot = tempDirs("akan-devkit-server-env-profile-");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { tempDirs, writeText } from "../testHelpers";
|
|
3
|
+
import { tempDirs, writeText } from "../test/testHelpers";
|
|
4
4
|
import { SideEffectImportOrder } from "./sideEffectImportOrder";
|
|
5
5
|
|
|
6
6
|
const makeTempRoot = tempDirs("akan-devkit-side-effect-order-");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { ApplicationBuildReporter } from "../applicationBuildReporter";
|
|
5
|
-
import { tempDirs, writeText as write } from "../testHelpers";
|
|
4
|
+
import { ApplicationBuildReporter } from "../app/applicationBuildReporter";
|
|
5
|
+
import { tempDirs, writeText as write } from "../test/testHelpers";
|
|
6
6
|
import { BarrelAnalyzer, type BarrelExportTarget } from "./barrelAnalyzer";
|
|
7
7
|
import { createTsconfigPackageResolver, rewriteBarrelImports } from "./barrelImportsPlugin";
|
|
8
8
|
import {
|
|
@@ -209,6 +209,56 @@ describe("BarrelAnalyzer and rewriteBarrelImports", () => {
|
|
|
209
209
|
expect(map?.get("OnlyA")).toEqual({ subpath: "@scope/pkg/a", originalName: "OnlyA" });
|
|
210
210
|
});
|
|
211
211
|
|
|
212
|
+
test("a name re-exported by name from a sub-barrel maps to the file that declares it", async () => {
|
|
213
|
+
const root = await makeTempRoot();
|
|
214
|
+
const pkgDir = path.join(root, "pkg");
|
|
215
|
+
await write(
|
|
216
|
+
path.join(pkgDir, "index.ts"),
|
|
217
|
+
'export { A, Bee as B2 } from "./sub";\nexport { C } from "./cycleA";\n',
|
|
218
|
+
);
|
|
219
|
+
await write(path.join(pkgDir, "sub", "index.ts"), 'export * from "./a";\nexport { B as Bee } from "./b";\n');
|
|
220
|
+
await write(path.join(pkgDir, "sub", "a.ts"), "export const A = 1;\n");
|
|
221
|
+
await write(path.join(pkgDir, "sub", "b.ts"), "export const B = 2;\n");
|
|
222
|
+
await write(path.join(pkgDir, "cycleA.ts"), 'export { C } from "./cycleB";\n');
|
|
223
|
+
await write(path.join(pkgDir, "cycleB.ts"), 'export { C } from "./cycleA";\n');
|
|
224
|
+
const analyzer = new BarrelAnalyzer({
|
|
225
|
+
resolvePackage: async () => ({ pkgName: "@scope/pkg", entryFile: path.join(pkgDir, "index.ts"), pkgDir }),
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const map = await analyzer.analyze("@scope/pkg");
|
|
229
|
+
expect(map?.get("A")).toEqual({ subpath: "@scope/pkg/sub/a", originalName: "A" });
|
|
230
|
+
expect(map?.get("B2")).toEqual({ subpath: "@scope/pkg/sub/b", originalName: "B" });
|
|
231
|
+
expect(map?.get("C")).toEqual({ subpath: "@scope/pkg/cycleA", originalName: "C" });
|
|
232
|
+
expect(
|
|
233
|
+
(await analyzer.filesOf("@scope/pkg"))
|
|
234
|
+
.map((file) => path.relative(pkgDir, file))
|
|
235
|
+
.sort((a, b) => a.localeCompare(b)),
|
|
236
|
+
).toEqual(["cycleA.ts", "cycleB.ts", "index.ts", "sub/a.ts", "sub/b.ts", "sub/index.ts"]);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test("a module that calls a macro import is still read, so a name it re-exports maps past it", async () => {
|
|
240
|
+
const root = await makeTempRoot();
|
|
241
|
+
const pkgDir = path.join(root, "app");
|
|
242
|
+
await write(path.join(pkgDir, "client.ts"), 'export { usePage, sig } from "./lib/useClient";\n');
|
|
243
|
+
await write(
|
|
244
|
+
path.join(pkgDir, "lib", "useClient.ts"),
|
|
245
|
+
[
|
|
246
|
+
'import { getSerializedSignal } from "./sig" with { type: "macro" };',
|
|
247
|
+
'export { sig } from "./sigs";',
|
|
248
|
+
"export const usePage = getSerializedSignal();",
|
|
249
|
+
"",
|
|
250
|
+
].join("\n"),
|
|
251
|
+
);
|
|
252
|
+
await write(path.join(pkgDir, "lib", "sigs.ts"), "export const sig = 1;\n");
|
|
253
|
+
const analyzer = new BarrelAnalyzer({
|
|
254
|
+
resolvePackage: async () => ({ pkgName: "@apps/app", entryFile: path.join(pkgDir, "client.ts"), pkgDir }),
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
const map = await analyzer.analyze("@apps/app");
|
|
258
|
+
expect(map?.get("sig")).toEqual({ subpath: "@apps/app/lib/sigs", originalName: "sig" });
|
|
259
|
+
expect(map?.get("usePage")).toEqual({ subpath: "@apps/app/lib/useClient", originalName: "usePage" });
|
|
260
|
+
});
|
|
261
|
+
|
|
212
262
|
test("two analyses that interleave each keep their own place in their barrel", async () => {
|
|
213
263
|
const root = await makeTempRoot();
|
|
214
264
|
const barrels = { first: ["a1", "a2", "a3"], second: ["b1", "b2"] } as const;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { mkdir, 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 { createTsconfigPackageResolver } from "./barrelImportsPlugin";
|
|
6
6
|
|
|
7
7
|
const makeTempRoot = tempDirs("akan-devkit-resolver-");
|
|
@@ -3,9 +3,9 @@ import { readFile, stat, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import type { AddressInfo } from "node:net";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { Client, type Connection, Server, utils } from "ssh2";
|
|
6
|
+
import { createTempApp, isolateEnv, tempRoots } from "../test/testHelpers";
|
|
6
7
|
import { createTunnel } from "./createTunnel";
|
|
7
8
|
import { SshHostKeys } from "./sshHostKeys";
|
|
8
|
-
import { createTempApp, isolateEnv, tempRoots } from "./testHelpers";
|
|
9
9
|
|
|
10
10
|
const freePort = () => {
|
|
11
11
|
const listener = Bun.listen({ hostname: "127.0.0.1", port: 0, socket: { data() {} } });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import type { ConnectConfig } from "ssh2";
|
|
3
|
-
import { type AppExecutor, WorkspaceExecutor } from "
|
|
4
|
-
import { ShellOnlyEnv } from "
|
|
3
|
+
import { type AppExecutor, WorkspaceExecutor } from "../executors";
|
|
4
|
+
import { ShellOnlyEnv } from "../util/shellOnlyEnv";
|
|
5
5
|
import { SshHostKeys } from "./sshHostKeys";
|
|
6
6
|
import { createSshTunnel } from "./sshTunnel";
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { ConfigLock } from "
|
|
5
|
-
import { FileSys } from "
|
|
4
|
+
import { ConfigLock } from "../cloud/configLock";
|
|
5
|
+
import { FileSys } from "../util/fileSys";
|
|
6
6
|
|
|
7
7
|
type KnownHosts = Record<string, string>;
|
|
8
8
|
|
|
@@ -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 { ProjectTypecheck } from "./projectTypecheck";
|
|
5
5
|
import { TypecheckFailure } from "./typecheckFailure";
|
|
6
6
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mkdir, rm } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import
|
|
3
|
+
import { CliError } from "../commandDecorators/cliError";
|
|
4
|
+
import type { TypecheckRecord } from "./typeChecker";
|
|
4
5
|
import { TypecheckFailure } from "./typecheckFailure";
|
|
5
6
|
|
|
6
7
|
export interface ProjectTypecheckOptions {
|
|
@@ -69,7 +70,10 @@ export class ProjectTypecheck {
|
|
|
69
70
|
if (exitCode === 0) return;
|
|
70
71
|
const records = report === "records" ? ProjectTypecheck.#parseRecords(stdout) : null;
|
|
71
72
|
if (records?.length) throw new TypecheckFailure(records);
|
|
72
|
-
|
|
73
|
+
const output = (stderr || stdout).trim();
|
|
74
|
+
if (exitCode === TypecheckFailure.workerExitCode && report === "pretty")
|
|
75
|
+
throw new CliError("checkFailed", output || "Typecheck failed");
|
|
76
|
+
throw new Error(output || `Typecheck failed with exit code ${exitCode}`);
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
static #parseRecords(stdout: string): TypecheckRecord[] | null {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import * as ts from "typescript";
|
|
4
|
-
import { tempDirs, writeJson, writeText } from "
|
|
4
|
+
import { tempDirs, writeJson, writeText } from "../test/testHelpers";
|
|
5
5
|
import { TypeChecker } from "./typeChecker";
|
|
6
6
|
|
|
7
7
|
const makeTempRoot = tempDirs("akan-devkit-type-checker-");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Logger } from "akanjs/common";
|
|
2
|
-
import { TypeChecker } from "
|
|
2
|
+
import { TypeChecker } from "./typeChecker";
|
|
3
|
+
import { TypecheckFailure } from "./typecheckFailure";
|
|
3
4
|
|
|
4
5
|
try {
|
|
5
6
|
const filePath = process.env.AKAN_TYPECHECK_FILE;
|
|
@@ -28,11 +29,11 @@ try {
|
|
|
28
29
|
//? Not process.cwd(): that is the realpath (/private/var on macOS) while TypeScript keeps the spelling it was given.
|
|
29
30
|
const root = process.env.AKAN_TYPECHECK_ROOT ?? process.cwd();
|
|
30
31
|
process.stdout.write(JSON.stringify(TypeChecker.toRecords(result.errors, root)));
|
|
31
|
-
process.exit(result.errors.length > 0 ?
|
|
32
|
+
process.exit(result.errors.length > 0 ? TypecheckFailure.workerExitCode : 0);
|
|
32
33
|
}
|
|
33
34
|
if (result.errors.length > 0) {
|
|
34
35
|
console.error(result.message);
|
|
35
|
-
process.exit(
|
|
36
|
+
process.exit(TypecheckFailure.workerExitCode);
|
|
36
37
|
}
|
|
37
38
|
} catch (error) {
|
|
38
39
|
console.error(error instanceof Error ? error.message : String(error));
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CliError } from "../commandDecorators/cliError";
|
|
2
|
+
import type { TypecheckRecord } from "./typeChecker";
|
|
3
|
+
|
|
4
|
+
export class TypecheckFailure extends CliError<"checkFailed"> {
|
|
5
|
+
//? The worker's exit when the project has type errors, so its crash, which exits 1, is told apart.
|
|
6
|
+
static readonly workerExitCode = 3;
|
|
2
7
|
|
|
3
|
-
export class TypecheckFailure extends Error {
|
|
4
8
|
constructor(readonly records: TypecheckRecord[]) {
|
|
5
9
|
super(
|
|
10
|
+
"checkFailed",
|
|
6
11
|
records
|
|
7
12
|
.slice(0, 20)
|
|
8
13
|
.map((record) => `${record.file ?? "-"}:${record.line}:${record.col} ${record.code} ${record.message}`)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export class ErrorReport {
|
|
5
|
+
static readonly shownNestedErrors = 20;
|
|
6
|
+
|
|
7
|
+
static format(error: unknown, workspaceRoot = process.cwd()): string {
|
|
8
|
+
return ErrorReport.#format(error, workspaceRoot, []);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static #format(error: unknown, workspaceRoot: string, ancestors: readonly unknown[]): string {
|
|
12
|
+
if (ancestors.includes(error)) return "[circular]";
|
|
13
|
+
const chain = [...ancestors, error];
|
|
14
|
+
if (error instanceof AggregateError) {
|
|
15
|
+
const shown = error.errors.slice(0, ErrorReport.shownNestedErrors);
|
|
16
|
+
const hidden = error.errors.length - shown.length;
|
|
17
|
+
const nestedMessages = [
|
|
18
|
+
...shown.map(
|
|
19
|
+
(nestedError, index) =>
|
|
20
|
+
ErrorReport.#format(nestedError, workspaceRoot, chain).trim() || `Unknown error ${index + 1}`,
|
|
21
|
+
),
|
|
22
|
+
...(hidden > 0 ? [`…and ${hidden} more`] : []),
|
|
23
|
+
]
|
|
24
|
+
.map((message) => message.replace(/^/gm, " "))
|
|
25
|
+
.join("\n");
|
|
26
|
+
const message = nestedMessages ? `${error.message}\n${nestedMessages}` : error.message;
|
|
27
|
+
return `${message}${ErrorReport.#causeOf(error, workspaceRoot, chain)}`;
|
|
28
|
+
}
|
|
29
|
+
if (error instanceof Error)
|
|
30
|
+
return `${ErrorReport.#withLocation(error.message, error, workspaceRoot)}${ErrorReport.#causeOf(error, workspaceRoot, chain)}`;
|
|
31
|
+
if (typeof error === "object" && error !== null && "message" in error)
|
|
32
|
+
return ErrorReport.#withLocation(String(error.message), error, workspaceRoot);
|
|
33
|
+
return String(error);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static #causeOf(error: Error, workspaceRoot: string, chain: readonly unknown[]): string {
|
|
37
|
+
return error.cause ? `\nCaused by: ${ErrorReport.#format(error.cause, workspaceRoot, chain)}` : "";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static #withLocation(message: string, error: object, workspaceRoot: string): string {
|
|
41
|
+
const { position } = error as { position?: { file: string; line: number; column: number } | null };
|
|
42
|
+
if (!position?.file) return message;
|
|
43
|
+
const file = ErrorReport.#relativeToWorkspace(position.file, workspaceRoot);
|
|
44
|
+
const location = position.line > 0 ? `${file}:${position.line}:${position.column}` : file;
|
|
45
|
+
return message.includes(location) ? message : message.replace(/^.*/, (headline) => `${headline} (${location})`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Bun names the file by its realpath, so a workspace root reached through a symlink is matched by its own too.
|
|
49
|
+
static #relativeToWorkspace(file: string, workspaceRoot: string): string {
|
|
50
|
+
if (!path.isAbsolute(file)) return file;
|
|
51
|
+
for (const root of [workspaceRoot, ErrorReport.#realpathOf(workspaceRoot)]) {
|
|
52
|
+
const relative = path.relative(root, file);
|
|
53
|
+
if (!relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative))
|
|
54
|
+
return relative.replaceAll(path.sep, "/");
|
|
55
|
+
}
|
|
56
|
+
return file;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static #realpathOf(dir: string): string {
|
|
60
|
+
try {
|
|
61
|
+
return realpathSync(dir);
|
|
62
|
+
} catch {
|
|
63
|
+
return dir;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { formatWithBiome, hasBiome } from "../test/testHelpers";
|
|
2
3
|
import { JsonFormatter } from "./jsonFormatter";
|
|
3
|
-
import { formatWithBiome, hasBiome } from "./testHelpers";
|
|
4
4
|
|
|
5
5
|
const pad = (length: number) => "x".repeat(length);
|
|
6
6
|
const thousands = Array.from({ length: 40 }, (_, idx) => idx * 1000);
|
package/workflow/artifacts.ts
CHANGED
|
@@ -95,11 +95,11 @@ export const createWorkflowApplyReport = ({
|
|
|
95
95
|
postApplyChecks?: WorkflowApplyReport["postApplyChecks"];
|
|
96
96
|
recommendations?: WorkflowApplyReport["recommendations"];
|
|
97
97
|
}): WorkflowApplyReport => {
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
action: inferNextActionCode(action, diagnostics)
|
|
102
|
-
|
|
98
|
+
const status = workflowStatus(diagnostics);
|
|
99
|
+
const validationCommands = status === "failed" ? [] : (recommendedValidationCommands ?? commands);
|
|
100
|
+
const nextActionsWithIntent = nextActions
|
|
101
|
+
.map((action) => ({ ...action, action: inferNextActionCode(action, diagnostics) }))
|
|
102
|
+
.filter((action) => status !== "failed" || action.action !== "validate");
|
|
103
103
|
if (sourceChangeBlocked(diagnostics) && !nextActionsWithIntent.some((action) => action.action === "blocked")) {
|
|
104
104
|
nextActionsWithIntent.unshift({
|
|
105
105
|
command: `akan workflow explain ${workflow}`,
|
|
@@ -111,12 +111,13 @@ export const createWorkflowApplyReport = ({
|
|
|
111
111
|
(left, right) => nextActionPriority(left, diagnostics) - nextActionPriority(right, diagnostics),
|
|
112
112
|
);
|
|
113
113
|
const sourceFilesChanged = uniqueBy(changedFiles, (file) => `${file.action}:${file.path}:${file.reason}`);
|
|
114
|
-
const generatedFilesSynced =
|
|
114
|
+
const generatedFilesSynced =
|
|
115
|
+
status === "failed" ? [] : uniqueBy(generatedFiles, (file) => `${file.action}:${file.path}:${file.reason}`);
|
|
115
116
|
return {
|
|
116
117
|
schemaVersion: 1,
|
|
117
118
|
workflow,
|
|
118
119
|
mode,
|
|
119
|
-
status
|
|
120
|
+
status,
|
|
120
121
|
summary: {
|
|
121
122
|
sourceFilesChanged,
|
|
122
123
|
generatedFilesSynced,
|