dependency-cruiser 16.3.9 → 16.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-cruiser",
3
- "version": "16.3.9",
3
+ "version": "16.3.10",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -49,6 +49,7 @@
49
49
  "Jessica Kerr (https://jessitron.com)",
50
50
  "Creative Ataraxia (https://github.com/Creative-Ataraxia)",
51
51
  "0xflotus (https://github.com/0xflotus)",
52
+ "KenjiroKubota (https://github.com/kubotak-is)",
52
53
  "Daniel Edholm Ignat (https://github.com/dignite)",
53
54
  "Daniel Rodríguez Rivero (https://danielorodriguez.com)",
54
55
  "Nick Ribal (https://github.com/elektronik2k5)",
@@ -145,12 +146,11 @@
145
146
  "acorn-walk": "8.3.3",
146
147
  "ajv": "8.17.1",
147
148
  "commander": "12.1.0",
148
- "enhanced-resolve": "5.17.0",
149
+ "enhanced-resolve": "5.17.1",
149
150
  "ignore": "5.3.1",
150
151
  "interpret": "^3.1.1",
151
152
  "is-installed-globally": "1.0.0",
152
153
  "json5": "2.2.3",
153
- "lodash": "4.17.21",
154
154
  "memoize": "10.0.0",
155
155
  "picocolors": "1.0.1",
156
156
  "picomatch": "4.0.2",
package/src/cli/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { join } from "node:path";
2
2
  import picomatch from "picomatch";
3
- import set from "lodash/set.js";
4
3
  import isInstalledGlobally from "is-installed-globally";
5
4
  import pc from "picocolors";
6
5
 
@@ -10,6 +9,7 @@ import { write } from "./utl/io.mjs";
10
9
  import setUpCliFeedbackListener from "./listeners/cli-feedback.mjs";
11
10
  import setUpPerformanceLogListener from "./listeners/performance-log/index.mjs";
12
11
  import setUpNDJSONListener from "./listeners/ndjson.mjs";
12
+ import { set } from "#utl/object-util.mjs";
13
13
  import cruise from "#main/cruise.mjs";
14
14
  import { INFO, bus } from "#utl/bus.mjs";
15
15
 
@@ -1,6 +1,5 @@
1
1
  import { accessSync, R_OK } from "node:fs";
2
2
  import { isAbsolute } from "node:path";
