docs(cli): improve upgrade message#18195
Conversation
|
|
||
| const exec = promisify(_exec); | ||
|
|
||
| export async function getLatestVersionFromNpm(): Promise<string> { |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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' }); |
There was a problem hiding this comment.
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.
16d2b37 to
2816093
Compare
2816093 to
ce8a001
Compare
|
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
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). |
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*
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