arboleya / electrify

Package your Meteor apps with Electron, and butter
MIT License
247 stars 52 forks source link

Middleware in build process #2

Closed AlexFrazer closed 9 years ago

AlexFrazer commented 9 years ago

Would be nice if there was some way to append to the build process. For example, updating PList content.

arboleya commented 9 years ago

Hi, do you have any suggestion on how to do it?

Also, I'd be nice if you could elaborate a little more about your need, I didn't get the specifics.

hems commented 9 years ago

@arboleya he wants to add some extra commands ( like a makefile would do ) after the build, probably before the app is launched

@AlexFrazer would a makefile help you out?

#makefile

my_custom_build:
  echo 'do something'
  echo 'do somthing else'

then execute

make my_custom_build
AlexFrazer commented 9 years ago

yeah pretty much. For example,

var pwd = path.resolve('.');
var build = path.join(pwd, 'meteor/.electron/.dist');

bundle:
  echo('electrifying app');
  electrify();
  echo('Copying icon');
  cp(path.join(pwd, 'meteor/public/favicon.ico'), path.join(build, 'resources/atom.icns'));
hems commented 9 years ago

@AlexFrazer can't you do that now?

just using a makefile or executing a shell command "electrify" ?

AlexFrazer commented 9 years ago

I am having trouble executing the shell command "electrify". It seems to be a very odd process to manage in a build find. Opening meteor, then opening meteor shell, then passing the command "electrify" isn't intuitive in an automated system, at least. Can the npm package just include some bundling functionality?

var electrify = require('electrify');

target.bundle = function () {
  var METEOR = path.join(__dirname, 'meteor');
  electrify.bundle(METEOR);
}
hems commented 9 years ago

@AlexFrazer agreed on the meteor shell thing, but maybe there is a way of making this one-liner and i'm not aware.. maybe @arboleya has knows workaround for this?

AlexFrazer commented 9 years ago

I have a workaround but it's not really the best...

Meteor.startup(function () {
  if (process.env.ELECTRIFY) {
    this.electrify();
    process.exit(0);
  }
});

Then in makefile:

target.bundle = function () {
  return exec('ELECTRIFY=true meteor --once');
}

just not exactly very friendly to do it that way

arboleya commented 9 years ago

@hems @AlexFrazer I thought you wanted to put something in the middle of the build system, but actually you want a post build thing.

Yes, it is a little odd and surely hard to automate. But not that hard.

At first I wanted a custom Meteor command such as meteor release electrify or something like that, there is a way to have custom commands, but it felt too complicated and nonsense.

As for the NPM package, currently it's needed only by the Electron application for the boot process, not for the Meteor package itself. As I wanted to have the Meteor thing completely independent from local NodeJS or global Npm packages, I ended up executing Meteor's server code through the interactive meteor shell, which was the only way I found.

Your workaround sounds reasonable but it looks like it doesn't work on windows, right?

Another approach would be to spawn meteor, then spawn meteor shell and manipulate the stdin and stdout to type electrify in the meteor shell and then send a SIGINT signal, something like that.

I'm redesigning things to accommodate plugins, I'll revisit this question in time, for sure.

I agree it's odd not to have a simple command to build the whole thing.

arboleya commented 9 years ago

@AlexFrazer Here it is: https://github.com/arboleya/electrify#npm-way

hems commented 9 years ago

:8ball:

AlexFrazer commented 9 years ago

Thank you good sir!