codemod
codemod copied to clipboard
[cli] codemod index.cjs detection fails on GitHub Actions
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, 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
- 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.
- gotcha. you can also share a Codemod Studio link like this https://go.codemod.com/h8HkdrS
- fixed the URL for our slack channel.
Here's the repo: https://github.com/foxted/codemod-polyfill
@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
Closing as completed. If the issue still persists after @arybitskiy's instructions, feel free to reopen the issue.