Skip to content

Commit

Permalink
publish
Browse files Browse the repository at this point in the history
  • Loading branch information
dmail committed Aug 20, 2024
1 parent b9a607e commit 6d96b97
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/related/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsenv/cli",
"version": "0.1.45",
"version": "0.1.46",
"description": "Command Line Interface for jsenv",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/related/cli/template-node-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@jsenv/assert": "4.4.1",
"@jsenv/core": "39.5.6",
"@jsenv/eslint-config-relax": "1.2.0",
"@jsenv/test": "3.5.7",
"@jsenv/test": "3.5.8",
"eslint": "9.9.0",
"prettier": "3.3.3"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/related/cli/template-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@jsenv/plugin-bundling": "2.7.9",
"@jsenv/plugin-minification": "1.5.6",
"@jsenv/eslint-config-relax": "1.2.0",
"@jsenv/test": "3.5.7",
"@jsenv/test": "3.5.8",
"eslint": "9.9.0",
"open": "10.1.0",
"@playwright/browser-chromium": "1.46.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/related/cli/template-web-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@jsenv/plugin-bundling": "2.7.9",
"@jsenv/plugin-minification": "1.5.6",
"@jsenv/eslint-config-relax": "1.2.0",
"@jsenv/test": "3.5.7",
"@jsenv/test": "3.5.8",
"eslint": "9.9.0",
"open": "10.1.0",
"@playwright/browser-chromium": "1.46.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/related/cli/template-web-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@jsenv/plugin-bundling": "2.7.9",
"@jsenv/plugin-minification": "1.5.6",
"@jsenv/eslint-config-relax": "1.2.0",
"@jsenv/test": "3.5.7",
"@jsenv/test": "3.5.8",
"eslint": "9.9.0",
"open": "10.1.0",
"@playwright/browser-chromium": "1.46.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/related/cli/template-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@jsenv/eslint-config-relax": "1.2.0",
"@jsenv/plugin-bundling": "2.7.9",
"@jsenv/plugin-minification": "1.5.6",
"@jsenv/test": "3.5.7",
"@jsenv/test": "3.5.8",
"eslint": "9.9.0",
"open": "10.1.0",
"@playwright/browser-chromium": "1.46.1",
Expand Down
163 changes: 131 additions & 32 deletions packages/related/test/dist/jsenv_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4317,6 +4317,11 @@ const reporterList = ({
{
reporter: "list",
beforeAll: async (testPlanResult) => {
const applyColorOnFileRelativeUrl = createApplyColorOnFileRelativeUrl(
testPlanResult.rootDirectoryUrl,
);
logOptions.applyColorOnFileRelativeUrl = applyColorOnFileRelativeUrl;

let spyReturnValue = await spy();
let write = spyReturnValue.write;
let end = spyReturnValue.end;
Expand Down Expand Up @@ -4472,6 +4477,58 @@ const reporterList = ({
return reporters;
};

const createApplyColorOnFileRelativeUrl = (rootDirectoryUrl) => {
const packageExistsMap = new Map();
const directoryHasPackageJsonFile = (directoryUrl) => {
if (packageExistsMap.has(directoryUrl)) {
return packageExistsMap.get(directoryUrl);
}
const packageJsonFileUrl = new URL("./package.json", directoryUrl);
if (existsSync(packageJsonFileUrl)) {
packageExistsMap.set(directoryUrl, true);
return true;
}
packageExistsMap.set(directoryUrl, false);
return false;
};
const applyColorOnFileRelativeUrl = (fileRelativeUrl, color) => {
let parts = fileRelativeUrl.split("/");
const filename = parts.pop();
let i = 0;
while (i < parts.length) {
const directoryRelativeUrl = parts.slice(0, i + 1).join("/");
const directoryUrl = new URL(`${directoryRelativeUrl}/`, rootDirectoryUrl)
.href;
if (directoryHasPackageJsonFile(directoryUrl)) {
if (i === 0) {
return ANSI.color(fileRelativeUrl, color);
}
// all the things before in grey
// all the things after in the color
const before = parts.slice(0, i).join("/");
const packageDirectory = parts[i];
const packageDirectoryStylized = ANSI.color(
ANSI.effect(packageDirectory, ANSI.UNDERLINE),
color,
);
let pathColored = ANSI.color(`${before}/`, color);
if (i === parts.length - 1) {
pathColored += packageDirectoryStylized;
pathColored += ANSI.color(`/${filename}`, color);
return pathColored;
}
const after = parts.slice(i + 1).join("/");
pathColored += packageDirectoryStylized;
pathColored += ANSI.color(`/${after}/${filename}`, color);
return pathColored;
}
i++;
}
return ANSI.color(fileRelativeUrl, color);
};
return applyColorOnFileRelativeUrl;
};

const renderIntro = (testPlanResult, logOptions) => {
const directory = logOptions.mockFluctuatingValues
? "/mock/"
Expand Down Expand Up @@ -4615,8 +4672,10 @@ const renderExecutionLabel = (execution, logOptions) => {

// description
{
const description =
descriptionFormatters[execution.result.status](execution);
const description = descriptionFormatters[execution.result.status](
execution,
logOptions,
);
label += description;
}
// runtimeInfo
Expand Down Expand Up @@ -4669,8 +4728,8 @@ const renderExecutionLabel = (execution, logOptions) => {
return label;
};
const descriptionFormatters = {
executing: ({ fileRelativeUrl }) => {
return ANSI.color(`${fileRelativeUrl}`, COLOR_EXECUTING);
executing: ({ fileRelativeUrl }, { applyColorOnFileRelativeUrl }) => {
return applyColorOnFileRelativeUrl(fileRelativeUrl, COLOR_EXECUTING);
},
skippedGroup: ({ from, to, skipReason }) => {
let description = `${UNICODE.CIRCLE_DOTTED_RAW} ${from + 1}:${to + 1} skipped`;
Expand All @@ -4679,57 +4738,97 @@ const descriptionFormatters = {
}
return ANSI.color(description, COLOR_SKIPPED);
},
skipped: ({ index, countersInOrder, fileRelativeUrl, skipReason }) => {
skipped: (
{ index, countersInOrder, fileRelativeUrl, skipReason },
{ applyColorOnFileRelativeUrl },
) => {
const total = countersInOrder.planified;
const number = fillLeft(index + 1, total, "0");
let description = `${UNICODE.CIRCLE_DOTTED_RAW} ${number}/${total} skipped ${fileRelativeUrl}`;
let skipped = ANSI.color(
`${UNICODE.CIRCLE_DOTTED_RAW} ${number}`,
COLOR_SKIPPED,
);
skipped += ANSI.color(`/${total}`, COLOR_SKIPPED);
skipped += " ";
skipped += ANSI.color("skipped", COLOR_SKIPPED);
skipped += " ";
skipped += applyColorOnFileRelativeUrl(fileRelativeUrl, COLOR_SKIPPED);
if (skipReason) {
description += ` (${skipReason})`;
skipped += " ";
skipped += ANSI.color(`(${skipReason})`, COLOR_SKIPPED);
}
return ANSI.color(description, COLOR_SKIPPED);
return skipped;
},
aborted: ({ index, countersInOrder, fileRelativeUrl }) => {
aborted: (
{ index, countersInOrder, fileRelativeUrl },
{ applyColorOnFileRelativeUrl },
) => {
const total = countersInOrder.planified;
const number = fillLeft(index + 1, total, "0");
return ANSI.color(
`${UNICODE.FAILURE_RAW} ${number}/${total} ${fileRelativeUrl}`,
COLOR_ABORTED,
);
let aborted = ANSI.color(`${UNICODE.FAILURE_RAW} ${number}`, COLOR_ABORTED);
aborted += ANSI.color(`/${total}`, COLOR_ABORTED);
aborted += " ";
aborted += applyColorOnFileRelativeUrl(fileRelativeUrl, COLOR_ABORTED);
return aborted;
},
cancelled: ({ index, countersInOrder, fileRelativeUrl }) => {
cancelled: (
{ index, countersInOrder, fileRelativeUrl },
{ applyColorOnFileRelativeUrl },
) => {
const total = countersInOrder.planified;
const number = fillLeft(index + 1, total, "0");
return ANSI.color(
`${UNICODE.FAILURE_RAW} ${number}/${total} ${fileRelativeUrl}`,
let cancelled = ANSI.color(
`${UNICODE.FAILURE_RAW} ${number}`,
COLOR_CANCELLED,
);
cancelled += ANSI.color(`/${total}`, COLOR_CANCELLED);
cancelled += " ";
cancelled += applyColorOnFileRelativeUrl(fileRelativeUrl, COLOR_CANCELLED);
return cancelled;
},
timedout: ({ index, countersInOrder, fileRelativeUrl, params }) => {
timedout: (
{ index, countersInOrder, fileRelativeUrl, params },
{ applyColorOnFileRelativeUrl },
) => {
const total = countersInOrder.planified;
const number = fillLeft(index + 1, total, "0");

return ANSI.color(
`${UNICODE.FAILURE_RAW} ${number}/${total} ${fileRelativeUrl} timeout after ${params.allocatedMs}ms`,
let timedout = ANSI.color(
`${UNICODE.FAILURE_RAW} ${number}`,
COLOR_TIMEOUT,
);
timedout += ANSI.color(`/${total}`, COLOR_TIMEOUT);
timedout += " ";
timedout += applyColorOnFileRelativeUrl(fileRelativeUrl, COLOR_TIMEOUT);
timedout += " ";
timedout += ANSI.color(
`timeout after ${params.allocatedMs}ms`,
COLOR_TIMEOUT,
);
return timedout;
},
failed: ({ index, countersInOrder, fileRelativeUrl }) => {
failed: (
{ index, countersInOrder, fileRelativeUrl },
{ applyColorOnFileRelativeUrl },
) => {
const total = countersInOrder.planified;
const number = fillLeft(index + 1, total, "0");

return ANSI.color(
`${UNICODE.FAILURE_RAW} ${number}/${total} ${fileRelativeUrl}`,
COLOR_FAILED,
);
let failed = ANSI.color(`${UNICODE.FAILURE_RAW} ${number}`, COLOR_FAILED);
failed += ANSI.color(`/${total}`, COLOR_FAILED);
failed += " ";
failed += applyColorOnFileRelativeUrl(fileRelativeUrl, COLOR_FAILED);
return failed;
},
completed: ({ index, countersInOrder, fileRelativeUrl }) => {
completed: (
{ index, countersInOrder, fileRelativeUrl },
{ applyColorOnFileRelativeUrl },
) => {
const total = countersInOrder.planified;
const number = fillLeft(index + 1, total, "0");

return ANSI.color(
`${UNICODE.OK_RAW} ${number}/${total} ${fileRelativeUrl}`,
COLOR_COMPLETED,
);
let completed = ANSI.color(`${UNICODE.OK_RAW} ${number}`, COLOR_COMPLETED);
completed += ANSI.color(`/${total}`, COLOR_COMPLETED);
completed += " ";
completed += applyColorOnFileRelativeUrl(fileRelativeUrl, COLOR_COMPLETED);
return completed;
},
};

Expand Down
2 changes: 1 addition & 1 deletion packages/related/test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsenv/test",
"version": "3.5.7",
"version": "3.5.8",
"license": "MIT",
"repository": {
"type": "git",
Expand Down

0 comments on commit 6d96b97

Please sign in to comment.