fix(core): bump deps and pack action to fix #4

This commit is contained in:
zcong1993 2020-07-06 11:31:21 +08:00
parent 5cf291c851
commit 2a68a4d06e
3 changed files with 95 additions and 93 deletions

174
dist/index.js vendored
View File

@ -385,7 +385,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(__webpack_require__(116));
const ding_bot_1 = __webpack_require__(808);
const ding_bot_1 = __webpack_require__(574);
const endpoint = 'https://oapi.dingtalk.com/robot/send';
function run() {
var _a, _b;
@ -396,7 +396,6 @@ function run() {
const secretStr = core.getInput('secret');
const ignoreError = core.getInput('ignoreError') === 'true';
const secret = secretStr === '' ? undefined : secretStr;
const data = JSON.parse(body);
if (secret) {
core.info('get secret, sign mode');
}
@ -407,7 +406,7 @@ function run() {
signKey: secret
});
try {
const resp = yield dingBot.rawSend(data);
const resp = yield dingBot.rawSend(body);
if ((resp === null || resp === void 0 ? void 0 : resp.errcode) !== 0) {
if (ignoreError) {
core.warning(resp === null || resp === void 0 ? void 0 : resp.errmsg);
@ -668,28 +667,6 @@ exports.getState = getState;
/***/ }),
/***/ 187:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSign = void 0;
const crypto_1 = __webpack_require__(417);
const sha256 = (str, key) => {
const h = crypto_1.createHmac('SHA256', key);
h.update(str);
return h.digest('base64');
};
exports.createSign = (key, ts) => {
const str = `${ts}\n${key}`;
const sign = sha256(str, key);
return encodeURIComponent(sign);
};
//# sourceMappingURL=sign.js.map
/***/ }),
/***/ 211:
/***/ (function(module) {
@ -1551,6 +1528,28 @@ module.exports = function parseHeaders(headers) {
};
/***/ }),
/***/ 363:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSign = void 0;
const crypto_1 = __webpack_require__(417);
const sha256 = (str, key) => {
const h = crypto_1.createHmac('SHA256', key);
h.update(str);
return h.digest('base64');
};
exports.createSign = (key, ts) => {
const str = `${ts}\n${key}`;
const sign = sha256(str, key);
return encodeURIComponent(sign);
};
//# sourceMappingURL=sign.js.map
/***/ }),
/***/ 402:
@ -2207,6 +2206,70 @@ module.exports = function isCancel(value) {
};
/***/ }),
/***/ 574:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DingBot = void 0;
const axios_1 = __webpack_require__(452);
const sign_1 = __webpack_require__(363);
const endpoint = 'https://oapi.dingtalk.com/robot/send';
class DingBot {
constructor(options) {
this.options = options;
if (!this.options.endpoint) {
this.options.endpoint = endpoint;
}
}
async sendTextMsg(msg) {
return this.send(msg);
}
async sendLinkMsg(msg) {
return this.send(msg);
}
async sendMarkdownMsg(msg) {
return this.send(msg);
}
async sendActionCardMsg(msg) {
return this.send(msg);
}
async sendFeedCardMsg(msg) {
return this.send(msg);
}
async send(msg) {
const data = await this.rawSend(msg);
if (data.errcode !== 0) {
throw new Error(data.errmsg);
}
}
async rawSend(msg) {
const { data } = await axios_1.default.request({
method: 'post',
url: this.buildUrl(),
data: msg,
headers: {
'content-type': 'application/json',
},
});
return data;
}
buildUrl() {
let url = `${endpoint}?access_token=${this.options.accessToken}`;
if (this.options.signKey) {
const ts = new Date().getTime();
const sign = sign_1.createSign(this.options.signKey, ts);
url += `&timestamp=${ts}&sign=${sign}`;
}
return url;
}
}
exports.DingBot = DingBot;
//# sourceMappingURL=index.js.map
/***/ }),
/***/ 605:
@ -2513,67 +2576,6 @@ module.exports = require("zlib");
/***/ }),
/***/ 808:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DingBot = void 0;
const axios_1 = __webpack_require__(452);
const sign_1 = __webpack_require__(187);
const endpoint = 'https://oapi.dingtalk.com/robot/send';
class DingBot {
constructor(options) {
this.options = options;
if (!this.options.endpoint) {
this.options.endpoint = endpoint;
}
}
async sendTextMsg(msg) {
return this.send(msg);
}
async sendLinkMsg(msg) {
return this.send(msg);
}
async sendMarkdownMsg(msg) {
return this.send(msg);
}
async sendActionCardMsg(msg) {
return this.send(msg);
}
async sendFeedCardMsg(msg) {
return this.send(msg);
}
async send(msg) {
const data = await this.rawSend(msg);
if (data.errcode !== 0) {
throw new Error(data.errmsg);
}
}
async rawSend(msg) {
const { data } = await axios_1.default.request({
method: 'post',
url: this.buildUrl(),
data: msg,
});
return data;
}
buildUrl() {
let url = `${endpoint}?access_token=${this.options.accessToken}`;
if (this.options.signKey) {
const ts = new Date().getTime();
const sign = sign_1.createSign(this.options.signKey, ts);
url += `&timestamp=${ts}&sign=${sign}`;
}
return url;
}
}
exports.DingBot = DingBot;
//# sourceMappingURL=index.js.map
/***/ }),
/***/ 810:
/***/ (function(module, __unusedexports, __webpack_require__) {

View File

@ -25,7 +25,7 @@
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.4",
"@zcong/ding-bot": "^0.1.0"
"@zcong/ding-bot": "^0.1.1"
},
"devDependencies": {
"@types/jest": "^26.0.0",

View File

@ -1,6 +1,6 @@
dependencies:
'@actions/core': registry.npmjs.org/@actions/core/1.2.4
'@zcong/ding-bot': registry.npmjs.org/@zcong/ding-bot/0.1.0
'@zcong/ding-bot': registry.npmjs.org/@zcong/ding-bot/0.1.1
devDependencies:
'@types/jest': registry.npmjs.org/@types/jest/26.0.0
'@types/node': registry.npmjs.org/@types/node/14.0.13
@ -1043,16 +1043,16 @@ packages:
registry: 'https://registry.npmjs.com/'
tarball: 'https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.3.0.tgz'
version: 3.3.0
registry.npmjs.org/@zcong/ding-bot/0.1.0:
registry.npmjs.org/@zcong/ding-bot/0.1.1:
dependencies:
axios: registry.npmjs.org/axios/0.19.2
dev: false
name: '@zcong/ding-bot'
resolution:
integrity: sha512-2T3cPUb1xnOcLMBi6H3hcscleM5E+UoO+Ly0L2EmLpbZUCYcWSfOBUT+wmHCR345h01s8L+YkjGM5hpBjvGBxQ==
integrity: sha512-vrUa7SjEusjnDvFix4au0pBEPHlmh2tqwAvzPqe/zDKH0eXV9BQr0S6YDhO+mOUigZOppbTqNoq+a33w7fjP/g==
registry: 'https://registry.npmjs.com/'
tarball: 'https://registry.npmjs.org/@zcong/ding-bot/-/ding-bot-0.1.0.tgz'
version: 0.1.0
tarball: 'https://registry.npmjs.org/@zcong/ding-bot/-/ding-bot-0.1.1.tgz'
version: 0.1.1
registry.npmjs.org/@zeit/ncc/0.22.3:
dev: true
hasBin: true
@ -7318,7 +7318,7 @@ specifiers:
'@types/jest': ^26.0.0
'@types/node': ^14.0.13
'@typescript-eslint/parser': ^3.3.0
'@zcong/ding-bot': ^0.1.0
'@zcong/ding-bot': ^0.1.1
'@zeit/ncc': ^0.22.3
eslint: ^7.2.0
eslint-plugin-github: ^4.0.1