ossy 0.3.1 → 0.3.4
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/lib/ossy/cli/changelogs/update.rb +1 -1
- data/lib/ossy/cli/commands.rb +6 -0
- data/lib/ossy/cli/configs/merge.rb +5 -3
- data/lib/ossy/cli/github/tagger.rb +6 -2
- data/lib/ossy/cli/metrics/rubocop.rb +38 -0
- data/lib/ossy/cli/releases/generate.rb +2 -0
- data/lib/ossy/container.rb +1 -1
- data/lib/ossy/engine/rubocop/run.rb +118 -0
- data/lib/ossy/github/client.rb +1 -1
- data/lib/ossy/version.rb +1 -1
- metadata +27 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09293736b8853ce4851c0a079a9f95bf747481919f49048448ed8b22dae77a27'
|
4
|
+
data.tar.gz: 5307d372e0f89aabb53d9c6370f752f5caf2a15e45ef3cf2f558cee2fc9070eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7874aa0794c7f9a005a630ec37282af64940e1d78750cd16d6e978902ecf3ea27303a9c99679db37861dff38f6edd28ced9db690f5013937a43dc503bd86dd2f
|
7
|
+
data.tar.gz: 916b47d21be438a82c41e74795f30800d8c854c48278cb540ecc2c4354f091f96f55f54b598df2f03119e9e2d7fa71af19083765f55d86bb3e74a8c4a319e68d
|
@@ -18,7 +18,7 @@ module Ossy
|
|
18
18
|
KEYS = %w[version summary date fixed added changed].freeze
|
19
19
|
|
20
20
|
def call(config_path:, message:)
|
21
|
-
attrs = YAML.
|
21
|
+
attrs = YAML.safe_load(message)
|
22
22
|
target = YAML.load_file(config_path)
|
23
23
|
|
24
24
|
version = attrs["version"] || target[0]["version"]
|
data/lib/ossy/cli/commands.rb
CHANGED
@@ -22,6 +22,8 @@ module Ossy
|
|
22
22
|
|
23
23
|
require "ossy/cli/templates/compile"
|
24
24
|
|
25
|
+
require "ossy/cli/metrics/rubocop"
|
26
|
+
|
25
27
|
register "github", aliases: %w[gh] do |github|
|
26
28
|
github.register "workflow", Github::Workflow, aliases: %w[w]
|
27
29
|
github.register "membership", Github::Membership, aliases: %w[m]
|
@@ -46,6 +48,10 @@ module Ossy
|
|
46
48
|
register "configs", aliases: %w[c] do |configs|
|
47
49
|
configs.register "merge", Configs::Merge, aliases: %w[m]
|
48
50
|
end
|
51
|
+
|
52
|
+
register "metrics", aliases: %w[m] do |configs|
|
53
|
+
configs.register "rubocop", Metrics::Rubocop, aliases: %w[rc]
|
54
|
+
end
|
49
55
|
end
|
50
56
|
end
|
51
57
|
end
|
@@ -16,7 +16,7 @@ module Ossy
|
|
16
16
|
argument :output_path, required: true, desc: "The path to the output file"
|
17
17
|
|
18
18
|
option :identifiers, required: false, default: "",
|
19
|
-
|
19
|
+
desc: "Key identifier that should be used for merging arrays of hashes"
|
20
20
|
|
21
21
|
def call(source_path:, target_path:, output_path:, **opts)
|
22
22
|
puts "Merging #{source_path} + #{target_path} into #{output_path}"
|
@@ -49,9 +49,11 @@ module Ossy
|
|
49
49
|
arr
|
50
50
|
.map
|
51
51
|
.with_index { |el, idx|
|
52
|
-
(after = el.delete("_after"))
|
53
|
-
[el, arr.index(arr.detect { |a| a[id].eql?(after) }) + 1]
|
52
|
+
if (after = el.delete("_after"))
|
53
|
+
[el, arr.index(arr.detect { |a| a[id].eql?(after) }) + 1]
|
54
|
+
else
|
54
55
|
[el, idx]
|
56
|
+
end
|
55
57
|
}.sort_by(&:last).map(&:first)
|
56
58
|
else
|
57
59
|
(val1 + val2).uniq
|
@@ -17,8 +17,12 @@ module Ossy
|
|
17
17
|
def call(repo:, tag:)
|
18
18
|
result = client.tagger(repo: repo, tag: tag)
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
return unless result
|
21
|
+
|
22
|
+
tagger = result[:tagger]
|
23
|
+
|
24
|
+
if tagger["email"].include?("users.noreply.github.com") || result[:verified].equal?(true)
|
25
|
+
puts tagger["name"]
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ossy/cli/commands/core"
|
4
|
+
require "ossy/import"
|
5
|
+
require "ossy/release"
|
6
|
+
|
7
|
+
require "yaml"
|
8
|
+
require "tilt"
|
9
|
+
require "ostruct"
|
10
|
+
|
11
|
+
module Ossy
|
12
|
+
module CLI
|
13
|
+
module Metrics
|
14
|
+
class Rubocop < Commands::Core
|
15
|
+
include Import[run_rubocop: "engine.rubocop.run"]
|
16
|
+
|
17
|
+
desc "Runs rubocop"
|
18
|
+
|
19
|
+
argument :path, required: true, desc: "The path to file(s)"
|
20
|
+
option :format, required: true, desc: "Output format"
|
21
|
+
option :do_exit, required: false,
|
22
|
+
desc: "Whether the command should exit with the same status as rubocop"
|
23
|
+
option :silence, required: false,
|
24
|
+
desc: "Whether the rubocop output should be displayed"
|
25
|
+
|
26
|
+
def call(path:, silence: "false", do_exit: "true", args: [], **opts)
|
27
|
+
result, output = run_rubocop.(path: path, args: args, **opts)
|
28
|
+
|
29
|
+
warn output if silence.eql?("false") && !result.success?
|
30
|
+
|
31
|
+
exit(result.exitstatus) if do_exit.eql?("true")
|
32
|
+
|
33
|
+
[result, output]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -37,6 +37,8 @@ module Ossy
|
|
37
37
|
argument :output_path, required: true, desc: "The path to the output md file"
|
38
38
|
argument :template_path, required: true, desc: "The path to the changelog ERB template"
|
39
39
|
|
40
|
+
option :data_path, required: false, desc: "Optional path to additional data yaml file"
|
41
|
+
|
40
42
|
def call(config_path:, output_path:, template_path:, data_path: nil)
|
41
43
|
puts "Generating #{output_path} from #{config_path} using #{template_path}"
|
42
44
|
|
data/lib/ossy/container.rb
CHANGED
@@ -7,7 +7,7 @@ require "ossy/types"
|
|
7
7
|
|
8
8
|
module Ossy
|
9
9
|
class Container < Dry::System::Container
|
10
|
-
use :env, inferrer: proc { ENV.fetch("OSSY_ENV"
|
10
|
+
use :env, inferrer: proc { ENV.fetch("OSSY_ENV", "development").to_sym }
|
11
11
|
|
12
12
|
configure do |config|
|
13
13
|
config.root = Pathname(__dir__).join("../../")
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "open3"
|
4
|
+
|
5
|
+
require "ossy/cli/commands/core"
|
6
|
+
require "ossy/struct"
|
7
|
+
|
8
|
+
module Ossy
|
9
|
+
module Engine
|
10
|
+
module Rubocop
|
11
|
+
# {
|
12
|
+
# "metadata" : {
|
13
|
+
# "ruby_platform" : "x86_64-darwin20",
|
14
|
+
# "ruby_version" : "2.7.2",
|
15
|
+
# "ruby_engine" : "ruby",
|
16
|
+
# "ruby_patchlevel" : "137",
|
17
|
+
# "rubocop_version" : "1.6.1"
|
18
|
+
# },
|
19
|
+
# "files" : [
|
20
|
+
# {
|
21
|
+
# "offenses" : [],
|
22
|
+
# "path" : "spec/spec_helper.rb"
|
23
|
+
# }
|
24
|
+
# ],
|
25
|
+
# "summary" : {
|
26
|
+
# "target_file_count" : 1,
|
27
|
+
# "inspected_file_count" : 1,
|
28
|
+
# "offense_count" : 0
|
29
|
+
# }
|
30
|
+
# }
|
31
|
+
#
|
32
|
+
# # json["files"] element
|
33
|
+
# {"path"=>"spec/fixtures/rubocop/bad.rb",
|
34
|
+
# "offenses"=>
|
35
|
+
# [{"severity"=>"convention",
|
36
|
+
# "message"=> "blablabla",
|
37
|
+
# "cop_name"=>"Style/StringLiterals",
|
38
|
+
# "corrected"=>false,
|
39
|
+
# "correctable"=>true,
|
40
|
+
# "location"=>
|
41
|
+
# {"start_line"=>3,
|
42
|
+
# "start_column"=>1,
|
43
|
+
# "last_line"=>3,
|
44
|
+
# "last_column"=>30,
|
45
|
+
# "length"=>30,
|
46
|
+
# "line"=>3,
|
47
|
+
# "column"=>1}}]}
|
48
|
+
class Result < Ossy::Struct
|
49
|
+
attribute :summary do
|
50
|
+
attribute :offense_count, Types::Integer
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.build(json)
|
54
|
+
klass =
|
55
|
+
case json["summary"]["offense_count"]
|
56
|
+
in 0 then Success
|
57
|
+
in 1.. then Failure
|
58
|
+
end
|
59
|
+
klass.new(json)
|
60
|
+
end
|
61
|
+
|
62
|
+
def failure?
|
63
|
+
!success?
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class Success < Result
|
68
|
+
def success?
|
69
|
+
true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class Failure < Result
|
74
|
+
attribute :files, Types::Array do
|
75
|
+
attribute :path, Types::String
|
76
|
+
attribute :offenses, Types::Array do
|
77
|
+
attribute :severity, Types::String
|
78
|
+
attribute :cop_name, Types::String
|
79
|
+
attribute :location do
|
80
|
+
attribute :start_line, Types::Integer
|
81
|
+
attribute :start_column, Types::Integer
|
82
|
+
attribute :last_line, Types::Integer
|
83
|
+
attribute :last_column, Types::Integer
|
84
|
+
attribute :line, Types::Integer
|
85
|
+
attribute :column, Types::Integer
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def success?
|
91
|
+
false
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class Run < Ossy::CLI::Commands::Core
|
96
|
+
option :path, desc: "Path to file(s)"
|
97
|
+
option :format, desc: "Path to file(s)"
|
98
|
+
|
99
|
+
def call(path:, format: "json", args: [])
|
100
|
+
extra_opts = args.join(" ")
|
101
|
+
result, output = exec("rubocop #{path} --format #{format} #{extra_opts}".strip)
|
102
|
+
|
103
|
+
case format
|
104
|
+
when "json" then Result.build(JSON.parse(output))
|
105
|
+
else
|
106
|
+
[result, output]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def exec(cmd, opts = {})
|
111
|
+
Open3.popen3(cmd, opts) do |_stdin, stdout, _stderr, wait_thr|
|
112
|
+
[wait_thr.value, stdout.read]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
data/lib/ossy/github/client.rb
CHANGED
data/lib/ossy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ossy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -64,20 +64,40 @@ dependencies:
|
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '1.2'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: dry-configurable
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0.12'
|
74
|
+
- - "<"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.13'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.12'
|
84
|
+
- - "<"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0.13'
|
67
87
|
- !ruby/object:Gem::Dependency
|
68
88
|
name: dry-system
|
69
89
|
requirement: !ruby/object:Gem::Requirement
|
70
90
|
requirements:
|
71
91
|
- - "~>"
|
72
92
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
93
|
+
version: 0.18.1
|
74
94
|
type: :runtime
|
75
95
|
prerelease: false
|
76
96
|
version_requirements: !ruby/object:Gem::Requirement
|
77
97
|
requirements:
|
78
98
|
- - "~>"
|
79
99
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
100
|
+
version: 0.18.1
|
81
101
|
- !ruby/object:Gem::Dependency
|
82
102
|
name: dry-types
|
83
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,9 +219,11 @@ files:
|
|
199
219
|
- lib/ossy/cli/github/tagger.rb
|
200
220
|
- lib/ossy/cli/github/update_file.rb
|
201
221
|
- lib/ossy/cli/github/workflow.rb
|
222
|
+
- lib/ossy/cli/metrics/rubocop.rb
|
202
223
|
- lib/ossy/cli/releases/generate.rb
|
203
224
|
- lib/ossy/cli/templates/compile.rb
|
204
225
|
- lib/ossy/container.rb
|
226
|
+
- lib/ossy/engine/rubocop/run.rb
|
205
227
|
- lib/ossy/github/client.rb
|
206
228
|
- lib/ossy/github/workflow.rb
|
207
229
|
- lib/ossy/import.rb
|
@@ -232,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
254
|
- !ruby/object:Gem::Version
|
233
255
|
version: '0'
|
234
256
|
requirements: []
|
235
|
-
rubygems_version: 3.2.
|
257
|
+
rubygems_version: 3.2.32
|
236
258
|
signing_key:
|
237
259
|
specification_version: 4
|
238
260
|
summary: Ossy is your ruby gem maintenance helper
|