detective-vue2 2.0.2 → 2.1.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/index.js +25 -15
- package/package.json +6 -5
package/index.js
CHANGED
|
@@ -6,25 +6,24 @@ const detectiveEs6 = require('detective-es6');
|
|
|
6
6
|
const detectiveScss = require('detective-scss');
|
|
7
7
|
const detectiveStylus = require('detective-stylus');
|
|
8
8
|
const detectiveSass = require('detective-sass');
|
|
9
|
+
const detectiveLess = require('@dependents/detective-less');
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
* Extracts the dependencies of the supplied Vue module
|
|
12
|
-
*/
|
|
13
|
-
module.exports = function(content, options) {
|
|
11
|
+
function detectiveVue(content, options) {
|
|
14
12
|
if (content === undefined) throw new Error('content not given');
|
|
15
13
|
if (typeof content !== 'string') throw new Error('content is not a string');
|
|
16
14
|
|
|
17
15
|
const result = compiler.parse(content, { sourceMap: false });
|
|
18
16
|
const { styles, script, scriptSetup } = result.descriptor;
|
|
19
|
-
const usedScript = script || scriptSetup;
|
|
20
17
|
|
|
21
18
|
const dependencies = [];
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
if (usedScript
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
for (const usedScript of [script, scriptSetup]) {
|
|
21
|
+
if (usedScript?.content) {
|
|
22
|
+
if (usedScript.attrs?.lang === 'ts') {
|
|
23
|
+
dependencies.push(...detectiveTypeScript(usedScript.content, options));
|
|
24
|
+
} else {
|
|
25
|
+
dependencies.push(...detectiveEs6(usedScript.content, options));
|
|
26
|
+
}
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
|
|
@@ -33,27 +32,38 @@ module.exports = function(content, options) {
|
|
|
33
32
|
for (const style of styles) {
|
|
34
33
|
switch (style.attrs.lang) {
|
|
35
34
|
case 'scss': {
|
|
36
|
-
dependencies.push(...detectiveScss(style.content));
|
|
35
|
+
dependencies.push(...detectiveScss(style.content, options));
|
|
37
36
|
|
|
38
37
|
break;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
case 'stylus': {
|
|
42
|
-
dependencies.push(...detectiveStylus(style.content));
|
|
41
|
+
dependencies.push(...detectiveStylus(style.content, options));
|
|
43
42
|
|
|
44
43
|
break;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
case 'sass': {
|
|
48
|
-
dependencies.push(...detectiveSass(style.content));
|
|
47
|
+
dependencies.push(...detectiveSass(style.content, options));
|
|
48
|
+
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
case 'less': {
|
|
53
|
+
dependencies.push(...detectiveLess(style.content, options));
|
|
49
54
|
|
|
50
55
|
break;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
default:
|
|
54
|
-
|
|
59
|
+
// css has no deps
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
return dependencies;
|
|
59
|
-
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Extracts the dependencies of the supplied Vue module
|
|
68
|
+
*/
|
|
69
|
+
module.exports = detectiveVue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "detective-vue2",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"author": "Havunen <sampo.kivisto@live.fi>",
|
|
5
5
|
"description": "Get the dependencies of a Vue module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"typescript": "^5.4.4"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@
|
|
42
|
+
"@dependents/detective-less": "^5.0.0",
|
|
43
|
+
"@vue/compiler-sfc": "^3.5.12",
|
|
43
44
|
"detective-es6": "^5.0.0",
|
|
44
45
|
"detective-sass": "^6.0.0",
|
|
45
46
|
"detective-scss": "^5.0.0",
|
|
@@ -47,9 +48,9 @@
|
|
|
47
48
|
"detective-typescript": "^13.0.0"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"c8": "^
|
|
51
|
-
"mocha": "^10.
|
|
52
|
-
"xo": "^0.
|
|
51
|
+
"c8": "^10.1.2",
|
|
52
|
+
"mocha": "^10.7.3",
|
|
53
|
+
"xo": "^0.59.3"
|
|
53
54
|
},
|
|
54
55
|
"xo": {
|
|
55
56
|
"space": true,
|