github_make_triage 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/LICENSE +21 -0
- data/README.md +15 -0
- data/bin/make-triage-project +56 -0
- data/github_make_triage.gemspec +21 -0
- data/lib/make_triage.rb +11 -0
- data/lib/make_triage/cli.rb +38 -0
- data/lib/make_triage/default_columns.rb +14 -0
- data/lib/make_triage/error.rb +6 -0
- data/lib/make_triage/error_handler.rb +23 -0
- data/lib/make_triage/github.rb +38 -0
- data/lib/make_triage/project_builder.rb +73 -0
- data/lib/make_triage/version.rb +5 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fb15fb5e47747d2cd266e0be6a7a9c8c411dd87d
|
4
|
+
data.tar.gz: d51114b18ede545f2278abf9ccb5d1f0e4bb3e96
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d299bc9cdc2cf1ef8ddffe849f3f065d4c7e369da11497102cb40f6f1bc407f40db7bb33ef37490e9fa383a1c39f5d83b77b5af7e5afff98d600b67a19b9ada4
|
7
|
+
data.tar.gz: 5b1171b11f801526b2585abddd9c97ca717c221b29d533f5c95f59df783371c1837630cf6578003d2d664a45a1052056c107d1a95f275f4a40364466d6259327
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Tallwave
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# GitHub Triage Project Maker
|
2
|
+
|
3
|
+
[](https://circleci.com/gh/Tallwave/github_make_triage) [](https://codeclimate.com/github/Tallwave/github_make_triage)
|
4
|
+
|
5
|
+
DESCRIPTION
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
## Contributing
|
12
|
+
|
13
|
+
* Fork
|
14
|
+
* Make it better
|
15
|
+
* Create a Pull Request
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby -W
|
2
|
+
# Copyright (c) 2017 Tallwave
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
|
5
|
+
|
6
|
+
require "make_triage/cli"
|
7
|
+
|
8
|
+
module MakeTriage
|
9
|
+
class Command
|
10
|
+
include CLI
|
11
|
+
|
12
|
+
def about
|
13
|
+
VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
def usage
|
17
|
+
<<HERE
|
18
|
+
Create a basic template in a GitHub project for bug triage.
|
19
|
+
|
20
|
+
Usage: #{$PROGRAM_NAME} [OPTION]... [OWNER] [REPO] [TOKEN]
|
21
|
+
|
22
|
+
Example: #{$PROGRAM_NAME} tallwave my_project abcdef
|
23
|
+
|
24
|
+
-h, --help display this help and exit
|
25
|
+
--version display the version
|
26
|
+
|
27
|
+
HERE
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def correct_number_of_args(arg_count)
|
32
|
+
arg_count == 3
|
33
|
+
end
|
34
|
+
|
35
|
+
def process_input(arg, index)
|
36
|
+
case index
|
37
|
+
when 0
|
38
|
+
@owner = arg
|
39
|
+
when 1
|
40
|
+
@repo = arg
|
41
|
+
when 2
|
42
|
+
@token = arg
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def define_options(options)
|
47
|
+
end
|
48
|
+
|
49
|
+
def perform_action
|
50
|
+
builder = MakeTriage::ProjectBuilder.new(@owner, @repo, @token)
|
51
|
+
builder.make
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
MakeTriage::Command.new.run
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib')
|
2
|
+
|
3
|
+
require 'make_triage'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'github_make_triage'
|
7
|
+
s.version = MakeTriage::VERSION
|
8
|
+
s.required_ruby_version = '>= 2.0'
|
9
|
+
s.summary = 'Create a Triage Workflow in a GitHub Project'
|
10
|
+
s.description = <<-HERE
|
11
|
+
Create a Triage Workflow in a GitHub Project
|
12
|
+
HERE
|
13
|
+
s.license = 'MIT'
|
14
|
+
s.author = 'Scott Williams'
|
15
|
+
s.email = 'scott@swilliams.me'
|
16
|
+
s.homepage = 'https://github.com/Tallwave/github_make_triage'
|
17
|
+
s.files = Dir['{bin,lib}/**/*'] + ['github_make_triage.gemspec']
|
18
|
+
s.executables = ['make-triage-project']
|
19
|
+
s.extra_rdoc_files = ['LICENSE', 'README.md']
|
20
|
+
s.require_paths = ['lib']
|
21
|
+
end
|
data/lib/make_triage.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Copyright (c) 2017 Tallwave
|
2
|
+
|
3
|
+
require "English"
|
4
|
+
require "shellwords"
|
5
|
+
require "json"
|
6
|
+
require "make_triage/github"
|
7
|
+
require "make_triage/error_handler"
|
8
|
+
require "make_triage/default_columns"
|
9
|
+
require "make_triage/project_builder"
|
10
|
+
require "make_triage/error"
|
11
|
+
require "make_triage/version"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright (c) 2017 Tallwave
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require "make_triage"
|
5
|
+
|
6
|
+
module MakeTriage
|
7
|
+
module CLI
|
8
|
+
|
9
|
+
def run
|
10
|
+
begin
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
define_options opts
|
13
|
+
opts.on "-h", "--help" do
|
14
|
+
puts usage
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on "--version" do
|
19
|
+
puts about
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
end.parse!
|
24
|
+
rescue OptionParser::ParseError => e
|
25
|
+
raise UsageError, e
|
26
|
+
end
|
27
|
+
|
28
|
+
fail UsageError, "missing argument" if ARGV.empty?
|
29
|
+
fail UsageError, "incorrect number of arguments" unless correct_number_of_args ARGV.count
|
30
|
+
ARGV.each_with_index { |arg, index| process_input arg, index }
|
31
|
+
perform_action()
|
32
|
+
|
33
|
+
rescue UsageError => e
|
34
|
+
puts "#{$PROGRAM_NAME}: #{e}\nTry `#{$PROGRAM_NAME} --help` for more information."
|
35
|
+
exit false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module MakeTriage
|
2
|
+
class ErrorHandler
|
3
|
+
def response_has_error(response)
|
4
|
+
response.code.to_i > 299
|
5
|
+
end
|
6
|
+
|
7
|
+
def error_message(response_text)
|
8
|
+
response_object = JSON.parse response_text
|
9
|
+
if response_object.is_a? Hash
|
10
|
+
response_object["message"]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def handle_error(error_message, should_abort = true)
|
15
|
+
msg = "ERROR: #{error_message}"
|
16
|
+
if should_abort
|
17
|
+
abort msg
|
18
|
+
else
|
19
|
+
puts msg
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
|
3
|
+
module MakeTriage
|
4
|
+
def self.project_url
|
5
|
+
"https://api.github.com/repos/%s/%s/projects?access_token=%s"
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.column_url
|
9
|
+
"https://api.github.com/projects/%s/columns?access_token=%s"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.make_project_url(*args)
|
13
|
+
url_format = MakeTriage.project_url
|
14
|
+
url_format % args
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.make_column_url(*args)
|
18
|
+
url_format = MakeTriage.column_url
|
19
|
+
url_format % args
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.make_project_uri(owner, repo, token)
|
23
|
+
URI.parse MakeTriage.make_project_url(owner, repo, token)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.make_column_uri(project_id, token)
|
27
|
+
URI.parse MakeTriage.make_column_url(project_id, token)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.turn_options_into_querystring(options)
|
31
|
+
querystring = ''
|
32
|
+
options.each do |k, v|
|
33
|
+
escaped_k, escaped_v = URI::encode(k), URI::encode(v)
|
34
|
+
querystring += "#{escaped_k}=#{escaped_v}&"
|
35
|
+
end
|
36
|
+
querystring.chop
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Copyright (c) 2017 Tallwave
|
2
|
+
|
3
|
+
require "net/http"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module MakeTriage
|
7
|
+
class ProjectBuilder
|
8
|
+
|
9
|
+
attr_accessor :outputter
|
10
|
+
|
11
|
+
def initialize(owner, repo, token = nil)
|
12
|
+
@owner = owner
|
13
|
+
@repo = repo
|
14
|
+
@token = token
|
15
|
+
end
|
16
|
+
|
17
|
+
def make
|
18
|
+
new_project_id = create_project 'Bug Tracking', 'Issue tracking and triage board'
|
19
|
+
if new_project_id
|
20
|
+
create_columns new_project_id, MakeTriage.default_columns
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def create_project(name, description)
|
26
|
+
uri = MakeTriage.make_project_uri @owner, @repo, @token
|
27
|
+
payload = {
|
28
|
+
"name" => name,
|
29
|
+
"body" => description
|
30
|
+
}
|
31
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
32
|
+
http.use_ssl = true if uri.scheme == "https"
|
33
|
+
req = Net::HTTP::Post.new uri.request_uri
|
34
|
+
req.content_type = "application/json"
|
35
|
+
req.add_field "Accept", "application/vnd.github.inertia-preview+json"
|
36
|
+
req.body = payload.to_json
|
37
|
+
response = handle_response http.request(req)
|
38
|
+
return retrieve_id(response) unless response == false
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_columns(project_id, columns)
|
42
|
+
columns.each { |column_name| create_column(project_id, column_name) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_column(project_id, column_name)
|
46
|
+
uri = MakeTriage.make_column_uri project_id, @token
|
47
|
+
payload = {
|
48
|
+
"name" => column_name
|
49
|
+
}
|
50
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
51
|
+
http.use_ssl = true if uri.scheme == "https"
|
52
|
+
req = Net::HTTP::Post.new uri.request_uri
|
53
|
+
req.content_type = "application/json"
|
54
|
+
req.add_field "Accept", "application/vnd.github.inertia-preview+json"
|
55
|
+
req.body = payload.to_json
|
56
|
+
return handle_response http.request(req)
|
57
|
+
end
|
58
|
+
|
59
|
+
def handle_response(response)
|
60
|
+
error_handler = ErrorHandler.new
|
61
|
+
if error_handler.response_has_error response
|
62
|
+
error_handler.handle_error error_handler.error_message(response.body), true
|
63
|
+
return false
|
64
|
+
end
|
65
|
+
return response.body
|
66
|
+
end
|
67
|
+
|
68
|
+
def retrieve_id(body)
|
69
|
+
response_obj = JSON.parse(body)
|
70
|
+
response_obj["id"]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github_make_triage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Williams
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |2
|
14
|
+
Create a Triage Workflow in a GitHub Project
|
15
|
+
email: scott@swilliams.me
|
16
|
+
executables:
|
17
|
+
- make-triage-project
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files:
|
20
|
+
- LICENSE
|
21
|
+
- README.md
|
22
|
+
files:
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- bin/make-triage-project
|
26
|
+
- github_make_triage.gemspec
|
27
|
+
- lib/make_triage.rb
|
28
|
+
- lib/make_triage/cli.rb
|
29
|
+
- lib/make_triage/default_columns.rb
|
30
|
+
- lib/make_triage/error.rb
|
31
|
+
- lib/make_triage/error_handler.rb
|
32
|
+
- lib/make_triage/github.rb
|
33
|
+
- lib/make_triage/project_builder.rb
|
34
|
+
- lib/make_triage/version.rb
|
35
|
+
homepage: https://github.com/Tallwave/github_make_triage
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.2.2
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: Create a Triage Workflow in a GitHub Project
|
59
|
+
test_files: []
|