webdriverio / codemod

A codemod to transform Protractor into WebdriverIO tests
MIT License
25 stars 12 forks source link

Adds Codeshift configuration #62

Closed danieldelcore closed 2 years ago

danieldelcore commented 2 years ago

Hi all 👋

I've added a CodeshiftCommunity config because I think it's a great candidate for this repository, since you guys maintain a wrapper CLI for JSCodeshift.

Codeshift is intended to act as a generic CLI wrapper of JSCodeshift and will allow you remove your CLI completely, if that's something you folks would rather not maintain. For now this will work in parallel to your CLI, in case you wanted to trial the library before committing to it.

This comes with some additional goodies:

To run codemods via Codeshift, you can do the following:

npx @codeshift/cli -p @wdio/codemod#protractor path/to/source

Or for versioned codemods

npx @codeshift/cli -p @wdio/codemod@6.0.0 path/to/source

There's absolutely no pressure to accept this PR if you dont think it's a good fit, please let me know if you have any questions/concerns.

linux-foundation-easycla[bot] commented 2 years ago

CLA Signed

The committers listed above are authorized under a signed CLA.

christian-bromann commented 2 years ago

@danieldelcore thanks for the PR. Could you elaborate what the difference is between presets and transforms?

danieldelcore commented 2 years ago

Hi @christian-bromann 👋

So transforms refer to codemods that target specific versions ie 10.0.0, 11.0.0 etc. And presets are more generic and can be applied to a package across all/many versions.

In practice the CLI treats these two differently. For example, transforms can be sequenced and move people from 5.0.0 => 7.0.0

for example: npx @codeshift/cli -p @wdio/codemod@6.0.0 --sequence path/to/source

The idea is eventually, the CLI will be able to look at your dependencies and apply any available codemods that are shipped for a given dependency, making your entire repository up to date etc.

Presets are slightly different in that they are run like so: npx @codeshift/cli -p @wdio/codemod#protractor path/to/source but can be treated more like traditional jscodeshift transforms 😄

There's more information here if you're interested : https://www.codeshiftcommunity.com/docs/configuration#presets

danieldelcore commented 2 years ago

Wonderful! Thanks a lot please feel free to reach out if you have any issues or questions!