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

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

Open
foxted opened this issue Jun 28, 2024 · 5 comments
Open

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

foxted opened this issue Jun 28, 2024 · 5 comments

Comments

@foxted
Copy link

foxted commented Jun 28, 2024

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.

@alexbit-codemod
Copy link
Contributor

alexbit-codemod commented Jun 28, 2024

@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 alexbit-codemod changed the title Codemod on Github Actions [cli] codemod index.cjs detection fails on GitHub Actions Jun 28, 2024
@foxted
Copy link
Author

foxted commented Jun 28, 2024

  • 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.

@alexbit-codemod
Copy link
Contributor

  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.

@foxted
Copy link
Author

foxted commented Jun 28, 2024

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

@arybitskiy
Copy link
Contributor

arybitskiy commented Jul 20, 2024

@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

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

No branches or pull requests

3 participants