@depup/detective-typescript 14.0.0-depup.0
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 +31 -0
- package/changes.json +10 -0
- package/index.js +169 -0
- package/package.json +105 -0
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @depup/detective-typescript
|
|
2
|
+
|
|
3
|
+
> Dependency-bumped version of [detective-typescript](https://www.npmjs.com/package/detective-typescript)
|
|
4
|
+
|
|
5
|
+
Generated by [DepUp](https://github.com/depup/npm) -- all production
|
|
6
|
+
dependencies bumped to latest versions.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @depup/detective-typescript
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
| Field | Value |
|
|
15
|
+
|-------|-------|
|
|
16
|
+
| Original | [detective-typescript](https://www.npmjs.com/package/detective-typescript) @ 14.0.0 |
|
|
17
|
+
| Processed | 2026-03-17 |
|
|
18
|
+
| Smoke test | passed |
|
|
19
|
+
| Deps updated | 1 |
|
|
20
|
+
|
|
21
|
+
## Dependency Changes
|
|
22
|
+
|
|
23
|
+
| Dependency | From | To |
|
|
24
|
+
|------------|------|-----|
|
|
25
|
+
| @typescript-eslint/typescript-estree | ^8.23.0 | ^8.57.1 |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
Source: https://github.com/depup/npm | Original: https://www.npmjs.com/package/detective-typescript
|
|
30
|
+
|
|
31
|
+
License inherited from the original package.
|
package/changes.json
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const parser = require('@typescript-eslint/typescript-estree');
|
|
4
|
+
const types = require('ast-module-types');
|
|
5
|
+
const Walker = require('node-source-walk');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Extracts the dependencies of the supplied TypeScript module
|
|
9
|
+
*
|
|
10
|
+
* @param {String|Object} src - File's content or AST
|
|
11
|
+
* @return {String[]}
|
|
12
|
+
*/
|
|
13
|
+
module.exports = (src, options = {}) => {
|
|
14
|
+
if (src === undefined) throw new Error('src not given');
|
|
15
|
+
if (src === '') return [];
|
|
16
|
+
|
|
17
|
+
const walkerOptions = { ...options, parser };
|
|
18
|
+
|
|
19
|
+
// Determine whether to skip "type-only" imports
|
|
20
|
+
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#import-types
|
|
21
|
+
// https://www.typescriptlang.org/v2/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export
|
|
22
|
+
const skipTypeImports = Boolean(options.skipTypeImports);
|
|
23
|
+
// Remove skipTypeImports option, as this option may not be recognized by the walker/parser
|
|
24
|
+
delete walkerOptions.skipTypeImports;
|
|
25
|
+
|
|
26
|
+
const mixedImports = Boolean(options.mixedImports);
|
|
27
|
+
delete walkerOptions.mixedImports;
|
|
28
|
+
|
|
29
|
+
const walker = new Walker(walkerOptions);
|
|
30
|
+
const dependencies = [];
|
|
31
|
+
|
|
32
|
+
// Pre-parse the source to get the AST to pass to `onFile`,
|
|
33
|
+
// then reuse that AST below in our walker walk.
|
|
34
|
+
const ast = typeof src === 'string' ? walker.parse(src) : src;
|
|
35
|
+
|
|
36
|
+
if (options.onFile) {
|
|
37
|
+
options.onFile({
|
|
38
|
+
options,
|
|
39
|
+
src,
|
|
40
|
+
ast,
|
|
41
|
+
walker
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
walker.walk(src, node => {
|
|
46
|
+
switch (node.type) {
|
|
47
|
+
case 'ImportExpression': {
|
|
48
|
+
if (!options.skipAsyncImports && node.source?.value) {
|
|
49
|
+
dependencies.push(node.source.value);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
case 'ImportDeclaration': {
|
|
56
|
+
if (skipTypeImports && isTypeImports(node)) {
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (node.source?.value) {
|
|
61
|
+
dependencies.push(node.source.value);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
case 'ExportNamedDeclaration':
|
|
68
|
+
case 'ExportAllDeclaration': {
|
|
69
|
+
if (skipTypeImports && isTypeExports(node)) {
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (node.source?.value) {
|
|
74
|
+
dependencies.push(node.source.value);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
case 'TSExternalModuleReference': {
|
|
81
|
+
if (node.expression?.value) {
|
|
82
|
+
dependencies.push(node.expression.value);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
case 'TSImportType': {
|
|
89
|
+
if (!skipTypeImports && node.argument.type === 'TSLiteralType') {
|
|
90
|
+
dependencies.push(node.argument.literal.value);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
case 'CallExpression': {
|
|
97
|
+
if (!mixedImports || !types.isRequire(node) ||
|
|
98
|
+
!node.arguments ||
|
|
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
|
+
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
default:
|
|
116
|
+
// nothing
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
if (options.onAfterFile) {
|
|
121
|
+
options.onAfterFile({
|
|
122
|
+
options,
|
|
123
|
+
src,
|
|
124
|
+
ast,
|
|
125
|
+
walker,
|
|
126
|
+
dependencies
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return dependencies;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
module.exports.tsx = (src, options = {}) => {
|
|
134
|
+
return module.exports(src, { ...options, jsx: true });
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
function extractDependencyFromRequire(node) {
|
|
138
|
+
if (['Literal', 'StringLiteral'].includes(node.arguments[0].type)) {
|
|
139
|
+
return node.arguments[0].value;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (node.arguments[0].type === 'TemplateLiteral') {
|
|
143
|
+
return node.arguments[0].quasis[0].value.raw;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function extractDependencyFromMainRequire(node) {
|
|
148
|
+
return node.arguments[0].value;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function isTypeImports(node) {
|
|
152
|
+
if (node.importKind === 'type') {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (node.specifiers?.length && node.specifiers?.every(n => n.importKind === 'type')) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function isTypeExports(node) {
|
|
162
|
+
if (node.exportKind === 'type') {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (node.specifiers?.length && node.specifiers?.every(n => n.exportKind === 'type')) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@depup/detective-typescript",
|
|
3
|
+
"version": "14.0.0-depup.0",
|
|
4
|
+
"author": "Patrik Henningsson <patrik.henningsson@gmail.com>",
|
|
5
|
+
"description": "[DepUp] Get the dependencies of a TypeScript module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.js",
|
|
9
|
+
"changes.json",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"lint": "xo",
|
|
14
|
+
"fix": "xo --fix",
|
|
15
|
+
"mocha": "mocha",
|
|
16
|
+
"test": "npm run lint && npm run mocha",
|
|
17
|
+
"test:ci": "c8 npm run mocha",
|
|
18
|
+
"watch": "npm run mocha -- -w"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/dependents/detective-typescript.git"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"depup",
|
|
26
|
+
"dependency-bumped",
|
|
27
|
+
"updated-deps",
|
|
28
|
+
"detective-typescript",
|
|
29
|
+
"detective",
|
|
30
|
+
"typescript",
|
|
31
|
+
"dependencies",
|
|
32
|
+
"module",
|
|
33
|
+
"ast",
|
|
34
|
+
"import"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
},
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"homepage": "https://github.com/dependents/detective-typescript",
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"typescript": "^5.4.4"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@typescript-eslint/typescript-estree": "^8.57.1",
|
|
46
|
+
"ast-module-types": "^6.0.1",
|
|
47
|
+
"node-source-walk": "^7.0.1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"c8": "^10.1.3",
|
|
51
|
+
"mocha": "^11.1.0",
|
|
52
|
+
"typescript": "^5.7.3",
|
|
53
|
+
"xo": "^0.60.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
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"depup": {
|
|
93
|
+
"changes": {
|
|
94
|
+
"@typescript-eslint/typescript-estree": {
|
|
95
|
+
"from": "^8.23.0",
|
|
96
|
+
"to": "^8.57.1"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"depsUpdated": 1,
|
|
100
|
+
"originalPackage": "detective-typescript",
|
|
101
|
+
"originalVersion": "14.0.0",
|
|
102
|
+
"processedAt": "2026-03-17T16:35:42.943Z",
|
|
103
|
+
"smokeTest": "passed"
|
|
104
|
+
}
|
|
105
|
+
}
|