Skip to content

fix(cli): guide Stage users to a working pattern in stack-selection error - #1847

Open
lemon0333 wants to merge 1 commit into
aws:mainfrom
lemon0333:fix/deploy-all-stages-message
Open

fix(cli): guide Stage users to a working pattern in stack-selection error#1847
lemon0333 wants to merge 1 commit into
aws:mainfrom
lemon0333:fix/deploy-all-stages-message

Conversation

@lemon0333

Copy link
Copy Markdown
Contributor

Fixes #1451

When an app has more than one stack and no selector is given, cdk deploy prints:

Since this app includes more than a single stack, specify which stacks to use (wildcards are supported) or specify --all

When the stacks live inside a Stage, this message is unhelpful: their ids are namespaced like StageName/StackName, and neither a bare stack name nor --all is the obvious way to target them, so users are left guessing (see #1451).

This change detects stacks that are nested inside a Stage (i.e. stacks that are not top-level stacks) and additionally points the user at a wildcard pattern that selects them, e.g.:

Some of these stacks are nested inside a Stage. To select the stacks in a Stage, use a pattern that matches their full path, e.g. 'StageName/*'

The hint is only appended when staged stacks are actually present, so flat apps are unaffected. The Stage detection is structural (stacks present recursively but not at the top level) rather than string-based, so a top-level stack whose display name happens to contain / is not misclassified. The same message is shared by the CLI stack-selection path (cloud-assembly.ts) and the toolkit-lib selectStacksV2 path, so both are updated for consistency.

Unit tests were added on both selector/error paths (Stage guidance present when nested, absent for flat apps, and stage patterns de-duplicated across multiple stages).

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

…rror

When an app has more than one stack and no selector is given, the CLI
prints "specify which stacks to use ... or `--all`". When the stacks
live inside a Stage, `--all` and a bare stack name are not the obvious
way to target them, so the message was unhelpful for Stage users.

Detect stacks that are nested inside a Stage (i.e. not top-level stacks)
and additionally point the user at a wildcard pattern that selects them,
e.g. `'StageName/*'`. Applied to both the CLI stack selection path and
the toolkit-lib `selectStacksV2` path, which share the same message.

Fixes aws#1451
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.44%. Comparing base (88f6ad1) to head (dd1cea6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1847      +/-   ##
==========================================
+ Coverage   90.31%   90.44%   +0.12%     
==========================================
  Files          80       80              
  Lines       12159    12188      +29     
  Branches     1725     1737      +12     
==========================================
+ Hits        10982    11024      +42     
+ Misses       1143     1130      -13     
  Partials       34       34              
Flag Coverage Δ
suite.unit 90.44% <100.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(deploy): cdk deploy suggests --all but it does not work with Stages

2 participants