threepointone / ratpack

ready. set. go!
197 stars 10 forks source link

Initial implementation of ChildProcess.exec method #31

Open ptmt opened 7 years ago

ptmt commented 7 years ago

This is a proof of concept. Could be dramatically improved with another layer of abstraction (almost like Electron bridge between node and browser).

For now you can use exec funciton that way:

 const result = await exec(`node ./ratpack.app/Contents/Resources/node_onLoad.js ${filepath}`);
     this.setState({

And get the result (can be serialized with json). Also, you babel-node would be handy for transpiring, since even Node v.7 doesn't support 100% ES 2015 (and modules, for example).

If you have any question, let's discuss in this thread.

And by the way, release binary compressed is less 1mb : ) Of course, it needs external dependency - Node.js.

ratpack.zip (780kb)

jan-15-2017 17-55-16

threepointone commented 7 years ago

This is amazing @ptmt! I'll dive into it soon. 1mb!

threepointone commented 7 years ago

I'm so chuffed by this, some quick thoughts -

ptmt commented 7 years ago

is there a way exec to return a stream/observable like thing? like node, I'd like to 'do' stuff with stdio/stdout as it comes in, not wait till the process exits

I see. I'll try to add that, it's a bit more complicated, but it's a certainly "must have" thing. It would have EventListener interface in JavaScript.

And yes, you can implement for example websocket server, since RN comes with WebSocket support out of the box (it's not as energy-effective, though, and can be possible memory leaks or something).

did I mention how chuffed I was? This would be a good electron alternative. Have you considered integrating an autoupdater with/without delta updates?

It's really easy to integrate with https://sparkle-project.org/, I have set of scripts to deploy to S3.

Electron is much easy to deal with for an average web developer, there a huge community and the most important it's cross-platform. So I think Electron is primary choice for any heavy GUI app, but for small utility apps that depend on a size and some native macOS features, RN could be an option.

threepointone commented 7 years ago

The more I think about it, the more I think the observable thing is not a 'must have' for me. Mostly for debugging purposes. I could tail a log if I had to. Don't sweat it. Setting up/communicating via a port wouldn't be too bad, I'll handle that.

I have a bunch of things on my plate right now so progress on this might be slow on my end, but I'll keep updating you as I go along. Thank you!