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

chore(cli): show warning when using deprecated version #102

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tttol
Copy link
Contributor

@tttol tttol commented Feb 23, 2025

Fixes aws/aws-cdk#298

What I changed

Show the warning message when Toolkit uses deprecated version of aws-cdk. The message is like below.

You are using deprecated version(aws-cdk@X.X.X): This version has been deprecated

Additional information

  • I'm new to aws-cdk.
  • I didn't submit PR to aws-cdk-cli-testing because I think that integration test is not needed in my change. But I am not confident in my judgment. Please let me know if additional integration tests are needed.

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

@tttol tttol changed the title chore(cli):show warning when using deprecated version chore(cli): show warning when using deprecated version Feb 23, 2025

export async function checkIfDeprecated(version: string): Promise<string | null> {
try {
const { stdout, stderr } = await exec(`npm view aws-cdk@${version} deprecated --silent`, { timeout: 3000 });
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you work this into the existing version check in some way? (it may be that you will need to change that existing check to return information about more than 1 version at a time).

I'd like to avoid doing unnecessary calls to NPM.

Copy link
Contributor Author

@tttol tttol Feb 25, 2025

Choose a reason for hiding this comment

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

@rix0rrr
It's true that my implementation results in unnecessary NPM calls. But I couldn't find the logic of version check in existing source code. Which logic/file are you referring when you said work this into the existing version check?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@tttol tttol Mar 3, 2025

Choose a reason for hiding this comment

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

@rix0rrr
Do you mean that calling checkIfDeprecated out of if (laterVersion) block is better?
Ref: https://github.com/aws/aws-cdk-cli/blob/main/packages/aws-cdk/lib/cli/version.ts#L125

    try {
      const laterVersion = await latestVersionIfHigher(currentVersion, versionCheckCache ?? new VersionCheckTTL());
+    const deprecationMessage = await checkIfDeprecated(currentVersion);
+    if (deprecationMessage) {
+      info(`You are using deprecated version(aws-cdk@${currentVersion}): ${deprecationMessage}`);
+    }
      if (laterVersion) {
        const versionMessage = await getVersionMessage(currentVersion, laterVersion);

@tttol tttol requested a review from rix0rrr March 2, 2025 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Toolkit: warn/error in case toolkit is using a deprecated version
2 participants