js_dependency 0.3.0 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df7ebbe8ac02b295b1ec9d1f9829e7e94868933af1c935f1f5094f4e74f1e876
4
- data.tar.gz: 388b4b017e4b1986b86f221a0bdc19490a9a9c8ca13eaea0847d032e094d6c31
3
+ metadata.gz: d117ec8b831e67223b243ed652261885f1bbffc4734f93ed2d386166d16d31e2
4
+ data.tar.gz: '008fe6a337a677fa62348ca4d76766f02d72affc2b851126f7f22cba45c32c4f'
5
5
  SHA512:
6
- metadata.gz: 753bccf5874fbe9edd2784d6a999393c13bac53d1da213c861c4d6c4f93fa48d70c6c7bebacaa863aa894e3a38174f2d3a547809c8ee1d6181f793d76d949ab6
7
- data.tar.gz: e449209ee8d7eaa9328db4b94cd28ef61352ace72e776d4297572a385d45bc8e2f5267dd05a638797f04b84268efd6cb61784ca6f4df939053d7172f7d7da8b0
6
+ metadata.gz: 891fdc5a595134a7724a4f9bdf061ac6290025e3e624d1f33d362ba74ef22d696a1dd3355f6befdd8a11661a07b531eef7877ff9271b4f4bb1ca01dd83f3c31e
7
+ data.tar.gz: 574b0b04401c6b3d4b7a510cb0dbbe972a0539d8e052bed48395cc4c7c1f3ec656bf314f57229e6ac79a2524fbacadf89825d8b30fc410e8e6acb3efd50b438e
data/.rubocop_todo.yml CHANGED
@@ -1,22 +1,22 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2022-07-24 12:55:17 UTC using RuboCop version 1.31.2.
3
+ # on 2022-07-26 00:36:01 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
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 4
9
+ # Offense count: 7
10
10
  # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
11
11
  Metrics/AbcSize:
12
- Max: 37
12
+ Max: 41
13
13
 
14
- # Offense count: 4
14
+ # Offense count: 5
15
15
  # Configuration parameters: IgnoredMethods.
16
16
  Metrics/CyclomaticComplexity:
17
- Max: 15
17
+ Max: 16
18
18
 
19
- # Offense count: 7
19
+ # Offense count: 9
20
20
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
21
21
  Metrics/MethodLength:
22
22
  Max: 26
@@ -26,25 +26,19 @@ Metrics/MethodLength:
26
26
  Metrics/ParameterLists:
27
27
  Max: 9
28
28
 
29
- # Offense count: 4
29
+ # Offense count: 5
30
30
  # Configuration parameters: IgnoredMethods.
31
31
  Metrics/PerceivedComplexity:
32
- Max: 16
33
-
34
- # Offense count: 1
35
- # This cop supports safe autocorrection (--autocorrect).
36
- Style/IfUnlessModifier:
37
- Exclude:
38
- - 'lib/js_dependency/index_creator.rb'
32
+ Max: 17
39
33
 
40
34
  # Offense count: 1
41
35
  Style/MultilineBlockChain:
42
36
  Exclude:
43
37
  - 'lib/js_dependency/mermaid/root.rb'
44
38
 
45
- # Offense count: 1
39
+ # Offense count: 6
46
40
  # This cop supports safe autocorrection (--autocorrect).
47
41
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
48
42
  # URISchemes: http, https
49
43
  Layout/LineLength:
50
- Max: 182
44
+ Max: 183
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.3] - 2022-07-26
4
+
5
+ - Add special style to target_paths in mermaid output CLI.
6
+
7
+ ## [0.3.2] - 2022-07-26
8
+
9
+ - Multiple excludes option for CLI.
10
+
11
+ ## [0.3.1] - 2022-07-25
12
+
13
+ - Multiple target paths for JsDependency.export and export_mermaid CLI.
14
+
3
15
  ## [0.3.0] - 2022-07-24
4
16
 
5
17
  - Stable mermaid support.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- js_dependency (0.3.0)
