depec 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/release.yml +20 -0
- data/.gitignore +12 -0
- data/.rspec +4 -0
- data/.ruby-version +1 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +82 -0
- data/README.md +68 -0
- data/Rakefile +13 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/depec.gemspec +41 -0
- data/exe/depec +5 -0
- data/lib/depec/analyzer.rb +49 -0
- data/lib/depec/cli.rb +54 -0
- data/lib/depec/configuration.rb +31 -0
- data/lib/depec/initializer.rb +34 -0
- data/lib/depec/target/base.rb +12 -0
- data/lib/depec/target/circle_ci.rb +37 -0
- data/lib/depec/target/github_actions.rb +19 -0
- data/lib/depec/target/node.rb +72 -0
- data/lib/depec/target/ruby.rb +76 -0
- data/lib/depec/version.rb +3 -0
- data/lib/depec.rb +2 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '09d7e12c703037257dfa1e43846e066dd6cccfb86e5cf2edff637db65fd59b58'
|
4
|
+
data.tar.gz: 9ad0579f597c149926f36401e06b9e30cc99cae1eefc30600f482e3673dd14a9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 41e11661859ed564b59644a10c25e967afe07f2387560454b78de29bad31f4f4a2c76a8636e100fae64c97cf7d82ab1cea3e5154f9f0f8a24db7db06daaf3135
|
7
|
+
data.tar.gz: 7fe8caf06f16979fb00f38d6e0e2b8ac49cadf04f6a4594eeafe7109c3d8efa93d6a376b8caebc0c91b1e879b3487b38b287970ec2f39cc02672f4c897d7d44e
|
@@ -0,0 +1,20 @@
|
|
1
|
+
name: Release
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
tags:
|
5
|
+
- 'v*'
|
6
|
+
jobs:
|
7
|
+
release:
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v2
|
11
|
+
- uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.0.3
|
14
|
+
bundler-cache: true
|
15
|
+
- run: |
|
16
|
+
git config --global user.email "me@moeki.dev"
|
17
|
+
git config --global user.name "moekidev"
|
18
|
+
- run: bundle exec rake release
|
19
|
+
env:
|
20
|
+
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.3
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem "bundler", "~> 2.2"
|
7
|
+
gem "rake", "~> 10.0"
|
8
|
+
gem "rspec", "~> 3.0"
|
9
|
+
gem "rspec-power_assert"
|
10
|
+
gem "thor", "~> 1.1"
|
11
|
+
gem "tty-prompt", "~> 0.23"
|
12
|
+
gem "dry-schema", "~> 1.8"
|
13
|
+
gem "yard"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
concurrent-ruby (1.1.9)
|
5
|
+
diff-lcs (1.4.4)
|
6
|
+
dry-configurable (0.13.0)
|
7
|
+
concurrent-ruby (~> 1.0)
|
8
|
+
dry-core (~> 0.6)
|
9
|
+
dry-container (0.9.0)
|
10
|
+
concurrent-ruby (~> 1.0)
|
11
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
12
|
+
dry-core (0.7.1)
|
13
|
+
concurrent-ruby (~> 1.0)
|
14
|
+
dry-inflector (0.2.1)
|
15
|
+
dry-initializer (3.0.4)
|
16
|
+
dry-logic (1.2.0)
|
17
|
+
concurrent-ruby (~> 1.0)
|
18
|
+
dry-core (~> 0.5, >= 0.5)
|
19
|
+
dry-schema (1.8.0)
|
20
|
+
concurrent-ruby (~> 1.0)
|
21
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
22
|
+
dry-core (~> 0.5, >= 0.5)
|
23
|
+
dry-initializer (~> 3.0)
|
24
|
+
dry-logic (~> 1.0)
|
25
|
+
dry-types (~> 1.5)
|
26
|
+
dry-types (1.5.1)
|
27
|
+
concurrent-ruby (~> 1.0)
|
28
|
+
dry-container (~> 0.3)
|
29
|
+
dry-core (~> 0.5, >= 0.5)
|
30
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
31
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
32
|
+
pastel (0.8.0)
|
33
|
+
tty-color (~> 0.5)
|
34
|
+
power_assert (1.1.7)
|
35
|
+
rake (10.5.0)
|
36
|
+
rspec (3.10.0)
|
37
|
+
rspec-core (~> 3.10.0)
|
38
|
+
rspec-expectations (~> 3.10.0)
|
39
|
+
rspec-mocks (~> 3.10.0)
|
40
|
+
rspec-core (3.10.1)
|
41
|
+
rspec-support (~> 3.10.0)
|
42
|
+
rspec-expectations (3.10.1)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.10.0)
|
45
|
+
rspec-mocks (3.10.2)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.10.0)
|
48
|
+
rspec-power_assert (1.1.0)
|
49
|
+
power_assert (~> 1.1.0)
|
50
|
+
rspec (>= 2.14)
|
51
|
+
rspec-support (3.10.3)
|
52
|
+
thor (1.1.0)
|
53
|
+
tty-color (0.6.0)
|
54
|
+
tty-cursor (0.7.1)
|
55
|
+
tty-prompt (0.23.1)
|
56
|
+
pastel (~> 0.8)
|
57
|
+
tty-reader (~> 0.8)
|
58
|
+
tty-reader (0.9.0)
|
59
|
+
tty-cursor (~> 0.7)
|
60
|
+
tty-screen (~> 0.8)
|
61
|
+
wisper (~> 2.0)
|
62
|
+
tty-screen (0.8.1)
|
63
|
+
webrick (1.7.0)
|
64
|
+
wisper (2.0.1)
|
65
|
+
yard (0.9.27)
|
66
|
+
webrick (~> 1.7.0)
|
67
|
+
|
68
|
+
PLATFORMS
|
69
|
+
ruby
|
70
|
+
|
71
|
+
DEPENDENCIES
|
72
|
+
bundler (~> 2.2)
|
73
|
+
dry-schema (~> 1.8)
|
74
|
+
rake (~> 10.0)
|
75
|
+
rspec (~> 3.0)
|
76
|
+
rspec-power_assert
|
77
|
+
thor (~> 1.1)
|
78
|
+
tty-prompt (~> 0.23)
|
79
|
+
yard
|
80
|
+
|
81
|
+
BUNDLED WITH
|
82
|
+
2.2.32
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Depec
|
2
|
+
|
3
|
+
Depec analyze project directory's dependency spec.
|
4
|
+
It provides CLI to parse files in a project directory and report dependency spec as JSON.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "depec"
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or:
|
19
|
+
|
20
|
+
$ gem install depec
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Initialize configuration:
|
25
|
+
|
26
|
+
```bash
|
27
|
+
depec init
|
28
|
+
? Do you want to know whether Ruby is used?: Yes
|
29
|
+
? Do you want to know Ruby version?: Yes
|
30
|
+
? Do you want to know Bundler version?: Yes
|
31
|
+
? Gem name that do you want to know version: rails, jekyll
|
32
|
+
? Do you want to know whether Node.js is used?: Yes
|
33
|
+
? Do you want to know Node.js version?: Yes
|
34
|
+
? Npm package name that do you want to know version: vue, react
|
35
|
+
? Do you want to know whether CircleCI is used?: Yes
|
36
|
+
? Do you want to know CircleCI images?: Yes
|
37
|
+
? Do you want to know whether GitHub Actions is used?: Yes
|
38
|
+
```
|
39
|
+
|
40
|
+
Analyze specified directory:
|
41
|
+
|
42
|
+
```bash
|
43
|
+
depec analyze DIR --config=.depecrc.yml
|
44
|
+
{
|
45
|
+
"name": DIR_NAME,
|
46
|
+
"ruby": true,
|
47
|
+
"ruby_version": "2.6.9",
|
48
|
+
"bundler_version": "2.2.32",
|
49
|
+
"rails_gem": null,
|
50
|
+
"jekyll_gem": null,
|
51
|
+
"node": true,
|
52
|
+
"node_version": "14.15.1",
|
53
|
+
"vue_npm": "3.0.7",
|
54
|
+
"react_npm": null,
|
55
|
+
"circle_ci": true,
|
56
|
+
"circle_ci_images": [
|
57
|
+
"cimg/ruby:2.6.9-node",
|
58
|
+
"cimg/postgres:12.9"
|
59
|
+
],
|
60
|
+
"github_actions": false
|
61
|
+
}
|
62
|
+
```
|
63
|
+
|
64
|
+
If you want to output to JSON file,
|
65
|
+
|
66
|
+
```bash
|
67
|
+
depec analyze DIR --config=.depecrc.yml --output=out.json
|
68
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "depec"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/depec.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "depec/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "depec"
|
8
|
+
spec.version = Depec::VERSION
|
9
|
+
spec.authors = ["moekidev"]
|
10
|
+
spec.email = ["me@moeki.dev"]
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.summary = "Depec analyzes project's depencency spec."
|
14
|
+
spec.description = <<~EOF
|
15
|
+
Depec analyzes project's dependency spec.
|
16
|
+
It provides CLI to parse files in a project directory and
|
17
|
+
report dependency spec as JSON.
|
18
|
+
EOF
|
19
|
+
spec.homepage = "https://github.com/modekdev/depec"
|
20
|
+
|
21
|
+
if spec.respond_to?(:metadata)
|
22
|
+
|
23
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
24
|
+
spec.metadata["source_code_uri"] = "https://github.com/modekdev/depec"
|
25
|
+
spec.metadata["changelog_uri"] = "https://github.com/modekdev/depec"
|
26
|
+
else
|
27
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
28
|
+
"public gem pushes."
|
29
|
+
end
|
30
|
+
|
31
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
+
end
|
34
|
+
spec.bindir = "exe"
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
+
spec.require_paths = ["lib"]
|
37
|
+
|
38
|
+
spec.add_runtime_dependency "thor", "~> 1.1"
|
39
|
+
spec.add_runtime_dependency "tty-prompt", "~> 0.23"
|
40
|
+
spec.add_runtime_dependency "dry-schema", "~> 1.8"
|
41
|
+
end
|
data/exe/depec
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative 'configuration'
|
2
|
+
Dir.glob(__dir__ + '/target/*.rb').each {|f| require_relative f }
|
3
|
+
|
4
|
+
module Depec
|
5
|
+
class Analyzer
|
6
|
+
#
|
7
|
+
# @param [String]
|
8
|
+
# @param [Hash]
|
9
|
+
#
|
10
|
+
def initialize(dir, config)
|
11
|
+
@dir = dir
|
12
|
+
@name = File.basename(@dir)
|
13
|
+
@config = Configuration.call(config).to_h
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# @return [Hash]
|
18
|
+
#
|
19
|
+
def analyze
|
20
|
+
results = {
|
21
|
+
name: @name
|
22
|
+
}
|
23
|
+
|
24
|
+
@config[:targets].each do |target, options|
|
25
|
+
klass = Object.const_get("Depec::Target::#{target.to_s.split('_').collect!{ |w| w.capitalize }.join}").new(@dir)
|
26
|
+
results[target] = klass.used? if options[:use]
|
27
|
+
if [:ruby, :node].include?(target)
|
28
|
+
results[:"#{target}_version"] = klass.version if options[:version]
|
29
|
+
end
|
30
|
+
if target == :circle_ci
|
31
|
+
results[:circle_ci_images] = klass.images if options[:images]
|
32
|
+
end
|
33
|
+
if target == :ruby
|
34
|
+
results[:bundler_version] = klass.bundler_version if options[:bundler_version]
|
35
|
+
options[:gem_version]&.each do |gem|
|
36
|
+
results[:"#{gem}_gem"] = klass.gem_version(gem)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
if target == :node
|
40
|
+
options[:npm_version]&.each do |npm|
|
41
|
+
results[:"#{npm}_npm"] = klass.npm_version(npm)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
results
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/depec/cli.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'yaml'
|
3
|
+
require 'thor'
|
4
|
+
require 'tty-prompt'
|
5
|
+
|
6
|
+
require_relative 'analyzer'
|
7
|
+
require_relative 'initializer'
|
8
|
+
require_relative 'configuration'
|
9
|
+
|
10
|
+
module Depec
|
11
|
+
class CLI < Thor
|
12
|
+
#
|
13
|
+
# @param [String] dir
|
14
|
+
#
|
15
|
+
desc "analyze DIR", "Analyze project dependency spec"
|
16
|
+
method_option "config", desc: "config", default: Depec::DEFAULT_CONFIG_FILE
|
17
|
+
method_option "output", desc: "output", default: nil
|
18
|
+
def analyze(dir)
|
19
|
+
result = Depec::Analyzer.new(dir, YAML.load_file(options["config"])).analyze
|
20
|
+
if options["output"]
|
21
|
+
File.open(options["output"], "w+") do |f|
|
22
|
+
f.write(result.to_json)
|
23
|
+
end
|
24
|
+
else
|
25
|
+
puts JSON.pretty_generate(result)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "init", "Initialize depec configuration"
|
30
|
+
def init
|
31
|
+
prompt = TTY::Prompt.new
|
32
|
+
initializer = Depec::Initializer.new
|
33
|
+
|
34
|
+
answers = {
|
35
|
+
ruby: prompt.yes?("? Do you want to know whether Ruby is used?: "),
|
36
|
+
ruby_version: prompt.yes?("? Do you want to know Ruby version?: "),
|
37
|
+
bundler_version: prompt.yes?("? Do you want to know Bundler version?: "),
|
38
|
+
gem_version: prompt.ask("? Gem name that do you want to know version: ", default: "rails, jekyll", convert: :array),
|
39
|
+
node: prompt.yes?("? Do you want to know whether Node.js is used?: "),
|
40
|
+
node_version: prompt.yes?("? Do you want to know Node.js version?: "),
|
41
|
+
npm_version: prompt.ask("? Npm package name that do you want to know version: ", default: "vue, react", convert: :array),
|
42
|
+
circle_ci: prompt.yes?("? Do you want to know whether CircleCI is used?: "),
|
43
|
+
circle_ci_images: prompt.yes?("? Do you want to know CircleCI images?: "),
|
44
|
+
github_actions: prompt.yes?("? Do you want to know whether GitHub Actions is used?: "),
|
45
|
+
}
|
46
|
+
|
47
|
+
config = initializer.processAnswers(answers)
|
48
|
+
|
49
|
+
File.open(Depec::DEFAULT_CONFIG_FILE, 'w+') do |f|
|
50
|
+
f.write(YAML.dump(config))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'dry/schema'
|
2
|
+
|
3
|
+
module Depec
|
4
|
+
DEFAULT_CONFIG_FILE = '.depecrc.yml'
|
5
|
+
end
|
6
|
+
|
7
|
+
Depec::Configuration = Dry::Schema.Params do
|
8
|
+
required(:targets).hash do
|
9
|
+
optional(:ruby).hash do
|
10
|
+
optional(:use).filled(:bool)
|
11
|
+
optional(:version).filled(:bool)
|
12
|
+
optional(:bundler_version).filled(:bool)
|
13
|
+
optional(:gem_version).array(:str?)
|
14
|
+
end
|
15
|
+
|
16
|
+
optional(:node).hash do
|
17
|
+
optional(:use).filled(:bool)
|
18
|
+
optional(:version).filled(:bool)
|
19
|
+
optional(:npm_version).array(:str?)
|
20
|
+
end
|
21
|
+
|
22
|
+
optional(:circle_ci).hash do
|
23
|
+
optional(:use).filled(:bool)
|
24
|
+
optional(:images).filled(:bool)
|
25
|
+
end
|
26
|
+
|
27
|
+
optional(:github_actions).hash do
|
28
|
+
optional(:use).filled(:bool)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Depec
|
2
|
+
class Initializer
|
3
|
+
attr_accessor :config
|
4
|
+
|
5
|
+
#
|
6
|
+
# @param [Hash] answers
|
7
|
+
# @return
|
8
|
+
#
|
9
|
+
def processAnswers(answers)
|
10
|
+
Depec::Configuration.call({
|
11
|
+
targets: {
|
12
|
+
ruby: {
|
13
|
+
use: answers[:ruby],
|
14
|
+
version: answers[:ruby_version],
|
15
|
+
bundler_version: answers[:bundler_version],
|
16
|
+
gem_version: answers[:gem_version]
|
17
|
+
},
|
18
|
+
node: {
|
19
|
+
use: answers[:node],
|
20
|
+
version: answers[:node_version],
|
21
|
+
npm_version: answers[:npm_version]
|
22
|
+
},
|
23
|
+
circle_ci: {
|
24
|
+
use: answers[:circle_ci],
|
25
|
+
images: answers[:circle_ci_images]
|
26
|
+
},
|
27
|
+
github_actions: {
|
28
|
+
use: answers[:github_actions]
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}).to_h
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Depec
|
2
|
+
module Target
|
3
|
+
class CircleCi < Base
|
4
|
+
#
|
5
|
+
# @return [String]
|
6
|
+
#
|
7
|
+
def config_file
|
8
|
+
File.join(@dir, '.circleci', 'config.yml')
|
9
|
+
end
|
10
|
+
|
11
|
+
#
|
12
|
+
# @return [Boolean]
|
13
|
+
#
|
14
|
+
def used?
|
15
|
+
File.exists?(config_file)
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# @return [Array]
|
20
|
+
#
|
21
|
+
def images
|
22
|
+
images = []
|
23
|
+
return images unless File.exists?(config_file)
|
24
|
+
|
25
|
+
File.open(config_file) do |f|
|
26
|
+
f.each_line do |line|
|
27
|
+
if line.include?(' image:')
|
28
|
+
images << line.match(/image: (?<image>.*)/)[:image]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
images
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Depec
|
2
|
+
module Target
|
3
|
+
class GithubActions < Base
|
4
|
+
#
|
5
|
+
# @return [String]
|
6
|
+
#
|
7
|
+
def workflows_dir
|
8
|
+
File.join(@dir, '.github', 'workflows')
|
9
|
+
end
|
10
|
+
|
11
|
+
#
|
12
|
+
# @return [Boolean]
|
13
|
+
#
|
14
|
+
def used?
|
15
|
+
File.exist?(workflows_dir)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Depec
|
2
|
+
module Target
|
3
|
+
class Node < Base
|
4
|
+
#
|
5
|
+
# @return [String]
|
6
|
+
#
|
7
|
+
def node_version_file
|
8
|
+
File.join(@dir, '.node-version')
|
9
|
+
end
|
10
|
+
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
#
|
14
|
+
def package_json
|
15
|
+
File.join(@dir, 'package.json')
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# @return [String]
|
20
|
+
#
|
21
|
+
def yarn_lock
|
22
|
+
File.join(@dir, 'yarn.lock')
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# @return [Boolean]
|
27
|
+
#
|
28
|
+
def used?
|
29
|
+
File.exists?(package_json)
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
#
|
35
|
+
def version
|
36
|
+
if File.exists?(node_version_file)
|
37
|
+
File.open(node_version_file) { |f| return f.gets.strip }
|
38
|
+
elsif File.exists?(package_json)
|
39
|
+
engine_section = false
|
40
|
+
File.open(package_json) do |f|
|
41
|
+
f.each_line do |line|
|
42
|
+
engine_section = true if line.include?('"engines"')
|
43
|
+
if engine_section && line.include?('"node"')
|
44
|
+
return line.match(/"node": "(?<version>.*)"/)[:version]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
return nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# @param [String] npm
|
55
|
+
# @return [String]
|
56
|
+
#
|
57
|
+
def npm_version(npm)
|
58
|
+
return unless File.exists?(yarn_lock)
|
59
|
+
|
60
|
+
version_line = false
|
61
|
+
File.open(yarn_lock) do |f|
|
62
|
+
f.each_line do |line|
|
63
|
+
return line.match(/version \"(?<version>.*)\"/)[:version] if version_line
|
64
|
+
version_line = true if line.match?(/^#{npm}@/)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
return nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Depec
|
2
|
+
module Target
|
3
|
+
class Ruby < Base
|
4
|
+
#
|
5
|
+
# @return [String]
|
6
|
+
#
|
7
|
+
def ruby_version_file
|
8
|
+
File.join(@dir, '.ruby-version')
|
9
|
+
end
|
10
|
+
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
#
|
14
|
+
def gemfile
|
15
|
+
File.join(@dir, 'Gemfile')
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# @return [String]
|
20
|
+
#
|
21
|
+
def gemfile_lock
|
22
|
+
File.join(@dir, 'Gemfile.lock')
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# @return [Boolean]
|
27
|
+
#
|
28
|
+
def used?
|
29
|
+
File.exists?(gemfile)
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
#
|
35
|
+
def version
|
36
|
+
return unless File.exists?(ruby_version_file)
|
37
|
+
File.open(ruby_version_file) { |f| return f.gets.strip }
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# @return [String]
|
42
|
+
#
|
43
|
+
def bundler_version
|
44
|
+
return unless File.exists?(gemfile_lock)
|
45
|
+
|
46
|
+
version_line = false
|
47
|
+
File.open(gemfile_lock) do |f|
|
48
|
+
f.each_line do |line|
|
49
|
+
return line.strip if version_line
|
50
|
+
version_line = true if line.include?('BUNDLED WITH')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
return nil
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# @param [String] gem
|
59
|
+
# @return [String]
|
60
|
+
#
|
61
|
+
def gem_version(gem)
|
62
|
+
return unless File.exists?(gemfile_lock)
|
63
|
+
|
64
|
+
File.open(gemfile_lock) do |f|
|
65
|
+
f.each_line do |line|
|
66
|
+
if line.match?(/ #{gem} \([0-9\.]+\)/)
|
67
|
+
return line.match(/#{gem} \((?<version>.*)\)/)[:version]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
return nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/depec.rb
ADDED
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: depec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- moekidev
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-12-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tty-prompt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.23'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.23'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-schema
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.8'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.8'
|
55
|
+
description: |
|
56
|
+
Depec analyzes project's dependency spec.
|
57
|
+
It provides CLI to parse files in a project directory and
|
58
|
+
report dependency spec as JSON.
|
59
|
+
email:
|
60
|
+
- me@moeki.dev
|
61
|
+
executables:
|
62
|
+
- depec
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- ".github/workflows/release.yml"
|
67
|
+
- ".gitignore"
|
68
|
+
- ".rspec"
|
69
|
+
- ".ruby-version"
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- bin/console
|
75
|
+
- bin/setup
|
76
|
+
- depec.gemspec
|
77
|
+
- exe/depec
|
78
|
+
- lib/depec.rb
|
79
|
+
- lib/depec/analyzer.rb
|
80
|
+
- lib/depec/cli.rb
|
81
|
+
- lib/depec/configuration.rb
|
82
|
+
- lib/depec/initializer.rb
|
83
|
+
- lib/depec/target/base.rb
|
84
|
+
- lib/depec/target/circle_ci.rb
|
85
|
+
- lib/depec/target/github_actions.rb
|
86
|
+
- lib/depec/target/node.rb
|
87
|
+
- lib/depec/target/ruby.rb
|
88
|
+
- lib/depec/version.rb
|
89
|
+
homepage: https://github.com/modekdev/depec
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata:
|
93
|
+
homepage_uri: https://github.com/modekdev/depec
|
94
|
+
source_code_uri: https://github.com/modekdev/depec
|
95
|
+
changelog_uri: https://github.com/modekdev/depec
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubygems_version: 3.2.32
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Depec analyzes project's depencency spec.
|
115
|
+
test_files: []
|