dependency-cruiser 13.0.2 → 13.0.3

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": "13.0.2",
3
+ "version": "13.0.3",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -156,9 +156,8 @@
156
156
  "ajv": "8.12.0",
157
157
  "chalk": "5.2.0",
158
158
  "commander": "10.0.1",
159
- "enhanced-resolve": "5.14.0",
159
+ "enhanced-resolve": "5.14.1",
160
160
  "figures": "5.0.0",
161
- "get-stream": "^6.0.1",
162
161
  "glob": "10.2.6",
163
162
  "handlebars": "4.7.7",
164
163
  "ignore": "5.2.4",
@@ -174,25 +173,25 @@
174
173
  "semver-try-require": "6.2.2",
175
174
  "teamcity-service-messages": "0.1.14",
176
175
  "tsconfig-paths-webpack-plugin": "4.0.1",
177
- "watskeburt": "0.11.2",
176
+ "watskeburt": "0.11.3",
178
177
  "wrap-ansi": "8.1.0"
179
178
  },
180
179
  "devDependencies": {
181
- "@babel/core": "7.21.8",
180
+ "@babel/core": "7.22.1",
182
181
  "@babel/plugin-transform-modules-commonjs": "7.21.5",
183
182
  "@babel/preset-typescript": "7.21.5",
184
- "@swc/core": "1.3.59",
185
- "@types/lodash": "4.14.194",
186
- "@types/node": "20.2.1",
183
+ "@swc/core": "1.3.62",
184
+ "@types/lodash": "4.14.195",
185
+ "@types/node": "20.2.5",
187
186
  "@types/prompts": "2.4.4",
188
- "@typescript-eslint/eslint-plugin": "5.59.6",
189
- "@typescript-eslint/parser": "5.59.6",
187
+ "@typescript-eslint/eslint-plugin": "5.59.8",
188
+ "@typescript-eslint/parser": "5.59.8",
190
189
  "@vue/compiler-sfc": "3.3.4",
191
- "c8": "7.13.0",
190
+ "c8": "7.14.0",
192
191
  "chai": "4.3.7",
193
192
  "chai-json-schema": "1.5.1",
194
193
  "coffeescript": "2.7.0",
195
- "eslint": "8.41.0",
194
+ "eslint": "8.42.0",
196
195
  "eslint-config-moving-meadow": "4.0.2",
197
196
  "eslint-config-prettier": "8.8.0",
198
197
  "eslint-plugin-budapestian": "5.0.1",
@@ -213,7 +212,7 @@
213
212
  "shx": "0.3.4",
214
213
  "svelte": "3.59.1",
215
214
  "symlink-dir": "5.1.1",
216
- "typescript": "5.0.4",
215
+ "typescript": "5.1.3",
217
216
  "upem": "7.3.2",
218
217
  "vue-template-compiler": "2.7.14",
219
218
  "yarn": "1.22.19"
@@ -1,4 +1,3 @@
1
- import getStream from "get-stream";
2
1
  import _format from "../main/format.mjs";
3
2
  import validateFileExistence from "./utl/validate-file-existence.mjs";
4
3
  import normalizeOptions from "./normalize-cli-options.mjs";
@@ -8,7 +7,7 @@ import { getInStream, write } from "./utl/io.mjs";
8
7
  *
9
8
  * @param {string} pResultFile the name of the file with cruise results
10
9
  * @param {import("../../types/dependency-cruiser").IFormatOptions} pOptions
11
- * @returns {Number} an exitCode
10
+ * @returns {Promise<Number>} an exitCode
12
11
  */
13
12
  export default async function format(pResultFile, pOptions) {
14
13
  const lOptions = await normalizeOptions(pOptions);
@@ -17,10 +16,30 @@ export default async function format(pResultFile, pOptions) {
17
16
  validateFileExistence(pResultFile);
18
17
  }
19
18
 
20
- const lResult = await getStream(getInStream(pResultFile));
19
+ return new Promise((pResolve, pReject) => {
20
+ let lInputAsString = "";
21
+ const lInStream = getInStream(pResultFile);
21
22
 
22
- const lReportingResult = await _format(JSON.parse(lResult), lOptions);
23
+ lInStream
24
+ .on("data", (pChunk) => {
25
+ lInputAsString += pChunk;
26
+ })
27
+ .on(
28
+ "error",
29
+ /* c8 ignore start */
30
+ (pError) => {
31
+ pReject(pError);
32
+ }
33
+ /* c8 ignore stop */
34
+ )
35
+ .on("end", async () => {
36
+ const lReportingResult = await _format(
37
+ JSON.parse(lInputAsString),
38
+ lOptions
39
+ );
23
40
 
24
- write(lOptions.outputTo, lReportingResult.output);
25
- return lReportingResult.exitCode;
41
+ write(lOptions.outputTo, lReportingResult.output);
42
+ pResolve(lReportingResult.exitCode);
43
+ });
44
+ });
26
45
  }
@@ -2,6 +2,7 @@
2
2
  import tryImport from "semver-try-require";
3
3
  import meta from "../../meta.js";
4
4
 
5
+ /** @type {import("typescript")} */
5
6
  const typescript = await tryImport(
6
7
  "typescript",
7
8
  meta.supportedTranspilers.typescript
@@ -120,13 +121,26 @@ function firstArgumentIsAString(pASTNode) {
120
121
  }
121
122
 
122
123
  function isRequireCallExpression(pASTNode) {
123
- return (
124
+ if (
124
125
  typescript.SyntaxKind[pASTNode.kind] === "CallExpression" &&
125
- pASTNode.expression &&
126
- typescript.SyntaxKind[pASTNode.expression.originalKeywordKind] ===
127
- "RequireKeyword" &&
128
- firstArgumentIsAString(pASTNode)
129
- );
126
+ pASTNode.expression
127
+ ) {
128
+ /*
129
+ * from typescript 5.0.0 the `originalKeywordKind` attribute is deprecated
130
+ * and from 5.2.0 it will be gone. However, in typescript < 5.0.0 (still used
131
+ * heavily IRL) it's the only way to get it - hence this test for the
132
+ * existence of the * identifierToKeywordKind function to remain backwards
133
+ * compatible
134
+ */
135
+ const lSyntaxKind = typescript.identifierToKeywordKind
136
+ ? typescript.SyntaxKind[
137
+ typescript.identifierToKeywordKind(pASTNode.expression)
138
+ ]
139
+ : /* c8 ignore next 1 */
140
+ typescript.SyntaxKind[pASTNode.expression.originalKeywordKind];
141
+ return lSyntaxKind === "RequireKeyword" && firstArgumentIsAString(pASTNode);
142
+ }
143
+ return false;
130
144
  }
131
145
 
132
146
  function isSingleExoticRequire(pASTNode, pString) {
package/src/meta.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* generated - don't edit */
2
2
 
3
3
  module.exports = {
4
- version: "13.0.2",
4
+ version: "13.0.3",
5
5
  engines: {
6
6
  node: "^16.14||>=18",
7
7
  },