brightpearl-cli 1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4270946635291cd6218eecb1db111e4e7f5f80ea
4
+ data.tar.gz: 99c3dae282a3fa940dd23b908258932bb99fe458
5
+ SHA512:
6
+ metadata.gz: d171d52f0b475e1f02949a690de03a100d5b36ccc6ef840e273b3f3dfb619e4b832bf2c38bbb99691b626aa774aaf43d46f775e57325e5274d4bac9c61ab1e5b
7
+ data.tar.gz: 37fdb1baaff906e229daab38e965d324d21d94b9caca37f3b8fa65759e88db0e864550b83ed927a7d8c9c99af6c8e4345d257c589231c926ab0a6f2725e19046
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 - Albert Rannetsperger (Brightpearl)
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ brightpearl-cli
2
+ ===============
3
+
4
+ **A command-line utility created for Brightpearl developers and QAs.**
5
+
6
+ **brightpearl-cli** is a tool used for automating daily work-flows and repetitive tasks within Brightpearl's technical team.
7
+ Its aim is to make the team more efficient by minimizing errors whilst conforming to Brightpearl's high, internal development practices at all times.
8
+
9
+ The tool is written primarily in Ruby.
10
+
11
+ CLI stands for Command-line Interface.
12
+
13
+ ### Installation
14
+
15
+ The gem lives on the RubyGems server so installation is as easy as:
16
+
17
+ ```bash
18
+ gem install columnist
19
+ ```
20
+
21
+ ### Usage
data/bin/bp ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'brightpearl_cli'
4
+
5
+ Brightpearl::execute
data/bin/brightpearl ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'brightpearl_cli'
4
+
5
+ Brightpearl::execute
@@ -0,0 +1,351 @@
1
+ require 'convoy'
2
+ require 'yaml'
3
+
4
+ require 'core/api'
5
+ require 'core/config'
6
+ require 'core/enums'
7
+ require 'core/git'
8
+ require 'core/jira'
9
+ require 'core/mysql'
10
+ require 'core/terminal'
11
+ require 'core/tools'
12
+ require 'core/validate'
13
+ require 'routes/build'
14
+ require 'routes/dummy_order'
15
+ require 'routes/git_branch'
16
+ require 'routes/git_checkout'
17
+ require 'routes/git_delete'
18
+ require 'routes/git_merge'
19
+ require 'routes/git_pull'
20
+ require 'routes/git_push'
21
+ require 'routes/git_stash'
22
+ require 'routes/git_update'
23
+ require 'routes/jira'
24
+ require 'routes/less'
25
+ require 'routes/reset'
26
+ require 'routes/review'
27
+ require 'routes/scripts_color'
28
+ require 'routes/scripts_code_sniffer'
29
+ require 'routes/setup'
30
+ require 'routes/update'
31
+ require 'routes/tests'
32
+
33
+ module Brightpearl
34
+
35
+ def self.execute
36
+
37
+ begin
38
+
39
+ unless !ARGV.any? || ARGV[0] == 'setup' || ARGV[0] == 'x'
40
+ Brightpearl::Config.initialize
41
+ end
42
+
43
+ Convoy::App.create do |brightpearl|
44
+
45
+ # COLOR OF TITLE TEXT
46
+ title_color = 255
47
+
48
+ # TRUE/FALSE DEPENDING ON WHETHER USER IN ON BETA OR NOT.
49
+ beta_only = Brightpearl::Config.param(Brightpearl::Config::BETA) == 'true' ? true : false
50
+
51
+ brightpearl.version '1.1.0'
52
+ brightpearl.summary "\x1B[38;5;166mBRIGHTPEARL-CLI\x1B[0m \x1B[38;5;240m\xe2\x80\x94 BETA\x1B[0m"
53
+ brightpearl.description "\x1B[38;5;#{title_color}mA command line utility for Brightpearl developers and QAs.\nUsed for automating daily work flows & completing repetitive tasks quicker with less errors.\nDesigned to work from anywhere on your workstation.\n\nUse #{Brightpearl::Terminal::format_command('brightpearl')}\x1B[38;5;#{title_color}m or #{Brightpearl::Terminal::format_command('bp')}\x1B[38;5;#{title_color}m to run.\x1B[0m"
54
+
55
+ if beta_only
56
+
57
+ # BUILD
58
+ brightpearl.command :build, :aliases => [:b] do |build|
59
+ build.summary 'Build (and deploy) Java services'
60
+ build.action do |opts, args|
61
+ BrightpearlCommand::Build.new(opts, args).execute
62
+ end
63
+ end
64
+
65
+ # DUMMY
66
+ brightpearl.command :dummy, :aliases => [:d] do |dummy|
67
+
68
+ dummy.summary 'Insert dummy data into the App'
69
+
70
+ # DUMMY ORDER
71
+ dummy.command :order, :aliases => [:o] do |dummy_order|
72
+ dummy_order.summary 'Create dummy orders'
73
+ dummy_order.options do |opts|
74
+ opts.opt :salesOrder, 'Create sales order', :short => '-s', :long => '--sales-order', :type => :boolean
75
+ opts.opt :salesCredit, 'Create sales credit', :short => '-S', :long => '--sales-credit', :type => :boolean
76
+ opts.opt :purchaseOrder, 'Create purchase order', :short => '-p', :long => '--purchase-order', :type => :boolean
77
+ opts.opt :purchaseCredit, 'Create purchase credit', :short => '-P', :long => '--purchase-credit', :type => :boolean
78
+ opts.opt :times, 'Specify number of orders (maximum 50)', :short => '-x', :long => '--times', :type => :int
79
+ end
80
+ dummy_order.action do |opts, args|
81
+ BrightpearlCommand::DummyOrder.new(opts, args).execute
82
+ end
83
+ end
84
+
85
+ # CREATE (DEFAULT)
86
+ dummy.action do
87
+ system('bp d -h')
88
+ end
89
+
90
+ end
91
+
92
+ end
93
+
94
+ # GIT
95
+
96
+ brightpearl.command :git, :aliases => [:g] do |git|
97
+
98
+ git.summary 'All git related functionality'
99
+
100
+ # GIT BRANCH
101
+ git.command :branch, :aliases => [:b] do |git_branch|
102
+ git_branch.summary 'List local/remote branches'
103
+ git_branch.options do |opts|
104
+ opts.opt :local, 'List local branches', :short => '-l', :long => '--local', :type => :boolean
105
+ opts.opt :remote, 'List remote branches', :short => '-r', :long => '--remote', :type => :boolean
106
+ opts.opt :sortDate, 'Sort by date', :short => '-d', :long => '--sort-date', :type => :boolean
107
+ opts.opt :sortRefname, 'Sort by branch name (default)', :short => '-n', :long => '--sort-refname', :type => :boolean
108
+ opts.opt :detailed, 'Show a more detailed output w/Jira data, etc. (takes longer)', :short => '-D', :long => '--detailed', :type => :boolean
109
+ end
110
+ git_branch.action do |opts, args|
111
+ BrightpearlCommand::GitBranch.new(opts, args).execute
112
+ end
113
+ end
114
+
115
+ # GIT CHECKOUT
116
+ git.command :checkout, :aliases => [:c, :co] do |git_checkout|
117
+ git_checkout.summary 'Create & checkout branches'
118
+ git_checkout.options do |opts|
119
+ opts.opt :branch, 'Create a branch locally', :short => '-b', :long => '--branch', :type => :boolean
120
+ opts.opt :branch_origin, 'Create a branch and push to origin', :short => '-B', :long => '--branch-origin', :type => :boolean
121
+ opts.opt :update, "Update branch after checkout. Will run a 'git pull' & 'git merge master'", :short => '-u', :long => '--update', :type => :boolean
122
+ opts.opt :updatePush, 'Same as --update but will also push to origin', :short => '-U', :long => '--update-push', :type => :boolean
123
+ end
124
+ git_checkout.action do |opts, args|
125
+ BrightpearlCommand::GitCheckout.new(opts, args).execute
126
+ end
127
+ end
128
+
129
+ # GIT DELETE
130
+ git.command :delete, :aliases => [:d] do |git_delete|
131
+ git_delete.summary 'Delete branch(es)'
132
+ git_delete.options do |opts|
133
+ opts.opt :delete_local, 'Delete local branch', :short => '-l', :long => '--delete-local', :type => :boolean
134
+ opts.opt :delete_remote, 'Delete remote branch', :short => '-r', :long => '--delete-remote', :type => :boolean
135
+ opts.opt :delete_both, 'Delete both local & remote branches', :short => '-b', :long => '--delete-both', :type => :boolean
136
+ end
137
+ git_delete.action do |opts, args|
138
+ BrightpearlCommand::GitDelete.new(opts, args).execute
139
+ end
140
+ end
141
+
142
+ # GIT MERGE
143
+ git.command :merge, :aliases => [:m] do |git_merge|
144
+ git_merge.summary 'Merge branch(es)'
145
+ d = "Accepts one #{Brightpearl::Terminal::format_action('mandatory')} primary argument \xe2\x80\x94 the name of the source branch."
146
+ d << "\nAccepts one #{Brightpearl::Terminal::format_action('optional')} secondary argument \xe2\x80\x94 the name of the target branch."
147
+ d << "\n"
148
+ d << "\nIf no secondary argument is given, target branch will be #{Brightpearl::Terminal::format_branch('current-branch')}"
149
+ d << "\n"
150
+ d << "\n #{Brightpearl::Terminal::format_command('bp g m')} #{Brightpearl::Terminal::format_command('source_branch')} \x1B[0m"
151
+ d << "\n #{Brightpearl::Terminal::format_command('bp g m')} #{Brightpearl::Terminal::format_command('source_branch target_branch')} \x1B[0m"
152
+ d << "\n"
153
+ d << "\nTo merge multiple branches at once, use comma-separated string (w/out spaces) :"
154
+ d << "\n"
155
+ d << "\n #{Brightpearl::Terminal::format_command('bp g m')} #{Brightpearl::Terminal::format_command('sb1,sb2,sb3')}"
156
+ d << "\n #{Brightpearl::Terminal::format_command('bp g m')} #{Brightpearl::Terminal::format_command('sb1,sb2,sb3 target_branch')}"
157
+ d << "\n"
158
+ d << "\nAlternatively, use the #{Brightpearl::Terminal::format_flag('f')} and specify a filename like so:"
159
+ d << "\n"
160
+ d << "\n\x1B[38;5;240m 1) Create a .txt file (IE: '/tmp/merge.txt') with names of branches you'd like to merge on separate lines."
161
+ d << "\n\x1B[38;5;240m 2) Pass the file as a parameter to the script."
162
+ d << "\n"
163
+ d << "\n #{Brightpearl::Terminal::format_command('bp g m')} #{Brightpearl::Terminal::format_command('-f /tmp/merge.txt')} \x1B[0m"
164
+ d << "\n #{Brightpearl::Terminal::format_command('bp g m')} #{Brightpearl::Terminal::format_command('-f /tmp/merge.txt target_branch')} \x1B[0m"
165
+ git_merge.description d
166
+ git_merge.options do |opts|
167
+ opts.opt :from_file, 'Get branch names from file (1 branch per line)', :short => '-f', :long => '--from-file', :type => :string
168
+ end
169
+ git_merge.action do |opts, args|
170
+ BrightpearlCommand::GitMerge.new(opts, args).execute
171
+ end
172
+ end
173
+
174
+ if beta_only
175
+
176
+ # GIT PULL
177
+ git.command :pull, :aliases => [:p] do |git_pull|
178
+ git_pull.summary 'Pull from origin'
179
+ git_pull.action do |opts, args|
180
+ BrightpearlCommand::GitPull.new(opts, args).execute
181
+ end
182
+ end
183
+
184
+ # GIT PUSH
185
+ git.command :push, :aliases => [:P] do |git_push|
186
+ git_push.summary 'Push to origin'
187
+ git_push.action do |opts, args|
188
+ BrightpearlCommand::GitPush.new(opts, args).execute
189
+ end
190
+ end
191
+
192
+ # GIT STASH
193
+ git.command :stash, :aliases => [:S] do |git_stash|
194
+ git_stash.summary 'Stash/un-stash your changes'
195
+ git_stash.action do |opts, args|
196
+ BrightpearlCommand::GitStash.new(opts, args).execute
197
+ end
198
+ end
199
+
200
+ end
201
+
202
+ # GIT UPDATE
203
+ git.command :update, :aliases => [:u] do |git_update|
204
+ git_update.summary 'Update branch(es)'
205
+ git_update.options do |opts|
206
+ opts.opt :all, 'Update all local branches', :short => '-a', :long => '--all', :type => :boolean
207
+ opts.opt :push, 'Push updates to origin', :short => '-P', :long => '--push', :type => :boolean
208
+ end
209
+ git_update.action do |opts, args|
210
+ BrightpearlCommand::GitUpdate.new(opts, args).execute
211
+ end
212
+ end
213
+
214
+ # GIT (DEFAULT)
215
+ git.action do
216
+ system('bp g -h')
217
+ end
218
+
219
+ end
220
+
221
+ if beta_only
222
+
223
+ # JIRA
224
+ brightpearl.command :jira, :aliases => [:j] do |jira|
225
+ jira.summary 'Access the Jira API'
226
+
227
+ # JIRA CARD
228
+ jira.command :card, :aliases => [:c] do |jira_card|
229
+ jira_card.summary 'Get detailed information about a card'
230
+ jira_card.action do |opts, args|
231
+ BrightpearlCommand::JiraCard.new(opts, args).execute
232
+ end
233
+ end
234
+
235
+ # JIRA (DEFAULT)
236
+ jira.action do
237
+ system('bp j -h')
238
+ end
239
+ end
240
+
241
+ end
242
+
243
+ # LESS
244
+ brightpearl.command :less, :aliases => [:l] do |less|
245
+ less.summary "Compile #{Brightpearl::Terminal::format_directory('screen.less')} file"
246
+ less.options do |opts|
247
+ opts.opt :skipConfirm, 'Skips confirmation. Will compile less file immediately', :short => '-K', :long => '--skip-confirmation', :type => :boolean
248
+ end
249
+ less.action do |opts, args|
250
+ BrightpearlCommand::Less.new(opts, args).execute
251
+ end
252
+ end
253
+
254
+ if beta_only
255
+
256
+ # RESET
257
+ brightpearl.command :reset, :aliases => [:R] do |reset|
258
+ reset.summary 'Reset various things within the App'
259
+ reset.options do |opts|
260
+ opts.opt :fitnesseDump, 'Reset the Fitnesse Dump on your VM', :short => '-f', :long => '--fitnesse-dump', :type => :boolean
261
+ end
262
+ reset.action do |opts, args|
263
+ BrightpearlCommand::Reset.new(opts, args).execute
264
+ end
265
+ end
266
+
267
+ end
268
+
269
+ # REVIEW
270
+ brightpearl.command :review, :aliases => [:r] do |review|
271
+ review.summary 'Perform a quick code review'
272
+ review.action do |opts, args|
273
+ BrightpearlCommand::Review.new(opts, args).execute
274
+ end
275
+ end
276
+
277
+ # SCRIPTS
278
+ brightpearl.command :scripts, :aliases => [:s] do |scripts|
279
+
280
+ scripts.summary 'Quick & dirty scripts'
281
+
282
+ # SCRIPTS COLOR
283
+ scripts.command :color, :aliases => [:c] do |scripts_color|
284
+ scripts_color.summary 'Shows a list of bash/ruby color codes (256-bit)'
285
+ scripts_color.action do |opts, args|
286
+ BrightpearlCommand::ScriptsColor.new(opts, args).execute
287
+ end
288
+ end
289
+
290
+ # SCRIPTS PHP CODE-SNIFFER
291
+ scripts.command :sniff, :aliases => [:s] do |code_sniffer|
292
+ code_sniffer.summary 'Run PHP CodeSniffer'
293
+ code_sniffer.action do |opts, args|
294
+ BrightpearlCommand::ScriptsCodeSniffer.new(opts, args).execute
295
+ end
296
+ end
297
+
298
+ # SCRIPTS (DEFAULT)
299
+ scripts.action do
300
+ system('bp s -h')
301
+ end
302
+
303
+ end
304
+
305
+ # TEST
306
+ brightpearl.command :tests, :aliases => [:t] do |test|
307
+ test.summary 'Run various tests (PHPUnit by default)'
308
+ test.options do |opts|
309
+ opts.opt :cucumber, 'Run Cucumber tests', :short => '-c', :long => '--cucumber', :type => :boolean
310
+ opts.opt :fitnesse, 'Run FitNesse tests', :short => '-f', :long => '--fitnesse', :type => :boolean
311
+ opts.opt :php, 'Run PHPUnit tests (default)', :short => '-p', :long => '--php-unit', :type => :boolean
312
+ opts.opt :ruby, 'Run Ruby UI tests', :short => '-r', :long => '--ruby-ui', :type => :boolean
313
+ end
314
+ test.action do |opts, args|
315
+ BrightpearlCommand::Test.new(opts, args).execute
316
+ end
317
+ end
318
+
319
+ # UPDATE
320
+ brightpearl.command :update, :aliases => [:u] do |update|
321
+ update.summary 'Check for updates'
322
+ update.action do |opts, args|
323
+ BrightpearlCommand::Update.new(opts, args).execute
324
+ end
325
+ end
326
+
327
+ # X - SETUP
328
+ brightpearl.command :setup, :aliases => [:x] do |setup|
329
+ setup.summary 'Setup your configuration file'
330
+ setup.action do |opts, args|
331
+ BrightpearlCommand::Setup.new(opts, args).execute
332
+ end
333
+ end
334
+
335
+ # BRIGHTPEARL/BP (DEFAULT)
336
+ brightpearl.action do
337
+ system('bp -h')
338
+ end
339
+
340
+ end
341
+
342
+ rescue RuntimeError => e
343
+
344
+ puts e.message
345
+ puts e.backtrace
346
+
347
+ end
348
+
349
+ end
350
+
351
+ end
data/lib/core/api.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Brightpearl
2
+
3
+ class API
4
+
5
+ end
6
+
7
+ end
@@ -0,0 +1,175 @@
1
+ require 'fileutils'
2
+ require 'parseconfig'
3
+
4
+ module Brightpearl
5
+
6
+ class Config
7
+
8
+ CONFIG_FILE = '~/.brightpearlrc'
9
+
10
+ BETA = 'beta'
11
+ MAC = 'mac'
12
+ LINUX = 'linux'
13
+
14
+ WORKSTATION_IP = 'workstation_ip'
15
+ WORKSTATION_OS = 'workstation_os'
16
+ WORKSTATION_PATH_TO_BP_CODE = 'workstation_path_to_bp_code'
17
+ WORKSTATION_PATH_TO_BP_DB = 'workstation_path_to_bp_db'
18
+ VM_IP = 'vm_ip'
19
+ VM_USER = 'vm_user'
20
+ VM_USER_PASSWORD = 'vm_user_password'
21
+ VM_ROOT = 'vm_root'
22
+ VM_ROOT_PASSWORD = 'vm_root_password'
23
+ VM_MYSQL_USER = 'vm_mysql_user'
24
+ VM_MYSQL_PASSWORD = 'vm_mysql_password'
25
+
26
+ @params = {}
27
+
28
+ def self.param(param_name)
29
+ unless required_config_keys.include?(param_name) || param_name == BETA
30
+ raise RuntimeError, "'#{param_name}' is not a valid config parameter."
31
+ end
32
+ @params[param_name]
33
+ end
34
+
35
+ def self.initialize
36
+ if config_file_exists?
37
+ run_load_config
38
+ else
39
+ run_first_journey
40
+ end
41
+ end
42
+
43
+ def self.config_file_exists?
44
+ unless File.exists? ("#{File.expand_path(CONFIG_FILE)}")
45
+ return false
46
+ end
47
+ true
48
+ end
49
+
50
+ def self.run_load_config
51
+ config_params_get
52
+ config_params_validate
53
+ end
54
+
55
+ def self.run_first_journey
56
+ first_journey_message
57
+ config_file_create
58
+ config_file_edit
59
+ config_params_get
60
+ config_params_validate(true)
61
+ end
62
+
63
+ def self.first_journey_message
64
+ puts
65
+ puts "Thank you for installing the \x1B[36mbrightpearl-cli\x1B[0m ruby gem."
66
+ puts "CLI stands for 'Command Line Interface'."
67
+ puts
68
+ puts 'The first thing you will need to do is setup your configuration file.'
69
+ puts "This file will always be located at: \x1B[33m~/.brightpearlrc\x1B[0m"
70
+ puts
71
+ puts "You probably won't have this file but this program will create it for you."
72
+ puts 'The next screen will open a nano text editor where you can set it up.'
73
+ Brightpearl::Terminal::enter_to_continue
74
+ end
75
+
76
+ def self.config_file_create
77
+ File.open("#{File.expand_path(CONFIG_FILE)}", 'w') { |file|
78
+ file.write("# CONFIGURATION FILE -- Make sure that ALL parameters are correct before saving.\n")
79
+ file.write("\n")
80
+ file.write("#{WORKSTATION_IP}=172.27.X.X\n")
81
+ file.write("#{WORKSTATION_OS}=linux\n")
82
+ file.write("#{WORKSTATION_PATH_TO_BP_CODE}=/brightpearl-source/brightpearl-code\n")
83
+ file.write("#{WORKSTATION_PATH_TO_BP_DB}=/brightpearl-source/brightpearl-db\n")
84
+ file.write("\n")
85
+ file.write("#{VM_IP}=172.27.X.X\n")
86
+ file.write("#{VM_USER}=\n")
87
+ file.write("#{VM_USER_PASSWORD}=\n")
88
+ file.write("#{VM_ROOT}=root\n")
89
+ file.write("#{VM_ROOT_PASSWORD}=peXXXXXXXre\n")
90
+ file.write("#{VM_MYSQL_USER}=root\n")
91
+ file.write("#{VM_MYSQL_PASSWORD}=peXXXXXXXre\n")
92
+ }
93
+ end
94
+
95
+ def self.config_file_edit
96
+ system("nano #{File.expand_path(CONFIG_FILE)}")
97
+ end
98
+
99
+ def self.config_params_get
100
+ config = ParseConfig.new("#{File.expand_path(CONFIG_FILE)}")
101
+ config.get_params.each do |param|
102
+ @params[param] = config[param]
103
+ end
104
+ end
105
+
106
+ def self.config_params_validate(show_success_message = false)
107
+ error_text = ''
108
+ missing_keys = get_missing_config_keys
109
+ if missing_keys.any?
110
+ missing_keys.each do |key|
111
+ error_text = "#{error_text}\x1B[38;5;196mKey/value must exist and cannot be null:\x1B[0m \x1B[38;5;240m#{key}\x1B[0m\n"
112
+ end
113
+ error_text = error_text[0..-2]
114
+ end
115
+ workstation_os = Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_OS)
116
+ unless workstation_os.downcase == MAC || workstation_os.downcase == LINUX
117
+ unless error_text == ''
118
+ error_text = "#{error_text}\n\n"
119
+ end
120
+ 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"
121
+ end
122
+ unless error_text == ''
123
+ show_error_message(error_text)
124
+ end
125
+ code_repo = Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)
126
+ unless File.directory?(code_repo)
127
+ error_text = "#{error_text}The following is NOT a valid directory: \x1B[0m#{code_repo}\x1B[90m\n"
128
+ end
129
+ unless File.directory?(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))
130
+ error_text = "#{error_text}The following is NOT a valid directory: \x1B[0m#{Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)}\x1B[90m\n"
131
+ end
132
+ unless error_text == ''
133
+ show_error_message(error_text)
134
+ end
135
+ if show_success_message
136
+ Brightpearl::Terminal::success('Configuration parameters are correct.', "You are now ready to start using this utility.\nStart by typing #{Brightpearl::Terminal::format_command('brightpearl --help')} (or #{Brightpearl::Terminal::format_command('bp -h')}).")
137
+ exit
138
+ end
139
+ end
140
+
141
+ def self.show_error_message(error_text)
142
+ Brightpearl::Terminal::error('Your configuration parameters are invalid.', "#{error_text}\nYou can fix this by running #{Brightpearl::Terminal::format_command('brightpearl setup')} (or #{Brightpearl::Terminal::format_command('bp x')}).")
143
+ exit
144
+ end
145
+
146
+ def self.get_missing_config_keys
147
+ missing_keys = required_config_keys.dup
148
+ @params.each do |key, value|
149
+ unless value == ''
150
+ missing_keys.delete(key)
151
+ end
152
+ end
153
+ missing_keys
154
+ end
155
+
156
+ def self.required_config_keys
157
+ [
158
+ WORKSTATION_IP,
159
+ WORKSTATION_OS,
160
+ WORKSTATION_PATH_TO_BP_CODE,
161
+ WORKSTATION_PATH_TO_BP_DB,
162
+ VM_IP,
163
+ VM_USER,
164
+ VM_USER_PASSWORD,
165
+ VM_ROOT,
166
+ VM_ROOT_PASSWORD,
167
+ VM_MYSQL_USER,
168
+ VM_MYSQL_PASSWORD
169
+ ]
170
+ end
171
+
172
+ end
173
+
174
+
175
+ end
data/lib/core/enums.rb ADDED
@@ -0,0 +1,9 @@
1
+ module Brightpearl
2
+
3
+ class Enum
4
+
5
+ PORT_ORDER_SERVICE = '9240'
6
+
7
+ end
8
+
9
+ end