Skip to content

refactor(cli): route synth through toolkit-lib - #1852

Draft
iankhou wants to merge 1 commit into
synth-io-snapshotsfrom
synth-toolkit-migration
Draft

refactor(cli): route synth through toolkit-lib#1852
iankhou wants to merge 1 commit into
synth-io-snapshotsfrom
synth-toolkit-migration

Conversation

@iankhou

@iankhou iankhou commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Note

Stacked on #1865 (the synth IO-snapshot baseline, generated against the current synth CLI implementation)

Reason for this change

cdk synth uses a legacy in-CLI implementation, while the we have similar logic in @aws-cdk/toolkit-lib (where commands like validate, list, metadata, and destroy already delegate). This change reroutes synth's validation and result emission through the toolkit-lib.

Description of changes

The design is "CLI selects, toolkit renders":

  • Stack selection stays CLI-side, preserving historical semantics
  • CliIoHost listeners map the toolkit messages onto the legacy output
  • Cleanup: deletes printSerializedObject and the obscureTemplate import (legacy-synth-only), removes selectStacksForDiff's now-dead autoValidate parameter, and extracts the shared pattern selection into selectStacksByPattern (used by both diff and synth).

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

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@iankhou
iankhou changed the base branch from main to synth-io-snapshots August 20, 2026 14:41
@iankhou
iankhou deployed to no-approval August 20, 2026 14:42 — with GitHub Actions Active
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants