@akanjs/devkit 3.2.0-rc.3 → 3.2.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +367 -11
- package/DEV_RUNTIME_KNOBS.md +4 -3
- package/README.ko.md +3 -2
- package/README.md +4 -2
- package/akanApp/BackendImportGraph.test.ts +1 -1
- package/akanApp/akanApp.host.test.ts +257 -1
- package/akanApp/akanApp.host.ts +146 -1223
- package/akanApp/akanApp.host.wiring.test.ts +727 -0
- package/akanApp/builderGap.ts +68 -0
- package/akanApp/builderRequestRelay.test.ts +93 -0
- package/akanApp/builderRequestRelay.ts +100 -0
- package/akanApp/builderRssRecycler.ts +182 -0
- package/akanApp/devBackend.ts +392 -0
- package/akanApp/devBuildStatusBoard.ts +128 -0
- package/akanApp/devBuilder.ts +196 -0
- package/akanApp/devHostPolicy.test.ts +11 -11
- package/akanApp/devHostPolicy.ts +2 -4
- package/akanApp/devIdleSuspend.test.ts +221 -0
- package/akanApp/devIdleSuspend.ts +192 -0
- package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
- package/akanApp/devRecycler.test.ts +66 -0
- package/akanApp/devRecycler.ts +305 -0
- package/akanApp/processRss.ts +61 -0
- package/akanConfig/akanConfig.test.ts +24 -1
- package/akanConfig/akanConfig.ts +10 -10
- package/akanConfig/akanWorkspaceConfig.ts +1 -1
- package/akanConfig/productionLockfile.ts +1 -1
- package/apiReport/apiDeclarationPrinter.ts +120 -0
- package/apiReport/apiReport.test.ts +526 -0
- package/apiReport/apiReport.ts +232 -0
- package/apiReport/apiReportDiff.ts +160 -0
- package/apiReport/apiReportPolicy.ts +65 -0
- package/apiReport/apiTargets.ts +311 -0
- package/apiReport/changesetBump.ts +19 -0
- package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +21 -0
- package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +10 -49
- package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +74 -7
- package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +20 -15
- package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
- package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +48 -12
- package/{routeJsBudget.ts → app/routeJsBudget.ts} +90 -27
- package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
- package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
- package/artifact/implicitRootLayout.test.ts +71 -3
- package/artifact/implicitRootLayout.ts +21 -4
- package/artifact/implicitRootLayoutRender.test.tsx +297 -0
- package/biome.base.json +2 -1
- package/cloud/cloudApi.test.ts +1 -1
- package/cloud/configLock.test.ts +1 -1
- package/cloud/globalConfig.test.ts +1 -1
- package/cloud/globalConfig.ts +1 -1
- package/cloud/updatePackUpload.test.ts +1 -1
- package/codeAgent/agent/AkanCodeEnv.ts +1 -1
- package/codeAgent/agent/akanCodePaths.ts +1 -1
- package/codeAgent/agent/akanSystemPrompt.ts +1 -1
- package/codeAgent/agent/codeAgent.test.ts +1 -1
- package/codeAgent/skills/akan-debug/SKILL.md +10 -3
- package/codeAgent/skills/akan-err/SKILL.md +7 -0
- package/codeAgent/skills/akan-mcp/SKILL.md +14 -2
- package/codeAgent/skills/akan-scaffold/SKILL.md +2 -2
- package/codeAgent/skills/akan-transport/SKILL.md +2 -0
- package/codeAgent/skills/akan-validate/SKILL.md +1 -0
- package/codeAgent/tools/AkanCli.ts +1 -1
- package/codeAgent/tools/AkanToolPack.ts +1 -1
- package/codeAgent/tools/McpClient.ts +28 -6
- package/codeAgent/tools/McpToolPack.ts +1 -1
- package/codeAgent/tools/akanCodePlugins.test.ts +14 -2
- package/commandDecorators/argMeta.ts +4 -0
- package/commandDecorators/cliError.ts +72 -0
- package/commandDecorators/command.ts +165 -91
- package/commandDecorators/commandBuilder.ts +1 -1
- package/commandDecorators/commandDecorators.test.ts +191 -16
- package/commandDecorators/exitCodeError.ts +6 -7
- package/commandDecorators/index.ts +1 -0
- package/commandDecorators/targetMeta.ts +1 -0
- package/commandDecorators/workspaceVersionCheck.test.ts +1 -1
- package/commandDecorators/workspaceVersionCheck.ts +1 -1
- package/context/akanContext.ts +576 -0
- package/context/akanContextInspection.ts +296 -0
- package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
- package/{akanMcpContract.ts → context/akanMcpContract.ts} +32 -262
- package/context/akanMcpToolError.ts +16 -0
- package/context/doctor/agentGuideCheck.ts +81 -0
- package/context/doctor/configLeftoverCheck.ts +35 -0
- package/context/doctor/doctorFindings.ts +70 -0
- package/context/doctor/generatedFreshness.ts +56 -0
- package/context/doctor/moduleShapeCheck.ts +88 -0
- package/context/doctor/recipeDuplicateCheck.ts +39 -0
- package/context/doctor/recipeIndexCheck.ts +87 -0
- package/context/doctor/rootShapeCheck.ts +55 -0
- package/context/doctor/workflowScope.ts +97 -0
- package/{constantFieldNames.test.ts → context/moduleFieldNames.test.ts} +24 -2
- package/context/moduleFieldNames.ts +25 -0
- package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
- package/context/safeRead.ts +9 -0
- package/csrE2e/csrE2eHarness.fixture.ts +1 -1
- package/devkitUtils.test.ts +39 -5
- package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
- package/{apiReference.ts → docs/apiReference.ts} +2 -2
- package/docs/errorCodeReference.test.ts +282 -0
- package/docs/errorCodeReference.ts +71 -0
- package/docs/errorCodeScan.ts +551 -0
- package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
- package/executors/appExecutor.ts +448 -0
- package/executors/commandExecutionError.ts +53 -0
- package/executors/executor.ts +527 -0
- package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
- package/{executors.test.ts → executors/executors.test.ts} +76 -15
- package/executors/index.ts +8 -0
- package/executors/libExecutor.ts +23 -0
- package/executors/moduleExecutor.ts +18 -0
- package/executors/pkgExecutor.ts +129 -0
- package/executors/sysExecutor.ts +301 -0
- package/executors/workspaceExecutor.ts +277 -0
- package/frontendBuild/allRoutesBuilder.test.ts +17 -5
- package/frontendBuild/allRoutesBuilder.ts +24 -6
- package/frontendBuild/autoImportSync.test.ts +1 -1
- package/frontendBuild/autoImportSync.ts +1 -1
- package/frontendBuild/buildRouteClient.test.ts +1 -1
- package/frontendBuild/bundleDefine.ts +2 -0
- package/frontendBuild/clientBuildTypes.ts +5 -2
- package/frontendBuild/clientEntriesBundler.test.ts +1 -1
- package/frontendBuild/clientEntryDiscovery.test.ts +28 -0
- package/frontendBuild/clientEntryDiscovery.ts +25 -6
- package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
- package/frontendBuild/csrDevArtifactWriter.ts +1 -1
- package/frontendBuild/cssCompiler.test.ts +1 -1
- package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
- package/frontendBuild/devGeneratedIndexSync.ts +7 -38
- package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
- package/frontendBuild/fontOptimizer.test.ts +1 -1
- package/frontendBuild/fontPruner.test.ts +1 -1
- package/frontendBuild/frontendBuild.test.ts +3 -3
- package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
- package/frontendBuild/hmrWatcher.test.ts +1 -1
- package/frontendBuild/hmrWatcher.ts +22 -1
- package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
- package/frontendBuild/mcpAppViewBuilder.ts +1 -1
- package/frontendBuild/nativeCore.test.ts +148 -0
- package/frontendBuild/optionalPeers.test.ts +36 -8
- package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
- package/frontendBuild/pagesBundleBuilder.ts +1 -1
- package/frontendBuild/precompressArtifacts.test.ts +1 -1
- package/frontendBuild/precompressArtifacts.ts +1 -1
- package/frontendBuild/serverGraphFile.ts +1 -1
- package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
- package/frontendBuild/ssrBaseArtifactBuilder.test.ts +26 -0
- package/frontendBuild/ssrBaseArtifactBuilder.ts +23 -19
- package/frontendBuild/ssrDevBundler.test.ts +1 -1
- package/frontendBuild/vendorImportScanner.test.ts +25 -4
- package/frontendBuild/vendorImportScanner.ts +25 -10
- package/frontendBuild/vendorNarrowing.test.ts +1 -1
- package/frontendBuild/watchRootResolver.test.ts +1 -1
- package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
- package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
- package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
- package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
- package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
- package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
- package/{prompter.ts → guideline/prompter.ts} +2 -3
- package/incrementalBuilder/buildBatch.proc.ts +14 -4
- package/incrementalBuilder/buildBatchProtocol.ts +2 -0
- package/incrementalBuilder/buildBatchRunner.test.ts +108 -1
- package/incrementalBuilder/buildBatchRunner.ts +17 -4
- package/incrementalBuilder/builderBoot.ts +106 -0
- package/incrementalBuilder/builderBuildStatus.ts +23 -0
- package/incrementalBuilder/builderChannel.test.ts +1 -1
- package/incrementalBuilder/builderChannel.ts +11 -0
- package/incrementalBuilder/builderGraphPayloads.ts +3 -3
- package/incrementalBuilder/builderLanes.ts +157 -0
- package/incrementalBuilder/builderWatch.ts +213 -0
- package/incrementalBuilder/csrRegistry.ts +234 -0
- package/incrementalBuilder/incrementalBuilder.host.test.ts +30 -1
- package/incrementalBuilder/incrementalBuilder.host.ts +10 -22
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +93 -2
- package/incrementalBuilder/incrementalBuilder.proc.ts +81 -823
- package/incrementalBuilder/ssrRegistry.ts +278 -0
- package/index.ts +22 -22
- package/integration/devStability.integration.test.ts +62 -56
- package/integration/devStabilityHarness.test.ts +1 -1
- package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
- package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
- package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
- package/lint/gritRules.test.ts +1 -1
- package/{linter.test.ts → lint/linter.test.ts} +1 -1
- package/lint/no-import-common-err.grit +31 -0
- package/lint/no-init-fetch-in-client.grit +1 -1
- package/lint/no-web-only-api-outside-webkit.grit +3 -3
- package/mobile/desktopBin.test.ts +1 -1
- package/mobile/desktopRelease.test.ts +1 -1
- package/mobile/desktopServerStage.test.ts +2 -2
- package/mobile/desktopServerStage.ts +1 -1
- package/mobile/nativeApi.test.ts +1 -1
- package/mobile/nativeApp.test.ts +1 -1
- package/mobile/nativeConfig.test.ts +1 -1
- package/mobile/nativePluginFolders.test.ts +1 -1
- package/mobile/nativePublicEnv.test.ts +1 -1
- package/mobile/nativeWebDir.test.ts +1 -1
- package/mobile/serverBundleSecrets.test.ts +1 -1
- package/mobile/tarWriter.test.ts +1 -1
- package/mobile/updatePackFolder.test.ts +1 -1
- package/package.json +167 -3
- package/packageExports.test.ts +20 -2
- package/piDependencyPins.test.ts +1 -1
- package/pipeline/PipelineDefinition.ts +1 -1
- package/platformTest/IdleWatchedProcess.test.ts +1 -1
- package/platformTest/PlatformTestRun.test.ts +1 -1
- package/platformTest/TestSnapshot.test.ts +1 -1
- package/preview/PreviewView.ts +32 -13
- package/preview/previewView.test.ts +33 -3
- package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
- package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
- package/quality/bareErrorScanner.ts +126 -0
- package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
- package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
- package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
- package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
- package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
- package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
- package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
- package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
- package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +1 -1
- package/{qualityScanner.ts → quality/qualityScanner.ts} +8 -8
- package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
- package/{subspace.test.ts → subspace/subspace.test.ts} +25 -4
- package/{subspace.ts → subspace/subspace.ts} +5 -5
- package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
- package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
- package/{testHelpers.ts → test/testHelpers.ts} +37 -1
- package/transforms/barrelAnalyzer.ts +31 -10
- package/transforms/browserDirnamePlugin.test.ts +1 -1
- package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
- package/transforms/mcpAppPageTrimmer.test.ts +1 -1
- package/transforms/pureLazyMarker.test.ts +1 -1
- package/transforms/serverEnvPlugin.test.ts +1 -1
- package/transforms/serverEnvProfile.test.ts +1 -1
- package/transforms/sideEffectImportOrder.test.ts +1 -1
- package/transforms/transforms.test.ts +52 -2
- package/transforms/tsconfigPackageResolver.test.ts +1 -1
- package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
- package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
- package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
- package/typecheck/projectTypecheck.test.ts +1 -1
- package/typecheck/projectTypecheck.ts +6 -2
- package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
- package/{typeChecker.ts → typecheck/typeChecker.ts} +1 -1
- package/typecheck/typecheck.proc.ts +4 -3
- package/typecheck/typecheckFailure.ts +7 -2
- package/util/errorReport.ts +66 -0
- package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
- package/workflow/artifacts.ts +8 -7
- package/workflow/constantSource.ts +187 -0
- package/workflow/dictionarySource.ts +184 -0
- package/workflow/executor.ts +6 -9
- package/workflow/fieldExpression.ts +153 -0
- package/workflow/fieldLabel.ts +61 -0
- package/workflow/fieldOrder.ts +117 -0
- package/workflow/fieldType.ts +93 -0
- package/workflow/guardCatalog.test.ts +1 -1
- package/workflow/index.ts +1 -0
- package/workflow/keyRename.ts +1 -1
- package/workflow/moduleIndex.test.ts +2 -2
- package/workflow/moduleIndex.ts +2 -2
- package/workflow/modulePaths.ts +27 -0
- package/workflow/mutationScaffold.ts +7 -15
- package/workflow/mutationSource.ts +2 -1
- package/workflow/plainName.ts +16 -3
- package/workflow/plan.ts +14 -2
- package/workflow/primitiveReport.ts +78 -0
- package/workflow/rolloutGate.test.ts +1 -1
- package/workflow/rolloutGate.ts +1 -1
- package/workflow/serviceSource.ts +33 -0
- package/workflow/signalSource.ts +96 -0
- package/workflow/source.ts +50 -1105
- package/workflow/sourceAst.ts +30 -0
- package/workflow/sourceImports.ts +105 -0
- package/workflow/sourceText.ts +13 -0
- package/workflow/templateSource.ts +30 -0
- package/workflow/testSource.ts +31 -0
- package/workflow/types.ts +1 -1
- package/workflow/uiPolicy.ts +1 -1
- package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
- package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
- package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
- package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
- package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
- package/{envSeed.ts → workspace/envSeed.ts} +1 -1
- package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
- package/{libSource.ts → workspace/libSource.ts} +1 -1
- package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
- package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
- package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
- package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +1 -1
- package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +1 -1
- package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
- package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
- package/akanContext.ts +0 -1084
- package/constantFieldNames.ts +0 -18
- package/executors.ts +0 -1749
- /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
- /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
- /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
- /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
- /package/{linter.ts → lint/linter.ts} +0 -0
- /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
- /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
- /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
- /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
- /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
- /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
- /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
- /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
- /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
- /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
- /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
- /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
- /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
- /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
- /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
- /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
- /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
- /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
- /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
- /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
- /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
- /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
- /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
- /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
- /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
- /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
- /package/{storeSource.ts → quality/storeSource.ts} +0 -0
- /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
- /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
- /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
- /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
- /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
- /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
- /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
- /package/{writePath.ts → quality/writePath.ts} +0 -0
- /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
- /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
- /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
- /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
- /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
- /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
- /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
- /package/{fileSys.test.ts → util/fileSys.test.ts} +0 -0
- /package/{fileSys.ts → util/fileSys.ts} +0 -0
- /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
- /package/{selectModel.ts → util/selectModel.ts} +0 -0
- /package/{semver.test.ts → util/semver.test.ts} +0 -0
- /package/{semver.ts → util/semver.ts} +0 -0
- /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
- /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
- /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
- /package/{spinner.ts → util/spinner.ts} +0 -0
- /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
- /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
- /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
- /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
- /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
- /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
- /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
- /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
- /package/{types.ts → workspace/types.ts} +0 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { ApiDeclarationPrinter } from "./apiDeclarationPrinter";
|
|
3
|
+
|
|
4
|
+
export interface ApiTarget {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
origin: string;
|
|
8
|
+
file: ts.SourceFile | null;
|
|
9
|
+
statements: ts.Statement[];
|
|
10
|
+
thirdParty: string | null;
|
|
11
|
+
members: ts.Symbol[] | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ImportBinding {
|
|
15
|
+
specifier: string;
|
|
16
|
+
imported: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//* Statements come from the emitted `.d.ts`, which also holds what the emit adds, such as a mixin class's `X_base`.
|
|
20
|
+
export class ApiTargets {
|
|
21
|
+
readonly #program: ts.Program;
|
|
22
|
+
readonly #checker: ts.TypeChecker;
|
|
23
|
+
readonly #emitted: ReadonlyMap<string, string>;
|
|
24
|
+
readonly #parsed = new Map<string, ts.SourceFile>();
|
|
25
|
+
readonly #indexes = new Map<ts.SourceFile, Map<string, ts.Statement[]>>();
|
|
26
|
+
readonly #imports = new Map<ts.SourceFile, Map<string, ImportBinding>>();
|
|
27
|
+
readonly #modules = new Map<string, ts.SourceFile | null>();
|
|
28
|
+
readonly #moduleExports = new Map<ts.SourceFile, Map<string, ts.Symbol>>();
|
|
29
|
+
readonly #references = new Map<string, ApiTarget[]>();
|
|
30
|
+
|
|
31
|
+
constructor(program: ts.Program, emitted: ReadonlyMap<string, string>) {
|
|
32
|
+
this.#program = program;
|
|
33
|
+
this.#checker = program.getTypeChecker();
|
|
34
|
+
this.#emitted = emitted;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exportsOf(sourceFile: ts.SourceFile) {
|
|
38
|
+
const moduleSymbol = this.#checker.getSymbolAtLocation(sourceFile);
|
|
39
|
+
return moduleSymbol ? this.#checker.getExportsOfModule(moduleSymbol) : [];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
typeTextOf(symbol: ts.Symbol) {
|
|
43
|
+
const target = symbol.flags & ts.SymbolFlags.Alias ? this.#checker.getAliasedSymbol(symbol) : symbol;
|
|
44
|
+
return this.#checker.typeToString(
|
|
45
|
+
this.#checker.getTypeOfSymbol(target),
|
|
46
|
+
undefined,
|
|
47
|
+
ts.TypeFormatFlags.NoTruncation,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
ofSymbol(symbol: ts.Symbol): ApiTarget[] {
|
|
52
|
+
const target = symbol.flags & ts.SymbolFlags.Alias ? this.#checker.getAliasedSymbol(symbol) : symbol;
|
|
53
|
+
const targets = new Map<string, ApiTarget>();
|
|
54
|
+
for (const declaration of target.declarations ?? []) {
|
|
55
|
+
const resolved = this.#ofDeclaration(declaration);
|
|
56
|
+
if (resolved && !targets.has(resolved.id)) targets.set(resolved.id, resolved);
|
|
57
|
+
}
|
|
58
|
+
return [...targets.values()];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
expand(targets: ApiTarget[], seen = new Set<string>()): ApiTarget[] {
|
|
62
|
+
return targets.flatMap((target) => {
|
|
63
|
+
if (!target.members) return [target];
|
|
64
|
+
if (seen.has(target.id)) return [];
|
|
65
|
+
seen.add(target.id);
|
|
66
|
+
return this.expand(
|
|
67
|
+
target.members.flatMap((member) => this.ofSymbol(member)),
|
|
68
|
+
seen,
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
referencesOf(target: ApiTarget): ApiTarget[] {
|
|
74
|
+
const cached = this.#references.get(target.id);
|
|
75
|
+
if (cached) return cached;
|
|
76
|
+
const file = target.file;
|
|
77
|
+
const found = file
|
|
78
|
+
? target.statements.flatMap((statement) =>
|
|
79
|
+
this.#referencesIn(ApiDeclarationPrinter.prepared(statement), file, target.origin),
|
|
80
|
+
)
|
|
81
|
+
: [];
|
|
82
|
+
const references = this.expand(found);
|
|
83
|
+
this.#references.set(target.id, references);
|
|
84
|
+
return references;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
#ofDeclaration(declaration: ts.Declaration): ApiTarget | null {
|
|
88
|
+
if (ts.isSourceFile(declaration)) {
|
|
89
|
+
return {
|
|
90
|
+
id: `${declaration.fileName}\0*`,
|
|
91
|
+
name: "*",
|
|
92
|
+
origin: declaration.fileName,
|
|
93
|
+
file: null,
|
|
94
|
+
statements: [],
|
|
95
|
+
thirdParty: ApiTargets.packageOf(declaration.fileName),
|
|
96
|
+
members: this.exportsOf(declaration),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const sourceFile = declaration.getSourceFile();
|
|
100
|
+
const name = ApiTargets.localNameOf(declaration);
|
|
101
|
+
if (name === null) return null;
|
|
102
|
+
const thirdParty = ApiTargets.packageOf(sourceFile.fileName);
|
|
103
|
+
const base = { id: `${sourceFile.fileName}\0${name}`, name, origin: sourceFile.fileName, members: null };
|
|
104
|
+
if (thirdParty) return { ...base, file: null, statements: [], thirdParty };
|
|
105
|
+
const file = sourceFile.isDeclarationFile ? sourceFile : this.#declarationFileOf(sourceFile);
|
|
106
|
+
if (!file) return { ...base, file: null, statements: [], thirdParty: null };
|
|
107
|
+
const statements = this.#indexOf(file).get(name);
|
|
108
|
+
if (statements) return { ...base, file, statements, thirdParty: null };
|
|
109
|
+
const nested = ApiTargets.#statementOf(declaration);
|
|
110
|
+
return {
|
|
111
|
+
...base,
|
|
112
|
+
id: `${base.id}\0${declaration.pos}`,
|
|
113
|
+
file,
|
|
114
|
+
statements: nested && sourceFile.isDeclarationFile ? [nested] : [],
|
|
115
|
+
thirdParty: null,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
#referencesIn(root: ts.Node, file: ts.SourceFile, origin: string): ApiTarget[] {
|
|
120
|
+
const found: ApiTarget[] = [];
|
|
121
|
+
const visit = (node: ts.Node) => {
|
|
122
|
+
if (ts.isTypeReferenceNode(node))
|
|
123
|
+
found.push(...this.#resolve(ApiTargets.#segmentsOf(node.typeName), node, file, origin));
|
|
124
|
+
else if (ts.isExpressionWithTypeArguments(node))
|
|
125
|
+
found.push(...this.#resolve(ApiTargets.#segmentsOf(node.expression), node, file, origin));
|
|
126
|
+
else if (ts.isTypeQueryNode(node))
|
|
127
|
+
found.push(...this.#resolve(ApiTargets.#segmentsOf(node.exprName), node, file, origin));
|
|
128
|
+
else if (ts.isComputedPropertyName(node))
|
|
129
|
+
found.push(...this.#resolve(ApiTargets.#segmentsOf(node.expression), node, file, origin));
|
|
130
|
+
else if (ts.isImportTypeNode(node)) found.push(...this.#resolveImportType(node, origin));
|
|
131
|
+
ts.forEachChild(node, visit);
|
|
132
|
+
};
|
|
133
|
+
visit(root);
|
|
134
|
+
return found;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#resolve(segments: string[] | null, at: ts.Node, file: ts.SourceFile, origin: string): ApiTarget[] {
|
|
138
|
+
const [head, next] = segments ?? [];
|
|
139
|
+
if (!head || ApiTargets.#isTypeParameter(at, head)) return [];
|
|
140
|
+
const local = this.#indexOf(file).get(head);
|
|
141
|
+
if (local) return [this.#local(file, origin, head, local)];
|
|
142
|
+
const binding = this.#importsOf(file).get(head);
|
|
143
|
+
if (!binding) return [];
|
|
144
|
+
const module = this.#moduleOf(binding.specifier, origin);
|
|
145
|
+
if (!module) return [];
|
|
146
|
+
if (binding.imported !== "*") return this.#exported(module, binding.imported);
|
|
147
|
+
return next ? this.#exported(module, next) : this.#namespaceOf(module);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
#resolveImportType(node: ts.ImportTypeNode, origin: string): ApiTarget[] {
|
|
151
|
+
const argument = node.argument;
|
|
152
|
+
if (!ts.isLiteralTypeNode(argument) || !ts.isStringLiteral(argument.literal)) return [];
|
|
153
|
+
const module = this.#moduleOf(argument.literal.text, origin);
|
|
154
|
+
if (!module) return [];
|
|
155
|
+
const [name] = node.qualifier ? (ApiTargets.#segmentsOf(node.qualifier) ?? []) : [];
|
|
156
|
+
return name ? this.#exported(module, name) : this.#namespaceOf(module);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
#local(file: ts.SourceFile, origin: string, name: string, statements: ts.Statement[]): ApiTarget {
|
|
160
|
+
return { id: `${origin}\0${name}`, name, origin, file, statements, thirdParty: null, members: null };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
#exported(module: ts.SourceFile, name: string) {
|
|
164
|
+
const symbol = this.#moduleExportsOf(module).get(name);
|
|
165
|
+
return symbol ? this.ofSymbol(symbol) : [];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#namespaceOf(module: ts.SourceFile): ApiTarget[] {
|
|
169
|
+
return [
|
|
170
|
+
{
|
|
171
|
+
id: `${module.fileName}\0*`,
|
|
172
|
+
name: "*",
|
|
173
|
+
origin: module.fileName,
|
|
174
|
+
file: null,
|
|
175
|
+
statements: [],
|
|
176
|
+
thirdParty: null,
|
|
177
|
+
members: [...this.#moduleExportsOf(module).values()],
|
|
178
|
+
},
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
#moduleExportsOf(module: ts.SourceFile) {
|
|
183
|
+
const cached = this.#moduleExports.get(module);
|
|
184
|
+
if (cached) return cached;
|
|
185
|
+
const exports = new Map(this.exportsOf(module).map((symbol) => [symbol.getName(), symbol]));
|
|
186
|
+
this.#moduleExports.set(module, exports);
|
|
187
|
+
return exports;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
#moduleOf(specifier: string, origin: string) {
|
|
191
|
+
const key = `${origin}\0${specifier}`;
|
|
192
|
+
if (this.#modules.has(key)) return this.#modules.get(key) ?? null;
|
|
193
|
+
const resolved = ts.resolveModuleName(specifier, origin, this.#program.getCompilerOptions(), ts.sys).resolvedModule;
|
|
194
|
+
const fileName = resolved?.resolvedFileName;
|
|
195
|
+
const module = fileName && !ApiTargets.packageOf(fileName) ? (this.#program.getSourceFile(fileName) ?? null) : null;
|
|
196
|
+
this.#modules.set(key, module);
|
|
197
|
+
return module;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
#declarationFileOf(sourceFile: ts.SourceFile) {
|
|
201
|
+
const cached = this.#parsed.get(sourceFile.fileName);
|
|
202
|
+
if (cached) return cached;
|
|
203
|
+
const text = this.#emitted.get(sourceFile.fileName);
|
|
204
|
+
if (text === undefined) return null;
|
|
205
|
+
const fileName = sourceFile.fileName.replace(/\.tsx?$/, ".d.ts");
|
|
206
|
+
const parsed = ts.createSourceFile(fileName, text, ts.ScriptTarget.Latest, true);
|
|
207
|
+
this.#parsed.set(sourceFile.fileName, parsed);
|
|
208
|
+
return parsed;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
#indexOf(file: ts.SourceFile) {
|
|
212
|
+
const cached = this.#indexes.get(file);
|
|
213
|
+
if (cached) return cached;
|
|
214
|
+
const index = new Map<string, ts.Statement[]>();
|
|
215
|
+
const add = (name: string, statement: ts.Statement) => index.set(name, [...(index.get(name) ?? []), statement]);
|
|
216
|
+
for (const statement of file.statements) {
|
|
217
|
+
if (ts.isVariableStatement(statement)) {
|
|
218
|
+
for (const declaration of statement.declarationList.declarations)
|
|
219
|
+
if (ts.isIdentifier(declaration.name))
|
|
220
|
+
add(declaration.name.text, ApiTargets.#narrowed(statement, declaration));
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
const name = ApiDeclarationPrinter.isNamed(statement) ? ApiTargets.localNameOf(statement) : null;
|
|
224
|
+
if (name !== null) add(name, statement);
|
|
225
|
+
}
|
|
226
|
+
this.#indexes.set(file, index);
|
|
227
|
+
return index;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
#importsOf(file: ts.SourceFile) {
|
|
231
|
+
const cached = this.#imports.get(file);
|
|
232
|
+
if (cached) return cached;
|
|
233
|
+
const bindings = new Map<string, ImportBinding>();
|
|
234
|
+
for (const statement of file.statements) {
|
|
235
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;
|
|
236
|
+
const specifier = statement.moduleSpecifier.text;
|
|
237
|
+
const clause = statement.importClause;
|
|
238
|
+
if (clause?.name) bindings.set(clause.name.text, { specifier, imported: "default" });
|
|
239
|
+
const named = clause?.namedBindings;
|
|
240
|
+
if (named && ts.isNamespaceImport(named)) bindings.set(named.name.text, { specifier, imported: "*" });
|
|
241
|
+
if (named && ts.isNamedImports(named))
|
|
242
|
+
for (const element of named.elements)
|
|
243
|
+
bindings.set(element.name.text, { specifier, imported: (element.propertyName ?? element.name).text });
|
|
244
|
+
}
|
|
245
|
+
this.#imports.set(file, bindings);
|
|
246
|
+
return bindings;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
static localNameOf(declaration: ts.Declaration): string | null {
|
|
250
|
+
const name = ts.getNameOfDeclaration(declaration);
|
|
251
|
+
if (name && ts.isIdentifier(name)) return name.text;
|
|
252
|
+
if (name) return null;
|
|
253
|
+
const modifiers = ts.canHaveModifiers(declaration) ? ts.getModifiers(declaration) : undefined;
|
|
254
|
+
return modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword) ? "default" : null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
static packageOf(fileName: string) {
|
|
258
|
+
const normalized = fileName.replaceAll("\\", "/");
|
|
259
|
+
const idx = normalized.lastIndexOf("/node_modules/");
|
|
260
|
+
if (idx < 0) return null;
|
|
261
|
+
const [scope = "", name = ""] = normalized.slice(idx + "/node_modules/".length).split("/");
|
|
262
|
+
return scope.startsWith("@") ? `${scope}/${name}` : scope;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
static #statementOf(declaration: ts.Declaration): ts.Statement | null {
|
|
266
|
+
if (ts.isVariableDeclaration(declaration)) {
|
|
267
|
+
const statement = declaration.parent.parent;
|
|
268
|
+
return ts.isVariableStatement(statement) ? ApiTargets.#narrowed(statement, declaration) : null;
|
|
269
|
+
}
|
|
270
|
+
return ApiDeclarationPrinter.isNamed(declaration) ? declaration : null;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
static #narrowed(statement: ts.VariableStatement, declaration: ts.VariableDeclaration) {
|
|
274
|
+
if (statement.declarationList.declarations.length === 1) return statement;
|
|
275
|
+
const narrowed = ts.factory.updateVariableStatement(
|
|
276
|
+
statement,
|
|
277
|
+
statement.modifiers,
|
|
278
|
+
ts.factory.updateVariableDeclarationList(statement.declarationList, [declaration]),
|
|
279
|
+
);
|
|
280
|
+
ts.setOriginalNode(narrowed, statement);
|
|
281
|
+
return narrowed;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
static #segmentsOf(node: ts.Node): string[] | null {
|
|
285
|
+
if (ts.isIdentifier(node)) return [node.text];
|
|
286
|
+
if (ts.isQualifiedName(node)) {
|
|
287
|
+
const left = ApiTargets.#segmentsOf(node.left);
|
|
288
|
+
return left && [...left, node.right.text];
|
|
289
|
+
}
|
|
290
|
+
if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name)) {
|
|
291
|
+
const left = ApiTargets.#segmentsOf(node.expression);
|
|
292
|
+
return left && [...left, node.name.text];
|
|
293
|
+
}
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
static #isTypeParameter(at: ts.Node, name: string) {
|
|
298
|
+
for (let node = at.parent; node && !ts.isSourceFile(node); node = node.parent) {
|
|
299
|
+
const typeParameters = (node as { typeParameters?: ts.NodeArray<ts.TypeParameterDeclaration> }).typeParameters;
|
|
300
|
+
if (typeParameters?.some((parameter) => parameter.name.text === name)) return true;
|
|
301
|
+
if (ts.isMappedTypeNode(node) && node.typeParameter.name.text === name) return true;
|
|
302
|
+
if (ts.isConditionalTypeNode(node) && ApiTargets.#infers(node.extendsType, name)) return true;
|
|
303
|
+
}
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
static #infers(node: ts.Node, name: string): boolean {
|
|
308
|
+
if (ts.isInferTypeNode(node) && node.typeParameter.name.text === name) return true;
|
|
309
|
+
return ts.forEachChild(node, (child) => ApiTargets.#infers(child, name) || undefined) ?? false;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Bump = "major" | "minor" | "patch";
|
|
2
|
+
|
|
3
|
+
export class ChangesetBump {
|
|
4
|
+
static readonly #rank: Record<Bump, number> = { patch: 0, minor: 1, major: 2 };
|
|
5
|
+
static readonly #entry = /^\s*(["']?)([^"'#:\s][^"'#:]*?)\1\s*:\s*(["']?)(major|minor|patch)\3\s*(?:#.*)?$/;
|
|
6
|
+
|
|
7
|
+
static of(text: string, packageName: string): Bump | null {
|
|
8
|
+
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text.replace(/^/, ""))?.[1] ?? "";
|
|
9
|
+
for (const line of frontmatter.split(/\r?\n/)) {
|
|
10
|
+
const match = ChangesetBump.#entry.exec(line);
|
|
11
|
+
if (match?.[2] === packageName) return match[4] as Bump;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static atLeast(bump: Bump | null, floor: Bump) {
|
|
17
|
+
return bump !== null && ChangesetBump.#rank[bump] >= ChangesetBump.#rank[floor];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -51,4 +51,25 @@ describe("ApplicationBuildReporter.printSummary", () => {
|
|
|
51
51
|
lines.indexOf("Route artifacts: dist/apps/shop/.akan/artifact"),
|
|
52
52
|
);
|
|
53
53
|
});
|
|
54
|
+
|
|
55
|
+
test("prints only the route JS budget warnings for a quiet build", () => {
|
|
56
|
+
const routeJsWarnings = [{ file: "apps/shop/akan.budget.json", message: "unreadable", fix: "correct it" }];
|
|
57
|
+
ApplicationBuildReporter.printRouteJsWarnings({ routeJsWarnings });
|
|
58
|
+
ApplicationBuildReporter.printRouteJsWarnings({});
|
|
59
|
+
|
|
60
|
+
expect(rawLog.mock.calls.map(([line]) => line)).toEqual([
|
|
61
|
+
"Warning: apps/shop/akan.budget.json: unreadable (correct it)",
|
|
62
|
+
]);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("prints each route JS budget warning of a build that only reports it", () => {
|
|
66
|
+
const routeJsWarnings = [
|
|
67
|
+
{ file: "apps/shop/akan.budget.json", message: "/:lang/memo loads 133,120 bytes brotli", fix: "shrink it" },
|
|
68
|
+
];
|
|
69
|
+
ApplicationBuildReporter.printSummary({ ...resultFor("main"), routeJsWarnings });
|
|
70
|
+
|
|
71
|
+
expect(rawLog.mock.calls.map(([line]) => line)).toContain(
|
|
72
|
+
"Warning: apps/shop/akan.budget.json: /:lang/memo loads 133,120 bytes brotli (shrink it)",
|
|
73
|
+
);
|
|
74
|
+
});
|
|
54
75
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { realpathSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
1
|
import { Logger } from "akanjs/common";
|
|
2
|
+
import { ErrorReport } from "../util/errorReport";
|
|
4
3
|
import { RouteJsBudget, type RouteJsBudgetWarning, type RouteJsSize } from "./routeJsBudget";
|
|
5
4
|
|
|
6
5
|
export interface ApplicationBuildPhaseResult {
|
|
@@ -40,63 +39,25 @@ export class ApplicationBuildReporter {
|
|
|
40
39
|
for (const line of RouteJsBudget.formatTable(result.routeJs)) Logger.rawLog(line);
|
|
41
40
|
Logger.rawLog("");
|
|
42
41
|
}
|
|
42
|
+
if (result.routeJsWarnings?.length) {
|
|
43
|
+
ApplicationBuildReporter.printRouteJsWarnings(result);
|
|
44
|
+
Logger.rawLog("");
|
|
45
|
+
}
|
|
43
46
|
Logger.rawLog(`Route artifacts: ${result.artifactDir}`);
|
|
44
47
|
Logger.rawLog(`Server output: ${result.outputDir}`);
|
|
45
48
|
Logger.rawLog(`Done in ${ApplicationBuildReporter.formatDuration(result.durationMs)}`);
|
|
46
49
|
if (result.environment === "local") Logger.rawLog(ApplicationBuildReporter.localBuildNotice);
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
static printRouteJsWarnings({ routeJsWarnings = [] }: Pick<ApplicationBuildResult, "routeJsWarnings">) {
|
|
53
|
+
for (const { file, message, fix } of routeJsWarnings) Logger.rawLog(`Warning: ${file}: ${message} (${fix})`);
|
|
54
|
+
}
|
|
55
|
+
|
|
49
56
|
static readonly localBuildNotice =
|
|
50
57
|
"Built for local: the server runs without endpoint rate limits, and boots on local defaults (Redis on localhost, the first database mode) where a deployment would stop to ask. For a host others can reach, run `akan build <app> --env main` with AKAN_PUBLIC_REPO_NAME and AKAN_PUBLIC_SERVE_DOMAIN set in the shell or the workspace .env.";
|
|
51
58
|
|
|
52
59
|
static formatError(error: unknown, workspaceRoot = process.cwd()): string {
|
|
53
|
-
|
|
54
|
-
const nestedMessages = error.errors
|
|
55
|
-
.map(
|
|
56
|
-
(nestedError, index) =>
|
|
57
|
-
ApplicationBuildReporter.formatError(nestedError, workspaceRoot).trim() || `Unknown error ${index + 1}`,
|
|
58
|
-
)
|
|
59
|
-
.map((message) => message.replace(/^/gm, " "))
|
|
60
|
-
.join("\n");
|
|
61
|
-
|
|
62
|
-
return nestedMessages ? `${error.message}\n${nestedMessages}` : error.message;
|
|
63
|
-
}
|
|
64
|
-
if (error instanceof Error) {
|
|
65
|
-
const causeMessage = error.cause
|
|
66
|
-
? `\nCaused by: ${ApplicationBuildReporter.formatError(error.cause, workspaceRoot)}`
|
|
67
|
-
: "";
|
|
68
|
-
return `${ApplicationBuildReporter.#withLocation(error.message, error, workspaceRoot)}${causeMessage}`;
|
|
69
|
-
}
|
|
70
|
-
if (typeof error === "object" && error !== null && "message" in error)
|
|
71
|
-
return ApplicationBuildReporter.#withLocation(String(error.message), error, workspaceRoot);
|
|
72
|
-
return String(error);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static #withLocation(message: string, error: object, workspaceRoot: string): string {
|
|
76
|
-
const { position } = error as { position?: { file: string; line: number; column: number } | null };
|
|
77
|
-
if (!position?.file) return message;
|
|
78
|
-
const file = ApplicationBuildReporter.#relativeToWorkspace(position.file, workspaceRoot);
|
|
79
|
-
const location = position.line > 0 ? `${file}:${position.line}:${position.column}` : file;
|
|
80
|
-
return message.includes(location) ? message : message.replace(/^.*/, (headline) => `${headline} (${location})`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Bun names the file by its realpath, so a workspace root reached through a symlink is matched by its own too.
|
|
84
|
-
static #relativeToWorkspace(file: string, workspaceRoot: string): string {
|
|
85
|
-
if (!path.isAbsolute(file)) return file;
|
|
86
|
-
for (const root of [workspaceRoot, ApplicationBuildReporter.#realpathOf(workspaceRoot)]) {
|
|
87
|
-
const relative = path.relative(root, file);
|
|
88
|
-
if (!relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative))
|
|
89
|
-
return relative.replaceAll(path.sep, "/");
|
|
90
|
-
}
|
|
91
|
-
return file;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
static #realpathOf(dir: string): string {
|
|
95
|
-
try {
|
|
96
|
-
return realpathSync(dir);
|
|
97
|
-
} catch {
|
|
98
|
-
return dir;
|
|
99
|
-
}
|
|
60
|
+
return ErrorReport.format(error, workspaceRoot);
|
|
100
61
|
}
|
|
101
62
|
|
|
102
63
|
static formatDuration(ms: number): string {
|
|
@@ -2,14 +2,15 @@ import { describe, expect, spyOn, test } from "bun:test";
|
|
|
2
2
|
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { AkanAppConfig } from "
|
|
6
|
-
import { ProductionLockfile } from "
|
|
5
|
+
import { AkanAppConfig } from "../akanConfig";
|
|
6
|
+
import { ProductionLockfile } from "../akanConfig/productionLockfile";
|
|
7
|
+
import type { App } from "../commandDecorators";
|
|
8
|
+
import { AppExecutor, Executor } from "../executors";
|
|
9
|
+
import { AllRoutesBuilder, type BuildAllRoutesResult, VendorNarrowing } from "../frontendBuild";
|
|
10
|
+
import { bundleDefine } from "../frontendBuild/bundleDefine";
|
|
11
|
+
import { createTempApp } from "../test/testHelpers";
|
|
12
|
+
import { ProjectTypecheck } from "../typecheck/projectTypecheck";
|
|
7
13
|
import { AKAN_BACKEND_MINIFY, AKAN_OPTIONAL_BACKEND_EXTERNALS, ApplicationBuildRunner } from "./applicationBuildRunner";
|
|
8
|
-
import type { App } from "./commandDecorators";
|
|
9
|
-
import { AppExecutor, Executor } from "./executors";
|
|
10
|
-
import { bundleDefine } from "./frontendBuild/bundleDefine";
|
|
11
|
-
import { createTempApp } from "./testHelpers";
|
|
12
|
-
import { ProjectTypecheck } from "./typecheck/projectTypecheck";
|
|
13
14
|
|
|
14
15
|
describe("ApplicationBuildRunner", () => {
|
|
15
16
|
test("externalizes Akan optional backend dependencies", () => {
|
|
@@ -307,6 +308,72 @@ console.info(new SampleService().name);
|
|
|
307
308
|
}
|
|
308
309
|
});
|
|
309
310
|
|
|
311
|
+
const buildSsrUntilVendors = async (routeChunkWritten: boolean) => {
|
|
312
|
+
const { root, workspace } = await createTempApp("portal");
|
|
313
|
+
const keys = ["AKAN_PUBLIC_ENV", "AKAN_PUBLIC_REPO_NAME", "AKAN_PUBLIC_SERVE_DOMAIN"] as const;
|
|
314
|
+
const shellEnv = Object.fromEntries(keys.map((key) => [key, process.env[key]]));
|
|
315
|
+
await Promise.all(["main.ts", "server.ts"].map((file) => writeFile(path.join(root, "apps", "portal", file), "")));
|
|
316
|
+
const app = AppExecutor.from(workspace, "portal");
|
|
317
|
+
app.prepareCommand = async () => ({ env: {} });
|
|
318
|
+
app.getPageKeys = async () => ["_index.tsx"];
|
|
319
|
+
const order: string[] = [];
|
|
320
|
+
let narrowed: Record<string, readonly string[]> = {};
|
|
321
|
+
const entryExports = VendorNarrowing.prototype.entryExports;
|
|
322
|
+
const bundle = spyOn(Bun, "build").mockImplementation(
|
|
323
|
+
async () => ({ success: true, outputs: [], logs: [] }) as unknown as Bun.BuildOutput,
|
|
324
|
+
);
|
|
325
|
+
const routes = spyOn(AllRoutesBuilder.prototype, "build").mockImplementation(async () => {
|
|
326
|
+
order.push("routes");
|
|
327
|
+
if (routeChunkWritten)
|
|
328
|
+
await Bun.write(
|
|
329
|
+
path.join(app.dist.cwdPath, ".akan/artifact/client/page-a1.js"),
|
|
330
|
+
'import{st}from"akanjs/store";',
|
|
331
|
+
);
|
|
332
|
+
const clientManifest = { "page#default": { id: "/_akan/client/page-a1.js", chunks: [], name: "default" } };
|
|
333
|
+
return { manifest: { routeIds: ["/"], clientManifest } } as unknown as BuildAllRoutesResult;
|
|
334
|
+
});
|
|
335
|
+
const vendors = spyOn(VendorNarrowing.prototype, "entryExports").mockImplementation(function (
|
|
336
|
+
this: VendorNarrowing,
|
|
337
|
+
entries,
|
|
338
|
+
) {
|
|
339
|
+
order.push("vendors");
|
|
340
|
+
narrowed = entryExports.call(this, entries);
|
|
341
|
+
throw new Error("stopped at the vendor build");
|
|
342
|
+
});
|
|
343
|
+
try {
|
|
344
|
+
const failure = await new ApplicationBuildRunner(app, { fast: true }).build().then(
|
|
345
|
+
() => "built",
|
|
346
|
+
(error: unknown) => (error instanceof Error ? error.message : String(error)),
|
|
347
|
+
);
|
|
348
|
+
return { failure, order, narrowed };
|
|
349
|
+
} finally {
|
|
350
|
+
bundle.mockRestore();
|
|
351
|
+
routes.mockRestore();
|
|
352
|
+
vendors.mockRestore();
|
|
353
|
+
for (const key of keys) {
|
|
354
|
+
if (shellEnv[key] === undefined) delete process.env[key];
|
|
355
|
+
else process.env[key] = shellEnv[key];
|
|
356
|
+
}
|
|
357
|
+
await rm(root, { recursive: true, force: true });
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
test("bundles the routes before the vendor entries, which export only the names the route chunks import", async () => {
|
|
362
|
+
const { failure, order, narrowed } = await buildSsrUntilVendors(true);
|
|
363
|
+
|
|
364
|
+
expect(failure).toBe("stopped at the vendor build");
|
|
365
|
+
expect(order).toEqual(["routes", "vendors"]);
|
|
366
|
+
expect(Object.entries(narrowed).find(([entry]) => entry.endsWith("akanjs-store.ts"))?.[1]).toEqual(["st"]);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
test("stops before the vendor entries when a route's client entry is not where the scan reads", async () => {
|
|
370
|
+
const { failure, order } = await buildSsrUntilVendors(false);
|
|
371
|
+
|
|
372
|
+
expect(failure).toContain("no file under");
|
|
373
|
+
expect(failure).toContain("/_akan/client/page-a1.js");
|
|
374
|
+
expect(order).toEqual(["routes"]);
|
|
375
|
+
});
|
|
376
|
+
|
|
310
377
|
test("akan typecheck names the script/ files nothing imports, and a build's typecheck leaves them out", async () => {
|
|
311
378
|
const { root, app } = await createTempApp("portal");
|
|
312
379
|
const run = spyOn(ProjectTypecheck.prototype, "run").mockImplementation(async () => "");
|
|
@@ -2,14 +2,9 @@ import path from "node:path";
|
|
|
2
2
|
import { toError } from "akanjs/common";
|
|
3
3
|
import { BUILD_ENV_FILE } from "akanjs/server/lifecycle/buildEnv";
|
|
4
4
|
import type { BunPlugin } from "bun";
|
|
5
|
-
import { ProductionLockfile } from "
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
ApplicationBuildProgressReporter,
|
|
9
|
-
ApplicationBuildResult,
|
|
10
|
-
} from "./applicationBuildReporter";
|
|
11
|
-
import type { App } from "./commandDecorators";
|
|
12
|
-
import { parseEnvFile, WorkspaceExecutor } from "./executors";
|
|
5
|
+
import { ProductionLockfile } from "../akanConfig/productionLockfile";
|
|
6
|
+
import type { App } from "../commandDecorators";
|
|
7
|
+
import { parseEnvFile, WorkspaceExecutor } from "../executors";
|
|
13
8
|
import {
|
|
14
9
|
AllRoutesBuilder,
|
|
15
10
|
CsrArtifactBuilder,
|
|
@@ -18,13 +13,18 @@ import {
|
|
|
18
13
|
precompressArtifacts,
|
|
19
14
|
SsrBaseArtifactBuilder,
|
|
20
15
|
VendorImportScanner,
|
|
21
|
-
} from "
|
|
16
|
+
} from "../frontendBuild";
|
|
17
|
+
import { createServerEnvPlugin } from "../transforms/serverEnvPlugin";
|
|
18
|
+
import { ServerEnvProfile } from "../transforms/serverEnvProfile";
|
|
19
|
+
import { ProjectTypecheck } from "../typecheck/projectTypecheck";
|
|
20
|
+
import { Spinner } from "../util/spinner";
|
|
21
|
+
import type { BaseDevEnv, PackageJson } from "../workspace/types";
|
|
22
|
+
import type {
|
|
23
|
+
ApplicationBuildPhaseResult,
|
|
24
|
+
ApplicationBuildProgressReporter,
|
|
25
|
+
ApplicationBuildResult,
|
|
26
|
+
} from "./applicationBuildReporter";
|
|
22
27
|
import { RouteJsBudget, type RouteJsBudgetMode, type RouteJsBudgetStatus, type RouteJsSize } from "./routeJsBudget";
|
|
23
|
-
import { Spinner } from "./spinner";
|
|
24
|
-
import { createServerEnvPlugin } from "./transforms/serverEnvPlugin";
|
|
25
|
-
import { ServerEnvProfile } from "./transforms/serverEnvProfile";
|
|
26
|
-
import { ProjectTypecheck } from "./typecheck/projectTypecheck";
|
|
27
|
-
import type { BaseDevEnv, PackageJson } from "./types";
|
|
28
28
|
|
|
29
29
|
export interface TypecheckOptions {
|
|
30
30
|
clean?: boolean;
|
|
@@ -55,7 +55,10 @@ export interface ApplicationBuildRunnerOptions {
|
|
|
55
55
|
environment?: string;
|
|
56
56
|
/** Bundles `env/env.server.<environment>.<profile>.ts`, which may hold no secret, in place of the environment's file. */
|
|
57
57
|
profile?: string;
|
|
58
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* `enforce` fails on an overage, a route with no entry, or a missing or unreadable akan.budget.json; `update` and
|
|
60
|
+
* `raise` rewrite the file first; `report` only warns.
|
|
61
|
+
*/
|
|
59
62
|
budget?: RouteJsBudgetMode;
|
|
60
63
|
}
|
|
61
64
|
export interface BuildOptions {
|
|
@@ -437,6 +440,7 @@ void run().catch((error) => {
|
|
|
437
440
|
const vendorExports = await VendorImportScanner.exportsUsedIn(
|
|
438
441
|
path.join(this.#app.dist.cwdPath, ".akan/artifact/client"),
|
|
439
442
|
NARROWABLE_VENDOR_SPECIFIERS,
|
|
443
|
+
Object.values(allRoutes.manifest.clientManifest).map(({ id }) => id),
|
|
440
444
|
);
|
|
441
445
|
const base = await new SsrBaseArtifactBuilder(this.#app, "build", {
|
|
442
446
|
serverEnv: this.#serverEnvPlugin(baseDevEnv.env, branches),
|
|
@@ -456,6 +460,7 @@ void run().catch((error) => {
|
|
|
456
460
|
const budgetPath = path.join(this.#app.cwdPath, RouteJsBudget.fileName);
|
|
457
461
|
const { summary: status, warnings } = await RouteJsBudget.check(sizes, {
|
|
458
462
|
mode: this.#budget,
|
|
463
|
+
app: this.#app.name,
|
|
459
464
|
budgetPath,
|
|
460
465
|
source: path.relative(this.#app.workspace.workspaceRoot, budgetPath),
|
|
461
466
|
environment,
|
|
@@ -23,7 +23,7 @@ export async function resolveSignalTestPreloadPath(target: SignalTestPreloadTarg
|
|
|
23
23
|
path.join(process.cwd(), "node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH),
|
|
24
24
|
path.join(process.cwd(), "pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH),
|
|
25
25
|
path.join(path.dirname(Bun.main), "../../akanjs", SIGNAL_TEST_PRELOAD_PATH),
|
|
26
|
-
path.resolve(import.meta.dir, "
|
|
26
|
+
path.resolve(import.meta.dir, "../../../akanjs", SIGNAL_TEST_PRELOAD_PATH),
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
const uniqueCandidates = [...new Set(candidates)];
|