jmmk / javascript-externs-generator

Generate externs for use with Google Closure Compiler
https://jmmk.github.io/javascript-externs-generator/
ISC License
135 stars 9 forks source link

Make it a script for command line consumption #2

Closed martinklepsch closed 8 years ago

martinklepsch commented 9 years ago

This seems to be nice fit for something like planck and in general CLI applications. Would be nice to be able to run it from there :)

jmmk commented 9 years ago

@martinklepsch I like the idea, but I'm not sure of the best way to distribute it. Were you thinking that it would just live in the git repo and to use it would be as simple as cloning and running it with planck?

I'm probably rambling, but here are my immediate thoughts related to planck and ClojureScript command line tools: If this was a JS utility, you might install it with npm install -g externs-generator, but there's currently no such command-line-utility ecosystem that I'm aware of for ClojureScript. Normally you install a ClojureScript library only as a dependency in your project, not as an executable to add to your PATH. Is this something that's likely to change now that we have planck? Can we/should we lean on NPM at all?

I haven't had the opportunity yet to play around with planck, and I haven't thought much in depth about this, so I'm interested to hear your feedback. Hopefully these same ideas are floating around elsewhere and someone is working on a solution.

martinklepsch commented 8 years ago

This seems like it might be a good source of inspiration: https://github.com/snoe/node-cljfmt

jmmk commented 8 years ago

Looks pretty straightforward, thanks!

The node stuff might also be useful for reading files for test fixtures instead of having to write everything as strings.

jmmk commented 8 years ago

@martinklepsch it should be available if you run npm install -g externs-generator. Then you can do generate-extern -f <library>.js -n <namespace> -o extern.js.

I'm using the jsdom library to simulate a browser to load the scripts and in my limited testing I found at least one library that doesn't work properly, but most of them that I tried worked fine.