ossy 0.1.0
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 +7 -0
- data/CHANGELOG.md +11 -0
- data/README.md +68 -0
- data/bin/ossy +8 -0
- data/lib/ossy.rb +6 -0
- data/lib/ossy/cli.rb +18 -0
- data/lib/ossy/cli/changelogs/generate.rb +56 -0
- data/lib/ossy/cli/changelogs/update.rb +46 -0
- data/lib/ossy/cli/commands.rb +45 -0
- data/lib/ossy/cli/commands/core.rb +12 -0
- data/lib/ossy/cli/configs/merge.rb +45 -0
- data/lib/ossy/cli/github/member.rb +27 -0
- data/lib/ossy/cli/github/membership.rb +32 -0
- data/lib/ossy/cli/github/tagger.rb +27 -0
- data/lib/ossy/cli/github/update_file.rb +30 -0
- data/lib/ossy/cli/github/workflow.rb +35 -0
- data/lib/ossy/cli/templates/compile.rb +46 -0
- data/lib/ossy/container.rb +28 -0
- data/lib/ossy/github/client.rb +89 -0
- data/lib/ossy/github/workflow.rb +13 -0
- data/lib/ossy/import.rb +7 -0
- data/lib/ossy/release.rb +40 -0
- data/lib/ossy/struct.rb +19 -0
- data/lib/ossy/types.rb +20 -0
- data/lib/ossy/version.rb +5 -0
- metadata +232 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b30259b0b16459328b9a7e112e90cee96a604c915aebca8716bf8d1c986082b7
|
4
|
+
data.tar.gz: 2422f8bffcfd38186bc9786daa437557a422baaa6b385f56a7d36f0e4a0cd61e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 697af87fcc7915b5008f80441f59b13d11a09057f6d29b3aaac9d7e20db48b08288a5306c66e6e7a7c754a436373329f59a2fccf85a162ef80f939a261cf0c77
|
7
|
+
data.tar.gz: 2492e1c5c41c4c925969f8f90392617c371ba5d6349a01e7077bccc0e3c720163ed95d6b578abd1af9e0a246b690b737f8473c78409237de750d4036fc20aa15
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
## 0.1.0 2020-01-22
|
2
|
+
|
3
|
+
The first public release!
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- `ossy github` - various commands that give you information from the GitHub API v3
|
8
|
+
- `ossy changelogs` - commands for updating `CHANGELOG` files automatically based on a YAML config
|
9
|
+
- `ossy configs` - commands for merging YAML configs
|
10
|
+
- `ossy templates` - commands for compiling `erb` templates
|
11
|
+
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Ossy
|
2
|
+
|
3
|
+
Ossy is a CLI tool that provides various commands that help with maintenance automation.
|
4
|
+
|
5
|
+
## Status
|
6
|
+
|
7
|
+
This is an early stage, things are changing fast. Currently `ossy` is used by [dry-rb.org](https://dry-rb.org) and [rom-rb.org](https://rom-rb.org).
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'ossy'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install ossy
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
First of all you need two `ENV` variables:
|
28
|
+
|
29
|
+
- `GITHUB_LOGIN` - the username that ossy will use to talk to GitHub
|
30
|
+
- `GITHUB_TOKEN` - the personal access token that you can create under [Developer settings](https://github.com/settings/tokens) on GitHub
|
31
|
+
|
32
|
+
Then, to learn more, type this in your terminal:
|
33
|
+
|
34
|
+
```bash
|
35
|
+
ossy help
|
36
|
+
```
|
37
|
+
|
38
|
+
Here are some `github` examples:
|
39
|
+
|
40
|
+
```bash
|
41
|
+
$ ossy github tagger dry-rb/dry-validation v1.2.0
|
42
|
+
Piotr Solnica
|
43
|
+
|
44
|
+
$ ossy github membership solnic dry-rb core
|
45
|
+
solnic has active membership in dry-rb/@core
|
46
|
+
|
47
|
+
$ ossy github workflow dry-rb/dry-validation sync_configs
|
48
|
+
Requesting: dry-rb/dry-validation => sync_configs
|
49
|
+
Success!
|
50
|
+
```
|
51
|
+
|
52
|
+
## Development
|
53
|
+
|
54
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
+
|
56
|
+
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).
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/solnic/ossy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
65
|
+
|
66
|
+
## Code of Conduct
|
67
|
+
|
68
|
+
Everyone interacting in the Ossy project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/solnic/ossy/blob/master/CODE_OF_CONDUCT.md).
|
data/bin/ossy
ADDED
data/lib/ossy.rb
ADDED
data/lib/ossy/cli.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry/cli'
|
4
|
+
require 'ossy/cli/commands'
|
5
|
+
|
6
|
+
module Ossy
|
7
|
+
module CLI
|
8
|
+
class Application < Dry::CLI
|
9
|
+
def self.start
|
10
|
+
new.()
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.new(commands = CLI::Commands)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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 Changelogs
|
14
|
+
class Generate < Commands::Core
|
15
|
+
class Context < OpenStruct
|
16
|
+
def self.new(data)
|
17
|
+
super(releases: data.map(&Release))
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(hash)
|
21
|
+
hash.each { |k, v| self[k.to_sym] = v }
|
22
|
+
self
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Generates a changelog markdown file from a yaml config'
|
27
|
+
|
28
|
+
argument :config_path, required: true, desc: 'The path to the changelog config'
|
29
|
+
argument :output_path, required: true, desc: 'The path to the output md file'
|
30
|
+
argument :template_path, required: true, desc: 'The path to the changelog ERB template'
|
31
|
+
|
32
|
+
option :data_path, required: false, desc: 'Optional path to additional data yaml file'
|
33
|
+
|
34
|
+
def call(config_path:, output_path:, template_path:, data_path: nil)
|
35
|
+
puts "Generating #{output_path} from #{config_path} using #{template_path}"
|
36
|
+
|
37
|
+
ctx_data = YAML.load_file(config_path)
|
38
|
+
template = Tilt.new(template_path)
|
39
|
+
|
40
|
+
context = Context.new(ctx_data)
|
41
|
+
|
42
|
+
if data_path
|
43
|
+
key = File.basename(data_path).gsub('.yml', '')
|
44
|
+
data = YAML.load_file(data_path)
|
45
|
+
|
46
|
+
context.update(key => OpenStruct.new(data))
|
47
|
+
end
|
48
|
+
|
49
|
+
output = template.render(context)
|
50
|
+
|
51
|
+
File.write(output_path, "#{output.strip}\n")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,46 @@
|
|
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
|
+
|
9
|
+
module Ossy
|
10
|
+
module CLI
|
11
|
+
module Changelogs
|
12
|
+
class Update < Commands::Core
|
13
|
+
desc 'Adds a new entry to a changelog config'
|
14
|
+
|
15
|
+
argument :config_path, required: true, desc: 'The path to the changelog config'
|
16
|
+
argument :message, required: true, desc: 'Message text including the entry'
|
17
|
+
|
18
|
+
KEYS = %w[version summary date fixed added changed].freeze
|
19
|
+
|
20
|
+
def call(config_path:, message:)
|
21
|
+
attrs = YAML.load(message)
|
22
|
+
target = YAML.load_file(config_path)
|
23
|
+
|
24
|
+
version = attrs['version'] || target[0]['version']
|
25
|
+
entry = target.detect { |e| e['version'].eql?(version) } || {}
|
26
|
+
|
27
|
+
release = Release.new(attrs.merge(version: version))
|
28
|
+
|
29
|
+
release.each do |type, logs|
|
30
|
+
(entry[type.to_s] ||= []).concat(logs).uniq!
|
31
|
+
end
|
32
|
+
|
33
|
+
entry.update(release.meta)
|
34
|
+
|
35
|
+
entry = KEYS.map { |key| [key, entry[key]] }.to_h
|
36
|
+
|
37
|
+
unless target.include?(entry)
|
38
|
+
target.unshift(entry.merge(release.meta))
|
39
|
+
end
|
40
|
+
|
41
|
+
File.write(config_path, YAML.dump(target))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry/cli/registry'
|
4
|
+
|
5
|
+
module Ossy
|
6
|
+
module CLI
|
7
|
+
module Commands
|
8
|
+
extend Dry::CLI::Registry
|
9
|
+
|
10
|
+
require 'ossy/cli/github/workflow'
|
11
|
+
require 'ossy/cli/github/membership'
|
12
|
+
require 'ossy/cli/github/tagger'
|
13
|
+
require 'ossy/cli/github/member'
|
14
|
+
require 'ossy/cli/github/update_file'
|
15
|
+
|
16
|
+
require 'ossy/cli/changelogs/generate'
|
17
|
+
require 'ossy/cli/changelogs/update'
|
18
|
+
|
19
|
+
require 'ossy/cli/configs/merge'
|
20
|
+
|
21
|
+
require 'ossy/cli/templates/compile'
|
22
|
+
|
23
|
+
register 'github', aliases: %w[gh] do |github|
|
24
|
+
github.register 'workflow', Github::Workflow, aliases: %w[w]
|
25
|
+
github.register 'membership', Github::Membership, aliases: %w[m]
|
26
|
+
github.register 'tagger', Github::Tagger, aliases: %w[t]
|
27
|
+
github.register 'member', Github::Member, aliases: %w[om]
|
28
|
+
github.register 'update_file', Github::UpdateFile, aliases: %w[uf]
|
29
|
+
end
|
30
|
+
|
31
|
+
register 'templates', aliases: %w[t] do |templates|
|
32
|
+
templates.register 'compile', Templates::Compile, aliases: %w[c]
|
33
|
+
end
|
34
|
+
|
35
|
+
register 'changelogs', aliases: %w[ch] do |changelogs|
|
36
|
+
changelogs.register 'generate', Changelogs::Generate, aliases: %w[g]
|
37
|
+
changelogs.register 'update', Changelogs::Update, aliases: %w[u]
|
38
|
+
end
|
39
|
+
|
40
|
+
register 'configs', aliases: %w[c] do |configs|
|
41
|
+
configs.register 'merge', Configs::Merge, aliases: %w[m]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ossy/cli/commands/core'
|
4
|
+
require 'ossy/import'
|
5
|
+
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
module Ossy
|
9
|
+
module CLI
|
10
|
+
module Configs
|
11
|
+
class Merge < Commands::Core
|
12
|
+
desc 'Merge two yaml config files into a new one'
|
13
|
+
|
14
|
+
argument :source_path, required: true, desc: 'The path to the source file'
|
15
|
+
argument :target_path, required: true, desc: 'The path to the target file'
|
16
|
+
argument :output_path, required: true, desc: 'The path to the output file'
|
17
|
+
|
18
|
+
def call(source_path:, target_path:, output_path:)
|
19
|
+
puts "Merging #{source_path} + #{target_path} into #{output_path}"
|
20
|
+
|
21
|
+
source = YAML.load_file(source_path)
|
22
|
+
target = YAML.load_file(target_path)
|
23
|
+
|
24
|
+
output = deep_merge(source, target)
|
25
|
+
|
26
|
+
File.write(output_path, YAML.dump(output))
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def deep_merge(h1, h2, &block)
|
32
|
+
h1.merge(h2) do |key, val1, val2|
|
33
|
+
if val1.is_a?(Hash) && val2.is_a?(Hash)
|
34
|
+
deep_merge(val1, val2, &block)
|
35
|
+
elsif val1.is_a?(Array) && val2.is_a?(Array)
|
36
|
+
(val1 + val2).uniq
|
37
|
+
else
|
38
|
+
val2
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ossy/cli/commands/core'
|
4
|
+
require 'ossy/import'
|
5
|
+
|
6
|
+
module Ossy
|
7
|
+
module CLI
|
8
|
+
module Github
|
9
|
+
class Member < Commands::Core
|
10
|
+
include Import['github.client']
|
11
|
+
|
12
|
+
desc 'Return org member identified by the full name'
|
13
|
+
|
14
|
+
argument :name, required: true, desc: 'The member name'
|
15
|
+
argument :org, required: true, desc: 'The org name'
|
16
|
+
|
17
|
+
def call(name:, org:)
|
18
|
+
result = client.member(name, org: org)
|
19
|
+
|
20
|
+
if result
|
21
|
+
puts result['login']
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ossy/cli/commands/core'
|
4
|
+
require 'ossy/import'
|
5
|
+
|
6
|
+
module Ossy
|
7
|
+
module CLI
|
8
|
+
module Github
|
9
|
+
class Membership < Commands::Core
|
10
|
+
include Import['github.client']
|
11
|
+
|
12
|
+
desc 'Check if a given user has an active membership in a team'
|
13
|
+
|
14
|
+
argument :username, required: true, desc: 'The username'
|
15
|
+
argument :org, required: true, desc: 'The name of the org'
|
16
|
+
argument :team, required: true, desc: 'The name of the team'
|
17
|
+
|
18
|
+
option :verify, required: false
|
19
|
+
|
20
|
+
def call(username:, org:, team:, verify: 'false')
|
21
|
+
result = client.membership?(username, org: org, team: team)
|
22
|
+
|
23
|
+
if verify.eql?('true')
|
24
|
+
exit(1) unless result
|
25
|
+
else
|
26
|
+
puts "#{username} has active membership in #{org}/@#{team}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ossy/cli/commands/core'
|
4
|
+
require 'ossy/import'
|
5
|
+
|
6
|
+
module Ossy
|
7
|
+
module CLI
|
8
|
+
module Github
|
9
|
+
class Tagger < Commands::Core
|
10
|
+
include Import['github.client']
|
11
|
+
|
12
|
+
desc 'Return tagger email for a verified tag'
|
13
|
+
|
14
|
+
argument :repo, required: true, desc: 'The repo'
|
15
|
+
argument :tag, required: true, desc: 'The tag name'
|
16
|
+
|
17
|
+
def call(repo:, tag:)
|
18
|
+
result = client.tagger(repo: repo, tag: tag)
|
19
|
+
|
20
|
+
if result && result[:verified].equal?(true)
|
21
|
+
puts result[:tagger]['name']
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ossy/cli/commands/core'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
module Ossy
|
7
|
+
module CLI
|
8
|
+
module Github
|
9
|
+
class UpdateFile < Commands::Core
|
10
|
+
desc 'Update provided file using a canonical source in another repository'
|
11
|
+
|
12
|
+
argument(:repo, required: true, desc: 'Source repository')
|
13
|
+
argument(:file, required: true, desc: 'File path ie owner/repo:path/to/file')
|
14
|
+
option(:branch, required: false, desc: 'Branch name', default: 'master')
|
15
|
+
|
16
|
+
def call(repo:, file:, branch:)
|
17
|
+
url = "https://raw.githubusercontent.com/#{repo}/#{branch}/shared/#{file}"
|
18
|
+
|
19
|
+
content = open(url).read
|
20
|
+
|
21
|
+
puts "Writing to #{file}"
|
22
|
+
|
23
|
+
File.write("./#{file}", content)
|
24
|
+
|
25
|
+
system "git commit #{file} -m 'Update #{file}'"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
require 'ossy/cli/commands/core'
|
6
|
+
require 'ossy/import'
|
7
|
+
|
8
|
+
module Ossy
|
9
|
+
module CLI
|
10
|
+
module Github
|
11
|
+
class Workflow < Commands::Core
|
12
|
+
include Import['github.workflow']
|
13
|
+
|
14
|
+
desc 'Start a GitHub workflow'
|
15
|
+
|
16
|
+
argument :repo, required: true, desc: 'The name of the repository on GitHub'
|
17
|
+
argument :name, required: true, desc: 'The name of the workflow'
|
18
|
+
|
19
|
+
option :payload, required: false, desc: 'Optional client payload'
|
20
|
+
|
21
|
+
def call(repo:, name:, payload: "{}")
|
22
|
+
puts "Requesting: #{repo} => #{name}"
|
23
|
+
|
24
|
+
result = workflow.(repo, name, JSON.load(payload))
|
25
|
+
|
26
|
+
if result.code.eql?(204)
|
27
|
+
puts 'Success!'
|
28
|
+
else
|
29
|
+
puts "Failure! #{result.inspect}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry/inflector'
|
4
|
+
require 'ossy/cli/commands/core'
|
5
|
+
require 'ossy/import'
|
6
|
+
|
7
|
+
require 'tilt'
|
8
|
+
require 'erb'
|
9
|
+
require 'yaml'
|
10
|
+
require 'ostruct'
|
11
|
+
|
12
|
+
module Ossy
|
13
|
+
module CLI
|
14
|
+
module Templates
|
15
|
+
class Compile < Commands::Core
|
16
|
+
class Context < OpenStruct
|
17
|
+
Inflector = Dry::Inflector.new do |i|
|
18
|
+
i.acronym 'CLI'
|
19
|
+
end
|
20
|
+
|
21
|
+
def inflector
|
22
|
+
Inflector
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
include Import['github.workflow']
|
27
|
+
|
28
|
+
desc 'Compile an erb template'
|
29
|
+
|
30
|
+
argument :source_path, required: true, desc: 'The path to the template file'
|
31
|
+
argument :target_path, required: true, desc: 'The path to the output file'
|
32
|
+
argument :data_file, required: true, desc: 'The path to yaml data file'
|
33
|
+
|
34
|
+
def call(source_path:, target_path:, data_file:)
|
35
|
+
puts "Compiling #{source_path} => #{target_path}"
|
36
|
+
|
37
|
+
data = YAML.load_file(data_file)
|
38
|
+
template = Tilt.new(source_path)
|
39
|
+
output = template.render(Context.new(data))
|
40
|
+
|
41
|
+
File.write(target_path, output)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry/system/container'
|
4
|
+
require 'dry/system/components'
|
5
|
+
|
6
|
+
require 'ossy/types'
|
7
|
+
|
8
|
+
module Ossy
|
9
|
+
class Container < Dry::System::Container
|
10
|
+
use :logging
|
11
|
+
use :env, inferrer: proc { ENV.fetch('OSSY_ENV') { 'development' }.to_sym }
|
12
|
+
|
13
|
+
configure do |config|
|
14
|
+
config.root = Pathname(__dir__).join('../../')
|
15
|
+
config.name = :ossy
|
16
|
+
config.default_namespace = 'ossy'
|
17
|
+
end
|
18
|
+
|
19
|
+
load_paths! 'lib'
|
20
|
+
|
21
|
+
boot(:settings, from: :system) do
|
22
|
+
settings do
|
23
|
+
key :github_login, Types::String.constrained(filled: true)
|
24
|
+
key :github_token, Types::String.constrained(filled: true)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ossy/import'
|
4
|
+
|
5
|
+
require 'http'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
module Ossy
|
9
|
+
module Github
|
10
|
+
class Client
|
11
|
+
include Import[:settings]
|
12
|
+
|
13
|
+
BASE_URL = 'https://api.github.com'
|
14
|
+
|
15
|
+
def membership?(username, org:, team:)
|
16
|
+
path = "orgs/#{org}/teams/#{team}/memberships/#{username}"
|
17
|
+
resp = get(path)
|
18
|
+
|
19
|
+
return false unless resp.code.equal?(200)
|
20
|
+
|
21
|
+
json = JSON.parse(resp.body)
|
22
|
+
|
23
|
+
json['state'].eql?('active')
|
24
|
+
end
|
25
|
+
|
26
|
+
def tagger(repo:, tag:)
|
27
|
+
path = "repos/#{repo}/git/ref/tags/#{tag}"
|
28
|
+
resp = get(path)
|
29
|
+
|
30
|
+
return false unless resp.code.equal?(200)
|
31
|
+
|
32
|
+
sha = JSON.parse(resp.body)['object']['sha']
|
33
|
+
|
34
|
+
path = "repos/#{repo}/git/tags/#{sha}"
|
35
|
+
resp = get(path)
|
36
|
+
|
37
|
+
return false unless resp.code.equal?(200)
|
38
|
+
|
39
|
+
json = JSON.parse(resp.body)
|
40
|
+
|
41
|
+
{ tagger: json['tagger'], verified: json['verification']['verified'] }
|
42
|
+
end
|
43
|
+
|
44
|
+
def member(name, org:)
|
45
|
+
path = "orgs/#{org}/members"
|
46
|
+
resp = get(path)
|
47
|
+
|
48
|
+
return nil unless resp.code.equal?(200)
|
49
|
+
|
50
|
+
user = JSON.parse(resp.body)
|
51
|
+
.map { |member| user(member['login']) }
|
52
|
+
.detect { |user| user['name'].eql?(name) }
|
53
|
+
|
54
|
+
user
|
55
|
+
end
|
56
|
+
|
57
|
+
def user(login)
|
58
|
+
path = "users/#{login}"
|
59
|
+
resp = get(path)
|
60
|
+
|
61
|
+
return nil unless resp.code.equal?(200)
|
62
|
+
|
63
|
+
JSON.parse(resp.body)
|
64
|
+
end
|
65
|
+
|
66
|
+
def request(meth, path, opts = {})
|
67
|
+
http.public_send(meth, url(path), opts)
|
68
|
+
end
|
69
|
+
|
70
|
+
def get(path, opts = {})
|
71
|
+
request(:get, path, params: opts)
|
72
|
+
end
|
73
|
+
|
74
|
+
def post(path, input)
|
75
|
+
request(:post, path, json: input)
|
76
|
+
end
|
77
|
+
|
78
|
+
def url(path)
|
79
|
+
"#{BASE_URL}/#{path}"
|
80
|
+
end
|
81
|
+
|
82
|
+
def http
|
83
|
+
HTTP
|
84
|
+
.headers('Accept': 'application/vnd.github.everest-preview+json')
|
85
|
+
.basic_auth(user: settings.github_login, pass: settings.github_token)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ossy/github/client'
|
4
|
+
|
5
|
+
module Ossy
|
6
|
+
module Github
|
7
|
+
class Workflow < Client
|
8
|
+
def call(repo, name, payload = {})
|
9
|
+
post("repos/#{repo}/dispatches", event_type: name, client_payload: payload)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/ossy/import.rb
ADDED
data/lib/ossy/release.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ossy/types'
|
4
|
+
require 'ossy/struct'
|
5
|
+
|
6
|
+
module Ossy
|
7
|
+
class Release < Ossy::Struct
|
8
|
+
attribute :version, Types::Version
|
9
|
+
attribute? :date, Types::ReleaseDate
|
10
|
+
attribute? :summary, Types::Summary
|
11
|
+
attribute? :fixed, Types::ChangeList
|
12
|
+
attribute? :added, Types::ChangeList
|
13
|
+
attribute? :changed, Types::ChangeList
|
14
|
+
|
15
|
+
def each(&block)
|
16
|
+
%i[fixed added changed].each do |type|
|
17
|
+
yield(type, self[type]) unless self[type].empty?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def meta
|
22
|
+
%i[version date summary]
|
23
|
+
.map { |key| [key.to_s, self[key]] if attributes.key?(key) }
|
24
|
+
.compact
|
25
|
+
.to_h
|
26
|
+
end
|
27
|
+
|
28
|
+
def fixed?
|
29
|
+
!fixed.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
def added?
|
33
|
+
!added.empty?
|
34
|
+
end
|
35
|
+
|
36
|
+
def changed?
|
37
|
+
!changed.empty?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/ossy/struct.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry/struct'
|
4
|
+
|
5
|
+
module Ossy
|
6
|
+
class Struct < Dry::Struct
|
7
|
+
transform_keys(&:to_sym)
|
8
|
+
|
9
|
+
transform_types do |type|
|
10
|
+
if type.default?
|
11
|
+
type.constructor do |value|
|
12
|
+
value.nil? ? Dry::Types::Undefined : value
|
13
|
+
end
|
14
|
+
else
|
15
|
+
type
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/ossy/types.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry/types'
|
4
|
+
|
5
|
+
module Ossy
|
6
|
+
module Types
|
7
|
+
include Dry.Types()
|
8
|
+
|
9
|
+
Version = Types::String.constrained(eql: 'unreleased') |
|
10
|
+
Types::String.constrained(format: %r[\d+\.\d+\.\d+])
|
11
|
+
|
12
|
+
Summary = Types::String.constrained(filled: true).optional
|
13
|
+
|
14
|
+
ReleaseDate = Types::Nil | Types::String | Types::Params::Date
|
15
|
+
|
16
|
+
ChangeList = Types::Coercible::Array
|
17
|
+
.of(Types::String.constrained(filled: true))
|
18
|
+
.default { [] }
|
19
|
+
end
|
20
|
+
end
|
data/lib/ossy/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,232 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ossy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Piotr Solnica
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-01-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dry-inflector
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.1.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.1.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: dry-cli
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.5'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.5'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: dry-types
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.2'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.2'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: dry-struct
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.2'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.2'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: dry-system
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0.14'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0.14'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: http
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '4.1'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '4.1'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: tilt
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '2.0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: bundler
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '2.0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '2.0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rake
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '10.0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '10.0'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: rspec
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '3.9'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '3.9'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: rubocop
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - '='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 0.71.0
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - '='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 0.71.0
|
173
|
+
description: Ossy is your ruby gem maintenance helper
|
174
|
+
email:
|
175
|
+
- piotr.solnica@gmail.com
|
176
|
+
executables:
|
177
|
+
- ossy
|
178
|
+
extensions: []
|
179
|
+
extra_rdoc_files: []
|
180
|
+
files:
|
181
|
+
- CHANGELOG.md
|
182
|
+
- README.md
|
183
|
+
- bin/ossy
|
184
|
+
- lib/ossy.rb
|
185
|
+
- lib/ossy/cli.rb
|
186
|
+
- lib/ossy/cli/changelogs/generate.rb
|
187
|
+
- lib/ossy/cli/changelogs/update.rb
|
188
|
+
- lib/ossy/cli/commands.rb
|
189
|
+
- lib/ossy/cli/commands/core.rb
|
190
|
+
- lib/ossy/cli/configs/merge.rb
|
191
|
+
- lib/ossy/cli/github/member.rb
|
192
|
+
- lib/ossy/cli/github/membership.rb
|
193
|
+
- lib/ossy/cli/github/tagger.rb
|
194
|
+
- lib/ossy/cli/github/update_file.rb
|
195
|
+
- lib/ossy/cli/github/workflow.rb
|
196
|
+
- lib/ossy/cli/templates/compile.rb
|
197
|
+
- lib/ossy/container.rb
|
198
|
+
- lib/ossy/github/client.rb
|
199
|
+
- lib/ossy/github/workflow.rb
|
200
|
+
- lib/ossy/import.rb
|
201
|
+
- lib/ossy/release.rb
|
202
|
+
- lib/ossy/struct.rb
|
203
|
+
- lib/ossy/types.rb
|
204
|
+
- lib/ossy/version.rb
|
205
|
+
homepage: https://github.com/solnic/ossy
|
206
|
+
licenses:
|
207
|
+
- MIT
|
208
|
+
metadata:
|
209
|
+
allowed_push_host: https://rubygems.org
|
210
|
+
homepage_uri: https://github.com/solnic/ossy
|
211
|
+
source_code_uri: https://github.com/solnic/ossy
|
212
|
+
changelog_uri: https://github.com/solnic/ossy
|
213
|
+
post_install_message:
|
214
|
+
rdoc_options: []
|
215
|
+
require_paths:
|
216
|
+
- lib
|
217
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - ">="
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
|
+
requirements:
|
224
|
+
- - ">="
|
225
|
+
- !ruby/object:Gem::Version
|
226
|
+
version: '0'
|
227
|
+
requirements: []
|
228
|
+
rubygems_version: 3.0.3
|
229
|
+
signing_key:
|
230
|
+
specification_version: 4
|
231
|
+
summary: Ossy is your ruby gem maintenance helper
|
232
|
+
test_files: []
|