flow-cli 0.0.3 → 0.0.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/exe/flow-cli +4 -0
- data/flow-cli.gemspec +1 -0
- data/lib/flow/cli/cmd_manager.rb +0 -1
- data/lib/flow/cli/commands/remote.rb +42 -14
- data/lib/flow/cli/exception.rb +3 -0
- data/lib/flow/cli/utils/api/flow_api_manager.rb +30 -6
- data/lib/flow/cli/utils/flow_api_rest.rb +1 -1
- data/lib/flow/cli/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39618a37200754a1da9175cdc5b385f5c98db0c4
|
4
|
+
data.tar.gz: 25601c88ee90747b4558c48b3e934df7beef8491
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08aa0177b1bb2f3b327d39150458cd87e5e32779a82b4530f222e39d65bcae4dcc624b9c62cddccc3735dc4739e6529abd9efc6a5378979d7829ea6cac9985ad
|
7
|
+
data.tar.gz: e82b9396481f479325eeb1085d52b8ffdf75f4147b8d39f631667725b6bc3c802fcc65f282fdd28108fd142f4176385441775dabd08d939cb6063299ab6bf8f5
|
data/exe/flow-cli
CHANGED
data/flow-cli.gemspec
CHANGED
data/lib/flow/cli/cmd_manager.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'byebug'
|
2
3
|
require 'tty'
|
3
4
|
require 'thor'
|
4
5
|
|
5
6
|
module Flow::Cli
|
6
7
|
module Commands
|
7
8
|
class Remote < Thor
|
8
|
-
def initialize(*args)
|
9
|
+
def initialize(*args, &proc)
|
9
10
|
super(*args)
|
10
11
|
@prompt = TTY::Prompt.new
|
11
12
|
@pastel = Pastel.new
|
12
|
-
@
|
13
|
-
@
|
13
|
+
@warning = @pastel.yellow.detach
|
14
|
+
@error = @pastel.red.bold.detach
|
14
15
|
@db_manager = Utils::DbManager
|
15
|
-
@api_manager = Utils::FlowApiManager.load_from_db
|
16
|
+
@api_manager = Utils::FlowApiManager.load_from_db(&proc)
|
16
17
|
end
|
17
18
|
|
18
19
|
desc "login", "bind flow ci account to flow cli."
|
@@ -23,9 +24,15 @@ module Flow::Cli
|
|
23
24
|
puts "login success"
|
24
25
|
end
|
25
26
|
|
27
|
+
desc "reset", "reset flow api info data"
|
28
|
+
def reset
|
29
|
+
@db_manager.overide_save({})
|
30
|
+
puts "reset success..."
|
31
|
+
end
|
32
|
+
|
26
33
|
desc "project_init", "set a project from flow ci to operation"
|
27
34
|
def project_init
|
28
|
-
projects =
|
35
|
+
projects = current_api_manager.fetch_projects
|
29
36
|
begin
|
30
37
|
file_origin = `git remote -v`.to_s.match("git.*.git").first
|
31
38
|
rescue
|
@@ -39,7 +46,7 @@ module Flow::Cli
|
|
39
46
|
|
40
47
|
@db_manager.save_attribute(:current_project_id, current_project_id)
|
41
48
|
|
42
|
-
flows =
|
49
|
+
flows = current_api_manager.fetch_flows(current_project_id)
|
43
50
|
|
44
51
|
current_flow_id = if flows.count == 1
|
45
52
|
flows.first[:id]
|
@@ -54,48 +61,69 @@ module Flow::Cli
|
|
54
61
|
|
55
62
|
desc "upload_p12 FILE_PATH [p12 password]", "upload_p12"
|
56
63
|
def upload_p12(file_path, password = nil)
|
64
|
+
choosed_project_check
|
57
65
|
basename = File.basename file_path
|
58
66
|
project_init unless @db_manager.read_attribute(:current_flow_id)
|
59
67
|
|
60
|
-
api_p12s =
|
68
|
+
api_p12s = current_api_manager.load_p12s(@db_manager.read_attribute(:current_flow_id))
|
61
69
|
old_p12 = api_p12s.find { |p12| p12[:filename] == basename }
|
62
70
|
unless old_p12.nil?
|
63
71
|
if @prompt.yes? "found a same name file, override?"
|
64
|
-
|
72
|
+
current_api_manager.delete_p12(old_p12[:id], @db_manager.read_attribute(:current_flow_id))
|
65
73
|
else
|
66
74
|
return puts "canceled.."
|
67
75
|
end
|
68
76
|
end
|
69
|
-
|
77
|
+
current_api_manager.upload_p12(@db_manager.read_attribute(:current_flow_id), file_path, password)
|
70
78
|
puts "uploaded."
|
71
79
|
end
|
72
80
|
|
73
81
|
desc "list_p12s", "list_p12s"
|
74
82
|
def list_p12s
|
75
|
-
|
83
|
+
choosed_project_check
|
84
|
+
puts current_api_manager.load_p12s(@db_manager.read_attribute(:current_flow_id))
|
76
85
|
end
|
77
86
|
|
78
87
|
desc "upload_provision", "upload_provision"
|
79
88
|
def upload_provision(file_path)
|
89
|
+
choosed_project_check
|
80
90
|
basename = File.basename file_path
|
81
91
|
project_init unless @db_manager.read_attribute(:current_flow_id)
|
82
92
|
|
83
|
-
api_provisions =
|
93
|
+
api_provisions = current_api_manager.load_provisions(@db_manager.read_attribute(:current_flow_id))
|
84
94
|
old_provision = api_provisions.find { |provision| provision[:filename] == basename }
|
85
95
|
unless old_provision.nil?
|
86
96
|
if @prompt.yes? "found a same name file, override?"
|
87
|
-
|
97
|
+
current_api_manager.delete_provision(old_provision[:id], @db_manager.read_attribute(:current_flow_id))
|
88
98
|
else
|
89
99
|
return puts "canceled.."
|
90
100
|
end
|
91
101
|
end
|
92
|
-
|
102
|
+
current_api_manager.upload_provision(@db_manager.read_attribute(:current_flow_id), file_path)
|
93
103
|
puts "uploaded."
|
94
104
|
end
|
95
105
|
|
96
106
|
desc "list_provisions", "list provisions"
|
97
107
|
def list_provisions
|
98
|
-
|
108
|
+
choosed_project_check
|
109
|
+
puts current_api_manager.load_provisions(@db_manager.read_attribute(:current_flow_id))
|
110
|
+
end
|
111
|
+
|
112
|
+
no_commands do
|
113
|
+
private
|
114
|
+
|
115
|
+
def current_api_manager
|
116
|
+
return @current_api_manager unless @current_api_manager.nil?
|
117
|
+
@api_manager.refresh_login do
|
118
|
+
[@prompt.ask("email?"), @prompt.mask("password?")]
|
119
|
+
end
|
120
|
+
@current_api_manager = @api_manager
|
121
|
+
@current_api_manager
|
122
|
+
end
|
123
|
+
|
124
|
+
def choosed_project_check
|
125
|
+
project_init if @db_manager.read_attribute(:current_project_id).nil?
|
126
|
+
end
|
99
127
|
end
|
100
128
|
end
|
101
129
|
end
|
data/lib/flow/cli/exception.rb
CHANGED
@@ -11,7 +11,10 @@ module Flow::Cli
|
|
11
11
|
send "#{item}=", hash[item.to_s]
|
12
12
|
end
|
13
13
|
yield self if block_given?
|
14
|
-
|
14
|
+
end
|
15
|
+
|
16
|
+
def fetch_user
|
17
|
+
send_to_api("get", "/user")
|
15
18
|
end
|
16
19
|
|
17
20
|
def fetch_orgs
|
@@ -27,7 +30,7 @@ module Flow::Cli
|
|
27
30
|
end
|
28
31
|
|
29
32
|
def fetch_project(project_id)
|
30
|
-
|
33
|
+
send_to_apapi_manageri(:get, "/projects/#{project_id}")
|
31
34
|
end
|
32
35
|
|
33
36
|
def fetch_flows(project_id)
|
@@ -60,7 +63,7 @@ module Flow::Cli
|
|
60
63
|
send_to_api(:get, "/flows/#{flow_id}/mobileprovisions")
|
61
64
|
end
|
62
65
|
|
63
|
-
def delete_provision(mobileprovisions_id,flow_id)
|
66
|
+
def delete_provision(mobileprovisions_id, flow_id)
|
64
67
|
send_to_api(:delete, "/mobileprovisions/#{mobileprovisions_id}", flow_id: flow_id)
|
65
68
|
end
|
66
69
|
|
@@ -85,6 +88,26 @@ module Flow::Cli
|
|
85
88
|
self.user_access_token = answer[:access_token]
|
86
89
|
end
|
87
90
|
|
91
|
+
def refresh_login(&proc)
|
92
|
+
fetch_user
|
93
|
+
rescue FlowApiError
|
94
|
+
puts "login fail, relogin..."
|
95
|
+
tmp_email = nil
|
96
|
+
tmp_password = nil
|
97
|
+
tmp_email, tmp_password = yield unless proc.nil?
|
98
|
+
self.email = tmp_email || email
|
99
|
+
self.password = tmp_password || password
|
100
|
+
login(email, password)
|
101
|
+
self
|
102
|
+
end
|
103
|
+
|
104
|
+
def login(email, password)
|
105
|
+
hash = self.class.login(email, password)
|
106
|
+
%i[email password user_access_token].each do |item|
|
107
|
+
send "#{item}=", hash[item]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
88
111
|
def standard_file(file)
|
89
112
|
return File.open(file) if file.is_a?(String)
|
90
113
|
file
|
@@ -93,12 +116,13 @@ module Flow::Cli
|
|
93
116
|
class << self
|
94
117
|
def login(email, password)
|
95
118
|
dict = FlowApiRest.post("/login", login: email, password: password)
|
96
|
-
DbManager.save(email: email, password: password)
|
97
|
-
dict
|
119
|
+
DbManager.save(email: email, password: password, user_access_token: dict[:access_token])
|
120
|
+
{ email: email, password: password, user_access_token: dict[:access_token] }
|
98
121
|
end
|
99
122
|
|
100
123
|
def load_from_db
|
101
|
-
|
124
|
+
dict = DbManager.read
|
125
|
+
new(dict)
|
102
126
|
end
|
103
127
|
end
|
104
128
|
end
|
@@ -11,7 +11,7 @@ module Flow::Cli
|
|
11
11
|
alias_method "#{method}_old", method
|
12
12
|
define_method method do |*args, &blk|
|
13
13
|
ret = __send__ "#{method}_old", *args, &blk
|
14
|
-
raise "response_body = #{ret[:response_body]}" if ret.is_a?(Hash) && ret[:status] == false
|
14
|
+
raise FlowApiError, "response_body = #{ret[:response_body]}" if ret.is_a?(Hash) && ret[:status] == false
|
15
15
|
ret
|
16
16
|
end
|
17
17
|
end
|
data/lib/flow/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flow-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- atpking
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -210,7 +210,8 @@ post_install_message: "\n _____ _ _____ ______ ___ ____ _ ___
|
|
210
210
|
\\ /\\ / / | | | | | | | | |\n | _| | |__| |_| |\\ V V /| |___ | | |
|
211
211
|
|___| |___ | |\n |_| |_____\\___/ \\_/\\_/(_)____|___| \\____|_____|___|\n\n
|
212
212
|
****************************************************\n 这是 flow.ci CLI 的早期版本,暂时只支持
|
213
|
-
ios 项目\n\n0.0.
|
213
|
+
ios 项目\n\n0.0.4 版本修正 在执行一些remote 指令,如果没登录,会报错的问题 另附增加 remote reset 指令\n0.0.3 版本新增
|
214
|
+
flow-cli remote 系列指令,支持传证书,传provisions 文件\n\n "
|
214
215
|
rdoc_options: []
|
215
216
|
require_paths:
|
216
217
|
- lib
|