codemod icon indicating copy to clipboard operation
codemod copied to clipboard

[cli] codemod index.cjs detection fails on GitHub Actions

Open foxted opened this issue 1 year ago • 5 comments
trafficstars

HI there,

I'm trying to run codemod on Github Actions using the following npx command:

npx codemod --source /path/to/my-codemod-repo --target /path/to/my-target-repo

But it seems like the index.cjs detection doesn't work.

Output:

Run ls -la /path/to/my-codemod-repo/dist
total 12
drwxr-xr-x 2 runner docker 4096 Jun 27 22:23 .
drwxr-xr-x 8 runner docker 4096 Jun 27 22:23 ..
-rw-r--r-- 1 runner docker 2027 Jun 27 22:23 index.cjs

npx codemod --source /path/to/my-codemod-repo --target /path/to/my-target-repo
npm warn exec The following package was not found and will be installed: [email protected]

Could not find the main file of the codemod with name index.cjs. Did you forget to run "codemod build"?

I tried both with the index.cjs committed to my repo and running codemod build in the previous steps of the pipeline, but nothing seems to help.

Looks like an issue with this function, but so far I am not sure what could be going wrong: https://github.com/codemod-com/codemod/blob/main/apps/cli/src/utils.ts#L133.

foxted avatar Jun 28 '24 19:06 foxted

@foxted, thanks for reporting this issue. i'll have the team look into it. in the meantime, can you share more details for repro? is it for a private codemod? with jscodeshift? and for --source did you use the path to the codemod folder?

you can also chat with me/team/community here: https://go.codemod.com/community

alexbit-codemod avatar Jun 28 '24 19:06 alexbit-codemod

  • It is a private codemod (with jscodeshift) indeed, I'll anonymize the repository and provide a link soon.
  • The source argument is an absolute path to the codemod folder provided by Codemod studio

The community link you shared is a 404 on my end.

foxted avatar Jun 28 '24 19:06 foxted

  1. gotcha. you can also share a Codemod Studio link like this https://go.codemod.com/h8HkdrS
  2. fixed the URL for our slack channel.

alexbit-codemod avatar Jun 28 '24 19:06 alexbit-codemod

Here's the repo: https://github.com/foxted/codemod-polyfill

foxted avatar Jun 28 '24 19:06 foxted

@foxted I do apologise for delay. If you want to run codemod with direct path to a codemod file:

  • source should point to source file (or bundle)
  • you need to specify engine

So it would be like

npx codemod --source /path/to/my-codemod-repo/src/index.ts --engine jscodeshift --target /path/to/my-target-repo

or

npx codemod --source /path/to/my-codemod-repo/dist/index.cjs --engine jscodeshift --target /path/to/my-target-repo

arybitskiy avatar Jul 20 '24 20:07 arybitskiy

Closing as completed. If the issue still persists after @arybitskiy's instructions, feel free to reopen the issue.

mohab-sameh avatar Dec 26 '24 15:12 mohab-sameh