refactor(cli): route synth through toolkit-lib - #1852
Draft
iankhou wants to merge 1 commit into
Draft
Conversation
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Reroutes `cdk synth`'s validation and result emission through the toolkit-lib `Toolkit.synth` action, replacing the legacy in-CLI implementation, with no change to user-visible output: against the committed 16-scenario IO snapshot baseline, the only recorded differences are message codes (the template and success messages now carry CDK_TOOLKIT_I1901/I1902 instead of no code, matching what the list migration did for I2901). Stack selection stays CLI-side to preserve the historical semantics and error messages exactly (the MainAssembly default including the empty selection for stage-only apps, and the NoStacksMatched message with the autoValidate nuance); the selected hierarchical ids are passed through to toolkit-lib verbatim, escaped for picomatch since ids are unrestricted strings and would otherwise be re-interpreted as glob patterns. CliIoHost listeners map the toolkit messages onto the historical output, following the list/metadata/destroy precedent: the single-stack I1901 result is rewritten to the (already obscured) template — or suppressed under --quiet — the multi-stack I1902 success line is releveled from result to info, and the toolkit-lib synthesis span lines are dropped (legacy synth never printed a synthesis-time line). The flags-message CI gating is unchanged and keys off the CLI-side selection count. Also deletes printSerializedObject and the obscureTemplate import (only used by the legacy synth path), removes selectStacksForDiff's now-dead autoValidate parameter, and extracts the shared pattern selection into selectStacksByPattern, used by both diff and synth.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Stacked on #1865 (the synth IO-snapshot baseline, generated against the current
synthCLI implementation)Reason for this change
cdk synthuses a legacy in-CLI implementation, while the we have similar logic in@aws-cdk/toolkit-lib(where commands likevalidate,list,metadata, anddestroyalready delegate). This change reroutes synth's validation and result emission through the toolkit-lib.Description of changes
The design is "CLI selects, toolkit renders":
CliIoHostlisteners map the toolkit messages onto the legacy outputprintSerializedObjectand theobscureTemplateimport (legacy-synth-only), removesselectStacksForDiff's now-deadautoValidateparameter, and extracts the shared pattern selection intoselectStacksByPattern(used by bothdiffandsynth).Describe any new or updated permissions being added
None.
Description of how you validated changes
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license