mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-21 19:25:46 +08:00
test: ctx
This commit is contained in:
29
dist/index.js
vendored
29
dist/index.js
vendored
@@ -14879,7 +14879,7 @@ function doMarkAssignees(comment) {
|
|||||||
const assignCommand = core.getInput('assign-command') || '/assign';
|
const assignCommand = core.getInput('assign-command') || '/assign';
|
||||||
if (comment.body.startsWith(assignCommand)) {
|
if (comment.body.startsWith(assignCommand)) {
|
||||||
const { body, user } = comment;
|
const { body, user } = comment;
|
||||||
const assigns = body.replace(assignCommand, '').trim().split('@').reduce((result, it) => it ? [...result, it.trim()] : result, []);
|
const assigns = (0, util_1.replaceStr2Arr)(body, assignCommand, '@');
|
||||||
const requirePermission = core.getInput('require-permission') || 'write';
|
const requirePermission = core.getInput('require-permission') || 'write';
|
||||||
const permission = yield ICE.getUserPermission(user.login);
|
const permission = yield ICE.getUserPermission(user.login);
|
||||||
if (!(0, actions_util_1.checkPermission)(requirePermission, permission)) {
|
if (!(0, actions_util_1.checkPermission)(requirePermission, permission)) {
|
||||||
@@ -15258,6 +15258,7 @@ class IssueHelperEngine {
|
|||||||
}
|
}
|
||||||
initInput(ctx) {
|
initInput(ctx) {
|
||||||
var _a;
|
var _a;
|
||||||
|
console.log(JSON.stringify(ctx));
|
||||||
// No display to outside
|
// No display to outside
|
||||||
const repoInput = core.getInput('repo');
|
const repoInput = core.getInput('repo');
|
||||||
if (repoInput) {
|
if (repoInput) {
|
||||||
@@ -15280,7 +15281,7 @@ class IssueHelperEngine {
|
|||||||
core.setFailed(`issue-number is missing!`);
|
core.setFailed(`issue-number is missing!`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.githubToken = core.getInput('token', { required: true });
|
this.token = core.getInput('token');
|
||||||
this.emoji = core.getInput('emoji') || '';
|
this.emoji = core.getInput('emoji') || '';
|
||||||
this.labels = (0, actions_util_1.dealStringToArr)(core.getInput('labels') || '');
|
this.labels = (0, actions_util_1.dealStringToArr)(core.getInput('labels') || '');
|
||||||
const assigneesInput = core.getInput('assignees') || '';
|
const assigneesInput = core.getInput('assignees') || '';
|
||||||
@@ -15292,12 +15293,12 @@ class IssueHelperEngine {
|
|||||||
this.updateMode = core.getInput('update-mode') === 'append' ? 'append' : 'replace';
|
this.updateMode = core.getInput('update-mode') === 'append' ? 'append' : 'replace';
|
||||||
}
|
}
|
||||||
initIssueCore() {
|
initIssueCore() {
|
||||||
const { owner, repo, issueNumber, githubToken } = this;
|
const { owner, repo, issueNumber, token } = this;
|
||||||
this.ICE = new issue_1.IssueCoreEngine({
|
this.ICE = new issue_1.IssueCoreEngine({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
issueNumber,
|
issueNumber,
|
||||||
githubToken,
|
token,
|
||||||
});
|
});
|
||||||
core.info(`[Init] [${owner}/${repo}] [${issueNumber}]`);
|
core.info(`[Init] [${owner}/${repo}] [${issueNumber}]`);
|
||||||
}
|
}
|
||||||
@@ -15534,13 +15535,14 @@ const rest_1 = __nccwpck_require__(5375);
|
|||||||
const shared_1 = __nccwpck_require__(3826);
|
const shared_1 = __nccwpck_require__(3826);
|
||||||
class IssueCoreEngine {
|
class IssueCoreEngine {
|
||||||
constructor(_info) {
|
constructor(_info) {
|
||||||
if (_info.owner && _info.repo && _info.githubToken) {
|
if (_info.owner && _info.repo) {
|
||||||
Object.assign(this, _info);
|
this.owner = _info.owner;
|
||||||
const octokit = new rest_1.Octokit({ auth: `token ${this.githubToken}` });
|
this.repo = _info.repo;
|
||||||
this.octokit = octokit;
|
this.issueNumber = _info.issueNumber;
|
||||||
|
this.octokit = new rest_1.Octokit({ auth: `token ${_info.token}` });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console && console.error && console.error(`Init failed, need owner、repo and token!`);
|
console && console.error && console.error(`Init failed, need owner、repo!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Allow modify issue number in this way
|
// Allow modify issue number in this way
|
||||||
@@ -15877,8 +15879,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const github = __importStar(__nccwpck_require__(5438));
|
|
||||||
const actions_util_1 = __nccwpck_require__(6972);
|
const actions_util_1 = __nccwpck_require__(6972);
|
||||||
|
const github = __importStar(__nccwpck_require__(5438));
|
||||||
const core = __importStar(__nccwpck_require__(9875));
|
const core = __importStar(__nccwpck_require__(9875));
|
||||||
const helper_1 = __nccwpck_require__(8406);
|
const helper_1 = __nccwpck_require__(8406);
|
||||||
function main() {
|
function main() {
|
||||||
@@ -15937,7 +15939,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getPreMonth = exports.checkDuplicate = exports.matchKeyword = exports.dealRandomAssignees = void 0;
|
exports.replaceStr2Arr = exports.getPreMonth = exports.checkDuplicate = exports.matchKeyword = exports.dealRandomAssignees = void 0;
|
||||||
const actions_util_1 = __nccwpck_require__(6972);
|
const actions_util_1 = __nccwpck_require__(6972);
|
||||||
const sampleSize_1 = __importDefault(__nccwpck_require__(2199));
|
const sampleSize_1 = __importDefault(__nccwpck_require__(2199));
|
||||||
const dealRandomAssignees = (assignees, randomTo) => {
|
const dealRandomAssignees = (assignees, randomTo) => {
|
||||||
@@ -15964,6 +15966,11 @@ const getPreMonth = (m) => {
|
|||||||
return m == 1 ? 12 : m - 1;
|
return m == 1 ? 12 : m - 1;
|
||||||
};
|
};
|
||||||
exports.getPreMonth = getPreMonth;
|
exports.getPreMonth = getPreMonth;
|
||||||
|
// replace some & split & cull empty
|
||||||
|
const replaceStr2Arr = (str, replace, split) => {
|
||||||
|
return str.replace(replace, '').trim().split(split).reduce((result, it) => it ? [...result, it.trim()] : result, []);
|
||||||
|
};
|
||||||
|
exports.replaceStr2Arr = replaceStr2Arr;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
@@ -67,6 +67,7 @@ export class IssueHelperEngine implements IIssueHelperEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private initInput(ctx: Context) {
|
private initInput(ctx: Context) {
|
||||||
|
console.log(JSON.stringify(ctx))
|
||||||
// No display to outside
|
// No display to outside
|
||||||
const repoInput = core.getInput('repo');
|
const repoInput = core.getInput('repo');
|
||||||
if (repoInput) {
|
if (repoInput) {
|
||||||
|
Reference in New Issue
Block a user