reg-notify-slack-plugin
Advanced tools
Comparing version 0.12.1 to 0.12.2
@@ -6,2 +6,2 @@ export interface SendOption { | ||
} | ||
export declare function sendWebHook(opt: SendOption): Promise<any>; | ||
export declare function sendWebHook({ webhookUrl, color, body }: SendOption): Promise<void>; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
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) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sendWebHook = void 0; | ||
const request_promise_1 = __importDefault(require("request-promise")); | ||
function sendWebHook(opt) { | ||
const reqParam = { | ||
url: opt.webhookUrl, | ||
method: "POST", | ||
json: true, | ||
body: { | ||
username: "Reg suit", | ||
icon_url: "https://raw.githubusercontent.com/reg-viz/artwork/master/logo/reg-viz-transparent_64.png", | ||
attachments: [ | ||
{ | ||
color: opt.color, | ||
text: opt.body, | ||
}, | ||
], | ||
}, | ||
}; | ||
return (0, request_promise_1.default)(reqParam); | ||
const undici_1 = require("undici"); | ||
function sendWebHook({ webhookUrl, color, body }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield (0, undici_1.fetch)(webhookUrl, { | ||
method: "POST", | ||
body: JSON.stringify({ | ||
username: "Reg suit", | ||
icon_url: "https://raw.githubusercontent.com/reg-viz/artwork/master/logo/reg-viz-transparent_64.png", | ||
attachments: [ | ||
{ | ||
color: color, | ||
text: body, | ||
}, | ||
], | ||
}), | ||
}); | ||
if (400 <= res.status) { | ||
throw new Error(`HTTP ${res.status}: Failed to send notification to ChatWork. Response: ${yield res.json()}`); | ||
} | ||
}); | ||
} | ||
exports.sendWebHook = sendWebHook; | ||
//# sourceMappingURL=send-web-hook.js.map |
@@ -10,5 +10,5 @@ import { PluginCreateOptions, PluginLogger, NotifierPlugin, NotifyParams } from "reg-suit-interface"; | ||
init(config: PluginCreateOptions<SlackNotiferPluginOptions>): void; | ||
notify(params: NotifyParams): Promise<any>; | ||
notify(params: NotifyParams): Promise<void>; | ||
createBody(params: NotifyParams): string; | ||
createColor(params: NotifyParams): "warning" | "danger" | "good"; | ||
} |
"use strict"; | ||
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) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -12,13 +21,15 @@ exports.SlackNotifierPlugin = void 0; | ||
notify(params) { | ||
const body = this.createBody(params); | ||
const color = this.createColor(params); | ||
this._logger.info(`Send to slack ${this._logger.colors.green(this._webhookUrl)}.`); | ||
this._logger.verbose("body to send to slack", body); | ||
if (this._noEmmit) | ||
return Promise.resolve(); | ||
const spinner = this._logger.getSpinner("sending message to Slack..."); | ||
spinner.start(); | ||
return (0, send_web_hook_1.sendWebHook)({ body, color, webhookUrl: this._webhookUrl }) | ||
.then(() => spinner.stop()) | ||
.catch(() => spinner.stop()); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const body = this.createBody(params); | ||
const color = this.createColor(params); | ||
this._logger.info(`Send to slack ${this._logger.colors.green(this._webhookUrl)}.`); | ||
this._logger.verbose("body to send to slack", body); | ||
if (this._noEmmit) | ||
return Promise.resolve(); | ||
const spinner = this._logger.getSpinner("sending message to Slack..."); | ||
spinner.start(); | ||
return (0, send_web_hook_1.sendWebHook)({ body, color, webhookUrl: this._webhookUrl }) | ||
.then(() => spinner.stop()) | ||
.catch(() => spinner.stop()); | ||
}); | ||
} | ||
@@ -25,0 +36,0 @@ createBody(params) { |
@@ -37,3 +37,3 @@ "use strict"; | ||
logger.error(logger.colors.red(reason.message)); | ||
return Promise.reject(reason.error); | ||
return Promise.reject(reason); | ||
}); | ||
@@ -40,0 +40,0 @@ } |
{ | ||
"name": "reg-notify-slack-plugin", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"description": "Notify reg-suit result to Slack channel.", | ||
@@ -21,11 +21,9 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"request": "^2.88.2", | ||
"request-promise": "^4.2.6" | ||
"undici": "^5.22.1" | ||
}, | ||
"devDependencies": { | ||
"@types/request-promise": "4.1.48", | ||
"reg-suit-interface": "^0.12.1", | ||
"reg-suit-interface": "^0.12.2", | ||
"typescript": "4.5.2" | ||
}, | ||
"gitHead": "fe7a148c51eb729aea428ad4bcc8abdd57f46a9c" | ||
"gitHead": "1573494ce4c07d57033da5d946977fb246e7ca70" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82535
1
2
220
+ Addedundici@^5.22.1
+ Added@fastify/busboy@2.1.1(transitive)
+ Addedundici@5.28.4(transitive)
- Removedrequest@^2.88.2
- Removedrequest-promise@^4.2.6
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedrequest-promise@4.2.6(transitive)
- Removedrequest-promise-core@1.1.4(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstealthy-require@1.1.1(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)