Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reg-notify-slack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reg-notify-slack-plugin - npm Package Compare versions

Comparing version 0.12.1 to 0.12.2

2

lib/send-web-hook.d.ts

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc