Skip to content

Commit

Permalink
refactor(init): replaces runtime wordwrap on feedback with a static w…
Browse files Browse the repository at this point in the history
…ordwrap
  • Loading branch information
sverweij committed Jun 29, 2024
1 parent 838b3e8 commit eac0d63
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
9 changes: 0 additions & 9 deletions .dependency-cruiser-known-violations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion .dependency-cruiser.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
27 changes: 19 additions & 8 deletions src/cli/init-config/write-run-scripts-to-manifest.mjs
Original file line number Diff line number Diff line change
@@ -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}`;

Expand All @@ -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 <regex>",
description:
"writes all dependencies to and from modules matching the given <regex> to stdout - in simple text",
" writes all dependencies to and from modules matching the given <regex>" +
EOL +
" to stdout - in simple text",
},
// {
// name: "depcruise:text",
Expand Down Expand Up @@ -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`,
Expand Down

0 comments on commit eac0d63

Please sign in to comment.