brightpearl-cli 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/bin/bp +1 -1
- data/bin/brightpearl +1 -1
- data/lib/brightpearl_cli.rb +161 -168
- data/lib/core/api.rb +1 -1
- data/lib/core/config.rb +10 -133
- data/lib/core/config_unique.rb +113 -0
- data/lib/core/encrypter.rb +6 -6
- data/lib/core/enums.rb +1 -1
- data/lib/core/git.rb +123 -108
- data/lib/core/git_delete.rb +89 -0
- data/lib/core/jira.rb +2 -2
- data/lib/core/mysql.rb +14 -14
- data/lib/core/pom.rb +129 -0
- data/lib/core/terminal.rb +28 -8
- data/lib/core/tools.rb +6 -6
- data/lib/core/utils_files.rb +92 -0
- data/lib/core/utils_routes.rb +25 -0
- data/lib/core/utils_strings.rb +45 -0
- data/lib/core/validate.rb +1 -1
- data/lib/routes/build.rb +16 -17
- data/lib/routes/dummy_order.rb +5 -5
- data/lib/routes/fix.rb +49 -0
- data/lib/routes/git_branch.rb +6 -6
- data/lib/routes/git_checkout.rb +42 -33
- data/lib/routes/git_delete.rb +8 -62
- data/lib/routes/git_merge.rb +198 -111
- data/lib/routes/git_pull.rb +11 -11
- data/lib/routes/git_push.rb +21 -12
- data/lib/routes/git_stash.rb +13 -8
- data/lib/routes/git_update.rb +17 -22
- data/lib/routes/jira.rb +3 -3
- data/lib/routes/production_logs.rb +12 -12
- data/lib/routes/reset.rb +1 -1
- data/lib/routes/review.rb +6 -5
- data/lib/routes/scripts_api_docs.rb +5 -5
- data/lib/routes/scripts_branch_cleaner.rb +58 -79
- data/lib/routes/scripts_color.rb +1 -1
- data/lib/routes/scripts_pom_fixer.rb +5 -62
- data/lib/routes/scripts_sonar.rb +82 -0
- data/lib/routes/setup.rb +6 -6
- data/lib/routes/tail.rb +5 -5
- data/lib/routes/test.rb +3 -3
- data/lib/routes/update.rb +1 -1
- metadata +16 -9
- data/lib/routes/scripts_code_sniffer.rb +0 -36
data/lib/core/config.rb
CHANGED
@@ -1,45 +1,14 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'parseconfig'
|
3
3
|
|
4
|
-
module
|
4
|
+
module App
|
5
5
|
|
6
6
|
class Config
|
7
7
|
|
8
|
-
CONFIG_FILE = '~/.brightpearlrc'
|
9
|
-
|
10
|
-
MAC = 'mac'
|
11
|
-
LINUX = 'linux'
|
12
|
-
|
13
|
-
WORKSTATION_IP = 'workstation_ip'
|
14
|
-
WORKSTATION_OS = 'workstation_os'
|
15
|
-
WORKSTATION_PATH_TO_BP_CODE = 'workstation_path_to_bp_code'
|
16
|
-
WORKSTATION_PATH_TO_BP_DB = 'workstation_path_to_bp_db'
|
17
|
-
VM_IP = 'vm_ip'
|
18
|
-
VM_USER = 'vm_user'
|
19
|
-
VM_USER_PASSWORD = 'vm_user_password'
|
20
|
-
VM_ROOT = 'vm_root'
|
21
|
-
VM_ROOT_PASSWORD = 'vm_root_password'
|
22
|
-
VM_MYSQL_USER = 'vm_mysql_user'
|
23
|
-
VM_MYSQL_PASSWORD = 'vm_mysql_password'
|
24
|
-
|
25
|
-
BETA = 'beta'
|
26
|
-
PREFERRED_TEXT_EDITOR = 'preferred_text_editor'
|
27
|
-
GIT_USERNAME = 'git_username'
|
28
|
-
|
29
|
-
CRYPT_KEY = 'crypt_key'
|
30
|
-
CRYPT_HEX = 'crypt_hex'
|
31
|
-
EC2_HOST = 'ec2_host'
|
32
|
-
EC2_USER = 'ec2_user'
|
33
|
-
EC2_PASS = 'ec2_pass'
|
34
|
-
|
35
8
|
@params = {}
|
36
9
|
|
37
|
-
|
38
|
-
|
39
|
-
Brightpearl::Terminal::error("#{Brightpearl::Terminal::format_highlight(param_name)} is not a valid config parameter", true)
|
40
|
-
end
|
41
|
-
@params[param_name]
|
42
|
-
end
|
10
|
+
extend ConfigUnique
|
11
|
+
include ConfigUnique
|
43
12
|
|
44
13
|
def self.initialize
|
45
14
|
if config_file_exists?
|
@@ -50,7 +19,7 @@ module Brightpearl
|
|
50
19
|
end
|
51
20
|
|
52
21
|
def self.config_file_exists?
|
53
|
-
unless File.exists?(File.expand_path(CONFIG_FILE))
|
22
|
+
unless File.exists? ("#{File.expand_path(CONFIG_FILE)}")
|
54
23
|
return false
|
55
24
|
end
|
56
25
|
true
|
@@ -71,53 +40,19 @@ module Brightpearl
|
|
71
40
|
|
72
41
|
def self.first_journey_message
|
73
42
|
puts
|
74
|
-
puts "Thank you for installing the #{
|
43
|
+
puts "Thank you for installing the #{App::Terminal::format_highlight("#{GEM_NAME}-cli")} ruby gem."
|
75
44
|
puts "CLI stands for 'Command Line Interface'."
|
76
45
|
puts
|
77
46
|
puts "The first thing you'll need to do is setup your configuration file."
|
78
|
-
puts "The file is located at: #{
|
47
|
+
puts "The file is located at: #{App::Terminal::format_directory(App::Config)}"
|
79
48
|
puts
|
80
49
|
puts "You probably won't have this file so the program will create it for you."
|
81
50
|
puts "\n"
|
82
|
-
unless
|
83
|
-
|
51
|
+
unless App::Terminal::prompt_yes_no('Create configuration file?')
|
52
|
+
App::Terminal::abort
|
84
53
|
end
|
85
54
|
end
|
86
55
|
|
87
|
-
def self.config_file_create
|
88
|
-
File.open("#{File.expand_path(CONFIG_FILE)}", 'w') { |file|
|
89
|
-
file.write("# CONFIGURATION FILE -- Use this file to configure brightpearl-cli\n")
|
90
|
-
file.write("\n")
|
91
|
-
file.write("#{WORKSTATION_IP}=172.27.X.X\n")
|
92
|
-
file.write("#{WORKSTATION_OS}=linux\n")
|
93
|
-
file.write("#{WORKSTATION_PATH_TO_BP_CODE}=/brightpearl-source/brightpearl-code\n")
|
94
|
-
file.write("#{WORKSTATION_PATH_TO_BP_DB}=/brightpearl-source/brightpearl-db\n")
|
95
|
-
file.write("\n")
|
96
|
-
file.write("#{VM_IP}=172.27.X.X\n")
|
97
|
-
file.write("#{VM_USER}=\n")
|
98
|
-
file.write("#{VM_USER_PASSWORD}=\n")
|
99
|
-
file.write("#{VM_ROOT}=root\n")
|
100
|
-
file.write("#{VM_ROOT_PASSWORD}=peXXXXXXXre\n")
|
101
|
-
file.write("#{VM_MYSQL_USER}=root\n")
|
102
|
-
file.write("#{VM_MYSQL_PASSWORD}=peXXXXXXXre\n")
|
103
|
-
file.write("\n")
|
104
|
-
file.write("# Usually vi, vim or nano\n")
|
105
|
-
file.write("#{PREFERRED_TEXT_EDITOR}=\n")
|
106
|
-
file.write("\n")
|
107
|
-
file.write("# Found by running $ git config user.name\n")
|
108
|
-
file.write("#{GIT_USERNAME}=\n")
|
109
|
-
file.write("\n")
|
110
|
-
file.write("#{CRYPT_KEY}=\n")
|
111
|
-
file.write("#{CRYPT_HEX}=\n")
|
112
|
-
file.write("#{EC2_HOST}=\n")
|
113
|
-
file.write("#{EC2_USER}=\n")
|
114
|
-
file.write("#{EC2_PASS}=\n")
|
115
|
-
file.write("\n")
|
116
|
-
file.write("# BETA FEATURES -- Set to TRUE to enable beta features -- NOT RECOMMENDED!\n")
|
117
|
-
file.write("#{BETA}=false\n")
|
118
|
-
}
|
119
|
-
end
|
120
|
-
|
121
56
|
def self.config_file_edit
|
122
57
|
system("nano #{File.expand_path(CONFIG_FILE)}")
|
123
58
|
end
|
@@ -138,32 +73,17 @@ module Brightpearl
|
|
138
73
|
end
|
139
74
|
error_text = error_text[0..-2]
|
140
75
|
end
|
141
|
-
workstation_os = Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_OS)
|
142
|
-
unless workstation_os.downcase == MAC || workstation_os.downcase == LINUX
|
143
|
-
unless error_text == ''
|
144
|
-
error_text = "#{error_text}\n\n"
|
145
|
-
end
|
146
|
-
error_text = "#{error_text}\x1B[38;5;196mThe value for \x1B[38;5;240m#{WORKSTATION_OS}\x1B[38;5;196m must be either: \x1B[38;5;84m#{MAC}\x1B[38;5;196m or \x1B[38;5;84m#{LINUX}\x1B[38;5;196m\x1B[0m\n"
|
147
|
-
end
|
148
|
-
code_repo = Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)
|
149
|
-
db_repo = Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)
|
150
|
-
unless File.directory?(code_repo)
|
151
|
-
error_text = "#{error_text}The following is NOT a valid directory: \x1B[0m#{code_repo}\x1B[90m\n"
|
152
|
-
end
|
153
|
-
unless File.directory?(db_repo)
|
154
|
-
error_text = "#{error_text}The following is NOT a valid directory: \x1B[0m#{db_repo}\x1B[90m\n"
|
155
|
-
end
|
156
76
|
unless error_text == ''
|
157
77
|
show_error_message(error_text)
|
158
78
|
end
|
159
79
|
if show_success_message
|
160
|
-
|
80
|
+
App::Terminal::success('Configuration parameters are correct.', "You are now ready to start using this utility.\nStart by typing #{App::Terminal::format_command("#{GEM_NAME} --help")} (or #{App::Terminal::format_command("#{GEM_NAME} -h")}).")
|
161
81
|
exit
|
162
82
|
end
|
163
83
|
end
|
164
84
|
|
165
85
|
def self.show_error_message(error_text)
|
166
|
-
|
86
|
+
App::Terminal::error('Your configuration parameters are invalid.', "#{error_text}\n\nYou can fix this by running #{App::Terminal::format_command("#{GEM_NAME} setup")} (or #{App::Terminal::format_command("#{GEM_NAME} x")}).")
|
167
87
|
exit
|
168
88
|
end
|
169
89
|
|
@@ -177,49 +97,6 @@ module Brightpearl
|
|
177
97
|
missing_keys
|
178
98
|
end
|
179
99
|
|
180
|
-
def self.required_config_keys
|
181
|
-
[
|
182
|
-
WORKSTATION_IP,
|
183
|
-
WORKSTATION_OS,
|
184
|
-
WORKSTATION_PATH_TO_BP_CODE,
|
185
|
-
WORKSTATION_PATH_TO_BP_DB,
|
186
|
-
VM_IP,
|
187
|
-
VM_USER,
|
188
|
-
VM_USER_PASSWORD,
|
189
|
-
VM_ROOT,
|
190
|
-
VM_ROOT_PASSWORD,
|
191
|
-
VM_MYSQL_USER,
|
192
|
-
VM_MYSQL_PASSWORD,
|
193
|
-
PREFERRED_TEXT_EDITOR,
|
194
|
-
GIT_USERNAME
|
195
|
-
]
|
196
|
-
end
|
197
|
-
|
198
|
-
def self.all_available_config_keys
|
199
|
-
[
|
200
|
-
WORKSTATION_IP,
|
201
|
-
WORKSTATION_OS,
|
202
|
-
WORKSTATION_PATH_TO_BP_CODE,
|
203
|
-
WORKSTATION_PATH_TO_BP_DB,
|
204
|
-
VM_IP,
|
205
|
-
VM_USER,
|
206
|
-
VM_USER_PASSWORD,
|
207
|
-
VM_ROOT,
|
208
|
-
VM_ROOT_PASSWORD,
|
209
|
-
VM_MYSQL_USER,
|
210
|
-
VM_MYSQL_PASSWORD,
|
211
|
-
PREFERRED_TEXT_EDITOR,
|
212
|
-
GIT_USERNAME,
|
213
|
-
BETA,
|
214
|
-
CRYPT_KEY,
|
215
|
-
CRYPT_HEX,
|
216
|
-
EC2_HOST,
|
217
|
-
EC2_USER,
|
218
|
-
EC2_PASS
|
219
|
-
]
|
220
|
-
end
|
221
|
-
|
222
100
|
end
|
223
101
|
|
224
|
-
|
225
102
|
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'parseconfig'
|
3
|
+
|
4
|
+
module ConfigUnique
|
5
|
+
|
6
|
+
# USED BY CONFIG CLASS
|
7
|
+
CONFIG_FILE = '~/.brightpearlrc'
|
8
|
+
GEM_NAME = 'brightpearl'
|
9
|
+
|
10
|
+
# MISC
|
11
|
+
MAC = 'mac'
|
12
|
+
LINUX = 'linux'
|
13
|
+
|
14
|
+
# STORED PARAMETERS
|
15
|
+
WORKSTATION_IP = 'workstation_ip'
|
16
|
+
WORKSTATION_OS = 'workstation_os'
|
17
|
+
WORKSTATION_PATH_TO_BP_CODE = 'workstation_path_to_bp_code'
|
18
|
+
WORKSTATION_PATH_TO_BP_DB = 'workstation_path_to_bp_db'
|
19
|
+
VM_IP = 'vm_ip'
|
20
|
+
VM_USER = 'vm_user'
|
21
|
+
VM_USER_PASSWORD = 'vm_user_password'
|
22
|
+
VM_ROOT = 'vm_root'
|
23
|
+
VM_ROOT_PASSWORD = 'vm_root_password'
|
24
|
+
VM_MYSQL_USER = 'vm_mysql_user'
|
25
|
+
VM_MYSQL_PASSWORD = 'vm_mysql_password'
|
26
|
+
PREFERRED_TEXT_EDITOR = 'preferred_text_editor'
|
27
|
+
GIT_USERNAME = 'git_username'
|
28
|
+
CRYPT_KEY = 'crypt_key'
|
29
|
+
CRYPT_HEX = 'crypt_hex'
|
30
|
+
EC2_HOST = 'ec2_host'
|
31
|
+
EC2_USER = 'ec2_user'
|
32
|
+
EC2_PASS = 'ec2_pass'
|
33
|
+
|
34
|
+
def param(param_name)
|
35
|
+
unless all_available_config_keys.include?(param_name)
|
36
|
+
App::Terminal::error("#{App::Terminal::format_highlight(param_name)} is not a valid config parameter", true)
|
37
|
+
end
|
38
|
+
@params[param_name]
|
39
|
+
end
|
40
|
+
|
41
|
+
def config_file_create
|
42
|
+
File.open("#{File.expand_path(CONFIG_FILE)}", 'w') { |file|
|
43
|
+
file.write("# CONFIGURATION FILE -- Use this file to configure brightpearl-cli\n")
|
44
|
+
file.write("\n")
|
45
|
+
file.write("#{WORKSTATION_IP}=172.27.X.X\n")
|
46
|
+
file.write("#{WORKSTATION_OS}=linux\n")
|
47
|
+
file.write("#{WORKSTATION_PATH_TO_BP_CODE}=/brightpearl-source/brightpearl-code\n")
|
48
|
+
file.write("#{WORKSTATION_PATH_TO_BP_DB}=/brightpearl-source/brightpearl-db\n")
|
49
|
+
file.write("\n")
|
50
|
+
file.write("#{VM_IP}=172.27.X.X\n")
|
51
|
+
file.write("#{VM_USER}=\n")
|
52
|
+
file.write("#{VM_USER_PASSWORD}=\n")
|
53
|
+
file.write("#{VM_ROOT}=root\n")
|
54
|
+
file.write("#{VM_ROOT_PASSWORD}=peXXXXXXXre\n")
|
55
|
+
file.write("#{VM_MYSQL_USER}=root\n")
|
56
|
+
file.write("#{VM_MYSQL_PASSWORD}=peXXXXXXXre\n")
|
57
|
+
file.write("\n")
|
58
|
+
file.write("# Usually vi, vim or nano\n")
|
59
|
+
file.write("#{PREFERRED_TEXT_EDITOR}=\n")
|
60
|
+
file.write("\n")
|
61
|
+
file.write("# Found by running $ git config user.name\n")
|
62
|
+
file.write("#{GIT_USERNAME}=\n")
|
63
|
+
file.write("\n")
|
64
|
+
file.write("#{CRYPT_KEY}=\n")
|
65
|
+
file.write("#{CRYPT_HEX}=\n")
|
66
|
+
file.write("#{EC2_HOST}=\n")
|
67
|
+
file.write("#{EC2_USER}=\n")
|
68
|
+
file.write("#{EC2_PASS}=\n")
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
def required_config_keys
|
73
|
+
[
|
74
|
+
WORKSTATION_IP,
|
75
|
+
WORKSTATION_OS,
|
76
|
+
WORKSTATION_PATH_TO_BP_CODE,
|
77
|
+
WORKSTATION_PATH_TO_BP_DB,
|
78
|
+
VM_IP,
|
79
|
+
VM_USER,
|
80
|
+
VM_USER_PASSWORD,
|
81
|
+
VM_ROOT,
|
82
|
+
VM_ROOT_PASSWORD,
|
83
|
+
VM_MYSQL_USER,
|
84
|
+
VM_MYSQL_PASSWORD,
|
85
|
+
PREFERRED_TEXT_EDITOR,
|
86
|
+
GIT_USERNAME
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
def all_available_config_keys
|
91
|
+
[
|
92
|
+
WORKSTATION_IP,
|
93
|
+
WORKSTATION_OS,
|
94
|
+
WORKSTATION_PATH_TO_BP_CODE,
|
95
|
+
WORKSTATION_PATH_TO_BP_DB,
|
96
|
+
VM_IP,
|
97
|
+
VM_USER,
|
98
|
+
VM_USER_PASSWORD,
|
99
|
+
VM_ROOT,
|
100
|
+
VM_ROOT_PASSWORD,
|
101
|
+
VM_MYSQL_USER,
|
102
|
+
VM_MYSQL_PASSWORD,
|
103
|
+
PREFERRED_TEXT_EDITOR,
|
104
|
+
GIT_USERNAME,
|
105
|
+
CRYPT_KEY,
|
106
|
+
CRYPT_HEX,
|
107
|
+
EC2_HOST,
|
108
|
+
EC2_USER,
|
109
|
+
EC2_PASS
|
110
|
+
]
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
data/lib/core/encrypter.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'openssl'
|
2
2
|
require 'base64'
|
3
3
|
|
4
|
-
module
|
4
|
+
module App
|
5
5
|
|
6
6
|
class Encrypter
|
7
7
|
|
@@ -10,11 +10,11 @@ module Brightpearl
|
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
|
13
|
-
@key =
|
14
|
-
@hex =
|
13
|
+
@key = App::Config::param(App::Config::CRYPT_KEY)
|
14
|
+
@hex = App::Config::param(App::Config::CRYPT_HEX)
|
15
15
|
|
16
16
|
if @key.nil? || @hex.nil?
|
17
|
-
|
17
|
+
App::Terminal::error('Encryption keys not found', ["The command you're trying to run probably requires access to an EC2 database (or some other advanced feature).", "In order for this to work you will need valid #{App::Terminal::format_highlight('encryption keys')}.", "Please speak to #{App::Terminal::format_highlight('Albert')} (or team Raptor) for more info."], true)
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
@@ -29,7 +29,7 @@ module Brightpearl
|
|
29
29
|
e << c.final
|
30
30
|
return Base64.encode64(e)
|
31
31
|
rescue
|
32
|
-
|
32
|
+
App::Terminal::error('Encryption failed', "Could not encrypt string #{string == '' ? '[blank]' : App::Terminal::format_highlight(string)} using crypt_key #{App::Terminal::format_highlight(App::Config::param(App::Config::CRYPT_KEY) == '' ? '[blank]' : App::Config::param(App::Config::CRYPT_KEY))} and crypt_hex #{App::Terminal::format_highlight(App::Config::param(App::Config::CRYPT_HEX) == '' ? '[blank]' : App::Config::param(App::Config::CRYPT_HEX))}")
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
@@ -45,7 +45,7 @@ module Brightpearl
|
|
45
45
|
d << c.final
|
46
46
|
return d
|
47
47
|
rescue
|
48
|
-
|
48
|
+
App::Terminal::error('Decryption failed', "Could not decrypt string #{string == '' ? '[blank]' : App::Terminal::format_highlight(string)} using crypt_key #{App::Terminal::format_highlight(App::Config::param(App::Config::CRYPT_KEY) == '' ? '[blank]' : App::Config::param(App::Config::CRYPT_KEY))} and crypt_hex #{App::Terminal::format_highlight(App::Config::param(App::Config::CRYPT_HEX) == '' ? '[blank]' : App::Config::param(App::Config::CRYPT_HEX))}")
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
data/lib/core/enums.rb
CHANGED