Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

feat: allow providing custom runner per transform file thru codeshiftConfig#97

Open
kiprasmel wants to merge 2 commits intohypermod-io:mainfrom
kiprasmel:feat/custom-runner
Open

feat: allow providing custom runner per transform file thru codeshiftConfig#97
kiprasmel wants to merge 2 commits intohypermod-io:mainfrom
kiprasmel:feat/custom-runner

Conversation

@kiprasmel
Copy link
Contributor

@kiprasmelkiprasmel commentedJan 24, 2022
edited
Loading

depends on:

example on how it could be used:

fixes a lot of cases for us:

  1. we have a postcss codemod that we want to run,
    while still utilizing the @codeshift/cli.

though, i don't know if these changes will work
if we're using a remote package, will they?

  1. we'll want to do some global pre-processing
    on files before running our codemod.

though, there's still no way to provide the codemod
as afunction instead of animport path to jscodeshift,
which will force us to do dependency injection
instead of just passing the pre-processed results
as an argument to a function.

this is where the considerations to fork jscodeshift
come into play again:

@kiprasmelkiprasmel changed the titlefeat: allow providing custom runner per transform file thru CodeshiftConfigfeat: allow providing custom runner per transform file thru codeshiftConfigJan 24, 2022
@kiprasmelkiprasmelforce-pushed thefeat/custom-runner branch 6 times, most recently fromc1905e9 toceed347CompareJanuary 26, 2022 10:56
@kiprasmel
Copy link
ContributorAuthor

would be great to review if possible@danieldelcore 🙏

danieldelcore reacted with eyes emoji

@kiprasmelkiprasmelforce-pushed thefeat/custom-runner branch 5 times, most recently frome063471 to1013148CompareJanuary 26, 2022 20:03
@danieldelcore
Copy link
Contributor

danieldelcore commentedJan 28, 2022
edited
Loading

Really interesting, could you give me some more background as to how this all fits together? As I understand it, instead of only being able to modify js / ts files you want to be able to provide a custom runner to begin to support other types of files like css?

Can you share an example codeshift.config with me?

Also i've just merged some fixes/improvements, you might want to rebase 😄

kiprasmel reacted with thumbs up emoji

@kiprasmel
Copy link
ContributorAuthor

kiprasmel commentedJan 28, 2022
edited
Loading

@danieldelcore hey! yes, correct, we want to have independance from upstream (you) so that we don't need to wait to get some custom runner merged (sometimes it could be very specific even, and you might not even need it merged, and that's fine), while still utilizing your CLI w/o publishing our own, and this unlocks the door.

this could even be used if e.g. you want to do more steps before/after the codemod run, e.g. doing some pre-processing, or idk updating some npm dependencies -- you can basically add any code there. the value is that we don't need to create wrapper CLIs around it, and just use the @codeshift/cli as it is.

re: updates -- coolio, rebased smoothly.

an example I already linked to --https://github.com/pipedrive/CodeshiftCommunity/pull/22

and you can read on how to use the codemods (we have a simple wrapperrun.js which by now the only unique functionality it has isshorthands.json; run.js is also the reason why i asked to change the config from .ts to .js! though, somecommunity/ packages here still use the non-cjsexport default instead ofmodule.exports =. and it's also the reason why we got rid ofrequire.resolve orpath.resolve inside ofcodeshift.config.js, and would recommend applying this to packages here as well. (the config becomes almost like a json file at this point)):

you can try running the demo files. i just added a new one for scss:

the only concern is -- will this work if we publish our npm package? i haven't had a chance to try that; i need to first extract into a separate repository. but ideally we'd figure this out here before i do that.

and maybe a slight change i'd do is renamingcodeshiftConfig to justcodemodsConfig orcodemodConfig or both. goes in line with the same idea that we should have an npm packagecodemods-cli that you couldnpx to, instead of@codeshift/cli.

wdyt? would be very useful.

in the issue you linked [1] from jscodeshift, i think you forgot the `path.resolve` for non-http(s) imports (not even sure how they'd work tbh).i tried running a local transform and it didn't work, but with this fix it did regardless of where i called the `packages/cli/bin/codeshift-cli.js` from. i think you might've been using the packages and not the --transforms flag so i understand why you could've missed it 😅tbh there are more improvements to make w/ the local transforms (see [2]) but this is the first step :D[1]facebook/jscodeshift#398[2]hypermod-io#48 (comment)Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
…Configdepends on:-hypermod-io#63example on how it could be used:-https://github.com/pipedrive/CodeshiftCommunity/pull/22    - though note we might refactor into separate PRs, idk,      preferably would use directly from upstream (you).fixes a lot of cases for us:1. we have a postcss codemod that we want to run,while still utilizing the @codeshift/cli.though, i don't know if these changes will workif we're using a remote package, will they?2. we'll want to do some global pre-processingon files before running our codemod.though, there's still no way to provide the codemodas a __function__ instead of an __import path__ to jscodeshift,which will force us to do dependency injectioninstead of just passing the pre-processed resultsas an argument to a function.this is where the considerations to fork jscodeshiftcome into play again:-hypermod-io#67Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@kiprasmel@danieldelcore

[8]ページ先頭

©2009-2026 Movatter.jp