detective-vue2 2.3.0 → 3.0.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 +10 -2
- package/index.js +16 -26
- package/package.json +15 -46
package/README.md
CHANGED
|
@@ -12,9 +12,11 @@ npm install detective-vue2 typescript
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
+
### ESM
|
|
16
|
+
|
|
15
17
|
```js
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
import fs from 'node:fs';
|
|
19
|
+
import detective from 'detective-vue2';
|
|
18
20
|
|
|
19
21
|
const content = fs.readFileSync('myfile.vue', 'utf8');
|
|
20
22
|
|
|
@@ -22,6 +24,12 @@ const content = fs.readFileSync('myfile.vue', 'utf8');
|
|
|
22
24
|
const dependencies = detective(content);
|
|
23
25
|
```
|
|
24
26
|
|
|
27
|
+
### CommonJS
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
const { default: detective } = require('detective-vue2');
|
|
31
|
+
```
|
|
32
|
+
|
|
25
33
|
## License
|
|
26
34
|
|
|
27
35
|
[MIT](LICENSE)
|
package/index.js
CHANGED
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const detectiveSass = require('detective-sass');
|
|
9
|
-
const detectiveLess = require('@dependents/detective-less');
|
|
1
|
+
import { parse } from '@vue/compiler-sfc';
|
|
2
|
+
import detectiveTypeScript from 'detective-typescript';
|
|
3
|
+
import detectiveEs6 from 'detective-es6';
|
|
4
|
+
import detectiveScss from 'detective-scss';
|
|
5
|
+
import detectiveStylus from 'detective-stylus';
|
|
6
|
+
import detectiveSass from 'detective-sass';
|
|
7
|
+
import detectiveLess from '@dependents/detective-less';
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* Extracts the dependencies of the supplied Vue module
|
|
13
11
|
*/
|
|
14
|
-
function
|
|
12
|
+
export default function detective(content, options) {
|
|
15
13
|
if (content === undefined) throw new Error('content not given');
|
|
16
14
|
if (typeof content !== 'string') throw new Error('content is not a string');
|
|
17
15
|
|
|
18
|
-
const
|
|
19
|
-
const { styles, script, scriptSetup } = result.descriptor;
|
|
20
|
-
|
|
16
|
+
const { styles, script, scriptSetup } = parse(content, { sourceMap: false }).descriptor;
|
|
21
17
|
const dependencies = [];
|
|
22
18
|
|
|
23
19
|
for (const usedScript of [script, scriptSetup]) {
|
|
24
|
-
if (usedScript
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
if (!usedScript || !usedScript.content) continue;
|
|
21
|
+
|
|
22
|
+
if (usedScript.attrs && usedScript.attrs.lang === 'ts') {
|
|
23
|
+
dependencies.push(...detectiveTypeScript(usedScript.content, options));
|
|
24
|
+
} else {
|
|
25
|
+
dependencies.push(...detectiveEs6(usedScript.content, options));
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
28
|
|
|
@@ -36,34 +32,28 @@ function detectiveVue(content, options) {
|
|
|
36
32
|
switch (style.attrs.lang) {
|
|
37
33
|
case 'scss': {
|
|
38
34
|
dependencies.push(...detectiveScss(style.content, options));
|
|
39
|
-
|
|
40
35
|
break;
|
|
41
36
|
}
|
|
42
37
|
|
|
43
38
|
case 'stylus': {
|
|
44
39
|
dependencies.push(...detectiveStylus(style.content, options));
|
|
45
|
-
|
|
46
40
|
break;
|
|
47
41
|
}
|
|
48
42
|
|
|
49
43
|
case 'sass': {
|
|
50
44
|
dependencies.push(...detectiveSass(style.content, options));
|
|
51
|
-
|
|
52
45
|
break;
|
|
53
46
|
}
|
|
54
47
|
|
|
55
48
|
case 'less': {
|
|
56
49
|
dependencies.push(...detectiveLess(style.content, options));
|
|
57
|
-
|
|
58
50
|
break;
|
|
59
51
|
}
|
|
60
52
|
|
|
61
53
|
default:
|
|
62
|
-
|
|
54
|
+
// css has no deps
|
|
63
55
|
}
|
|
64
56
|
}
|
|
65
57
|
|
|
66
58
|
return dependencies;
|
|
67
59
|
}
|
|
68
|
-
|
|
69
|
-
module.exports = detectiveVue;
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "detective-vue2",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"author": "Havunen <sampo.kivisto@live.fi>",
|
|
5
5
|
"description": "Get the dependencies of a Vue module",
|
|
6
|
-
"
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js"
|
|
9
|
+
},
|
|
7
10
|
"files": [
|
|
8
11
|
"index.js"
|
|
9
12
|
],
|
|
@@ -33,58 +36,24 @@
|
|
|
33
36
|
},
|
|
34
37
|
"homepage": "https://github.com/dependents/detective-vue2",
|
|
35
38
|
"engines": {
|
|
36
|
-
"node": ">=
|
|
39
|
+
"node": ">=20.19.0 || >=22.12.0"
|
|
37
40
|
},
|
|
38
41
|
"peerDependencies": {
|
|
39
42
|
"typescript": "^5.4.4 || ^6.0.2"
|
|
40
43
|
},
|
|
41
44
|
"dependencies": {
|
|
42
|
-
"@dependents/detective-less": "^
|
|
43
|
-
"@vue/compiler-sfc": "^3.5.
|
|
44
|
-
"detective-es6": "^
|
|
45
|
-
"detective-sass": "^
|
|
46
|
-
"detective-scss": "^
|
|
47
|
-
"detective-stylus": "^
|
|
48
|
-
"detective-typescript": "^
|
|
45
|
+
"@dependents/detective-less": "^6.0.0",
|
|
46
|
+
"@vue/compiler-sfc": "^3.5.34",
|
|
47
|
+
"detective-es6": "^6.0.0",
|
|
48
|
+
"detective-sass": "^7.0.0",
|
|
49
|
+
"detective-scss": "^6.0.0",
|
|
50
|
+
"detective-stylus": "^6.0.0",
|
|
51
|
+
"detective-typescript": "^15.0.0"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
|
-
"c8": "^
|
|
54
|
+
"c8": "^11.0.0",
|
|
52
55
|
"typescript": "^6.0.3",
|
|
53
56
|
"uvu": "^0.5.6",
|
|
54
|
-
"xo": "^0.
|
|
55
|
-
},
|
|
56
|
-
"xo": {
|
|
57
|
-
"space": true,
|
|
58
|
-
"ignores": [
|
|
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
|
-
"space-before-function-paren": [
|
|
81
|
-
"error",
|
|
82
|
-
"never"
|
|
83
|
-
],
|
|
84
|
-
"unicorn/prefer-module": "off",
|
|
85
|
-
"unicorn/prefer-node-protocol": "off",
|
|
86
|
-
"unicorn/prefer-top-level-await": "off",
|
|
87
|
-
"unicorn/prevent-abbreviations": "off"
|
|
88
|
-
}
|
|
57
|
+
"xo": "^2.0.2"
|
|
89
58
|
}
|
|
90
59
|
}
|