js_dependency 0.3.8 → 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 +12 -0
- data/Gemfile.lock +1 -1
- data/README.md +18 -8
- data/lib/js_dependency/cli.rb +15 -5
- data/lib/js_dependency/cli_utils/config.rb +72 -8
- data/lib/js_dependency/cli_utils/yaml.rb +30 -10
- data/lib/js_dependency/version.rb +1 -1
- 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: 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-
|
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
@@ -1,5 +1,17 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.11] - 2022-08-13
|
4
|
+
|
5
|
+
- Add target_paths options in configuration file to use array.
|
6
|
+
|
7
|
+
## [0.3.10] - 2022-08-13
|
8
|
+
|
9
|
+
- Add file_config options to specify configuration yaml which user like.
|
10
|
+
|
11
|
+
## [0.3.9] - 2022-08-12
|
12
|
+
|
13
|
+
- Add alias_paths options of hash.
|
14
|
+
|
3
15
|
## [0.3.8] - 2022-08-11
|
4
16
|
|
5
17
|
- `.js_dependecy.yaml` is arrowed for configuration file name.
|
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
|
@@ -46,6 +49,12 @@ excludes: # Exclude words that you want to skip from export.
|
|
46
49
|
- excludeWord2
|
47
50
|
```
|
48
51
|
|
52
|
+
If you want to specify .js_dependency.yml as another path, you can add option path by `-f` option.
|
53
|
+
|
54
|
+
```shell
|
55
|
+
js_dependency -f path/to/yourfilename.yml
|
56
|
+
```
|
57
|
+
|
49
58
|
Each parameter is overridden by the command line.
|
50
59
|
|
51
60
|
```
|
@@ -56,6 +65,7 @@ parent_analyze_level -> -p
|
|
56
65
|
name_level -> -n
|
57
66
|
output_path -> -o
|
58
67
|
exclude -> -e
|
68
|
+
alias_paths -> -a
|
59
69
|
```
|
60
70
|
|
61
71
|
#### Export Mermaid Format
|
@@ -63,31 +73,31 @@ exclude -> -e
|
|
63
73
|
##### Single target path
|
64
74
|
|
65
75
|
```shell
|
66
|
-
js_dependency -s ./src -t ./src/App.vue -o ./mermaid.txt -c 2 -p 2 -n 1
|
76
|
+
js_dependency -s ./src -t ./src/App.vue -o ./mermaid.txt -c 2 -p 2 -n 1 -a @:./pages
|
67
77
|
```
|
68
78
|
|
69
79
|
##### Multiple target paths
|
70
80
|
|
71
81
|
```shell
|
72
|
-
js_dependency -s ./src -t ./src/App.vue ./src/components/Sub.vue -o ./mermaid.txt -c 2 -p 2 -n 1
|
82
|
+
js_dependency -s ./src -t ./src/App.vue ./src/components/Sub.vue -o ./mermaid.txt -c 2 -p 2 -n 1 -a @:./pages
|
73
83
|
```
|
74
84
|
|
75
|
-
##### Exclude path which
|
85
|
+
##### Exclude path which include exclude words `-e` from output
|
76
86
|
|
77
87
|
```shell
|
78
|
-
js_dependency -s ./src -t ./src/App.vue -o ./mermaid.txt -c 2 -p 2 -n 1 -e excludeWord1 excludeWord2
|
88
|
+
js_dependency -s ./src -t ./src/App.vue -o ./mermaid.txt -c 2 -p 2 -n 1 -e excludeWord1 excludeWord2 -a @:./pages
|
79
89
|
```
|
80
90
|
|
81
91
|
#### Export parents components list
|
82
92
|
|
83
93
|
```shell
|
84
|
-
js_dependency parents -s ./src -t ./src/App.vue -o ./parents.txt -p 2
|
94
|
+
js_dependency parents -s ./src -t ./src/App.vue -o ./parents.txt -p 2 -a @:./pages
|
85
95
|
```
|
86
96
|
|
87
97
|
#### Export children components list
|
88
98
|
|
89
99
|
```shell
|
90
|
-
js_dependency childrent -s ./src -t ./src/App.vue -o ./children.txt -c 2
|
100
|
+
js_dependency childrent -s ./src -t ./src/App.vue -o ./children.txt -c 2 -a @:./pages
|
91
101
|
```
|
92
102
|
|
93
103
|
#### Export orphan components list
|
@@ -95,7 +105,7 @@ js_dependency childrent -s ./src -t ./src/App.vue -o ./children.txt -c 2
|
|
95
105
|
Components that are not used in other components.
|
96
106
|
|
97
107
|
```shell
|
98
|
-
js_dependency orphan -s ./src
|
108
|
+
js_dependency orphan -s ./src -a @:./pages
|
99
109
|
```
|
100
110
|
|
101
111
|
#### Export left components list
|
@@ -103,7 +113,7 @@ js_dependency orphan -s ./src
|
|
103
113
|
Components that do not import other components.
|
104
114
|
|
105
115
|
```shell
|
106
|
-
js_dependency leave -s ./src
|
116
|
+
js_dependency leave -s ./src -a @:./pages
|
107
117
|
```
|
108
118
|
|
109
119
|
### By ruby code
|
data/lib/js_dependency/cli.rb
CHANGED
@@ -15,9 +15,11 @@ module JsDependency
|
|
15
15
|
method_option :parent_analyze_level, type: :numeric, aliases: "-p", desc: "Output level of parent dependency"
|
16
16
|
method_option :name_level, type: :numeric, aliases: "-n", desc: "Output name level"
|
17
17
|
method_option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
|
18
|
+
method_option :alias_paths, type: :hash, aliases: "-a", desc: "Alias paths by hash format."
|
19
|
+
method_option :file_config, type: :string, aliases: "-f", desc: "Configuration file path."
|
18
20
|
|
19
21
|
def export_mermaid
|
20
|
-
args = JsDependency::CliUtils::Yaml.new.args
|
22
|
+
args = JsDependency::CliUtils::Yaml.new(path: options[:file_config]).args
|
21
23
|
config = JsDependency::CliUtils::Config.new(options, args)
|
22
24
|
puts JsDependency.export_mermaid(
|
23
25
|
config.src_path,
|
@@ -37,9 +39,11 @@ module JsDependency
|
|
37
39
|
method_option :output_path, type: :string, aliases: "-o", desc: "Output file path"
|
38
40
|
method_option :parent_analyze_level, type: :numeric, aliases: "-p", desc: "Output level of parent dependency"
|
39
41
|
method_option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
|
42
|
+
method_option :alias_paths, type: :hash, aliases: "-a", desc: "Alias paths by hash format."
|
43
|
+
method_option :file_config, type: :string, aliases: "-f", desc: "Configuration file path."
|
40
44
|
|
41
45
|
def parents
|
42
|
-
args = JsDependency::CliUtils::Yaml.new.args
|
46
|
+
args = JsDependency::CliUtils::Yaml.new(path: options[:file_config]).args
|
43
47
|
config = JsDependency::CliUtils::Config.new(options, args)
|
44
48
|
puts JsDependency.parents(
|
45
49
|
config.src_path,
|
@@ -57,9 +61,11 @@ module JsDependency
|
|
57
61
|
method_option :output_path, type: :string, aliases: "-o", desc: "Output file path"
|
58
62
|
method_option :child_analyze_level, type: :numeric, aliases: "-c", desc: "Output level of child dependency"
|
59
63
|
method_option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
|
64
|
+
method_option :alias_paths, type: :hash, aliases: "-a", desc: "Alias paths by hash format."
|
65
|
+
method_option :file_config, type: :string, aliases: "-f", desc: "Configuration file path."
|
60
66
|
|
61
67
|
def children
|
62
|
-
args = JsDependency::CliUtils::Yaml.new.args
|
68
|
+
args = JsDependency::CliUtils::Yaml.new(path: options[:file_config]).args
|
63
69
|
config = JsDependency::CliUtils::Config.new(options, args)
|
64
70
|
puts JsDependency.children(
|
65
71
|
config.src_path,
|
@@ -73,9 +79,11 @@ module JsDependency
|
|
73
79
|
|
74
80
|
desc "orphan", "export components than is not depended by others"
|
75
81
|
method_option :src_path, type: :string, aliases: "-s", desc: "Root folder."
|
82
|
+
method_option :alias_paths, type: :hash, aliases: "-a", desc: "Alias paths by hash format."
|
83
|
+
method_option :file_config, type: :string, aliases: "-f", desc: "Configuration file path."
|
76
84
|
|
77
85
|
def orphan
|
78
|
-
args = JsDependency::CliUtils::Yaml.new.args
|
86
|
+
args = JsDependency::CliUtils::Yaml.new(path: options[:file_config]).args
|
79
87
|
config = JsDependency::CliUtils::Config.new(options, args)
|
80
88
|
puts JsDependency.orphan(
|
81
89
|
config.src_path,
|
@@ -85,9 +93,11 @@ module JsDependency
|
|
85
93
|
|
86
94
|
desc "leave", "export components than is not depended by others"
|
87
95
|
method_option :src_path, type: :string, aliases: "-s", desc: "Root folder."
|
96
|
+
method_option :alias_paths, type: :hash, aliases: "-a", desc: "Alias paths by hash format."
|
97
|
+
method_option :file_config, type: :string, aliases: "-f", desc: "Configuration file path."
|
88
98
|
|
89
99
|
def leave
|
90
|
-
args = JsDependency::CliUtils::Yaml.new.args
|
100
|
+
args = JsDependency::CliUtils::Yaml.new(path: options[:file_config]).args
|
91
101
|
config = JsDependency::CliUtils::Config.new(options, args)
|
92
102
|
puts JsDependency.leave(
|
93
103
|
config.src_path,
|
@@ -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
|
-
@alias_paths = args[:alias_paths] ||
|
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
|
@@ -3,22 +3,42 @@
|
|
3
3
|
module JsDependency
|
4
4
|
module CliUtils
|
5
5
|
class Yaml
|
6
|
-
attr_reader :
|
7
|
-
:
|
6
|
+
attr_reader :dir_path,
|
7
|
+
:path
|
8
8
|
|
9
9
|
# @param [String, nil] dir_path
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
# @param [String, nil] path
|
11
|
+
def initialize(dir_path: nil, path: nil)
|
12
|
+
@dir_path = present?(dir_path) ? dir_path : Dir.pwd
|
13
|
+
@path = path
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Hash]
|
17
|
+
def args
|
18
|
+
pathname = if present?(@path)
|
19
|
+
Pathname.new(@path)
|
20
|
+
else
|
21
|
+
config_pathname
|
22
|
+
end
|
23
|
+
|
24
|
+
if pathname.nil?
|
25
|
+
{}
|
26
|
+
else
|
27
|
+
symbolize_keys(YAML.safe_load(pathname.read))
|
28
|
+
end
|
18
29
|
end
|
19
30
|
|
20
31
|
private
|
21
32
|
|
33
|
+
# @param [String] str
|
34
|
+
# @return [TrueClass, FalseClass]
|
35
|
+
def present?(str)
|
36
|
+
return false if str.nil?
|
37
|
+
return false if str.empty?
|
38
|
+
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
22
42
|
# @return [Pathname, nil]
|
23
43
|
def config_pathname
|
24
44
|
dir_pathname = Pathname.new(@dir_path)
|
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.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- junara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pathname
|