Skip to content

Commit

Permalink
refactor: out core
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Feb 10, 2022
1 parent 2b45195 commit bdb9ee8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 27 deletions.
27 changes: 4 additions & 23 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15279,12 +15279,14 @@ class IssueHelperEngine {
}
initIssueCore() {
const { owner, repo, issueNumber } = this;
const token = core.getInput('token');
this.ICE = new issue_1.IssueCoreEngine({
owner,
repo,
issueNumber,
token,
});
core.info(`[Init] [${owner}/${repo}] [${issueNumber}]`);
core.info(`[Init] [${owner}/${repo} => ${issueNumber}]`);
}
doExeAction(action) {
return __awaiter(this, void 0, void 0, function* () {
Expand Down Expand Up @@ -15504,25 +15506,6 @@ __exportStar(__nccwpck_require__(6882), exports);

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
Expand All @@ -15535,16 +15518,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.IssueCoreEngine = void 0;
const rest_1 = __nccwpck_require__(5375);
const core = __importStar(__nccwpck_require__(9875));
const shared_1 = __nccwpck_require__(3826);
class IssueCoreEngine {
constructor(_info) {
if (_info.owner && _info.repo) {
this.owner = _info.owner;
this.repo = _info.repo;
this.issueNumber = _info.issueNumber;
const token = core.getInput('token');
this.octokit = new rest_1.Octokit({ auth: `token ${token}` });
this.octokit = new rest_1.Octokit({ auth: `token ${_info.token}` });
}
else {
console && console.error && console.error(`Init failed, need owner、repo!`);
Expand Down
4 changes: 3 additions & 1 deletion src/helper/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ export class IssueHelperEngine implements IIssueHelperEngine {

private initIssueCore() {
const { owner, repo, issueNumber } = this;
const token = core.getInput('token');
this.ICE = new IssueCoreEngine({
owner,
repo,
issueNumber,
token,
});
core.info(`[Init] [${owner}/${repo}] [${issueNumber}]`);
core.info(`[Init] [${owner}/${repo} => ${issueNumber}]`);
}

public async doExeAction(action: TAction) {
Expand Down
Empty file added src/issue/README.md
Empty file.
4 changes: 1 addition & 3 deletions src/issue/issue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Octokit } from '@octokit/rest';
import * as core from '../core';
import { EEmoji } from '../shared';
import { TEmoji, TLockReasons, TUpdateMode, TIssueState, TUserPermission } from '../types';
import { IIssueBaseInfo, IIssueCoreEngine, IListIssuesParams, TIssueList, TIssueInfo, TCommentList } from './types';
Expand All @@ -15,8 +14,7 @@ export class IssueCoreEngine implements IIssueCoreEngine {
this.owner = _info.owner;
this.repo = _info.repo;
this.issueNumber = _info.issueNumber;
const token = core.getInput('token');
this.octokit = new Octokit({ auth: `token ${token}` });
this.octokit = new Octokit({ auth: `token ${_info.token}` });
} else {
console && console.error && console.error(`Init failed, need owner、repo!`);
}
Expand Down
1 change: 1 addition & 0 deletions src/issue/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface IIssueBaseInfo {
owner: string;
repo: string;
issueNumber: number;
token: string;
}

export interface IListIssuesParams {
Expand Down

0 comments on commit bdb9ee8

Please sign in to comment.