@vitest/ui
Advanced tools
Comparing version 0.27.3 to 0.28.0
import { fileURLToPath } from 'url'; | ||
import path from 'path'; | ||
import { resolve } from 'pathe'; | ||
import sirv from 'sirv'; | ||
function normalizeWindowsPath(input = "") { | ||
if (!input.includes("\\")) { | ||
return input; | ||
} | ||
return input.replace(/\\/g, "/"); | ||
} | ||
const _UNC_REGEX = /^[/][/]/; | ||
const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/; | ||
const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/; | ||
const sep = "/"; | ||
const delimiter = ":"; | ||
const normalize = function(path2) { | ||
if (path2.length === 0) { | ||
return "."; | ||
} | ||
path2 = normalizeWindowsPath(path2); | ||
const isUNCPath = path2.match(_UNC_REGEX); | ||
const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX); | ||
const isPathAbsolute = isAbsolute(path2); | ||
const trailingSeparator = path2[path2.length - 1] === "/"; | ||
path2 = normalizeString(path2, !isPathAbsolute); | ||
if (path2.length === 0) { | ||
if (isPathAbsolute) { | ||
return "/"; | ||
} | ||
return trailingSeparator ? "./" : "."; | ||
} | ||
if (trailingSeparator) { | ||
path2 += "/"; | ||
} | ||
if (isUNCPath) { | ||
if (hasUNCDrive) { | ||
return `//./${path2}`; | ||
} | ||
return `//${path2}`; | ||
} | ||
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2; | ||
}; | ||
const join = function(...args) { | ||
if (args.length === 0) { | ||
return "."; | ||
} | ||
let joined; | ||
for (let i = 0; i < args.length; ++i) { | ||
const arg = args[i]; | ||
if (arg.length > 0) { | ||
if (joined === void 0) { | ||
joined = arg; | ||
} else { | ||
joined += `/${arg}`; | ||
} | ||
} | ||
} | ||
if (joined === void 0) { | ||
return "."; | ||
} | ||
return normalize(joined); | ||
}; | ||
const resolve = function(...args) { | ||
args = args.map((arg) => normalizeWindowsPath(arg)); | ||
let resolvedPath = ""; | ||
let resolvedAbsolute = false; | ||
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) { | ||
const path2 = i >= 0 ? args[i] : process.cwd(); | ||
if (path2.length === 0) { | ||
continue; | ||
} | ||
resolvedPath = `${path2}/${resolvedPath}`; | ||
resolvedAbsolute = isAbsolute(path2); | ||
} | ||
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute); | ||
if (resolvedAbsolute && !isAbsolute(resolvedPath)) { | ||
return `/${resolvedPath}`; | ||
} | ||
return resolvedPath.length > 0 ? resolvedPath : "."; | ||
}; | ||
function normalizeString(path2, allowAboveRoot) { | ||
let res = ""; | ||
let lastSegmentLength = 0; | ||
let lastSlash = -1; | ||
let dots = 0; | ||
let char = null; | ||
for (let i = 0; i <= path2.length; ++i) { | ||
if (i < path2.length) { | ||
char = path2[i]; | ||
} else if (char === "/") { | ||
break; | ||
} else { | ||
char = "/"; | ||
} | ||
if (char === "/") { | ||
if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) { | ||
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") { | ||
if (res.length > 2) { | ||
const lastSlashIndex = res.lastIndexOf("/"); | ||
if (lastSlashIndex === -1) { | ||
res = ""; | ||
lastSegmentLength = 0; | ||
} else { | ||
res = res.slice(0, lastSlashIndex); | ||
lastSegmentLength = res.length - 1 - res.lastIndexOf("/"); | ||
} | ||
lastSlash = i; | ||
dots = 0; | ||
continue; | ||
} else if (res.length !== 0) { | ||
res = ""; | ||
lastSegmentLength = 0; | ||
lastSlash = i; | ||
dots = 0; | ||
continue; | ||
} | ||
} | ||
if (allowAboveRoot) { | ||
res += res.length > 0 ? "/.." : ".."; | ||
lastSegmentLength = 2; | ||
} | ||
} else { | ||
if (res.length > 0) { | ||
res += `/${path2.slice(lastSlash + 1, i)}`; | ||
} else { | ||
res = path2.slice(lastSlash + 1, i); | ||
} | ||
lastSegmentLength = i - lastSlash - 1; | ||
} | ||
lastSlash = i; | ||
dots = 0; | ||
} else if (char === "." && dots !== -1) { | ||
++dots; | ||
} else { | ||
dots = -1; | ||
} | ||
} | ||
return res; | ||
} | ||
const isAbsolute = function(p) { | ||
return _IS_ABSOLUTE_RE.test(p); | ||
}; | ||
const toNamespacedPath = function(p) { | ||
return normalizeWindowsPath(p); | ||
}; | ||
const extname = function(p) { | ||
return path.posix.extname(normalizeWindowsPath(p)); | ||
}; | ||
const relative = function(from, to) { | ||
return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to)); | ||
}; | ||
const dirname = function(p) { | ||
return path.posix.dirname(normalizeWindowsPath(p)); | ||
}; | ||
const format = function(p) { | ||
return normalizeWindowsPath(path.posix.format(p)); | ||
}; | ||
const basename = function(p, ext) { | ||
return path.posix.basename(normalizeWindowsPath(p), ext); | ||
}; | ||
const parse = function(p) { | ||
return path.posix.parse(normalizeWindowsPath(p)); | ||
}; | ||
const _path = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
sep: sep, | ||
delimiter: delimiter, | ||
normalize: normalize, | ||
join: join, | ||
resolve: resolve, | ||
normalizeString: normalizeString, | ||
isAbsolute: isAbsolute, | ||
toNamespacedPath: toNamespacedPath, | ||
extname: extname, | ||
relative: relative, | ||
dirname: dirname, | ||
format: format, | ||
basename: basename, | ||
parse: parse | ||
}); | ||
({ | ||
..._path | ||
}); | ||
var index = (base = "/__vitest__/") => { | ||
@@ -189,0 +6,0 @@ return { |
import { promises } from 'fs'; | ||
import { fileURLToPath } from 'url'; | ||
import path from 'path'; | ||
import require$$0 from 'tty'; | ||
import { resolve, basename, dirname, relative } from 'pathe'; | ||
import c from 'picocolors'; | ||
import fg from 'fast-glob'; | ||
import { stringify } from 'flatted'; | ||
function normalizeWindowsPath(input = "") { | ||
if (!input.includes("\\")) { | ||
return input; | ||
} | ||
return input.replace(/\\/g, "/"); | ||
} | ||
const _UNC_REGEX = /^[/][/]/; | ||
const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/; | ||
const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/; | ||
const sep = "/"; | ||
const delimiter = ":"; | ||
const normalize = function(path2) { | ||
if (path2.length === 0) { | ||
return "."; | ||
} | ||
path2 = normalizeWindowsPath(path2); | ||
const isUNCPath = path2.match(_UNC_REGEX); | ||
const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX); | ||
const isPathAbsolute = isAbsolute(path2); | ||
const trailingSeparator = path2[path2.length - 1] === "/"; | ||
path2 = normalizeString(path2, !isPathAbsolute); | ||
if (path2.length === 0) { | ||
if (isPathAbsolute) { | ||
return "/"; | ||
} | ||
return trailingSeparator ? "./" : "."; | ||
} | ||
if (trailingSeparator) { | ||
path2 += "/"; | ||
} | ||
if (isUNCPath) { | ||
if (hasUNCDrive) { | ||
return `//./${path2}`; | ||
} | ||
return `//${path2}`; | ||
} | ||
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2; | ||
}; | ||
const join = function(...args) { | ||
if (args.length === 0) { | ||
return "."; | ||
} | ||
let joined; | ||
for (let i = 0; i < args.length; ++i) { | ||
const arg = args[i]; | ||
if (arg.length > 0) { | ||
if (joined === void 0) { | ||
joined = arg; | ||
} else { | ||
joined += `/${arg}`; | ||
} | ||
} | ||
} | ||
if (joined === void 0) { | ||
return "."; | ||
} | ||
return normalize(joined); | ||
}; | ||
const resolve = function(...args) { | ||
args = args.map((arg) => normalizeWindowsPath(arg)); | ||
let resolvedPath = ""; | ||
let resolvedAbsolute = false; | ||
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) { | ||
const path2 = i >= 0 ? args[i] : process.cwd(); | ||
if (path2.length === 0) { | ||
continue; | ||
} | ||
resolvedPath = `${path2}/${resolvedPath}`; | ||
resolvedAbsolute = isAbsolute(path2); | ||
} | ||
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute); | ||
if (resolvedAbsolute && !isAbsolute(resolvedPath)) { | ||
return `/${resolvedPath}`; | ||
} | ||
return resolvedPath.length > 0 ? resolvedPath : "."; | ||
}; | ||
function normalizeString(path2, allowAboveRoot) { | ||
let res = ""; | ||
let lastSegmentLength = 0; | ||
let lastSlash = -1; | ||
let dots = 0; | ||
let char = null; | ||
for (let i = 0; i <= path2.length; ++i) { | ||
if (i < path2.length) { | ||
char = path2[i]; | ||
} else if (char === "/") { | ||
break; | ||
} else { | ||
char = "/"; | ||
} | ||
if (char === "/") { | ||
if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) { | ||
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") { | ||
if (res.length > 2) { | ||
const lastSlashIndex = res.lastIndexOf("/"); | ||
if (lastSlashIndex === -1) { | ||
res = ""; | ||
lastSegmentLength = 0; | ||
} else { | ||
res = res.slice(0, lastSlashIndex); | ||
lastSegmentLength = res.length - 1 - res.lastIndexOf("/"); | ||
} | ||
lastSlash = i; | ||
dots = 0; | ||
continue; | ||
} else if (res.length !== 0) { | ||
res = ""; | ||
lastSegmentLength = 0; | ||
lastSlash = i; | ||
dots = 0; | ||
continue; | ||
} | ||
} | ||
if (allowAboveRoot) { | ||
res += res.length > 0 ? "/.." : ".."; | ||
lastSegmentLength = 2; | ||
} | ||
} else { | ||
if (res.length > 0) { | ||
res += `/${path2.slice(lastSlash + 1, i)}`; | ||
} else { | ||
res = path2.slice(lastSlash + 1, i); | ||
} | ||
lastSegmentLength = i - lastSlash - 1; | ||
} | ||
lastSlash = i; | ||
dots = 0; | ||
} else if (char === "." && dots !== -1) { | ||
++dots; | ||
} else { | ||
dots = -1; | ||
} | ||
} | ||
return res; | ||
} | ||
const isAbsolute = function(p) { | ||
return _IS_ABSOLUTE_RE.test(p); | ||
}; | ||
const toNamespacedPath = function(p) { | ||
return normalizeWindowsPath(p); | ||
}; | ||
const extname = function(p) { | ||
return path.posix.extname(normalizeWindowsPath(p)); | ||
}; | ||
const relative = function(from, to) { | ||
return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to)); | ||
}; | ||
const dirname = function(p) { | ||
return path.posix.dirname(normalizeWindowsPath(p)); | ||
}; | ||
const format = function(p) { | ||
return normalizeWindowsPath(path.posix.format(p)); | ||
}; | ||
const basename = function(p, ext) { | ||
return path.posix.basename(normalizeWindowsPath(p), ext); | ||
}; | ||
const parse = function(p) { | ||
return path.posix.parse(normalizeWindowsPath(p)); | ||
}; | ||
const _path = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
sep: sep, | ||
delimiter: delimiter, | ||
normalize: normalize, | ||
join: join, | ||
resolve: resolve, | ||
normalizeString: normalizeString, | ||
isAbsolute: isAbsolute, | ||
toNamespacedPath: toNamespacedPath, | ||
extname: extname, | ||
relative: relative, | ||
dirname: dirname, | ||
format: format, | ||
basename: basename, | ||
parse: parse | ||
}); | ||
({ | ||
..._path | ||
}); | ||
var picocolors = {exports: {}}; | ||
let tty = require$$0; | ||
let isColorSupported = | ||
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) && | ||
("FORCE_COLOR" in process.env || | ||
process.argv.includes("--color") || | ||
process.platform === "win32" || | ||
(tty.isatty(1) && process.env.TERM !== "dumb") || | ||
"CI" in process.env); | ||
let formatter = | ||
(open, close, replace = open) => | ||
input => { | ||
let string = "" + input; | ||
let index = string.indexOf(close, open.length); | ||
return ~index | ||
? open + replaceClose(string, close, replace, index) + close | ||
: open + string + close | ||
}; | ||
let replaceClose = (string, close, replace, index) => { | ||
let start = string.substring(0, index) + replace; | ||
let end = string.substring(index + close.length); | ||
let nextIndex = end.indexOf(close); | ||
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end | ||
}; | ||
let createColors = (enabled = isColorSupported) => ({ | ||
isColorSupported: enabled, | ||
reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String, | ||
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String, | ||
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String, | ||
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String, | ||
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String, | ||
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String, | ||
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String, | ||
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String, | ||
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String, | ||
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String, | ||
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String, | ||
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String, | ||
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String, | ||
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String, | ||
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String, | ||
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String, | ||
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String, | ||
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String, | ||
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String, | ||
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String, | ||
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String, | ||
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String, | ||
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String, | ||
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String, | ||
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String, | ||
}); | ||
picocolors.exports = createColors(); | ||
picocolors.exports.createColors = createColors; | ||
async function getModuleGraph(ctx, id) { | ||
@@ -338,4 +94,4 @@ const graph = {}; | ||
})); | ||
this.ctx.logger.log(`${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.magenta(" HTML ")))} ${picocolors.exports.magenta("Report is generated")}`); | ||
this.ctx.logger.log(`${picocolors.exports.dim(" You can run ")}${picocolors.exports.bold(`npx vite preview --base __vitest__ --outDir ${relative(this.ctx.config.root, htmlDir)}`)}${picocolors.exports.dim(" to see the test results.")}`); | ||
this.ctx.logger.log(`${c.bold(c.inverse(c.magenta(" HTML ")))} ${c.magenta("Report is generated")}`); | ||
this.ctx.logger.log(`${c.dim(" You can run ")}${c.bold(`npx vite preview --base __vitest__ --outDir ${relative(this.ctx.config.root, htmlDir)}`)}${c.dim(" to see the test results.")}`); | ||
} | ||
@@ -342,0 +98,0 @@ } |
{ | ||
"name": "@vitest/ui", | ||
"type": "module", | ||
"version": "0.27.3", | ||
"version": "0.28.0", | ||
"description": "UI for Vitest", | ||
@@ -33,2 +33,4 @@ "license": "MIT", | ||
"flatted": "^3.2.7", | ||
"pathe": "^1.1.0", | ||
"picocolors": "^1.0.0", | ||
"sirv": "^2.0.2" | ||
@@ -55,3 +57,2 @@ }, | ||
"floating-vue": "^2.0.0-y.0", | ||
"picocolors": "^1.0.0", | ||
"rollup": "^2.79.1", | ||
@@ -66,3 +67,4 @@ "splitpanes": "^3.1.5", | ||
"vue-router": "^4.1.6", | ||
"@vitest/ws-client": "0.27.3" | ||
"@vitest/runner": "0.28.0", | ||
"@vitest/ws-client": "0.28.0" | ||
}, | ||
@@ -69,0 +71,0 @@ "scripts": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
1
799078
5
2435
+ Addedpathe@^1.1.0
+ Addedpicocolors@^1.0.0
+ Addedpathe@1.1.2(transitive)
+ Addedpicocolors@1.1.0(transitive)