project-report 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/bin/project-report +114 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bb2e40ca5b103334ae6bf30cb1d7d0adb72a9b5824c18e2480723d145ba27acf
|
4
|
+
data.tar.gz: 17f2bc41029fdddd6e0839400e38f9dd409d317f333e4e8e4e7d7aa67bc8175f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ee2a176a527dc6ab6aaea20fde66fb845d0b2308209548adb1a7f1f38497263d8fa43e0e74d885ecfcf49e6633cbbc4ef52e63064b3ef4c7d95f134365d027f4
|
7
|
+
data.tar.gz: cb0cc8c3c9959cb0209057ee2b3085081d76d904eaba7141c5c676c96ca745001a700fc13cab04af25b25fafec00bee245f972a0b16920b96e02b4c181988af3
|
data/bin/project-report
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rugged'
|
3
|
+
require 'linguist'
|
4
|
+
require 'optparse'
|
5
|
+
require 'bibliothecary'
|
6
|
+
|
7
|
+
def parse_options
|
8
|
+
ARGV.push('-h') if ARGV.empty?
|
9
|
+
options = { :name => "",
|
10
|
+
:business => "",
|
11
|
+
}
|
12
|
+
OptionParser.new do |opts|
|
13
|
+
opts.banner = "Generate statistics about project, such as used languages, row counts and dependencies.
|
14
|
+
Usage: project-report [options] -r<paths to git repository in local directory>
|
15
|
+
|
16
|
+
Example: ./project-report -r . -n\"Project Report\" --business=\"Open Source\"
|
17
|
+
|
18
|
+
Options:
|
19
|
+
"
|
20
|
+
|
21
|
+
opts.on("-oFILE", "--output-file=FILE", "Write output to this file. Otherwise to STDOUT") do |o|
|
22
|
+
options[:output] = o
|
23
|
+
end
|
24
|
+
opts.on("-nNAME", "--project-name=NAME", "Project name, will be prompted if not set") do |name|
|
25
|
+
options[:name] = name
|
26
|
+
end
|
27
|
+
opts.on("-bBUSINESS", "--business=BUSINESS", "Project business area, will be prompted if not set") do |business|
|
28
|
+
options[:business] = business
|
29
|
+
end
|
30
|
+
opts.on("-h", "--help", "Show this message") do
|
31
|
+
puts opts
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
opts.on("-rX,Y,Z --repos=X,Y,Z", Array, "Comma separated list of repository paths to scan. All repositories are assumed to be under the same project") do |list|
|
35
|
+
options[:repos] = list
|
36
|
+
options[:repos].each do |repo|
|
37
|
+
raise "#{repo} must be a git directory" unless File.directory?("#{repo}/.git")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end.parse!
|
41
|
+
|
42
|
+
mandatory = [:repos]
|
43
|
+
missing = mandatory.select { |param| options[param].nil? }
|
44
|
+
unless missing.empty?
|
45
|
+
raise OptionParser::MissingArgument.new(missing.join(', ')) #
|
46
|
+
end
|
47
|
+
|
48
|
+
options
|
49
|
+
end
|
50
|
+
|
51
|
+
def language_stats(path)
|
52
|
+
repo = Rugged::Repository.new(path)
|
53
|
+
Linguist::Repository.new(repo, repo.head.target_id)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Scan Package manager data
|
57
|
+
def scan_package_manager_data(root, paths)
|
58
|
+
manifests = Bibliothecary.identify_manifests(paths)
|
59
|
+
project_analyses = manifests.flat_map do |manifest|
|
60
|
+
Bibliothecary.analyse_file("#{root}/#{manifest}", File.open("#{root}/#{manifest}").read)
|
61
|
+
end
|
62
|
+
project_analyses.filter do |analysis|
|
63
|
+
# TODO flag for lockfile data? Drop them for now
|
64
|
+
analysis[:kind] != "lockfile"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def repo_stats(repo_path)
|
69
|
+
stats = language_stats(repo_path)
|
70
|
+
files = stats.repository.index.map { |h| h[:path] }
|
71
|
+
scans = scan_package_manager_data(repo_path, files)
|
72
|
+
{
|
73
|
+
"path" => repo_path,
|
74
|
+
"languages" => stats.languages,
|
75
|
+
"subprojects" => scans.map { |scan|
|
76
|
+
{
|
77
|
+
"platform" => scan[:platform],
|
78
|
+
"path" => scan[:path],
|
79
|
+
"dependencies" => scan[:dependencies].map { |dep|
|
80
|
+
{
|
81
|
+
"name" => dep[:name],
|
82
|
+
"type" => dep[:type].to_s,
|
83
|
+
"requirement" => dep[:requirement]
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
# Prompt missing fields
|
92
|
+
options = parse_options
|
93
|
+
if options[:name] == ""
|
94
|
+
print "Project name? "
|
95
|
+
options[:name] = STDIN.gets.strip
|
96
|
+
end
|
97
|
+
if options[:business] == ""
|
98
|
+
print "Project business area (e.g. ecommerce, banking, etc..)? "
|
99
|
+
options[:business] = STDIN.gets.strip
|
100
|
+
end
|
101
|
+
|
102
|
+
# Generate end result
|
103
|
+
project = {
|
104
|
+
"project" => {
|
105
|
+
"name" => options[:name],
|
106
|
+
"business" => options[:business],
|
107
|
+
"repos" => options[:repos].map{ |repo| repo_stats(repo)}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
if options[:output]
|
111
|
+
File.write(options[:output], project.to_yaml)
|
112
|
+
else
|
113
|
+
puts(project.to_yaml(indentation: 10))
|
114
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: project-report
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tatu Lahtela
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: github-linguist
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 7.16.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 7.16.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bibliothecary
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 7.0.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 7.0.2
|
41
|
+
description: |-
|
42
|
+
Generate language statistics and dependency report for projects.
|
43
|
+
Shows used languages with row counts, used package managers and dependenccies.
|
44
|
+
email: lahtela@iki.fi
|
45
|
+
executables:
|
46
|
+
- project-report
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- bin/project-report
|
51
|
+
homepage: https://github.com/ration/project-report
|
52
|
+
licenses:
|
53
|
+
- MIT
|
54
|
+
metadata: {}
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubygems_version: 3.1.2
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Generate language statistics and dependency report for projects
|
74
|
+
test_files: []
|