@akanjs/devkit 3.2.0-rc.9 → 3.2.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -529
- package/DEV_RUNTIME_KNOBS.md +4 -3
- package/README.ko.md +3 -2
- package/README.md +4 -2
- package/akanApp/BackendImportGraph.test.ts +1 -1
- package/akanApp/akanApp.host.test.ts +152 -6
- package/akanApp/akanApp.host.ts +187 -1220
- package/akanApp/akanApp.host.wiring.test.ts +931 -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 +394 -0
- package/akanApp/devBuildStatusBoard.ts +128 -0
- package/akanApp/devBuilder.ts +200 -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/devStartTimeline.test.ts +115 -0
- package/akanApp/devStartTimeline.ts +69 -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 +463 -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} +106 -18
- 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/buildCacheStamp.test.ts +42 -0
- package/frontendBuild/buildCacheStamp.ts +23 -0
- 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/cssCandidateCache.test.ts +70 -1
- package/frontendBuild/cssCandidateCache.ts +17 -10
- 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 +145 -4
- package/frontendBuild/fontOptimizer.ts +103 -18
- 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/ssrBaseArtifactBuilder.test.ts +30 -1
- package/frontendBuild/ssrBaseArtifactBuilder.ts +40 -12
- 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 +16 -5
- package/incrementalBuilder/buildBatchProtocol.ts +3 -0
- package/incrementalBuilder/buildBatchRunner.test.ts +122 -2
- package/incrementalBuilder/buildBatchRunner.ts +17 -4
- package/incrementalBuilder/builderBoot.ts +113 -0
- package/incrementalBuilder/builderBuildStatus.ts +23 -0
- package/incrementalBuilder/builderChannel.test.ts +1 -1
- package/incrementalBuilder/builderChannel.ts +19 -2
- 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 +16 -0
- package/incrementalBuilder/incrementalBuilder.host.ts +7 -1
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +142 -7
- package/incrementalBuilder/incrementalBuilder.proc.ts +82 -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/nativePublicEnv.ts +2 -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/{fileSys.test.ts → util/fileSys.test.ts} +13 -0
- package/{fileSys.ts → util/fileSys.ts} +2 -2
- 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/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
- /package/{selectModel.ts → util/selectModel.ts} +0 -0
- /package/{semver.test.ts → util/semver.test.ts} +0 -0
- /package/{semver.ts → util/semver.ts} +0 -0
- /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
- /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
- /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
- /package/{spinner.ts → util/spinner.ts} +0 -0
- /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
- /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
- /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
- /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
- /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
- /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
- /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
- /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
- /package/{types.ts → workspace/types.ts} +0 -0
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { describe, expect, spyOn, test } from "bun:test";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { lstat, mkdir, readFile, readlink, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { lstat, mkdir, readFile, readlink, rm, stat, utimes, writeFile } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { AkanAppConfig } from "
|
|
6
|
-
import {
|
|
7
|
-
AppExecutor,
|
|
8
|
-
CommandExecutionError,
|
|
9
|
-
Executor,
|
|
10
|
-
type LibExecutor,
|
|
11
|
-
PkgExecutor,
|
|
12
|
-
WorkspaceExecutor,
|
|
13
|
-
} from "./executors";
|
|
14
|
-
import { DevGeneratedIndexSync } from "./frontendBuild/devGeneratedIndexSync";
|
|
15
|
-
import { AppInfo } from "./scanInfo";
|
|
5
|
+
import { AkanAppConfig } from "../akanConfig";
|
|
6
|
+
import { DevGeneratedIndexSync } from "../frontendBuild/devGeneratedIndexSync";
|
|
16
7
|
import {
|
|
17
8
|
createTempApp,
|
|
18
9
|
createTempLib,
|
|
@@ -23,8 +14,10 @@ import {
|
|
|
23
14
|
tempRoots,
|
|
24
15
|
writeJson,
|
|
25
16
|
writeText,
|
|
26
|
-
} from "
|
|
27
|
-
import
|
|
17
|
+
} from "../test/testHelpers";
|
|
18
|
+
import { AppInfo } from "../workspace/scanInfo";
|
|
19
|
+
import type { PackageJson } from "../workspace/types";
|
|
20
|
+
import { AppExecutor, CommandExecutionError, Executor, type LibExecutor, PkgExecutor, WorkspaceExecutor } from "./";
|
|
28
21
|
|
|
29
22
|
isolateEnv();
|
|
30
23
|
const makeTempRoot = tempDirs("akan-devkit-");
|
|
@@ -48,6 +41,27 @@ const rootPackageJson = (extra: Partial<PackageJson> = {}): PackageJson => ({
|
|
|
48
41
|
...extra,
|
|
49
42
|
});
|
|
50
43
|
|
|
44
|
+
describe("executors module graph", () => {
|
|
45
|
+
test("the executors barrel and each file beside it load first in a fresh process", async () => {
|
|
46
|
+
const entries: string[] = [];
|
|
47
|
+
for await (const file of new Bun.Glob("*.ts").scan({ cwd: import.meta.dir }))
|
|
48
|
+
if (!file.endsWith(".test.ts")) entries.push(file);
|
|
49
|
+
const failures = await Promise.all(
|
|
50
|
+
entries.map(async (entry) => {
|
|
51
|
+
const proc = Bun.spawn([process.execPath, "-e", `await import(${JSON.stringify(`./${entry}`)})`], {
|
|
52
|
+
cwd: import.meta.dir,
|
|
53
|
+
stdout: "ignore",
|
|
54
|
+
stderr: "pipe",
|
|
55
|
+
});
|
|
56
|
+
const [code, stderr] = await Promise.all([proc.exited, new Response(proc.stderr).text()]);
|
|
57
|
+
return code === 0 ? null : `${entry}: ${stderr.split("\n").find((line) => line.includes("error:")) ?? stderr}`;
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
expect(entries.length).toBeGreaterThan(8);
|
|
61
|
+
expect(failures.filter((failure) => failure !== null)).toEqual([]);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
51
65
|
describe("Executor filesystem helpers", () => {
|
|
52
66
|
test("reports command failures with command context and captured output", async () => {
|
|
53
67
|
const root = await makeTempRoot();
|
|
@@ -303,7 +317,7 @@ describe("Executor filesystem helpers", () => {
|
|
|
303
317
|
const exec = new Executor("fixture", root);
|
|
304
318
|
|
|
305
319
|
await exec.applyTemplate({ basePath: "app", template: "app", dict: { appName: "demo" }, options: { libs: [] } });
|
|
306
|
-
const templateRoot = path.resolve(import.meta.dir, "
|
|
320
|
+
const templateRoot = path.resolve(import.meta.dir, "../../cli/templates/app/public");
|
|
307
321
|
await expect(readFile(path.join(root, "app/public/apple-touch-icon.png"))).resolves.toEqual(
|
|
308
322
|
await readFile(path.join(templateRoot, "apple-touch-icon.png")),
|
|
309
323
|
);
|
|
@@ -598,7 +612,7 @@ describe("Workspace and app executor environment contracts", () => {
|
|
|
598
612
|
expect(app.getCommandEnv().AKAN_PUBLIC_SERVE_DOMAIN).toBe("example.com");
|
|
599
613
|
});
|
|
600
614
|
|
|
601
|
-
test("akan start clears the dev output and keeps the
|
|
615
|
+
test("akan start clears the dev output and keeps the caches and a native folder from before dist/native", async () => {
|
|
602
616
|
const root = await makeTempRoot();
|
|
603
617
|
process.env.AKAN_PUBLIC_REPO_NAME = "repo";
|
|
604
618
|
process.env.AKAN_PUBLIC_SERVE_DOMAIN = "example.com";
|
|
@@ -612,11 +626,14 @@ describe("Workspace and app executor environment contracts", () => {
|
|
|
612
626
|
"native/desktop/updates/macos-arm64/main.json",
|
|
613
627
|
"native/desktop/build/macos/App.app",
|
|
614
628
|
"cache/bin/ffmpeg",
|
|
629
|
+
"cache/cssCandidates.json",
|
|
630
|
+
"cache/fontCache.json",
|
|
631
|
+
"cache/fonts/Assistant-400-normal-abc.woff2",
|
|
615
632
|
];
|
|
616
633
|
const removed = [
|
|
617
634
|
"artifact/client/app.js",
|
|
635
|
+
"artifact/fontCache.json",
|
|
618
636
|
"generated/dict/index.ts",
|
|
619
|
-
"cache/cssCandidates.json",
|
|
620
637
|
"desktop/server/main.js",
|
|
621
638
|
"mobile/desktop/native/macos/App.app",
|
|
622
639
|
];
|
|
@@ -630,6 +647,30 @@ describe("Workspace and app executor environment contracts", () => {
|
|
|
630
647
|
expect(existsSync(path.join(akan, file))).toBe(false);
|
|
631
648
|
});
|
|
632
649
|
|
|
650
|
+
test("akan start removes a cache temp file a killed start left, and keeps one a running start is writing", async () => {
|
|
651
|
+
const root = await makeTempRoot();
|
|
652
|
+
process.env.AKAN_PUBLIC_REPO_NAME = "repo";
|
|
653
|
+
process.env.AKAN_PUBLIC_SERVE_DOMAIN = "example.com";
|
|
654
|
+
process.env.AKAN_PUBLIC_ENV = "local";
|
|
655
|
+
process.env.PORT_OFFSET = "0";
|
|
656
|
+
await writeJson(path.join(root, "package.json"), rootPackageJson());
|
|
657
|
+
await mkdir(path.join(root, "apps/starttemps/page"), { recursive: true });
|
|
658
|
+
await writeFile(path.join(root, "apps/starttemps/akan.config.ts"), "export default {};\n");
|
|
659
|
+
const cache = path.join(root, "apps/starttemps/.akan/cache");
|
|
660
|
+
const stale = ["cssCandidates.json.1.a.tmp", "fonts/x.woff2.1.b.tmp"];
|
|
661
|
+
const fresh = ["fontCache.json.2.c.tmp", "fonts/x.woff2.2.d.tmp"];
|
|
662
|
+
const kept = [...fresh, "cssCandidates.json", "fonts/x.woff2"];
|
|
663
|
+
for (const file of [...stale, ...kept]) await writeText(path.join(cache, file), "x");
|
|
664
|
+
const twoMinutesAgo = new Date(Date.now() - 120_000);
|
|
665
|
+
for (const file of stale) await utimes(path.join(cache, file), twoMinutesAgo, twoMinutesAgo);
|
|
666
|
+
|
|
667
|
+
const app = AppExecutor.from(new WorkspaceExecutor({ workspaceRoot: root, repoName: "repo" }), "starttemps");
|
|
668
|
+
await app.prepareCommand("start");
|
|
669
|
+
|
|
670
|
+
for (const file of stale) expect(existsSync(path.join(cache, file))).toBe(false);
|
|
671
|
+
for (const file of kept) expect(existsSync(path.join(cache, file))).toBe(true);
|
|
672
|
+
});
|
|
673
|
+
|
|
633
674
|
describe("syncPages", () => {
|
|
634
675
|
// `AppExecutor.from` memoises by name, so each test needs a name no other test has used.
|
|
635
676
|
const makeAppWithLibPages = async (
|
|
@@ -1027,6 +1068,33 @@ describe("Workspace and app executor environment contracts", () => {
|
|
|
1027
1068
|
|
|
1028
1069
|
await expect(app.getPageKeys({ refresh: true })).resolves.toEqual(["./(docs)/_layout.tsx"]);
|
|
1029
1070
|
});
|
|
1071
|
+
|
|
1072
|
+
const levelBoundaryLayout = [
|
|
1073
|
+
"export const LevelBoundary = ({ children }) => children;",
|
|
1074
|
+
"export default function Layout({ children }) { return children; }",
|
|
1075
|
+
"",
|
|
1076
|
+
].join("\n");
|
|
1077
|
+
|
|
1078
|
+
test("refuses a LevelBoundary export on the app's root layout, which the generated one would ignore", async () => {
|
|
1079
|
+
const app = await makeRouteValidationApp("root-level-boundary", "export default {};\n", {
|
|
1080
|
+
"_layout.tsx": levelBoundaryLayout,
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1083
|
+
await expect(app.getPageKeys({ refresh: true })).rejects.toThrow(
|
|
1084
|
+
/unsupported export "LevelBoundary" in .*page[\\/]_layout\.tsx: LevelBoundary belongs to the root layout Akan\.js generates, which never reads one from an app's layout/,
|
|
1085
|
+
);
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
test("refuses a LevelBoundary export on a grouped root layout under the app's own, naming the grouped file", async () => {
|
|
1089
|
+
const app = await makeRouteValidationApp("nested-root-level-boundary", "export default {};\n", {
|
|
1090
|
+
"_layout.tsx": "export default function Layout({ children }) { return children; }\n",
|
|
1091
|
+
"(home)/_layout.tsx": levelBoundaryLayout,
|
|
1092
|
+
});
|
|
1093
|
+
|
|
1094
|
+
await expect(app.getPageKeys({ refresh: true })).rejects.toThrow(
|
|
1095
|
+
/unsupported export "LevelBoundary" in .*page[\\/]\(home\)[\\/]_layout\.tsx: LevelBoundary belongs to the root layout Akan\.js generates/,
|
|
1096
|
+
);
|
|
1097
|
+
});
|
|
1030
1098
|
});
|
|
1031
1099
|
|
|
1032
1100
|
test("accepts head route exports during page key discovery", async () => {
|
|
@@ -1304,6 +1372,26 @@ describe("WorkspaceExecutor listing", () => {
|
|
|
1304
1372
|
});
|
|
1305
1373
|
|
|
1306
1374
|
describe("SysExecutor module listing", () => {
|
|
1375
|
+
test("reads an app's and a lib's constants from that sys's own folder", async () => {
|
|
1376
|
+
const { root, workspace, app } = trackRoot(await createTempApp("demo"));
|
|
1377
|
+
const appConstant = "export const owner = 'app';\n";
|
|
1378
|
+
const libConstant = "export const owner = 'lib';\n";
|
|
1379
|
+
await writeText(path.join(root, "apps/demo/lib/post/post.constant.ts"), appConstant);
|
|
1380
|
+
await writeText(path.join(root, "libs/shared/lib/user/user.constant.ts"), libConstant);
|
|
1381
|
+
await writeText(path.join(root, "libs/shared/akan.config.ts"), "export default {};\n");
|
|
1382
|
+
await mkdir(path.join(root, "libs/shared/lib/__scalar"), { recursive: true });
|
|
1383
|
+
const contents = (files: { content: string }[]) => files.map((file) => file.content);
|
|
1384
|
+
|
|
1385
|
+
const scan = spyOn(AppInfo, "fromExecutor").mockResolvedValue({ getLibs: () => ["shared"] } as never);
|
|
1386
|
+
expect(process.cwd()).not.toBe(root);
|
|
1387
|
+
try {
|
|
1388
|
+
expect(contents(await workspace.getConstantFiles())).toEqual([appConstant, libConstant]);
|
|
1389
|
+
expect(contents(await app.getConstantFilesWithLibs())).toEqual([appConstant, libConstant]);
|
|
1390
|
+
} finally {
|
|
1391
|
+
scan.mockRestore();
|
|
1392
|
+
}
|
|
1393
|
+
});
|
|
1394
|
+
|
|
1307
1395
|
test("lists only the module folders that hold the module's own file", async () => {
|
|
1308
1396
|
const root = await makeTempRoot();
|
|
1309
1397
|
const lib = path.join(root, "apps/modlist/lib");
|
|
@@ -1472,7 +1560,7 @@ describe("SysExecutor scan", () => {
|
|
|
1472
1560
|
test.skipIf(!hasBiome)(
|
|
1473
1561
|
"writes env.server.type.ts the way Biome prints it, spreading libs in dependency order",
|
|
1474
1562
|
async () => {
|
|
1475
|
-
const { default: getContent } = (await import("
|
|
1563
|
+
const { default: getContent } = (await import("../../cli/templates/env/_env.server.type")) as {
|
|
1476
1564
|
default: (scanInfo: unknown) => { content: string };
|
|
1477
1565
|
};
|
|
1478
1566
|
const libs = ["util", "shared", "shopAdmin", "shop", "a10", "a9"];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AppExecutor, type AppRouteSource, type PageRoot } from "./appExecutor";
|
|
2
|
+
export { CommandExecutionError, type CommandExecutionErrorOptions } from "./commandExecutionError";
|
|
3
|
+
export { Executor, execEmoji, type WrittenFileContent } from "./executor";
|
|
4
|
+
export { LibExecutor } from "./libExecutor";
|
|
5
|
+
export { ModuleExecutor } from "./moduleExecutor";
|
|
6
|
+
export { PkgExecutor } from "./pkgExecutor";
|
|
7
|
+
export { SysExecutor } from "./sysExecutor";
|
|
8
|
+
export { parseEnvFile, WorkspaceExecutor } from "./workspaceExecutor";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AkanLibConfig } from "../akanConfig";
|
|
2
|
+
import { Executor, execEmoji } from "./executor";
|
|
3
|
+
import { type NamedExecutorOptions, SysExecutor } from "./sysExecutor";
|
|
4
|
+
import { WorkspaceExecutor } from "./workspaceExecutor";
|
|
5
|
+
|
|
6
|
+
export class LibExecutor extends SysExecutor {
|
|
7
|
+
dist: Executor;
|
|
8
|
+
override emoji = execEmoji.lib;
|
|
9
|
+
constructor({ workspace, name }: NamedExecutorOptions) {
|
|
10
|
+
super({ workspace, name, type: "lib" });
|
|
11
|
+
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/libs/${name}`);
|
|
12
|
+
}
|
|
13
|
+
static from(executor: SysExecutor | WorkspaceExecutor, name: string) {
|
|
14
|
+
return new LibExecutor({ workspace: executor instanceof WorkspaceExecutor ? executor : executor.workspace, name });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#akanConfig: AkanLibConfig | null = null;
|
|
18
|
+
override async getConfig({ refresh }: { refresh?: boolean } = {}) {
|
|
19
|
+
if (this.#akanConfig && !refresh) return this.#akanConfig;
|
|
20
|
+
this.#akanConfig = await AkanLibConfig.from(this, { bustImportCache: refresh });
|
|
21
|
+
return this.#akanConfig;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Executor, execEmoji } from "./executor";
|
|
2
|
+
import type { SysExecutor } from "./sysExecutor";
|
|
3
|
+
|
|
4
|
+
interface ModuleExecutorOptions {
|
|
5
|
+
sys: SysExecutor;
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export class ModuleExecutor extends Executor {
|
|
9
|
+
sys: SysExecutor;
|
|
10
|
+
override emoji = execEmoji.module;
|
|
11
|
+
constructor({ sys, name }: ModuleExecutorOptions) {
|
|
12
|
+
super(name, `${sys.workspace.workspaceRoot}/${sys.type}s/${sys.name}/lib/${name}`);
|
|
13
|
+
this.sys = sys;
|
|
14
|
+
}
|
|
15
|
+
static from(sysExecutor: SysExecutor, name: string) {
|
|
16
|
+
return new ModuleExecutor({ sys: sysExecutor, name });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { PkgInfo } from "../workspace/scanInfo";
|
|
3
|
+
import type { PackageJson, TsConfigJson } from "../workspace/types";
|
|
4
|
+
import { Executor, execEmoji } from "./executor";
|
|
5
|
+
import type { NamedExecutorOptions, SysExecutor } from "./sysExecutor";
|
|
6
|
+
import { WorkspaceExecutor } from "./workspaceExecutor";
|
|
7
|
+
|
|
8
|
+
export class PkgExecutor extends Executor {
|
|
9
|
+
workspace: WorkspaceExecutor;
|
|
10
|
+
override name: string;
|
|
11
|
+
dist: Executor;
|
|
12
|
+
override emoji = execEmoji.pkg;
|
|
13
|
+
constructor({ workspace = WorkspaceExecutor.fromRoot(), name }: NamedExecutorOptions) {
|
|
14
|
+
super(name, `${workspace.workspaceRoot}/pkgs/${name}`);
|
|
15
|
+
this.workspace = workspace;
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/pkgs/${name}`);
|
|
18
|
+
}
|
|
19
|
+
static from(executor: SysExecutor | WorkspaceExecutor, name: string) {
|
|
20
|
+
return new PkgExecutor({ workspace: executor instanceof WorkspaceExecutor ? executor : executor.workspace, name });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#scanInfo: PkgInfo | null = null;
|
|
24
|
+
async scan({ refresh }: { refresh?: boolean } = {}): Promise<PkgInfo> {
|
|
25
|
+
if (this.#scanInfo && !refresh) return this.#scanInfo;
|
|
26
|
+
const scanInfo = await PkgInfo.fromExecutor(this, { refresh });
|
|
27
|
+
this.#scanInfo = scanInfo;
|
|
28
|
+
return scanInfo;
|
|
29
|
+
}
|
|
30
|
+
async #getDependencyVersion(rootPackageJson: PackageJson, dep: string): Promise<string | undefined> {
|
|
31
|
+
const rootDeps = {
|
|
32
|
+
...rootPackageJson.dependencies,
|
|
33
|
+
...rootPackageJson.devDependencies,
|
|
34
|
+
};
|
|
35
|
+
const rootVersion = rootDeps[dep];
|
|
36
|
+
if (rootVersion) return rootVersion;
|
|
37
|
+
// Overrides never reach a consumer's install, so a pinned transitive dep is published as a dependency.
|
|
38
|
+
const overrideVersion = rootPackageJson.overrides?.[dep];
|
|
39
|
+
if (typeof overrideVersion === "string") return overrideVersion;
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const packageJsonPath = `pkgs/${dep}/package.json`;
|
|
43
|
+
if (!(await Bun.file(path.join(this.workspace.workspaceRoot, packageJsonPath)).exists())) return undefined;
|
|
44
|
+
const packageJson = await this.workspace.readJson(packageJsonPath);
|
|
45
|
+
if ((packageJson as PackageJson).name === dep) return (packageJson as PackageJson).version;
|
|
46
|
+
} catch {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async #toDependencyMap(
|
|
51
|
+
rootPackageJson: PackageJson,
|
|
52
|
+
dependencies: string[] = [],
|
|
53
|
+
devDependencies: string[] = [],
|
|
54
|
+
): Promise<Pick<PackageJson, "dependencies" | "devDependencies">> {
|
|
55
|
+
const dependencyNames = [...new Set(dependencies)].sort();
|
|
56
|
+
const devDependencyNames = [...new Set(devDependencies)]
|
|
57
|
+
.filter((dep) => !dependencyNames.includes(dep))
|
|
58
|
+
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
59
|
+
const dependencyVersions = new Map<string, string>();
|
|
60
|
+
const missingDeps: string[] = [];
|
|
61
|
+
for (const dep of [...dependencyNames, ...devDependencyNames]) {
|
|
62
|
+
const version = await this.#getDependencyVersion(rootPackageJson, dep);
|
|
63
|
+
if (version) dependencyVersions.set(dep, version);
|
|
64
|
+
else missingDeps.push(dep);
|
|
65
|
+
}
|
|
66
|
+
if (missingDeps.length > 0)
|
|
67
|
+
throw new Error(`Missing dependency versions in root package.json: ${missingDeps.join(", ")}`);
|
|
68
|
+
|
|
69
|
+
const toDependencyMap = (names: string[]) =>
|
|
70
|
+
Object.fromEntries(names.map((dep) => [dep, dependencyVersions.get(dep) as string]));
|
|
71
|
+
return { dependencies: toDependencyMap(dependencyNames), devDependencies: toDependencyMap(devDependencyNames) };
|
|
72
|
+
}
|
|
73
|
+
async updatePackageJsonDependencies(
|
|
74
|
+
dependencies: string[] = [],
|
|
75
|
+
devDependencies: string[] = [],
|
|
76
|
+
): Promise<PackageJson> {
|
|
77
|
+
const [rootPackageJson, pkgJson] = await Promise.all([this.workspace.getPackageJson(), this.getPackageJson()]);
|
|
78
|
+
const dependencyMaps = await this.#toDependencyMap(rootPackageJson, dependencies, devDependencies);
|
|
79
|
+
const newPkgJson = {
|
|
80
|
+
...pkgJson,
|
|
81
|
+
...dependencyMaps,
|
|
82
|
+
};
|
|
83
|
+
await this.writeJson("package.json", newPkgJson);
|
|
84
|
+
return newPkgJson;
|
|
85
|
+
}
|
|
86
|
+
async generateDistPackageJson(dependencies: string[] = [], devDependencies: string[] = []): Promise<PackageJson> {
|
|
87
|
+
const [rootPackageJson, pkgJson] = await Promise.all([this.workspace.getPackageJson(), this.getPackageJson()]);
|
|
88
|
+
const dependencyMaps = await this.#toDependencyMap(rootPackageJson, dependencies, devDependencies);
|
|
89
|
+
const distPkgJson: PackageJson = {
|
|
90
|
+
...pkgJson,
|
|
91
|
+
type: "module",
|
|
92
|
+
exports: {
|
|
93
|
+
...pkgJson.exports,
|
|
94
|
+
".": {
|
|
95
|
+
import: "./index.ts",
|
|
96
|
+
types: "./index.ts",
|
|
97
|
+
default: "./index.ts",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
engines: { bun: ">=1.4.4" },
|
|
101
|
+
...dependencyMaps,
|
|
102
|
+
};
|
|
103
|
+
await Promise.all([this.dist.writeJson("package.json", distPkgJson), this.writeJson("package.json", distPkgJson)]);
|
|
104
|
+
return distPkgJson;
|
|
105
|
+
}
|
|
106
|
+
async build(): Promise<void> {
|
|
107
|
+
await Bun.build({
|
|
108
|
+
root: this.cwdPath,
|
|
109
|
+
entrypoints: [`${this.cwdPath}/index.ts`],
|
|
110
|
+
splitting: false,
|
|
111
|
+
target: "bun",
|
|
112
|
+
});
|
|
113
|
+
await this.cp(`${this.cwdPath}/dist`, this.dist.cwdPath);
|
|
114
|
+
}
|
|
115
|
+
async generateTsconfigJson(): Promise<TsConfigJson> {
|
|
116
|
+
const [rootTsconfig, pkgTsconfig] = await Promise.all([this.workspace.getTsConfig(), this.getTsConfig()]);
|
|
117
|
+
const tsconfig: TsConfigJson = {
|
|
118
|
+
...rootTsconfig,
|
|
119
|
+
...pkgTsconfig,
|
|
120
|
+
compilerOptions: {
|
|
121
|
+
...rootTsconfig.compilerOptions,
|
|
122
|
+
...pkgTsconfig.compilerOptions,
|
|
123
|
+
paths: {},
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
await this.dist.writeJson("tsconfig.json", tsconfig);
|
|
127
|
+
return tsconfig;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { capitalize, getPageSourceFileViolation } from "akanjs/common";
|
|
4
|
+
import { AkanAppConfig, AkanLibConfig } from "../akanConfig";
|
|
5
|
+
import {
|
|
6
|
+
renderScopeAgentBlock,
|
|
7
|
+
renderScopeAgentsMd,
|
|
8
|
+
renderScopeClaudeMd,
|
|
9
|
+
scanScopeRecipes,
|
|
10
|
+
upsertAgentBlock,
|
|
11
|
+
} from "../guideline/agentsIndex";
|
|
12
|
+
import { CodegenLock } from "../workspace/codegenLock";
|
|
13
|
+
import { EnvSeed } from "../workspace/envSeed";
|
|
14
|
+
import { ManifestDependencies } from "../workspace/manifestDependencies";
|
|
15
|
+
import { AppInfo, isAkanFrameworkDependency, LibInfo } from "../workspace/scanInfo";
|
|
16
|
+
import type { FileContent } from "../workspace/types";
|
|
17
|
+
import { barrelFacetDirs } from "../workspace/workspaceLayout";
|
|
18
|
+
import type { AppExecutor } from "./appExecutor";
|
|
19
|
+
import { Executor, execEmoji } from "./executor";
|
|
20
|
+
import type { LibExecutor } from "./libExecutor";
|
|
21
|
+
import { WorkspaceExecutor } from "./workspaceExecutor";
|
|
22
|
+
|
|
23
|
+
export interface NamedExecutorOptions {
|
|
24
|
+
workspace?: WorkspaceExecutor;
|
|
25
|
+
name: string;
|
|
26
|
+
}
|
|
27
|
+
interface SysExecutorOptions extends NamedExecutorOptions {
|
|
28
|
+
type: "app" | "lib";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class SysExecutor extends Executor {
|
|
32
|
+
workspace: WorkspaceExecutor;
|
|
33
|
+
override name: string;
|
|
34
|
+
type: "app" | "lib";
|
|
35
|
+
override emoji: string;
|
|
36
|
+
constructor({ workspace = WorkspaceExecutor.fromRoot(), name, type }: SysExecutorOptions) {
|
|
37
|
+
super(name, `${workspace.workspaceRoot}/${type}s/${name}`);
|
|
38
|
+
this.workspace = workspace;
|
|
39
|
+
this.name = name;
|
|
40
|
+
this.type = type;
|
|
41
|
+
this.emoji = execEmoji[type];
|
|
42
|
+
}
|
|
43
|
+
#akanConfig: AkanAppConfig | AkanLibConfig | null = null;
|
|
44
|
+
async getConfig({ refresh }: { refresh?: boolean } = {}) {
|
|
45
|
+
if (this.#akanConfig && !refresh) return this.#akanConfig;
|
|
46
|
+
this.#akanConfig =
|
|
47
|
+
this.type === "app"
|
|
48
|
+
? await AkanAppConfig.from(this as unknown as AppExecutor)
|
|
49
|
+
: await AkanLibConfig.from(this as unknown as LibExecutor);
|
|
50
|
+
return this.#akanConfig;
|
|
51
|
+
}
|
|
52
|
+
async getModules() {
|
|
53
|
+
const path = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
|
|
54
|
+
return await this.workspace.getDirInModule(path, this.name);
|
|
55
|
+
}
|
|
56
|
+
async getPageConventionViolations(): Promise<{ relativePath: string; reason: string }[]> {
|
|
57
|
+
if (!(await this.exists("page"))) return [];
|
|
58
|
+
const violations: { relativePath: string; reason: string }[] = [];
|
|
59
|
+
for (const entry of await this.getAllFiles("**/*", { cwd: this.getPath("page") })) {
|
|
60
|
+
const relativePath = entry.split(path.sep).join("/");
|
|
61
|
+
const reason = getPageSourceFileViolation(relativePath);
|
|
62
|
+
if (reason) violations.push({ relativePath: `page/${relativePath}`, reason });
|
|
63
|
+
}
|
|
64
|
+
return violations;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#scanInfo: AppInfo | LibInfo | null = null;
|
|
68
|
+
hasScanInfo() {
|
|
69
|
+
return this.#scanInfo !== null;
|
|
70
|
+
}
|
|
71
|
+
getScanInfo<AllowEmpty extends boolean = false>({
|
|
72
|
+
allowEmpty,
|
|
73
|
+
}: {
|
|
74
|
+
allowEmpty?: AllowEmpty;
|
|
75
|
+
} = {}): AllowEmpty extends true ? AppInfo | LibInfo | null : AppInfo | LibInfo {
|
|
76
|
+
if (!this.hasScanInfo() && !allowEmpty) throw new Error("Scan info is not available");
|
|
77
|
+
return this.#scanInfo as AllowEmpty extends true ? AppInfo | LibInfo | null : AppInfo | LibInfo;
|
|
78
|
+
}
|
|
79
|
+
async #seedEnvFiles(): Promise<FileContent[]> {
|
|
80
|
+
const envDir = path.join(this.cwdPath, "env");
|
|
81
|
+
const missing = await new EnvSeed(envDir).missing();
|
|
82
|
+
if (!missing.length) return [];
|
|
83
|
+
const written = await Promise.all(
|
|
84
|
+
missing.map(({ fileName, content }) =>
|
|
85
|
+
this.writeFile(path.join(envDir, fileName), content, { overwrite: false, silent: true }),
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
this.logger.info(
|
|
89
|
+
`${missing.map(({ fileName }) => `env/${fileName}`).join(", ")} were missing (gitignored, so a clone has none) and now hold local defaults: put this machine's values in them, or fetch the team's with \`akan download-env\`.`,
|
|
90
|
+
);
|
|
91
|
+
return written;
|
|
92
|
+
}
|
|
93
|
+
#getScanTemplateTasks(scanInfo: AppInfo | LibInfo): (Promise<FileContent[]> | null)[] {
|
|
94
|
+
return [
|
|
95
|
+
this.#seedEnvFiles(),
|
|
96
|
+
this._applyTemplate({ basePath: "env", template: "env", scanInfo }),
|
|
97
|
+
this._applyTemplate({ basePath: "lib", template: "lib", scanInfo }),
|
|
98
|
+
this._applyTemplate({ basePath: ".", template: "server.ts", scanInfo }),
|
|
99
|
+
this._applyTemplate({ basePath: ".", template: "client.ts", scanInfo }),
|
|
100
|
+
this.type === "lib" ? this._applyTemplate({ basePath: ".", template: "index.ts", scanInfo }) : null,
|
|
101
|
+
...barrelFacetDirs.map((facet) =>
|
|
102
|
+
this._applyTemplate({
|
|
103
|
+
basePath: facet,
|
|
104
|
+
template: "facetIndex/index.ts",
|
|
105
|
+
scanInfo,
|
|
106
|
+
options: { exec: this, facet },
|
|
107
|
+
}),
|
|
108
|
+
),
|
|
109
|
+
...[
|
|
110
|
+
...scanInfo.getDatabaseModules().map((model) => [model, `lib/${model}`]),
|
|
111
|
+
...scanInfo.getServiceModules().map((model) => [model, `lib/_${model}`]),
|
|
112
|
+
...scanInfo.getScalarModules().map((model) => [model, `lib/__scalar/${model}`]),
|
|
113
|
+
].map(([model, basePath]) =>
|
|
114
|
+
this._applyTemplate({ basePath, template: "moduleRoot", scanInfo, dict: { model, Model: capitalize(model) } }),
|
|
115
|
+
),
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
async scan({
|
|
119
|
+
refresh = false,
|
|
120
|
+
write = true,
|
|
121
|
+
writeLib = write,
|
|
122
|
+
}: {
|
|
123
|
+
refresh?: boolean;
|
|
124
|
+
write?: boolean;
|
|
125
|
+
writeLib?: boolean;
|
|
126
|
+
} = {}): Promise<AppInfo | LibInfo> {
|
|
127
|
+
if (this.#scanInfo && !refresh) return this.#scanInfo;
|
|
128
|
+
const scanInfo =
|
|
129
|
+
this.type === "app"
|
|
130
|
+
? await AppInfo.fromExecutor(this as unknown as AppExecutor, {
|
|
131
|
+
refresh,
|
|
132
|
+
})
|
|
133
|
+
: await LibInfo.fromExecutor(this as unknown as LibExecutor, {
|
|
134
|
+
refresh,
|
|
135
|
+
});
|
|
136
|
+
//* Locked: `writeLib` rewrites dependency-lib barrels that other dev servers regenerate and watch too.
|
|
137
|
+
if (write)
|
|
138
|
+
await CodegenLock.run(this.workspace.workspaceRoot, `scan:${this.name}`, async () => {
|
|
139
|
+
await Promise.all(this.#getScanTemplateTasks(scanInfo));
|
|
140
|
+
await this.writeJson(`akan.${this.type}.json`, scanInfo.getScanResult());
|
|
141
|
+
await this.#updateDependencies(scanInfo);
|
|
142
|
+
if (writeLib) {
|
|
143
|
+
const libInfos = [...scanInfo.getLibInfos().values()];
|
|
144
|
+
await Promise.all(libInfos.flatMap((libInfo) => libInfo.exec.#getScanTemplateTasks(libInfo)));
|
|
145
|
+
}
|
|
146
|
+
await this.syncAgentsIndex(scanInfo);
|
|
147
|
+
});
|
|
148
|
+
this.#scanInfo = scanInfo;
|
|
149
|
+
return scanInfo;
|
|
150
|
+
}
|
|
151
|
+
/** Rewrites only the marker block of the scoped AGENTS.md; content outside the markers belongs to the user. */
|
|
152
|
+
async syncAgentsIndex(scanInfo?: AppInfo | LibInfo) {
|
|
153
|
+
const info = scanInfo ?? (await this.scan({ write: false }));
|
|
154
|
+
const scope = { type: this.type, name: this.name };
|
|
155
|
+
const recipes = await scanScopeRecipes(this.workspace.workspaceRoot, scope, info.getScanResult().libDeps);
|
|
156
|
+
const block = renderScopeAgentBlock(scope, recipes);
|
|
157
|
+
const existing = (await this.exists("AGENTS.md")) ? await this.readFile("AGENTS.md") : null;
|
|
158
|
+
await this.writeFile(
|
|
159
|
+
"AGENTS.md",
|
|
160
|
+
existing?.trim() ? upsertAgentBlock(existing, block) : renderScopeAgentsMd(scope, block),
|
|
161
|
+
);
|
|
162
|
+
// CLAUDE.md 는 얇은 포인터라 최초 1회만 깔아준다 — 사용자가 지우거나 고친 것을 되살리지 않는다.
|
|
163
|
+
if (!(await this.exists("CLAUDE.md"))) await this.writeFile("CLAUDE.md", renderScopeClaudeMd(scope));
|
|
164
|
+
}
|
|
165
|
+
//* The root is the cached copy the dependency scan read, so a name it declares is judged by the same snapshot.
|
|
166
|
+
async #updateDependencies(scanInfo: AppInfo | LibInfo) {
|
|
167
|
+
const [rootPackageJson, packageJson] = await Promise.all([
|
|
168
|
+
this.workspace.getPackageJson(),
|
|
169
|
+
this.getPackageJson({ refresh: true }),
|
|
170
|
+
]);
|
|
171
|
+
const { dependencies: runtime, devDependencies: typeOnly, akanConfig } = scanInfo.getScanResult();
|
|
172
|
+
const kept = new Set([
|
|
173
|
+
...ManifestDependencies.keptBy(packageJson),
|
|
174
|
+
...akanConfig.externalLibs,
|
|
175
|
+
...akanConfig.trustedDependencies,
|
|
176
|
+
]);
|
|
177
|
+
//? The scan leaves the framework out of its imports on purpose, so it is never a prune candidate.
|
|
178
|
+
const isKept = (dep: string) => kept.has(dep) || isAkanFrameworkDependency(dep);
|
|
179
|
+
const { dependencies, devDependencies, removed, unverifiable } = new ManifestDependencies(
|
|
180
|
+
rootPackageJson,
|
|
181
|
+
{ runtime, typeOnly },
|
|
182
|
+
isKept,
|
|
183
|
+
).realign(packageJson);
|
|
184
|
+
const manifestPath = `${this.type}s/${this.name}/package.json`;
|
|
185
|
+
if (removed.length)
|
|
186
|
+
this.logger.info(
|
|
187
|
+
`Removed from ${manifestPath}, declared by the root and imported nowhere: ${removed.join(", ")} (list one in akan.keepDependencies to keep it)`,
|
|
188
|
+
);
|
|
189
|
+
if (unverifiable.length)
|
|
190
|
+
this.logger.warn(
|
|
191
|
+
`${manifestPath} lists ${unverifiable.join(", ")}, which the root package.json does not declare, so sync cannot tell whether it is used; kept as is`,
|
|
192
|
+
);
|
|
193
|
+
await this.setPackageJson({ ...packageJson, dependencies, devDependencies });
|
|
194
|
+
}
|
|
195
|
+
override async getLocalFile(targetPath: string) {
|
|
196
|
+
const filePath = path.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
|
|
197
|
+
const content = await this.workspace.readFile(filePath);
|
|
198
|
+
return { filePath, content };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async getDatabaseModules() {
|
|
202
|
+
return (await this.readdir("lib"))
|
|
203
|
+
.filter((name) => !name.startsWith("_") && !name.endsWith(".ts"))
|
|
204
|
+
.filter((name) => existsSync(`${this.cwdPath}/lib/${name}/${name}.constant.ts`));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async getServiceModules() {
|
|
208
|
+
return (await this.readdir("lib"))
|
|
209
|
+
.filter((name) => name.startsWith("_") && !name.startsWith("__"))
|
|
210
|
+
.filter((name) => existsSync(`${this.cwdPath}/lib/${name}/${name.slice(1)}.service.ts`));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async getScalarModules() {
|
|
214
|
+
return (await this.readdir("lib/__scalar"))
|
|
215
|
+
.filter((name) => !name.startsWith("_"))
|
|
216
|
+
.filter((name) => existsSync(`${this.cwdPath}/lib/__scalar/${name}/${name}.constant.ts`));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async #getComponentModules(role: "View" | "Unit" | "Template") {
|
|
220
|
+
return (await this.readdir("lib"))
|
|
221
|
+
.filter((name) => !name.startsWith("_") && !name.endsWith(".ts"))
|
|
222
|
+
.filter((name) => existsSync(`${this.cwdPath}/lib/${name}/${capitalize(name)}.${role}.tsx`));
|
|
223
|
+
}
|
|
224
|
+
async #getComponentSources(role: "View" | "Unit" | "Template") {
|
|
225
|
+
const modules = await this.#getComponentModules(role);
|
|
226
|
+
return Promise.all(modules.map((name) => this.getLocalFile(`lib/${name}/${capitalize(name)}.${role}.tsx`)));
|
|
227
|
+
}
|
|
228
|
+
async getViewComponents() {
|
|
229
|
+
return await this.#getComponentModules("View");
|
|
230
|
+
}
|
|
231
|
+
async getUnitComponents() {
|
|
232
|
+
return await this.#getComponentModules("Unit");
|
|
233
|
+
}
|
|
234
|
+
async getTemplateComponents() {
|
|
235
|
+
return await this.#getComponentModules("Template");
|
|
236
|
+
}
|
|
237
|
+
async getViewsSourceCode() {
|
|
238
|
+
return await this.#getComponentSources("View");
|
|
239
|
+
}
|
|
240
|
+
async getUnitsSourceCode() {
|
|
241
|
+
return await this.#getComponentSources("Unit");
|
|
242
|
+
}
|
|
243
|
+
async getTemplatesSourceCode() {
|
|
244
|
+
return await this.#getComponentSources("Template");
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async getScalarConstantFiles() {
|
|
248
|
+
const scalarModules = await this.getScalarModules();
|
|
249
|
+
return Promise.all(
|
|
250
|
+
scalarModules.map((scalarModule) =>
|
|
251
|
+
this.getLocalFile(`lib/__scalar/${scalarModule}/${scalarModule}.constant.ts`),
|
|
252
|
+
),
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
async getScalarDictionaryFiles() {
|
|
257
|
+
const scalarModules = await this.getScalarModules();
|
|
258
|
+
return Promise.all(
|
|
259
|
+
scalarModules.map((scalarModule) =>
|
|
260
|
+
this.getLocalFile(`lib/__scalar/${scalarModule}/${scalarModule}.dictionary.ts`),
|
|
261
|
+
),
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
async getConstantFiles() {
|
|
266
|
+
const modules = await this.getModules();
|
|
267
|
+
return Promise.all(modules.map((module) => this.getLocalFile(`lib/${module}/${module}.constant.ts`)));
|
|
268
|
+
}
|
|
269
|
+
async getConstantFilesWithLibs() {
|
|
270
|
+
const scanInfo =
|
|
271
|
+
this.type === "app"
|
|
272
|
+
? await AppInfo.fromExecutor(this as unknown as AppExecutor)
|
|
273
|
+
: await LibInfo.fromExecutor(this as unknown as LibExecutor);
|
|
274
|
+
const sysContantFiles = await this.getConstantFiles();
|
|
275
|
+
const sysScalarConstantFiles = await this.getScalarConstantFiles();
|
|
276
|
+
const libDeps = scanInfo.getLibs();
|
|
277
|
+
const libConstantFiles = await Promise.all(
|
|
278
|
+
//? Not LibExecutor.from: libExecutor.ts extends this file's class, so importing it here would load it first.
|
|
279
|
+
libDeps.map(async (lib) => {
|
|
280
|
+
const libSys = new SysExecutor({ workspace: this.workspace, name: lib, type: "lib" });
|
|
281
|
+
return [...(await libSys.getConstantFiles()), ...(await libSys.getScalarConstantFiles())];
|
|
282
|
+
}),
|
|
283
|
+
);
|
|
284
|
+
return [...sysContantFiles, ...sysScalarConstantFiles, ...libConstantFiles.flat()];
|
|
285
|
+
}
|
|
286
|
+
async getDictionaryFiles() {
|
|
287
|
+
const modules = await this.getModules();
|
|
288
|
+
return Promise.all(modules.map((module) => this.getLocalFile(`lib/${module}/${module}.dictionary.ts`)));
|
|
289
|
+
}
|
|
290
|
+
override async applyTemplate(options: {
|
|
291
|
+
basePath: string;
|
|
292
|
+
template: string;
|
|
293
|
+
dict?: { [key: string]: string };
|
|
294
|
+
overwrite?: boolean;
|
|
295
|
+
}): Promise<FileContent[]> {
|
|
296
|
+
const scanInfo = await this.scan();
|
|
297
|
+
const fileContents = await super.applyTemplate({ ...options, scanInfo });
|
|
298
|
+
await this.scan();
|
|
299
|
+
return fileContents;
|
|
300
|
+
}
|
|
301
|
+
}
|