brightpearl-cli 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/brightpearl_cli.rb +151 -76
- data/lib/core/config.rb +67 -17
- data/lib/core/encrypter.rb +55 -0
- data/lib/core/enums.rb +2 -0
- data/lib/core/git.rb +82 -37
- data/lib/core/mysql.rb +34 -8
- data/lib/core/terminal.rb +74 -165
- data/lib/core/tools.rb +33 -13
- data/lib/routes/build.rb +92 -19
- data/lib/routes/git_checkout.rb +13 -19
- data/lib/routes/git_delete.rb +18 -33
- data/lib/routes/git_merge.rb +148 -70
- data/lib/routes/git_pull.rb +40 -4
- data/lib/routes/git_push.rb +40 -4
- data/lib/routes/git_stash.rb +19 -2
- data/lib/routes/git_update.rb +13 -73
- data/lib/routes/jira.rb +1 -0
- data/lib/routes/production_logs.rb +356 -0
- data/lib/routes/review.rb +30 -4
- data/lib/routes/scripts_api_docs.rb +41 -0
- data/lib/routes/scripts_branch_cleaner.rb +196 -0
- data/lib/routes/scripts_pom_fixer.rb +94 -0
- data/lib/routes/setup.rb +11 -3
- data/lib/routes/tail.rb +46 -0
- metadata +15 -10
- data/lib/routes/less.rb +0 -37
- /data/lib/routes/{tests.rb → test.rb} +0 -0
@@ -0,0 +1,94 @@
|
|
1
|
+
module BrightpearlCommand
|
2
|
+
|
3
|
+
class ScriptsPomFixer < ::Convoy::ActionCommand::Base
|
4
|
+
|
5
|
+
def execute
|
6
|
+
|
7
|
+
@opts = command_options
|
8
|
+
@args = arguments
|
9
|
+
@git = Brightpearl::Git.new
|
10
|
+
opts_validate
|
11
|
+
opts_routing
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def opts_validate
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def opts_routing
|
20
|
+
|
21
|
+
fix_poms
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def fix_poms
|
26
|
+
|
27
|
+
command = "find #{ Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)} -name 'pom.xml'"
|
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
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
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
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
data/lib/routes/setup.rb
CHANGED
@@ -4,9 +4,17 @@ module BrightpearlCommand
|
|
4
4
|
|
5
5
|
def execute
|
6
6
|
|
7
|
-
Brightpearl::Config::
|
8
|
-
|
9
|
-
|
7
|
+
if File.exists?(File.expand_path(Brightpearl::Config::CONFIG_FILE))
|
8
|
+
|
9
|
+
Brightpearl::Config::config_file_edit
|
10
|
+
Brightpearl::Config::config_params_get
|
11
|
+
Brightpearl::Config::config_params_validate(true)
|
12
|
+
|
13
|
+
else
|
14
|
+
|
15
|
+
Brightpearl::Config.initialize
|
16
|
+
|
17
|
+
end
|
10
18
|
|
11
19
|
end
|
12
20
|
|
data/lib/routes/tail.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module BrightpearlCommand
|
2
|
+
|
3
|
+
class Tail < ::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
|
+
tail_all_catalina_out
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def tail_all_catalina_out
|
25
|
+
|
26
|
+
if Brightpearl::Tools::this_is_a_mac
|
27
|
+
|
28
|
+
begin
|
29
|
+
system('clear')
|
30
|
+
Brightpearl::Terminal::info("Tailing #{Brightpearl::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 '#{Brightpearl::Terminal::format_command('CTRL + C')}\x1B[38;5;240m' to quit."])
|
31
|
+
system("sshpass -p#{Brightpearl::Config.param(Brightpearl::Config::VM_USER_PASSWORD)} ssh #{Brightpearl::Config.param(Brightpearl::Config::VM_USER)}@#{Brightpearl::Config.param(Brightpearl::Config::VM_IP)} 'tail -f /var/log/tomcat/*/catalina.out | grep -v \"scheduling\\|/var/log\\|rabbitmq\\|Clearing app version/service version cache\\|^$\"'")
|
32
|
+
ensure
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
|
36
|
+
else
|
37
|
+
|
38
|
+
Brightpearl::Terminal::info('This functionality has not yet been implemented on your OS', ["Currently only works on #{Brightpearl::Terminal::format_action(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_OS))}", nil, "You are on #{Brightpearl::Terminal::format_action(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_OS))}"])
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
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.2.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-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: columnist
|
@@ -109,13 +109,12 @@ executables:
|
|
109
109
|
extensions: []
|
110
110
|
extra_rdoc_files: []
|
111
111
|
files:
|
112
|
-
- LICENSE
|
113
112
|
- README.md
|
114
|
-
-
|
115
|
-
- bin/brightpearl
|
113
|
+
- LICENSE
|
116
114
|
- lib/brightpearl_cli.rb
|
117
115
|
- lib/core/api.rb
|
118
116
|
- lib/core/config.rb
|
117
|
+
- lib/core/encrypter.rb
|
119
118
|
- lib/core/enums.rb
|
120
119
|
- lib/core/git.rb
|
121
120
|
- lib/core/jira.rb
|
@@ -134,14 +133,20 @@ files:
|
|
134
133
|
- lib/routes/git_stash.rb
|
135
134
|
- lib/routes/git_update.rb
|
136
135
|
- lib/routes/jira.rb
|
137
|
-
- lib/routes/
|
136
|
+
- lib/routes/production_logs.rb
|
138
137
|
- lib/routes/reset.rb
|
139
138
|
- lib/routes/review.rb
|
139
|
+
- lib/routes/scripts_api_docs.rb
|
140
|
+
- lib/routes/scripts_branch_cleaner.rb
|
140
141
|
- lib/routes/scripts_code_sniffer.rb
|
141
142
|
- lib/routes/scripts_color.rb
|
143
|
+
- lib/routes/scripts_pom_fixer.rb
|
142
144
|
- lib/routes/setup.rb
|
143
|
-
- lib/routes/
|
145
|
+
- lib/routes/tail.rb
|
146
|
+
- lib/routes/test.rb
|
144
147
|
- lib/routes/update.rb
|
148
|
+
- bin/bp
|
149
|
+
- bin/brightpearl
|
145
150
|
homepage: http://rubygems.org/gems/brightpearl-cli
|
146
151
|
licenses:
|
147
152
|
- MIT
|
@@ -152,9 +157,9 @@ require_paths:
|
|
152
157
|
- lib
|
153
158
|
required_ruby_version: !ruby/object:Gem::Requirement
|
154
159
|
requirements:
|
155
|
-
- - "
|
160
|
+
- - ">="
|
156
161
|
- !ruby/object:Gem::Version
|
157
|
-
version: '
|
162
|
+
version: '1.9'
|
158
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
164
|
requirements:
|
160
165
|
- - ">="
|
@@ -162,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
167
|
version: '0'
|
163
168
|
requirements: []
|
164
169
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
170
|
+
rubygems_version: 2.1.11
|
166
171
|
signing_key:
|
167
172
|
specification_version: 4
|
168
173
|
summary: Brightpearl (Command Line Interface)
|
data/lib/routes/less.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module BrightpearlCommand
|
2
|
-
|
3
|
-
class Less < ::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
|
-
|
19
|
-
def opts_routing
|
20
|
-
|
21
|
-
compile_less_file
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
def compile_less_file
|
26
|
-
|
27
|
-
unless @opts[:skipConfirm]
|
28
|
-
puts "\nYou are about to #{Brightpearl::Terminal::format_action('COMPILE THE BRIGHTPEARL LESS FILE')}"
|
29
|
-
Brightpearl::Terminal::enter_to_continue
|
30
|
-
end
|
31
|
-
Brightpearl::Terminal.command(['lessc -x less/screen.less screen.css'], "#{Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)}/brightpearl/public/brightpearl/includes/css")
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
File without changes
|