Skip to content

Commit

Permalink
EPMRPP-89644 || add setup script and update build process
Browse files Browse the repository at this point in the history
  • Loading branch information
AliakseiLiasnitski committed Mar 19, 2024
1 parent e839b17 commit d5610eb
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 31 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
"description": "Agent to integrate Vitest with ReportPortal.",
"main": "build/index.js",
"types": "build/index.d.ts",
"type": "module",
"exports": {
".": {
"import": "./build/index.js",
"require": "./build/index.js"
},
"./setup": {
"import": "./build/setup.js",
"require": "./build/setup.js"
"import": "./build/scripts/setup.js",
"require": "./build/scripts/setup.js"
}
},
"scripts": {
"build": "npm run clean && tsc",
"clean": "rimraf ./build",
"lint": "eslint \"src/**/*.ts\"",
"format": "npm run lint -- --fix",
"postbuild": "mkdir -p build && cp -R src/scripts build/",
"test": "jest",
"test:coverage": "jest --coverage"
},
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
import { RPReporter } from './reporter';
import { ReportingApi } from './reportingApi';
import { LOG_LEVELS, STATUSES } from './constants';
import { GlobalReportingApi } from './models';

declare global {
const ReportingApi: GlobalReportingApi;
}

export { RPReporter, ReportingApi, LOG_LEVELS, STATUSES };
export default RPReporter;
2 changes: 1 addition & 1 deletion src/models/reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ export interface ReportingApi {
}

export interface GlobalReportingApi {
attachment: (data: Attachment) => void;
attachment: (data: Attachment, description?: string) => void;
}
7 changes: 4 additions & 3 deletions src/reportingApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ const attachment = (task: Task, data: Models.Attachment, description?: string) =

export const ReportingApi: Models.ReportingApi = {
attachment,
}
};

export const bindReportingApi = (task: Task): Models.GlobalReportingApi => ({
attachment: (data: Models.Attachment) => attachment(task, data)
})
attachment: (data: Models.Attachment, description?: string) =>
attachment(task, data, description),
});
4 changes: 2 additions & 2 deletions src/setup.ts → src/scripts/setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach } from "vitest";
import { bindReportingApi } from "./reportingApi";
import { afterEach, beforeEach } from 'vitest';
import { bindReportingApi } from '../reportingApi';

beforeEach(async (ctx) => {
// @ts-ignore
Expand Down
20 changes: 0 additions & 20 deletions src/types/global.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/types/interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ declare namespace Interfaces {
}

interface GlobalReportingApi {
attachment: (data: Attachment) => void;
attachment: (data: Attachment, description?: string) => void;
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"outDir": "./build"
},
"include": ["./src/**/*"],
"exclude": ["node_modules", "src/__tests__"]
"exclude": ["node_modules", "src/__tests__", "src/scripts"]
}

0 comments on commit d5610eb

Please sign in to comment.