Override Generators
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, node.js
- 领域
- cli
调研方向
首先查看 lib/cli/cmd-add.js 以及关于自定义 .donejs generator 的相关 issue donejs/generator-donejs#140。将提议的自定义 generator 路径与现有的 add/generate 流程进行比较,然后明确应如何选择自定义 prompt 和 validation。当项目能够覆盖一个 generator,并在运行相关 command 时使用这些自定义 prompt,即视为完成。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- JavaScript
- 星标
- 6
- 派生
- 7
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
donejs/cli 的其他 Issue
-
难度 5/5 一周以上 新手友好度 15/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 45/100
-
discussion question
难度 5/5 一周以上 新手友好度 20/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复
-
curriculum documentation quality
难度 2/5 1-3 小时 新手友好度 78/100
githubnext/gh-aw-workshop#3897 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
agent/quality hive/hosted-available-lke648397-260827-5n31 quality testing
难度 2/5 1-3 小时 新手友好度 91/100
维护者通常 1 天内回复