Skip to content

docs(cli): improve upgrade message#18195

Merged
mergify[bot] merged 2 commits intoaws:masterfrom
blimmer:blimmer/improve-upgrade-message
Jan 3, 2022
Merged

docs(cli): improve upgrade message#18195
mergify[bot] merged 2 commits intoaws:masterfrom
blimmer:blimmer/improve-upgrade-message

Conversation

@blimmer
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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)

try {
const versionCheckCache = new VersionCheckTTL();
const laterVersion = await latestVersionIfHigher(versionNumber(), versionCheckCache);
const laterVersion = await latestVersionIfHigher(currentVersion, versionCheckCache ?? new VersionCheckTTL());
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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