4
+ js_dependency (0.3.3)
5
5
  pathname
6
6
  thor
7
7
  yaml
data/README.md CHANGED
@@ -49,10 +49,24 @@ exclude -> -e
49
49
 
50
50
  #### Export Mermaid Format
51
51
 
52
+ ##### Single target path
53
+
52
54
  ```shell
53
55
  js_dependency -s ./src -t ./src/App.vue -o ./mermaid.txt -c 2 -p 2 -n 1
54
56
  ```
55
57
 
58
+ ##### Multiple target paths
59
+
60
+ ```shell
61
+ js_dependency -s ./src -t ./src/App.vue ./src/components/Sub.vue -o ./mermaid.txt -c 2 -p 2 -n 1
62
+ ```
63
+
64
+ ##### Exclude path which iclude exclude words `-e` from output
65
+
66
+ ```shell
67
+ js_dependency -s ./src -t ./src/App.vue -o ./mermaid.txt -c 2 -p 2 -n 1 -e excludeWord1 excludeWord2
68
+ ```
69
+
56
70
  #### Export parents components list
57
71
 
58
72
  ```shell
@@ -9,12 +9,12 @@ module JsDependency
9
9
 
10
10
  desc "export_mermaid", "Output mermaid flowchart string."
11
11
  option :src_path, type: :string, aliases: "-s", desc: "Root folder."
12
- option :target_path, type: :string, aliases: "-t", desc: "Target file that you want to analyze."
12
+ option :target_paths, type: :array, aliases: "-t", desc: "Target file that you want to analyze."
13
13
  option :output_path, type: :string, aliases: "-o", desc: "Output file path"
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"
17
+ option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
18
18
 
19
19
  def export_mermaid
20
20
  pathname = Pathname.new(".js_dependency.yml")
@@ -22,21 +22,21 @@ module JsDependency
22
22
  args = YAML.safe_load(pathname.read) if pathname.exist?
23
23
 
24
24
  src_path = options[:src_path] || args["src_path"]
25
- target_path = options[:target_path] || args["target_path"]
25
+ target_paths = options[:target_paths] || (args["target_path"].is_a?(String) ? [args["target_path"]] : args["target_path"])
26
26
  child_analyze_level = options[:child_analyze_level] || args["child_analyze_level"] || 2
27
27
  parent_analyze_level = options[:parent_analyze_level] || args["parent_analyze_level"] || 2
28
28
  output_path = options[:output_path] || args["output_path"] || nil
29
29
  alias_paths = args["alias_paths"] || nil
30
30
  name_level = options[:name_level] || args["name_level"] || 1
31
- excludes = if options[:exclude]
32
- [options[:exclude]]
31
+ excludes = if options[:excludes].length.positive?
32
+ options[:excludes]
33
33
  elsif args["excludes"]
34
34
  args["excludes"]
35
35
  end
36
36
 
37
37
  str = JsDependency.export_mermaid(
38
38
  src_path,
39
- target_path,
39
+ target_paths,
40
40
  child_analyze_level: child_analyze_level,
41
41
  parent_analyze_level: parent_analyze_level,
42
42
  output_path: output_path,
@@ -53,7 +53,7 @@ module JsDependency
53
53
  option :target_path, type: :string, aliases: "-t", desc: "Target file that you want to analyze."
54
54
  option :output_path, type: :string, aliases: "-o", desc: "Output file path"
55
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"
56
+ option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
57
57
 
58
58
  def parents
59
59
  pathname = Pathname.new(".js_dependency.yml")
@@ -65,8 +65,8 @@ module JsDependency
65
65
  parent_analyze_level = options[:parent_analyze_level] || args["parent_analyze_level"] || 1
66
66
  output_path = options[:output_path] || args["output_path"] || nil
67
67
  alias_paths = args["alias_paths"] || nil
68
- excludes = if options[:exclude]
69
- [options[:exclude]]
68
+ excludes = if options[:excludes].length.positive?
69
+ options[:excludes]
70
70
  elsif args["excludes"]
71
71
  args["excludes"]
72
72
  end
@@ -88,7 +88,7 @@ module JsDependency
88
88
  option :target_path, type: :string, aliases: "-t", desc: "Target file that you want to analyze."
89
89
  option :output_path, type: :string, aliases: "-o", desc: "Output file path"
90
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"
91
+ option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
92
92
 
93
93
  def children
94
94
  pathname = Pathname.new(".js_dependency.yml")
@@ -100,8 +100,8 @@ module JsDependency
100
100
  child_analyze_level = options[:child_analyze_level] || args["child_analyze_level"] || 1
101
101
  output_path = options[:output_path] || args["output_path"] || nil
102
102
  alias_paths = args["alias_paths"] || nil
103
- excludes = if options[:exclude]
104
- [options[:exclude]]
103
+ excludes = if options[:excludes].length.positive?
104
+ options[:excludes]
105
105
  elsif args["excludes"]
106
106
  args["excludes"]
107
107
  end
@@ -17,6 +17,8 @@ module JsDependency
17
17
  scripts.uniq.sort.join("\n")
18
18
  end
19
19
 
20
+ # @param [String] str
21
+ # @return [String]
20
22
  def self.call(str)
21
23
  new(str).call
22
24
  end
@@ -7,11 +7,16 @@ require_relative "pathname_utility"
7
7
 
8
8
  module JsDependency
9
9
  class IndexCreator
10
+ # @param [String] src
11
+ # @param [Array<String>] alias_paths
10
12
  def initialize(src, alias_paths: nil)
11
13
  @src = src
12
14
  @alias_paths = alias_paths
13
15
  end
14
16
 
17
+ # @param [String] src
18
+ # @param [Array<String>] alias_paths
19
+ # @param [Array<String>] excludes
15
20
  def self.call(src, alias_paths: nil, excludes: nil)
16
21
  index = new(src, alias_paths: alias_paths).call
17
22
  index.transform_values do |value|
@@ -19,6 +24,7 @@ module JsDependency
19
24
  end
20
25
  end
21
26
 
27
+ # @return [Hash]
22
28
  def call
23
29
  src_pathname = Pathname.new(@src).relative? ? Pathname.new(@src).realpath : Pathname.new(@src)
24
30
  raise Error, "#{@src} is not directory." unless src_pathname.directory?
@@ -31,6 +37,9 @@ module JsDependency
31
37
 
32
38
  private
33
39
 
40
+ # @param [Pathname] src_pathname
41
+ # @param [Array<String>] alias_paths
42
+ # @return [Hash]
34
43
  def index_from(src_pathname, alias_paths)
35
44
  pattern = %w[**/*.vue **/*.js **/*.jsx]
36
45
 
@@ -39,11 +48,15 @@ module JsDependency
39
48
 
40
49
  obj[component_pathname.to_s] = import_pathnames.map(&:to_s)
41
50
  if component_pathname.basename.to_s == "index.js"
42
- obj[component_pathname.dirname.to_s] = import_pathnames.map(&:to_s)
51
+ obj[component_pathname.dirname.to_s] =
52
+ import_pathnames.map(&:to_s)
43
53
  end
44
54
  end
45
55
  end
46
56
 
57
+ # @param [Pathname] component_pathname
58
+ # @param [Array<String>] alias_paths
59
+ # @return [Array<Pathname>]
47
60
  def import_pathnames_from(component_pathname, alias_paths)
48
61
  component_dirname = component_pathname.dirname
49
62
  script_str = extract_script_string(component_pathname)
@@ -52,6 +65,10 @@ module JsDependency
52
65
  end
53
66
  end
54
67
 
68
+ # @param [String] import_path
69
+ # @param [Array<String>] alias_paths
70
+ # @param [Pathname] component_dirname
71
+ # @return [Pathname]
55
72
  def standardize_path(import_path, alias_paths, component_dirname)
56
73
  import_pathname = Pathname.new(replace_path_alias(import_path, alias_paths))
57
74
 
@@ -67,6 +84,8 @@ module JsDependency
67
84
  import_pathname.cleanpath
68
85
  end
69
86
 
87
+ # @param [Pathname] pathname
88
+ # @return [String]
70
89
  def extract_script_string(pathname)
71
90
  str = pathname.read
72
91
  extname = pathname.extname
@@ -75,6 +94,9 @@ module JsDependency
75
94
  JsDependency::ExtractScriptTag.call(str)
76
95
  end
77
96
 
97
+ # @param [String] path
98
+ # @param [Array<String>] alias_paths
99
+ # @return [String]
78
100
  def replace_path_alias(path, alias_paths)
79
101
  JsDependency::ReplacePathAlias.call(path, alias_paths)
80
102
  end
@@ -1,31 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../pathname_utility"
4
+
3
5
  module JsDependency
4
6
  module Mermaid
5
7
  class NodesLink
6
8
  attr_reader :parent, :child
7
9
 
10
+ # @param [String] parent
11
+ # @param [String] child
8
12
  def initialize(parent, child)
9
13
  @parent = Pathname.new(parent)
10
14
  @child = Pathname.new(child)
11
15
  end
12
16
 
17
+ # @param [Integer] level
18
+ # @return [String]
13
19
  def parent_module_name(level = 0)
14
20
  mermaid_str(@parent, level)
15
21
  end
16
22
 
23
+ # @param [Integer] level
24
+ # @return [String]
17
25
  def child_module_name(level = 0)
18
26
  mermaid_str(@child, level)
19
27
  end
20
28
 
21
29
  private
22
30
 
31
+ # @param [Pathname] pathname
32
+ # @param [Integer] level
23
33
  def mermaid_str(pathname, level = 0)
24
34
  "#{parse(pathname).join("_")}[\"#{parse(pathname, level).join("/")}\"]"
25
35
  end
26
36
 
37
+ # @param [Pathname] pathname
38
+ # @param [Integer] level
27
39
  def parse(pathname, level = -1)
28
- pathname.each_filename.with_object([]) { |filename, array| array << filename }.reverse[0..level].reverse
40
+ JsDependency::PathnameUtility.parse(pathname, level)
29
41
  end
30
42
  end
31
43
  end
@@ -6,16 +6,34 @@ module JsDependency
6
6
  class Root
7
7
  attr_accessor :orientation
8
8
 
9
+ # @param [String] orientation
9
10
  def initialize(orientation = "LR")
10
11
  @orientation = orientation
11
12
  @list = []
12
13
  end
13
14
 
15
+ # @param [String] parent
16
+ # @param [String] child
14
17
  def add(parent, child)
15
18
  @list << NodesLink.new(parent, child)
16
19
  end
17
20
 
21
+ # @param [Integer] name_level
22
+ # @param [nil, String] src_path
23
+ # @return [String]
18
24
  def export(name_level: 1, src_path: nil)
25
+ ([export_header] + export_nodes(name_level: name_level, src_path: src_path)).join("\n")
26
+ end
27
+
28
+ # @return [String]
29
+ def export_header
30
+ "flowchart #{orientation}"
31
+ end
32
+
33
+ # @param [Integer] name_level
34
+ # @param [nil, String] src_path
35
+ # @return [Array<String>]
36
+ def export_nodes(name_level: 1, src_path: nil)
19
37
  nodes_links = if src_path
20
38
  src_pathname = Pathname.new(src_path).realpath
21
39
  @list.map do |nodes_link|
@@ -25,12 +43,11 @@ module JsDependency
25
43
  else
26
44
  @list
27
45
  end
28
- str = "flowchart #{orientation}\n"
29
- str + nodes_links.uniq do |link|
46
+ nodes_links.uniq do |link|
30
47
  "#{link.parent}__#{link.child}"
31
48
  end.sort_by { |link| "#{link.parent}__#{link.child}" }.map do |link|
32
49
  "#{link.parent_module_name(name_level)} --> #{link.child_module_name(name_level)}"
33
- end.join("\n")
50
+ end
34
51
  end
35
52
  end
36
53
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module JsDependency
4
4
  module PathnameUtility
5
+ # @param [Pathname] pathname
6
+ # @return [Pathname]
5
7
  def self.complement_extname(pathname)
6
8
  return pathname if pathname.exist? || pathname.extname != ""
7
9
 
@@ -14,6 +16,8 @@ module JsDependency
14
16
  pathname
15
17
  end
16
18
 
19
+ # @param [String] target_path
20
+ # @return [Pathname]
17
21
  def self.to_target_pathname(target_path)
18
22
  if Pathname.new(target_path).relative? && Pathname.new(target_path).exist?
19
23
  Pathname.new(target_path).realpath
@@ -21,5 +25,11 @@ module JsDependency
21
25
  Pathname.new(target_path)
22
26
  end
23
27
  end
28
+
29
+ # @param [Pathname] pathname
30
+ # @param [Integer] level
31
+ def self.parse(pathname, level = -1)
32
+ pathname.each_filename.with_object([]) { |filename, array| array << filename }.reverse[0..level].reverse
33
+ end
24
34
  end
25
35
  end
@@ -36,6 +36,7 @@ module JsDependency
36
36
  str
37
37
  end
38
38
 
39
+ # @return [Array<String>]
39
40
  def safe_list
40
41
  ["@rails/ujs"]
41
42
  end
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "pathname_utility"
3
4
  module JsDependency
4
5
  class TargetPathname
6
+ attr_accessor :color_css, :font_size_css
7
+
5
8
  # @param [String] target_path
6
9
  def initialize(target_path)
7
10
  @pathname = if Pathname.new(target_path).relative? && Pathname.new(target_path).exist?
@@ -9,6 +12,8 @@ module JsDependency
9
12
  else
10
13
  Pathname.new(target_path)
11
14
  end
15
+ @color_css = "#f9f"
16
+ @font_size_css = "4px"
12
17
  end
13
18
 
14
19
  # @param [Integer] analyze_level
@@ -45,8 +50,19 @@ module JsDependency
45
50
  end
46
51
  end
47
52
 
53
+ def mermaid_style(src_path)
54
+ src_pathname = Pathname.new(src_path).realpath
55
+ export_style(parse(@pathname.exist? ? @pathname.relative_path_from(src_pathname) : @pathname).join("_"))
56
+ end
57
+
48
58
  private
49
59
 
60
+ # @param [String] path
61
+ # @return [String]
62
+ def export_style(path)
63
+ "style #{path} stroke:#{@color_css},stroke-width:#{@font_size_css}"
64
+ end
65
+
50
66
  # @param [String] target_path
51
67
  # @param [Hash] index
52
68
  # @return [Array]
@@ -63,12 +79,16 @@ module JsDependency
63
79
  index[target_path] || []
64
80
  end
65
81
 
82
+ # @param [String] target_path
83
+ # @return [Pathname]
66
84
  def to_target_pathname(target_path)
67
- if Pathname.new(target_path).relative? && Pathname.new(target_path).exist?
68
- Pathname.new(target_path).realpath
69
- else
70
- Pathname.new(target_path)
71
- end
85
+ JsDependency::PathnameUtility.to_target_pathname(target_path)
86
+ end
87
+
88
+ # @param [Pathname] pathname
89
+ # @param [Integer] level
90
+ def parse(pathname, level = -1)
91
+ JsDependency::PathnameUtility.parse(pathname, level)
72
92
  end
73
93
  end
74
94
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsDependency
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.3"
5
5
  end
data/lib/js_dependency.rb CHANGED
@@ -19,7 +19,7 @@ module JsDependency
19
19
  end
20
20
 
21
21
  # @param [String] src_path
22
- # @param [String] target_path
22
+ # @param [Array<String>] target_paths
23
23
  # @param [String] orientation
24
24
  # @param [Hash, nil] alias_paths
25
25
  # @param [Integer] child_analyze_level
@@ -28,23 +28,28 @@ module JsDependency
28
28
  # @param [String, nil] output_path
29
29
  # @param [Array, nil] excludes
30
30
  # @return [String]
31
- 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)
31
+ def self.export_mermaid(src_path, target_paths, orientation: "LR", alias_paths: nil, child_analyze_level: 1, parent_analyze_level: 1, name_level: 1, output_path: nil, excludes: nil)
32
32
  output_pathname = Pathname.new(output_path) if output_path
33
33
  index = JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths, excludes: excludes)
34
34
 
35
- target_pathname = JsDependency::TargetPathname.new(target_path)
36
-
37
- mermaid_root = JsDependency::Mermaid::Root.new(orientation)
35
+ nodes = []
36
+ styles = []
37
+ target_paths.each do |target_path|
38
+ target_pathname = JsDependency::TargetPathname.new(target_path)
39
+ styles += [target_pathname.mermaid_style(src_path)]
40
+ mermaid_root = JsDependency::Mermaid::Root.new(orientation)
38
41
 
39
- target_pathname.each_parent_path(parent_analyze_level, index) do |parent_path, child_path|
40
- mermaid_root.add(parent_path, child_path)
41
- end
42
+ target_pathname.each_parent_path(parent_analyze_level, index) do |parent_path, child_path|
43
+ mermaid_root.add(parent_path, child_path)
44
+ end
42
45
 
43
- target_pathname.each_child_path(child_analyze_level, index) do |parent_path, child_path|
44
- mermaid_root.add(parent_path, child_path)
46
+ target_pathname.each_child_path(child_analyze_level, index) do |parent_path, child_path|
47
+ mermaid_root.add(parent_path, child_path)
48
+ end
49
+ nodes += mermaid_root.export_nodes(name_level: name_level, src_path: src_path)
45
50
  end
46
51
 
47
- output = mermaid_root.export(name_level: name_level, src_path: src_path)
52
+ output = (["flowchart LR"] + nodes.uniq + styles.uniq).join("\n")
48
53
  output_pathname&.write(output)
49
54
  output
50
55
  end
@@ -62,12 +67,12 @@ module JsDependency
62
67
  index = JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths, excludes: excludes)
63
68
 
64
69
  target_pathname = JsDependency::TargetPathname.new(target_path)
65
- list = []
70
+ paths = []
66
71
  target_pathname.each_parent_path(parent_analyze_level, index) do |parent_path, _child_path|
67
- list << parent_path
72
+ paths << parent_path
68
73
  end
69
- output = list.uniq.sort.map do |path|
70
- Pathname.new(path).relative_path_from(Pathname.new(src_path).realpath.to_s)
74
+ output = paths.uniq.sort.map do |path|
75
+ Pathname.new(path).exist? ? Pathname.new(path).relative_path_from(Pathname.new(src_path).realpath.to_s).to_s : Pathname.new(path).to_s
71
76
  end
72
77
  output_pathname&.write(output.sort.join("\n"))
73
78
  output
@@ -86,12 +91,12 @@ module JsDependency
86
91
  index = JsDependency::IndexCreator.call(src_path, alias_paths: alias_paths, excludes: excludes)
87
92
 
88
93
  target_pathname = JsDependency::TargetPathname.new(target_path)
89
- list = []
94
+ paths = []
90
95
  target_pathname.each_child_path(child_analyze_level, index) do |_parent_path, child_path|
91
- list << child_path
96
+ paths << child_path
92
97
  end
93
- output = list.uniq.sort.map do |path|
94
- Pathname.new(path).relative_path_from(Pathname.new(src_path).realpath.to_s)
98
+ output = paths.uniq.sort.map do |path|
99
+ Pathname.new(path).exist? ? Pathname.new(path).relative_path_from(Pathname.new(src_path).realpath.to_s).to_s : Pathname.new(path).to_s
95
100
  end
96
101
  output_pathname&.write(output.sort.join("\n"))
97
102
  output
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.0
4
+ version: 0.3.3
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-24 00:00:00.000000000 Z
11
+ date: 2022-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pathname