From 2a68a4d06ed966d2e5c28178e7187c107ec57862 Mon Sep 17 00:00:00 2001 From: zcong1993 Date: Mon, 6 Jul 2020 11:31:21 +0800 Subject: [PATCH] fix(core): bump deps and pack action to fix #4 --- dist/index.js | 174 +++++++++++++++++++++++++------------------------ package.json | 2 +- pnpm-lock.yaml | 12 ++-- 3 files changed, 95 insertions(+), 93 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7878a06..e48502b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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 += `×tamp=${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 += `×tamp=${ts}&sign=${sign}`; - } - return url; - } -} -exports.DingBot = DingBot; -//# sourceMappingURL=index.js.map - -/***/ }), - /***/ 810: /***/ (function(module, __unusedexports, __webpack_require__) { diff --git a/package.json b/package.json index 910cf71..8563bc7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 40627ed..c1c66e4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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