From 6d96b9726acb6089ceec71b14cf0b44f7766a1e1 Mon Sep 17 00:00:00 2001 From: dmail Date: Tue, 20 Aug 2024 15:10:08 +0200 Subject: [PATCH] publish --- packages/related/cli/package.json | 2 +- .../cli/template-node-package/package.json | 2 +- .../cli/template-web-components/package.json | 2 +- .../cli/template-web-preact/package.json | 2 +- .../cli/template-web-react/package.json | 2 +- .../related/cli/template-web/package.json | 2 +- packages/related/test/dist/jsenv_test.js | 163 ++++++++++++++---- packages/related/test/package.json | 2 +- 8 files changed, 138 insertions(+), 39 deletions(-) diff --git a/packages/related/cli/package.json b/packages/related/cli/package.json index e5d6324daf..f9c5b8e989 100644 --- a/packages/related/cli/package.json +++ b/packages/related/cli/package.json @@ -1,6 +1,6 @@ { "name": "@jsenv/cli", - "version": "0.1.45", + "version": "0.1.46", "description": "Command Line Interface for jsenv", "license": "MIT", "repository": { diff --git a/packages/related/cli/template-node-package/package.json b/packages/related/cli/template-node-package/package.json index 7378654ebd..ccbbb0762c 100644 --- a/packages/related/cli/template-node-package/package.json +++ b/packages/related/cli/template-node-package/package.json @@ -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" } diff --git a/packages/related/cli/template-web-components/package.json b/packages/related/cli/template-web-components/package.json index 09dbb47117..c5a6761855 100644 --- a/packages/related/cli/template-web-components/package.json +++ b/packages/related/cli/template-web-components/package.json @@ -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", diff --git a/packages/related/cli/template-web-preact/package.json b/packages/related/cli/template-web-preact/package.json index c074cb6b82..36d00f497a 100644 --- a/packages/related/cli/template-web-preact/package.json +++ b/packages/related/cli/template-web-preact/package.json @@ -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", diff --git a/packages/related/cli/template-web-react/package.json b/packages/related/cli/template-web-react/package.json index 94f6f5502c..03895fb276 100644 --- a/packages/related/cli/template-web-react/package.json +++ b/packages/related/cli/template-web-react/package.json @@ -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", diff --git a/packages/related/cli/template-web/package.json b/packages/related/cli/template-web/package.json index e603c33a86..182065fac1 100644 --- a/packages/related/cli/template-web/package.json +++ b/packages/related/cli/template-web/package.json @@ -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", diff --git a/packages/related/test/dist/jsenv_test.js b/packages/related/test/dist/jsenv_test.js index 52b87a9445..2feb252259 100644 --- a/packages/related/test/dist/jsenv_test.js +++ b/packages/related/test/dist/jsenv_test.js @@ -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; @@ -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/" @@ -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 @@ -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`; @@ -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; }, }; diff --git a/packages/related/test/package.json b/packages/related/test/package.json index f3558424b7..94aded6520 100644 --- a/packages/related/test/package.json +++ b/packages/related/test/package.json @@ -1,6 +1,6 @@ { "name": "@jsenv/test", - "version": "3.5.7", + "version": "3.5.8", "license": "MIT", "repository": { "type": "git",