New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@empiricalrun/reporter

Package Overview
Dependencies
Maintainers
0
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@empiricalrun/reporter - npm Package Compare versions

Comparing version

to
0.6.0

dist/sink/dashboard.d.ts

6

CHANGELOG.md
# @empiricalrun/reporter
## 0.6.0
### Minor Changes
- 273f0ef: feat: add dashboard sink to reporter
## 0.5.0

@@ -4,0 +10,0 @@

61

dist/bin/index.js
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const google_1 = require("../sinks/google");
const slack_1 = require("../sinks/slack");
const appium_1 = require("../sources/appium");
const playwright_1 = require("../sources/playwright");
function buildRunLink(repoName, runId) {
return `https://github.com/empirical-run/${repoName}-tests/actions/runs/${runId}`;
}
const workflow_1 = require("../workflow");
(async function main() {
if (process.argv.length != 6) {
console.log("Expected args not found: npx @empiricalrun/reporter $MESSAGE_TYPE $CUSTOMER_NAME $RUN_ID $REPORT_TYPE");
process.exit(1);
}
const [messageType, repoName, runId, reportType] = process.argv.slice(2);
if (!runId || !repoName) {
console.error("Missing arguments: runId or repoName");
process.exit(1);
}
const runLink = buildRunLink(repoName, runId);
let reportSource = undefined;
if (reportType == "playwright") {
reportSource = new playwright_1.PlaywrightReportSource(repoName, runId);
}
else if (reportType == "appium") {
reportSource = new appium_1.AppiumReportSource(repoName, runId);
}
else {
console.error(`report type (fourth arg) must be "playwright" or "appium".`);
process.exit(1);
}
let sink;
try {
const sinkUrl = new URL(process.env.SLACK_WEBHOOK_URL);
if (sinkUrl.hostname === "hooks.slack.com") {
sink = new slack_1.SlackReportSink(sinkUrl.toString(), runLink, runId, reportSource);
}
else if (sinkUrl.hostname === "chat.googleapis.com") {
sink = new google_1.GoogleChatReportSink(sinkUrl.toString(), runLink, runId, reportSource);
}
else {
console.log("Unsupported sink URL in $SLACK_WEBHOOK_URL");
process.exit(1);
}
const parameters = process.argv.slice(2);
const workflow = (0, workflow_1.getWorkflow)(parameters);
await workflow.execute();
}
catch (e) {
console.error("Missing environment variable: SLACK_WEBHOOK_URL");
console.error("Failed to run reporter::", e.message);
process.exit(1);
}
if (messageType === "start") {
await sink.sendStartMessage();
}
else if (messageType === "end") {
if (!reportSource.reportExists()) {
await sink.sendMessageForError();
}
else {
await sink.sendEndMessage();
}
}
else {
console.log(`message type (first arg) must be "start" or "end".`);
process.exit(1);
}
return;
})();
export declare function humanReadable(duration: number): string;
export declare function parseJsonReport<T>(srcFile: string): T;
/**
* method to generate github action run link using `runId` and `repoName`
* this is specific to the repos created under empirical-run org
* @param repoName
* @param runId
* @returns
*/
export declare function buildGhRunLink(repoName: string, runId: string): string;
/**
*
* @returns
*/
export declare function getGhEvent(): Record<string, any> | undefined;
/**
*
* @returns
*/
export declare function getGhEventPullNumber(): number | undefined;
/**
*
* @param repoName
* @returns
*/
export declare function getGhEventPrLink(repoName: string): string | undefined;
//# sourceMappingURL=utils.d.ts.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseJsonReport = exports.humanReadable = void 0;
exports.getGhEventPrLink = exports.getGhEventPullNumber = exports.getGhEvent = exports.buildGhRunLink = exports.parseJsonReport = exports.humanReadable = void 0;
const fs_1 = __importDefault(require("fs"));

@@ -20,1 +20,47 @@ function humanReadable(duration) {

exports.parseJsonReport = parseJsonReport;
/**
* method to generate github action run link using `runId` and `repoName`
* this is specific to the repos created under empirical-run org
* @param repoName
* @param runId
* @returns
*/
function buildGhRunLink(repoName, runId) {
return `https://github.com/empirical-run/${repoName}-tests/actions/runs/${runId}`;
}
exports.buildGhRunLink = buildGhRunLink;
/**
*
* @returns
*/
function getGhEvent() {
if (!process.env.GITHUB_EVENT_PATH) {
return;
}
const event = JSON.parse(fs_1.default.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8"));
return event;
}
exports.getGhEvent = getGhEvent;
/**
*
* @returns
*/
function getGhEventPullNumber() {
const event = getGhEvent();
if (event) {
return Number(event.pull_request.number);
}
}
exports.getGhEventPullNumber = getGhEventPullNumber;
/**
*
* @param repoName
* @returns
*/
function getGhEventPrLink(repoName) {
const pullNumber = getGhEventPullNumber();
if (pullNumber && !Number.isNaN(pullNumber)) {
return `https://github.com/empirical-run/${repoName}-tests/pull/${pullNumber}`;
}
}
exports.getGhEventPrLink = getGhEventPrLink;
{
"name": "@empiricalrun/reporter",
"version": "0.5.0",
"version": "0.6.0",
"publishConfig": {

@@ -5,0 +5,0 @@ "registry": "https://registry.npmjs.org/",

Sorry, the diff of this file is not supported yet