js_dependency 0.3.14 → 0.3.15
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 +2 -0
- data/.rubocop_todo.yml +11 -6
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/README.md +5 -5
- data/lib/js_dependency/cli.rb +3 -2
- data/lib/js_dependency/cli_utils/config.rb +2 -1
- data/lib/js_dependency/pathname_utility.rb +9 -0
- data/lib/js_dependency/report/markdown.rb +14 -9
- data/lib/js_dependency/version.rb +1 -1
- data/lib/js_dependency.rb +23 -15
- 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: c40c515c695755869134ea2cda376981c48e4202648fc4946d66219b93d5917b
|
4
|
+
data.tar.gz: c185eaf95efb2f6a8c11abd91380b2f736c8ddee5dc410f7ea0dab44641eb0aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af9562638595533ae8cda360e0a5575909a3d36f376e47d863988b0e2ced296853cafda54468530c8484c63516d304ce8e7180e7491491461748778df340eb06
|
7
|
+
data.tar.gz: f2f0046905e4906585b47b89b50d37e767b96498d49680202346105ac78f07322cb4eb69471611e326031d654c37e6bb3ef4d37c72d7b1e29c8f4a45220d106b
|
data/.js_dependency.yml.sample
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2022-08-21
|
3
|
+
# on 2022-08-21 08:22:13 UTC using RuboCop version 1.35.0.
|
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
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 3
|
10
10
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
|
11
11
|
Metrics/AbcSize:
|
12
|
-
Max:
|
12
|
+
Max: 32
|
13
13
|
|
14
14
|
# Offense count: 1
|
15
15
|
# Configuration parameters: CountComments, CountAsOne.
|
16
16
|
Metrics/ClassLength:
|
17
|
-
Max:
|
17
|
+
Max: 120
|
18
18
|
|
19
19
|
# Offense count: 2
|
20
20
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
|
@@ -24,12 +24,12 @@ Metrics/CyclomaticComplexity:
|
|
24
24
|
# Offense count: 10
|
25
25
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
26
26
|
Metrics/MethodLength:
|
27
|
-
Max:
|
27
|
+
Max: 22
|
28
28
|
|
29
29
|
# Offense count: 4
|
30
30
|
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
|
31
31
|
Metrics/ParameterLists:
|
32
|
-
Max:
|
32
|
+
Max: 10
|
33
33
|
|
34
34
|
# Offense count: 2
|
35
35
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
|
@@ -37,6 +37,11 @@ Metrics/PerceivedComplexity:
|
|
37
37
|
Max: 15
|
38
38
|
|
39
39
|
# Offense count: 1
|
40
|
+
# Configuration parameters: CountAsOne.
|
41
|
+
RSpec/ExampleLength:
|
42
|
+
Max: 6
|
43
|
+
|
44
|
+
# Offense count: 2
|
40
45
|
# This cop supports safe autocorrection (--autocorrect).
|
41
46
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
42
47
|
# URISchemes: http, https
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
-
## [0.3.
|
3
|
+
## [0.3.15] - 2022-08-21
|
4
|
+
|
5
|
+
- Add exclude_output_names option for export_markdown_report.
|
6
|
+
|
7
|
+
## [0.3.14] - 2022-08-21
|
4
8
|
|
5
9
|
- Add export_markdown_report cli. This will export the markdown report to a file for GitHub comment.
|
6
10
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -91,9 +91,11 @@ js_dependency -s ./src -t ./src/App.vue -o ./mermaid.txt -c 2 -p 2 -n 1 -e exclu
|
|
91
91
|
#### Export Markdown report
|
92
92
|
|
93
93
|
```shell
|
94
|
-
js_dependency export_markdown_report -s ./src -t ./src/App.vue -c 2 -p 2 -n 1 -a @:./pages --identifier your_uniq_identifier_for_upsert_report
|
94
|
+
js_dependency export_markdown_report -s ./src -t ./src/App.vue -c 2 -p 2 -n 1 -a @:./pages --identifier your_uniq_identifier_for_upsert_report --exclude_output_names pages
|
95
95
|
```
|
96
96
|
|
97
|
+
``--exclude_output_names`` option is used to exclude outputs from orphan list by name matching. In following results, include pages file is excluded from orphan.
|
98
|
+
|
97
99
|
Like this:
|
98
100
|
|
99
101
|
```
|
@@ -101,10 +103,9 @@ Like this:
|
|
101
103
|
|
102
104
|
### Orphan modules
|
103
105
|
|
104
|
-
|
106
|
+
2 orphaned modules.
|
105
107
|
|
106
108
|
* ``components/sub/Exclude.vue``
|
107
|
-
* ``pages/app.js``
|
108
109
|
* ``utils/calculation.js``
|
109
110
|
|
110
111
|
### Module dependency
|
@@ -129,10 +130,9 @@ style utils_calculation.js stroke:#f9f,stroke-width:4px
|
|
129
130
|
|
130
131
|
### Orphan modules
|
131
132
|
|
132
|
-
|
133
|
+
2 orphaned modules.
|
133
134
|
|
134
135
|
* ``components/sub/Exclude.vue``
|
135
|
-
* ``pages/app.js``
|
136
136
|
* ``utils/calculation.js``
|
137
137
|
|
138
138
|
### Module dependency
|
data/lib/js_dependency/cli.rb
CHANGED
@@ -121,7 +121,7 @@ module JsDependency
|
|
121
121
|
method_option :alias_paths, type: :hash, aliases: "-a", desc: "Alias paths by hash format."
|
122
122
|
method_option :file_config, type: :string, aliases: "-f", desc: "Configuration file path."
|
123
123
|
method_option :identifier, type: :string, desc: "Embed id in markdown."
|
124
|
-
|
124
|
+
method_option :exclude_output_names, type: :array, desc: "Exclude output names"
|
125
125
|
def export_markdown_report
|
126
126
|
args = JsDependency::CliUtils::Yaml.new(path: options[:file_config]).args
|
127
127
|
config = JsDependency::CliUtils::Config.new(options, args)
|
@@ -133,7 +133,8 @@ module JsDependency
|
|
133
133
|
alias_paths: config.alias_paths,
|
134
134
|
name_level: config.name_level,
|
135
135
|
excludes: config.excludes,
|
136
|
-
identifier: config.identifier
|
136
|
+
identifier: config.identifier,
|
137
|
+
exclude_output_names: config.exclude_output_names
|
137
138
|
)
|
138
139
|
end
|
139
140
|
end
|
@@ -4,7 +4,7 @@ module JsDependency
|
|
4
4
|
module CliUtils
|
5
5
|
class Config
|
6
6
|
attr_reader :src_path, :target_paths, :target_path, :child_analyze_level, :parent_analyze_level, :output_path,
|
7
|
-
:alias_paths, :name_level, :excludes, :identifier
|
7
|
+
:alias_paths, :name_level, :excludes, :identifier, :exclude_output_names
|
8
8
|
|
9
9
|
# @param [Hash] options
|
10
10
|
# @param [Hash] args
|
@@ -21,6 +21,7 @@ module JsDependency
|
|
21
21
|
@name_level = options[:name_level] || args[:name_level] || 1
|
22
22
|
@excludes = calc_excludes(options[:excludes], args[:excludes])
|
23
23
|
@identifier = options[:identifier] || nil
|
24
|
+
@exclude_output_names = options[:exclude_output_names] || []
|
24
25
|
end
|
25
26
|
|
26
27
|
private
|
@@ -46,5 +46,14 @@ module JsDependency
|
|
46
46
|
pathname.to_s
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
# @param [Array<String>] paths
|
51
|
+
# @return [Array<String>]
|
52
|
+
def self.filter_js_files(paths)
|
53
|
+
return paths if paths.nil? || paths.empty?
|
54
|
+
|
55
|
+
permitted_extnames = %w[.js .vue .jsx]
|
56
|
+
paths.filter { |path| permitted_extnames.include?(Pathname.new(path).extname) }
|
57
|
+
end
|
49
58
|
end
|
50
59
|
end
|
@@ -10,7 +10,7 @@ module JsDependency
|
|
10
10
|
# @param [nil, String] identifier
|
11
11
|
def initialize(orphan_list, mermaid_markdown, identifier: nil)
|
12
12
|
@orphan_list = orphan_list || []
|
13
|
-
@mermaid_markdown = mermaid_markdown
|
13
|
+
@mermaid_markdown = mermaid_markdown
|
14
14
|
@identifier = identifier || "js_dependency_report_identifier"
|
15
15
|
end
|
16
16
|
|
@@ -30,17 +30,22 @@ module JsDependency
|
|
30
30
|
markdown += "#{@orphan_list.map { |str| "* ``#{str}``" }.join("\n")}\n\n"
|
31
31
|
end
|
32
32
|
|
33
|
-
markdown +=
|
34
|
-
### Module dependency
|
33
|
+
markdown += "### Module dependency\n\n"
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
if @mermaid_markdown.nil? || @mermaid_markdown.empty?
|
36
|
+
markdown += ".vue or .js or .jsx files are not changed.\n\n"
|
37
|
+
else
|
38
|
+
markdown += <<~"MAKRDOWNTEXT"
|
39
|
+
```mermaid
|
40
|
+
MAKRDOWNTEXT
|
39
41
|
|
40
|
-
|
41
|
-
```
|
42
|
+
markdown += @mermaid_markdown.to_s
|
42
43
|
|
43
|
-
|
44
|
+
markdown += <<~"MAKRDOWNTEXT"
|
45
|
+
```
|
46
|
+
|
47
|
+
MAKRDOWNTEXT
|
48
|
+
end
|
44
49
|
|
45
50
|
markdown += "<!-- #{@identifier} -->"
|
46
51
|
markdown
|
data/lib/js_dependency.rb
CHANGED
@@ -36,9 +36,13 @@ module JsDependency
|
|
36
36
|
# @param [String] src_path
|
37
37
|
# @param [Hash, nil] alias_paths
|
38
38
|
# @return [Array<String>]
|
39
|
-
def self.orphan(src_path, alias_paths: nil)
|
39
|
+
def self.orphan(src_path, alias_paths: nil, exclude_output_names: [])
|
40
40
|
index = JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths)
|
41
|
-
JsDependency::SourceAnalysis::Orphan.new(index, src_path).call
|
41
|
+
JsDependency::SourceAnalysis::Orphan.new(index, src_path).call.filter do |path|
|
42
|
+
exclude_output_names.none? do |name|
|
43
|
+
path.include?(name)
|
44
|
+
end
|
45
|
+
end
|
42
46
|
end
|
43
47
|
|
44
48
|
# @param [String] src_path
|
@@ -137,19 +141,23 @@ module JsDependency
|
|
137
141
|
# @param [String, nil] identifier
|
138
142
|
# @return [String]
|
139
143
|
def self.export_markdown_report(src_path, target_paths, orientation: "LR", alias_paths: nil, child_analyze_level: 1,
|
140
|
-
parent_analyze_level: 1, name_level: 1, excludes: nil, identifier: nil)
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
144
|
+
parent_analyze_level: 1, name_level: 1, excludes: nil, identifier: nil, exclude_output_names: [])
|
145
|
+
permitted_target_paths = JsDependency::PathnameUtility.filter_js_files(target_paths)
|
146
|
+
mermaid_markdown = if target_paths.nil? || target_paths.empty?
|
147
|
+
nil
|
148
|
+
else
|
149
|
+
JsDependency.export_mermaid(
|
150
|
+
src_path,
|
151
|
+
permitted_target_paths,
|
152
|
+
orientation: orientation,
|
153
|
+
alias_paths: alias_paths,
|
154
|
+
child_analyze_level: child_analyze_level,
|
155
|
+
parent_analyze_level: parent_analyze_level,
|
156
|
+
name_level: name_level,
|
157
|
+
excludes: excludes
|
158
|
+
)
|
159
|
+
end
|
160
|
+
orphan_list = JsDependency.orphan(src_path, alias_paths: alias_paths, exclude_output_names: exclude_output_names)
|
153
161
|
|
154
162
|
JsDependency::Report::Markdown.new(orphan_list, mermaid_markdown, identifier: identifier).export
|
155
163
|
end
|