-
Notifications
You must be signed in to change notification settings - Fork 76
fix(cli): cdk watch glob pattern support broken after chokidar v3 -> v4 upgrade #1134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1134 +/- ##
==========================================
+ Coverage 87.71% 87.72% +0.01%
==========================================
Files 72 72
Lines 10116 10129 +13
Branches 1337 1337
==========================================
+ Hits 8873 8886 +13
Misses 1217 1217
Partials 26 26
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
new-app.zip |
Fixes #1126
Description
The
cdk watchcommand stopped working correctly after upgrading to CDK CLI v2.1100.1+. File changes were not being detected, causing watch mode to appear broken.Root Cause
Chokidar v4 removed built-in glob pattern support. The CDK CLI was passing glob patterns like
**,**/*.tsdirectly tochokidar.watch(), which no longer expands them. Instead, chokidar v4 treats these as literal file paths.Solution
Use
picomatchlibrary to handle glob pattern matching. The fix created acreateIgnoreMatcherutility in toolkit-lib that:rootDirmy-dir→my-dir/**) for backward compatibilitytoolkit-libandaws-cdk:chokidar.watch(patterns, ...)tochokidar.watch('.', { ignored: fn, cwd: rootDir })Fixed default include pattern in aws-cdk:
**glob patternThis is a backwards-compatible change and there were no changes to the public API. Users continue to configure watch the same way in
cdk.json:{ "watch": { "include": ["**/*.ts", "**/*.js"], "exclude": ["node_modules/**", "cdk.out/**"] } }Testing
cdkbinary; verified that the currently released version does not work, then verified the new changes function as expected, and behave the same as versions before 2.1100.1 (see logs)createIgnoreMatcherincluding pattern normalizationtoolkit-libaws-cdkto verify filtering behaviorLogs
Tested on MacOS. Initialized a new CDK app and ran
cdk watchusing CDK CLI v2.1100.0 (version beforecdk watchstopped working). See annotated logs.Logs from
cdk watchusing CDK CLI v2.1100.0 (previously working version) in a sample projectHere, I create a new file called
track-me-please, to verifywatchredeploys the appHere, I make a change to lib/new-app-stack.ts to verify
watchredeploys the appDuring this run, I also create a file called
.dont-track-meand make a change totest/new-app.test.ts. Neither of these changes result in a deployment. This validates that these files are properly ignored.Then, I ran
cdk watchusing my locally builtcdk(new changes). See annotated logs.Logs from
cdk watchusing locally built CDK CLI in a sample projectNote that these logs immediately follow the logs above.
Here, I create a new file called
track-me-too.watchdeploys, as expected.Here, I make a change to
lib/new-app-stack.ts, which triggers a deployment, as expected.I also verified that the latest version of the CDK CLI does not track files correctly. Below are the logs, which show no activity, even though I made several file changes. The logs also do not indicate that
watchis tracking any files.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license