lloeki / matterfront

Mattermost frontend app for OS X, Windows and Linux
MIT License
152 stars 27 forks source link

[WIP] integrate Electron-packager for Distribution #10

Closed LongLiveCHIEF closed 8 years ago

LongLiveCHIEF commented 8 years ago

add devDevependency for electron-packager, and enable builds for confirmed working distros.

lloeki commented 8 years ago

I'm using a Makefile for that, but I'm very open for more idiomatic suggestions.

LongLiveCHIEF commented 8 years ago

I'd like to simplify the process to the point where they can just

> npm install -g matterfront
> matterfront

For contributors, the process would be:

> git clone https://github.com/lloeki/matterfront
> cd matterfront && npm install
> npm start -H http://example.matterfront.com

In both scenarios, it automatically detects your platform and installs the correct electron binary, as well as auto installs and configures the config settings. (I'm tossing in some option CLI params for good measure for future support and development purposes).

I'm mostly done with this contribution (check your network graph for my commits), and if you'd like to add me as a collaborator, I'll maintain the packaging, distribution, and any cli support, including publishing to npm.

In my package.json, I listed myself as the author, since I intend to publish it to npm and maintain that package... and the author field is tied to that responsibility. I did however add your info underneath contributors.

If you choose to add me as a collaborator, I'll change the repository and issues fields to lloeki/matterfront.

lloeki commented 8 years ago

I've had a cursory look at your code and this looks nice, although a couple details trip me up (probably nothing earth-shattering, but I'll wait for your PR to land comments).

I have a few (possibly silly) questions though, how to:

LongLiveCHIEF commented 8 years ago

build all arch and platform packages (as zips) at once, on a single machine?

Javascript isn't like a C based language, it compiles to a runtime (like Java). Electron itself requires a different base binary for each arch type, which you can specify with electron-packager's build flags. It will download the correct zip for each of platforms you've told it to build, and then package that into Electron's executable format and then compressed as an executable extension for each specific platform. You can compile for all platforms on any machine, but may only launch the artifact built for your architecture.

create a release with an embedded config, allowing easy, configuration-less deployment in an enterprise?

There are a few approaches I'm taking for this, including a Matterfront cli, and solving the this will eventually be configurable via the UI thing right away. But... I'll leave this one to be answered by my PR.

replicate the former make install step (that builds, then deploys the .app in /Applications on OS X)?

This is already taken care automatically by npm, or by the build script within my package.json. Try it out! NPM manages this process, for both install with intent to contribute, as well as install with intent to use. in one, npm installs electron-prebuilt, which when paired with npm scripts, is usable from the command line, and auto-detects your host architecture and platform.

For the other, npm scripts is used, and merely running npm run build will create a bundle/executable for each platform you want to distribute to (including Linux!), in your /dist folder.

By utilizing npm instead of make (which is foreign to most js developers), you get to utilize the built-in node stuff that electron itself (as well as electron-prebuilt and electron-packager) were built to rely upon. Tossing make in there complicates things a whole bunch, since all of these tools were built to assume that your project would have and be utilizing npm and have a package.json.