js_dependency 0.3.7 → 0.3.8
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/.rubocop_todo.yml +8 -13
 - data/CHANGELOG.md +6 -0
 - data/Gemfile.lock +1 -1
 - data/lib/js_dependency/cli.rb +58 -119
 - data/lib/js_dependency/cli_utils/config.rb +28 -0
 - data/lib/js_dependency/cli_utils/yaml.rb +39 -0
 - data/lib/js_dependency/version.rb +1 -1
 - data/lib/js_dependency.rb +2 -0
 - metadata +3 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a376c442837e1a87365b91b1f13b46e048f271078e691425350237066e1f567d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 606813cc029e62b21c7073409c8312c27104adada8b3e3e33877075fde15d2cc
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: da8c831e0eec9e3251597874af4b067efb2079c651e46341beb5a8f34b70b857c2960f134cd0db6fc8e8cf380090b70d87732891d8161ecfbdfe7756179d7cba
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3513921cc2068f220fcd5ca001d59339a361e36fe76c9bf9ca5f4bc4f5ba5cf91ac0f220c72814cad02a44e6ed9ddc11421721a6d20d1f1a010b7bec5422893f
         
     | 
    
        data/.rubocop_todo.yml
    CHANGED
    
    | 
         @@ -1,37 +1,32 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # This configuration was generated by
         
     | 
| 
       2 
2 
     | 
    
         
             
            # `rubocop --auto-gen-config`
         
     | 
| 
       3 
     | 
    
         
            -
            # on 2022-08-11  
     | 
| 
      
 3 
     | 
    
         
            +
            # on 2022-08-11 12:19:56 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
         
     | 
| 
       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:  
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            # Offense count: 1
         
     | 
| 
       15 
     | 
    
         
            -
            # Configuration parameters: CountComments, CountAsOne.
         
     | 
| 
       16 
     | 
    
         
            -
            Metrics/ClassLength:
         
     | 
| 
       17 
     | 
    
         
            -
              Max: 129
         
     | 
| 
      
 12 
     | 
    
         
            +
              Max: 31
         
     | 
| 
       18 
13 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
            # Offense count:  
     | 
| 
      
 14 
     | 
    
         
            +
            # Offense count: 3
         
     | 
| 
       20 
15 
     | 
    
         
             
            # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
         
     | 
| 
       21 
16 
     | 
    
         
             
            Metrics/CyclomaticComplexity:
         
     | 
| 
       22 
17 
     | 
    
         
             
              Max: 18
         
     | 
| 
       23 
18 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
            # Offense count:  
     | 
| 
      
 19 
     | 
    
         
            +
            # Offense count: 8
         
     | 
| 
       25 
20 
     | 
    
         
             
            # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
         
     | 
| 
       26 
21 
     | 
    
         
             
            Metrics/MethodLength:
         
     | 
| 
       27 
     | 
    
         
            -
              Max:  
     | 
| 
      
 22 
     | 
    
         
            +
              Max: 19
         
     | 
| 
       28 
23 
     | 
    
         | 
| 
       29 
24 
     | 
    
         
             
            # Offense count: 3
         
     | 
| 
       30 
25 
     | 
    
         
             
            # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
         
     | 
| 
       31 
26 
     | 
    
         
             
            Metrics/ParameterLists:
         
     | 
| 
       32 
27 
     | 
    
         
             
              Max: 9
         
     | 
| 
       33 
28 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
            # Offense count:  
     | 
| 
      
 29 
     | 
    
         
            +
            # Offense count: 3
         
     | 
| 
       35 
30 
     | 
    
         
             
            # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
         
     | 
| 
       36 
31 
     | 
    
         
             
            Metrics/PerceivedComplexity:
         
     | 
| 
       37 
32 
     | 
    
         
             
              Max: 19
         
     | 
| 
         @@ -41,7 +36,7 @@ Style/MultilineBlockChain: 
     | 
|
| 
       41 
36 
     | 
    
         
             
              Exclude:
         
     | 
| 
       42 
37 
     | 
    
         
             
                - 'lib/js_dependency/mermaid/root.rb'
         
     | 
| 
       43 
38 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
            # Offense count:  
     | 
| 
      
 39 
     | 
    
         
            +
            # Offense count: 6
         
     | 
| 
       45 
40 
     | 
    
         
             
            # This cop supports safe autocorrection (--autocorrect).
         
     | 
| 
       46 
41 
     | 
    
         
             
            # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
         
     | 
| 
       47 
42 
     | 
    
         
             
            # URISchemes: http, https
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/js_dependency/cli.rb
    CHANGED
    
    | 
         @@ -8,152 +8,91 @@ module JsDependency 
     | 
|
| 
       8 
8 
     | 
    
         
             
                default_command :export_mermaid
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                desc "export_mermaid", "Output mermaid flowchart string."
         
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
       12 
     | 
    
         
            -
                 
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
       16 
     | 
    
         
            -
                 
     | 
| 
       17 
     | 
    
         
            -
                 
     | 
| 
      
 11 
     | 
    
         
            +
                method_option :src_path, type: :string, aliases: "-s", desc: "Root folder."
         
     | 
| 
      
 12 
     | 
    
         
            +
                method_option :target_paths, type: :array, aliases: "-t", desc: "Target file that you want to analyze."
         
     | 
| 
      
 13 
     | 
    
         
            +
                method_option :output_path, type: :string, aliases: "-o", desc: "Output file path"
         
     | 
| 
      
 14 
     | 
    
         
            +
                method_option :child_analyze_level, type: :numeric, aliases: "-c", desc: "Output level of child dependency"
         
     | 
| 
      
 15 
     | 
    
         
            +
                method_option :parent_analyze_level, type: :numeric, aliases: "-p", desc: "Output level of parent dependency"
         
     | 
| 
      
 16 
     | 
    
         
            +
                method_option :name_level, type: :numeric, aliases: "-n", desc: "Output name level"
         
     | 
| 
      
 17 
     | 
    
         
            +
                method_option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                def export_mermaid
         
     | 
| 
       20 
     | 
    
         
            -
                   
     | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
       22 
     | 
    
         
            -
                   
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                  excludes = if options[:excludes]&.length&.positive?
         
     | 
| 
       32 
     | 
    
         
            -
                               options[:excludes]
         
     | 
| 
       33 
     | 
    
         
            -
                             elsif args["excludes"]
         
     | 
| 
       34 
     | 
    
         
            -
                               args["excludes"]
         
     | 
