js_dependency 0.3.14 → 0.4.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.
- checksums.yaml +4 -4
- data/.js_dependency.yml.sample +2 -0
- data/.rubocop_todo.yml +11 -6
- data/CHANGELOG.md +15 -2
- data/Gemfile +9 -0
- data/Gemfile.lock +112 -54
- data/Guardfile +18 -0
- data/README.md +12 -5
- data/js_dependency.gemspec +0 -7
- data/lib/js_dependency/cli.rb +3 -2
- data/lib/js_dependency/cli_utils/config.rb +3 -2
- data/lib/js_dependency/extractor/extract_script_tag.rb +9 -1
- data/lib/js_dependency/pathname_utility.rb +9 -0
- data/lib/js_dependency/report/markdown.rb +15 -10
- data/lib/js_dependency/source_analysis/orphan.rb +1 -1
- data/lib/js_dependency/version.rb +1 -1
- data/lib/js_dependency.rb +23 -15
- metadata +4 -101
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16849080f31654121c34449373ebff1848e5529586ce48f0ceb42169efb91652
|
|
4
|
+
data.tar.gz: 4430ca0ea3d689f829bb9dd5ebda28d43b1594979acbe977fe67a1fb8dd2f35e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a68498b0b19fc9210d3e5b9a5b1bf311b4953c4dc11514af91ebb4c3e1b235e11c68468db643021b1bbbe2189417e5e4fe1d442561ca5f34873d456bd924cc7b
|
|
7
|
+
data.tar.gz: 2a0b1b81acd03a8acf0153219f622887ff262a806c636eb5e73db489744c686a227791bdbae01b4a9a9dbea74a66d469d0e5bc852427d733da42d463d7a0b9b0
|
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,19 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
-
## [0.
|
|
3
|
+
## [0.4.0] - 2024-03-31
|
|
4
|
+
|
|
5
|
+
- Breaking change: Support only Ruby 3.0 or later. [#34](https://github.com/junara/js_dependency/pull/34)
|
|
6
|
+
|
|
7
|
+
- Add support Vue script setup and lang. [#35](https://github.com/junara/js_dependency/pull/35) [#36](https://github.com/junara/js_dependency/pull/36)
|
|
8
|
+
- `<script setup>` and `<script lang="ts">` are supported.
|
|
9
|
+
|
|
10
|
+
- Fix some typos. [#33](https://github.com/junara/js_dependency/pull/33)
|
|
11
|
+
|
|
12
|
+
## [0.3.15] - 2022-08-21
|
|
13
|
+
|
|
14
|
+
- Add exclude_output_names option for export_markdown_report.
|
|
15
|
+
|
|
16
|
+
## [0.3.14] - 2022-08-21
|
|
4
17
|
|
|
5
18
|
- Add export_markdown_report cli. This will export the markdown report to a file for GitHub comment.
|
|
6
19
|
|
|
@@ -27,7 +40,7 @@
|
|
|
27
40
|
|
|
28
41
|
## [0.3.8] - 2022-08-11
|
|
29
42
|
|
|
30
|
-
- `.
|
|
43
|
+
- `.js_dependency.yaml` is arrowed for configuration file name.
|
|
31
44
|
- Refactor codes.
|
|
32
45
|
- Add test codes.
|
|
33
46
|
|
data/Gemfile
CHANGED
|
@@ -11,6 +11,15 @@ gem "rspec", "~> 3.0"
|
|
|
11
11
|
|
|
12
12
|
gem "codecov", require: false, group: "test"
|
|
13
13
|
gem "debug", ">= 1.0.0"
|
|
14
|
+
gem "guard-rspec", require: false
|
|
14
15
|
gem "rubocop", "~> 1.21"
|
|
15
16
|
gem "simplecov", require: false, group: :test
|
|
16
17
|
gem "yarn"
|
|
18
|
+
|
|
19
|
+
gem "rspec-parameterized", "~> 1.0"
|
|
20
|
+
|
|
21
|
+
gem "rubocop-performance", "~> 1.21"
|
|
22
|
+
|
|
23
|
+
gem "rubocop-rake", "~> 0.6.0"
|
|
24
|
+
|
|
25
|
+
gem "rubocop-rspec", "~> 2.28"
|
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
js_dependency (0.
|
|
5
|
-
pathname
|
|
4
|
+
js_dependency (0.4.0)
|
|
6
5
|
thor
|
|
7
6
|
yaml
|
|
8
7
|
|
|
@@ -10,87 +9,144 @@ GEM
|
|
|
10
9
|
remote: https://rubygems.org/
|
|
11
10
|
specs:
|
|
12
11
|
ast (2.4.2)
|
|
13
|
-
|
|
12
|
+
binding_of_caller (1.0.1)
|
|
13
|
+
debug_inspector (>= 1.2.0)
|
|
14
14
|
codecov (0.6.0)
|
|
15
15
|
simplecov (>= 0.15, < 0.22)
|
|
16
16
|
coderay (1.1.3)
|
|
17
|
-
debug (1.
|
|
18
|
-
irb (
|
|
19
|
-
reline (>= 0.3.
|
|
20
|
-
|
|
17
|
+
debug (1.9.2)
|
|
18
|
+
irb (~> 1.10)
|
|
19
|
+
reline (>= 0.3.8)
|
|
20
|
+
debug_inspector (1.2.0)
|
|
21
|
+
diff-lcs (1.5.1)
|
|
21
22
|
docile (1.4.0)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
ffi (1.16.3)
|
|
24
|
+
formatador (1.1.0)
|
|
25
|
+
guard (2.18.1)
|
|
26
|
+
formatador (>= 0.2.4)
|
|
27
|
+
listen (>= 2.7, < 4.0)
|
|
28
|
+
lumberjack (>= 1.0.12, < 2.0)
|
|
29
|
+
nenv (~> 0.1)
|
|
30
|
+
notiffany (~> 0.0)
|
|
31
|
+
pry (>= 0.13.0)
|
|
32
|
+
shellany (~> 0.0)
|
|
33
|
+
thor (>= 0.18.1)
|
|
34
|
+
guard-compat (1.2.1)
|
|
35
|
+
guard-rspec (4.7.3)
|
|
36
|
+
guard (~> 2.1)
|
|
37
|
+
guard-compat (~> 1.1)
|
|
38
|
+
rspec (>= 2.99.0, < 4.0)
|
|
39
|
+
io-console (0.7.2)
|
|
40
|
+
irb (1.12.0)
|
|
41
|
+
rdoc
|
|
42
|
+
reline (>= 0.4.2)
|
|
43
|
+
json (2.7.1)
|
|
44
|
+
language_server-protocol (3.17.0.3)
|
|
45
|
+
listen (3.9.0)
|
|
46
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
47
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
48
|
+
lumberjack (1.2.10)
|
|
49
|
+
method_source (1.0.0)
|
|
50
|
+
nenv (0.3.0)
|
|
51
|
+
notiffany (0.1.3)
|
|
52
|
+
nenv (~> 0.1)
|
|
53
|
+
shellany (~> 0.0)
|
|
54
|
+
parallel (1.24.0)
|
|
55
|
+
parser (3.3.0.5)
|
|
28
56
|
ast (~> 2.4.1)
|
|
57
|
+
racc
|
|
29
58
|
parslet (2.0.0)
|
|
30
|
-
pathname (0.2.0)
|
|
31
59
|
proc_to_ast (0.1.0)
|
|
32
60
|
coderay
|
|
33
61
|
parser
|
|
34
62
|
unparser
|
|
35
|
-
|
|
63
|
+
pry (0.14.2)
|
|
64
|
+
coderay (~> 1.1)
|
|
65
|
+
method_source (~> 1.0)
|
|
66
|
+
psych (5.1.2)
|
|
67
|
+
stringio
|
|
68
|
+
racc (1.7.3)
|
|
69
|
+
rack (3.0.10)
|
|
36
70
|
rainbow (3.1.1)
|
|
37
|
-
rake (13.0
|
|
38
|
-
|
|
39
|
-
|
|
71
|
+
rake (13.1.0)
|
|
72
|
+
rb-fsevent (0.11.2)
|
|
73
|
+
rb-inotify (0.10.1)
|
|
74
|
+
ffi (~> 1.0)
|
|
75
|
+
rdoc (6.6.3.1)
|
|
76
|
+
psych (>= 4.0.0)
|
|
77
|
+
regexp_parser (2.9.0)
|
|
78
|
+
reline (0.5.0)
|
|
40
79
|
io-console (~> 0.5)
|
|
41
|
-
rexml (3.2.
|
|
42
|
-
rspec (3.
|
|
43
|
-
rspec-core (~> 3.
|
|
44
|
-
rspec-expectations (~> 3.
|
|
45
|
-
rspec-mocks (~> 3.
|
|
46
|
-
rspec-core (3.
|
|
47
|
-
rspec-support (~> 3.
|
|
48
|
-
rspec-expectations (3.
|
|
80
|
+
rexml (3.2.6)
|
|
81
|
+
rspec (3.13.0)
|
|
82
|
+
rspec-core (~> 3.13.0)
|
|
83
|
+
rspec-expectations (~> 3.13.0)
|
|
84
|
+
rspec-mocks (~> 3.13.0)
|
|
85
|
+
rspec-core (3.13.0)
|
|
86
|
+
rspec-support (~> 3.13.0)
|
|
87
|
+
rspec-expectations (3.13.0)
|
|
49
88
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
50
|
-
rspec-support (~> 3.
|
|
51
|
-
rspec-mocks (3.
|
|
89
|
+
rspec-support (~> 3.13.0)
|
|
90
|
+
rspec-mocks (3.13.0)
|
|
52
91
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
53
|
-
rspec-support (~> 3.
|
|
54
|
-
rspec-parameterized (0.
|
|
55
|
-
|
|
92
|
+
rspec-support (~> 3.13.0)
|
|
93
|
+
rspec-parameterized (1.0.0)
|
|
94
|
+
rspec-parameterized-core (< 2)
|
|
95
|
+
rspec-parameterized-table_syntax (< 2)
|
|
96
|
+
rspec-parameterized-core (1.0.0)
|
|
56
97
|
parser
|
|
57
98
|
proc_to_ast
|
|
58
99
|
rspec (>= 2.13, < 4)
|
|
59
100
|
unparser
|
|
60
|
-
rspec-
|
|
61
|
-
|
|
101
|
+
rspec-parameterized-table_syntax (1.0.1)
|
|
102
|
+
binding_of_caller
|
|
103
|
+
rspec-parameterized-core (< 2)
|
|
104
|
+
rspec-support (3.13.1)
|
|
105
|
+
rubocop (1.62.1)
|
|
62
106
|
json (~> 2.3)
|
|
107
|
+
language_server-protocol (>= 3.17.0)
|
|
63
108
|
parallel (~> 1.10)
|
|
64
|
-
parser (>= 3.
|
|
109
|
+
parser (>= 3.3.0.2)
|
|
65
110
|
rainbow (>= 2.2.2, < 4.0)
|
|
66
111
|
regexp_parser (>= 1.8, < 3.0)
|
|
67
112
|
rexml (>= 3.2.5, < 4.0)
|
|
68
|
-
rubocop-ast (>= 1.
|
|
113
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
69
114
|
ruby-progressbar (~> 1.7)
|
|
70
|
-
unicode-display_width (>=
|
|
71
|
-
rubocop-ast (1.
|
|
72
|
-
parser (>= 3.
|
|
73
|
-
rubocop-
|
|
74
|
-
rubocop (
|
|
75
|
-
|
|
115
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
|
116
|
+
rubocop-ast (1.31.2)
|
|
117
|
+
parser (>= 3.3.0.4)
|
|
118
|
+
rubocop-capybara (2.20.0)
|
|
119
|
+
rubocop (~> 1.41)
|
|
120
|
+
rubocop-factory_bot (2.25.1)
|
|
121
|
+
rubocop (~> 1.41)
|
|
122
|
+
rubocop-performance (1.21.0)
|
|
123
|
+
rubocop (>= 1.48.1, < 2.0)
|
|
124
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
76
125
|
rubocop-rake (0.6.0)
|
|
77
126
|
rubocop (~> 1.0)
|
|
78
|
-
rubocop-rspec (2.
|
|
79
|
-
rubocop (~> 1.
|
|
80
|
-
|
|
127
|
+
rubocop-rspec (2.28.0)
|
|
128
|
+
rubocop (~> 1.40)
|
|
129
|
+
rubocop-capybara (~> 2.17)
|
|
130
|
+
rubocop-factory_bot (~> 2.22)
|
|
131
|
+
rubocop-rspec_rails (~> 2.28)
|
|
132
|
+
rubocop-rspec_rails (2.28.1)
|
|
133
|
+
rubocop (~> 1.40)
|
|
134
|
+
ruby-progressbar (1.13.0)
|
|
135
|
+
shellany (0.0.1)
|
|
81
136
|
simplecov (0.21.2)
|
|
82
137
|
docile (~> 1.1)
|
|
83
138
|
simplecov-html (~> 0.11)
|
|
84
139
|
simplecov_json_formatter (~> 0.1)
|
|
85
140
|
simplecov-html (0.12.3)
|
|
86
141
|
simplecov_json_formatter (0.1.4)
|
|
87
|
-
|
|
142
|
+
stringio (3.1.0)
|
|
143
|
+
thor (1.3.1)
|
|
88
144
|
trollop (2.9.10)
|
|
89
|
-
unicode-display_width (2.
|
|
90
|
-
unparser (0.6.
|
|
145
|
+
unicode-display_width (2.5.0)
|
|
146
|
+
unparser (0.6.13)
|
|
91
147
|
diff-lcs (~> 1.3)
|
|
92
|
-
parser (>= 3.
|
|
93
|
-
yaml (0.
|
|
148
|
+
parser (>= 3.3.0)
|
|
149
|
+
yaml (0.3.0)
|
|
94
150
|
yarn (0.1.1)
|
|
95
151
|
parslet (>= 1.2)
|
|
96
152
|
rack (>= 1.3)
|
|
@@ -98,21 +154,23 @@ GEM
|
|
|
98
154
|
|
|
99
155
|
PLATFORMS
|
|
100
156
|
arm64-darwin-21
|
|
157
|
+
arm64-darwin-23
|
|
101
158
|
x86_64-linux
|
|
102
159
|
|
|
103
160
|
DEPENDENCIES
|
|
104
161
|
codecov
|
|
105
162
|
debug (>= 1.0.0)
|
|
163
|
+
guard-rspec
|
|
106
164
|
js_dependency!
|
|
107
165
|
rake (~> 13.0)
|
|
108
166
|
rspec (~> 3.0)
|
|
109
|
-
rspec-parameterized
|
|
167
|
+
rspec-parameterized (~> 1.0)
|
|
110
168
|
rubocop (~> 1.21)
|
|
111
|
-
rubocop-performance
|
|
112
|
-
rubocop-rake
|
|
113
|
-
rubocop-rspec
|
|
169
|
+
rubocop-performance (~> 1.21)
|
|
170
|
+
rubocop-rake (~> 0.6.0)
|
|
171
|
+
rubocop-rspec (~> 2.28)
|
|
114
172
|
simplecov
|
|
115
173
|
yarn
|
|
116
174
|
|
|
117
175
|
BUNDLED WITH
|
|
118
|
-
2.3
|
|
176
|
+
2.5.3
|
data/Guardfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
|
4
|
+
require "guard/rspec/dsl"
|
|
5
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
|
6
|
+
|
|
7
|
+
# Feel free to open issues for suggestions and improvements
|
|
8
|
+
|
|
9
|
+
# RSpec files
|
|
10
|
+
rspec = dsl.rspec
|
|
11
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
12
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
|
13
|
+
watch(rspec.spec_files)
|
|
14
|
+
|
|
15
|
+
# Ruby files
|
|
16
|
+
ruby = dsl.ruby
|
|
17
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
|
18
|
+
end
|
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
|
|
@@ -212,6 +212,13 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
|
212
212
|
|
|
213
213
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
214
214
|
|
|
215
|
+
|
|
216
|
+
### Using guard-rspec
|
|
217
|
+
|
|
218
|
+
```shell
|
|
219
|
+
bundle exec guard
|
|
220
|
+
```
|
|
221
|
+
|
|
215
222
|
## Contributing
|
|
216
223
|
|
|
217
224
|
Bug reports and pull requests are welcome on GitHub at https://github.com/junara/js_dependency. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/js_dependency/blob/main/CODE_OF_CONDUCT.md).
|
data/js_dependency.gemspec
CHANGED
|
@@ -30,15 +30,8 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
31
31
|
spec.require_paths = ["lib"]
|
|
32
32
|
|
|
33
|
-
spec.add_dependency "pathname"
|
|
34
33
|
spec.add_dependency "thor"
|
|
35
34
|
spec.add_dependency "yaml"
|
|
36
|
-
spec.add_development_dependency "rspec"
|
|
37
|
-
spec.add_development_dependency "rspec-parameterized"
|
|
38
|
-
spec.add_development_dependency "rubocop"
|
|
39
|
-
spec.add_development_dependency "rubocop-performance"
|
|
40
|
-
spec.add_development_dependency "rubocop-rake"
|
|
41
|
-
spec.add_development_dependency "rubocop-rspec"
|
|
42
35
|
|
|
43
36
|
# For more information and examples about making a new gem, check out our
|
|
44
37
|
# guide at: https://bundler.io/guides/creating_gem.html
|
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
|
|
@@ -86,7 +87,7 @@ module JsDependency
|
|
|
86
87
|
return nil if obj.nil?
|
|
87
88
|
return obj if obj.is_a?(String)
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
obj.first if obj.is_a?(Array)
|
|
90
91
|
end
|
|
91
92
|
end
|
|
92
93
|
end
|
|
@@ -15,7 +15,15 @@ module JsDependency
|
|
|
15
15
|
list << Regexp.last_match(1)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
scripts += str.gsub(%r{<script.+src=".+">(.+)</script>}m).with_object([]) do |_, list|
|
|
18
|
+
scripts += str.gsub(%r{<script.+src=["'].+["']>(.+)</script>}m).with_object([]) do |_, list|
|
|
19
|
+
list << Regexp.last_match(1)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
scripts += str.gsub(%r{<script.+setup>(.+)</script>}m).with_object([]) do |_, list|
|
|
23
|
+
list << Regexp.last_match(1)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
scripts += str.gsub(%r{<script.+lang=["'][tj]s["']>(.+)</script>}m).with_object([]) do |_, list|
|
|
19
27
|
list << Regexp.last_match(1)
|
|
20
28
|
end
|
|
21
29
|
|
|
@@ -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,13 +10,13 @@ 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
|
|
|
17
17
|
# @return [String]
|
|
18
18
|
def export
|
|
19
|
-
markdown = <<~
|
|
19
|
+
markdown = <<~MAKRDOWNTEXT
|
|
20
20
|
## JsDependency Reports
|
|
21
21
|
|
|
22
22
|
### Orphan modules
|
|
@@ -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
|
metadata
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: js_dependency
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- junara
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-03-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: pathname
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0'
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
27
13
|
- !ruby/object:Gem::Dependency
|
|
28
14
|
name: thor
|
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,90 +38,6 @@ dependencies:
|
|
|
52
38
|
- - ">="
|
|
53
39
|
- !ruby/object:Gem::Version
|
|
54
40
|
version: '0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rspec
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - ">="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: rspec-parameterized
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - ">="
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0'
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - ">="
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0'
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: rubocop
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - ">="
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: '0'
|
|
90
|
-
type: :development
|
|
91
|
-
prerelease: false
|
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
-
requirements:
|
|
94
|
-
- - ">="
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: '0'
|
|
97
|
-
- !ruby/object:Gem::Dependency
|
|
98
|
-
name: rubocop-performance
|
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - ">="
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: '0'
|
|
104
|
-
type: :development
|
|
105
|
-
prerelease: false
|
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
108
|
-
- - ">="
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: '0'
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: rubocop-rake
|
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
|
114
|
-
requirements:
|
|
115
|
-
- - ">="
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: '0'
|
|
118
|
-
type: :development
|
|
119
|
-
prerelease: false
|
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
-
requirements:
|
|
122
|
-
- - ">="
|
|
123
|
-
- !ruby/object:Gem::Version
|
|
124
|
-
version: '0'
|
|
125
|
-
- !ruby/object:Gem::Dependency
|
|
126
|
-
name: rubocop-rspec
|
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
|
128
|
-
requirements:
|
|
129
|
-
- - ">="
|
|
130
|
-
- !ruby/object:Gem::Version
|
|
131
|
-
version: '0'
|
|
132
|
-
type: :development
|
|
133
|
-
prerelease: false
|
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
-
requirements:
|
|
136
|
-
- - ">="
|
|
137
|
-
- !ruby/object:Gem::Version
|
|
138
|
-
version: '0'
|
|
139
41
|
description: Analyze dependency using import for JavaScript.
|
|
140
42
|
email:
|
|
141
43
|
- jun5araki@gmail.com
|
|
@@ -152,6 +54,7 @@ files:
|
|
|
152
54
|
- CODE_OF_CONDUCT.md
|
|
153
55
|
- Gemfile
|
|
154
56
|
- Gemfile.lock
|
|
57
|
+
- Guardfile
|
|
155
58
|
- LICENSE.txt
|
|
156
59
|
- README.md
|
|
157
60
|
- Rakefile
|
|
@@ -200,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
200
103
|
- !ruby/object:Gem::Version
|
|
201
104
|
version: '0'
|
|
202
105
|
requirements: []
|
|
203
|
-
rubygems_version: 3.3
|
|
106
|
+
rubygems_version: 3.5.3
|
|
204
107
|
signing_key:
|
|
205
108
|
specification_version: 4
|
|
206
109
|
summary: Analyze dependency using import for JavaScript.
|