JSRocksHQ / harmonic

The next static site generator
http://harmonicjs.com/
MIT License
282 stars 26 forks source link

Support task runner #129

Open jaydson opened 9 years ago

jaydson commented 9 years ago

All modern website are built using some kind of task-runner. Harmonic must to support task-runner integration in some way.

Maybe a custom CLI command that Harmonic can run after or before the build. I don't know yet what is the best approach here.

UltCombo commented 9 years ago

You mean, making Grunt/gulp/broccoli/etc plugins to wrap Harmonic?

Once we have an working API, wrapping Harmonic with build tool/task runner plugins will be easy or even unnecessary.

jaydson commented 9 years ago

Let me try to explain what i meant.

Assuming a website with using Grunt as task runner, which have concatenation, lint and minify tasks. Now, what is the best way to integrate this project with Harmonic? I mean, the developer want to have Grunt, but want to have the Harmonic logic for posts, pages, categories, etc. Also, the developer doesn't want to hack and start using the Harmonic API. He just wants to use the Harmonic CLI and Grunt, together. It's clear now?

As i said, i don't know yet the best way to deal with. Perhaps just keep it simple by now, and force the developer that want to use Harmonic and a task runner to handle that. For example, before run Harmonic, he must to run Grunt or whatever.

UltCombo commented 9 years ago

If the developer wants to integrate Harmonic into his gulp/Grunt/etc. workflow, I believe the Harmonic API is best suited for the task. E.g.:

gulp.task('build', ['lint'], function(cb) {
    new Harmonic('path/to/project').build().then(function(){ cb(); }, cb);
});
gulp.task('lint', function() {
    // ...
});

Then executing gulp build will lint and run harmonic build.

Is this what you meant?

jaydson commented 9 years ago

No, hahaa. In this scenario, this simply doesn't scale. Harmonic API should be helpful for those who wants to create software that has a static generator as dependency.

For websites, i don't think this is a good approach. Harmonic CLI should be the right tool. The wesite has static files, tasks, etc. Harmonic's job is help creating pages, templates, articles, etc. Keep this separated is the point.

Take a look:

harmonic init // start
harmonic new_post "my post" // some post
harmonic new_page "some page" // some page

Here, we have an article and a page. But the Front-End resources are handled for the task runner, and it makes no sense for the developer interact with the API, because it can be done by running the task runner and harmonic after that.

What i meant in the beginning is that Harmonic could support a way for developers tell what tasks to run, or what coomand to run, so he can still just running:

harmonic run

And Harmonic will execute Grunt/Gulp/Whatever tasks.

UltCombo commented 9 years ago

Ohh, I guess I understand it now.

So the use cases are:

  1. A Harmonic template needs to compile/minify files before Harmonic generates the pages.
  2. The developer wants to post-process the files generated by Harmonic.

Did I get it right this time?

For use case 1, perhaps the currently selected theme could hook into the plugins API.

For use case 2, the developer could harmonic build && grunt, or we can leave that to Harmonic plugins which allow hooking into more specific steps of the file generation.