Skip to content

Commit

Permalink
feat: add show-number
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed May 31, 2021
1 parent 06621dc commit 3a4083d
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.2.0

- feat: add `show-number`.

## v1.1.0

`2021.05.28`
Expand Down
3 changes: 2 additions & 1 deletion README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
steps:
- uses: actions/checkout@master

- uses: actions-cool/contributor-helper@v1.0.0
- uses: actions-cool/contributor-helper@v1.2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
update-files: 'DEMO.base.md, Demo.simple.md'
Expand Down Expand Up @@ -61,6 +61,7 @@ jobs:
| avatar-width | 头像大小,默认 50,详细样式固定 200。 | ✖ |
| style | 列表样式,默认为 `base`,可选 `simple` `detail`。 | ✖ |
| show-total | 是否显示总数,默认为 true。 | ✖ |
| show-number | 显示头像的总数量,默认为 50。 | ✖ |
| user-emoji | 自定义详细样式 User 前的 emoji,当为 `random` 时,会随机选取。 | ✖ |

### Outputs
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
steps:
- uses: actions/checkout@master

- uses: actions-cool/contributor-helper@v1.1.0
- uses: actions-cool/contributor-helper@v1.2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
update-files: 'DEMO.base.md, Demo.simple.md'
Expand Down Expand Up @@ -67,6 +67,7 @@ jobs:
| block-users | 屏蔽用户,由于有些可能包含 bot,这里可以屏蔽掉。 | ✖ |
| style | 列表样式,默认为 `base`,可选 `simple` `detail`。 | ✖ |
| show-total | 是否显示总数,默认为 true。 | ✖ |
| show-number | 显示头像的总数量,默认为 50。 | ✖ |
| user-emoji | 自定义详细样式 User 前的 emoji,当为 `random` 时,会随机选取。 | ✖ |

### Outputs
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ inputs:
description: The contributor list style. Option simple base detail.
show-total:
description: Whether show tatal number.
show-number:
description: The number show.
user-emoji:
description: Customize the emoji before user.

Expand Down
17 changes: 16 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8967,6 +8967,8 @@ const STYLES = ['simple', 'base', 'detail'];
const DEFAULT_STYLE = 'base';
const DEFAULT_WIDTH = 50;

const DEFAULT_SHOW_NUMBER = 50;

const DEFAULT_TOTAL_EMOJI = '📊';
const DEFAULT_USER_EMOJI = '😊';
const DEFAULT_COMPANY_EMOJI = '🏢';
Expand All @@ -8979,6 +8981,7 @@ module.exports = {
STYLES,
DEFAULT_STYLE,
DEFAULT_WIDTH,
DEFAULT_SHOW_NUMBER,
DEFAULT_TOTAL_EMOJI,
DEFAULT_USER_EMOJI,
DEFAULT_COMPANY_EMOJI,
Expand Down Expand Up @@ -9341,7 +9344,13 @@ const { dealStringToArr } = __nccwpck_require__(55);

const { queryContributors, formatSimple, formatBase, formatDeatil } = __nccwpck_require__(2873);

const { STYLES, DEFAULT_STYLE, DEFAULT_WIDTH, DEFAULT_TOTAL_EMOJI } = __nccwpck_require__(6818);
const {
STYLES,
DEFAULT_STYLE,
DEFAULT_WIDTH,
DEFAULT_SHOW_NUMBER,
DEFAULT_TOTAL_EMOJI,
} = __nccwpck_require__(6818);

const context = github.context;

Expand Down Expand Up @@ -9376,6 +9385,12 @@ async function run() {
return !dealStringToArr(blockUsers).includes(c.login);
});
}

let showNumber = core.getInput('show-number') || DEFAULT_SHOW_NUMBER;

if (contributors.length > showNumber) {
contributors = contributors.slice(0, showNumber + 1);
}
core.info(`[Actions: Query] The ${owner}/${repo} has ${contributors.length} contributors.`);
core.setOutput('contributors', contributors);
if (files.length == 0) {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "action-js-template",
"version": "0.0.1",
"private": true,
"description": "A javascript template for rapid development of GitHub actions.",
"main": "src/main.js",
Expand Down
3 changes: 3 additions & 0 deletions src/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const STYLES = ['simple', 'base', 'detail'];
const DEFAULT_STYLE = 'base';
const DEFAULT_WIDTH = 50;

const DEFAULT_SHOW_NUMBER = 50;

const DEFAULT_TOTAL_EMOJI = '📊';
const DEFAULT_USER_EMOJI = '😊';
const DEFAULT_COMPANY_EMOJI = '🏢';
Expand All @@ -14,6 +16,7 @@ module.exports = {
STYLES,
DEFAULT_STYLE,
DEFAULT_WIDTH,
DEFAULT_SHOW_NUMBER,
DEFAULT_TOTAL_EMOJI,
DEFAULT_USER_EMOJI,
DEFAULT_COMPANY_EMOJI,
Expand Down
14 changes: 13 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ const { dealStringToArr } = require('actions-util');

const { queryContributors, formatSimple, formatBase, formatDeatil } = require('./tool');

const { STYLES, DEFAULT_STYLE, DEFAULT_WIDTH, DEFAULT_TOTAL_EMOJI } = require('./const');
const {
STYLES,
DEFAULT_STYLE,
DEFAULT_WIDTH,
DEFAULT_SHOW_NUMBER,
DEFAULT_TOTAL_EMOJI,
} = require('./const');

const context = github.context;

Expand Down Expand Up @@ -40,6 +46,12 @@ async function run() {
return !dealStringToArr(blockUsers).includes(c.login);
});
}

let showNumber = core.getInput('show-number') || DEFAULT_SHOW_NUMBER;

if (contributors.length > showNumber) {
contributors = contributors.slice(0, showNumber + 1);
}
core.info(`[Actions: Query] The ${owner}/${repo} has ${contributors.length} contributors.`);
core.setOutput('contributors', contributors);
if (files.length == 0) {
Expand Down

0 comments on commit 3a4083d

Please sign in to comment.