Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Add configuration run environment#48

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
xuexb wants to merge3 commits intomaster
base:master
Choose a base branch
Loading
fromfeat/config

Conversation

@xuexb
Copy link
Owner

@xuexbxuexb commentedJan 21, 2018
edited
Loading

先不要合并。

  1. 在所有功能文件里添加了name 字段,标识当前功能模块对应的配置名称,如:name: issue/autoLabel 表示对应了配置文件里的issue.autoLabel ,当然也在想配置里是不是也直接写这个 key 而不是多套一级,如:pullRequest/autoReviewRequestpullRequest.autoReviewRequest 的区别
  2. 在注册里先把功能文件根据name 排列,并循环所有的package.json 配置开启的功能,去注册事件,注册时以空间名/仓库名@事件名 ,这样在触发时就可以无条件触发了,因为是以仓库为粒度了
  3. 注册事件时为了注入配置数据,做了一层代理,如:
module.exports={name:'pullRequest/autoReviewRequest',register(on){on('pull_request_labeled',({payload, repo},{config, scope})=>{})}}

上面对应了:

"config": {"github-bot": {"username/repo": {"pullRequest": {"autoReviewRequest": {"enabled":true,"data": {"need demo":"您好,请填写相关 Demo 链接。","need update package":"请更新版本号。"          }        }      }    }  }}

事件回调参数说明:

  • payload - 对应接口数据,via:
    githubEvent.emit(`${payload.repository.full_name}@${eventName}`,{
    repo:payload.repository.name,
    payload
    })
  • repo - 仓库名称(不带空间名)
  • config - 对应当前匹配请求+空间名/仓库名下的所有配置,也就是pkg.config.github-bot.username/repo,via:
    callback(data,{
    config:pkg.config['github-bot'][repo],
    scope:config.data||{}
    })
  • scope - 当前配置功能模块的配置,也就是pkg.config.github-bot.username/repo.pullRequest.autoReviewRequest

@coveralls
Copy link

coveralls commentedJan 21, 2018
edited
Loading

Coverage Status

Coverage decreased (-0.08%) to 99.359% when pullingdaf7a5a on feat/config into4da5f41 on master.

@xuexb
Copy link
OwnerAuthor

@yugasun 老铁看下大体上没毛病吧,现在就差测试用例和文档说明了。

@yugasun
Copy link
Collaborator

yugasun commentedJan 24, 2018
edited
Loading

@xuexb 整体流程没问题,思路也很好,可不可以在重要流程地方把注释加上,方便阅读。

另外几点建议:

  1. 可否将相关配置从package.json 文件中脱离,这里本来是项目的整体信息,不方便可定制化的配置
  2. 部分箭头嵌套是的代码可否用统一工具函数来处理,精简代码,比如此处:
    Object.keys(pkg.config['github-bot']).forEach(repo=>{
    Object.keys(pkg.config['github-bot'][repo]).forEach(type=>{
    Object.keys(pkg.config['github-bot'][repo][type]).forEach(name=>{
  3. 对于各个模块的name 属性值,使用. 作为命名空间连接符,会不会更加清晰明了。

@xuexbxuexb mentioned this pull requestFeb 25, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@xuexb@coveralls@yugasun@jiandansousuo-bot

[8]ページ先頭

©2009-2025 Movatter.jp