Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Override Generators

未关闭
#104 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
领域
cli

调研方向

首先查看 lib/cli/cmd-add.js 以及关于自定义 .donejs generator 的相关 issue donejs/generator-donejs#140。将提议的自定义 generator 路径与现有的 add/generate 流程进行比较,然后明确应如何选择自定义 prompt 和 validation。当项目能够覆盖一个 generator,并在运行相关 command 时使用这些自定义 prompt,即视为完成。

由索引模型根据 Issue 内容生成。

描述

enhancement

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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

donejs/cli 的其他 Issue

查看 donejs/cli 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。