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

docs(cli): improve upgrade message #18195

Merged
merged 2 commits into from
Jan 3, 2022

Conversation

blimmer
Copy link
Contributor

@blimmer blimmer commented Dec 27, 2021

This PR relates to #18024. It adds information on upgrading between major versions to the upgrade banner.


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

@gitpod-io
Copy link

gitpod-io bot commented Dec 27, 2021

@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Dec 27, 2021

const exec = promisify(_exec);

export async function getLatestVersionFromNpm(): Promise<string> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I broke this method out into a separate file/module so I can easily stub it in tests. It's challenging/confusing to mock a method in the same file with Jest or Sinon (see https://stackoverflow.com/questions/45111198/how-to-mock-functions-in-the-same-module-using-jest and https://stackoverflow.com/questions/39861674/stubbing-method-in-same-file-using-sinon)

if (!process.stdout.isTTY || process.env.CDK_DISABLE_VERSION_CHECK) {
return;
}

try {
const versionCheckCache = new VersionCheckTTL();
const laterVersion = await latestVersionIfHigher(versionNumber(), versionCheckCache);
const laterVersion = await latestVersionIfHigher(currentVersion, versionCheckCache ?? new VersionCheckTTL());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the ability to pass a version check file via dependency injection to this method to add additional tests. This ensures that the tests aren't mucking with the global version check file.

process.stdout.isTTY = true;
process.env.CDK_DISABLE_VERSION_CHECK = '1';
sinon.stub(process, 'stdout').value({ ...process.stdout, isTTY: true });
sinon.stub(process, 'env').value({ ...process.env, CDK_DISABLE_VERSION_CHECK: '1' });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this test from directly setting these global "process" variables to stubbing them with sinon. This ensures that the values get set back to their original values after the tests run. Before this change, the CDK_DISABLE_VERSION_CHECK environment variable was still set in the environment, causing my new tests below to fail.

@blimmer blimmer force-pushed the blimmer/improve-upgrade-message branch from 16d2b37 to 2816093 Compare December 27, 2021 23:05
@blimmer blimmer changed the title feat(cli): improve upgrade message docs(cli): improve upgrade message Dec 27, 2021
@blimmer blimmer marked this pull request as ready for review December 27, 2021 23:06
@blimmer blimmer force-pushed the blimmer/improve-upgrade-message branch from 2816093 to ce8a001 Compare December 27, 2021 23:20
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

This is great, thanks!

@mergify
Copy link
Contributor

mergify bot commented Jan 3, 2022

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).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: f508b43
  • 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 e1d7efa into aws:master Jan 3, 2022
@mergify
Copy link
Contributor

mergify bot commented Jan 3, 2022

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).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
This PR relates to aws#18024. It adds information on upgrading between major versions to the upgrade banner.

----

*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
package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants