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]: aws-sdk-js-codemod doesn't work for me unless I use an absolute path #478

Closed
1 task
xelfer opened this issue Mar 22, 2023 · 14 comments
Closed
1 task
Labels
bug Something isn't working dependencies

Comments

@xelfer
Copy link

xelfer commented Mar 22, 2023

Self-service

  • I'd be willing to implement a fix

Describe the bug

aws-sdk-js-codemod doesn't work for me unless I use an absolute path. It claims the path does not exist.

nick@nbp src % npx aws-sdk-js-codemod -t v2-to-v3 loadfromddb.ts 
Skipping path loadfromddb.ts which does not exist. 
No files selected, nothing to do. 
All done. 
Results: 
0 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 0.003seconds 

nick@nbp src % npx aws-sdk-js-codemod -t v2-to-v3 ./loadfromddb.ts
Skipping path ./loadfromddb.ts which does not exist. 
No files selected, nothing to do. 
All done. 
Results: 
0 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 0.002seconds 

nick@nbp src % npx aws-sdk-js-codemod -t v2-to-v3 /Users/nick/dev/cfwtv/packages/functions/src/loadfromddb.ts
Processing 1 files... 
Spawning 1 workers...
Sending 1 files to free worker...
All done. 
Results: 
0 errors
0 unmodified
0 skipped
1 ok
Time elapsed: 0.661seconds 

Steps to reproduce

I ran the command as advised in documentation

Observed behavior

The command did not work unless I specified the full system path.

Expected behavior

The command should work using relative paths.

Environment

aws-sdk-js-codemod: 0.14.1
- jscodeshift: 0.14.0
- recast: 0.21.5

Additional context

I'm using default zsh in a visual studio code terminal on an Apple MacBook M1 Max running macOS Monterey 12.1.

@xelfer xelfer added bug Something isn't working triage Triaging bugs labels Mar 22, 2023
@xelfer xelfer changed the title [Bug?]: [Bug]: aws-sdk-js-codemod doesn't work for me unless I use an absolute path Mar 22, 2023
@trivikr
Copy link
Member

trivikr commented Mar 22, 2023

I'm not able to reproduce this locally on MacOS.

My system info:

  System:
    OS: macOS 12.6.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 101.27 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh

Commands run:

$ cat input.js 
import { ACM } from "aws-sdk";

new ACM();

$ npx aws-sdk-js-codemod -t v2-to-v3 input.js  
Processing 1 files... 
Spawning 1 workers...
Sending 1 files to free worker...
All done. 
Results: 
0 errors
0 unmodified
0 skipped
1 ok
Time elapsed: 0.266seconds

$ cat input.js                               
import { ACM } from "@aws-sdk/client-acm";

new ACM();

I see that your logs have the following errors:

Skipping path loadfromddb.ts which does not exist. 

The codemod is not able to find your file.

Can you ls loadfromddb.ts to check if file exists in the folder?
Does pwd return /Users/nick/dev/cfwtv/packages/functions/src, or it there some symlink?

What's the output of running npx envinfo --system on your machine?

@trivikr
Copy link
Member

trivikr commented Mar 22, 2023

@xelfer
Copy link
Author

xelfer commented Mar 22, 2023

Yes, it exists in the folder. There are no symlinks. I just replicated your test here:

Ensure the file is there:

nick@nbp src % cat input.js 
import { ACM } from "aws-sdk";

new ACM();
nick@nbp src % ls
input.js        loadfromddb.ts  savetoddb.ts
nick@nbp src % pwd
/Users/nick/dev/cfwtv/packages/functions/src
nick@nbp src % npx aws-sdk-js-codemod -t v2-to-v3 input.js 
Skipping path input.js which does not exist. 
No files selected, nothing to do. 
All done. 
Results: 
0 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 0.003seconds 
  System:
    OS: macOS 12.1
    CPU: (10) x64 Apple M1 Max
    Memory: 181.93 MB / 64.00 GB
    Shell: 5.8 - /bin/zsh

Looks like I'm missing a few OS updates, will do them now to see if it helps at all.

@xelfer
Copy link
Author

xelfer commented Mar 23, 2023

Same issue, really odd.

nick@nbp src % npx aws-sdk-js-codemod -t v2-to-v3 input.js
Skipping path input.js which does not exist. 
No files selected, nothing to do. 
All done. 
Results: 
0 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 0.003seconds 
nick@nbp src % npx envinfo --system

  System:
    OS: macOS 13.2.1
    CPU: (10) x64 Apple M1 Max
    Memory: 2.94 GB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh

@trivikr
Copy link
Member

trivikr commented Mar 23, 2023

Is the issue reproducible if you use JSCodeShift directly?

$ npx jscodeshift -t ~/.npm/_npx/<tmp>/node_modules/aws-sdk-js-codemod/dist/transforms/v2-to-v3/transformer.js input.js

where <tmp> is the temporary folder npx creates to install codemod.

The above commands calls jscodeshift directly, and passes just the v2-to-v3 transformer.
If transformation doesn't work in this case too, then the issue is with jscodeshift, and it will have to be reported upstream.

@xelfer
Copy link
Author

xelfer commented Mar 23, 2023

It looks like it:

nick@nbp src % npx jscodeshift -t ~/.npm/_npx/c10ddf24489924c3/node_modules/aws-sdk-js-codemod/dist/transforms/v2-to-v3/transformer.js input.js
Need to install the following packages:
  jscodeshift@0.14.0
Ok to proceed? (y) y
Skipping path input.js which does not exist. 
No files selected, nothing to do. 
All done. 
Results: 
0 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 0.003seconds 

@trivikr
Copy link
Member

trivikr commented Mar 23, 2023

It looks like it:

Can you create bug report on jscodeshift, and reference this issue?

@xelfer
Copy link
Author

xelfer commented Mar 23, 2023

Will do, thank you for the help!

@trivikr
Copy link
Member

trivikr commented Mar 23, 2023

Closing as this issue would be followed up upstream facebook/jscodeshift#554

@trivikr trivikr closed this as completed Mar 23, 2023
@ElonVolo
Copy link

ElonVolo commented Mar 25, 2023

I wasn't able to reproduce the issue. Can someone create a temporary git repository with the simplest-possible case of the issue happening?

@trivikr
Copy link
Member

trivikr commented Mar 25, 2023

Can someone create a temporary git repository with the simplest-possible case of the issue happening?

The issue appears to be any transformer, and not specific to aws-sdk-js-codemod.

From the latest update in facebook/jscodeshift#554 (comment), it looks like jscodeshift is not able to read relative URLs, and also the ones which start with ~/.npm.

Source code in jscodeshift which writes the error:

@ElonVolo
Copy link

ElonVolo commented Mar 25, 2023 via email

@trivikr
Copy link
Member

trivikr commented Mar 26, 2023

Trivikram, have you been able to reproduce the problem yet?

No. My original repro attempt had failed in #478 (comment).

Then I'd provided tips in #478 (comment) to check if issue is in jscodeshift, which @xelfer attempted.

@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 Apr 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working dependencies
Projects
None yet
Development

No branches or pull requests

3 participants