facebook / jscodeshift

A JavaScript codemod toolkit.
https://jscodeshift.com
MIT License
9.22k stars 477 forks source link

Fetch directly from astexplorer #58

Open cpojer opened 8 years ago

cpojer commented 8 years ago

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

hzoo commented 8 years ago

This would be amazing

fkling commented 8 years ago

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 :)

hzoo commented 8 years ago

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

danieldelcore commented 3 years ago

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