-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add command to import/export to AST Explorer... #12
Comments
I am planning to work on import and export, before that I need some clarfications. The import can work for two ways:
codemod-cli new <project-name> --import <ast-explorer-url> --codemod <codemod-name>
codemod-cli import <ast-explorer-url> <codemod-name> One more caveat is that the transform from ast-explorer will look like this: // Press ctrl+space for code completion
export default function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.Identifier)
.forEach(path => {
j(path).replaceWith(
j.identifier(path.node.name.split('').reverse().join(''))
);
})
.toSource();
} But the codemod-cli generates the default transform like this: const { getParser } = require('codemod-cli').jscodeshift;
const { getOptions } = require('codemod-cli');
module.exports = function transformer(file, api) {
const j = getParser(api);
const options = getOptions();
return j(file.source)
.find(j.Identifier)
.forEach(path => {
path.node.name = path.node.name
.split('')
.reverse()
.join('');
})
.toSource();
} I think we need to do some modification after importing , can we let the codemod author make the changes on his own? |
In case of export also, we can have something like:
$ cd transforms/sample
$ codemod-cli export
And for the source file we need to figure which test fixture we need to export, is it the
|
I’d start with the first thing (import as a means to generate a new project), but we should be able to add both fairly easily if we factor the code well enough. Then we’d also want a way to update the codemod after the initial import (e.g. the author makes tweaks to the astexplorer side and wants to sync them back to the local project).
Sure, I think that is fine. But I also think we could fairly easily make a transform we run for them after downloading. Also, we could make transforms support ES modules (via |
I am changing the
|
Gotcha, sounds good to me |
I tried to implement export also, but I met with a problem of gist revisions not able to identify properly with ast-explorer. You can see the error if you try this: |
Looks like ast explorer is not able to read my gists (from my account), it is only accepting gists from here |
Mapping out tasks for export here for future reference:
|
No description provided.
The text was updated successfully, but these errors were encountered: