-
-
Notifications
You must be signed in to change notification settings - Fork 298
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
[Composability] Run Queue and Composable API #433
Comments
Thank you for putting together your thoughts on an API for this. It's massively useful in continuing the conversation. My two cents:
|
I feel I also feel we can bring everyone of these pieces progressively into play. And, I think just these simple change would allow a user from running (for example) Then when we make a decision on the composability API, we just bring it into play with more ease with these building pieces already in place. |
If we can maintain backwards compat. with |
@SBoudrias could you talk about some of the practical work that we would need to do to implement composability? I've played around with your queing system and could see where it could fit in. So so far it looks like:
Is there anything else? |
Yeah, so I see it in two big section. First one is allowing generators to be runned together. This include current propositions, queue system (allowing generators to run side by side rather than one after the other) and Gruntfile API (sharing control on common files). This first step should allow one generator from requesting another one programmatically (composable pieces). The second step is to allow user to combine unrelated generator. This one is trickier, and currently there's the option of passing generators intent, or maybe just theorize on possible combination and create a mostly user based control (generator author wouldn't need to consider combination much when they write their generators). This would also require ways of scoping generators to parts of the system (basically file paths). But this is still blurry to me, it still require more reflexion. On the architecture side, I think all this would need to be coordinate by a global For now this is how I'd see it. One unresolved question here would be how we handle command line options and programmatically called generators options. This one is hard because currently options are linked to the |
Just coming back on some though, we may not be able to use |
About this, I'd like to copy-paste the initial queue list proposed on the PRD (which need works and though)
|
It seems to me that maximum composability will come from having generators operate on a formal representation of a directory tree. What if the core of a generator were a series of functions that either created such a tree or mutated an existing tree? Each generator could perform arbitrary transformations on the tree as well as queue "instantiator" functions on target nodes. The tree could be "grown" at the end by traversing it and executing all the instantiators on each node (or falling back to a default, like reading a template file, if there are no instantiators); this would produce strings containing the full file content at each file node. At the very end, the tree could be written to disk with another traversal that creates directory or file for each node. This system is a good solution for giving multiple generators control over the same file. For example, a distributed Gruntfile specification across many generators could be implemented by having each one queue instantiators that add specific configuration to the Gruntfile node. Another advantage of this is that it eases and speeds testing by avoiding unnecessary filesystem transactions. @SBoudrias recently posted testing guidelines (#449) specifying that |
@smackesey I'm not sure this would be manageable performance wise (it would require a lot of memory). And I'm not sure I see how this would help compose generators. Either way, if you'd like to add on this idea, please use #345 as your point is not directly related to using a queue system to allow generators to run in "parallel" (~kinda) rather than in series. |
On the queue subject, here's the list of queue group I see (first run first):
|
The above list looks good to me. Could we s/writing/write or would that cause conflicts elsewhere? I also had a question about |
Another question :) Do we see ourselves wanting pre/post hooks for the queue group? e.g supporting post-initialize, post-write, post-install etc or would these just cause unnecessary overhead? |
Not sure I understand...
I see it mostly used by subgenerators to read package.json, bower.json, .editorconfig or any other relevant config file.
I believe this is overhead, but we can add them later very easily if it is something people needs. |
I see a couple of usability problems with prompt here:
Possibly could be addressed with the ability to see what has been asked, but would require a common vocabulary. |
@JohnMorales I think that composed generators should be focused enough so features don't overlaps. Although, this is a valid comment for the long. When we add support for user defined composition, we may need to disable some run calls / or limit each generator namespace to be runned only once. |
On duplicate questions: the generators may need to read and act on previous generator's prompt answers. For example: an early "set up your dev environment" generator offers the choice between CSS and Sass and lets the user specify directories; a later generator automatically knows whether to add Sass or CSS boilerplate, and where to put it. |
Love API number 2, by the way. |
It's a bit late, but path.js:299
return splitPathRe.exec(filename).slice(1);
^
RangeError: Maximum call stack size exceeded May be it's time to deprecate |
What?
It is a prerelease, errors and bugs are expected. Report details (and open new issues) so we can fix them. |
Sorry, wrong link. This comment confused me before I get what is wrong with |
Subject previously brought here #345 (comment) and on the PRD document.
The idea is to run every Generator method inside a loop in order to allow different Generators from running their action in harmony. For example, all prompt run first, then the writing, then the install.
Suggested API
If keeping current API
I'd suggest extending the function prototype to add a helper method.
With a new API
I kinda prefer this way of inheritance using a method on the constructor.
Though, I wonder if using queue name as key is obvious enough or if it would bring conflicts (though we could easily throw relevant error when someone overwrite a reserved name...). Another option could be to nest the queues deeper, e.g.
this.queue.prompt.taskName
What about backward compatibility?
If we're not changing the API, we can simply push all old generator task in the default queue.
If we're changing the API, then we got a way to detect our current API and offer a shim runner calling the
#run
method.Default actions
I believe the Generator should always queue the
#installDependencies
task without asking the user to do it. (This way we can also make sure we only run the install commands once)I also think we can automatically schedule write to the Gruntfile.js if we abstract its AST away.
Actual work
I created a small Node module for creating grouped queue with different priority. I really liked backburner API, but it wasn't though for node - plus queue system are really easy to integrate in a few lines of code sooooo.
The text was updated successfully, but these errors were encountered: