generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 69
chore(cli): show warning when using deprecated version #102
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b6331f5
add logic and new test
tttol a56d547
fix test
tttol bf4a6a3
fix test
tttol 398b8be
Improve version checking and npm interaction
tttol 6672b83
Add timeout to npm view command
tttol 64e08b5
Pass current version to npm view command
tttol ca2de44
Merge branch 'main' into show-deprecation-msg
tttol 3c2979f
exec two npm call in parallel
tttol 381c90e
Fixed issues from PR feedback
tttol b73dc5b
update legacy-exports
tttol 24cf0e8
Merge branch 'main' into show-deprecation-msg
tttol 755c7d9
Merge branch 'main' into show-deprecation-msg
tttol f96ec8f
fix for pr comment
tttol 13784e5
Merge branch 'main' into show-deprecation-msg
tttol 1b0356a
remove unnecessary changes
tttol dcc358a
Merge branch 'main' into show-deprecation-msg
tttol 5a7dac0
fix lint error
tttol 7fb137e
Merge branch 'main' into show-deprecation-msg
tttol 4e75e79
Merge remote-tracking branch 'origin/main' into show-deprecation-msg
mrgrain 0d97797
Merge branch 'main' into show-deprecation-msg
mrgrain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,34 @@ | ||
| import { exec as _exec } from 'child_process'; | ||
| import { promisify } from 'util'; | ||
| import * as semver from 'semver'; | ||
| import { ToolkitError } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api'; | ||
| import { debug } from '../../logging'; | ||
|
|
||
| const exec = promisify(_exec); | ||
|
|
||
| /* c8 ignore start */ // not called during unit tests | ||
| export async function getLatestVersionFromNpm(): Promise<string> { | ||
| const { stdout, stderr } = await exec('npm view aws-cdk version', { timeout: 3000 }); | ||
| if (stderr && stderr.trim().length > 0) { | ||
| debug(`The 'npm view' command generated an error stream with content [${stderr.trim()}]`); | ||
| } | ||
| const latestVersion = stdout.trim(); | ||
| if (!semver.valid(latestVersion)) { | ||
| throw new ToolkitError(`npm returned an invalid semver ${latestVersion}`); | ||
| } | ||
| /* c8 ignore start */ | ||
| export async function execNpmView(currentVersion: string) { | ||
| try { | ||
| // eslint-disable-next-line @cdklabs/promiseall-no-unbounded-parallelism | ||
| const [latestResult, currentResult] = await Promise.all([ | ||
| exec('npm view aws-cdk@latest version', { timeout: 3000 }), | ||
| exec(`npm view aws-cdk@${currentVersion} name version deprecated --json`, { timeout: 3000 }), | ||
| ]); | ||
|
|
||
| if (latestResult.stderr && latestResult.stderr.trim().length > 0) { | ||
| throw new ToolkitError(`npm view command for latest version failed: ${latestResult.stderr.trim()}`); | ||
| } | ||
| if (currentResult.stderr && currentResult.stderr.trim().length > 0) { | ||
| throw new ToolkitError(`npm view command for current version failed: ${currentResult.stderr.trim()}`); | ||
| } | ||
|
|
||
| return latestVersion; | ||
| const latestVersion = latestResult.stdout; | ||
| const currentInfo = JSON.parse(currentResult.stdout); | ||
|
|
||
| return { | ||
| latestVersion: latestVersion, | ||
| deprecated: currentInfo.deprecated, | ||
| }; | ||
| } catch (err: unknown) { | ||
| throw err; | ||
| } | ||
| } | ||
| /* c8 ignore stop */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please make sure no other changes than the removal are in this file
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed unnecessary changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only correct if you assume the
latestpointer never points to a deprecated version. If that's something you assume, you should put it in a comment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the comment 👍