vitest-github-actions-reporter
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -0,5 +1,9 @@ | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -20,12 +24,158 @@ var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
// src/actions.ts | ||
var startGroup = (groupName) => `::group::${groupName}`; | ||
var endGroup = () => `::endgroup::`; | ||
var outputError = (obj, message) => { | ||
const args = Object.entries(obj).map(([key, val]) => `${key}=${val}`).join(","); | ||
return `::error ${args}::${message}`; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { | ||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b] | ||
}) : x)(function(x) { | ||
if (typeof require !== "undefined") | ||
return require.apply(this, arguments); | ||
throw new Error('Dynamic require of "' + x + '" is not supported'); | ||
}); | ||
var __esm = (fn, res) => function __init() { | ||
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; | ||
}; | ||
var __commonJS = (cb, mod) => function __require2() { | ||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
}; | ||
var __reExport = (target, module, copyDefault, desc) => { | ||
if (module && typeof module === "object" || typeof module === "function") { | ||
for (let key of __getOwnPropNames(module)) | ||
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default")) | ||
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
}; | ||
var __toESM = (module, isNodeMode) => { | ||
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", !isNodeMode && module && module.__esModule ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module); | ||
}; | ||
// node_modules/tsup/assets/esm_shims.js | ||
var init_esm_shims = __esm({ | ||
"node_modules/tsup/assets/esm_shims.js"() { | ||
} | ||
}); | ||
// node_modules/@actions/core/lib/utils.js | ||
var require_utils = __commonJS({ | ||
"node_modules/@actions/core/lib/utils.js"(exports) { | ||
"use strict"; | ||
init_esm_shims(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toCommandProperties = exports.toCommandValue = void 0; | ||
function toCommandValue(input) { | ||
if (input === null || input === void 0) { | ||
return ""; | ||
} else if (typeof input === "string" || input instanceof String) { | ||
return input; | ||
} | ||
return JSON.stringify(input); | ||
} | ||
exports.toCommandValue = toCommandValue; | ||
function toCommandProperties(annotationProperties) { | ||
if (!Object.keys(annotationProperties).length) { | ||
return {}; | ||
} | ||
return { | ||
title: annotationProperties.title, | ||
file: annotationProperties.file, | ||
line: annotationProperties.startLine, | ||
endLine: annotationProperties.endLine, | ||
col: annotationProperties.startColumn, | ||
endColumn: annotationProperties.endColumn | ||
}; | ||
} | ||
exports.toCommandProperties = toCommandProperties; | ||
} | ||
}); | ||
// node_modules/@actions/core/lib/command.js | ||
var require_command = __commonJS({ | ||
"node_modules/@actions/core/lib/command.js"(exports) { | ||
"use strict"; | ||
init_esm_shims(); | ||
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) { | ||
if (k2 === void 0) | ||
k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { | ||
return m[k]; | ||
} }); | ||
} : function(o, m, k, k2) { | ||
if (k2 === void 0) | ||
k2 = k; | ||
o[k2] = m[k]; | ||
}); | ||
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
} : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = exports && exports.__importStar || function(mod) { | ||
if (mod && mod.__esModule) | ||
return mod; | ||
var result = {}; | ||
if (mod != null) { | ||
for (var k in mod) | ||
if (k !== "default" && Object.hasOwnProperty.call(mod, k)) | ||
__createBinding(result, mod, k); | ||
} | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.issue = exports.issueCommand = void 0; | ||
var os = __importStar(__require("os")); | ||
var utils_1 = require_utils(); | ||
function issueCommand2(command, properties, message) { | ||
const cmd = new Command(command, properties, message); | ||
process.stdout.write(cmd.toString() + os.EOL); | ||
} | ||
exports.issueCommand = issueCommand2; | ||
function issue2(name, message = "") { | ||
issueCommand2(name, {}, message); | ||
} | ||
exports.issue = issue2; | ||
var CMD_STRING = "::"; | ||
var Command = class { | ||
constructor(command, properties, message) { | ||
if (!command) { | ||
command = "missing.command"; | ||
} | ||
this.command = command; | ||
this.properties = properties; | ||
this.message = message; | ||
} | ||
toString() { | ||
let cmdStr = CMD_STRING + this.command; | ||
if (this.properties && Object.keys(this.properties).length > 0) { | ||
cmdStr += " "; | ||
let first = true; | ||
for (const key in this.properties) { | ||
if (this.properties.hasOwnProperty(key)) { | ||
const val = this.properties[key]; | ||
if (val) { | ||
if (first) { | ||
first = false; | ||
} else { | ||
cmdStr += ","; | ||
} | ||
cmdStr += `${key}=${escapeProperty(val)}`; | ||
} | ||
} | ||
} | ||
} | ||
cmdStr += `${CMD_STRING}${escapeData(this.message)}`; | ||
return cmdStr; | ||
} | ||
}; | ||
function escapeData(s) { | ||
return utils_1.toCommandValue(s).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A"); | ||
} | ||
function escapeProperty(s) { | ||
return utils_1.toCommandValue(s).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C"); | ||
} | ||
} | ||
}); | ||
// src/index.ts | ||
init_esm_shims(); | ||
var import_command = __toESM(require_command(), 1); | ||
var GitHubActionsReporter = class { | ||
@@ -38,5 +188,5 @@ onInit(ctx) { | ||
return; | ||
this.ctx.log(startGroup("Vitest Annotations")); | ||
(0, import_command.issue)("group", "Vitest Annotations"); | ||
this.reportFiles(files); | ||
this.ctx.log(endGroup()); | ||
(0, import_command.issue)("endgroup"); | ||
} | ||
@@ -64,6 +214,5 @@ reportFiles(files) { | ||
const position = this.getPositionFromError(filename, (_a = suite.result) == null ? void 0 : _a.error); | ||
const text = outputError(__spreadProps(__spreadValues({}, position), { | ||
(0, import_command.issueCommand)("error", __spreadProps(__spreadValues({}, position), { | ||
title: this.getErrorTitle((_b = suite.result) == null ? void 0 : _b.error, "Failed Suite") | ||
}), (_d = (_c = suite.result) == null ? void 0 : _c.error) == null ? void 0 : _d.stackStr); | ||
this.ctx.log(text); | ||
} | ||
@@ -75,6 +224,5 @@ reportTest(filename, test) { | ||
const position = this.getPositionFromError(filename, (_b = test.result) == null ? void 0 : _b.error); | ||
const text = outputError(__spreadProps(__spreadValues({}, position), { | ||
(0, import_command.issueCommand)("error", __spreadProps(__spreadValues({}, position), { | ||
title: this.getErrorTitle((_c = test.result) == null ? void 0 : _c.error, "Failed Test") | ||
}), (_d = test.result.error) == null ? void 0 : _d.stackStr); | ||
this.ctx.log(text); | ||
} | ||
@@ -81,0 +229,0 @@ getPositionFromError(filename, error) { |
{ | ||
"name": "vitest-github-actions-reporter", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Vitest reporter to create annotations when running tests in GitHub Actions", | ||
@@ -46,2 +46,3 @@ "type": "module", | ||
"devDependencies": { | ||
"@actions/core": "^1.6.0", | ||
"@typescript-eslint/eslint-plugin": "^5.13.0", | ||
@@ -48,0 +49,0 @@ "@typescript-eslint/parser": "^5.13.0", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33250
492
10
3