js_dependency 0.3.10 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.js_dependency.yml.sample +3 -0
- data/.rubocop_todo.yml +5 -5
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/lib/js_dependency/cli_utils/config.rb +71 -7
- data/lib/js_dependency/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a61cec11e64fc475a0fb7838b11abf8ab6a1a0d8cfab0929e475eff2fcbef6c0
|
4
|
+
data.tar.gz: 461e0b8503aec5ab25f7b3508ae420af41f72022e39a4e1388a8ae8217858ac1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2e5483e130e608b4a21741ffccf44db1f812a6096b9f4c5df419cb97029f340c9c8ba770542133d528a213720f924282e9cd72bfd6cc135606904a594c20ed1
|
7
|
+
data.tar.gz: ae67a36c93fdb56ddc5a59c6244d78b7c58f08399d72a725a6d655e945f518c2a14f517c6253dde5cf26516c1cf30a5834ac77cc752e0a67a51301c13d2576e2
|
data/.js_dependency.yml.sample
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2022-08-13
|
3
|
+
# on 2022-08-13 05:13:43 UTC using RuboCop version 1.34.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -9,12 +9,12 @@
|
|
9
9
|
# Offense count: 3
|
10
10
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
|
11
11
|
Metrics/AbcSize:
|
12
|
-
Max:
|
12
|
+
Max: 29
|
13
13
|
|
14
14
|
# Offense count: 3
|
15
15
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
|
16
16
|
Metrics/CyclomaticComplexity:
|
17
|
-
Max:
|
17
|
+
Max: 15
|
18
18
|
|
19
19
|
# Offense count: 8
|
20
20
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
@@ -29,14 +29,14 @@ Metrics/ParameterLists:
|
|
29
29
|
# Offense count: 3
|
30
30
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
|
31
31
|
Metrics/PerceivedComplexity:
|
32
|
-
Max:
|
32
|
+
Max: 15
|
33
33
|
|
34
34
|
# Offense count: 1
|
35
35
|
Style/MultilineBlockChain:
|
36
36
|
Exclude:
|
37
37
|
- 'lib/js_dependency/mermaid/root.rb'
|
38
38
|
|
39
|
-
# Offense count:
|
39
|
+
# Offense count: 8
|
40
40
|
# This cop supports safe autocorrection (--autocorrect).
|
41
41
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
42
42
|
# URISchemes: http, https
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -35,6 +35,9 @@ Configuration file is `./.js_dependency.yml`. This file includes parameters for
|
|
35
35
|
```yaml
|
36
36
|
src_path: ./src # Root folder
|
37
37
|
target_path: ./src/App.vue # Target file tha you want to analyze
|
38
|
+
target_paths: # Target files tha you want to analyze
|
39
|
+
- ./src/App1.vue
|
40
|
+
- ./src/App2.vue
|
38
41
|
child_analyze_level: 2 # Output level of child analyze
|
39
42
|
parent_analyze_level: 2 # Output level of parent analyze
|
40
43
|
name_level: 1 # Output name level
|
@@ -10,18 +10,82 @@ module JsDependency
|
|
10
10
|
# @param [Hash] args
|
11
11
|
def initialize(options, args)
|
12
12
|
@src_path = options[:src_path] || args[:src_path]
|
13
|
-
@target_paths = options[:
|
14
|
-
|
13
|
+
@target_paths = calc_target_paths(options[:target_path], options[:target_paths], args[:target_path],
|
14
|
+
args[:target_paths])
|
15
|
+
@target_path = calc_target_path(options[:target_path], options[:target_paths], args[:target_path],
|
16
|
+
args[:target_paths])
|
15
17
|
@child_analyze_level = options[:child_analyze_level] || args[:child_analyze_level] || 2
|
16
18
|
@parent_analyze_level = options[:parent_analyze_level] || args[:parent_analyze_level] || 2
|
17
19
|
@output_path = options[:output_path] || args[:output_path] || nil
|
18
20
|
@alias_paths = options[:alias_paths] || args[:alias_paths] || {}
|
19
21
|
@name_level = options[:name_level] || args[:name_level] || 1
|
20
|
-
@excludes =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
@excludes = calc_excludes(options[:excludes], args[:excludes])
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# @param [String, Array, nil] option_target_path
|
28
|
+
# @param [String, Array, nil] option_target_paths
|
29
|
+
# @param [String, Array, nil] args_target_path
|
30
|
+
# @param [String, Array, nil] args_target_paths
|
31
|
+
# @return [nil, Array]
|
32
|
+
def calc_target_paths(option_target_path, option_target_paths, args_target_path, args_target_paths)
|
33
|
+
[option_target_paths, option_target_path, args_target_paths, args_target_path].each do |obj|
|
34
|
+
return as_array(obj) if present?(obj)
|
35
|
+
end
|
36
|
+
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
# @param [String, Array, nil] option_target_path
|
41
|
+
# @param [String, Array, nil] option_target_paths
|
42
|
+
# @param [String, Array, nil] args_target_path
|
43
|
+
# @param [String, Array, nil] args_target_paths
|
44
|
+
# @return [nil, String]
|
45
|
+
def calc_target_path(option_target_path, option_target_paths, args_target_path, args_target_paths)
|
46
|
+
[option_target_path, option_target_paths, args_target_path, args_target_paths].each do |obj|
|
47
|
+
return as_string_or_first(obj) if present?(obj)
|
48
|
+
end
|
49
|
+
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
|
53
|
+
# @param [Object] option_excludes
|
54
|
+
# @param [Object] args_excludes
|
55
|
+
# @return [nil, Array]
|
56
|
+
def calc_excludes(option_excludes, args_excludes)
|
57
|
+
[option_excludes, args_excludes].each do |obj|
|
58
|
+
return as_array(obj) if present?(obj)
|
59
|
+
end
|
60
|
+
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
|
64
|
+
# @param [Array, String, nil] obj
|
65
|
+
# @return [TrueClass, FalseClass]
|
66
|
+
def present?(obj)
|
67
|
+
return false if obj.nil?
|
68
|
+
return false if obj.empty?
|
69
|
+
|
70
|
+
true
|
71
|
+
end
|
72
|
+
|
73
|
+
# @param [Array, String, nil] obj
|
74
|
+
# @return [Array, nil]
|
75
|
+
def as_array(obj)
|
76
|
+
return nil if obj.nil?
|
77
|
+
return obj if obj.is_a?(Array)
|
78
|
+
|
79
|
+
[obj]
|
80
|
+
end
|
81
|
+
|
82
|
+
# @param [Array, String, nil] obj
|
83
|
+
# @return [String, nil]
|
84
|
+
def as_string_or_first(obj)
|
85
|
+
return nil if obj.nil?
|
86
|
+
return obj if obj.is_a?(String)
|
87
|
+
|
88
|
+
return obj.first if obj.is_a?(Array)
|
25
89
|
end
|
26
90
|
end
|
27
91
|
end
|