brightpearl-cli 1.3.0 → 1.4.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 +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
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module AppCommand
|
2
2
|
|
3
3
|
class ScriptsPomFixer < ::Convoy::ActionCommand::Base
|
4
4
|
|
@@ -6,7 +6,7 @@ module BrightpearlCommand
|
|
6
6
|
|
7
7
|
@opts = command_options
|
8
8
|
@args = arguments
|
9
|
-
@git =
|
9
|
+
@git = App::Git.new
|
10
10
|
opts_validate
|
11
11
|
opts_routing
|
12
12
|
|
@@ -24,69 +24,12 @@ module BrightpearlCommand
|
|
24
24
|
|
25
25
|
def fix_poms
|
26
26
|
|
27
|
-
|
28
|
-
files = Brightpearl::Terminal::command_capture(command)
|
29
|
-
files = files[0].split("\n")
|
30
|
-
|
31
|
-
unless files.any?
|
32
|
-
Brightpearl::Terminal::error('No files found', ["The command: #{Brightpearl::Terminal::format_command(command)} didn't return any files.", 'It might be possible that the directory structure of our codebase has changed and this script needs to be updated.', nil, "Speak to #{Brightpearl::Terminal::format_highlight('Albert')}."], true)
|
33
|
-
end
|
34
|
-
|
35
|
-
files_to_change = []
|
36
|
-
files.each do |filename|
|
37
|
-
file_lines = File.open(filename, 'rb').read
|
38
|
-
file_lines.split("\n").each do |line|
|
39
|
-
if line.match(/<version>\d+\.\d+\.\d+-(.*)-(snapshot)<\/version>/i)
|
40
|
-
files_to_change << filename
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
unless files_to_change.any?
|
46
|
-
Brightpearl::Terminal::info('No feature-tagged POMs found', 'Nothing to un-snapshot.')
|
47
|
-
exit
|
48
|
-
end
|
49
|
-
|
50
|
-
unless Brightpearl::Terminal::prompt_yes_no('Un-snapshot POMs', generate_confirmation_text(files_to_change))
|
51
|
-
Brightpearl::Terminal::abort(nil, nil, true, false)
|
52
|
-
end
|
53
|
-
|
54
|
-
files_to_change.each do |filename|
|
55
|
-
Brightpearl::Terminal::output("Un-snapshotting: #{Brightpearl::Terminal::format_directory(filename)}")
|
56
|
-
contents = File.read(filename)
|
57
|
-
contents_new = contents.gsub(/-(.*)-SNAPSHOT/, '-SNAPSHOT')
|
58
|
-
File.open(filename, 'w') { |file| file.puts contents_new }
|
59
|
-
end
|
60
|
-
|
61
|
-
Brightpearl::Terminal::command('git status', Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
|
62
|
-
|
63
|
-
commit_message = "BP-0000 Un-snapshotted POMs on #{@git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))}."
|
64
|
-
|
65
|
-
if Brightpearl::Terminal::prompt_yes_no('Commit to GIT', ["This will commit your changes to GIT with message: #{Brightpearl::Terminal::format_highlight(commit_message)}"])
|
66
|
-
Brightpearl::Terminal::command(['git add .', "git commit -m '#{commit_message.gsub("'", "\\'")}'"], Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
|
67
|
-
else
|
68
|
-
Brightpearl::Terminal::info('Un-snapshotting complete', "Please note that your changes #{Brightpearl::Terminal::format_highlight('HAVE NOT')} been #{Brightpearl::Terminal::format_action('committed')} to Git.", false)
|
69
|
-
exit
|
70
|
-
end
|
71
|
-
|
72
|
-
if Brightpearl::Terminal::prompt_yes_no('Push changes to origin')
|
73
|
-
Brightpearl::Terminal::command('git push', Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
|
74
|
-
Brightpearl::Terminal::info('Un-snapshotting complete', "Your POMs have been un-snapshotted, the changes #{Brightpearl::Terminal::format_action('committed')} to Git and #{Brightpearl::Terminal::format_action('pushed')} to origin.")
|
75
|
-
else
|
76
|
-
Brightpearl::Terminal::info('Un-snapshotting complete', ["Your POMs have been un-snapshotted and the changes #{Brightpearl::Terminal::format_action('committed')} to Git.", 'However, nothing has been pushed to origin. You will need to do this manually.'], false)
|
77
|
-
end
|
27
|
+
current_branch_code_repo = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
|
78
28
|
|
79
|
-
|
29
|
+
files_to_change = App::Pom::get_files_to_change
|
80
30
|
|
81
|
-
|
31
|
+
App::Pom::unsnapshot_files(files_to_change, (@opts[:forMaster] ? App::Git::MASTER : current_branch_code_repo))
|
82
32
|
|
83
|
-
def generate_confirmation_text(files_to_change)
|
84
|
-
confirmation_text = ['The following files will have their branch tags removed:', nil]
|
85
|
-
files_to_change.each do |file_name|
|
86
|
-
confirmation_text << Brightpearl::Terminal::format_directory(file_name)
|
87
|
-
end
|
88
|
-
confirmation_text
|
89
|
-
confirmation_text
|
90
33
|
end
|
91
34
|
|
92
35
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module AppCommand
|
2
|
+
|
3
|
+
class ScriptsSonar < ::Convoy::ActionCommand::Base
|
4
|
+
|
5
|
+
def execute
|
6
|
+
|
7
|
+
@opts = command_options
|
8
|
+
@args = arguments
|
9
|
+
|
10
|
+
@git = App::Git.new
|
11
|
+
|
12
|
+
opts_validate
|
13
|
+
opts_routing
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def opts_validate
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def opts_routing
|
22
|
+
|
23
|
+
run_sonar
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def run_sonar
|
28
|
+
|
29
|
+
App::Terminal::info('Running PHP Sonar (CodeSniffer)')
|
30
|
+
space_inserted = false
|
31
|
+
file_found_to_scan = false
|
32
|
+
|
33
|
+
results = []
|
34
|
+
changed_files = @git.get_changed_files(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
|
35
|
+
|
36
|
+
changed_files[0].split("\n").each do |changed_file|
|
37
|
+
if changed_file =~ /\Abrightpearl\/private\/library\/Lib\/(.*)/i
|
38
|
+
file_found_to_scan = true
|
39
|
+
unless space_inserted
|
40
|
+
puts
|
41
|
+
space_inserted = true
|
42
|
+
end
|
43
|
+
App::Terminal::output("Scanning: #{App::Terminal::format_directory(changed_file)}")
|
44
|
+
command = "phpcs --report=full --standard=#{App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)}/brightpearl/private/tests/phpcs/phpcs.xml #{App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)}/#{changed_file}"
|
45
|
+
results << App::Terminal::command_capture(command, App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE), false, false)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
unless file_found_to_scan
|
50
|
+
App::Terminal::info("No files to scan. The only files which #{App::Terminal::format_highlight('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"))
|
51
|
+
end
|
52
|
+
|
53
|
+
found_results = false
|
54
|
+
results_output = []
|
55
|
+
|
56
|
+
results.each do |result|
|
57
|
+
if result.any?
|
58
|
+
unless result[0] == ''
|
59
|
+
result[0].split("\n").each do |line|
|
60
|
+
if line =~ /\AFILE:\s(.*).\w{3,5}/i
|
61
|
+
found_results = true
|
62
|
+
results_output << "\x1B[38;5;196m#{line}\x1B[0m"
|
63
|
+
else
|
64
|
+
results_output << "\x1B[38;5;250m#{line}\x1B[0m"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
if found_results
|
72
|
+
App::Terminal::error('Found errors!', results_output)
|
73
|
+
else
|
74
|
+
App::Terminal::success('No errors found.', nil, file_found_to_scan ? true : false)
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
data/lib/routes/setup.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
module
|
1
|
+
module AppCommand
|
2
2
|
|
3
3
|
class Setup < ::Convoy::ActionCommand::Base
|
4
4
|
|
5
5
|
def execute
|
6
6
|
|
7
|
-
if File.exists?(File.expand_path(
|
7
|
+
if File.exists?(File.expand_path(App::Config::CONFIG_FILE))
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
App::Config::config_file_edit
|
10
|
+
App::Config::config_params_get
|
11
|
+
App::Config::config_params_validate(true)
|
12
12
|
|
13
13
|
else
|
14
14
|
|
15
|
-
|
15
|
+
App::Config.initialize
|
16
16
|
|
17
17
|
end
|
18
18
|
|
data/lib/routes/tail.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module AppCommand
|
2
2
|
|
3
3
|
class Tail < ::Convoy::ActionCommand::Base
|
4
4
|
|
@@ -23,19 +23,19 @@ module BrightpearlCommand
|
|
23
23
|
|
24
24
|
def tail_all_catalina_out
|
25
25
|
|
26
|
-
if
|
26
|
+
if App::Tools::this_is_a_mac
|
27
27
|
|
28
28
|
begin
|
29
29
|
system('clear')
|
30
|
-
|
31
|
-
system("sshpass -p#{
|
30
|
+
App::Terminal::info("Tailing #{App::Terminal::format_action('all')} Java logs", ['tail -f /var/log/tomcat/*/catalina.out | grep -v "scheduling\|/var/log\|rabbitmq\|Clearing app version/service version cache\|^$"', nil, "Press '#{App::Terminal::format_command('CTRL + C')}\x1B[38;5;240m' to quit."])
|
31
|
+
system("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)} 'tail -f /var/log/tomcat/*/catalina.out | grep -v \"scheduling\\|/var/log\\|rabbitmq\\|Clearing app version/service version cache\\|^$\"'")
|
32
32
|
ensure
|
33
33
|
exit
|
34
34
|
end
|
35
35
|
|
36
36
|
else
|
37
37
|
|
38
|
-
|
38
|
+
App::Terminal::info('This functionality has not yet been implemented on your OS', ["Currently only works on #{App::Terminal::format_action(App::Config.param(App::Config::WORKSTATION_OS))}", nil, "You are on #{App::Terminal::format_action(App::Config.param(App::Config::WORKSTATION_OS))}"])
|
39
39
|
|
40
40
|
end
|
41
41
|
|
data/lib/routes/test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module AppCommand
|
2
2
|
|
3
3
|
class Test < ::Convoy::ActionCommand::Base
|
4
4
|
|
@@ -54,9 +54,9 @@ module BrightpearlCommand
|
|
54
54
|
def run_php
|
55
55
|
|
56
56
|
commands = [
|
57
|
-
"sshpass -p#{
|
57
|
+
"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(' ')}'"
|
58
58
|
]
|
59
|
-
|
59
|
+
App::Terminal::command(commands, nil, false)
|
60
60
|
|
61
61
|
end
|
62
62
|
|
data/lib/routes/update.rb
CHANGED
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.4.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-
|
11
|
+
date: 2015-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: columnist
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 2.9.1
|
62
|
-
- -
|
62
|
+
- - '>='
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: 2.9.1
|
65
65
|
type: :runtime
|
@@ -69,7 +69,7 @@ dependencies:
|
|
69
69
|
- - '='
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: 2.9.1
|
72
|
-
- -
|
72
|
+
- - '>='
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 2.9.1
|
75
75
|
- !ruby/object:Gem::Dependency
|
@@ -114,16 +114,23 @@ files:
|
|
114
114
|
- lib/brightpearl_cli.rb
|
115
115
|
- lib/core/api.rb
|
116
116
|
- lib/core/config.rb
|
117
|
+
- lib/core/config_unique.rb
|
117
118
|
- lib/core/encrypter.rb
|
118
119
|
- lib/core/enums.rb
|
119
120
|
- lib/core/git.rb
|
121
|
+
- lib/core/git_delete.rb
|
120
122
|
- lib/core/jira.rb
|
121
123
|
- lib/core/mysql.rb
|
124
|
+
- lib/core/pom.rb
|
122
125
|
- lib/core/terminal.rb
|
123
126
|
- lib/core/tools.rb
|
127
|
+
- lib/core/utils_files.rb
|
128
|
+
- lib/core/utils_routes.rb
|
129
|
+
- lib/core/utils_strings.rb
|
124
130
|
- lib/core/validate.rb
|
125
131
|
- lib/routes/build.rb
|
126
132
|
- lib/routes/dummy_order.rb
|
133
|
+
- lib/routes/fix.rb
|
127
134
|
- lib/routes/git_branch.rb
|
128
135
|
- lib/routes/git_checkout.rb
|
129
136
|
- lib/routes/git_delete.rb
|
@@ -138,9 +145,9 @@ files:
|
|
138
145
|
- lib/routes/review.rb
|
139
146
|
- lib/routes/scripts_api_docs.rb
|
140
147
|
- lib/routes/scripts_branch_cleaner.rb
|
141
|
-
- lib/routes/scripts_code_sniffer.rb
|
142
148
|
- lib/routes/scripts_color.rb
|
143
149
|
- lib/routes/scripts_pom_fixer.rb
|
150
|
+
- lib/routes/scripts_sonar.rb
|
144
151
|
- lib/routes/setup.rb
|
145
152
|
- lib/routes/tail.rb
|
146
153
|
- lib/routes/test.rb
|
@@ -157,17 +164,17 @@ require_paths:
|
|
157
164
|
- lib
|
158
165
|
required_ruby_version: !ruby/object:Gem::Requirement
|
159
166
|
requirements:
|
160
|
-
- -
|
167
|
+
- - ~>
|
161
168
|
- !ruby/object:Gem::Version
|
162
|
-
version: '
|
169
|
+
version: '2.0'
|
163
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
171
|
requirements:
|
165
|
-
- -
|
172
|
+
- - '>='
|
166
173
|
- !ruby/object:Gem::Version
|
167
174
|
version: '0'
|
168
175
|
requirements: []
|
169
176
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.0.14
|
171
178
|
signing_key:
|
172
179
|
specification_version: 4
|
173
180
|
summary: Brightpearl (Command Line Interface)
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module BrightpearlCommand
|
2
|
-
|
3
|
-
class ScriptsCodeSniffer < ::Convoy::ActionCommand::Base
|
4
|
-
|
5
|
-
def execute
|
6
|
-
|
7
|
-
@opts = command_options
|
8
|
-
@args = arguments
|
9
|
-
opts_validate
|
10
|
-
opts_routing
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
def opts_validate
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def opts_routing
|
19
|
-
|
20
|
-
run_code_sniffer
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
def run_code_sniffer
|
25
|
-
|
26
|
-
@todo
|
27
|
-
command = "phpcs --report=full --standard=#{Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)}/brightpearl/private/tests/phpcs/phpcs.xml #{Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)}/brightpearl/private/library/Lib/#{@args[0]}"
|
28
|
-
puts command
|
29
|
-
exit
|
30
|
-
system(command)
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|