Skip to content
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

feat(cli): introduce the 'watch' command #17240

Merged
merged 1 commit into from
Nov 5, 2021

Conversation

skinny85
Copy link
Contributor

This PR introduces the "watch" command, in two variants: as a separate new cdk watch command,
and as an argument to the existing cdk deploy command.

The "watch" process will observe the project files, defined by the new "include" and "exclude" settings in cdk.json
(see aws/aws-cdk-rfcs#383 for details),
and will trigger a cdk deploy when it detects any changes.
The deployment will by default use the new "hotswap" deployments for maximum speed.

Since cdk deploy is a relatively slow process for a "watch" command,
there is some logic to perform intelligent queuing of any file events that happen while cdk deploy is running.
We will batch all of those events, and trigger a single cdk deploy after the current one finishes.
This ensures only a single cdk deploy command ever executes at a time.

The observing of the files, and reacting to their changes, is accomplished using the chokidar library.


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

@skinny85 skinny85 requested review from rix0rrr and eladb October 30, 2021 01:04
@skinny85 skinny85 self-assigned this Oct 30, 2021
@gitpod-io
Copy link

gitpod-io bot commented Oct 30, 2021

@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Oct 30, 2021
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 30, 2021
packages/aws-cdk/README.md Show resolved Hide resolved
packages/aws-cdk/README.md Outdated Show resolved Hide resolved
packages/aws-cdk/README.md Outdated Show resolved Hide resolved
packages/aws-cdk/README.md Outdated Show resolved Hide resolved
packages/aws-cdk/README.md Show resolved Hide resolved
packages/aws-cdk/lib/cdk-toolkit.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/cdk-toolkit.ts Show resolved Hide resolved
packages/aws-cdk/lib/cdk-toolkit.ts Show resolved Hide resolved
packages/aws-cdk/lib/cdk-toolkit.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/cdk-toolkit.ts Outdated Show resolved Hide resolved
@skinny85
Copy link
Contributor Author

skinny85 commented Nov 2, 2021

@eladb thanks so much for the thorough review! I've incorporated most of your comments, and asked a few clarifying questions for the rest of them. If you could make another pass through the comments, and the code, I would appreciate it - let's get this feature merged! 😊

Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a few comments

@eladb eladb added the pr/do-not-merge This PR should not be merged at this time. label Nov 2, 2021
@skinny85 skinny85 removed the pr/do-not-merge This PR should not be merged at this time. label Nov 5, 2021
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 563666d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 0adc8b7 into aws:master Nov 5, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 5, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@skinny85 skinny85 deleted the cdk-watch-watch branch November 5, 2021 02:35
iliapolo pushed a commit that referenced this pull request Nov 7, 2021
This PR introduces the "watch" command, in two variants: as a separate new `cdk watch` command,
and as an argument to the existing `cdk deploy` command.

The "watch" process will observe the project files, defined by the new `"include"` and `"exclude"` settings in `cdk.json`
(see aws/aws-cdk-rfcs#383 for details),
and will trigger a `cdk deploy` when it detects any changes.
The deployment will by default use the new "hotswap" deployments for maximum speed.

Since `cdk deploy` is a relatively slow process for a "watch" command,
there is some logic to perform intelligent queuing of any file events that happen while `cdk deploy` is running.
We will batch all of those events, and trigger a single `cdk deploy` after the current one finishes.
This ensures only a single `cdk deploy` command ever executes at a time.

The observing of the files, and reacting to their changes, is accomplished using the [`chokidar` library](https://www.npmjs.com/package/chokidar).

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
This PR introduces the "watch" command, in two variants: as a separate new `cdk watch` command,
and as an argument to the existing `cdk deploy` command.

The "watch" process will observe the project files, defined by the new `"include"` and `"exclude"` settings in `cdk.json`
(see aws/aws-cdk-rfcs#383 for details),
and will trigger a `cdk deploy` when it detects any changes.
The deployment will by default use the new "hotswap" deployments for maximum speed.

Since `cdk deploy` is a relatively slow process for a "watch" command,
there is some logic to perform intelligent queuing of any file events that happen while `cdk deploy` is running.
We will batch all of those events, and trigger a single `cdk deploy` after the current one finishes.
This ensures only a single `cdk deploy` command ever executes at a time.

The observing of the files, and reacting to their changes, is accomplished using the [`chokidar` library](https://www.npmjs.com/package/chokidar).

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants