facebook / facebook/jscodeshift

Custom cli helper

Open
#132 1 comment 1 reaction 0 assignees View on GitHub
improvement
Dominant language
JavaScript
Stars
10k
Forks
498
PR merge metrics
No merged PRs in 30d

Description

In #126 it was proposed to add a helper for generating custom cli for codemod collections.

The reasoning mentioned there:

> Another option worth considering is custom cli. I did this with [my repo of codemods](https://github.com/relekang/codemods#usage). A benefit with this approach is that jscodeshift becomes a dependency of the codemod and thus the user knows that is it tested with the jscodeshift version they use it with. jscodeshift could have a helper which makes it a bit easier to generate the cli wrapper as well as keeping it in sync with jscodeshift cli options.

As I mentioned in #126 I will have time to start implement this next week.

I was thinking that the usage would be that the bin script of a codemod collection would be something like this:

``` javascript
var path = require('path');
var cli = require('jscodeshift').cli;

cli({
list: function list() {
return [{name: 'template-strings', description: '...'}];
},
resolve: function resolve(name) {
return path.join(__dirname, 'transforms', name + '.js');
}
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.