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

[Bug]: npx does not use the latest version of the codemod #180

Closed
trivikr opened this issue Dec 20, 2022 · 4 comments · Fixed by #345
Closed

[Bug]: npx does not use the latest version of the codemod #180

trivikr opened this issue Dec 20, 2022 · 4 comments · Fixed by #345

Comments

@trivikr
Copy link
Member

trivikr commented Dec 20, 2022

Describe the bug

npx does not use the latest version of codemod

Steps to reproduce

To reproduce, you need to have an older version of aws-sdk-js-codemod installed

$ npm view aws-sdk-js-codemod version 
0.6.3

$ npx aws-sdk-js-codemod --version
aws-sdk-js-codemod: 0.6.1
...

Run the following commands:

$ npx aws-sdk-js-codemod@latest --version

$ npx aws-sdk-js-codemod --version

Observed behavior

When latest is explicitly passed, it uses the latest version.
But it does not override the previously installed version

$ npx aws-sdk-js-codemod@latest --version
Need to install the following packages:
  aws-sdk-js-codemod@0.6.3
Ok to proceed? (y) y
aws-sdk-js-codemod: 0.6.3
...

$ npx aws-sdk-js-codemod --version 
aws-sdk-js-codemod: 0.6.1
...

Expected behavior

Default documentation should update how to use the latest version.

The current usage recommends npx aws-sdk-js-codemod which will use the catched version: https://github.com/awslabs/aws-sdk-js-codemod#usage

@trivikr
Copy link
Member Author

trivikr commented Dec 20, 2022

This seems to be the default behavior of npm CLI as discussed in npm/cli#2329

We can recommend running aws-sdk-js-codemod@latest in README, but that will ask user to install CLI every time it's run, as that version is not cached.

$ npx aws-sdk-js-codemod@latest --version
Need to install the following packages:
  aws-sdk-js-codemod@0.6.3
Ok to proceed? (y) y
aws-sdk-js-codemod: 0.6.3
...

$ npx aws-sdk-js-codemod@latest --version
Need to install the following packages:
  aws-sdk-js-codemod@0.6.3
Ok to proceed? (y) y
aws-sdk-js-codemod: 0.6.3
...

@trivikr trivikr changed the title [Bug?]: npx does not use the latest version of the codemod [Bug]: npx does not use the latest version of the codemod Dec 20, 2022
@trivikr
Copy link
Member Author

trivikr commented Dec 20, 2022

We'll probably add an FAQ to README requesting users to clear their npm cache.

Example gist https://gist.github.com/karlhorky/3e092d1def377f409976566db2e46029

We may also request user to run npx clear-npx-cache which clears npx cache programatically.

@trivikr
Copy link
Member Author

trivikr commented Jan 9, 2023

A message can be added in --help section which is displayed by default.

Existing output

$ npx aws-sdk-js-codemod --help
-----------------------------------------------------------------------------------------------
aws-sdk-js-codemod is a lightweight wrapper over jscodeshift.
It processes --help, --version and --transform options before passing them downstream.

You can provide names of the custom transforms instead of a local path or url:

     v2-to-v3  Converts AWS SDK for JavaScript APIs in a Javascript/TypeScript codebase from 
               version 2 (v2) to version 3 (v3). 

Example: aws-sdk-js-codemod -t v2-to-v3 example.js

-----------------------------------------------------------------------------------------------
...

The new section could be:

$ npx aws-sdk-js-codemod --help
-----------------------------------------------------------------------------------------------
aws-sdk-js-codemod is a lightweight wrapper over jscodeshift.
It processes --help, --version and --transform options before passing them downstream.

You can provide names of the custom transforms instead of a local path or url:

     v2-to-v3  Converts AWS SDK for JavaScript APIs in a Javascript/TypeScript codebase from 
               version 2 (v2) to version 3 (v3). 

Example: aws-sdk-js-codemod -t v2-to-v3 example.js

To use the latest version of aws-sdk-js-codemod, please clear your npx cache and re-run.
-----------------------------------------------------------------------------------------------

@github-actions
Copy link
Contributor

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant