flight_plan_cli 0.4.1 → 0.4.2
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/VERSION +1 -1
- data/lib/flight_plan_cli/api.rb +13 -1
- data/lib/flight_plan_cli/clients/flight_plan.rb +5 -5
- data/lib/flight_plan_cli/commands/checkout.rb +7 -5
- data/lib/flight_plan_cli/commands/config.rb +32 -0
- data/lib/flight_plan_cli/commands/list.rb +2 -2
- data/lib/flight_plan_cli/commands/release.rb +14 -4
- data/lib/flight_plan_cli/initializer.rb +13 -1
- data/lib/flight_plan_cli/settings.rb +51 -17
- data/lib/flight_plan_cli/utils.rb +14 -0
- data/lib/flight_plan_cli.rb +9 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5faa3c024a368a1b31c0ba594f0ed7aad71f8470
|
4
|
+
data.tar.gz: c5f6f0e7633224a2d879a9398a3ace6e6cb272a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f33825b438064b0d8d0bd1b2ce27b9bcad578749b3fc09596d11f57cfd5f8dd6429ad7febfb1f542fd7855c60a2e9e301a2459c80a5624902fd3343df5465bb
|
7
|
+
data.tar.gz: 104e6755bff099711d4b15a5fe074f802a111d88b650e95fa430157326967ad2f3c1ac7b14ecdc03df4736cbcd4a29cbe54ca66dd9160218ea7a0f9751aedaa5
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/lib/flight_plan_cli/api.rb
CHANGED
@@ -20,6 +20,17 @@ module FlightPlanCli
|
|
20
20
|
HTTParty.get("#{url}/boards/#{board_id}/board_tickets.json", query: params, headers: headers)
|
21
21
|
end
|
22
22
|
|
23
|
+
def create_release(title = nil)
|
24
|
+
params = {
|
25
|
+
release: {
|
26
|
+
title: title || 'FlightPlan CLI release',
|
27
|
+
repo_ids: [repo_id]
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
HTTParty.post("#{url}/boards/#{board_id}/releases", body: params.to_json, headers: headers)
|
32
|
+
end
|
33
|
+
|
23
34
|
private
|
24
35
|
|
25
36
|
attr_reader :url, :key, :secret
|
@@ -27,7 +38,8 @@ module FlightPlanCli
|
|
27
38
|
|
28
39
|
def headers
|
29
40
|
@headers = {
|
30
|
-
'Authorization' => "Token token=\"#{key}:#{secret}\""
|
41
|
+
'Authorization' => "Token token=\"#{key}:#{secret}\"",
|
42
|
+
'Content-Type' => 'application/json'
|
31
43
|
}
|
32
44
|
end
|
33
45
|
end
|
@@ -3,11 +3,11 @@ module FlightPlanCli
|
|
3
3
|
module FlightPlan
|
4
4
|
def flight_plan
|
5
5
|
@flight_plan ||= FlightPlanCli::Api.new(
|
6
|
-
url: FlightPlanCli
|
7
|
-
key: FlightPlanCli
|
8
|
-
secret: FlightPlanCli
|
9
|
-
board_id: FlightPlanCli
|
10
|
-
repo_id: FlightPlanCli
|
6
|
+
url: FlightPlanCli.settings.api_url,
|
7
|
+
key: FlightPlanCli.settings.api_key,
|
8
|
+
secret: FlightPlanCli.settings.api_secret,
|
9
|
+
board_id: FlightPlanCli.settings.board_id,
|
10
|
+
repo_id: FlightPlanCli.settings.repo_id
|
11
11
|
)
|
12
12
|
end
|
13
13
|
end
|
@@ -4,8 +4,10 @@ module FlightPlanCli
|
|
4
4
|
include FlightPlanCli::Clients::Git
|
5
5
|
include FlightPlanCli::Clients::FlightPlan
|
6
6
|
|
7
|
-
def initialize(issue_no)
|
7
|
+
def initialize(issue_no, options)
|
8
8
|
@issue_no = issue_no
|
9
|
+
@base_branch = options["base"]
|
10
|
+
@branch_prefix = options["prefix"]
|
9
11
|
@fetched = false
|
10
12
|
end
|
11
13
|
|
@@ -18,7 +20,7 @@ module FlightPlanCli
|
|
18
20
|
|
19
21
|
private
|
20
22
|
|
21
|
-
attr_reader :issue_no
|
23
|
+
attr_reader :issue_no, :base_branch, :branch_prefix
|
22
24
|
|
23
25
|
def local_branch_for_issue
|
24
26
|
issue_branches = local_branches.map(&:name).grep(/##{issue_no}[^0-9]/)
|
@@ -49,14 +51,14 @@ module FlightPlanCli
|
|
49
51
|
return false unless branches.count == 1
|
50
52
|
|
51
53
|
branch_name = branch_name(branches.first)
|
52
|
-
git.checkout(
|
54
|
+
git.checkout(base_branch)
|
53
55
|
git.pull
|
54
|
-
puts "Creating new branch #{branch_name} from
|
56
|
+
puts "Creating new branch #{branch_name} from #{base_branch}".green
|
55
57
|
git.branch(branch_name).checkout
|
56
58
|
end
|
57
59
|
|
58
60
|
def branch_name(branch)
|
59
|
-
"
|
61
|
+
"#{branch_prefix}/##{branch['ticket']['remote_number']}-" +
|
60
62
|
branch['ticket']['remote_title']
|
61
63
|
.gsub(/\([^)]*\)/, '') # remove everything inside brackets
|
62
64
|
.match(/^.{0,60}\b/)[0] # take the first 60 chars (finish on word boundry)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module FlightPlanCli
|
2
|
+
module Commands
|
3
|
+
class Config
|
4
|
+
def process
|
5
|
+
# Load config up-front to trigger any errors
|
6
|
+
FlightPlanCli.settings.config
|
7
|
+
|
8
|
+
puts '= CONFIG ===='.bold
|
9
|
+
puts "Using #{FlightPlanCli.settings.base_config_file}".green
|
10
|
+
pretty_print FlightPlanCli.settings.base_config
|
11
|
+
|
12
|
+
puts
|
13
|
+
|
14
|
+
puts '= USER ===='.bold
|
15
|
+
user_file = FlightPlanCli.settings.user_config_file
|
16
|
+
|
17
|
+
if user_file
|
18
|
+
puts "Using #{user_file}".green
|
19
|
+
pretty_print FlightPlanCli.settings.user_config
|
20
|
+
else
|
21
|
+
puts 'No user config file found'.yellow
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def pretty_print(config)
|
28
|
+
puts YAML.dump(config).sub(/^---\n/, '')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -13,7 +13,7 @@ module FlightPlanCli
|
|
13
13
|
|
14
14
|
def process
|
15
15
|
swimlanes = tickets_by_swimlane
|
16
|
-
|
16
|
+
FlightPlanCli.settings.default_swimlane_ids.each do |swimlane_id|
|
17
17
|
next unless swimlanes.key?(swimlane_id)
|
18
18
|
|
19
19
|
print_swimlane(swimlanes[swimlane_id])
|
@@ -35,7 +35,7 @@ module FlightPlanCli
|
|
35
35
|
swimlanes = {}
|
36
36
|
response.each do |board_ticket|
|
37
37
|
swimlane = board_ticket['swimlane']
|
38
|
-
next unless
|
38
|
+
next unless FlightPlanCli.settings.default_swimlane_ids.include? swimlane['id']
|
39
39
|
|
40
40
|
swimlanes[swimlane['id']] ||= swimlane
|
41
41
|
swimlanes[swimlane['id']]['tickets'] ||= []
|
@@ -4,13 +4,23 @@ module FlightPlanCli
|
|
4
4
|
include FlightPlanCli::Clients::FlightPlan
|
5
5
|
|
6
6
|
def process
|
7
|
-
|
8
|
-
|
7
|
+
response = flight_plan.create_release
|
8
|
+
unless response.code == 201
|
9
|
+
puts "Failed to create a release (#{response.code})".red
|
10
|
+
if response['errors'].present?
|
11
|
+
response['errors'].each do |error|
|
12
|
+
puts "error: #{error}".red
|
13
|
+
end
|
14
|
+
end
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
18
|
+
release = response['release']
|
9
19
|
repo_release = release['repo_releases'].first
|
10
|
-
puts "Created #{repo_release['repo']['name']} release \"#{release['title']}\" with the following tickets:"
|
20
|
+
puts "Created #{repo_release['repo']['name']} release \"#{release['title']}\" with the following tickets:".green
|
11
21
|
repo_release['board_tickets'].each do |board_ticket|
|
12
22
|
ticket = board_ticket['ticket']
|
13
|
-
puts " ##{ticket['remote_number']} - #{ticket['remote_title']}"
|
23
|
+
puts " ##{ticket['remote_number']} - #{ticket['remote_title']}".green
|
14
24
|
end
|
15
25
|
end
|
16
26
|
end
|
@@ -9,10 +9,22 @@ module FlightPlanCli
|
|
9
9
|
end
|
10
10
|
|
11
11
|
desc 'checkout ISSUE_NO', 'checkout a branch for ISSUE_NO'
|
12
|
+
option :base, desc: 'base branch for the new branch', aliases: :b, default: 'master'
|
13
|
+
option :prefix, desc: 'prefix for the new branch', aliases: :p, default: 'feature'
|
12
14
|
def checkout(issue_no)
|
13
|
-
Commands::Checkout.new(issue_no).process
|
15
|
+
Commands::Checkout.new(issue_no, options).process
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'release', 'create a release'
|
19
|
+
def release
|
20
|
+
Commands::Release.new.process
|
14
21
|
end
|
15
22
|
|
16
23
|
map co: :checkout
|
24
|
+
|
25
|
+
desc 'config', 'Print current config'
|
26
|
+
def config
|
27
|
+
Commands::Config.new.process
|
28
|
+
end
|
17
29
|
end
|
18
30
|
end
|
@@ -1,46 +1,80 @@
|
|
1
1
|
module FlightPlanCli
|
2
|
-
|
2
|
+
class Settings
|
3
3
|
CONFIG_YAML_PATH = '.flight_plan_cli/config.yml'.freeze
|
4
4
|
USER_YAML_PATH = '.flight_plan_cli/user.yml'.freeze
|
5
5
|
|
6
|
-
def
|
6
|
+
def board_id
|
7
7
|
config['board_id']
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def repo_id
|
11
11
|
config['repo_id']
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def default_swimlane_ids
|
15
15
|
config['ls']['default_swimlane_ids']
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def api_url
|
19
19
|
config['api_url']
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def api_key
|
23
23
|
config['flight_plan_api_key']
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def api_secret
|
27
27
|
config['flight_plan_api_secret']
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
31
|
-
@config ||=
|
30
|
+
def config
|
31
|
+
@config ||= base_config.merge(user_config)
|
32
|
+
end
|
33
|
+
|
34
|
+
def base_config_file
|
35
|
+
@base_config_file ||=
|
32
36
|
begin
|
33
|
-
|
34
|
-
YAML.load_file(CONFIG_YAML_PATH).merge(
|
35
|
-
FileTest.exist?(USER_YAML_PATH) ? YAML.load_file(USER_YAML_PATH) : {}
|
36
|
-
)
|
37
|
+
locate_file(CONFIG_YAML_PATH) or Utils.quit("#{CONFIG_YAML_PATH} not found")
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
def base_config
|
42
|
+
@base_config ||= load_yaml(base_config_file)
|
43
|
+
end
|
44
|
+
|
45
|
+
def user_config_file
|
46
|
+
@user_config_file ||= locate_file(USER_YAML_PATH)
|
47
|
+
end
|
48
|
+
|
49
|
+
def user_config
|
50
|
+
@user_config ||= load_yaml(user_config_file)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def locate_file(filename)
|
56
|
+
Pathname.pwd.ascend do |path|
|
57
|
+
found_file = path.join(filename)
|
58
|
+
|
59
|
+
return found_file if found_file.readable? && !found_file.directory?
|
60
|
+
break if path == home_directory
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def load_yaml(filename)
|
65
|
+
if filename
|
66
|
+
YAML.load_file(filename)
|
67
|
+
else
|
68
|
+
{}
|
69
|
+
end
|
70
|
+
rescue YAML::Exception => error
|
71
|
+
Utils.quit "Error parsing `#{filename}`:", error
|
72
|
+
rescue => error
|
73
|
+
Utils.quit "Error loading `#{filename}`:", error
|
74
|
+
end
|
75
|
+
|
76
|
+
def home_directory
|
77
|
+
@home_directory ||= Pathname.new(Dir.home)
|
44
78
|
end
|
45
79
|
end
|
46
80
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module FlightPlanCli
|
2
|
+
module Utils
|
3
|
+
def self.quit(message, error = nil)
|
4
|
+
warn message.red.bold
|
5
|
+
|
6
|
+
if error
|
7
|
+
warn "\n #{error.class}: #{error.message}".yellow
|
8
|
+
warn(error.backtrace.map {|line| " #{line}".white })
|
9
|
+
end
|
10
|
+
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/flight_plan_cli.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'colorize'
|
3
3
|
require 'git'
|
4
|
+
require 'flight_plan_cli/utils'
|
4
5
|
require 'flight_plan_cli/settings'
|
5
6
|
require 'flight_plan_cli/clients/git'
|
6
7
|
require 'flight_plan_cli/clients/flight_plan'
|
7
8
|
require 'flight_plan_cli/commands/list'
|
8
9
|
require 'flight_plan_cli/commands/checkout'
|
10
|
+
require 'flight_plan_cli/commands/release'
|
11
|
+
require 'flight_plan_cli/commands/config'
|
9
12
|
require 'flight_plan_cli/initializer'
|
10
13
|
require 'flight_plan_cli/version'
|
11
14
|
require 'flight_plan_cli/api'
|
15
|
+
|
16
|
+
module FlightPlanCli
|
17
|
+
def self.settings
|
18
|
+
@settings ||= Settings.new
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flight_plan_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Cleary
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.15.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fakefs
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.14.2
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.14.2
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,10 +193,12 @@ files:
|
|
179
193
|
- lib/flight_plan_cli/clients/flight_plan.rb
|
180
194
|
- lib/flight_plan_cli/clients/git.rb
|
181
195
|
- lib/flight_plan_cli/commands/checkout.rb
|
196
|
+
- lib/flight_plan_cli/commands/config.rb
|
182
197
|
- lib/flight_plan_cli/commands/list.rb
|
183
198
|
- lib/flight_plan_cli/commands/release.rb
|
184
199
|
- lib/flight_plan_cli/initializer.rb
|
185
200
|
- lib/flight_plan_cli/settings.rb
|
201
|
+
- lib/flight_plan_cli/utils.rb
|
186
202
|
- lib/flight_plan_cli/version.rb
|
187
203
|
homepage: https://github.com/jcleary/flight_plan_cli
|
188
204
|
licenses:
|