lone
Turn node.js apps into standalone executables.
npm install -g lone && lone ./path-to-app;
your app is ready: ./path-to-app/dist/app_OSX_64
explain
neat trick, but how? a slight twist on how node-webkit does it.
- get the node source
- add
lone/_third_party_main.js
to library files innode.gyp
- compile node
- run
npm install
on./path-to-app
- put everything from
./path-to-app
in a tarball mkdir -p ./path-to-app/dist && cat out/Release/node app.tar.gz > ./path-to-app/dist/app_OSX_64
- when
app_OSX_64
is executed, node calls_third_party_main.js
- read
app_OSX_64
looking for a boundary where node stops and the app tarball begins - slice out the app tarball into a buffer that's inflated into a tmp directory and run
- marinate, rotate, and cover
Gulp + GitHub Releases
Your source gets published to npm but how do you make your shiny new binaries available for easy downloading? Here's a gulp task that will build your binaries with lone and then upload them to GitHub releases.
First, we'll need some extra dev deps so:
npm install --save-dev gulp async github-release gulp-rename keepup
Now add a gulpfile.js
to the root of your project:
var gulp = exec = exec async = release = rename = keepup = ; // Delete crap we don't need, which ends up saving several megabytes.{ var tasks = blobs = '{test*,doc*,example*,bench*,image*,tool*,lcov-report*}' paths = './node_modules/**/' + blobs './node_modules/**/node_modules/**/' + blobs './node_modules/**/node_modules/**/node_modules/**/' + blobs './node_modules/**/node_modules/.bin' './node_modules/**/node_modules/**/node_modules/.bin' ; tasks = paths; tasks; async;} gulp;
Now we just run gulp dist
on any platform and our app binaries are avilable
on GitHub without having to mess around with windows paths or cygwin.
License
MIT
Continuum of making computers do things
3 classes of solutions: cli, "status bar", gui.
Naive model of methods for implementing solutions:
- scripts: perl, bash, python, BAT
- module: publish to pypi, npm, artifactory, etc
- native cli: c*, qt, many-others, way it's always been done
- dynamic cli:
lone
,go compile
- dynamic gui: node-webkit, atom-shell, brackets-shell
- native gui: Cocoa, winfx
class | upsides | downsides |
---|---|---|
script | worksforme | 30 scripts to start mongod and none correct |
module | reusable in web | need toolchain, language bias, etc |
native cli | what people want. | hard, expensive |
dynamic cli | what people want. | emerging |
dynamic gui | what people want. | emerging |
native gui | what people want. | really really hard |
Status Bar Apps
Usually a feature of native gui apps, "status bar" apps (eg cloudup, dropbox, etc) should have a home of their own rather than glumping into lone's scope. This statusbar module might use lone under the hood, but definitely needs to be separate. Rumps is an example python impl.
BitBar is another exciting new project to solve this need. When paired with @sindresorhus/bitbar, writing these apps could not be much easier.