@akanjs/devkit 3.2.0-rc.8 → 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 -528
- 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
|
@@ -8,9 +8,22 @@ export interface StoreAccessCount {
|
|
|
8
8
|
accessCount: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
const formSetterPrefixes = ["set", "add", "sub", "addOrSub", "upload"];
|
|
12
|
+
const startsUpper = (text: string) => /^[A-Z]/.test(text);
|
|
13
|
+
|
|
14
|
+
const isFormSetterName = (name: string) => {
|
|
15
|
+
if (!/^\w+$/.test(name)) return false;
|
|
16
|
+
if (name.startsWith("writeOn")) return startsUpper(name.slice("writeOn".length));
|
|
17
|
+
return formSetterPrefixes.some(
|
|
18
|
+
(prefix) =>
|
|
19
|
+
name.startsWith(prefix) &&
|
|
20
|
+
startsUpper(name.slice(prefix.length)) &&
|
|
21
|
+
/On[A-Z]/.test(name.slice(prefix.length + 1)),
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
11
25
|
//? A generated form setter only binds a field to its control: a long form is a size breach, not a busy component.
|
|
12
26
|
export class StoreAccessScanner {
|
|
13
|
-
static readonly #formSetter = /^(?:(?:set|add|sub|addOrSub|upload)[A-Z]\w*On|writeOn)[A-Z]\w*$/;
|
|
14
27
|
readonly #index: WritingActionIndex;
|
|
15
28
|
|
|
16
29
|
constructor(index: WritingActionIndex) {
|
|
@@ -64,7 +77,7 @@ export class StoreAccessScanner {
|
|
|
64
77
|
access.name.text === "do" &&
|
|
65
78
|
ts.isPropertyAccessExpression(action) &&
|
|
66
79
|
action.expression === access &&
|
|
67
|
-
|
|
80
|
+
isFormSetterName(action.name.text) &&
|
|
68
81
|
!this.#index.isWritingAction(action.name.text)
|
|
69
82
|
);
|
|
70
83
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import ignore from "ignore";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
import { AbstractDoc } from "./abstractDoc";
|
|
6
|
+
import type { SourceFileInfo } from "./qualityScanner";
|
|
7
|
+
|
|
8
|
+
type IgnoreFilter = ReturnType<typeof ignore>;
|
|
9
|
+
|
|
10
|
+
export class WorkspaceSourceFiles {
|
|
11
|
+
readonly #workspaceRoot: string;
|
|
12
|
+
|
|
13
|
+
constructor(workspaceRoot: string) {
|
|
14
|
+
this.#workspaceRoot = workspaceRoot;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async collect(dirs: string[] = ["apps", "libs"]) {
|
|
18
|
+
const ignoreFilter = ignore().add(await this.#readGitIgnore());
|
|
19
|
+
const files = new Set<string>();
|
|
20
|
+
for (const dir of dirs) {
|
|
21
|
+
const absoluteDir = path.join(this.#workspaceRoot, dir);
|
|
22
|
+
if (await WorkspaceSourceFiles.#isDirectory(absoluteDir)) await this.#walk(absoluteDir, ignoreFilter, files);
|
|
23
|
+
}
|
|
24
|
+
return [...files].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async read(file: string): Promise<SourceFileInfo> {
|
|
28
|
+
const absolutePath = path.join(this.#workspaceRoot, file);
|
|
29
|
+
const content = await readFile(absolutePath, "utf8");
|
|
30
|
+
const scriptKind = file.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
31
|
+
return {
|
|
32
|
+
file,
|
|
33
|
+
absolutePath,
|
|
34
|
+
content,
|
|
35
|
+
sourceFile: ts.createSourceFile(file, content, ts.ScriptTarget.Latest, true, scriptKind),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async #readGitIgnore() {
|
|
40
|
+
const gitIgnorePath = path.join(this.#workspaceRoot, ".gitignore");
|
|
41
|
+
if (!(await Bun.file(gitIgnorePath).exists())) return [];
|
|
42
|
+
return (await readFile(gitIgnorePath, "utf8")).split(/\r?\n/);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async #walk(currentPath: string, ignoreFilter: IgnoreFilter, files: Set<string>) {
|
|
46
|
+
const entries = await readdir(currentPath, { withFileTypes: true });
|
|
47
|
+
for (const entry of entries) {
|
|
48
|
+
const absolutePath = path.join(currentPath, entry.name);
|
|
49
|
+
const relativePath = path.relative(this.#workspaceRoot, absolutePath).split(path.sep).join("/");
|
|
50
|
+
if (WorkspaceSourceFiles.#shouldSkip(relativePath, entry.isDirectory(), ignoreFilter)) continue;
|
|
51
|
+
|
|
52
|
+
if (entry.isDirectory()) {
|
|
53
|
+
await this.#walk(absolutePath, ignoreFilter, files);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if ((relativePath.endsWith(".ts") || relativePath.endsWith(".tsx")) && !relativePath.endsWith(".d.ts")) {
|
|
57
|
+
files.add(relativePath);
|
|
58
|
+
} else if (AbstractDoc.isAbstractPath(relativePath)) {
|
|
59
|
+
files.add(relativePath);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static #shouldSkip(relativePath: string, isDirectory: boolean, ignoreFilter: IgnoreFilter) {
|
|
65
|
+
const ignorePath = isDirectory ? `${relativePath}/` : relativePath;
|
|
66
|
+
return (
|
|
67
|
+
relativePath === ".git" ||
|
|
68
|
+
relativePath.includes("/.git/") ||
|
|
69
|
+
relativePath.includes("/node_modules/") ||
|
|
70
|
+
ignoreFilter.ignores(relativePath) ||
|
|
71
|
+
ignoreFilter.ignores(ignorePath)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static async #isDirectory(absolutePath: string) {
|
|
76
|
+
try {
|
|
77
|
+
return (await stat(absolutePath)).isDirectory();
|
|
78
|
+
} catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { describe, expect, setDefaultTimeout, test } from "bun:test";
|
|
1
|
+
import { describe, expect, setDefaultTimeout, spyOn, test } from "bun:test";
|
|
2
2
|
import { mkdir, readdir, rm } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { Executor, WorkspaceExecutor } from "
|
|
5
|
-
import {
|
|
4
|
+
import { Executor, WorkspaceExecutor } from "../executors";
|
|
5
|
+
import { isolateEnv, tempDirs, writeText as write } from "../test/testHelpers";
|
|
6
|
+
import { FileSys } from "../util/fileSys";
|
|
6
7
|
import { Subspace } from "./subspace";
|
|
7
8
|
import { SubspaceClone } from "./subspaceClone";
|
|
8
9
|
import { SubspaceConfig } from "./subspaceConfig";
|
|
9
10
|
import { SubspaceReport } from "./subspaceReport";
|
|
10
|
-
import { isolateEnv, tempDirs, writeText as write } from "./testHelpers";
|
|
11
11
|
|
|
12
12
|
//? Each case drives several real git clones and pushes; on a 4-core Windows VM that alone lands at 2-5s.
|
|
13
13
|
setDefaultTimeout(20_000);
|
|
@@ -214,6 +214,21 @@ describe("Subspace push", () => {
|
|
|
214
214
|
expect(await FileSys.fileExists(path.join(subspaceRoot, "libs/moved-kit/common/renamed.ts"))).toBe(true);
|
|
215
215
|
});
|
|
216
216
|
|
|
217
|
+
test("puts `--` before every repo and remote it hands git, so none reads as an option", async () => {
|
|
218
|
+
const { bareRoot, clonePath, subspace } = await makeMirror("dash-served", "dash-private", "dash-kit");
|
|
219
|
+
const spawn = spyOn(Executor.prototype, "spawn");
|
|
220
|
+
try {
|
|
221
|
+
expect((await subspace.push("develop", { verify: false })).outcome).toBe("pushed");
|
|
222
|
+
const gitArgs = spawn.mock.calls.filter(([command]) => command === "git").map(([, args]) => args);
|
|
223
|
+
expect(gitArgs).toContainEqual(["fetch", "--quiet", "--", "subspace-acme", "develop"]);
|
|
224
|
+
expect(gitArgs).toContainEqual(["clone", "--quiet", "--", bareRoot, clonePath]);
|
|
225
|
+
expect(gitArgs).toContainEqual(["fetch", "--quiet", "--", "origin", "develop"]);
|
|
226
|
+
expect(gitArgs).toContainEqual(["push", "--quiet", "--", "origin", "develop"]);
|
|
227
|
+
} finally {
|
|
228
|
+
spawn.mockRestore();
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
217
232
|
test("is idempotent — a second push with no workspace change is skipped", async () => {
|
|
218
233
|
const { subspace } = await makeMirror("idem-served", "idem-private", "idem-kit");
|
|
219
234
|
expect((await subspace.push("develop", { verify: false })).outcome).toBe("pushed");
|
|
@@ -486,6 +501,12 @@ describe("Subspace pull", () => {
|
|
|
486
501
|
});
|
|
487
502
|
|
|
488
503
|
describe("SubspaceConfig", () => {
|
|
504
|
+
test("refuses a repo that git would read as an option", () => {
|
|
505
|
+
expect(
|
|
506
|
+
() => new SubspaceConfig({ subspaces: [{ name: "a", repo: "--upload-pack=touch pwned", apps: ["one"] }] }),
|
|
507
|
+
).toThrow(/reads as a git option/);
|
|
508
|
+
});
|
|
509
|
+
|
|
489
510
|
test("refuses one app claimed by two subspaces", () => {
|
|
490
511
|
expect(
|
|
491
512
|
() =>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { mkdir } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { toError } from "akanjs/common";
|
|
4
|
-
import { AppExecutor, type WorkspaceExecutor } from "
|
|
5
|
-
import { FileSys } from "
|
|
6
|
-
import { LibSource } from "
|
|
7
|
-
import { SlicePlanner } from "
|
|
4
|
+
import { AppExecutor, type WorkspaceExecutor } from "../executors";
|
|
5
|
+
import { FileSys } from "../util/fileSys";
|
|
6
|
+
import { LibSource } from "../workspace/libSource";
|
|
7
|
+
import { SlicePlanner } from "../workspace/slicePlanner";
|
|
8
8
|
import { SubspaceClone } from "./subspaceClone";
|
|
9
9
|
import type { SubspaceConfig, SubspaceDeclaration } from "./subspaceConfig";
|
|
10
10
|
|
|
@@ -146,7 +146,7 @@ export class Subspace {
|
|
|
146
146
|
if (remotes.includes(this.#remote)) await this.#git(["remote", "set-url", this.#remote, this.#declaration.repo]);
|
|
147
147
|
else await this.#git(["remote", "add", this.#remote, this.#declaration.repo]);
|
|
148
148
|
try {
|
|
149
|
-
await this.#git(["fetch", "--quiet", this.#remote, branch]);
|
|
149
|
+
await this.#git(["fetch", "--quiet", "--", this.#remote, branch]);
|
|
150
150
|
return true;
|
|
151
151
|
} catch {
|
|
152
152
|
//? A subspace that has never had this branch is not an error here — `push` refuses it by name.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { mkdir, readdir, rename, rm } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { toError } from "akanjs/common";
|
|
4
|
-
import { Executor, WorkspaceExecutor } from "
|
|
5
|
-
import { FileSys } from "
|
|
6
|
-
import { LibSource } from "
|
|
7
|
-
import { type SlicePlan, SlicePlanner } from "
|
|
4
|
+
import { Executor, WorkspaceExecutor } from "../executors";
|
|
5
|
+
import { FileSys } from "../util/fileSys";
|
|
6
|
+
import { LibSource } from "../workspace/libSource";
|
|
7
|
+
import { type SlicePlan, SlicePlanner } from "../workspace/slicePlanner";
|
|
8
|
+
import type { PackageJson } from "../workspace/types";
|
|
8
9
|
import { SubspaceConfig, type SubspaceDeclaration } from "./subspaceConfig";
|
|
9
|
-
import type { PackageJson } from "./types";
|
|
10
10
|
|
|
11
11
|
export class SubspaceClone {
|
|
12
12
|
static readonly anchorFile = "akan.subspace.json";
|
|
@@ -53,9 +53,9 @@ export class SubspaceClone {
|
|
|
53
53
|
if (!(await FileSys.dirExists(path.join(this.#clonePath, ".git")))) {
|
|
54
54
|
await rm(this.#clonePath, { recursive: true, force: true });
|
|
55
55
|
await mkdir(path.dirname(this.#clonePath), { recursive: true });
|
|
56
|
-
await this.#workspace.spawn("git", ["clone", "--quiet", this.#declaration.repo, this.#clonePath]);
|
|
56
|
+
await this.#workspace.spawn("git", ["clone", "--quiet", "--", this.#declaration.repo, this.#clonePath]);
|
|
57
57
|
}
|
|
58
|
-
await this.#clone.spawn("git", ["fetch", "--quiet", "origin", branch]);
|
|
58
|
+
await this.#clone.spawn("git", ["fetch", "--quiet", "--", "origin", branch]);
|
|
59
59
|
await this.#clone.spawn("git", ["checkout", "--quiet", "-f", "-B", branch, `origin/${branch}`]);
|
|
60
60
|
await this.#clone.spawn("git", ["clean", "-qfd"]);
|
|
61
61
|
}
|
|
@@ -116,7 +116,7 @@ export class SubspaceClone {
|
|
|
116
116
|
const message = `${SubspaceClone.syncSubjectPrefix}${this.#workspace.repoName}@${sha}`;
|
|
117
117
|
await this.#clone.spawn("git", ["commit", "--quiet", "-m", message]);
|
|
118
118
|
//* Never force: a diverged subspace holds customer commits, and `pull` is how those come back.
|
|
119
|
-
await this.#clone.spawn("git", ["push", "--quiet", "origin", branch]);
|
|
119
|
+
await this.#clone.spawn("git", ["push", "--quiet", "--", "origin", branch]);
|
|
120
120
|
return (await this.#clone.spawn("git", ["rev-parse", "--short", "HEAD"])).trim();
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SubspaceConfigInput, SubspaceDeclaration } from "akanjs";
|
|
2
|
-
import type { WorkspaceExecutor } from "
|
|
2
|
+
import type { WorkspaceExecutor } from "../executors";
|
|
3
3
|
|
|
4
4
|
export type { SubspaceConfigInput, SubspaceDeclaration };
|
|
5
5
|
|
|
@@ -32,6 +32,10 @@ export class SubspaceConfig {
|
|
|
32
32
|
for (const subspace of this.subspaces) {
|
|
33
33
|
if (!subspace.name || !subspace.repo)
|
|
34
34
|
throw new Error(`${SubspaceConfig.source}: every subspace needs a name and a repo`);
|
|
35
|
+
if (subspace.repo.startsWith("-"))
|
|
36
|
+
throw new Error(
|
|
37
|
+
`${SubspaceConfig.source}: subspace "${subspace.name}" repo "${subspace.repo}" reads as a git option`,
|
|
38
|
+
);
|
|
35
39
|
//? The name is the clone folder under .akan/subspace, which a fresh clone empties first.
|
|
36
40
|
if (!SubspaceConfig.namePattern.test(subspace.name))
|
|
37
41
|
throw new Error(
|
|
@@ -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).split(path.sep).join("/"))
|
|
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
|
|
|
@@ -31,6 +31,28 @@ describe("ProjectTypecheck", () => {
|
|
|
31
31
|
expect((error as Error).message).not.toContain("old.test.ts");
|
|
32
32
|
}, 60_000);
|
|
33
33
|
|
|
34
|
+
test("checks a package whose tsconfig names no include, caching outside it", async () => {
|
|
35
|
+
const root = await makeTempRoot();
|
|
36
|
+
const dir = path.join(root, "pkgs/tool");
|
|
37
|
+
await write(
|
|
38
|
+
path.join(dir, "tsconfig.json"),
|
|
39
|
+
JSON.stringify({ compilerOptions: { strict: true, types: [], target: "esnext", module: "esnext" } }),
|
|
40
|
+
);
|
|
41
|
+
await write(path.join(dir, "index.ts"), 'export const port: number = "8282";\n');
|
|
42
|
+
const cacheDir = path.join(root, ".akan/typecheck/pkgs/tool");
|
|
43
|
+
|
|
44
|
+
const error = await new ProjectTypecheck(dir, root, { ...process.env })
|
|
45
|
+
.checkIncremental(path.join(dir, "tsconfig.json"), cacheDir, "records")
|
|
46
|
+
.catch((e: unknown) => e);
|
|
47
|
+
|
|
48
|
+
expect(error).toBeInstanceOf(TypecheckFailure);
|
|
49
|
+
expect((error as TypecheckFailure).records.map(({ file, code }) => [file, code])).toEqual([
|
|
50
|
+
["pkgs/tool/index.ts", "TS2322"],
|
|
51
|
+
]);
|
|
52
|
+
expect(await Bun.file(path.join(cacheDir, "tsconfig.tsbuildinfo")).exists()).toBe(true);
|
|
53
|
+
expect(await Bun.file(path.join(dir, "tsconfig.tsbuildinfo")).exists()).toBe(false);
|
|
54
|
+
}, 60_000);
|
|
55
|
+
|
|
34
56
|
test("hands back one record per diagnostic when asked for records", async () => {
|
|
35
57
|
const { root, dir } = await project();
|
|
36
58
|
const error = await new ProjectTypecheck(dir, root, { ...process.env })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdir, rm } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { CliError } from "../commandDecorators/cliError";
|
|
4
|
-
import type { TypecheckRecord } from "
|
|
4
|
+
import type { TypecheckRecord } from "./typeChecker";
|
|
5
5
|
import { TypecheckFailure } from "./typecheckFailure";
|
|
6
6
|
|
|
7
7
|
export interface ProjectTypecheckOptions {
|
|
@@ -50,13 +50,21 @@ export class ProjectTypecheck {
|
|
|
50
50
|
return tsconfigPath;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
//? The project's own tsconfig, not one extending it from the cache folder: there the default `include` would
|
|
54
|
+
//? resolve from that folder, which holds no source.
|
|
55
|
+
async checkIncremental(tsconfigPath: string, cacheDir: string, report: "pretty" | "records" = "pretty") {
|
|
56
|
+
await mkdir(cacheDir, { recursive: true });
|
|
57
|
+
await this.check(tsconfigPath, report, path.join(cacheDir, "tsconfig.tsbuildinfo"));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async check(tsconfigPath: string, report: "pretty" | "records" = "pretty", tsBuildInfoFile?: string) {
|
|
54
61
|
const proc = Bun.spawn([process.execPath, await ProjectTypecheck.workerEntry(this.workspaceRoot)], {
|
|
55
62
|
cwd: this.workspaceRoot,
|
|
56
63
|
env: {
|
|
57
64
|
...this.env,
|
|
58
65
|
AKAN_COMMAND_TYPE: "typecheck",
|
|
59
66
|
AKAN_TYPECHECK_TSCONFIG: tsconfigPath,
|
|
67
|
+
...(tsBuildInfoFile ? { AKAN_TYPECHECK_BUILDINFO: tsBuildInfoFile } : {}),
|
|
60
68
|
...(report === "records" ? { AKAN_TYPECHECK_FORMAT: "json", AKAN_TYPECHECK_ROOT: this.workspaceRoot } : {}),
|
|
61
69
|
},
|
|
62
70
|
stdout: "pipe",
|