From eac0d63da8b595a707b47e09ec4c97c344e366bf Mon Sep 17 00:00:00 2001 From: sverweij Date: Sat, 29 Jun 2024 10:09:39 +0200 Subject: [PATCH] refactor(init): replaces runtime wordwrap on feedback with a static wordwrap --- .dependency-cruiser-known-violations.json | 9 ------- .dependency-cruiser.json | 5 +++- .../write-run-scripts-to-manifest.mjs | 27 +++++++++++++------ 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.dependency-cruiser-known-violations.json b/.dependency-cruiser-known-violations.json index c893c35bb..06020d77c 100644 --- a/.dependency-cruiser-known-violations.json +++ b/.dependency-cruiser-known-violations.json @@ -44,15 +44,6 @@ "name": "no-non-package-json" } }, - { - "type": "module", - "from": "src/graph-utl/consolidate-to-folder.mjs", - "to": "src/graph-utl/consolidate-to-folder.mjs", - "rule": { - "severity": "error", - "name": "not-unreachable-from-cli" - } - }, { "type": "module", "from": "src/schema/baseline-violations.schema.mjs", diff --git a/.dependency-cruiser.json b/.dependency-cruiser.json index cbaf67477..375dffe10 100644 --- a/.dependency-cruiser.json +++ b/.dependency-cruiser.json @@ -233,7 +233,10 @@ "name": "not-unreachable-from-cli", "severity": "error", "comment": "This module in the src/ tree is not reachable from the cli - and is likely dead wood. Either use it or remove it. If a module is flagged for which it's logical it is not reachable from cli (i.e. a configuration file), add it to the pathNot in the 'to' of this rule.", - "from": { "path": "^bin/" }, + // the exceptions for "^src/report/": the reporters are dynamically loaded; + // they're like internal plugins, so there is a dependency but it's determined + // at runtime. + "from": { "path": ["^bin/", "^src/report/"] }, "to": { "path": "^src", "pathNot": [ diff --git a/src/cli/init-config/write-run-scripts-to-manifest.mjs b/src/cli/init-config/write-run-scripts-to-manifest.mjs index 910291233..28b71c92a 100644 --- a/src/cli/init-config/write-run-scripts-to-manifest.mjs +++ b/src/cli/init-config/write-run-scripts-to-manifest.mjs @@ -1,10 +1,11 @@ +/* eslint-disable prefer-template */ /* eslint-disable security/detect-object-injection */ import { writeFileSync } from "node:fs"; +import { EOL } from "node:os"; import chalk from "chalk"; import { PACKAGE_MANIFEST as _PACKAGE_MANIFEST } from "../defaults.mjs"; import { readManifest } from "./environment-helpers.mjs"; import { folderNameArrayToRE } from "./utl.mjs"; -import wrapAndIndent from "#utl/wrap-and-indent.mjs"; const PACKAGE_MANIFEST = `./${_PACKAGE_MANIFEST}`; @@ -13,37 +14,47 @@ const EXPERIMENTAL_SCRIPT_DOC = [ name: "depcruise", headline: "npm run depcruise", description: - "validates against the rules in .dependency-cruiser.js and writes the outcome to stdout", + " validates against the rules in .dependency-cruiser.js and writes the" + + EOL + + " outcome to stdout", }, { name: "depcruise:html", headline: "npm run depcruise:html", description: - "validates against the rules in .dependency-cruiser.js and writes it to 'dependency-violation-report.html' with a friendly layout", + " validates against the rules in .dependency-cruiser.js and writes it to" + + EOL + + " 'dependency-violation-report.html' with a friendly layout", }, { name: "depcruise:graph", headline: "npm run depcruise:graph", description: - "writes a detailed internal graph of your app to 'dependency-graph.html'", + " writes a detailed internal graph of your app to 'dependency-graph.html'", }, { name: "depcruise:graph:dev", headline: "npm run depcruise:graph:dev", description: - "opens a detailed internal graph of your app in your default browser (uses the 'browser' command line program)", + " opens a detailed internal graph of your app in your default browser" + + EOL + + " (uses the 'browser' command line program)", }, { name: "depcruise:graph:archi", headline: "depcruise:graph:archi", description: - "writes a high-level internal graph of your app to 'high-level-dependency-graph.html", + " writes a high-level internal graph of your app to" + + EOL + + " 'high-level-dependency-graph.html", }, { name: "depcruise:focus", headline: "npm run depcruise:focus ", description: - "writes all dependencies to and from modules matching the given to stdout - in simple text", + " writes all dependencies to and from modules matching the given " + + EOL + + " to stdout - in simple text", }, // { // name: "depcruise:text", @@ -121,7 +132,7 @@ function getSuccessMessage(pDestinationManifestFileName) { (pAll, pScript) => { return `${pAll}${ `\n ${chalk.green("►")} ${pScript.headline}` + - `\n${wrapAndIndent(`${pScript.description}`, lExplanationIndent)}\n\n` + `\n${pScript.description}\n\n` }`; }, ` ${chalk.green("√")} Run scripts added to '${pDestinationManifestFileName}':\n`,