jscodeshift icon indicating copy to clipboard operation
jscodeshift copied to clipboard

Fetch directly from astexplorer

Open cpojer opened this issue 9 years ago • 4 comments

Add support for jscodeshift -t http://astexplorer.net/#/QaBzVS9XHK

cpojer avatar Oct 20 '15 23:10 cpojer

This would be amazing

hzoo avatar Jul 01 '16 13:07 hzoo

It's not possible right now, since we don't run our own server. But we have to solve the parse situation anyway, so probably afterwards :)

fkling avatar Jul 01 '16 17:07 fkling

I was thinking the same for babel (although probably out of scope) babel src -d lib --plugins http://astexplorer.net/#/QaBzVS9XHK. You could parse the html and output a hidden div with the plugin code haha.

What would be fun to do is to use requirefromtwitter/twpm

hzoo avatar Jul 01 '16 18:07 hzoo

Looks like this is already supported! Currently jscodeshift lets you pass a url to the --transform cli arg. Which means you can pass raw files from github or gist.

So the workflow from astexplorer is admittedly convoluted but still works so 🤷

  1. Write a transform
  2. Press 'Snippet' in the top nav
  3. Then 'Share'.
  4. A modal will show up with three options. Go to the provided 'Gist' URL
  5. That will take you to a gist with a couple of files. Your transform will be one of them.
  6. Now scroll down to your transform.js and press raw
  7. Copy the url to the raw transform
  8. Run jscodeshift with that url as the transform param.

Example: jscodeshift --transform="https://gist.githubusercontent.com/astexplorer/294702b0d5b73c3e1f44e630fa81ccbf/raw/80ef86991585ee03001c4de49cb61d1eb8f789e6/transform.js" path/to/code

danieldelcore avatar Jul 13 '21 04:07 danieldelcore