@depup/detective-typescript 14.0.0-depup.0 → 15.0.1-depup.12
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/README.md +3 -3
- package/changes.json +3 -3
- package/index.js +46 -57
- package/package.json +27 -60
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ npm install @depup/detective-typescript
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [detective-typescript](https://www.npmjs.com/package/detective-typescript) @
|
|
17
|
-
| Processed | 2026-
|
|
16
|
+
| Original | [detective-typescript](https://www.npmjs.com/package/detective-typescript) @ 15.0.1 |
|
|
17
|
+
| Processed | 2026-07-21 |
|
|
18
18
|
| Smoke test | passed |
|
|
19
19
|
| Deps updated | 1 |
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ npm install @depup/detective-typescript
|
|
|
22
22
|
|
|
23
23
|
| Dependency | From | To |
|
|
24
24
|
|------------|------|-----|
|
|
25
|
-
| @typescript-eslint/typescript-estree | ^8.
|
|
25
|
+
| @typescript-eslint/typescript-estree | ^8.62.1 | ^8.65.0 |
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
package/changes.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bumped": {
|
|
3
3
|
"@typescript-eslint/typescript-estree": {
|
|
4
|
-
"from": "^8.
|
|
5
|
-
"to": "^8.
|
|
4
|
+
"from": "^8.62.1",
|
|
5
|
+
"to": "^8.65.0"
|
|
6
6
|
}
|
|
7
7
|
},
|
|
8
|
-
"timestamp": "2026-
|
|
8
|
+
"timestamp": "2026-07-21T17:13:36.796Z",
|
|
9
9
|
"totalUpdated": 1
|
|
10
10
|
}
|
package/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const types = require('ast-module-types');
|
|
5
|
-
const Walker = require('node-source-walk');
|
|
1
|
+
import parser from '@typescript-eslint/typescript-estree';
|
|
2
|
+
import { isRequire, isPlainRequire, isMainScopedRequire } from 'ast-module-types';
|
|
3
|
+
import Walker from 'node-source-walk';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Extracts the dependencies of the supplied TypeScript module
|
|
@@ -10,21 +8,25 @@ const Walker = require('node-source-walk');
|
|
|
10
8
|
* @param {String|Object} src - File's content or AST
|
|
11
9
|
* @return {String[]}
|
|
12
10
|
*/
|
|
13
|
-
|
|
11
|
+
export default function detective(src, options = {}) {
|
|
14
12
|
if (src === undefined) throw new Error('src not given');
|
|
15
13
|
if (src === '') return [];
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
// Destructure detective-specific options; the rest are forwarded to the walker/parser.
|
|
16
|
+
const {
|
|
17
|
+
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#import-types
|
|
18
|
+
// https://www.typescriptlang.org/v2/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export
|
|
19
|
+
skipTypeImports: skipTypeImportsRaw,
|
|
20
|
+
mixedImports: mixedImportsRaw,
|
|
21
|
+
skipAsyncImports,
|
|
22
|
+
onFile,
|
|
23
|
+
onAfterFile,
|
|
24
|
+
...walkerOptions
|
|
25
|
+
} = options;
|
|
26
|
+
|
|
27
|
+
const skipTypeImports = Boolean(skipTypeImportsRaw);
|
|
28
|
+
const mixedImports = Boolean(mixedImportsRaw);
|
|
29
|
+
walkerOptions.parser = parser;
|
|
28
30
|
|
|
29
31
|
const walker = new Walker(walkerOptions);
|
|
30
32
|
const dependencies = [];
|
|
@@ -33,8 +35,8 @@ module.exports = (src, options = {}) => {
|
|
|
33
35
|
// then reuse that AST below in our walker walk.
|
|
34
36
|
const ast = typeof src === 'string' ? walker.parse(src) : src;
|
|
35
37
|
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
+
if (onFile) {
|
|
39
|
+
onFile({
|
|
38
40
|
options,
|
|
39
41
|
src,
|
|
40
42
|
ast,
|
|
@@ -42,10 +44,10 @@ module.exports = (src, options = {}) => {
|
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
walker.walk(
|
|
47
|
+
walker.walk(ast, node => {
|
|
46
48
|
switch (node.type) {
|
|
47
49
|
case 'ImportExpression': {
|
|
48
|
-
if (!
|
|
50
|
+
if (!skipAsyncImports && node.source?.value) {
|
|
49
51
|
dependencies.push(node.source.value);
|
|
50
52
|
}
|
|
51
53
|
|
|
@@ -53,7 +55,7 @@ module.exports = (src, options = {}) => {
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
case 'ImportDeclaration': {
|
|
56
|
-
if (skipTypeImports &&
|
|
58
|
+
if (skipTypeImports && isTypeNode(node, 'importKind')) {
|
|
57
59
|
break;
|
|
58
60
|
}
|
|
59
61
|
|
|
@@ -66,7 +68,7 @@ module.exports = (src, options = {}) => {
|
|
|
66
68
|
|
|
67
69
|
case 'ExportNamedDeclaration':
|
|
68
70
|
case 'ExportAllDeclaration': {
|
|
69
|
-
if (skipTypeImports &&
|
|
71
|
+
if (skipTypeImports && isTypeNode(node, 'exportKind')) {
|
|
70
72
|
break;
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -86,29 +88,18 @@ module.exports = (src, options = {}) => {
|
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
case 'TSImportType': {
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
+
if (skipTypeImports) break;
|
|
92
|
+
|
|
93
|
+
if (node.source?.value) {
|
|
94
|
+
dependencies.push(node.source.value);
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
break;
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
case 'CallExpression': {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
node.arguments.length === 0) {
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (types.isPlainRequire(node)) {
|
|
104
|
-
const result = extractDependencyFromRequire(node);
|
|
105
|
-
if (result) {
|
|
106
|
-
dependencies.push(result);
|
|
107
|
-
}
|
|
108
|
-
} else if (types.isMainScopedRequire(node)) {
|
|
109
|
-
dependencies.push(extractDependencyFromMainRequire(node));
|
|
110
|
-
}
|
|
111
|
-
|
|
101
|
+
const dep = handleCallExpression(node, mixedImports);
|
|
102
|
+
if (dep) dependencies.push(dep);
|
|
112
103
|
break;
|
|
113
104
|
}
|
|
114
105
|
|
|
@@ -117,8 +108,8 @@ module.exports = (src, options = {}) => {
|
|
|
117
108
|
}
|
|
118
109
|
});
|
|
119
110
|
|
|
120
|
-
if (
|
|
121
|
-
|
|
111
|
+
if (onAfterFile) {
|
|
112
|
+
onAfterFile({
|
|
122
113
|
options,
|
|
123
114
|
src,
|
|
124
115
|
ast,
|
|
@@ -128,10 +119,10 @@ module.exports = (src, options = {}) => {
|
|
|
128
119
|
}
|
|
129
120
|
|
|
130
121
|
return dependencies;
|
|
131
|
-
}
|
|
122
|
+
}
|
|
132
123
|
|
|
133
|
-
|
|
134
|
-
return
|
|
124
|
+
detective.tsx = function(src, options = {}) {
|
|
125
|
+
return detective(src, { ...options, jsx: true });
|
|
135
126
|
};
|
|
136
127
|
|
|
137
128
|
function extractDependencyFromRequire(node) {
|
|
@@ -148,22 +139,20 @@ function extractDependencyFromMainRequire(node) {
|
|
|
148
139
|
return node.arguments[0].value;
|
|
149
140
|
}
|
|
150
141
|
|
|
151
|
-
function
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
142
|
+
function isTypeNode(node, kind) {
|
|
143
|
+
return node[kind] === 'type' || (node.specifiers?.length > 0 && node.specifiers.every(n => n[kind] === 'type'));
|
|
144
|
+
}
|
|
155
145
|
|
|
156
|
-
|
|
157
|
-
|
|
146
|
+
function handleCallExpression(node, mixedImports) {
|
|
147
|
+
if (!mixedImports || !isRequire(node) || !node.arguments || node.arguments.length === 0) {
|
|
148
|
+
return;
|
|
158
149
|
}
|
|
159
|
-
}
|
|
160
150
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return true;
|
|
151
|
+
if (isPlainRequire(node)) {
|
|
152
|
+
return extractDependencyFromRequire(node);
|
|
164
153
|
}
|
|
165
154
|
|
|
166
|
-
if (node
|
|
167
|
-
return
|
|
155
|
+
if (isMainScopedRequire(node)) {
|
|
156
|
+
return extractDependencyFromMainRequire(node);
|
|
168
157
|
}
|
|
169
158
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/detective-typescript",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.1-depup.12",
|
|
4
4
|
"author": "Patrik Henningsson <patrik.henningsson@gmail.com>",
|
|
5
|
-
"description": "
|
|
6
|
-
"
|
|
5
|
+
"description": "Get the dependencies of a TypeScript module (with updated dependencies)",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js"
|
|
9
|
+
},
|
|
7
10
|
"files": [
|
|
8
11
|
"index.js",
|
|
9
12
|
"changes.json",
|
|
@@ -12,20 +15,21 @@
|
|
|
12
15
|
"scripts": {
|
|
13
16
|
"lint": "xo",
|
|
14
17
|
"fix": "xo --fix",
|
|
15
|
-
"
|
|
16
|
-
"test": "npm run lint &&
|
|
17
|
-
"test:ci": "
|
|
18
|
-
"watch": "npm run mocha -- -w"
|
|
18
|
+
"vitest": "vitest",
|
|
19
|
+
"test": "npm run lint && vitest run",
|
|
20
|
+
"test:ci": "vitest run --coverage"
|
|
19
21
|
},
|
|
20
22
|
"repository": {
|
|
21
23
|
"type": "git",
|
|
22
24
|
"url": "git+https://github.com/dependents/detective-typescript.git"
|
|
23
25
|
},
|
|
24
26
|
"keywords": [
|
|
25
|
-
"depup",
|
|
26
|
-
"dependency-bumped",
|
|
27
|
-
"updated-deps",
|
|
28
27
|
"detective-typescript",
|
|
28
|
+
"depup",
|
|
29
|
+
"updated-dependencies",
|
|
30
|
+
"security",
|
|
31
|
+
"latest",
|
|
32
|
+
"patched",
|
|
29
33
|
"detective",
|
|
30
34
|
"typescript",
|
|
31
35
|
"dependencies",
|
|
@@ -34,72 +38,35 @@
|
|
|
34
38
|
"import"
|
|
35
39
|
],
|
|
36
40
|
"engines": {
|
|
37
|
-
"node": ">=
|
|
41
|
+
"node": ">=20.19.0 || >=22.12.0"
|
|
38
42
|
},
|
|
39
43
|
"license": "MIT",
|
|
40
44
|
"homepage": "https://github.com/dependents/detective-typescript",
|
|
41
45
|
"peerDependencies": {
|
|
42
|
-
"typescript": "^5.4.4"
|
|
46
|
+
"typescript": "^5.4.4 || ^6.0.2"
|
|
43
47
|
},
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
46
|
-
"ast-module-types": "^
|
|
47
|
-
"node-source-walk": "^
|
|
49
|
+
"@typescript-eslint/typescript-estree": "^8.65.0",
|
|
50
|
+
"ast-module-types": "^7.0.0",
|
|
51
|
+
"node-source-walk": "^8.0.0"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"xo": "^0.
|
|
54
|
-
},
|
|
55
|
-
"xo": {
|
|
56
|
-
"space": true,
|
|
57
|
-
"ignores": [
|
|
58
|
-
"index.d.ts",
|
|
59
|
-
"test/fixtures/*"
|
|
60
|
-
],
|
|
61
|
-
"rules": {
|
|
62
|
-
"arrow-body-style": "off",
|
|
63
|
-
"capitalized-comments": "off",
|
|
64
|
-
"comma-dangle": [
|
|
65
|
-
"error",
|
|
66
|
-
"never"
|
|
67
|
-
],
|
|
68
|
-
"curly": [
|
|
69
|
-
"error",
|
|
70
|
-
"multi-line"
|
|
71
|
-
],
|
|
72
|
-
"operator-linebreak": [
|
|
73
|
-
"error",
|
|
74
|
-
"after"
|
|
75
|
-
],
|
|
76
|
-
"object-curly-spacing": [
|
|
77
|
-
"error",
|
|
78
|
-
"always"
|
|
79
|
-
],
|
|
80
|
-
"prefer-template": "error",
|
|
81
|
-
"space-before-function-paren": [
|
|
82
|
-
"error",
|
|
83
|
-
"never"
|
|
84
|
-
],
|
|
85
|
-
"unicorn/no-anonymous-default-export": "off",
|
|
86
|
-
"unicorn/prefer-module": "off",
|
|
87
|
-
"unicorn/prefer-node-protocol": "off",
|
|
88
|
-
"unicorn/prefer-top-level-await": "off",
|
|
89
|
-
"unicorn/prevent-abbreviations": "off"
|
|
90
|
-
}
|
|
54
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
55
|
+
"typescript": "^6.0.3",
|
|
56
|
+
"vitest": "^4.1.9",
|
|
57
|
+
"xo": "^2.0.2"
|
|
91
58
|
},
|
|
92
59
|
"depup": {
|
|
93
60
|
"changes": {
|
|
94
61
|
"@typescript-eslint/typescript-estree": {
|
|
95
|
-
"from": "^8.
|
|
96
|
-
"to": "^8.
|
|
62
|
+
"from": "^8.62.1",
|
|
63
|
+
"to": "^8.65.0"
|
|
97
64
|
}
|
|
98
65
|
},
|
|
99
66
|
"depsUpdated": 1,
|
|
100
67
|
"originalPackage": "detective-typescript",
|
|
101
|
-
"originalVersion": "
|
|
102
|
-
"processedAt": "2026-
|
|
68
|
+
"originalVersion": "15.0.1",
|
|
69
|
+
"processedAt": "2026-07-21T17:13:50.255Z",
|
|
103
70
|
"smokeTest": "passed"
|
|
104
71
|
}
|
|
105
72
|
}
|