js_dependency 0.2.1 → 0.2.3.1
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.
- checksums.yaml +4 -4
- data/.js_dependency.yml.sample +3 -0
- data/.rubocop_todo.yml +12 -12
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/lib/js_dependency/cli.rb +27 -3
- data/lib/js_dependency/extract_import_path.rb +2 -2
- data/lib/js_dependency/version.rb +1 -1
- data/lib/js_dependency.rb +19 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a59fced735fccc952d4f31d5dc27e41637ef5ee67bc5f5b7eb8038f5458808c
|
4
|
+
data.tar.gz: b4e713344b1a58d6dac1143068a20cf1e43bad0158c50c4ef28c1e8cd0b7ddc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2432b1e03352673908567cfc7f0ec5798bae146201db548c48899b1601e6d79680a3bef33daec2b82fa00bc541ff0b099757d65ded91f9801f026dcc5d52a56
|
7
|
+
data.tar.gz: 9f952a5dc433c9e687c12505dbb47136cbf8da671f5981cf008d1f002d282c3195f14976a94a911364c581adc55f36c68cb1e0d0459961328a49fa44b5e8bc4f
|
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-07-
|
3
|
+
# on 2022-07-20 23:10:21 UTC using RuboCop version 1.31.2.
|
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,32 +9,32 @@
|
|
9
9
|
# Offense count: 6
|
10
10
|
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
11
11
|
Metrics/AbcSize:
|
12
|
-
Max:
|
12
|
+
Max: 37
|
13
13
|
|
14
|
-
# Offense count:
|
14
|
+
# Offense count: 6
|
15
15
|
# Configuration parameters: IgnoredMethods.
|
16
16
|
Metrics/CyclomaticComplexity:
|
17
|
-
Max:
|
17
|
+
Max: 15
|
18
18
|
|
19
19
|
# Offense count: 8
|
20
20
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
21
21
|
Metrics/MethodLength:
|
22
|
-
Max:
|
22
|
+
Max: 26
|
23
23
|
|
24
24
|
# Offense count: 1
|
25
25
|
# Configuration parameters: CountComments, CountAsOne.
|
26
26
|
Metrics/ModuleLength:
|
27
|
-
Max:
|
27
|
+
Max: 114
|
28
28
|
|
29
|
-
# Offense count:
|
29
|
+
# Offense count: 3
|
30
30
|
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
|
31
31
|
Metrics/ParameterLists:
|
32
|
-
Max:
|
32
|
+
Max: 9
|
33
33
|
|
34
|
-
# Offense count:
|
34
|
+
# Offense count: 6
|
35
35
|
# Configuration parameters: IgnoredMethods.
|
36
36
|
Metrics/PerceivedComplexity:
|
37
|
-
Max:
|
37
|
+
Max: 16
|
38
38
|
|
39
39
|
# Offense count: 1
|
40
40
|
# This cop supports safe autocorrection (--autocorrect).
|
@@ -42,9 +42,9 @@ Style/IfUnlessModifier:
|
|
42
42
|
Exclude:
|
43
43
|
- 'lib/js_dependency/index_creator.rb'
|
44
44
|
|
45
|
-
# Offense count:
|
45
|
+
# Offense count: 2
|
46
46
|
# This cop supports safe autocorrection (--autocorrect).
|
47
47
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
48
48
|
# URISchemes: http, https
|
49
49
|
Layout/LineLength:
|
50
|
-
Max:
|
50
|
+
Max: 182
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.3.1] - 2022-07-21
|
4
|
+
|
5
|
+
- Revert for script tag with line brake.
|
6
|
+
- Fix exclude pattern.
|
7
|
+
|
8
|
+
## [0.2.3] - 2022-07-21
|
9
|
+
|
10
|
+
- Fix for script tag with line brake.
|
11
|
+
|
12
|
+
## [0.2.2] - 2022-07-21
|
13
|
+
|
14
|
+
- Add CLI option parameter "exclude".
|
15
|
+
- Add yaml configuration option parameter "excludes" that is array of "exclude".
|
16
|
+
|
3
17
|
## [0.2.1] - 2022-07-20
|
4
18
|
|
5
19
|
- Output parents and children cli with line brake and sort.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -30,6 +30,9 @@ name_level: 1 # Output name level
|
|
30
30
|
output_path: ./mermaid.txt # Output file path
|
31
31
|
alias_paths: # Alias path
|
32
32
|
"@": ./pages # absolute path or relative path of src_path
|
33
|
+
excludes: # Exclude words that you want to skip from export.
|
34
|
+
- excludeWord1
|
35
|
+
- excludeWord2
|
33
36
|
```
|
34
37
|
|
35
38
|
Each parameter is overridden by the command line.
|
@@ -41,6 +44,7 @@ child_analyze_level -> -c
|
|
41
44
|
parent_analyze_level -> -p
|
42
45
|
name_level -> -n
|
43
46
|
output_path -> -o
|
47
|
+
exclude -> -e
|
44
48
|
```
|
45
49
|
|
46
50
|
#### Export Mermaid Format
|
data/lib/js_dependency/cli.rb
CHANGED
@@ -14,6 +14,8 @@ module JsDependency
|
|
14
14
|
option :child_analyze_level, type: :numeric, aliases: "-c", desc: "Output level of child dependency"
|
15
15
|
option :parent_analyze_level, type: :numeric, aliases: "-p", desc: "Output level of parent dependency"
|
16
16
|
option :name_level, type: :numeric, aliases: "-n", desc: "Output name level"
|
17
|
+
option :exclude, type: :string, aliases: "-e", desc: "Exclude the word that is included in the path"
|
18
|
+
|
17
19
|
def export_mermaid
|
18
20
|
pathname = Pathname.new(".js_dependency.yml")
|
19
21
|
args = {}
|
@@ -26,6 +28,11 @@ module JsDependency
|
|
26
28
|
output_path = options[:output_path] || args["output_path"] || nil
|
27
29
|
alias_paths = args["alias_paths"] || nil
|
28
30
|
name_level = options[:name_level] || args["name_level"] || 1
|
31
|
+
excludes = if options[:exclude]
|
32
|
+
[options[:exclude]]
|
33
|
+
elsif args["excludes"]
|
34
|
+
args["excludes"]
|
35
|
+
end
|
29
36
|
|
30
37
|
str = JsDependency.export_mermaid(
|
31
38
|
src_path,
|
@@ -34,7 +41,8 @@ module JsDependency
|
|
34
41
|
parent_analyze_level: parent_analyze_level,
|
35
42
|
output_path: output_path,
|
36
43
|
alias_paths: alias_paths,
|
37
|
-
name_level: name_level
|
44
|
+
name_level: name_level,
|
45
|
+
excludes: excludes
|
38
46
|
)
|
39
47
|
|
40
48
|
puts str
|
@@ -45,6 +53,8 @@ module JsDependency
|
|
45
53
|
option :target_path, type: :string, aliases: "-t", desc: "Target file that you want to analyze."
|
46
54
|
option :output_path, type: :string, aliases: "-o", desc: "Output file path"
|
47
55
|
option :parent_analyze_level, type: :numeric, aliases: "-p", desc: "Output level of parent dependency"
|
56
|
+
option :exclude, type: :string, aliases: "-e", desc: "Exclude the word that is included in the path"
|
57
|
+
|
48
58
|
def parents
|
49
59
|
pathname = Pathname.new(".js_dependency.yml")
|
50
60
|
args = {}
|
@@ -55,13 +65,19 @@ module JsDependency
|
|
55
65
|
parent_analyze_level = options[:parent_analyze_level] || args["parent_analyze_level"] || 1
|
56
66
|
output_path = options[:output_path] || args["output_path"] || nil
|
57
67
|
alias_paths = args["alias_paths"] || nil
|
68
|
+
excludes = if options[:exclude]
|
69
|
+
[options[:exclude]]
|
70
|
+
elsif args["excludes"]
|
71
|
+
args["excludes"]
|
72
|
+
end
|
58
73
|
|
59
74
|
str = JsDependency.parents(
|
60
75
|
src_path,
|
61
76
|
target_path,
|
62
77
|
parent_analyze_level: parent_analyze_level,
|
63
78
|
output_path: output_path,
|
64
|
-
alias_paths: alias_paths
|
79
|
+
alias_paths: alias_paths,
|
80
|
+
excludes: excludes
|
65
81
|
).sort.uniq.join("\n")
|
66
82
|
|
67
83
|
puts str
|
@@ -72,6 +88,8 @@ module JsDependency
|
|
72
88
|
option :target_path, type: :string, aliases: "-t", desc: "Target file that you want to analyze."
|
73
89
|
option :output_path, type: :string, aliases: "-o", desc: "Output file path"
|
74
90
|
option :child_analyze_level, type: :numeric, aliases: "-c", desc: "Output level of child dependency"
|
91
|
+
option :exclude, type: :string, aliases: "-e", desc: "Exclude the word that is included in the path"
|
92
|
+
|
75
93
|
def children
|
76
94
|
pathname = Pathname.new(".js_dependency.yml")
|
77
95
|
args = {}
|
@@ -82,13 +100,19 @@ module JsDependency
|
|
82
100
|
child_analyze_level = options[:child_analyze_level] || args["child_analyze_level"] || 1
|
83
101
|
output_path = options[:output_path] || args["output_path"] || nil
|
84
102
|
alias_paths = args["alias_paths"] || nil
|
103
|
+
excludes = if options[:exclude]
|
104
|
+
[options[:exclude]]
|
105
|
+
elsif args["excludes"]
|
106
|
+
args["excludes"]
|
107
|
+
end
|
85
108
|
|
86
109
|
str = JsDependency.children(
|
87
110
|
src_path,
|
88
111
|
target_path,
|
89
112
|
child_analyze_level: child_analyze_level,
|
90
113
|
output_path: output_path,
|
91
|
-
alias_paths: alias_paths
|
114
|
+
alias_paths: alias_paths,
|
115
|
+
excludes: excludes
|
92
116
|
).sort.uniq.join("\n")
|
93
117
|
|
94
118
|
puts str
|
@@ -7,7 +7,7 @@ module JsDependency
|
|
7
7
|
@str = str
|
8
8
|
end
|
9
9
|
|
10
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
10
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
11
11
|
# @return [Array<String>]
|
12
12
|
def call
|
13
13
|
str = @str
|
@@ -68,7 +68,7 @@ module JsDependency
|
|
68
68
|
end
|
69
69
|
paths.uniq.sort
|
70
70
|
end
|
71
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
71
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
72
72
|
|
73
73
|
def self.call(str)
|
74
74
|
new(str).call
|
data/lib/js_dependency.rb
CHANGED
@@ -17,8 +17,9 @@ module JsDependency
|
|
17
17
|
# @param [Integer] parent_analyze_level
|
18
18
|
# @param [Integer] name_level
|
19
19
|
# @param [String, nil] output_path
|
20
|
+
# @param [Array, nil] excludes
|
20
21
|
# @return [String]
|
21
|
-
def self.export_mermaid(src_path, target_path, orientation: "LR", alias_paths: nil, child_analyze_level: 1, parent_analyze_level: 1, name_level: 1, output_path: nil)
|
22
|
+
def self.export_mermaid(src_path, target_path, orientation: "LR", alias_paths: nil, child_analyze_level: 1, parent_analyze_level: 1, name_level: 1, output_path: nil, excludes: nil)
|
22
23
|
output_pathname = Pathname.new(output_path) if output_path
|
23
24
|
index = JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths)
|
24
25
|
|
@@ -30,11 +31,11 @@ module JsDependency
|
|
30
31
|
|
31
32
|
root = JsDependency::Mermaid::Root.new(orientation)
|
32
33
|
|
33
|
-
parents_paths(target_pathname, parent_analyze_level, index) do |parent_path, child_path|
|
34
|
+
parents_paths(target_pathname, parent_analyze_level, index, excludes: excludes) do |parent_path, child_path|
|
34
35
|
root.add(parent_path, child_path)
|
35
36
|
end
|
36
37
|
|
37
|
-
children_paths(target_pathname, child_analyze_level, index) do |parent_path, child_path|
|
38
|
+
children_paths(target_pathname, child_analyze_level, index, excludes: excludes) do |parent_path, child_path|
|
38
39
|
root.add(parent_path, child_path)
|
39
40
|
end
|
40
41
|
|
@@ -43,7 +44,7 @@ module JsDependency
|
|
43
44
|
output
|
44
45
|
end
|
45
46
|
|
46
|
-
def self.parents(src_path, target_path, alias_paths: nil, parent_analyze_level: 1, output_path: nil)
|
47
|
+
def self.parents(src_path, target_path, alias_paths: nil, parent_analyze_level: 1, output_path: nil, excludes: nil)
|
47
48
|
output_pathname = Pathname.new(output_path) if output_path
|
48
49
|
index = JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths)
|
49
50
|
|
@@ -53,7 +54,7 @@ module JsDependency
|
|
53
54
|
Pathname.new(target_path)
|
54
55
|
end
|
55
56
|
list = []
|
56
|
-
parents_paths(target_pathname, parent_analyze_level, index) do |parent_path, _child_path|
|
57
|
+
parents_paths(target_pathname, parent_analyze_level, index, excludes: excludes) do |parent_path, _child_path|
|
57
58
|
list << parent_path
|
58
59
|
end
|
59
60
|
output = list.uniq
|
@@ -61,7 +62,7 @@ module JsDependency
|
|
61
62
|
output
|
62
63
|
end
|
63
64
|
|
64
|
-
def self.children(src_path, target_path, alias_paths: nil, child_analyze_level: 1, output_path: nil)
|
65
|
+
def self.children(src_path, target_path, alias_paths: nil, child_analyze_level: 1, output_path: nil, excludes: nil)
|
65
66
|
output_pathname = Pathname.new(output_path) if output_path
|
66
67
|
index = JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths)
|
67
68
|
|
@@ -71,7 +72,7 @@ module JsDependency
|
|
71
72
|
Pathname.new(target_path)
|
72
73
|
end
|
73
74
|
list = []
|
74
|
-
children_paths(target_pathname, child_analyze_level, index) do |_parent_path, child_path|
|
75
|
+
children_paths(target_pathname, child_analyze_level, index, excludes: excludes) do |_parent_path, child_path|
|
75
76
|
list << child_path
|
76
77
|
end
|
77
78
|
output = list.uniq
|
@@ -92,6 +93,7 @@ module JsDependency
|
|
92
93
|
list << parent if children.any?(target_pathname.to_s)
|
93
94
|
end
|
94
95
|
end
|
96
|
+
|
95
97
|
private_class_method :extract_parent_paths
|
96
98
|
|
97
99
|
# @param [String] target_path
|
@@ -105,6 +107,7 @@ module JsDependency
|
|
105
107
|
end
|
106
108
|
index[target_pathname.to_s] || []
|
107
109
|
end
|
110
|
+
|
108
111
|
private_class_method :extract_children_paths
|
109
112
|
|
110
113
|
# @param [String] src
|
@@ -112,9 +115,10 @@ module JsDependency
|
|
112
115
|
def self.create_index(src_path, alias_paths: nil)
|
113
116
|
JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths)
|
114
117
|
end
|
118
|
+
|
115
119
|
private_class_method :create_index
|
116
120
|
|
117
|
-
def self.parents_paths(target_pathname, analyze_level, index)
|
121
|
+
def self.parents_paths(target_pathname, analyze_level, index, excludes: nil)
|
118
122
|
temp_paths = [target_pathname.to_s]
|
119
123
|
analyze_level.times do
|
120
124
|
list = []
|
@@ -126,15 +130,18 @@ module JsDependency
|
|
126
130
|
end
|
127
131
|
|
128
132
|
list += extract_parent_paths(temp_pathname.to_s, index).each do |parent_path|
|
133
|
+
next if excludes&.any? { |ignore| parent_path.to_s.include?(ignore) || temp_pathname.to_s.include?(ignore) }
|
134
|
+
|
129
135
|
yield parent_path, temp_pathname.to_s
|
130
136
|
end
|
131
137
|
end
|
132
138
|
temp_paths = list
|
133
139
|
end
|
134
140
|
end
|
141
|
+
|
135
142
|
private_class_method :parents_paths
|
136
143
|
|
137
|
-
def self.children_paths(target_pathname, analyze_level, index)
|
144
|
+
def self.children_paths(target_pathname, analyze_level, index, excludes: nil)
|
138
145
|
temp_paths = [target_pathname.to_s]
|
139
146
|
analyze_level.times do
|
140
147
|
list = []
|
@@ -146,11 +153,14 @@ module JsDependency
|
|
146
153
|
end
|
147
154
|
|
148
155
|
list += extract_children_paths(temp_pathname.to_s, index).each do |child_path|
|
156
|
+
next if excludes&.any? { |ignore| child_path.to_s.include?(ignore) || temp_pathname.to_s.include?(ignore) }
|
157
|
+
|
149
158
|
yield temp_pathname.to_s, child_path
|
150
159
|
end
|
151
160
|
end
|
152
161
|
temp_paths = list
|
153
162
|
end
|
154
163
|
end
|
164
|
+
|
155
165
|
private_class_method :children_paths
|
156
166
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_dependency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.1
|
4
|
+
version: 0.2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- junara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pathname
|