lukeed / taskr

A fast, concurrency-focused task automation tool.
MIT License
2.53k stars 74 forks source link

Add `fly.imports` key to `package.json` config #234

Closed lukeed closed 7 years ago

lukeed commented 7 years ago

Pulled from #233

For the sake of reusable, private plugins:

{
  "fly": {
    "imports": [
      "./build/custom-task-one.js",
      "./build/custom-task-two.js",
      "./build/custom-task-three.js"
    ]
  }
}
// build/custom-task-one.js
module.exports = function () {
  this.plugin('plugOne', {every: 0}, function * (files, opts) {
    // custom stuff
  })
}

// flyfile.js
yield this.source('src').plugOne({hello: 'world'}).target('dist');

Open to alternative names for the imports key.

The same functionality can be achieved using npm link (or npm install and file:./ as a dependency), but this requires that each plugin has its own package.json file.

You can group multiple plugins in the same "package" (example). However, this method also doesn't scale well & becomes quite messy to manage.

devmondo commented 7 years ago

@lukeed love this!!! configuration based,

imports is fine, if i may suggest also may call themlocal-extensions, local-plugins, local-tasks or just omit the local part

lukeed commented 7 years ago

@devmondo thanks!

As mentioned in #233, I want to stay away from calling it plugins only because it implies that you can declare public packages there too. So, there, I used localPlugins

devmondo commented 7 years ago

@lukeed awesome, i noticed you call them above task it is good too and i agree with you about your concern, i think require too is a good candidate this goes along with Node convensions

lukeed commented 7 years ago

i noticed you call them above task it is good too

@devmondo sorry, what do you mean?

devmondo commented 7 years ago

// build/custom-task-one.js

lukeed commented 7 years ago

Oh, sorry. I meant custom-plugin-*.js. This new keys is only for plugins.

Tasks can already be shared easily from within a flyfile.

exports.default = function * () {
  // example "custom" task
};

exports.styles = require('./tasks/styles');

exports.scripts = require('./tasks/scripts');
devmondo commented 7 years ago

man lovely!!! i cant wait for this to be released

lukeed commented 7 years ago

The key is called requires.

{
  "fly": {
    "requires": [
      "./build/custom-plugin-one.js",
      "./build/custom-plugin-two.js",
      "./build/custom-plugin-three.js"
    ]
  }
}
devmondo commented 7 years ago

awesome!!!!!

lukeed commented 7 years ago

@devmondo You can now access this by installing the latest beta release.

devmondo commented 7 years ago

@lukeed it is working perfectly!!!!! thank you very much

lukeed commented 7 years ago

@devmondo Yippee! 🙌🏼