@s-ui/lint-reporters
Version:
Send lint errors and golden path metrics to DataDog
1,524 lines • 59.8 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
// ../../node_modules/console-table-printer/dist/src/utils/colored-console-line.js
var require_colored_console_line = __commonJS({
"../../node_modules/console-table-printer/dist/src/utils/colored-console-line.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_COLOR_MAP = void 0;
exports.DEFAULT_COLOR_MAP = {
red: "\x1B[31m",
green: "\x1B[32m",
yellow: "\x1B[33m",
blue: "\x1B[34m",
magenta: "\x1B[35m",
cyan: "\x1B[36m",
white: "\x1B[37m",
white_bold: "\x1B[01m",
reset: "\x1B[0m"
};
var ColoredConsoleLine = class {
constructor(colorMap = exports.DEFAULT_COLOR_MAP) {
this.text = "";
this.colorMap = colorMap;
}
addCharsWithColor(color, text) {
const colorAnsi = this.colorMap[color];
this.text += colorAnsi !== void 0 ? `${colorAnsi}${text}${this.colorMap.reset}` : text;
}
renderConsole() {
return this.text;
}
};
exports.default = ColoredConsoleLine;
}
});
// ../../node_modules/console-table-printer/dist/src/utils/table-constants.js
var require_table_constants = __commonJS({
"../../node_modules/console-table-printer/dist/src/utils/table-constants.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_HEADER_ALIGNMENT = exports.DEFAULT_ROW_ALIGNMENT = exports.DEFAULT_HEADER_FONT_COLOR = exports.DEFAULT_ROW_FONT_COLOR = exports.COLORS = exports.ALIGNMENTS = exports.DEFAULT_TABLE_STYLE = exports.DEFAULT_ROW_SEPARATOR = exports.DEFAULT_COLUMN_LEN = void 0;
exports.DEFAULT_COLUMN_LEN = 20;
exports.DEFAULT_ROW_SEPARATOR = false;
exports.DEFAULT_TABLE_STYLE = {
headerTop: {
left: "\u250C",
mid: "\u252C",
right: "\u2510",
other: "\u2500"
},
headerBottom: {
left: "\u251C",
mid: "\u253C",
right: "\u2524",
other: "\u2500"
},
tableBottom: {
left: "\u2514",
mid: "\u2534",
right: "\u2518",
other: "\u2500"
},
vertical: "\u2502",
rowSeparator: {
left: "\u251C",
mid: "\u253C",
right: "\u2524",
other: "\u2500"
}
};
exports.ALIGNMENTS = ["right", "left", "center"];
exports.COLORS = [
"red",
"green",
"yellow",
"white",
"blue",
"magenta",
"cyan",
"white_bold",
"reset"
];
exports.DEFAULT_ROW_FONT_COLOR = "white";
exports.DEFAULT_HEADER_FONT_COLOR = "white_bold";
exports.DEFAULT_ROW_ALIGNMENT = "right";
exports.DEFAULT_HEADER_ALIGNMENT = "center";
}
});
// ../../node_modules/console-table-printer/dist/src/internalTable/input-converter.js
var require_input_converter = __commonJS({
"../../node_modules/console-table-printer/dist/src/internalTable/input-converter.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.rawColumnToInternalColumn = exports.objIfExists = void 0;
var table_constants_1 = require_table_constants();
var objIfExists = (key, val) => {
if (!val) {
return {};
}
return {
[key]: val
};
};
exports.objIfExists = objIfExists;
var rawColumnToInternalColumn = (column) => {
var _a;
return Object.assign(Object.assign(Object.assign(Object.assign({ name: column.name, title: (_a = column.title) !== null && _a !== void 0 ? _a : column.name }, (0, exports.objIfExists)("color", column.color)), (0, exports.objIfExists)("maxLen", column.maxLen)), (0, exports.objIfExists)("minLen", column.minLen)), { alignment: column.alignment || table_constants_1.DEFAULT_ROW_ALIGNMENT });
};
exports.rawColumnToInternalColumn = rawColumnToInternalColumn;
}
});
// ../../node_modules/simple-wcswidth/dist/src/non-spacing-chars.js
var require_non_spacing_chars = __commonJS({
"../../node_modules/simple-wcswidth/dist/src/non-spacing-chars.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var combining = [
{ first: 768, last: 879 },
{ first: 1155, last: 1158 },
{ first: 1160, last: 1161 },
{ first: 1425, last: 1469 },
{ first: 1471, last: 1471 },
{ first: 1473, last: 1474 },
{ first: 1476, last: 1477 },
{ first: 1479, last: 1479 },
{ first: 1536, last: 1539 },
{ first: 1552, last: 1557 },
{ first: 1611, last: 1630 },
{ first: 1648, last: 1648 },
{ first: 1750, last: 1764 },
{ first: 1767, last: 1768 },
{ first: 1770, last: 1773 },
{ first: 1807, last: 1807 },
{ first: 1809, last: 1809 },
{ first: 1840, last: 1866 },
{ first: 1958, last: 1968 },
{ first: 2027, last: 2035 },
{ first: 2305, last: 2306 },
{ first: 2364, last: 2364 },
{ first: 2369, last: 2376 },
{ first: 2381, last: 2381 },
{ first: 2385, last: 2388 },
{ first: 2402, last: 2403 },
{ first: 2433, last: 2433 },
{ first: 2492, last: 2492 },
{ first: 2497, last: 2500 },
{ first: 2509, last: 2509 },
{ first: 2530, last: 2531 },
{ first: 2561, last: 2562 },
{ first: 2620, last: 2620 },
{ first: 2625, last: 2626 },
{ first: 2631, last: 2632 },
{ first: 2635, last: 2637 },
{ first: 2672, last: 2673 },
{ first: 2689, last: 2690 },
{ first: 2748, last: 2748 },
{ first: 2753, last: 2757 },
{ first: 2759, last: 2760 },
{ first: 2765, last: 2765 },
{ first: 2786, last: 2787 },
{ first: 2817, last: 2817 },
{ first: 2876, last: 2876 },
{ first: 2879, last: 2879 },
{ first: 2881, last: 2883 },
{ first: 2893, last: 2893 },
{ first: 2902, last: 2902 },
{ first: 2946, last: 2946 },
{ first: 3008, last: 3008 },
{ first: 3021, last: 3021 },
{ first: 3134, last: 3136 },
{ first: 3142, last: 3144 },
{ first: 3146, last: 3149 },
{ first: 3157, last: 3158 },
{ first: 3260, last: 3260 },
{ first: 3263, last: 3263 },
{ first: 3270, last: 3270 },
{ first: 3276, last: 3277 },
{ first: 3298, last: 3299 },
{ first: 3393, last: 3395 },
{ first: 3405, last: 3405 },
{ first: 3530, last: 3530 },
{ first: 3538, last: 3540 },
{ first: 3542, last: 3542 },
{ first: 3633, last: 3633 },
{ first: 3636, last: 3642 },
{ first: 3655, last: 3662 },
{ first: 3761, last: 3761 },
{ first: 3764, last: 3769 },
{ first: 3771, last: 3772 },
{ first: 3784, last: 3789 },
{ first: 3864, last: 3865 },
{ first: 3893, last: 3893 },
{ first: 3895, last: 3895 },
{ first: 3897, last: 3897 },
{ first: 3953, last: 3966 },
{ first: 3968, last: 3972 },
{ first: 3974, last: 3975 },
{ first: 3984, last: 3991 },
{ first: 3993, last: 4028 },
{ first: 4038, last: 4038 },
{ first: 4141, last: 4144 },
{ first: 4146, last: 4146 },
{ first: 4150, last: 4151 },
{ first: 4153, last: 4153 },
{ first: 4184, last: 4185 },
{ first: 4448, last: 4607 },
{ first: 4959, last: 4959 },
{ first: 5906, last: 5908 },
{ first: 5938, last: 5940 },
{ first: 5970, last: 5971 },
{ first: 6002, last: 6003 },
{ first: 6068, last: 6069 },
{ first: 6071, last: 6077 },
{ first: 6086, last: 6086 },
{ first: 6089, last: 6099 },
{ first: 6109, last: 6109 },
{ first: 6155, last: 6157 },
{ first: 6313, last: 6313 },
{ first: 6432, last: 6434 },
{ first: 6439, last: 6440 },
{ first: 6450, last: 6450 },
{ first: 6457, last: 6459 },
{ first: 6679, last: 6680 },
{ first: 6912, last: 6915 },
{ first: 6964, last: 6964 },
{ first: 6966, last: 6970 },
{ first: 6972, last: 6972 },
{ first: 6978, last: 6978 },
{ first: 7019, last: 7027 },
{ first: 7616, last: 7626 },
{ first: 7678, last: 7679 },
{ first: 8203, last: 8207 },
{ first: 8234, last: 8238 },
{ first: 8288, last: 8291 },
{ first: 8298, last: 8303 },
{ first: 8400, last: 8431 },
{ first: 12330, last: 12335 },
{ first: 12441, last: 12442 },
{ first: 43014, last: 43014 },
{ first: 43019, last: 43019 },
{ first: 43045, last: 43046 },
{ first: 64286, last: 64286 },
{ first: 65024, last: 65039 },
{ first: 65056, last: 65059 },
{ first: 65279, last: 65279 },
{ first: 65529, last: 65531 },
{ first: 68097, last: 68099 },
{ first: 68101, last: 68102 },
{ first: 68108, last: 68111 },
{ first: 68152, last: 68154 },
{ first: 68159, last: 68159 },
{ first: 119143, last: 119145 },
{ first: 119155, last: 119170 },
{ first: 119173, last: 119179 },
{ first: 119210, last: 119213 },
{ first: 119362, last: 119364 },
{ first: 917505, last: 917505 },
{ first: 917536, last: 917631 },
{ first: 917760, last: 917999 }
];
exports.default = combining;
}
});
// ../../node_modules/simple-wcswidth/dist/src/binary-search.js
var require_binary_search = __commonJS({
"../../node_modules/simple-wcswidth/dist/src/binary-search.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bisearch = (ucs, table, tableSize) => {
let min = 0;
let mid;
let max = tableSize;
if (ucs < table[0].first || ucs > table[max].last)
return 0;
while (max >= min) {
mid = Math.floor((min + max) / 2);
if (ucs > table[mid].last) {
min = mid + 1;
} else if (ucs < table[mid].first) {
max = mid - 1;
} else {
return 1;
}
}
return 0;
};
exports.default = bisearch;
}
});
// ../../node_modules/simple-wcswidth/dist/src/wcwidth.js
var require_wcwidth = __commonJS({
"../../node_modules/simple-wcswidth/dist/src/wcwidth.js"(exports) {
"use strict";
var __importDefault = exports && exports.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var non_spacing_chars_1 = __importDefault(require_non_spacing_chars());
var binary_search_1 = __importDefault(require_binary_search());
var mk_wcwidth = (ucs) => {
if (ucs === 0) {
return 0;
}
if (ucs < 32 || ucs >= 127 && ucs < 160) {
return -1;
}
if (binary_search_1.default(ucs, non_spacing_chars_1.default, non_spacing_chars_1.default.length - 1)) {
return 0;
}
return 1 + Number(ucs >= 4352 && (ucs <= 4447 || ucs === 9001 || ucs === 9002 || ucs >= 11904 && ucs <= 42191 && ucs !== 12351 || ucs >= 44032 && ucs <= 55203 || ucs >= 63744 && ucs <= 64255 || ucs >= 65040 && ucs <= 65049 || ucs >= 65072 && ucs <= 65135 || ucs >= 65280 && ucs <= 65376 || ucs >= 65504 && ucs <= 65510 || ucs >= 131072 && ucs <= 196605 || ucs >= 196608 && ucs <= 262141));
};
exports.default = mk_wcwidth;
}
});
// ../../node_modules/simple-wcswidth/dist/src/wcswidth.js
var require_wcswidth = __commonJS({
"../../node_modules/simple-wcswidth/dist/src/wcswidth.js"(exports) {
"use strict";
var __importDefault = exports && exports.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var wcwidth_1 = __importDefault(require_wcwidth());
var mk_wcswidth = (pwcs) => {
let width = 0;
for (let i2 = 0; i2 < pwcs.length; i2++) {
const charCode = pwcs.charCodeAt(i2);
const w2 = wcwidth_1.default(charCode);
if (w2 < 0) {
return -1;
}
width += w2;
}
return width;
};
exports.default = mk_wcswidth;
}
});
// ../../node_modules/simple-wcswidth/dist/index.js
var require_dist = __commonJS({
"../../node_modules/simple-wcswidth/dist/index.js"(exports) {
"use strict";
var __importDefault = exports && exports.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.wcswidth = exports.wcwidth = void 0;
var wcswidth_1 = __importDefault(require_wcswidth());
exports.wcswidth = wcswidth_1.default;
var wcwidth_1 = __importDefault(require_wcwidth());
exports.wcwidth = wcwidth_1.default;
}
});
// ../../node_modules/console-table-printer/dist/src/utils/console-utils.js
var require_console_utils = __commonJS({
"../../node_modules/console-table-printer/dist/src/utils/console-utils.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findWidthInConsole = exports.stripAnsi = void 0;
var simple_wcswidth_1 = require_dist();
var colorRegex = /\x1b\[\d{1,3}(;\d{1,3})*m/g;
var stripAnsi = (str) => str.replace(colorRegex, "");
exports.stripAnsi = stripAnsi;
var findWidthInConsole = (str, charLength) => {
let strLen = 0;
str = (0, exports.stripAnsi)(str);
if (charLength) {
Object.entries(charLength).forEach(([key, value]) => {
let regex = new RegExp(key, "g");
strLen += (str.match(regex) || []).length * value;
str = str.replace(key, "");
});
}
strLen += (0, simple_wcswidth_1.wcswidth)(str);
return strLen;
};
exports.findWidthInConsole = findWidthInConsole;
}
});
// ../../node_modules/console-table-printer/dist/src/utils/string-utils.js
var require_string_utils = __commonJS({
"../../node_modules/console-table-printer/dist/src/utils/string-utils.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.biggestWordInSentence = exports.textWithPadding = exports.splitTextIntoTextsOfMinLen = void 0;
var console_utils_1 = require_console_utils();
var splitTextIntoTextsOfMinLen = (inpStr, width, charLength) => {
const ret = [];
const spaceSeparatedStrings = inpStr.split(" ");
let now = [];
let cnt = 0;
spaceSeparatedStrings.forEach((strWithoutSpace) => {
const consoleWidth = (0, console_utils_1.findWidthInConsole)(strWithoutSpace, charLength);
if (cnt + consoleWidth <= width) {
cnt += consoleWidth + 1;
now.push(strWithoutSpace);
} else {
ret.push(now.join(" "));
now = [strWithoutSpace];
cnt = consoleWidth + 1;
}
});
ret.push(now.join(" "));
return ret;
};
exports.splitTextIntoTextsOfMinLen = splitTextIntoTextsOfMinLen;
var textWithPadding = (text, alignment, columnLen, charLength) => {
const curTextSize = (0, console_utils_1.findWidthInConsole)(text, charLength);
const leftPadding = Math.floor((columnLen - curTextSize) / 2);
const rightPadding = columnLen - leftPadding - curTextSize;
if (columnLen < curTextSize) {
const splittedLines = (0, exports.splitTextIntoTextsOfMinLen)(text, columnLen);
if (splittedLines.length === 1) {
return text;
}
return splittedLines.map((singleLine) => (0, exports.textWithPadding)(singleLine, alignment, columnLen, charLength)).join("\n");
}
switch (alignment) {
case "left":
return text.concat(" ".repeat(columnLen - curTextSize));
case "center":
return " ".repeat(leftPadding).concat(text).concat(" ".repeat(rightPadding));
case "right":
default:
return " ".repeat(columnLen - curTextSize).concat(text);
}
};
exports.textWithPadding = textWithPadding;
var biggestWordInSentence = (inpStr, charLength) => inpStr.split(" ").reduce((a, b2) => Math.max(a, (0, console_utils_1.findWidthInConsole)(b2, charLength)), 0);
exports.biggestWordInSentence = biggestWordInSentence;
}
});
// ../../node_modules/console-table-printer/dist/src/utils/table-helpers.js
var require_table_helpers = __commonJS({
"../../node_modules/console-table-printer/dist/src/utils/table-helpers.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWidthLimitedColumnsArray = exports.createHeaderAsRow = exports.renderTableHorizontalBorders = exports.findLenOfColumn = exports.createRow = exports.createColumFromComputedColumn = exports.createColumFromOnlyName = exports.createTableHorizontalBorders = exports.convertRawRowOptionsToStandard = exports.cellText = void 0;
var input_converter_1 = require_input_converter();
var console_utils_1 = require_console_utils();
var string_utils_1 = require_string_utils();
var table_constants_1 = require_table_constants();
var max = (a, b2) => Math.max(a, b2);
var cellText = (text) => text === void 0 || text === null ? "" : `${text}`;
exports.cellText = cellText;
var convertRawRowOptionsToStandard = (options) => {
if (options) {
return {
color: options.color,
separator: options.separator || table_constants_1.DEFAULT_ROW_SEPARATOR
};
}
return void 0;
};
exports.convertRawRowOptionsToStandard = convertRawRowOptionsToStandard;
var createTableHorizontalBorders = ({ left, mid, right, other }, column_lengths) => {
let ret = left;
column_lengths.forEach((len) => {
ret += other.repeat(len + 2);
ret += mid;
});
ret = ret.slice(0, -mid.length);
ret += right;
return ret;
};
exports.createTableHorizontalBorders = createTableHorizontalBorders;
var createColumFromOnlyName = (name) => ({
name,
title: name
});
exports.createColumFromOnlyName = createColumFromOnlyName;
var createColumFromComputedColumn = (column) => {
var _a;
return Object.assign(Object.assign(Object.assign(Object.assign({ name: column.name, title: (_a = column.title) !== null && _a !== void 0 ? _a : column.name }, (0, input_converter_1.objIfExists)("color", column.color)), (0, input_converter_1.objIfExists)("maxLen", column.maxLen)), (0, input_converter_1.objIfExists)("minLen", column.minLen)), { alignment: column.alignment || table_constants_1.DEFAULT_ROW_ALIGNMENT });
};
exports.createColumFromComputedColumn = createColumFromComputedColumn;
var createRow = (color, text, separator) => ({
color,
separator,
text
});
exports.createRow = createRow;
var findLenOfColumn = (column, rows, charLength) => {
const columnId = column.name;
const columnTitle = column.title;
let length = max(0, (column === null || column === void 0 ? void 0 : column.minLen) || 0);
if (column.maxLen) {
length = max(length, max(column.maxLen, (0, string_utils_1.biggestWordInSentence)(columnTitle, charLength)));
length = rows.reduce((acc, row) => max(acc, (0, string_utils_1.biggestWordInSentence)((0, exports.cellText)(row.text[columnId]), charLength)), length);
return length;
}
length = max(length, (0, console_utils_1.findWidthInConsole)(columnTitle, charLength));
rows.forEach((row) => {
length = max(length, (0, console_utils_1.findWidthInConsole)((0, exports.cellText)(row.text[columnId]), charLength));
});
return length;
};
exports.findLenOfColumn = findLenOfColumn;
var renderTableHorizontalBorders = (style, column_lengths) => {
const str = (0, exports.createTableHorizontalBorders)(style, column_lengths);
return str;
};
exports.renderTableHorizontalBorders = renderTableHorizontalBorders;
var createHeaderAsRow = (createRowFn, columns) => {
const headerColor = table_constants_1.DEFAULT_HEADER_FONT_COLOR;
const row = createRowFn(headerColor, {}, false);
columns.forEach((column) => {
row.text[column.name] = column.title;
});
return row;
};
exports.createHeaderAsRow = createHeaderAsRow;
var getWidthLimitedColumnsArray = (columns, row, charLength) => {
const ret = {};
columns.forEach((column) => {
ret[column.name] = (0, string_utils_1.splitTextIntoTextsOfMinLen)((0, exports.cellText)(row.text[column.name]), column.length || table_constants_1.DEFAULT_COLUMN_LEN, charLength);
});
return ret;
};
exports.getWidthLimitedColumnsArray = getWidthLimitedColumnsArray;
}
});
// ../../node_modules/console-table-printer/dist/src/internalTable/table-pre-processors.js
var require_table_pre_processors = __commonJS({
"../../node_modules/console-table-printer/dist/src/internalTable/table-pre-processors.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.preProcessRows = exports.preProcessColumns = void 0;
var table_helpers_1 = require_table_helpers();
var createComputedColumnsIfNecessary = (table) => {
if (table.computedColumns.length) {
table.computedColumns.forEach((computedColumn) => {
table.addColumn(computedColumn);
table.rows.forEach((row) => {
row.text[computedColumn.name] = computedColumn.function(row.text);
});
});
}
};
var disableColumnsIfNecessary = (table) => {
if (table.enabledColumns.length) {
table.columns = table.columns.filter((col) => table.enabledColumns.includes(col.name));
}
};
var enableColumnsIfNecessary = (table) => {
if (table.disabledColumns.length) {
table.columns = table.columns.filter((col) => !table.disabledColumns.includes(col.name));
}
};
var findColumnWidth = (table) => {
table.columns.forEach((column) => {
column.length = (0, table_helpers_1.findLenOfColumn)(column, table.rows, table.charLength);
});
};
var preProcessColumns = (table) => {
createComputedColumnsIfNecessary(table);
enableColumnsIfNecessary(table);
disableColumnsIfNecessary(table);
findColumnWidth(table);
};
exports.preProcessColumns = preProcessColumns;
var preProcessRows = (table) => {
const newRows = table.rows.filter((r2) => table.filterFunction(r2.text)).sort((r1, r2) => table.sortFunction(r1.text, r2.text));
table.rows = newRows;
};
exports.preProcessRows = preProcessRows;
}
});
// ../../node_modules/console-table-printer/dist/src/internalTable/internal-table-printer.js
var require_internal_table_printer = __commonJS({
"../../node_modules/console-table-printer/dist/src/internalTable/internal-table-printer.js"(exports) {
"use strict";
var __importDefault = exports && exports.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.printSimpleTable = exports.renderSimpleTable = exports.renderTable = void 0;
var colored_console_line_1 = __importDefault(require_colored_console_line());
var string_utils_1 = require_string_utils();
var table_constants_1 = require_table_constants();
var table_helpers_1 = require_table_helpers();
var internal_table_1 = __importDefault(require_internal_table());
var table_pre_processors_1 = require_table_pre_processors();
var renderOneLine = (tableStyle, columns, currentLineIndex, widthLimitedColumnsArray, isHeader, row, colorMap, charLength) => {
const line = new colored_console_line_1.default(colorMap);
line.addCharsWithColor("", tableStyle.vertical);
columns.forEach((column) => {
const thisLineHasText = currentLineIndex < widthLimitedColumnsArray[column.name].length;
const textForThisLine = thisLineHasText ? (0, table_helpers_1.cellText)(widthLimitedColumnsArray[column.name][currentLineIndex]) : "";
line.addCharsWithColor(table_constants_1.DEFAULT_ROW_FONT_COLOR, " ");
line.addCharsWithColor(isHeader && table_constants_1.DEFAULT_HEADER_FONT_COLOR || column.color || row.color, (0, string_utils_1.textWithPadding)(textForThisLine, column.alignment || table_constants_1.DEFAULT_ROW_ALIGNMENT, column.length || table_constants_1.DEFAULT_COLUMN_LEN, charLength));
line.addCharsWithColor("", ` ${tableStyle.vertical}`);
});
return line.renderConsole();
};
var renderWidthLimitedLines = (tableStyle, columns, row, colorMap, isHeader, charLength) => {
const widthLimitedColumnsArray = (0, table_helpers_1.getWidthLimitedColumnsArray)(columns, row, charLength);
const totalLines = Object.values(widthLimitedColumnsArray).reduce((a, b2) => Math.max(a, b2.length), 0);
const ret = [];
for (let currentLineIndex = 0; currentLineIndex < totalLines; currentLineIndex += 1) {
const singleLine = renderOneLine(tableStyle, columns, currentLineIndex, widthLimitedColumnsArray, isHeader, row, colorMap, charLength);
ret.push(singleLine);
}
return ret;
};
var renderRow = (table, row) => {
let ret = [];
ret = ret.concat(renderWidthLimitedLines(table.tableStyle, table.columns, row, table.colorMap, void 0, table.charLength));
return ret;
};
var renderTableTitle = (table) => {
const ret = [];
if (table.title === void 0) {
return ret;
}
const getTableWidth = () => {
const reducer = (accumulator, currentValue) => accumulator + currentValue + 2 + 1;
return table.columns.map((m2) => m2.length || table_constants_1.DEFAULT_COLUMN_LEN).reduce(reducer, 1);
};
const titleWithPadding = (0, string_utils_1.textWithPadding)(table.title, table_constants_1.DEFAULT_HEADER_ALIGNMENT, getTableWidth());
const styledText = new colored_console_line_1.default(table.colorMap);
styledText.addCharsWithColor(table_constants_1.DEFAULT_HEADER_FONT_COLOR, titleWithPadding);
ret.push(styledText.renderConsole());
return ret;
};
var renderTableHeaders = (table) => {
let ret = [];
ret.push((0, table_helpers_1.renderTableHorizontalBorders)(table.tableStyle.headerTop, table.columns.map((m2) => m2.length || table_constants_1.DEFAULT_COLUMN_LEN)));
const row = (0, table_helpers_1.createHeaderAsRow)(table_helpers_1.createRow, table.columns);
ret = ret.concat(renderWidthLimitedLines(table.tableStyle, table.columns, row, table.colorMap, true));
ret.push((0, table_helpers_1.renderTableHorizontalBorders)(table.tableStyle.headerBottom, table.columns.map((m2) => m2.length || table_constants_1.DEFAULT_COLUMN_LEN)));
return ret;
};
var renderTableEnding = (table) => {
const ret = [];
ret.push((0, table_helpers_1.renderTableHorizontalBorders)(table.tableStyle.tableBottom, table.columns.map((m2) => m2.length || table_constants_1.DEFAULT_COLUMN_LEN)));
return ret;
};
var renderRowSeparator = (table, row) => {
const ret = [];
const lastRowIndex = table.rows.length - 1;
const currentRowIndex = table.rows.indexOf(row);
if (currentRowIndex !== lastRowIndex && row.separator) {
ret.push((0, table_helpers_1.renderTableHorizontalBorders)(table.tableStyle.rowSeparator, table.columns.map((m2) => m2.length || table_constants_1.DEFAULT_COLUMN_LEN)));
}
return ret;
};
var renderTable = (table) => {
(0, table_pre_processors_1.preProcessColumns)(table);
(0, table_pre_processors_1.preProcessRows)(table);
const ret = [];
renderTableTitle(table).forEach((row) => ret.push(row));
renderTableHeaders(table).forEach((row) => ret.push(row));
table.rows.forEach((row) => {
renderRow(table, row).forEach((row_) => ret.push(row_));
renderRowSeparator(table, row).forEach((row_) => ret.push(row_));
});
renderTableEnding(table).forEach((row) => ret.push(row));
return ret.join("\n");
};
exports.renderTable = renderTable;
var renderSimpleTable = (rows) => {
const table = new internal_table_1.default();
table.addRows(rows);
return (0, exports.renderTable)(table);
};
exports.renderSimpleTable = renderSimpleTable;
var printSimpleTable = (rows) => {
console.log((0, exports.renderSimpleTable)(rows));
};
exports.printSimpleTable = printSimpleTable;
}
});
// ../../node_modules/console-table-printer/dist/src/internalTable/internal-table.js
var require_internal_table = __commonJS({
"../../node_modules/console-table-printer/dist/src/internalTable/internal-table.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var colored_console_line_1 = require_colored_console_line();
var table_constants_1 = require_table_constants();
var table_helpers_1 = require_table_helpers();
var input_converter_1 = require_input_converter();
var internal_table_printer_1 = require_internal_table_printer();
var DEFAULT_ROW_SORT_FUNC = () => 0;
var DEFAULT_ROW_FILTER_FUNC = () => true;
var TableInternal = class {
initSimple(columns) {
this.columns = columns.map((column) => ({
name: column,
title: column,
alignment: table_constants_1.DEFAULT_ROW_ALIGNMENT
}));
}
initDetailed(options) {
var _a;
this.title = (options === null || options === void 0 ? void 0 : options.title) || this.title;
this.tableStyle = (options === null || options === void 0 ? void 0 : options.style) || this.tableStyle;
this.sortFunction = (options === null || options === void 0 ? void 0 : options.sort) || this.sortFunction;
this.filterFunction = (options === null || options === void 0 ? void 0 : options.filter) || this.filterFunction;
this.enabledColumns = (options === null || options === void 0 ? void 0 : options.enabledColumns) || this.enabledColumns;
this.disabledColumns = (options === null || options === void 0 ? void 0 : options.disabledColumns) || this.disabledColumns;
this.computedColumns = (options === null || options === void 0 ? void 0 : options.computedColumns) || this.computedColumns;
this.columns = ((_a = options === null || options === void 0 ? void 0 : options.columns) === null || _a === void 0 ? void 0 : _a.map(input_converter_1.rawColumnToInternalColumn)) || this.columns;
this.rowSeparator = (options === null || options === void 0 ? void 0 : options.rowSeparator) || this.rowSeparator;
this.charLength = (options === null || options === void 0 ? void 0 : options.charLength) || this.charLength;
if (options === null || options === void 0 ? void 0 : options.shouldDisableColors) {
this.colorMap = {};
} else if (options === null || options === void 0 ? void 0 : options.colorMap) {
this.colorMap = Object.assign(Object.assign({}, this.colorMap), options.colorMap);
}
if (options.rows !== void 0) {
this.addRows(options.rows);
}
}
constructor(options) {
this.rows = [];
this.columns = [];
this.title = void 0;
this.tableStyle = table_constants_1.DEFAULT_TABLE_STYLE;
this.filterFunction = DEFAULT_ROW_FILTER_FUNC;
this.sortFunction = DEFAULT_ROW_SORT_FUNC;
this.enabledColumns = [];
this.disabledColumns = [];
this.computedColumns = [];
this.rowSeparator = table_constants_1.DEFAULT_ROW_SEPARATOR;
this.colorMap = colored_console_line_1.DEFAULT_COLOR_MAP;
this.charLength = {};
if (options instanceof Array) {
this.initSimple(options);
} else if (typeof options === "object") {
this.initDetailed(options);
}
}
createColumnFromRow(text) {
const colNames = this.columns.map((col) => col.name);
Object.keys(text).forEach((key) => {
if (!colNames.includes(key)) {
this.columns.push((0, table_helpers_1.createColumFromOnlyName)(key));
}
});
}
addColumn(textOrObj) {
if (typeof textOrObj === "string") {
this.columns.push((0, table_helpers_1.createColumFromOnlyName)(textOrObj));
} else {
this.columns.push((0, table_helpers_1.createColumFromComputedColumn)(textOrObj));
}
}
addColumns(toBeInsertedColumns) {
toBeInsertedColumns.forEach((toBeInsertedColumn) => {
this.addColumn(toBeInsertedColumn);
});
}
addRow(text, options) {
this.createColumnFromRow(text);
this.rows.push((0, table_helpers_1.createRow)((options === null || options === void 0 ? void 0 : options.color) || table_constants_1.DEFAULT_ROW_FONT_COLOR, text, (options === null || options === void 0 ? void 0 : options.separator) !== void 0 ? options === null || options === void 0 ? void 0 : options.separator : this.rowSeparator));
}
addRows(toBeInsertedRows, options) {
toBeInsertedRows.forEach((toBeInsertedRow) => {
this.addRow(toBeInsertedRow, options);
});
}
renderTable() {
return (0, internal_table_printer_1.renderTable)(this);
}
};
exports.default = TableInternal;
}
});
// ../../node_modules/console-table-printer/dist/src/console-table-printer.js
var require_console_table_printer = __commonJS({
"../../node_modules/console-table-printer/dist/src/console-table-printer.js"(exports) {
"use strict";
var __importDefault = exports && exports.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var internal_table_1 = __importDefault(require_internal_table());
var table_helpers_1 = require_table_helpers();
var Table2 = class {
constructor(options) {
this.table = new internal_table_1.default(options);
}
addColumn(column) {
this.table.addColumn(column);
return this;
}
addColumns(columns) {
this.table.addColumns(columns);
return this;
}
addRow(text, rowOptions) {
this.table.addRow(text, (0, table_helpers_1.convertRawRowOptionsToStandard)(rowOptions));
return this;
}
addRows(toBeInsertedRows, rowOptions) {
this.table.addRows(toBeInsertedRows, (0, table_helpers_1.convertRawRowOptionsToStandard)(rowOptions));
return this;
}
printTable() {
const tableRendered = this.table.renderTable();
console.log(tableRendered);
}
render() {
return this.table.renderTable();
}
};
exports.default = Table2;
}
});
// ../../node_modules/console-table-printer/dist/index.js
var require_dist2 = __commonJS({
"../../node_modules/console-table-printer/dist/index.js"(exports) {
"use strict";
var __importDefault = exports && exports.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderTable = exports.printTable = exports.Table = void 0;
var console_table_printer_1 = __importDefault(require_console_table_printer());
exports.Table = console_table_printer_1.default;
var internal_table_printer_1 = require_internal_table_printer();
Object.defineProperty(exports, "printTable", { enumerable: true, get: function() {
return internal_table_printer_1.printSimpleTable;
} });
Object.defineProperty(exports, "renderTable", { enumerable: true, get: function() {
return internal_table_printer_1.renderSimpleTable;
} });
}
});
// ../../node_modules/globrex/index.js
var require_globrex = __commonJS({
"../../node_modules/globrex/index.js"(exports, module2) {
var isWin = process.platform === "win32";
var SEP = isWin ? `\\\\+` : `\\/`;
var SEP_ESC = isWin ? `\\\\` : `/`;
var GLOBSTAR = `((?:[^/]*(?:/|$))*)`;
var WILDCARD = `([^/]*)`;
var GLOBSTAR_SEGMENT = `((?:[^${SEP_ESC}]*(?:${SEP_ESC}|$))*)`;
var WILDCARD_SEGMENT = `([^${SEP_ESC}]*)`;
function globrex2(glob, { extended = false, globstar = false, strict = false, filepath = false, flags = "" } = {}) {
let regex = "";
let segment = "";
let path = { regex: "", segments: [] };
let inGroup = false;
let inRange = false;
const ext = [];
function add(str, { split, last, only } = {}) {
if (only !== "path")
regex += str;
if (filepath && only !== "regex") {
path.regex += str === "\\/" ? SEP : str;
if (split) {
if (last)
segment += str;
if (segment !== "") {
if (!flags.includes("g"))
segment = `^${segment}$`;
path.segments.push(new RegExp(segment, flags));
}
segment = "";
} else {
segment += str;
}
}
}
let c2, n2;
for (let i2 = 0; i2 < glob.length; i2++) {
c2 = glob[i2];
n2 = glob[i2 + 1];
if (["\\", "$", "^", ".", "="].includes(c2)) {
add(`\\${c2}`);
continue;
}
if (c2 === "/") {
add(`\\${c2}`, { split: true });
if (n2 === "/" && !strict)
regex += "?";
continue;
}
if (c2 === "(") {
if (ext.length) {
add(c2);
continue;
}
add(`\\${c2}`);
continue;
}
if (c2 === ")") {
if (ext.length) {
add(c2);
let type = ext.pop();
if (type === "@") {
add("{1}");
} else if (type === "!") {
add("([^/]*)");
} else {
add(type);
}
continue;
}
add(`\\${c2}`);
continue;
}
if (c2 === "|") {
if (ext.length) {
add(c2);
continue;
}
add(`\\${c2}`);
continue;
}
if (c2 === "+") {
if (n2 === "(" && extended) {
ext.push(c2);
continue;
}
add(`\\${c2}`);
continue;
}
if (c2 === "@" && extended) {
if (n2 === "(") {
ext.push(c2);
continue;
}
}
if (c2 === "!") {
if (extended) {
if (inRange) {
add("^");
continue;
}
if (n2 === "(") {
ext.push(c2);
add("(?!");
i2++;
continue;
}
add(`\\${c2}`);
continue;
}
add(`\\${c2}`);
continue;
}
if (c2 === "?") {
if (extended) {
if (n2 === "(") {
ext.push(c2);
} else {
add(".");
}
continue;
}
add(`\\${c2}`);
continue;
}
if (c2 === "[") {
if (inRange && n2 === ":") {
i2++;
let value = "";
while (glob[++i2] !== ":")
value += glob[i2];
if (value === "alnum")
add("(\\w|\\d)");
else if (value === "space")
add("\\s");
else if (value === "digit")
add("\\d");
i2++;
continue;
}
if (extended) {
inRange = true;
add(c2);
continue;
}
add(`\\${c2}`);
continue;
}
if (c2 === "]") {
if (extended) {
inRange = false;
add(c2);
continue;
}
add(`\\${c2}`);
continue;
}
if (c2 === "{") {
if (extended) {
inGroup = true;
add("(");
continue;
}
add(`\\${c2}`);
continue;
}
if (c2 === "}") {
if (extended) {
inGroup = false;
add(")");
continue;
}
add(`\\${c2}`);
continue;
}
if (c2 === ",") {
if (inGroup) {
add("|");
continue;
}
add(`\\${c2}`);
continue;
}
if (c2 === "*") {
if (n2 === "(" && extended) {
ext.push(c2);
continue;
}
let prevChar = glob[i2 - 1];
let starCount = 1;
while (glob[i2 + 1] === "*") {
starCount++;
i2++;
}
let nextChar = glob[i2 + 1];
if (!globstar) {
add(".*");
} else {
let isGlobstar = starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0);
if (isGlobstar) {
add(GLOBSTAR, { only: "regex" });
add(GLOBSTAR_SEGMENT, { only: "path", last: true, split: true });
i2++;
} else {
add(WILDCARD, { only: "regex" });
add(WILDCARD_SEGMENT, { only: "path" });
}
}
continue;
}
add(c2);
}
if (!flags.includes("g")) {
regex = `^${regex}$`;
segment = `^${segment}$`;
if (filepath)
path.regex = `^${path.regex}$`;
}
const result = { regex: new RegExp(regex, flags) };
if (filepath) {
path.segments.push(new RegExp(segment, flags));
path.regex = new RegExp(path.regex, flags);
path.globstar = new RegExp(!flags.includes("g") ? `^${GLOBSTAR_SEGMENT}$` : GLOBSTAR_SEGMENT, flags);
result.path = path;
}
return result;
}
module2.exports = globrex2;
}
});
// src/sui-lint-js-reporter.ts
var sui_lint_js_reporter_exports = {};
__export(sui_lint_js_reporter_exports, {
JSReporter: () => JSReporter
});
module.exports = __toCommonJS(sui_lint_js_reporter_exports);
var import_console_table_printer = __toESM(require_dist2());
var import_globrex = __toESM(require_globrex());
// src/Reporter.ts
var import_child_process = require("child_process");
var import_util = require("util");
// src/Sender/HTTPSender.ts
var import_node_https = __toESM(require("https"));
// ../../node_modules/ts-pattern/dist/index.js
var t = Symbol.for("@ts-pattern/matcher");
var e = Symbol.for("@ts-pattern/isVariadic");
var n = "@ts-pattern/anonymous-select-key";
var r = (t2) => Boolean(t2 && "object" == typeof t2);
var i = (e2) => e2 && !!e2[t];
var o = (n2, s2, c2) => {
if (i(n2)) {
const e2 = n2[t](), { matched: r2, selections: i2 } = e2.match(s2);
return r2 && i2 && Object.keys(i2).forEach((t2) => c2(t2, i2[t2])), r2;
}
if (r(n2)) {
if (!r(s2))
return false;
if (Array.isArray(n2)) {
if (!Array.isArray(s2))
return false;
let t2 = [], r2 = [], a = [];
for (const o2 of n2.keys()) {
const s3 = n2[o2];
i(s3) && s3[e] ? a.push(s3) : a.length ? r2.push(s3) : t2.push(s3);
}
if (a.length) {
if (a.length > 1)
throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
if (s2.length < t2.length + r2.length)
return false;
const e2 = s2.slice(0, t2.length), n3 = 0 === r2.length ? [] : s2.slice(-r2.length), i2 = s2.slice(t2.length, 0 === r2.length ? Infinity : -r2.length);
return t2.every((t3, n4) => o(t3, e2[n4], c2)) && r2.every((t3, e3) => o(t3, n3[e3], c2)) && (0 === a.length || o(a[0], i2, c2));
}
return n2.length === s2.length && n2.every((t3, e2) => o(t3, s2[e2], c2));
}
return Object.keys(n2).every((e2) => {
const r2 = n2[e2];
return (e2 in s2 || i(a = r2) && "optional" === a[t]().matcherType) && o(r2, s2[e2], c2);
var a;
});
}
return Object.is(s2, n2);
};
var s = (e2) => {
var n2, o2, a;
return r(e2) ? i(e2) ? null != (n2 = null == (o2 = (a = e2[t]()).getSelectionKeys) ? void 0 : o2.call(a)) ? n2 : [] : Array.isArray(e2) ? c(e2, s) : c(Object.values(e2), s) : [];
};
var c = (t2, e2) => t2.reduce((t3, n2) => t3.concat(e2(n2)), []);
function u(t2) {
return Object.assign(t2, { optional: () => l(t2), and: (e2) => m(t2, e2), or: (e2) => d(t2, e2), select: (e2) => void 0 === e2 ? p(t2) : p(e2, t2) });
}
function l(e2) {
return u({ [t]: () => ({ match: (t2) => {
let n2 = {};
const r2 = (t3, e3) => {
n2[t3] = e3;
};
return void 0 === t2 ? (s(e2).forEach((t3) => r2(t3, void 0)), { matched: true, selections: n2 }) : { matched: o(e2, t2, r2), selections: n2 };
}, getSelectionKeys: () => s(e2), matcherType: "optional" }) });
}
function m(...e2) {
return u({ [t]: () => ({ match: (t2) => {
let n2 = {};
const r2 = (t3, e3) => {
n2[t3] = e3;
};
return { matched: e2.every((e3) => o(e3, t2, r2)), selections: n2 };
}, getSelectionKeys: () => c(e2, s), matcherType: "and" }) });
}
function d(...e2) {
return u({ [t]: () => ({ match: (t2) => {
let n2 = {};
const r2 = (t3, e3) => {
n2[t3] = e3;
};
return c(e2, s).forEach((t3) => r2(t3, void 0)), { matched: e2.some((e3) => o(e3, t2, r2)), selections: n2 };
}, getSelectionKeys: () => c(e2, s), matcherType: "or" }) });
}
function y(e2) {
return { [t]: () => ({ match: (t2) => ({ matched: Boolean(e2(t2)) }) }) };
}
function p(...e2) {
const r2 = "string" == typeof e2[0] ? e2[0] : void 0, i2 = 2 === e2.length ? e2[1] : "string" == typeof e2[0] ? void 0 : e2[0];
return u({ [t]: () => ({ match: (t2) => {
let e3 = { [null != r2 ? r2 : n]: t2 };
return { matched: void 0 === i2 || o(i2, t2, (t3, n2) => {
e3[t3] = n2;
}), selections: e3 };
}, getSelectionKeys: () => [null != r2 ? r2 : n].concat(void 0 === i2 ? [] : s(i2)) }) });
}
function v(t2) {
return "number" == typeof t2;
}
function b(t2) {
return "string" == typeof t2;
}
function w(t2) {
return "bigint" == typeof t2;
}
var S = u(y(function(t2) {
return true;
}));
var j = (t2) => Object.assign(u(t2), { startsWith: (e2) => {
return j(m(t2, (n2 = e2, y((t3) => b(t3) && t3.startsWith(n2)))));
var n2;
}, endsWith: (e2) => {
return j(m(t2, (n2 = e2, y((t3) => b(t3) && t3.endsWith(n2)))));
var n2;
}, minLength: (e2) => j(m(t2, ((t3) => y((e3) => b(e3) && e3.length >= t3))(e2))), maxLength: (e2) => j(m(t2, ((t3) => y((e3) => b(e3) && e3.length <= t3))(e2))), includes: (e2) => {
return j(m(t2, (n2 = e2, y((t3) => b(t3) && t3.includes(n2)))));
var n2;
}, regex: (e2) => {
return j(m(t2, (n2 = e2, y((t3) => b(t3) && Boolean(t3.match(n2))))));
var n2;
} });
var E = j(y(b));
var K = (t2) => Object.assign(u(t2), { between: (e2, n2) => K(m(t2, ((t3, e3) => y((n3) => v(n3) && t3 <= n3 && e3 >= n3))(e2, n2))), lt: (e2) => K(m(t2, ((t3) => y((e3) => v(e3) && e3 < t3))(e2))), gt: (e2) => K(m(t2, ((t3) => y((e3) => v(e3) && e3 > t3))(e2))), lte: (e2) => K(m(t2, ((t3) => y((e3) => v(e3) && e3 <= t3))(e2))), gte: (e2) => K(m(t2, ((t3) => y((e3) => v(e3) && e3 >= t3))(e2))), int: () => K(m(t2, y((t3) => v(t3) && Number.isInteger(t3)))), finite: () => K(m(t2, y((t3) => v(t3) && Number.isFinite(t3)))), positive: () => K(m(t2, y((t3) => v(t3) && t3 > 0))), negative: () => K(m(t2, y((t3) => v(t3) && t3 < 0))) });
var x = K(y(v));
var A = (t2) => Object.assign(u(t2), { between: (e2, n2) => A(m(t2, ((t3, e3) => y((n3) => w(n3) && t3 <= n3 && e3 >= n3))(e2, n2))), lt: (e2) => A(m(t2, ((t3) => y((e3) => w(e3) && e3 < t3))(e2))), gt: (e2) => A(m(t2, ((t3) => y((e3) => w(e3) && e3 > t3))(e2))), lte: (e2) => A(m(t2, ((t3) => y((e3) => w(e3) && e3 <= t3))(e2))), gte: (e2) => A(m(t2, ((t3) => y((e3) => w(e3) && e3 >= t3))(e2))), positive: () => A(m(t2, y((t3) => w(t3) && t3 > 0))), negative: () => A(m(t2, y((t3) => w(t3) && t3 < 0))) });
var P = A(y(w));
var T = u(y(function(t2) {
return "boolean" == typeof t2;
}));
var k = u(y(function(t2) {
return "symbol" == typeof t2;
}));
var B = u(y(function(t2) {
return null == t2;
}));
var _ = u(y(function(t2) {
return null != t2;
}));
var W = { matched: false, value: void 0 };
function $(t2) {
return new z(t2, W);
}
var z = class {
constructor(t2, e2) {
this.input = void 0, this.state = void 0, this.input = t2, this.state = e2;
}
with(...t2) {
if (this.state.matched)
return this;
const e2 = t2[t2.length - 1], r2 = [t2[0]];
let i2;
3 === t2.length && "function" == typeof t2[1] ? i2 = t2[1] : t2.length > 2 && r2.push(...t2.slice(1, t2.length - 1));
let s2 = false, c2 = {};
const a = (t3, e3) => {
s2 = true, c2[t3] = e3;
}, u2 = !r2.some((t3) => o(t3, this.input, a)) || i2 && !Boolean(i2(this.input)) ? W : { matched: true, value: e2(s2 ? n in c2 ? c2[n] : c2 : this.input, this.input) };
return new z(this.input, u2);
}
when(t2, e2) {
if (this.state.matched)
return this;
const n2 = Boolean(t2(this.input));
return new z(this.input, n2 ? { matched: true, value: e2(this.input, this.input) } : W);
}
otherwise(t2) {
return this.state.matched ? this.state.value : t2(this.input);
}
exhaustive() {
if (this.state.matched)
return this.state.value;
let t2;
try {
t2 = JSON.stringify(this.input);
} catch (e2) {
t2 = this.input;
}
throw new Error(`Pattern matching error: no pattern matches value ${t2}`);
}
run() {
return this.exhaustive();
}
returnType() {
return this;
}
};
// src/Sender/HTTPSender.ts
var ONE_SECOND = 1e3;
var delay = async (ms) => new Promise((resolve) => setTimeout(resolve, ms));
var { MS_URL = "ms-common--metrics.es-global-pro.schip.io", BASIC_AUTH } = process.env;
var HTTPSender = class {
static create() {
return new HTTPSender();
}
async send(signals) {
if (!signals || signals.length === 0)
return this.log("\u{1F621} Sorry but there are not signals to send");
const body = signals.map(
(signal) => $(signal).with({ type: "repository" }, (p2) => ({ rule: p2.rule, value: p2.value, type: p2.type })).with({ type: "js" }, (p2) => ({ rule: p2.ruleName, value: p2.numberOfFails, type: p2.type })).exhaustive()
);
this.log("\u{1F680} Sending the metric to the microservice.");
const ok = await this.request(body);
if (ok)
this.log("\u{1F913} The metric has been successfully sent to the microservice.");
if (!ok) {
this.log("\u{1F605} The initial attempt to send the metric has failed. We will retry in 1 second.");
await delay(ONE_SECOND);
$(await this.request(body)).with(true, () => this.log("\u{1F60F} The retry attempt to send the metric has worked successfully.")).with(
false,
() => this.log(
"\u{1F621} Sorry, but the second retry attempt to send the metric has also failed. We will not attempt again, and the metric will be lost forever."
)
);
}
return void 0;
}
log(...msg) {
console.log.apply(console, msg);
}
async request(body) {
if (BASIC_AUTH === void 0) {
this.log("\u274C BASIC_AUTH env var shouldnt be undefined");
process.exit(1);
}
const bodyReq = {
metrics: [
{
name: "metrics.frontend.discipline",
organisationName: process.env.GITHUB_REPOSITORY_OWNER,
repositoryId: process.env.GITHUB_REPOSITORY_ID,
tags: body.map((bodyJSON) => ({
tagSetId: $(bodyJSON.type).with("repository", (p2) => "global.metrics.frontend.repository").with("js", (p2) => "global.metrics.frontend.code").exhaustive(),
key: bodyJSON.rule,
value: bodyJSON.value
}))
}
]
};
return new Promise((resolve, _reject) => {
const options = {
hostname: MS_URL,
port: 443,
path: "/v2/ci-metrics",
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Length": Buffer.byteLength(JSON.stringify(bodyReq)),
Authorization: "Basic " + BASIC_AUTH
}
};
const req = import_node_https.default.request(options, (res) => {
this.log(`STATUS: ${res.statusCode}`);
this.log(`HEADERS: ${JSON.stringify(res.headers)}`);
res.setEncoding("utf8");
res.on("data", (chunk) => {
this.log(`BODY: ${chunk}`);
});
res.on("end", () => {
this.log("No more data in response.");
const isSuccess = res.statusCode && res.statusCode >= 200 && res.statusCode < 300;
resolve(Boolean(isSuccess));
});
});
req.on("error", (e2) => {
this.log(`problem with request: ${e2.message}`);
resolve(false);
});
this.log("Body:\n\n", JSON.stringify(bodyReq, null, 2), "\n\n");
req.write(JSON.stringify(bodyReq));
req.end();
});
}
};
// src/Reporter.ts
var exec = (0, import_util.promisify)(import_child_process.exec);
var Reporter = class {
constructor() {
__publicField(this, "sender", HTTPSender.create());
}
async _isMaster() {
let branch = await exec("git rev-parse --abbrev-ref HEAD").catch(() => "UNKNOW_BRANCH");
if (typeof branch !== "string") {
branch = branch.stdout;
}
return branch.trim() === "master" || branch.trim() === "main";
}
async _getRepository() {
var _a;
let url = await exec("git config --get remote.origin.url").catch(() => "git@github.com:sui/remote-url.git");
if (typeof url !== "string") {
url = url.stdout;
}
const cleanUrl = url.trim().replace("\n", "");
const isHttp = cleanUrl.startsWith("https://");
if (isHttp) {
return (_a = cleanUrl.split("/")[4]) == null ? void 0 : _a.replace(".git", "");
} else {
const [, address] = cleanUrl.split("@");
return address.split("/")[1].replace(".git", "");
}
}
};
// src/sui-lint-js-reporter.ts
var generatePaternFromRule = (rule, eslintConfig) => {
const globalRules = Object.keys(eslintConfig.rules);
if (globalRules.some((eslintRule) => eslintRule === rule))
return [{ regex: /.*/ }];
return eslintConfig.overrides.map((override) => {
var _a;
if (!((_a = override.plugins) == null ? void 0 : _a.some((plugin) => plugin === "sui")))
return false;
const rules = Object.keys(override.rules);
if (!rules.some((overrideRule) => overrideRule === rule))
return false;
return override.files.map((glob) => (0, import_globrex.default)(glob));
}).filter(Boolean).flat(Infinity);
};
var _JSReporter = class extends Reporter {
constructor() {
super(...arguments);
__publicField(this, "data");
}
static async create() {
return new _JSReporter();
}
map(results) {
const stats = results.reduce((rulesIDs, entry) => {
const repitedRulesFailed = entry.messages.map((message) => message.ruleId);
const rulesFailed = /* @__PURE__ */ new Set([...repitedRulesFailed]);
rulesFailed.forEach((rule) => {
var _a;
if (rule == null)
return;
rulesIDs[rule] = (_a = rulesIDs[rule]) != null ? _a : [];
rulesIDs[rule].push(entry.filePath);
});
return rulesIDs;
}, {});
this.data = {
totalFiles: results.length,
paths: results.map((r2) => r2.filePath),
...stats
};
console.log({
totalFiles: results.length,
stats: Object.fromEntries(
Object.entries(stats).map(([rule, files]) => {
if (!_JSReporter.RULES_TO_SEND.some((whiteRule) => rule.startsWith(whiteRule)))
return [];
return [rule, files.length];
})
)
});
return this;
}
async send() {
if (this.data === void 0) {
throw new Error("[sui-lint] No data to send. Maybe you must call to map before");
}
if (!await this._isMaster()) {
return console.log("[sui-lint] Reporters only will happen in MASTER branch.");
}
const repository = await this._getRepository();
const config = await Promise.resolve().then(() => __toESM(require(process.cwd() + "/node_modules/@s-ui/lint/eslintrc")));
const { totalFiles, paths, ...rest } = this.data;
console.log(`
We are apply filter to send ONLY this metrics:
${_JSReporter.RULES_TO_SEND.join("\n")}
And your are trying to send all this metrics:
${Object.keys(rest).join(`
`)}
`);
const statsEntries = Object.entries(rest).map((entry) => {
var _a;
const [rule, failedFiles] = entry;
if (!_JSReporter.RULES_TO_SEND.some((whiteRule) => rule.startsWith(whiteRule)))
return false;
const patterns = generatePaternFromRule(rule, config);
const ruleRelativePaths = (_a = paths.filter((path) => patterns.some((pattern) => path.match(pattern.regex)))) == null ? void 0 : _a.length;
if (!Array.isArray(failedFiles))
return [rule, 0];
return [rule, failedFiles.length * 100 / ruleRelativePaths];
}).filter(Boolean);
const stats = Object.fromEntries(statsEntries);
const signals = Object.entries(stats).map((entry) => {
const [rule, percentageOfFails] = entry;
const signal = { type: "js", ruleName: rule, numberOfFails: percentageOfFails, repository };
return signal;
});
await this.sender.send(signals);
if (signals.length === 0)
return console.log("[JSReporter#send] Nothing to send. No signals");
const p2 = new import_console_table_printer.Table({ title: "List of Signals that will be send to DD" });
signals.forEach((signal) => p2.addRow(signal));
p2.printTable();
}
};
var JSReporter = _JSReporter;
__publicField(JSReporter, "RULES_TO_SEND", ["sui/factory-pattern", "sui/serialize-deserialize", "sui/decorators"]);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
JSReporter
});