Override Generators
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, node.js
- Domain
- cli
Research direction
Start by reviewing lib/cli/cmd-add.js and the related donejs/generator-donejs#140 issue about .donejs generator customization. Compare the proposed custom generator path and existing add/generate flow, then clarify how custom prompts and validation should be selected. Done means a project can override a generator and use those customized prompts when running the relevant command.
Written by the indexing model from the issue text.
Description
What
A related issue (donejs/generator-donejs#140) outlines the method of using the .donejs folder to customize a generator's templates. It would be nice to have the ability to custom the generator itself.
Why
For a react-view-model project. Since a custom element tag name that the component prompt collects doesn't translate well to a react component so I'd like to change the prompt and it's validation.
You could also do things like making a component generator that prompts you for a type and builds one of several predefined types.
How
My immediate thought would be to modify the add command to do something like:
var path = require('path');
var utils = require('../utils');
var generate = require('./cmd-generate');
var debug = require('debug')('donejs-cli:add');
module.exports = function(root, name, params) {
var generators = require(path.join(root, 'node_modules', 'generator-donejs'));
var customGeneratorPath = path.join(process.cwd(), '.donejs', 'name', 'index.js');
// Use the custom generator here!
if (fs.exists(customGeneratorPath)) {
return utils.generate(root, '.donejs', [name].concat(params))
}
if (generators[name]) {
debug('add called but running generate instead', name, params);
return generate(root, name, params);
}
debug('add', name, params);
return utils.add(path.join(root, 'node_modules'), name, params);
};
Comments Please 😃
I am happy to implement this in my spare time because I'd like to see it done ASAP. I just would like a little input first so I know if I am heading down the wrong path before I start.
- Dominant language
- JavaScript
- Stars
- 6
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from donejs/cli
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
discussion question
Difficulty 5/5 Over a week Newbie friendliness 20/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area-deployment area-integrations triage:bot-seen
Difficulty 2/5 Half a day Newbie friendliness 86/100
-
Issue-Bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
sugarlabs/musicblocks#8924 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
ArduPilot/ardupilot_wiki#8088 ·
-
[BUG] createTool tools cannot be registered with Mastra when exactOptionalPropertyTypes is enabled Opencustomer-eng status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100