brightpearl-cli 1.4.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/phpunit/IntegrationTestCase.php +512 -0
- data/assets/phpunit/JournalEntries.php +246 -0
- data/assets/phpunit/Message.php +101 -0
- data/assets/phpunit/Providers.php +404 -0
- data/assets/phpunit/RedirectException.php +20 -0
- data/assets/phpunit/ReservedContactIds.php +27 -0
- data/assets/phpunit/Values.php +30 -0
- data/assets/phpunit/bootstrap.php +85 -0
- data/assets/phpunit/jenkins-bootstrap.php +60 -0
- data/lib/brightpearl_cli.rb +26 -9
- data/lib/core/config.rb +1 -1
- data/lib/core/ebay.rb +11 -0
- data/lib/core/ebay_factory.rb +34 -0
- data/lib/core/enums.rb +8 -0
- data/lib/core/git.rb +44 -2
- data/lib/core/git_delete.rb +57 -15
- data/lib/core/mysql.rb +13 -13
- data/lib/core/pom.rb +44 -21
- data/lib/core/sql_update.rb +24 -0
- data/lib/core/terminal.rb +5 -4
- data/lib/core/utils_files.rb +0 -8
- data/lib/core/vm.rb +62 -0
- data/lib/routes/dummy_order.rb +0 -1
- data/lib/routes/fix.rb +30 -5
- data/lib/routes/git_checkout.rb +7 -2
- data/lib/routes/git_delete.rb +9 -3
- data/lib/routes/git_merge.rb +22 -6
- data/lib/routes/git_update.rb +1 -1
- data/lib/routes/production_logs.rb +4 -4
- data/lib/routes/review.rb +8 -2
- data/lib/routes/scripts_sonar.rb +6 -2
- data/lib/routes/scripts_sql_update.rb +33 -0
- data/lib/routes/test.rb +23 -8
- data/lib/version.rb +1 -0
- data/vm-scripts/sql-updates.sh +9 -0
- metadata +18 -2
data/lib/routes/git_checkout.rb
CHANGED
@@ -49,7 +49,7 @@ module AppCommand
|
|
49
49
|
source_branch_name = @args[1].nil? ? App::Git::MASTER : @args[1]
|
50
50
|
|
51
51
|
# If new branch is 12345, add 'bp-' prefix.
|
52
|
-
if new_branch_name =~ /\A\d{5}\z/i
|
52
|
+
if new_branch_name =~ /\A\d{4,5}\z/i
|
53
53
|
new_branch_name = "bp-#{new_branch_name}"
|
54
54
|
end
|
55
55
|
|
@@ -107,6 +107,11 @@ module AppCommand
|
|
107
107
|
def checkout_branch
|
108
108
|
|
109
109
|
branch_to_checkout = @args[0]
|
110
|
+
|
111
|
+
if branch_to_checkout =~ /\A\d{4,5}\z/i
|
112
|
+
branch_to_checkout = @git.resolve_branch_for_jira(branch_to_checkout)
|
113
|
+
end
|
114
|
+
|
110
115
|
branch_data = @git.branch_data(branch_to_checkout)
|
111
116
|
|
112
117
|
# If branch is already checked out.
|
@@ -142,7 +147,7 @@ module AppCommand
|
|
142
147
|
end
|
143
148
|
if @opts[:update] || @opts[:updatePush]
|
144
149
|
commands << 'git pull'
|
145
|
-
commands << "git merge #{App::Git::MASTER}"
|
150
|
+
commands << "git merge #{App::Git::MASTER} --no-edit"
|
146
151
|
end
|
147
152
|
if @opts[:updatePush]
|
148
153
|
commands << 'git push'
|
data/lib/routes/git_delete.rb
CHANGED
@@ -36,12 +36,18 @@ module AppCommand
|
|
36
36
|
|
37
37
|
def opts_routing
|
38
38
|
|
39
|
+
branch_to_delete = @args[0]
|
40
|
+
|
41
|
+
if branch_to_delete =~ /\A\d{4,5}\z/i
|
42
|
+
branch_to_delete = @git.resolve_branch_for_jira(branch_to_delete)
|
43
|
+
end
|
44
|
+
|
39
45
|
if @opts[:delete_local]
|
40
|
-
App::GitDelete::delete_local(
|
46
|
+
App::GitDelete::delete_local(branch_to_delete)
|
41
47
|
elsif @opts[:delete_remote]
|
42
|
-
App::GitDelete::delete_remote(
|
48
|
+
App::GitDelete::delete_remote(branch_to_delete)
|
43
49
|
elsif @opts[:delete_both]
|
44
|
-
App::GitDelete::delete_both(
|
50
|
+
App::GitDelete::delete_both(branch_to_delete)
|
45
51
|
end
|
46
52
|
|
47
53
|
end
|
data/lib/routes/git_merge.rb
CHANGED
@@ -228,6 +228,8 @@ module AppCommand
|
|
228
228
|
branches_data.each do |branch_data|
|
229
229
|
|
230
230
|
branch_name = branch_data[0][:"#{App::Git::BRANCH_NAME}"]
|
231
|
+
App::Terminal::info("Merging: #{App::Terminal::format_branch(branch_name)}")
|
232
|
+
|
231
233
|
commands_1 = [
|
232
234
|
"git checkout #{branch_name}",
|
233
235
|
'git pull'
|
@@ -271,6 +273,7 @@ module AppCommand
|
|
271
273
|
end
|
272
274
|
|
273
275
|
changed_files_code["#{branch_name}"] = App::Terminal::command_capture(commands_3, cd_repo)
|
276
|
+
|
274
277
|
App::Terminal::command(commands_4, cd_repo)
|
275
278
|
merge_to_target = App::Terminal::command(commands_5, cd_repo)
|
276
279
|
if merge_to_target[0] == false
|
@@ -292,7 +295,22 @@ module AppCommand
|
|
292
295
|
App::Terminal::abort(nil, nil, true, false)
|
293
296
|
end
|
294
297
|
end
|
298
|
+
|
295
299
|
changed_files_db["#{branch_name}"] = App::Terminal::command_capture(commands_3, db_repo)
|
300
|
+
|
301
|
+
unless changed_files_db["#{branch_name}"].nil? || changed_files_db["#{branch_name}"] == '' || changed_files_db["#{branch_name}"] == ['']
|
302
|
+
|
303
|
+
puts changed_files_db
|
304
|
+
puts
|
305
|
+
puts
|
306
|
+
puts changed_files_db["#{branch_name}"].inspect
|
307
|
+
|
308
|
+
unless App::Terminal::prompt_yes_no('BOMBED OUT ON SQL CHANGES!!', changed_files_db["#{branch_name}"])
|
309
|
+
App::Terminal::abort(nil, nil, true, false)
|
310
|
+
end
|
311
|
+
|
312
|
+
end
|
313
|
+
|
296
314
|
App::Terminal::command(commands_4, db_repo, false)
|
297
315
|
merge_to_target = App::Terminal::command(commands_5, db_repo)
|
298
316
|
if merge_to_target[0] == false
|
@@ -365,9 +383,6 @@ module AppCommand
|
|
365
383
|
@source_branches.concat(source_branches)
|
366
384
|
end
|
367
385
|
|
368
|
-
# Un-comment to sort alphanumerically.
|
369
|
-
# @source_branches.sort_by! { |m| m.downcase }
|
370
|
-
|
371
386
|
@source_branches.uniq!
|
372
387
|
|
373
388
|
# If branch(es) was/were specified as '1234' or '12345', this code tries to resolve it automatically as bp-12345/bug-12345/feature-12345
|
@@ -378,6 +393,7 @@ module AppCommand
|
|
378
393
|
end
|
379
394
|
end
|
380
395
|
if branches_to_resolve.any?
|
396
|
+
App::Terminal::info('Attempting to automatically resolve branches for:', branches_to_resolve.keys)
|
381
397
|
new_source_branches = []
|
382
398
|
@source_branches.each do |branch_name|
|
383
399
|
unless branches_to_resolve.keys.include?(branch_name)
|
@@ -390,17 +406,17 @@ module AppCommand
|
|
390
406
|
|
391
407
|
# If more than one possible branch exists, IE: bug-14145 & bp-14145
|
392
408
|
unless branches_to_resolve[branch_to_resolve] == false
|
393
|
-
App::Terminal::error("More than one possible branch found for
|
409
|
+
App::Terminal::error("More than one possible branch found for jira number: #{App::Terminal::format_highlight(branch_to_resolve)}", [App::Terminal::format_branch(possible_branch), App::Terminal::format_branch(branches_to_resolve[branch_to_resolve]), nil, "In this case, you must specify the branch name #{App::Terminal::format_highlight('explicitly')}."], true)
|
394
410
|
end
|
395
411
|
|
396
412
|
branches_to_resolve[branch_to_resolve] = possible_branch
|
397
|
-
App::Terminal::output("Resolved branch #{App::Terminal::format_branch(possible_branch)} from
|
413
|
+
App::Terminal::output("Resolved branch #{App::Terminal::format_branch(possible_branch)} from jira number: #{App::Terminal::format_highlight(branch_to_resolve)}", App::Terminal::MSG_AUTOMATIC)
|
398
414
|
end
|
399
415
|
end
|
400
416
|
end
|
401
417
|
branches_to_resolve.each do |branch_to_resolve|
|
402
418
|
if branch_to_resolve[1] == false
|
403
|
-
App::Terminal::error("No branch found for
|
419
|
+
App::Terminal::error("No branch found for jira number: #{App::Terminal::format_highlight(branch_to_resolve[0])}", ['Please check your input and try again.'], true)
|
404
420
|
end
|
405
421
|
new_source_branches << branch_to_resolve[1] unless branch_to_resolve[1] == '' || branch_to_resolve[1].nil?
|
406
422
|
end
|
data/lib/routes/git_update.rb
CHANGED
@@ -32,7 +32,7 @@ module AppCommand
|
|
32
32
|
if current_branch != App::Git::MASTER
|
33
33
|
commands << "git checkout #{current_branch}"
|
34
34
|
commands << "git pull origin #{current_branch}"
|
35
|
-
commands << 'git merge master'
|
35
|
+
commands << 'git merge master --no-edit'
|
36
36
|
end
|
37
37
|
results = App::Terminal::command(commands, repo_dir)
|
38
38
|
if current_branch != App::Git::MASTER
|
@@ -79,7 +79,7 @@ module AppCommand
|
|
79
79
|
data_previous = []
|
80
80
|
sql_1 = "SELECT COUNT(*) AS frequency, account_version, error_message, error_file, error_line FROM brightpearl.php_logs WHERE account_version='#{@args[0]}' GROUP BY error_message, error_file, error_line ORDER BY frequency DESC"
|
81
81
|
data_previous_result = @ec2_connection.query(sql_1)
|
82
|
-
data_previous_result.
|
82
|
+
data_previous_result.each do |result|
|
83
83
|
data_previous << result
|
84
84
|
end
|
85
85
|
sql_2 = "SELECT COUNT(*) AS frequency, account_version, error_message, error_file, error_line FROM brightpearl.php_logs WHERE account_version='#{@args[1]}' GROUP BY error_message, error_file, error_line HAVING frequency > 1 ORDER BY frequency DESC"
|
@@ -115,7 +115,7 @@ module AppCommand
|
|
115
115
|
column('')
|
116
116
|
column('')
|
117
117
|
end
|
118
|
-
data.
|
118
|
+
data.each do |row_data|
|
119
119
|
row_color = get_color_php_logs(data_previous, row_data)
|
120
120
|
error_file = row_data['error_file'].split('/')
|
121
121
|
error_file = "#{error_file[error_file.count - 2]}/#{error_file[error_file.count - 1]}"
|
@@ -156,7 +156,7 @@ module AppCommand
|
|
156
156
|
unless error_message.nil? || error_file.nil? || error_line.nil? || account_version.nil? || account_name.nil? || ruid.nil?
|
157
157
|
error_color = 248
|
158
158
|
result = @ec2_connection.query("SELECT id FROM php_logs WHERE ruid='#{ruid}' AND error_file='#{error_file.gsub("'",) { "\\'" }}' AND error_line='#{error_line.gsub("'", '')}'")
|
159
|
-
if result.
|
159
|
+
if result.count == 0
|
160
160
|
error_color = 198
|
161
161
|
sql = "INSERT INTO php_logs (
|
162
162
|
ruid,
|
@@ -322,7 +322,7 @@ module AppCommand
|
|
322
322
|
rescue
|
323
323
|
App::Terminal::warning('Query Failed', sql)
|
324
324
|
end
|
325
|
-
unless result.
|
325
|
+
unless result.count > 0
|
326
326
|
App::Terminal::info('No data', "We currently don't have any data for version: #{App::Terminal::format_highlight(version_number)}")
|
327
327
|
exit
|
328
328
|
end
|
data/lib/routes/review.rb
CHANGED
@@ -32,9 +32,15 @@ module AppCommand
|
|
32
32
|
|
33
33
|
current_branch = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
|
34
34
|
|
35
|
-
@
|
35
|
+
if @args[0] =~ /\A\d{4,5}\z/i
|
36
|
+
branch_to_review = @git.resolve_branch_for_jira(@args[0])
|
37
|
+
else
|
38
|
+
branch_to_review = @args[0]
|
39
|
+
end
|
40
|
+
|
41
|
+
@git.check_branch_exists_somewhere(branch_to_review)
|
36
42
|
|
37
|
-
system("BR=#{
|
43
|
+
system("BR=#{branch_to_review} && bp g co -u ${BR} && bp g d -l ${BR} && bp g co #{current_branch}")
|
38
44
|
|
39
45
|
end
|
40
46
|
|
data/lib/routes/scripts_sonar.rb
CHANGED
@@ -47,7 +47,12 @@ module AppCommand
|
|
47
47
|
end
|
48
48
|
|
49
49
|
unless file_found_to_scan
|
50
|
-
|
50
|
+
if changed_files[0] == '' && changed_files[1].nil?
|
51
|
+
App::Terminal::info("No files to scan. #{App::Terminal::format_highlight('No files changed')} between #{App::Terminal::format_branch(@git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))} and #{App::Terminal::format_branch("origin/#{App::Git::MASTER}")}")
|
52
|
+
else
|
53
|
+
App::Terminal::info("No files to scan. #{App::Terminal::format_highlight('The only files changed')} between #{App::Terminal::format_branch(@git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))} and #{App::Terminal::format_branch("origin/#{App::Git::MASTER}")} are:", changed_files[0].split("\n"))
|
54
|
+
end
|
55
|
+
exit
|
51
56
|
end
|
52
57
|
|
53
58
|
found_results = false
|
@@ -72,7 +77,6 @@ module AppCommand
|
|
72
77
|
App::Terminal::error('Found errors!', results_output)
|
73
78
|
else
|
74
79
|
App::Terminal::success('No errors found.', nil, file_found_to_scan ? true : false)
|
75
|
-
exit
|
76
80
|
end
|
77
81
|
|
78
82
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module AppCommand
|
2
|
+
|
3
|
+
class ScriptsSqlUpdate < ::Convoy::ActionCommand::Base
|
4
|
+
|
5
|
+
def execute
|
6
|
+
|
7
|
+
@opts = command_options
|
8
|
+
@args = arguments
|
9
|
+
|
10
|
+
opts_validate
|
11
|
+
opts_routing
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def opts_validate
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def opts_routing
|
20
|
+
|
21
|
+
run_sql_update
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def run_sql_update
|
26
|
+
|
27
|
+
App::SqlUpdate::run_sql_update
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/routes/test.rb
CHANGED
@@ -17,13 +17,13 @@ module AppCommand
|
|
17
17
|
opts_set = opts_set + 1 if @opts[:cucumber]
|
18
18
|
opts_set = opts_set + 1 if @opts[:fitnesse]
|
19
19
|
opts_set = opts_set + 1 if @opts[:php]
|
20
|
+
opts_set = opts_set + 1 if @opts[:php_local]
|
20
21
|
opts_set = opts_set + 1 if @opts[:ruby]
|
21
22
|
|
22
23
|
if opts_set >= 2
|
23
|
-
puts "You can only run one set of tests at a time. Please set only 1 one of the following flags: \x1B[90m-c, -f, -p, -r\x1B[0m"
|
24
|
+
puts "You can only run one set of tests at a time. Please set only 1 one of the following flags: \x1B[90m-c, -f, -p, -P, -r\x1B[0m"
|
24
25
|
exit
|
25
|
-
elsif
|
26
|
-
opts_set == 0
|
26
|
+
elsif opts_set == 0
|
27
27
|
@opts[:php] = true
|
28
28
|
end
|
29
29
|
|
@@ -35,7 +35,7 @@ module AppCommand
|
|
35
35
|
run_cucumber
|
36
36
|
elsif @opts[:fitnesse]
|
37
37
|
run_fitnesse
|
38
|
-
elsif @opts[:php]
|
38
|
+
elsif @opts[:php] || @opts[:php_local]
|
39
39
|
run_php
|
40
40
|
elsif @opts[:ruby]
|
41
41
|
run_ruby
|
@@ -53,10 +53,25 @@ module AppCommand
|
|
53
53
|
|
54
54
|
def run_php
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
if @opts[:php]
|
57
|
+
|
58
|
+
App::Terminal::info('Running PHPUnit tests on VM')
|
59
|
+
|
60
|
+
commands = [
|
61
|
+
"sshpass -p#{App::Config.param(App::Config::VM_USER_PASSWORD)} ssh #{App::Config.param(App::Config::VM_USER)}@#{App::Config.param(App::Config::VM_IP)} 'cd /brightpearl-source/brightpearl-code/brightpearl/private/tests/ && ./phpunit.sh #{@args.join(' ')}'"
|
62
|
+
]
|
63
|
+
App::Terminal::command(commands, nil, false)
|
64
|
+
|
65
|
+
elsif @opts[:php_local]
|
66
|
+
|
67
|
+
App::Terminal::warning('Running PHPUnit tests on Workstation', "This isn't fully functioning yet.")
|
68
|
+
|
69
|
+
commands = [
|
70
|
+
"phpunit --bootstrap #{App::Enum::get_base_path}/assets/phpunit/bootstrap.php"
|
71
|
+
]
|
72
|
+
App::Terminal::command(commands, "#{App::Config.param(ConfigUnique::WORKSTATION_PATH_TO_BP_CODE)}/brightpearl/private/tests", false)
|
73
|
+
|
74
|
+
end
|
60
75
|
|
61
76
|
end
|
62
77
|
|
data/lib/version.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
VERSION = '1.7.0'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
COUNTER=$1
|
4
|
+
|
5
|
+
while [ ${COUNTER} -lt $2 ]; do
|
6
|
+
echo "mysql app < /brightpearl-source/brightpearl-db/brightpearl/structure/0${COUNTER}.sql"
|
7
|
+
mysql app < /brightpearl-source/brightpearl-db/brightpearl/structure/0${COUNTER}.sql
|
8
|
+
let COUNTER=COUNTER+1
|
9
|
+
done
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brightpearl-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Albert Rannetsperger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: columnist
|
@@ -111,10 +111,21 @@ extra_rdoc_files: []
|
|
111
111
|
files:
|
112
112
|
- README.md
|
113
113
|
- LICENSE
|
114
|
+
- assets/phpunit/bootstrap.php
|
115
|
+
- assets/phpunit/IntegrationTestCase.php
|
116
|
+
- assets/phpunit/jenkins-bootstrap.php
|
117
|
+
- assets/phpunit/JournalEntries.php
|
118
|
+
- assets/phpunit/Message.php
|
119
|
+
- assets/phpunit/Providers.php
|
120
|
+
- assets/phpunit/RedirectException.php
|
121
|
+
- assets/phpunit/ReservedContactIds.php
|
122
|
+
- assets/phpunit/Values.php
|
114
123
|
- lib/brightpearl_cli.rb
|
115
124
|
- lib/core/api.rb
|
116
125
|
- lib/core/config.rb
|
117
126
|
- lib/core/config_unique.rb
|
127
|
+
- lib/core/ebay.rb
|
128
|
+
- lib/core/ebay_factory.rb
|
118
129
|
- lib/core/encrypter.rb
|
119
130
|
- lib/core/enums.rb
|
120
131
|
- lib/core/git.rb
|
@@ -122,12 +133,14 @@ files:
|
|
122
133
|
- lib/core/jira.rb
|
123
134
|
- lib/core/mysql.rb
|
124
135
|
- lib/core/pom.rb
|
136
|
+
- lib/core/sql_update.rb
|
125
137
|
- lib/core/terminal.rb
|
126
138
|
- lib/core/tools.rb
|
127
139
|
- lib/core/utils_files.rb
|
128
140
|
- lib/core/utils_routes.rb
|
129
141
|
- lib/core/utils_strings.rb
|
130
142
|
- lib/core/validate.rb
|
143
|
+
- lib/core/vm.rb
|
131
144
|
- lib/routes/build.rb
|
132
145
|
- lib/routes/dummy_order.rb
|
133
146
|
- lib/routes/fix.rb
|
@@ -148,10 +161,13 @@ files:
|
|
148
161
|
- lib/routes/scripts_color.rb
|
149
162
|
- lib/routes/scripts_pom_fixer.rb
|
150
163
|
- lib/routes/scripts_sonar.rb
|
164
|
+
- lib/routes/scripts_sql_update.rb
|
151
165
|
- lib/routes/setup.rb
|
152
166
|
- lib/routes/tail.rb
|
153
167
|
- lib/routes/test.rb
|
154
168
|
- lib/routes/update.rb
|
169
|
+
- lib/version.rb
|
170
|
+
- vm-scripts/sql-updates.sh
|
155
171
|
- bin/bp
|
156
172
|
- bin/brightpearl
|
157
173
|
homepage: http://rubygems.org/gems/brightpearl-cli
|