| 
       35 
     | 
    
         
            -
                             end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                  str = JsDependency.export_mermaid(
         
     | 
| 
       38 
     | 
    
         
            -
                    src_path,
         
     | 
| 
       39 
     | 
    
         
            -
                    target_paths,
         
     | 
| 
       40 
     | 
    
         
            -
                    child_analyze_level: child_analyze_level,
         
     | 
| 
       41 
     | 
    
         
            -
                    parent_analyze_level: parent_analyze_level,
         
     | 
| 
       42 
     | 
    
         
            -
                    output_path: output_path,
         
     | 
| 
       43 
     | 
    
         
            -
                    alias_paths: alias_paths,
         
     | 
| 
       44 
     | 
    
         
            -
                    name_level: name_level,
         
     | 
| 
       45 
     | 
    
         
            -
                    excludes: excludes
         
     | 
| 
      
 20 
     | 
    
         
            +
                  args = JsDependency::CliUtils::Yaml.new.args
         
     | 
| 
      
 21 
     | 
    
         
            +
                  config = JsDependency::CliUtils::Config.new(options, args)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  puts JsDependency.export_mermaid(
         
     | 
| 
      
 23 
     | 
    
         
            +
                    config.src_path,
         
     | 
| 
      
 24 
     | 
    
         
            +
                    config.target_paths,
         
     | 
| 
      
 25 
     | 
    
         
            +
                    child_analyze_level: config.child_analyze_level,
         
     | 
| 
      
 26 
     | 
    
         
            +
                    parent_analyze_level: config.parent_analyze_level,
         
     | 
| 
      
 27 
     | 
    
         
            +
                    output_path: config.output_path,
         
     | 
| 
      
 28 
     | 
    
         
            +
                    alias_paths: config.alias_paths,
         
     | 
| 
      
 29 
     | 
    
         
            +
                    name_level: config.name_level,
         
     | 
| 
      
 30 
     | 
    
         
            +
                    excludes: config.excludes
         
     | 
| 
       46 
31 
     | 
    
         
             
                  )
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                  puts str
         
     | 
| 
       49 
32 
     | 
    
         
             
                end
         
     | 
| 
       50 
33 
     | 
    
         | 
| 
       51 
34 
     | 
    
         
             
                desc "parents", "export parents list"
         
     | 
| 
       52 
     | 
    
         
            -
                 
     | 
| 
       53 
     | 
    
         
            -
                 
     | 
| 
       54 
     | 
    
         
            -
                 
     | 
| 
       55 
     | 
    
         
            -
                 
     | 
| 
       56 
     | 
    
         
            -
                 
     | 
| 
      
 35 
     | 
    
         
            +
                method_option :src_path, type: :string, aliases: "-s", desc: "Root folder."
         
     | 
| 
      
 36 
     | 
    
         
            +
                method_option :target_path, type: :string, aliases: "-t", desc: "Target file that you want to analyze."
         
     | 
| 
      
 37 
     | 
    
         
            +
                method_option :output_path, type: :string, aliases: "-o", desc: "Output file path"
         
     | 
| 
      
 38 
     | 
    
         
            +
                method_option :parent_analyze_level, type: :numeric, aliases: "-p", desc: "Output level of parent dependency"
         
     | 
| 
      
 39 
     | 
    
         
            +
                method_option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
         
     | 
| 
       57 
40 
     | 
    
         | 
| 
       58 
41 
     | 
    
         
             
                def parents
         
     | 
| 
       59 
     | 
    
         
            -
                   
     | 
| 
       60 
     | 
    
         
            -
                   
     | 
| 
       61 
     | 
    
         
            -
                   
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                  excludes = if options[:excludes]&.length&.positive?
         
     | 
| 
       69 
     | 
    
         
            -
                               options[:excludes]
         
     | 
| 
       70 
     | 
    
         
            -
                             elsif args["excludes"]
         
     | 
| 
       71 
     | 
    
         
            -
                               args["excludes"]
         
     | 
| 
       72 
     | 
    
         
            -
                             end
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                  str = JsDependency.parents(
         
     | 
| 
       75 
     | 
    
         
            -
                    src_path,
         
     | 
| 
       76 
     | 
    
         
            -
                    target_path,
         
     | 
| 
       77 
     | 
    
         
            -
                    parent_analyze_level: parent_analyze_level,
         
     | 
| 
       78 
     | 
    
         
            -
                    output_path: output_path,
         
     | 
| 
       79 
     | 
    
         
            -
                    alias_paths: alias_paths,
         
     | 
| 
       80 
     | 
    
         
            -
                    excludes: excludes
         
     | 
| 
      
 42 
     | 
    
         
            +
                  args = JsDependency::CliUtils::Yaml.new.args
         
     | 
| 
      
 43 
     | 
    
         
            +
                  config = JsDependency::CliUtils::Config.new(options, args)
         
     | 
| 
      
 44 
     | 
    
         
            +
                  puts JsDependency.parents(
         
     | 
| 
      
 45 
     | 
    
         
            +
                    config.src_path,
         
     | 
| 
      
 46 
     | 
    
         
            +
                    config.target_path,
         
     | 
| 
      
 47 
     | 
    
         
            +
                    parent_analyze_level: config.parent_analyze_level,
         
     | 
| 
      
 48 
     | 
    
         
            +
                    output_path: config.output_path,
         
     | 
| 
      
 49 
     | 
    
         
            +
                    alias_paths: config.alias_paths,
         
     | 
| 
      
 50 
     | 
    
         
            +
                    excludes: config.excludes
         
     | 
| 
       81 
51 
     | 
    
         
             
                  ).join("\n")
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
                  puts str
         
     | 
| 
       84 
52 
     | 
    
         
             
                end
         
     | 
| 
       85 
53 
     | 
    
         | 
| 
       86 
54 
     | 
    
         
             
                desc "children", "export children list"
         
     | 
| 
       87 
     | 
    
         
            -
                 
     | 
| 
       88 
     | 
    
         
            -
                 
     | 
| 
       89 
     | 
    
         
            -
                 
     | 
| 
       90 
     | 
    
         
            -
                 
     | 
| 
       91 
     | 
    
         
            -
                 
     | 
| 
      
 55 
     | 
    
         
            +
                method_option :src_path, type: :string, aliases: "-s", desc: "Root folder."
         
     | 
| 
      
 56 
     | 
    
         
            +
                method_option :target_path, type: :string, aliases: "-t", desc: "Target file that you want to analyze."
         
     | 
| 
      
 57 
     | 
    
         
            +
                method_option :output_path, type: :string, aliases: "-o", desc: "Output file path"
         
     | 
| 
      
 58 
     | 
    
         
            +
                method_option :child_analyze_level, type: :numeric, aliases: "-c", desc: "Output level of child dependency"
         
     | 
| 
      
 59 
     | 
    
         
            +
                method_option :excludes, type: :array, aliases: "-e", desc: "Exclude the word that is included in the path"
         
     | 
| 
       92 
60 
     | 
    
         | 
| 
       93 
61 
     | 
    
         
             
                def children
         
     | 
| 
       94 
     | 
    
         
            -
                   
     | 
| 
       95 
     | 
    
         
            -
                   
     | 
| 
       96 
     | 
    
         
            -
                   
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
                  excludes = if options[:excludes]&.length&.positive?
         
     | 
| 
       104 
     | 
    
         
            -
                               options[:excludes]
         
     | 
| 
       105 
     | 
    
         
            -
                             elsif args["excludes"]
         
     | 
| 
       106 
     | 
    
         
            -
                               args["excludes"]
         
     | 
| 
       107 
     | 
    
         
            -
                             end
         
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
                  str = JsDependency.children(
         
     | 
| 
       110 
     | 
    
         
            -
                    src_path,
         
     | 
| 
       111 
     | 
    
         
            -
                    target_path,
         
     | 
| 
       112 
     | 
    
         
            -
                    child_analyze_level: child_analyze_level,
         
     | 
| 
       113 
     | 
    
         
            -
                    output_path: output_path,
         
     | 
| 
       114 
     | 
    
         
            -
                    alias_paths: alias_paths,
         
     | 
| 
       115 
     | 
    
         
            -
                    excludes: excludes
         
     | 
| 
      
 62 
     | 
    
         
            +
                  args = JsDependency::CliUtils::Yaml.new.args
         
     | 
| 
      
 63 
     | 
    
         
            +
                  config = JsDependency::CliUtils::Config.new(options, args)
         
     | 
| 
      
 64 
     | 
    
         
            +
                  puts JsDependency.children(
         
     | 
| 
      
 65 
     | 
    
         
            +
                    config.src_path,
         
     | 
| 
      
 66 
     | 
    
         
            +
                    config.target_path,
         
     | 
| 
      
 67 
     | 
    
         
            +
                    child_analyze_level: config.child_analyze_level,
         
     | 
| 
      
 68 
     | 
    
         
            +
                    output_path: config.output_path,
         
     | 
| 
      
 69 
     | 
    
         
            +
                    alias_paths: config.alias_paths,
         
     | 
| 
      
 70 
     | 
    
         
            +
                    excludes: config.excludes
         
     | 
| 
       116 
71 
     | 
    
         
             
                  ).join("\n")
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
                  puts str
         
     | 
| 
       119 
72 
     | 
    
         
             
                end
         
     | 
| 
       120 
73 
     | 
    
         | 
| 
       121 
74 
     | 
    
         
             
                desc "orphan", "export components than is not depended by others"
         
     | 
| 
       122 
     | 
    
         
            -
                 
     | 
| 
      
 75 
     | 
    
         
            +
                method_option :src_path, type: :string, aliases: "-s", desc: "Root folder."
         
     | 
| 
       123 
76 
     | 
    
         | 
| 
       124 
77 
     | 
    
         
             
                def orphan
         
     | 
| 
       125 
     | 
    
         
            -
                   
     | 
| 
       126 
     | 
    
         
            -
                   
     | 
| 
       127 
     | 
    
         
            -
                   
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
                  alias_paths = args["alias_paths"] || nil
         
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
                  str = JsDependency.orphan(
         
     | 
| 
       133 
     | 
    
         
            -
                    src_path,
         
     | 
| 
       134 
     | 
    
         
            -
                    alias_paths: alias_paths
         
     | 
| 
      
 78 
     | 
    
         
            +
                  args = JsDependency::CliUtils::Yaml.new.args
         
     | 
| 
      
 79 
     | 
    
         
            +
                  config = JsDependency::CliUtils::Config.new(options, args)
         
     | 
| 
      
 80 
     | 
    
         
            +
                  puts JsDependency.orphan(
         
     | 
| 
      
 81 
     | 
    
         
            +
                    config.src_path,
         
     | 
| 
      
 82 
     | 
    
         
            +
                    alias_paths: config.alias_paths
         
     | 
| 
       135 
83 
     | 
    
         
             
                  ).join("\n")
         
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
                  puts str
         
     | 
| 
       138 
84 
     | 
    
         
             
                end
         
     | 
| 
       139 
85 
     | 
    
         | 
| 
       140 
86 
     | 
    
         
             
                desc "leave", "export components than is not depended by others"
         
     | 
| 
       141 
     | 
    
         
            -
                 
     | 
| 
      
 87 
     | 
    
         
            +
                method_option :src_path, type: :string, aliases: "-s", desc: "Root folder."
         
     | 
| 
       142 
88 
     | 
    
         | 
| 
       143 
89 
     | 
    
         
             
                def leave
         
     | 
| 
       144 
     | 
    
         
            -
                   
     | 
| 
       145 
     | 
    
         
            -
                   
     | 
| 
       146 
     | 
    
         
            -
                   
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
                  alias_paths = args["alias_paths"] || nil
         
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
                  str = JsDependency.leave(
         
     | 
| 
       152 
     | 
    
         
            -
                    src_path,
         
     | 
| 
       153 
     | 
    
         
            -
                    alias_paths: alias_paths
         
     | 
| 
      
 90 
     | 
    
         
            +
                  args = JsDependency::CliUtils::Yaml.new.args
         
     | 
| 
      
 91 
     | 
    
         
            +
                  config = JsDependency::CliUtils::Config.new(options, args)
         
     | 
| 
      
 92 
     | 
    
         
            +
                  puts JsDependency.leave(
         
     | 
| 
      
 93 
     | 
    
         
            +
                    config.src_path,
         
     | 
| 
      
 94 
     | 
    
         
            +
                    alias_paths: config.alias_paths
         
     | 
| 
       154 
95 
     | 
    
         
             
                  ).join("\n")
         
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
                  puts str
         
     | 
| 
       157 
96 
     | 
    
         
             
                end
         
     | 
| 
       158 
97 
     | 
    
         | 
| 
       159 
98 
     | 
    
         
             
                desc "version", "show version"
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module JsDependency
         
     | 
| 
      
 4 
     | 
    
         
            +
              module CliUtils
         
     | 
| 
      
 5 
     | 
    
         
            +
                class Config
         
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :src_path, :target_paths, :target_path, :child_analyze_level, :parent_analyze_level, :output_path,
         
     | 
| 
      
 7 
     | 
    
         
            +
                              :alias_paths, :name_level, :excludes
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  # @param [Hash] options
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # @param [Hash] args
         
     | 
| 
      
 11 
     | 
    
         
            +
                  def initialize(options, args)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @src_path = options[:src_path] || args[:src_path]
         
     | 
| 
      
 13 
     | 
    
         
            +
                    @target_paths = options[:target_paths] || (args[:target_path].is_a?(String) ? [args[:target_path]] : args[:target_path])
         
     | 
| 
      
 14 
     | 
    
         
            +
                    @target_path = options[:target_path] || args[:target_path]
         
     | 
| 
      
 15 
     | 
    
         
            +
                    @child_analyze_level = options[:child_analyze_level] || args[:child_analyze_level] || 2
         
     | 
| 
      
 16 
     | 
    
         
            +
                    @parent_analyze_level = options[:parent_analyze_level] || args[:parent_analyze_level] || 2
         
     | 
| 
      
 17 
     | 
    
         
            +
                    @output_path = options[:output_path] || args[:output_path] || nil
         
     | 
| 
      
 18 
     | 
    
         
            +
                    @alias_paths = args[:alias_paths] || nil
         
     | 
| 
      
 19 
     | 
    
         
            +
                    @name_level = options[:name_level] || args[:name_level] || 1
         
     | 
| 
      
 20 
     | 
    
         
            +
                    @excludes = if options[:excludes]&.length&.positive?
         
     | 
| 
      
 21 
     | 
    
         
            +
                                  options[:excludes]
         
     | 
| 
      
 22 
     | 
    
         
            +
                                elsif args[:excludes]
         
     | 
| 
      
 23 
     | 
    
         
            +
                                  args[:excludes]
         
     | 
| 
      
 24 
     | 
    
         
            +
                                end
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,39 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module JsDependency
         
     | 
| 
      
 4 
     | 
    
         
            +
              module CliUtils
         
     | 
| 
      
 5 
     | 
    
         
            +
                class Yaml
         
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :args,
         
     | 
| 
      
 7 
     | 
    
         
            +
                              :dir_path
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  # @param [String, nil] dir_path
         
     | 
| 
      
 10 
     | 
    
         
            +
                  def initialize(dir_path: nil)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @dir_path = dir_path || Dir.pwd
         
     | 
| 
      
 12 
     | 
    
         
            +
                    pathname = config_pathname
         
     | 
| 
      
 13 
     | 
    
         
            +
                    @args = if pathname.nil?
         
     | 
| 
      
 14 
     | 
    
         
            +
                              {}
         
     | 
| 
      
 15 
     | 
    
         
            +
                            else
         
     | 
| 
      
 16 
     | 
    
         
            +
                              symbolize_keys(YAML.safe_load(pathname.read))
         
     | 
| 
      
 17 
     | 
    
         
            +
                            end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  private
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  # @return [Pathname, nil]
         
     | 
| 
      
 23 
     | 
    
         
            +
                  def config_pathname
         
     | 
| 
      
 24 
     | 
    
         
            +
                    dir_pathname = Pathname.new(@dir_path)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    pathname = nil
         
     | 
| 
      
 26 
     | 
    
         
            +
                    %w[.js_dependency.yml .js_dependency.yaml].each do |path|
         
     | 
| 
      
 27 
     | 
    
         
            +
                      pathname = (dir_pathname + path) if (dir_pathname + path).exist?
         
     | 
| 
      
 28 
     | 
    
         
            +
                    end
         
     | 
| 
      
 29 
     | 
    
         
            +
                    pathname
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  # @param [Hash] hash
         
     | 
| 
      
 33 
     | 
    
         
            +
                  # @return [Hash]
         
     | 
| 
      
 34 
     | 
    
         
            +
                  def symbolize_keys(hash)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    hash.transform_keys(&:to_sym)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/js_dependency.rb
    CHANGED
    
    | 
         @@ -9,6 +9,8 @@ require_relative "js_dependency/mermaid/target_pathname" 
     | 
|
| 
       9 
9 
     | 
    
         
             
            require_relative "js_dependency/source_analysis/leave"
         
     | 
| 
       10 
10 
     | 
    
         
             
            require_relative "js_dependency/source_analysis/orphan"
         
     | 
| 
       11 
11 
     | 
    
         
             
            require_relative "js_dependency/pathname_utility"
         
     | 
| 
      
 12 
     | 
    
         
            +
            require_relative "js_dependency/cli_utils/yaml"
         
     | 
| 
      
 13 
     | 
    
         
            +
            require_relative "js_dependency/cli_utils/config"
         
     | 
| 
       12 
14 
     | 
    
         
             
            require "pathname"
         
     | 
| 
       13 
15 
     | 
    
         | 
| 
       14 
16 
     | 
    
         
             
            module JsDependency
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       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.8
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - junara
         
     | 
| 
         @@ -159,6 +159,8 @@ files: 
     | 
|
| 
       159 
159 
     | 
    
         
             
            - js_dependency.gemspec
         
     | 
| 
       160 
160 
     | 
    
         
             
            - lib/js_dependency.rb
         
     | 
| 
       161 
161 
     | 
    
         
             
            - lib/js_dependency/cli.rb
         
     | 
| 
      
 162 
     | 
    
         
            +
            - lib/js_dependency/cli_utils/config.rb
         
     | 
| 
      
 163 
     | 
    
         
            +
            - lib/js_dependency/cli_utils/yaml.rb
         
     | 
| 
       162 
164 
     | 
    
         
             
            - lib/js_dependency/extractor/extract_import_path.rb
         
     | 
| 
       163 
165 
     | 
    
         
             
            - lib/js_dependency/extractor/extract_script_tag.rb
         
     | 
| 
       164 
166 
     | 
    
         
             
            - lib/js_dependency/extractor/extract_src_path.rb
         
     |