-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start tasks via API #177
Comments
Does |
My directory would roughly have:
The parent package looks for Here's an example of me "hacking" this functionality into my project var reporter = require('fly/lib/reporter');
var spawn = require('fly/lib/cli/spawn');
var creed = require('creed');
creed.coroutine(spawn)(process.cwd())
.then(function (fly) {
reporter.call(fly)
.emit('fly_run', {path: fly.file})
.start(['build']);
}); |
I'm not sure that I fully understand what you're trying to accomplish, so I'm going to guess & carpet-bomb you with a couple options. Plugins routeYou can "install" your plugins locally and then use them as normal fly-plugins. {
"devDependencies": {
// install from a private repo?
"fly-plugin1": "git+ssh://github.com/<user>/<repo>#<branch>",
// install from local linked
"fly-plugin2": "*",
// install from local file
"fly-plugin3": "file:../plugin3/build.js"
} The "local linked" requires The "local file" is explained here and here. Fly needs its plugins to be prefaced with "fly-" in order to parse/recognize them; hence the "fly-plugin1", "fly-plugin2", etc. At that point, you can have a main exports.default = function * () {
yield this.source('src/**/*')
.plugin1({opts})
.plugin2({opts})
.target('dist');
// third plugin has its own source/target
yield this.source('plugin3/app')
.plugin3({opts})
.target('plugin3/tmp');
} Each plugin's // .../plugin1/index.js
module.exports = function () {
this.filter('plugin1', function (data, opts) {
// ... stuff
});
}; Tasks routeYou can also export entire tasks from your plugin sub-dirs. exports.plugin1 = require('./path/to/plugin1');
exports.plugin2 = require('./path/to/plugin2');
exports.plugin3 = require('./path/to/plugin3');
yield this.start(['plugin1', 'plugin2', 'plugin3']); These can also be run in Each plugin "controls" its own source, destination, etc: // .../plugin1/index.js
module.exports = function * () {
// have to run 'source' from the flyfile.js root
// because that's where the plugin is initiated from
yield this.source('plugin1/src/**/*.js')
.target('dist/p2'); // will be sent to root + dist/p2
} "Mono-repo" routeYou can also just manage everything from the single You can check out the tail-end of #171 for info on how to easily manage the pathing of all your sources and targets. With the // flyfile.js
exports.default = function * () {
yield this.start('common'); // do bunch of common stuff to all dirs, prepare?
// wait....
yield this.start(['plugin1', 'plugin2', 'plugin3'], {parallel: true}); // do each unique task
// wait ...
yield this.start('finish'); // closing common actions
} |
You probably missed the above, since I posted it shortly after you responsed: var reporter = require('fly/lib/reporter');
var spawn = require('fly/lib/cli/spawn');
var creed = require('creed');
creed.coroutine(spawn)(process.cwd())
.then(function (fly) {
reporter.call(fly)
.emit('fly_run', {path: fly.file})
.start(['build']);
}); These aren't fly plugins. These are components/extensions for a proper package. To be more specific, this is a browser extension that is being modularized. Each component of the extension can be built as its own separate extension for quick testing. The extension we ship out to customers needs to build each component and add the necessarily files to the manifest.json. The main extension needs to find each component, have each component build itself, and provide additional data to include that component in the main extensions. Additionally, each component of this extension could have its own build process. In fact, the current main extension uses grunt, which may not be ripped out until we've finished modularizing it, so there is no access to In gulp I can trivially do this, which solves my needs var gulp = require('gulp');
require('../gulpfile.js');
gulp.start('default'); Each component then can be built for inclusion in the main extension trivially. |
Ah, I see. Fly can't do this right now because it populates internal variables after being spawn, which means they're not accessible with a standard That said, you could still achieve this same build architecture with options 2 & 3 that I posted above. Another option, too, is to create a |
Added in #218 |
It would be nice if there were a static method to use to start the tasks programmatically, much like
gulp.start
currently can do . I took a look at it seems like this could be "faked" until it is baked into fly.The text was updated successfully, but these errors were encountered: