Skip to content

Commit

Permalink
feat: add block-users
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed May 28, 2021
1 parent 6d33db7 commit 06621dc
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 119 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v1.1.0

`2021.05.28`

- fix: some default.
- feat: add `block-users`.

## v1.0.0

`2021.05.28`
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
## 🚀 如果使用?

> 你可以参照当前项目的例子来使用:https://github.com/actions-cool/contributor-helper/blob/main/.github/workflows/contributor-help.yml
>
>
> 触发条件根据需要设置
```yml
Expand All @@ -35,11 +35,12 @@ jobs:
steps:
- uses: actions/checkout@master

- uses: actions-cool/contributor-helper@v1.0.0
- uses: actions-cool/contributor-helper@v1.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
update-files: 'DEMO.base.md, Demo.simple.md'
update-places: '## Contributors List/## hi, ## Contributors List/## hello'
block-users: 'bot1, bot2'
style: 'simple'
avatar-width: '66'

Expand All @@ -63,6 +64,7 @@ jobs:
| update-files | 更新文件列表,可填写多个,参照例子。 | ✖ |
| update-places | 更新文件地方,需和文件个数保持一直,需传入起始位置和终止位置,参照例子。 | ✖ |
| avatar-width | 头像大小,默认 50,详细样式固定 200。 | ✖ |
| block-users | 屏蔽用户,由于有些可能包含 bot,这里可以屏蔽掉。 | ✖ |
| style | 列表样式,默认为 `base`,可选 `simple` `detail`。 | ✖ |
| show-total | 是否显示总数,默认为 true。 | ✖ |
| user-emoji | 自定义详细样式 User 前的 emoji,当为 `random` 时,会随机选取。 | ✖ |
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ inputs:
required: true
repo:
description: The repository name.
block-users:
description: Block users name.
update-files:
description: The update files path.
update-places:
Expand Down
129 changes: 71 additions & 58 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8588,6 +8588,30 @@ function onceStrict (fn) {
}


/***/ }),

/***/ 1057:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

"use strict";


var sampleSize = __nccwpck_require__(2199);

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var sampleSize__default = /*#__PURE__*/_interopDefaultLegacy(sampleSize);

var SMILEY_EMOJIS = ['😀', '😃', '😄', '😁', '😆', '😅', '😂', '🤣', '🥲', '☺️', '😊', '😇', '🙂', '🙃', '😉', '😌', '😍', '🥰', '😘', '😗', '😙', '😚', '😋', '😛', '😝', '😜', '🤪', '🤨', '🧐', '🤓', '😎', '🥸', '🤩', '🥳', '😏', '😒', '😞', '😔', '😟', '😕', '🙁', '☹️', '😣', '😖', '😫', '😩', '🥺', '😢', '😭', '😤', '😠', '😡', '🤬', '🤯', '😳', '🥵', '🥶', '😱', '😨', '😰', '😥', '😓', '🤗', '🤔', '🤭', '🤫', '🤥', '😶', '😐', '😑', '😬', '🙄', '😯', '😦', '😧', '😮', '😲', '🥱', '😴', '🤤', '😪', '😵', '🤐', '🥴', '🤢', '🤮', '🤧', '😷', '🤒', '🤕', '🤑', '🤠', '👽', '👾', '🤖', '🎃'];

var randomSmiley = function randomSmiley() {
var c = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
return sampleSize__default['default'](SMILEY_EMOJIS, c);
};

module.exports = randomSmiley;


/***/ }),

/***/ 4294:
Expand Down Expand Up @@ -8943,50 +8967,25 @@ const STYLES = ['simple', 'base', 'detail'];
const DEFAULT_STYLE = 'base';
const DEFAULT_WIDTH = 50;

const DEFAULT_TOTAL_EMOJI = '📊';
const DEFAULT_USER_EMOJI = '😊';
const USER_EMOJIS = [
'😀',
'😃',
'😄',
'😁',
'😆',
'😅',
'😂',
'🤣',
'🥲',
'☺️',
'😊',
'😇',
'🙂',
'🙃',
'😉',
'😌',
'😍',
'🥰',
'😘',
'😗',
'😙',
'😚',
'😋',
'😛',
'😝',
'😜',
'🤪',
'🤨',
'🧐',
'🤓',
'😎',
'🥸',
'🤩',
'🥳',
];
const DEFAULT_COMPANY_EMOJI = '🏢';
const DEFAULT_LOCATION_EMOJI = '🏠';
const DEFAULT_FOLLOWERS_EMOJI = '💕';
const DEFAULT_CREATED_EMOJI = '🏆';
const DEFAULT_BIO_EMOJI = '🎉';

module.exports = {
STYLES,
DEFAULT_STYLE,
DEFAULT_WIDTH,
DEFAULT_TOTAL_EMOJI,
DEFAULT_USER_EMOJI,
USER_EMOJIS,
DEFAULT_COMPANY_EMOJI,
DEFAULT_LOCATION_EMOJI,
DEFAULT_FOLLOWERS_EMOJI,
DEFAULT_CREATED_EMOJI,
DEFAULT_BIO_EMOJI,
};


Expand All @@ -8998,10 +8997,17 @@ module.exports = {
const core = __nccwpck_require__(2186);
const { Octokit } = __nccwpck_require__(5375);
const token = core.getInput('token');
const randomSmiley = __nccwpck_require__(1057);
const octokit = new Octokit({ auth: `token ${token}` });
const sampleSize = __nccwpck_require__(2199);

const { DEFAULT_USER_EMOJI, USER_EMOJIS } = __nccwpck_require__(6818);
const {
DEFAULT_USER_EMOJI,
DEFAULT_COMPANY_EMOJI,
DEFAULT_LOCATION_EMOJI,
DEFAULT_FOLLOWERS_EMOJI,
DEFAULT_CREATED_EMOJI,
DEFAULT_BIO_EMOJI,
} = __nccwpck_require__(6818);

// **************************************************************************

Expand Down Expand Up @@ -9072,8 +9078,9 @@ async function formatDeatil(arr, w) {
const userEmoji = core.getInput('user-emoji') || DEFAULT_USER_EMOJI;
let emojis = [];
if (userEmoji == 'random') {
emojis = sampleSize(USER_EMOJIS, arr.length);
emojis = randomSmiley(arr.length);
}
const showEmoji = userEmoji != 'none';
for (var i = 0; i < arr.length; i += 1) {
let o = arr[i];
let u = await queryUser(o.login);
Expand All @@ -9082,48 +9089,48 @@ async function formatDeatil(arr, w) {
<td rowspan="6">
<img src="${o.avatar_url}" width="${w}" />
</td>
<td width="130">
<strong>${emoji} User: </strong>
<td width="130" align="left">
<strong>${showEmoji ? emoji : ''} User: </strong>
</td>
<td>
<a href="${u.html_url}" target="_blank">${u.login}</a>
</td>
</tr>
<tr>
<td>
<strong>🏢 Company: </strong>
<td align="left">
<strong>${showEmoji ? DEFAULT_COMPANY_EMOJI : ''} Company: </strong>
</td>
<td>
${getCompany(u.company)}
</td>
</tr>
<tr>
<td>
<strong>🏠 Location: </strong>
<td align="left">
<strong>${showEmoji ? DEFAULT_LOCATION_EMOJI : ''} Location: </strong>
</td>
<td>
${u.location ? u.location : '-'}
</td>
</tr>
<tr>
<td>
<strong>💕 Followers: </strong>
<td align="left">
<strong>${showEmoji ? DEFAULT_FOLLOWERS_EMOJI : ''} Followers: </strong>
</td>
<td>
${u.followers ? u.followers : '-'}
</td>
</tr>
<tr>
<td>
<strong>🏆 Created: </strong>
<td align="left">
<strong>${showEmoji ? DEFAULT_CREATED_EMOJI : ''} Created: </strong>
</td>
<td>
${u.created_at.substring(0, 10)}
</td>
</tr>
<tr>
<td>
<strong>🎉 Bio: </strong>
<td align="left">
<strong>${showEmoji ? DEFAULT_BIO_EMOJI : ''} Bio: </strong>
</td>
<td>
${u.bio ? u.bio : '-'}
Expand Down Expand Up @@ -9334,7 +9341,7 @@ const { dealStringToArr } = __nccwpck_require__(55);

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

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

const context = github.context;

Expand All @@ -9350,9 +9357,8 @@ async function run() {
repo = context.repo.repo;
}

const updateFiles = core.getInput('update-files') || 'README.md, README.en-US.md';
const updatePlaces =
core.getInput('update-places') || '## Contributors List/## 3, ## Contributors List/## 4';
const updateFiles = core.getInput('update-files');
const updatePlaces = core.getInput('update-places');

const files = dealStringToArr(updateFiles);
const places = dealStringToArr(updatePlaces);
Expand All @@ -9362,7 +9368,14 @@ async function run() {
return false;
}

const contributors = await queryContributors(owner, repo);
let contributors = await queryContributors(owner, repo);
const blockUsers = core.getInput('block-users') || 'semantic-release-bot, x6-bot[bot]';

if (blockUsers) {
contributors = contributors.filter(c => {
return !dealStringToArr(blockUsers).includes(c.login);
});
}
core.info(`[Actions: Query] The ${owner}/${repo} has ${contributors.length} contributors.`);
core.setOutput('contributors', contributors);
if (files.length == 0) {
Expand Down Expand Up @@ -9407,7 +9420,7 @@ ${formatSimple(contributors, avatarWidth)}
if (showTotal == 'true') {
body = `
> 📊 Total: <kbd>**${contributors.length}**</kbd>${body}`;
> ${DEFAULT_TOTAL_EMOJI} Total: <kbd>**${contributors.length}**</kbd>${body}`;
}

for (var i = 0; i < files.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@actions/github": "^4.0.0",
"@octokit/rest": "^18.0.14",
"actions-util": "^1.0.0",
"lodash": "^4.17.21"
"random-smiley": "^1.0.0"
},
"devDependencies": {
"@umijs/fabric": "^2.5.6",
Expand Down
49 changes: 12 additions & 37 deletions src/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,23 @@ const STYLES = ['simple', 'base', 'detail'];
const DEFAULT_STYLE = 'base';
const DEFAULT_WIDTH = 50;

const DEFAULT_TOTAL_EMOJI = '📊';
const DEFAULT_USER_EMOJI = '😊';
const USER_EMOJIS = [
'😀',
'😃',
'😄',
'😁',
'😆',
'😅',
'😂',
'🤣',
'🥲',
'☺️',
'😊',
'😇',
'🙂',
'🙃',
'😉',
'😌',
'😍',
'🥰',
'😘',
'😗',
'😙',
'😚',
'😋',
'😛',
'😝',
'😜',
'🤪',
'🤨',
'🧐',
'🤓',
'😎',
'🥸',
'🤩',
'🥳',
];
const DEFAULT_COMPANY_EMOJI = '🏢';
const DEFAULT_LOCATION_EMOJI = '🏠';
const DEFAULT_FOLLOWERS_EMOJI = '💕';
const DEFAULT_CREATED_EMOJI = '🏆';
const DEFAULT_BIO_EMOJI = '🎉';

module.exports = {
STYLES,
DEFAULT_STYLE,
DEFAULT_WIDTH,
DEFAULT_TOTAL_EMOJI,
DEFAULT_USER_EMOJI,
USER_EMOJIS,
DEFAULT_COMPANY_EMOJI,
DEFAULT_LOCATION_EMOJI,
DEFAULT_FOLLOWERS_EMOJI,
DEFAULT_CREATED_EMOJI,
DEFAULT_BIO_EMOJI,
};
Loading

0 comments on commit 06621dc

Please sign in to comment.