3
- import set from "lodash/set.js";
4
3
  import {
5
4
  RULES_FILE_NAME_SEARCH_ARRAY,
6
5
  DEFAULT_BASELINE_FILE_NAME,
@@ -11,6 +10,7 @@ import {
11
10
  BABEL_CONFIG,
12
11
  OLD_DEFAULT_RULES_FILE_NAME,
13
12
  } from "./defaults.mjs";
13
+ import { set } from "#utl/object-util.mjs";
14
14
  import loadConfig from "#config-utl/extract-depcruise-config/index.mjs";
15
15
 
16
16
  function getOptionValue(pDefault) {
@@ -1,6 +1,5 @@
1
1
  import { isDeepStrictEqual } from "node:util";
2
- import uniqBy from "lodash/uniqBy.js";
3
- import uniqWith from "lodash/uniqWith.js";
2
+ import { uniqBy, uniqWith } from "#utl/array-util.mjs";
4
3
 
5
4
  function extendNamedRule(pExtendedRule, pForbiddenArrayBase) {
6
5
  return pForbiddenArrayBase
@@ -1,7 +1,7 @@
1
- import uniqWith from "lodash/uniqWith.js";
2
1
  import isSameViolation from "./is-same-violation.mjs";
3
2
  import { findRuleByName } from "#graph-utl/rule-set.mjs";
4
3
  import compare from "#graph-utl/compare.mjs";
4
+ import { uniqWith } from "#utl/array-util.mjs";
5
5
 
6
6
  function cutNonTransgressions(pModule) {
7
7
  return {
@@ -1,5 +1,4 @@
1
1
  import { join, extname, dirname } from "node:path";
2
- import uniqBy from "lodash/uniqBy.js";
3
2
  import { extract as acornExtract } from "./acorn/extract.mjs";
4
3
  import {
5
4
  extract as tscExtract,
@@ -14,7 +13,7 @@ import {
14
13
  detectPreCompilationNess,
15
14
  extractModuleAttributes,
16
15
  } from "./helpers.mjs";
17
- import { intersects } from "#utl/array-util.mjs";
16
+ import { uniqBy, intersects } from "#utl/array-util.mjs";
18
17
 
19
18
  function extractWithTsc(pCruiseOptions, pFileName, pTranspileOptions) {
20
19
  let lDependencies = tscExtract(pCruiseOptions, pFileName, pTranspileOptions);
@@ -26,7 +26,7 @@ import { isScoped, isRelativeModuleName } from "./module-classifiers.mjs";
26
26
  *
27
27
  * At this time we don't take situations into account where the caller includes
28
28
  * a node module through a local path (which could make sense if you're on
29
- * non-commonJS and are still using node_modules) e.g. '../node_modules/lodash/fp'
29
+ * non-commonJS and are still using node_modules) e.g. '../node_modules/oldash/fp'
30
30
  *
31
31
  * @param {string} pModule a module name
32
32
  * @return {string} the module name root
@@ -58,8 +58,8 @@ export function getPackageRoot(pModule) {
58
58
  * returns the contents of the package.json of the given pModule as it would
59
59
  * resolve from pBaseDirectory
60
60
  *
61
- * e.g. to get the package.json of `lodash` that is required bya
62
- * `src/report/something.js` use `getPackageJSON('lodash', 'src/report/');`
61
+ * e.g. to get the package.json of `oldash` that is required bya
62
+ * `src/report/something.js` use `getPackageJSON('oldash', 'src/report/');`
63
63
  *
64
64
  * The pBaseDirectory parameter is necessary because dependency-cruiser/ this module
65
65
  * will have a different base dir, and will hence resolve either to the
@@ -1,5 +1,5 @@
1
- import uniqBy from "lodash/uniqBy.js";
2
1
  import compare from "./compare.mjs";
2
+ import { uniqBy } from "#utl/array-util.mjs";
3
3
 
4
4
  function mergeModule(pLeftModule, pRightModule) {
5
5
  return {
@@ -1,6 +1,4 @@
1
- import get from "lodash/get.js";
2
- import has from "lodash/has.js";
3
- import set from "lodash/set.js";
1
+ import { has, get, set } from "#utl/object-util.mjs";
4
2
 
5
3
  const RE_PROPERTIES = [
6
4
  "path",
@@ -30,7 +28,7 @@ export function normalizeREProperties(
30
28
  let lPropertyContainer = structuredClone(pPropertyContainer);
31
29
 
32
30
  for (const lProperty of pREProperties) {
33
- // lProperty can be nested properties, so we use lodash.has and lodash.get
31
+ // lProperty can be nested properties, so we use _.has and _.get
34
32
  // instead of elvis operators
35
33
  if (has(lPropertyContainer, lProperty)) {
36
34
  set(
@@ -1,10 +1,9 @@
1
1
  import Ajv from "ajv";
2
2
  import safeRegex from "safe-regex";
3
- import has from "lodash/has.js";
4
- import get from "lodash/get.js";
5
3
  import { assertCruiseOptionsValid } from "../options/assert-validity.mjs";
6
4
  import { normalizeToREAsString } from "../helpers.mjs";
7
5
  import configurationSchema from "#configuration-schema";
6
+ import { has, get } from "#utl/object-util.mjs";
8
7
 
9
8
  const ajv = new Ajv();
10
9
  // the default for this is 25 - as noted in the safe-regex source code already,
@@ -29,8 +28,8 @@ function assertSchemaCompliance(pSchema, pConfiguration) {
29
28
  }
30
29
 
31
30
  function hasPath(pObject, pSection, pCondition) {
32
- // pCondition can be nested properties, so we use lodash.has instead
33
- // of elvis operators
31
+ // pCondition can be nested properties, so we use a bespoke
32
+ // 'has' function instead of simple elvis operators
34
33
  return has(pObject, pSection) && has(pObject[pSection], pCondition);
35
34
  }
36
35
 
package/src/meta.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /* generated - don't edit */
2
2
 
3
3
  module.exports = {
4
- version: "16.3.9",
4
+ version: "16.3.10",
5
5
  engines: {
6
6
  node: "^18.17||>=20",
7
7
  },
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable prefer-template */
2
- import get from "lodash/get.js";
3
2
  import theming from "./theming.mjs";
4
3
  import moduleUtl from "./module-utl.mjs";
5
4
  import prepareFolderLevel from "./prepare-folder-level.mjs";
6
5
  import prepareCustomLevel from "./prepare-custom-level.mjs";
7
6
  import prepareFlatLevel from "./prepare-flat-level.mjs";
8
7
  import { applyFilters } from "#graph-utl/filter-bank.mjs";
8
+ import { get } from "#utl/object-util.mjs";
9
9
 
10
10
  // not importing EOL from "node:os" so output is the same on windows and unices
11
11
  const EOL = "\n";
@@ -151,8 +151,8 @@ function pryReporterOptionsFromResults(pGranularity, pResults) {
151
151
  const lFallbackReporterOptions =
152
152
  pResults?.summary?.optionsUsed?.reporterOptions?.dot;
153
153
 
154
- // using lodash.get here because the reporter options will contain nested
155
- // properties, which it handles for us
154
+ // using a bespoke 'get' function here because the reporter options will
155
+ // contain nested properties, which it handles for us
156
156
  return get(
157
157
  pResults,
158
158
  GRANULARITY2REPORTER_OPTIONS.get(pGranularity),
@@ -1,6 +1,5 @@
1
- import get from "lodash/get.js";
2
- import has from "lodash/has.js";
3
1
  import DEFAULT_THEME from "./default-theme.mjs";
2
+ import { has, get } from "#utl/object-util.mjs";
4
3
 
5
4
  function matchesRE(pValue, pRE) {
6
5
  const lMatchResult = pValue.match && pValue.match(pRE);
@@ -14,10 +13,13 @@ function matchesCriterion(pModuleKey, pCriterion) {
14
13
 
15
14
  function moduleOrDependencyMatchesCriteria(pSchemeEntry, pModule) {
16
15
  return Object.keys(pSchemeEntry.criteria).every((pKey) => {
17
- // we use lodash.get here because in the criteria you can enter
18
- // nested keys like "rules[0].severity" : "error", and lodash.get handles
19
- // that for us
20
- const lCriterion = get(pSchemeEntry.criteria, pKey);
16
+ // the keys can have paths in them like {"rules[0].severity": "info"}
17
+ // To get the criterion treat that key as a string and not as a path
18
+ // eslint-disable-next-line security/detect-object-injection
19
+ const lCriterion = pSchemeEntry.criteria[pKey];
20
+ // we use a bespoke 'get' here because in the criteria you can enter
21
+ // nested keys like "rules[0].severity" : "error", and that function
22
+ // handles those for us
21
23
  const lModuleKey = get(pModule, pKey);
22
24
 
23
25
  if (!(lModuleKey || has(pModule, pKey))) {
@@ -13,3 +13,27 @@ export function intersects(pLeftArray, pRightArray) {
13
13
  export function uniq(pArray) {
14
14
  return [...new Set(pArray)];
15
15
  }
16
+
17
+ /**
18
+ * @param {any[]} pArray
19
+ * @param {function} pIteratee
20
+ * @returns {any[]}
21
+ */
22
+ export function uniqBy(pArray, pIteratee) {
23
+ return pArray.filter(
24
+ (pElement, pIndex, pSelf) =>
25
+ pIndex === pSelf.findIndex((pY) => pIteratee(pElement) === pIteratee(pY)),
26
+ );
27
+ }
28
+
29
+ /**
30
+ * @param {any[]} pArray
31
+ * @param {function} pComparator
32
+ * @returns {any[]}
33
+ */
34
+ export function uniqWith(pArray, pComparator) {
35
+ return pArray.filter(
36
+ (pElement, pIndex, pSelf) =>
37
+ pIndex === pSelf.findIndex((pY) => pComparator(pElement, pY)),
38
+ );
39
+ }
@@ -0,0 +1,40 @@
1
+ /* eslint-disable security/detect-object-injection */
2
+
3
+ export function get(pObject, pPath, pDefault) {
4
+ if (!pObject || !pPath) {
5
+ return pDefault;
6
+ }
7
+ // Regex explained: https://regexr.com/58j0k
8
+ const lPathArray = pPath.match(/([^[.\]])+/g);
9
+
10
+ const lReturnValue = lPathArray.reduce((pPreviousObject, pKey) => {
11
+ return pPreviousObject && pPreviousObject[pKey];
12
+ }, pObject);
13
+
14
+ if (!lReturnValue) {
15
+ return pDefault;
16
+ }
17
+ return lReturnValue;
18
+ }
19
+
20
+ export function set(pObject, pPath, pValue) {
21
+ const lPathArray = pPath.match(/([^[.\]])+/g);
22
+
23
+ lPathArray.reduce((pPreviousObject, pKey, pIndex) => {
24
+ if (pIndex === lPathArray.length - 1) {
25
+ pPreviousObject[pKey] = pValue;
26
+ } else if (!pPreviousObject[pKey]) {
27
+ pPreviousObject[pKey] = {};
28
+ }
29
+ return pPreviousObject[pKey];
30
+ }, pObject);
31
+ }
32
+
33
+ /**
34
+ * @param {any} pObject
35
+ * @param {string} pPath
36
+ * @returns {boolean}
37
+ */
38
+ export function has(pObject, pPath) {
39
+ return Boolean(get(pObject, pPath));
40
+ }