jscodeshift
jscodeshift copied to clipboard
Custom cli helper
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. 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:
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');
}
});
Got started today. I also added it to my codemod repo. I am a bit unsure about the best way to test this so any suggestions would be highly appreciated.