lowendinsight 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/lowendinsight/environment_yml_dependencies.rb +34 -0
- data/lib/lowendinsight/gemfile_dependencies.rb +100 -0
- data/lib/lowendinsight/gemspec_dependencies.rb +73 -0
- data/lib/lowendinsight/package_json_dependencies.rb +118 -0
- data/lib/lowendinsight/pom_dependencies.rb +61 -0
- data/lib/lowendinsight/project_type.rb +60 -0
- data/lib/lowendinsight/version.rb +24 -0
- data/lib/lowendinsight.rb +48 -0
- data/lowendinsight.gemspec +36 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 968fe99a9cff0ccc9fc2950d92bc1d9ee37d884c
|
4
|
+
data.tar.gz: c8ea51626660b3f5abc827e37e80b3357c22395e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c56d87c6f493801fa943268444e64a3f307ec448f4976083203774ae75de6dd4dfa2cf2fa91319375a5c79b4a5a391adacca94684535ee0685dd0587bac24a1
|
7
|
+
data.tar.gz: 7b94f258ae953fe95491a641093f84721d526294dc107384c232f84dc33c45b9200f65f1c55951ac79c20b4b10127fbeb9bda1e3f0c0db5e2cecf9db9f91bc2b
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Selection Pressure LLC
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Lowendinsight
|
2
|
+
|
3
|
+
Lowendinsight is a simple module to parse and analyze various package manager's
|
4
|
+
dependency definitions. Currently supported is Ruby Gems' Gemfile and gemspec,
|
5
|
+
Node.js' package.json, and Maven's pom.xml files. More to come, as well as
|
6
|
+
helper methods for checking currency and stuff like that.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'lowendinsight'
|
14
|
+
```
|
15
|
+
|
16
|
+
or referencing the latest from Github:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'lowendinsight', :git => 'https://github.com/ion-channel/lowendinsight.git'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install lowendinsight
|
29
|
+
|
30
|
+
## Usage example
|
31
|
+
|
32
|
+
Super simple, get dependencies (as a Ruby Hash):
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Lowendinsight::GemfileDependencies.get_dependencies_from_repo "https://github.com/org/repo"
|
36
|
+
```
|
37
|
+
Returns:
|
38
|
+
```ruby
|
39
|
+
{"git"=>"= 1.2.9.1", "gemnasium-parser"=>"= 0.1.9", "bundler"=>"~> 1.10", "rake"=>"~> 10.0", "minitest"=>">= 0"}
|
40
|
+
```
|
41
|
+
|
42
|
+
or
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
Lowendinsight::GemspecDependencies.get_dependencies_from_file File.join("../../some.gemspec")
|
46
|
+
```
|
47
|
+
|
48
|
+
Lowendinsight also can determine the project type for you (pom, package,
|
49
|
+
Gemfile/gemspec):
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
Lowendinsight::ProjectType.determine_project_type_from_repo "https://github.com/org/repo"
|
53
|
+
```
|
54
|
+
Returns:
|
55
|
+
```ruby
|
56
|
+
{"type" => "pom"}
|
57
|
+
```
|
58
|
+
|
59
|
+
See the specs for other examples.
|
60
|
+
|
61
|
+
## Development
|
62
|
+
|
63
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
64
|
+
|
65
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ion-channel/lowendinsight.
|
70
|
+
|
71
|
+
## License
|
72
|
+
|
73
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "lowendinsight"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
# Copyright (c) 2016 Selection Pressure LLC
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
module Lowendinsight
|
23
|
+
module EnvironmentDependencies
|
24
|
+
|
25
|
+
def self.get_dependencies_from_repo(url)
|
26
|
+
return {}
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.get_dependencies_from_file(file)
|
30
|
+
return {}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
# Copyright (c) 2016 Selection Pressure LLC
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
require "gemnasium/parser"
|
23
|
+
|
24
|
+
module Lowendinsight
|
25
|
+
module GemfileDependencies
|
26
|
+
def self.get_dependencies_from_repo(url)
|
27
|
+
@url = url
|
28
|
+
paths = URI(@url).path.split("/")
|
29
|
+
@name = paths[(paths.size)-1]
|
30
|
+
g = Git.clone(@url, @name, :path => '/tmp/checkout')
|
31
|
+
gf = Gemnasium::Parser.gemfile Bundler.read_file("/tmp/checkout/#{@name}/Gemfile")
|
32
|
+
d = []
|
33
|
+
gf.dependencies.each do |dep|
|
34
|
+
d << {"name" => dep.name, "specified" => dep.requirement.to_s}
|
35
|
+
end
|
36
|
+
|
37
|
+
FileUtils.rm_rf("/tmp/checkout/#{@name}")
|
38
|
+
|
39
|
+
return d
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.get_all_dependencies_from_file(file)
|
43
|
+
d = []
|
44
|
+
top_level = get_dependencies_from_file(file)
|
45
|
+
if top_level[0]["message"]
|
46
|
+
d = top_level
|
47
|
+
else
|
48
|
+
top_level.each do |h|
|
49
|
+
version = h["specified"].split(" ")[1].strip
|
50
|
+
deps = get_dependencies_from_rubygems(h["name"], version)
|
51
|
+
d << {"name" => h["name"], "specified" => version, "available" => get_latest_version_from_rubygems(h["name"]), "dependencies" => deps}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
return d
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.get_latest_version_from_rubygems(gem)
|
58
|
+
uri = URI("https://rubygems.org/api/v1/versions/#{gem}/latest.json")
|
59
|
+
res = Net::HTTP.get(uri)
|
60
|
+
j = JSON.parse(res)
|
61
|
+
return j["version"]
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.get_dependencies_from_rubygems(gem, version)
|
65
|
+
uri = URI("https://rubygems.org/api/v1/dependencies.json?gems=#{gem}")
|
66
|
+
res = Net::HTTP.get(uri)
|
67
|
+
j = JSON.parse(res)
|
68
|
+
d = []
|
69
|
+
if version == '0'
|
70
|
+
last = j.last
|
71
|
+
last["dependencies"].each do |dep|
|
72
|
+
d << {"name" => dep[0], "specified" => dep.last}
|
73
|
+
end
|
74
|
+
else
|
75
|
+
j.each do |g|
|
76
|
+
if g["number"] == version
|
77
|
+
g["dependencies"].each do |dep|
|
78
|
+
inner_deps = get_dependencies_from_rubygems(dep[0], dep.last.split(" ")[1])
|
79
|
+
d << {"name" => dep[0],"specified" => dep.last, "dependencies" => inner_deps}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
return d
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.get_dependencies_from_file(file)
|
88
|
+
gf = Gemnasium::Parser.gemfile file
|
89
|
+
d = []
|
90
|
+
if gf.dependencies.empty?
|
91
|
+
d << {"message"=>"no dependencies defined in Gemfile, perhaps gemspec"}
|
92
|
+
else
|
93
|
+
gf.dependencies.each do |dep|
|
94
|
+
d << {"name" => dep.name, "specified" => dep.requirement.to_s}
|
95
|
+
end
|
96
|
+
end
|
97
|
+
return d
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
# Copyright (c) 2016 Selection Pressure LLC
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
require "gemnasium/parser"
|
23
|
+
|
24
|
+
module Lowendinsight
|
25
|
+
module GemspecDependencies
|
26
|
+
|
27
|
+
def self.get_dependencies_from_repo(url)
|
28
|
+
@url = url
|
29
|
+
paths = URI(@url).path.split("/")
|
30
|
+
@name = paths[(paths.size)-1]
|
31
|
+
g = Git.clone(@url, @name, :path => '/tmp/checkout')
|
32
|
+
gf = Gemnasium::Parser.gemspec Bundler.read_file("/tmp/checkout/#{@name}/#{@name}.gemspec")
|
33
|
+
d = []
|
34
|
+
gf.dependencies.each do |dep|
|
35
|
+
d << {"name" => dep.name, "specified" => dep.requirement.to_s}
|
36
|
+
end
|
37
|
+
|
38
|
+
FileUtils.rm_rf("/tmp/checkout/#{@name}")
|
39
|
+
|
40
|
+
return d
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.get_all_dependencies_from_file(file)
|
44
|
+
d = []
|
45
|
+
top_level = get_dependencies_from_file(file)
|
46
|
+
if top_level[0]["message"]
|
47
|
+
d = top_level
|
48
|
+
else
|
49
|
+
top_level.each do |dep|
|
50
|
+
version = dep["specified"].split(" ")[1].strip
|
51
|
+
deps = Lowendinsight::GemfileDependencies.get_dependencies_from_rubygems(dep["name"], version)
|
52
|
+
d << {"name" => dep["name"], "specified" => version,
|
53
|
+
"available" => Lowendinsight::GemfileDependencies.get_latest_version_from_rubygems(dep["name"]),
|
54
|
+
"dependencies" => deps}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
return d
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.get_dependencies_from_file(file)
|
61
|
+
gf = Gemnasium::Parser.gemspec file
|
62
|
+
d = []
|
63
|
+
if gf.dependencies.empty?
|
64
|
+
d << {"message"=>"no dependencies defined in gemspec"}
|
65
|
+
else
|
66
|
+
gf.dependencies.each do |dep|
|
67
|
+
d << {"name" => dep.name, "specified" => dep.requirement.to_s}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
return d
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
# Copyright (c) 2016 Selection Pressure LLC
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
module Lowendinsight
|
23
|
+
module PackageDependencies
|
24
|
+
|
25
|
+
def self.get_dependencies_from_repo(url)
|
26
|
+
|
27
|
+
h = []
|
28
|
+
|
29
|
+
begin
|
30
|
+
@url = url
|
31
|
+
paths = URI(@url).path.split("/")
|
32
|
+
@name = paths[(paths.size)-1]
|
33
|
+
|
34
|
+
g = Git.clone(@url, @name, :path => '/tmp/checkout')
|
35
|
+
raise unless File.exist?("/tmp/checkout/#{@name}/package.json")
|
36
|
+
json = JSON.parse(File.read("/tmp/checkout/#{@name}/package.json"))["dependencies"]
|
37
|
+
|
38
|
+
FileUtils.rm_rf("/tmp/checkout/#{@name}")
|
39
|
+
json.each do |k,v|
|
40
|
+
h << {"name" => k, "specified" => v}
|
41
|
+
end
|
42
|
+
rescue Exception => e
|
43
|
+
h << {"message" => "no package.json found"}
|
44
|
+
return h
|
45
|
+
end
|
46
|
+
return h
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.get_all_dependencies_from_file(file)
|
50
|
+
h = []
|
51
|
+
return [{"message":"npm not found"}] if !npm?
|
52
|
+
|
53
|
+
top_level = get_dependencies_from_file(file)
|
54
|
+
top_level.each do |dep|
|
55
|
+
deps = get_dependencies_from_npm(dep["name"],dep["specified"])
|
56
|
+
return deps if deps[0]['message']
|
57
|
+
h << {"name" => dep["name"], "specified" => dep["specified"], "available" => get_latest_version_of_package(dep["name"]), "dependencies" => deps}
|
58
|
+
end
|
59
|
+
return h
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.get_dependencies_from_npm(package, version)
|
63
|
+
j = {}
|
64
|
+
d = []
|
65
|
+
begin
|
66
|
+
return d[{"message":"npm not found"}] if !npm?
|
67
|
+
j = JSON.parse(`npm info #{package}@"#{version}" --json`)
|
68
|
+
rescue
|
69
|
+
d = [{"dependency_check_failed"=>{"package" => package, "version" => version}}]
|
70
|
+
end
|
71
|
+
if j["dependencies"]
|
72
|
+
j["dependencies"].each do |package|
|
73
|
+
version = version_clean(package[1].delete("~"))
|
74
|
+
inner_deps = get_dependencies_from_npm(package[0], version)
|
75
|
+
d << {"name" => package[0], "specified" => package[1], "dependencies" => inner_deps}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
return d
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.version_clean(version)
|
82
|
+
if version.count('.') == 1
|
83
|
+
version = version + ".0"
|
84
|
+
elsif version.count('.') == 0
|
85
|
+
version = version + ".0.0"
|
86
|
+
end
|
87
|
+
return version
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.get_latest_version_of_package(package)
|
91
|
+
JSON.parse(`npm info #{package} --json`)['dist-tags']['latest']
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.get_dependencies_from_file(file)
|
95
|
+
h = []
|
96
|
+
begin
|
97
|
+
json = JSON.parse(file)["dependencies"]
|
98
|
+
if json.nil?
|
99
|
+
return h
|
100
|
+
else
|
101
|
+
json.each do |k,v|
|
102
|
+
h << {"name" => k, "specified" => v}
|
103
|
+
end
|
104
|
+
return h
|
105
|
+
end
|
106
|
+
rescue
|
107
|
+
h << {"message" => "not a valid package.json"}
|
108
|
+
return h
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.npm?
|
114
|
+
npm = Lowendinsight.which('npm')
|
115
|
+
return npm
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
# Copyright (c) 2016 Selection Pressure LLC
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
module Lowendinsight
|
23
|
+
module PomDependencies
|
24
|
+
|
25
|
+
def self.get_dependencies_from_repo(url)
|
26
|
+
|
27
|
+
h = {}
|
28
|
+
|
29
|
+
begin
|
30
|
+
@url = url
|
31
|
+
paths = URI(@url).path.split("/")
|
32
|
+
@name = paths[(paths.size)-1]
|
33
|
+
|
34
|
+
g = Git.clone(@url, @name, :path => '/tmp/checkout')
|
35
|
+
#json = JSON.parse(File.read("/tmp/checkout/#{@name}/package.json"))["dependencies"]
|
36
|
+
raise unless File.exist?("/tmp/checkout/#{@name}/pom.xml")
|
37
|
+
o = `cd /tmp/checkout/#{@name} && mvn -B dependency:list -DoutputFile='deps.txt'`
|
38
|
+
d = File.read("/tmp/checkout/#{@name}/deps.txt").strip.lines.map(&:chomp).drop(1)
|
39
|
+
|
40
|
+
|
41
|
+
d.each do |dep|
|
42
|
+
dep = dep.strip.split(":")
|
43
|
+
h["#{dep[4]}:#{dep[0]}.#{dep[1]}"] = dep[3]
|
44
|
+
end
|
45
|
+
|
46
|
+
rescue
|
47
|
+
# pom.xml not found?
|
48
|
+
h["message"] = "no pom.xml found"
|
49
|
+
end
|
50
|
+
|
51
|
+
FileUtils.rm_rf("/tmp/checkout/#{@name}")
|
52
|
+
|
53
|
+
return h
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.get_dependencies_from_file(file)
|
57
|
+
return {}
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
module Lowendinsight
|
3
|
+
module ProjectType
|
4
|
+
def self.determine_project_type_from_repo(url)
|
5
|
+
@url = url
|
6
|
+
paths = URI(@url).path.split("/")
|
7
|
+
@name = paths[(paths.size)-1]
|
8
|
+
g = Git.clone(@url, @name, :path => '/tmp/checkout')
|
9
|
+
|
10
|
+
if package?
|
11
|
+
h = {"type" => "package"}
|
12
|
+
elsif pom?
|
13
|
+
h = {"type" => "pom"}
|
14
|
+
elsif gemfile?
|
15
|
+
h = {"type" => "gemfile"}
|
16
|
+
elsif gemspec?
|
17
|
+
h = {"type" => "gemspec"}
|
18
|
+
else
|
19
|
+
h = {"type" => "unknown"}
|
20
|
+
end
|
21
|
+
|
22
|
+
FileUtils.rm_rf("/tmp/checkout/#{@name}")
|
23
|
+
|
24
|
+
return h
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.pom?
|
29
|
+
File.exist?("/tmp/checkout/#{@name}/pom.xml")
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.package?
|
33
|
+
File.exist?("/tmp/checkout/#{@name}/package.json")
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.gemfile?
|
37
|
+
if File.exist?("/tmp/checkout/#{@name}/Gemfile")
|
38
|
+
h = Lowendinsight::GemfileDependencies.get_dependencies_from_file Bundler.read_file("/tmp/checkout/#{@name}/Gemfile")
|
39
|
+
if h[0]["message"] == "no dependencies defined in Gemfile, perhaps gemspec"
|
40
|
+
return false
|
41
|
+
else
|
42
|
+
return true
|
43
|
+
end
|
44
|
+
else
|
45
|
+
return false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.gemspec?
|
50
|
+
if File.exist?("/tmp/checkout/#{@name}/Gemfile")
|
51
|
+
h = Lowendinsight::GemfileDependencies.get_dependencies_from_file Bundler.read_file("/tmp/checkout/#{@name}/Gemfile")
|
52
|
+
if h[0]["message"] == "no dependencies defined in Gemfile, perhaps gemspec"
|
53
|
+
return true if File.exist?("/tmp/checkout/#{@name}/#{@name}.gemspec")
|
54
|
+
end
|
55
|
+
elsif File.exist?("/tmp/checkout/#{@name}/#{@name}.gemspec")
|
56
|
+
return true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
# Copyright (c) 2016 Selection Pressure LLC
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
module Lowendinsight
|
23
|
+
VERSION = "0.0.1"
|
24
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
# Copyright (c) 2016 Selection Pressure LLC
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
require "json"
|
23
|
+
require "git"
|
24
|
+
require "net/http"
|
25
|
+
require "lowendinsight/version"
|
26
|
+
require "lowendinsight/project_type"
|
27
|
+
require "lowendinsight/gemfile_dependencies"
|
28
|
+
require "lowendinsight/gemspec_dependencies"
|
29
|
+
require "lowendinsight/package_json_dependencies"
|
30
|
+
require "lowendinsight/pom_dependencies"
|
31
|
+
|
32
|
+
module Lowendinsight
|
33
|
+
|
34
|
+
## Attribution: http://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
|
35
|
+
# Cross-platform way of finding an executable in the $PATH.
|
36
|
+
#
|
37
|
+
# which('ruby') #=> /usr/bin/ruby
|
38
|
+
def self.which(cmd)
|
39
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
40
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
41
|
+
exts.each { |ext|
|
42
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
43
|
+
return exe if File.executable?(exe) && !File.directory?(exe)
|
44
|
+
}
|
45
|
+
end
|
46
|
+
return nil
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lowendinsight/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lowendinsight"
|
8
|
+
spec.version = Lowendinsight::VERSION
|
9
|
+
spec.authors = ["Kit Plummer"]
|
10
|
+
spec.email = ["kitplummer@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Lowendinsight provides basic dependency analysis.}
|
13
|
+
spec.description = %q{Lowendinsight gleens information for project dependency specifications including transitive dependency lists and version status.}
|
14
|
+
spec.homepage = "https://lowendinsight.github.com"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "git", "1.2.9.1"
|
31
|
+
spec.add_dependency "gemnasium-parser", "0.1.9"
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "minitest"
|
35
|
+
spec.add_development_dependency "simplecov"
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lowendinsight
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kit Plummer
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: git
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.9.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.2.9.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gemnasium-parser
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.9
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.9
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
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: simplecov
|
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
|
+
description: Lowendinsight gleens information for project dependency specifications
|
98
|
+
including transitive dependency lists and version status.
|
99
|
+
email:
|
100
|
+
- kitplummer@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".travis.yml"
|
107
|
+
- CODE_OF_CONDUCT.md
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- lib/lowendinsight.rb
|
115
|
+
- lib/lowendinsight/environment_yml_dependencies.rb
|
116
|
+
- lib/lowendinsight/gemfile_dependencies.rb
|
117
|
+
- lib/lowendinsight/gemspec_dependencies.rb
|
118
|
+
- lib/lowendinsight/package_json_dependencies.rb
|
119
|
+
- lib/lowendinsight/pom_dependencies.rb
|
120
|
+
- lib/lowendinsight/project_type.rb
|
121
|
+
- lib/lowendinsight/version.rb
|
122
|
+
- lowendinsight.gemspec
|
123
|
+
homepage: https://lowendinsight.github.com
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
metadata:
|
127
|
+
allowed_push_host: https://rubygems.org
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.4.8
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Lowendinsight provides basic dependency analysis.
|
148
|
+
test_files: []
|