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

@rehearsal/reporter

Package Overview
Dependencies
Maintainers
3
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rehearsal/reporter - npm Package Compare versions

Comparing version 0.0.37 to 0.0.38

dist/src/formatters/sonarqube-formatter.d.ts

21

dist/src/formatters/sarif-formatter.d.ts

@@ -0,3 +1,24 @@

import { Log } from 'sarif';
import { Report } from '../types';
export declare class SarifFormatter {
private report;
private rules;
private ruleIndexMap;
private artifactIndexMap;
private artifacts;
private results;
constructor(report: Report);
format(): string;
buildLog(): Log;
private buildRun;
private addRule;
private addArtifact;
private addResult;
private buildResult;
private getFilesData;
private buildLocation;
private ruleExists;
private artifactExists;
}
export declare function sarifFormatter(report: Report): string;
//# sourceMappingURL=sarif-formatter.d.ts.map

33

dist/src/formatters/sarif-formatter.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sarifFormatter = void 0;
exports.sarifFormatter = exports.SarifFormatter = void 0;
class SarifFormatter {

@@ -14,4 +14,12 @@ constructor(report) {

format() {
return JSON.stringify(buildLog(this.buildRun()), null, 2);
return JSON.stringify(this.buildLog(), null, 2);
}
buildLog() {
const runs = this.buildRun();
return {
version: '2.1.0',
$schema: 'http://json.schemastore.org/sarif-2.1.0-rtm.4',
runs: Array.isArray(runs) ? runs : [runs],
};
}
buildRun() {

@@ -102,3 +110,4 @@ const run = createRun(this.report);

fileName: file.fileName,
code: file.code || undefined,
newCode: file.newCode,
oldCode: file.oldCode,
codeFixAction: file.codeFixAction || undefined,

@@ -131,3 +140,4 @@ },

properties: {
code: file.code,
newCode: file.newCode,
oldCode: file.oldCode,
codeFixAction: file.codeFixAction,

@@ -146,9 +156,3 @@ roles: file.roles,

}
function buildLog(runs) {
return {
version: '2.1.0',
$schema: 'http://json.schemastore.org/sarif-2.1.0-rtm.4',
runs: Array.isArray(runs) ? runs : [runs],
};
}
exports.SarifFormatter = SarifFormatter;
function updateArtifact(artifact, file) {

@@ -195,3 +199,3 @@ var _a;

driver: {
name: '@rehearsal/upgrade',
name: `${report.summary.commandName}`,
informationUri: 'https://github.com/rehearsal-js/rehearsal-js',

@@ -205,6 +209,3 @@ rules: [],

description: {
text: 'This is the run of @rehearsal/upgrade on your product against TypeScript ' +
report.summary.tsVersion +
' at ' +
report.summary.timestamp,
text: `This is the run of ${report.summary.commandName} on your product against TypeScript ${report.summary.tsVersion} at ${report.summary.timestamp}`,
},

@@ -211,0 +212,0 @@ },

@@ -5,3 +5,4 @@ export { Reporter } from './reporter';

export { sarifFormatter } from './formatters/sarif-formatter';
export { sonarqubeFormatter } from './formatters/sonarqube-formatter';
export type { CodeFixAction, FileRole, Location, ProcessedFile, Report, ReportItem, ReportSummary, ReportFormatter, } from './types';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sarifFormatter = exports.mdFormatter = exports.jsonFormatter = exports.Reporter = void 0;
exports.sonarqubeFormatter = exports.sarifFormatter = exports.mdFormatter = exports.jsonFormatter = exports.Reporter = void 0;
var reporter_1 = require("./reporter");

@@ -12,2 +12,4 @@ Object.defineProperty(exports, "Reporter", { enumerable: true, get: function () { return reporter_1.Reporter; } });

Object.defineProperty(exports, "sarifFormatter", { enumerable: true, get: function () { return sarif_formatter_1.sarifFormatter; } });
var sonarqube_formatter_1 = require("./formatters/sonarqube-formatter");
Object.defineProperty(exports, "sonarqubeFormatter", { enumerable: true, get: function () { return sonarqube_formatter_1.sonarqubeFormatter; } });
//# sourceMappingURL=index.js.map

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

import { type ProcessedFile, type Report, type ReportFormatter, type ReportItem } from './types';
import type { DiagnosticWithLocation, Node } from 'typescript';
import type { Logger } from 'winston';
import { type ProcessedFile, type Report, type ReportFormatter, type ReportItem } from './types';
declare type ReporterMeta = {
projectName: string;
basePath: string;
commandName: string;
tsVersion: string;
};
/**

@@ -11,3 +17,3 @@ * Representation of diagnostic and migration report.

private logger?;
constructor(projectName?: string, basePath?: string, logger?: Logger);
constructor(meta: ReporterMeta, logger?: Logger);
getFileNames(): string[];

@@ -40,2 +46,3 @@ getItemsByAnalysisTarget(fileName: string): ReportItem[];

}
export {};
//# sourceMappingURL=reporter.d.ts.map

@@ -10,3 +10,4 @@ "use strict";

class Reporter {
constructor(projectName = '', basePath = '', logger) {
constructor(meta, logger) {
const { projectName, basePath, commandName, tsVersion } = meta;
this.basePath = basePath;

@@ -17,3 +18,3 @@ this.logger = logger === null || logger === void 0 ? void 0 : logger.child({ service: 'rehearsal-reporter' });

projectName: projectName,
tsVersion: typescript_1.version,
tsVersion: tsVersion,
timestamp: new Date().toLocaleString('en-US', {

@@ -29,2 +30,3 @@ year: 'numeric',

basePath: basePath,
commandName: commandName,
},

@@ -31,0 +33,0 @@ items: [],

@@ -6,2 +6,3 @@ export declare type ReportSummary = Record<string, unknown> & {

timestamp: string;
commandName: string;
};

@@ -20,3 +21,4 @@ export declare type FileRole = 'analysisTarget' | 'tracedFile' | 'unmodified' | 'modified';

fixed: boolean;
code: string | undefined;
newCode: string | undefined;
oldCode: string | undefined;
codeFixAction: CodeFixAction | undefined;

@@ -23,0 +25,0 @@ hintAdded: boolean;

{
"name": "@rehearsal/reporter",
"version": "0.0.37",
"version": "0.0.38",
"description": "Rehearsal Reporter",

@@ -21,11 +21,2 @@ "keywords": [

],
"scripts": {
"build": "tsc -b",
"lint": "npm-run-all lint:*",
"lint:eslint": "eslint --fix . --ext .ts",
"lint:tsc-src": "tsc --noEmit",
"prepare": "pnpm build",
"test": "vitest --run",
"test:watch": "vitest --coverage --watch"
},
"dependencies": {

@@ -39,2 +30,3 @@ "winston": "^3.6.0"

"@types/sarif": "^2.1.4",
"fs-extra": "^10.1.0",
"lodash.get": "^4.4.2",

@@ -52,3 +44,10 @@ "typescript": "4.7.4",

},
"gitHead": "ac6c24607565fb4dadec860ff690a3025118bc7d"
}
"scripts": {
"build": "tsc -b",
"lint": "npm-run-all lint:*",
"lint:eslint": "eslint --fix . --ext .ts",
"lint:tsc-src": "tsc --noEmit",
"test": "vitest --run",
"test:watch": "vitest --coverage --watch"
}
}

@@ -5,3 +5,3 @@ import { Artifact, Location, Log, PropertyBag, ReportingDescriptor, Result, Run } from 'sarif';

class SarifFormatter {
export class SarifFormatter {
private report: Report;

@@ -19,5 +19,15 @@ private rules: ReportingDescriptor[] = [];

format(): string {
return JSON.stringify(buildLog(this.buildRun()), null, 2);
return JSON.stringify(this.buildLog(), null, 2);
}
buildLog(): Log {
const runs = this.buildRun();
return {
version: '2.1.0' as const,
$schema: 'http://json.schemastore.org/sarif-2.1.0-rtm.4',
runs: Array.isArray(runs) ? runs : [runs],
};
}
private buildRun(): Run {

@@ -131,3 +141,4 @@ const run = createRun(this.report);

fileName: file.fileName,
code: file.code || undefined,
newCode: file.newCode,
oldCode: file.oldCode,
codeFixAction: file.codeFixAction || undefined,

@@ -161,3 +172,4 @@ },

properties: {
code: file.code,
newCode: file.newCode,
oldCode: file.oldCode,
codeFixAction: file.codeFixAction,

@@ -179,10 +191,2 @@ roles: file.roles,

function buildLog(runs: Run | Run[]): Log {
return {
version: '2.1.0' as const,
$schema: 'http://json.schemastore.org/sarif-2.1.0-rtm.4',
runs: Array.isArray(runs) ? runs : [runs],
};
}
function updateArtifact(artifact: Artifact, file: ProcessedFile): Artifact {

@@ -231,3 +235,3 @@ let roles = Array.from(new Set(artifact.roles?.concat(file.roles)));

driver: {
name: '@rehearsal/upgrade',
name: `${report.summary.commandName}`,
informationUri: 'https://github.com/rehearsal-js/rehearsal-js',

@@ -241,7 +245,3 @@ rules: [],

description: {
text:
'This is the run of @rehearsal/upgrade on your product against TypeScript ' +
report.summary.tsVersion +
' at ' +
report.summary.timestamp,
text: `This is the run of ${report.summary.commandName} on your product against TypeScript ${report.summary.tsVersion} at ${report.summary.timestamp}`,
},

@@ -248,0 +248,0 @@ },

@@ -5,2 +5,3 @@ export { Reporter } from './reporter';

export { sarifFormatter } from './formatters/sarif-formatter';
export { sonarqubeFormatter } from './formatters/sonarqube-formatter';

@@ -7,0 +8,0 @@ export type {

import { existsSync, readFileSync, writeFileSync } from 'fs';
import { DiagnosticCategory, flattenDiagnosticMessageText, SyntaxKind } from 'typescript';
import { type ProcessedFile, type Report, type ReportFormatter, type ReportItem } from './types';
import type { DiagnosticWithLocation, Node } from 'typescript';
import { DiagnosticCategory, flattenDiagnosticMessageText, SyntaxKind, version } from 'typescript';
import type { Logger } from 'winston';
import { type ProcessedFile, type Report, type ReportFormatter, type ReportItem } from './types';
type ReporterMeta = {
projectName: string;
basePath: string;
commandName: string;
tsVersion: string;
};

@@ -17,9 +23,12 @@ /**

constructor(projectName = '', basePath = '', logger?: Logger) {
constructor(meta: ReporterMeta, logger?: Logger) {
const { projectName, basePath, commandName, tsVersion } = meta;
this.basePath = basePath;
this.logger = logger?.child({ service: 'rehearsal-reporter' });
this.report = {
summary: {
projectName: projectName,
tsVersion: version,
tsVersion: tsVersion,
timestamp: new Date().toLocaleString('en-US', {

@@ -35,2 +44,3 @@ year: 'numeric',

basePath: basePath,
commandName: commandName,
},

@@ -37,0 +47,0 @@ items: [],

@@ -6,2 +6,3 @@ export type ReportSummary = Record<string, unknown> & {

timestamp: string;
commandName: string;
};

@@ -23,3 +24,4 @@

fixed: boolean;
code: string | undefined;
newCode: string | undefined;
oldCode: string | undefined;
codeFixAction: CodeFixAction | undefined;

@@ -26,0 +28,0 @@ hintAdded: boolean;

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

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