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.
@@ -0,0 +1,288 @@
1
+ module BrightpearlCommand
2
+
3
+ class GitMerge < ::Convoy::ActionCommand::Base
4
+
5
+ def execute
6
+
7
+ @opts = command_options
8
+ @args = arguments
9
+ @git = Brightpearl::Git.new
10
+
11
+ @source_branches = []
12
+ @target_branch = nil
13
+
14
+ opts_validate
15
+ opts_routing
16
+
17
+ end
18
+
19
+ def opts_validate
20
+
21
+ unless @args.any?
22
+ unless @opts[:from_file]
23
+ system('bp g m -h')
24
+ exit
25
+ end
26
+ end
27
+
28
+ if @args[0] == Brightpearl::Git::MASTER
29
+ Brightpearl::Terminal::error('Not allowed', "You cannot merge #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)}\x1B[38;5;240m to #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)}", true)
30
+ end
31
+
32
+ if @opts[:from_file]
33
+ unless @args[1].nil?
34
+ Brightpearl::Terminal::error('Too many parameters', ["When using the #{Brightpearl::Terminal::format_flag('f')}\x1B[38;5;240m, system only expects one #{Brightpearl::Terminal::format_action('optional')}\x1B[38;5;240m parameter \xe2\x80\x94 the target branch.", "The amount of parameters you tried to pass is: #{@args.length}"], true)
35
+ end
36
+ unless File.file?(@opts[:from_file])
37
+ Brightpearl::Terminal::error('File not found', "The file: #{Brightpearl::Terminal::format_directory(@opts[:from_file])}\x1B[38;5;240m doesn't exist.", true)
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ def opts_routing
44
+
45
+ retrieve_source_branches
46
+ retrieve_target_branches
47
+
48
+ merge
49
+
50
+ end
51
+
52
+ def merge
53
+
54
+ puts "\x1B[38;5;40m@TODO \xe2\x80\x94 If no source branches, must throw error.\x1B[0m"
55
+
56
+ unless Brightpearl::Terminal::prompt_yes_no("You're about to #{Brightpearl::Terminal::format_action('merge')} the following branch(es):", generate_source_target_text, "Would you like to #{Brightpearl::Terminal::format_action('CONTINUE')}\x1B[38;5;89m")
57
+ Brightpearl::Terminal::abort(nil, nil, true, false)
58
+ end
59
+
60
+ atleast_one_branch_found = false
61
+ atleast_one_error = false
62
+ current_branch_cd = @git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
63
+ current_branch_db = @git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))
64
+ cd_repo = Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)
65
+ db_repo = Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)
66
+ non_existent_branches_cd = []
67
+ non_existent_branches_db = []
68
+ branches_with_stashes_cd = []
69
+ branches_with_stashes_db = []
70
+ changed_files = []
71
+
72
+ # # SANITY CHECK SCRIPT
73
+ # @source_branches.each do |x|
74
+ # grep_string = x.split('-')
75
+ # grep_string = "BP-#{grep_string[grep_string.count - 1]}"
76
+ # puts "\x1B[38;5;39m#{x}\x1B[0m \xe2\x80\x94 (#{grep_string})"
77
+ # system("cd #{Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)} && git log | grep '#{grep_string}' --color=auto")
78
+ # system("cd #{Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)} && git log | grep '#{grep_string}' --color=auto")
79
+ # end
80
+ # puts
81
+ # exit
82
+
83
+ # UPDATE MASTER & CHECKOUT BRANCH TO MERGE TO
84
+ Brightpearl::Terminal::output("Updating #{Brightpearl::Terminal::format_branch(@target_branch)}")
85
+ target_branch_data = @git.branch_data(@target_branch, nil, false)
86
+ if target_branch_data[0][:"#{Brightpearl::Git::BRANCH_EXISTS}"] == false || target_branch_data[1][:"#{Brightpearl::Git::BRANCH_EXISTS}"] == false
87
+ Brightpearl::Terminal::error("Target branch #{Brightpearl::Terminal::format_branch(@target_branch)} doesn't exist", 'Please check your spelling and try again.', true)
88
+ end
89
+ commands = [
90
+ "git checkout #{Brightpearl::Git::MASTER}",
91
+ 'git pull',
92
+ "git checkout #{@target_branch}",
93
+ 'git pull',
94
+ "git merge #{Brightpearl::Git::MASTER}"
95
+ ]
96
+ @git.repo_loop.each do |repo_dir|
97
+ Brightpearl::Terminal::command(commands, repo_dir)
98
+ end
99
+
100
+ # GET DATA FIRST
101
+ branches_data = []
102
+ @source_branches.each do |branch_name|
103
+ branches_data << @git.branch_data(branch_name, nil, false)
104
+ end
105
+
106
+ # RUN CHECKS
107
+ branches_data.each do |branch_data|
108
+ if branch_data[0][:"#{Brightpearl::Git::BRANCH_EXISTS}"] || branch_data[1][:"#{Brightpearl::Git::BRANCH_EXISTS}"]
109
+ atleast_one_branch_found = true
110
+ end
111
+ if branch_data[0][:"#{Brightpearl::Git::BRANCH_EXISTS}"] == false
112
+ non_existent_branches_cd << branch_data[0][:"#{Brightpearl::Git::BRANCH_NAME}"]
113
+ end
114
+ if branch_data[1][:"#{Brightpearl::Git::BRANCH_EXISTS}"] == false
115
+ non_existent_branches_db << branch_data[0][:"#{Brightpearl::Git::BRANCH_NAME}"]
116
+ end
117
+ if branch_data[0][:"#{Brightpearl::Git::BRANCH_HAS_STASH}"]
118
+ branches_with_stashes_cd << branch_data[0][:"#{Brightpearl::Git::BRANCH_NAME}"]
119
+ end
120
+ if branch_data[1][:"#{Brightpearl::Git::BRANCH_HAS_STASH}"]
121
+ branches_with_stashes_db << branch_data[1][:"#{Brightpearl::Git::BRANCH_NAME}"]
122
+ end
123
+ if branch_data[0][:"#{Brightpearl::Git::BRANCH_EXISTS_LOCALLY}"] == false && branch_data[0][:"#{Brightpearl::Git::BRANCH_EXISTS}"]
124
+ commands_cd = [
125
+ "git checkout #{branch_data[0][:"#{Brightpearl::Git::BRANCH_NAME}"]}",
126
+ 'git pull',
127
+ "git checkout #{current_branch_cd}"
128
+ ]
129
+ Brightpearl::Terminal::command(commands_cd, Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
130
+ end
131
+ if branch_data[1][:"#{Brightpearl::Git::BRANCH_EXISTS_LOCALLY}"] == false && branch_data[1][:"#{Brightpearl::Git::BRANCH_EXISTS}"]
132
+ commands_db = [
133
+ "git checkout #{branch_data[1][:"#{Brightpearl::Git::BRANCH_NAME}"]}",
134
+ 'git pull',
135
+ "git checkout #{current_branch_db}"
136
+ ]
137
+ Brightpearl::Terminal::command(commands_db, Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))
138
+ end
139
+ end
140
+
141
+ puts # DO NOT REMOVE.
142
+
143
+ # STOP HERE IF THERE ARE FAILURES
144
+ if non_existent_branches_cd.any?
145
+ Brightpearl::Terminal::warning("The following branches could not be found in: #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)))}", non_existent_branches_cd, false)
146
+ atleast_one_error = true
147
+ end
148
+ if non_existent_branches_db.any?
149
+ Brightpearl::Terminal::warning("The following branches could not be found in: #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)))}", non_existent_branches_db, false)
150
+ atleast_one_error = true
151
+ end
152
+ if branches_with_stashes_cd.any?
153
+ Brightpearl::Terminal::error("The following branches have stashes (#{@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))})", branches_with_stashes_cd, false)
154
+ atleast_one_error = true
155
+ end
156
+ if branches_with_stashes_db.any?
157
+ Brightpearl::Terminal::error("The following branches have stashes (#{@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))})", branches_with_stashes_db, false)
158
+ atleast_one_error = true
159
+ end
160
+ if atleast_one_branch_found == false
161
+ Brightpearl::Terminal::error('All the branches you specified cannot be found.', 'Nothing to merge. Aborting script.', true)
162
+ end
163
+
164
+ source_target_text = generate_source_target_text
165
+ source_target_text.unshift('')
166
+ if atleast_one_error
167
+ source_target_text.unshift('Although issues were detected, the script determined that these are non-fatal and can continue with the merge.')
168
+ end
169
+ source_target_text.unshift("This is officially the \x1B[38;5;196mPOINT OF NO RETURN\x1B[38;5;240m. Please make sure everything is OK before continuing.")
170
+
171
+ unless Brightpearl::Terminal::prompt_yes_no("You're about to #{Brightpearl::Terminal::format_action('merge')} the following branch(es):", source_target_text, "Are you absolutely sure you would like to #{Brightpearl::Terminal::format_action('CONTINUE')}\x1B[38;5;89m with the merge?")
172
+ Brightpearl::Terminal::abort(nil, nil, true, false)
173
+ end
174
+
175
+ # DO THE MERGE
176
+ branches_data.each do |branch_data|
177
+
178
+ branch_name = branch_data[0][:"#{Brightpearl::Git::BRANCH_NAME}"]
179
+ commands1 = []
180
+ commands1 << "git checkout #{branch_name}"
181
+ commands1 << 'git pull'
182
+ commands2 = ["git merge #{Brightpearl::Git::MASTER}"]
183
+ commands3 = [
184
+ 'git push',
185
+ "git checkout #{@target_branch}"
186
+ ]
187
+ commands4 = ["git merge #{branch_name}"]
188
+
189
+ # CODE BRANCHES
190
+ unless non_existent_branches_cd.include?(branch_name)
191
+ Brightpearl::Terminal::command(commands1, cd_repo)
192
+ merge_master_result = Brightpearl::Terminal::command(commands2, cd_repo)
193
+ if merge_master_result[0] == false
194
+ Brightpearl::Terminal::error('Merge conflict occurred', "Unable to successfully merge #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)} \xe2\x86\x92 #{Brightpearl::Terminal::format_branch(branch_name)} \xe2\x80\x94 (#{@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))})", true)
195
+ end
196
+ Brightpearl::Terminal::command(commands3, cd_repo)
197
+ merge_to_target = Brightpearl::Terminal::command(commands4, cd_repo)
198
+ if merge_to_target == false
199
+ Brightpearl::Terminal::error('Merge conflict occurred', "Unable to successfully merge #{Brightpearl::Terminal::format_branch(branch_name)} \xe2\x86\x92 #{Brightpearl::Terminal::format_branch(@target_branch)} \xe2\x80\x94 (#{@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))})", true)
200
+ end
201
+ end
202
+
203
+ # DB BRANCHES
204
+ if non_existent_branches_db.include?(branch_name)
205
+ # Brightpearl::Terminal::warning("Skipping #{Brightpearl::Terminal::format_branch(branch_name)} \xe2\x80\x94 (#{@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))})", 'Branch not found.')
206
+ else
207
+ Brightpearl::Terminal::command(commands1, db_repo)
208
+ merge_master_result = Brightpearl::Terminal::command(commands2, db_repo)
209
+ if merge_master_result[0] == false
210
+ Brightpearl::Terminal::error('Merge conflict occurred', "Unable to successfully merge #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)} \xe2\x86\x92 #{Brightpearl::Terminal::format_branch(branch_name)} \xe2\x80\x94 (#{@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))})", true)
211
+ end
212
+ Brightpearl::Terminal::command(commands3, db_repo, false)
213
+ merge_to_target = Brightpearl::Terminal::command(commands4, db_repo)
214
+ if merge_to_target == false
215
+ Brightpearl::Terminal::error('Merge conflict occurred', "Unable to successfully merge #{Brightpearl::Terminal::format_branch(branch_name)} \xe2\x86\x92 #{Brightpearl::Terminal::format_branch(@target_branch)} \xe2\x80\x94 (#{@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))})", true)
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ Brightpearl::Terminal::success('It seems as if everything ran smoothly', "#{@source_branches.count} #{(@source_branches.count) == 1 ? 'branch has' : 'branches have'} been successfully merged to #{Brightpearl::Terminal::format_branch(@target_branch)}")
222
+ if Brightpearl::Terminal::prompt_yes_no('Just to be safe, would you like to run a sanity check?', ["This will execute #{Brightpearl::Terminal::format_command('git log')}\x1B[38;5;240m on #{Brightpearl::Terminal::format_branch(@target_branch)}\x1B[38;5;240m and #{Brightpearl::Terminal::format_command('grep')}\x1B[38;5;240m for Jira numbers relating to", 'to all the branches you have just merged. This way we can double-check they have', 'actually been merged', nil, "Please note this process may not be \x1B[38;5;250m100%\x1B[38;5;240m reliable"])
223
+
224
+ # SANITY CHECK SCRIPT
225
+ @source_branches.each do |x|
226
+ grep_string = x.split('-')
227
+ grep_string = "BP-#{grep_string[grep_string.count - 1]}"
228
+ puts "\x1B[38;5;39m#{x}\x1B[0m \xe2\x80\x94 (#{grep_string})"
229
+ system("cd #{Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)} && git log | grep '#{grep_string}' --color=auto")
230
+ system("cd #{Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)} && git log | grep '#{grep_string}' --color=auto")
231
+ end
232
+ puts
233
+
234
+ end
235
+
236
+ end
237
+
238
+ private
239
+
240
+ def retrieve_source_branches
241
+ if @opts[:from_file]
242
+ File.open(@opts[:from_file]).each do |line|
243
+ line_trimmed = line.gsub(/\s+/, '')
244
+ if line_trimmed != ''
245
+ line_split = line_trimmed.split(',')
246
+ @source_branches.concat(line_split)
247
+ end
248
+ end
249
+ else
250
+ source_branches = @args[0].split(',')
251
+ @source_branches.concat(source_branches)
252
+ end
253
+ @source_branches.sort_by! { |m| m.downcase }
254
+ @source_branches.uniq!
255
+ end
256
+
257
+ def retrieve_target_branches
258
+ if @opts[:from_file]
259
+ if @args[0].nil?
260
+ @target_branch = Brightpearl::Git::MASTER
261
+ else
262
+ @target_branch = @args[0]
263
+ end
264
+ else
265
+ if @args[1].nil?
266
+ @target_branch = Brightpearl::Git::MASTER
267
+ else
268
+ @target_branch = @args[1]
269
+ end
270
+ end
271
+ end
272
+
273
+ def generate_source_target_text
274
+ source_branches_dup = @source_branches.dup
275
+ source_branch_text = ["Source branch(es): \x1B[38;5;117m#{source_branches_dup.shift}"]
276
+ unless source_branches_dup.empty?
277
+ source_branches_dup.each do |sb|
278
+ source_branch_text << " \x1B[38;5;117m#{sb}"
279
+ end
280
+ source_branch_text << ''
281
+ end
282
+ source_branch_text << " Target branch: \x1B[38;5;40m#{@target_branch}"
283
+ source_branch_text
284
+ end
285
+
286
+ end
287
+
288
+ end
@@ -0,0 +1,16 @@
1
+ module BrightpearlCommand
2
+
3
+ class GitPull < ::Convoy::ActionCommand::Base
4
+
5
+ def execute
6
+
7
+ Convoy::Logger.output.puts "Command: #{command_name}"
8
+ Convoy::Logger.output.puts "Options: #{options}"
9
+ Convoy::Logger.output.puts "Command options: #{command_options}"
10
+ Convoy::Logger.output.puts "Arguments: #{arguments}"
11
+
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,16 @@
1
+ module BrightpearlCommand
2
+
3
+ class GitPush < ::Convoy::ActionCommand::Base
4
+
5
+ def execute
6
+
7
+ Convoy::Logger.output.puts "Command: #{command_name}"
8
+ Convoy::Logger.output.puts "Options: #{options}"
9
+ Convoy::Logger.output.puts "Command options: #{command_options}"
10
+ Convoy::Logger.output.puts "Arguments: #{arguments}"
11
+
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,27 @@
1
+ module BrightpearlCommand
2
+
3
+ class GitStash < ::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
+ # SHOW WHAT FILES HAVE CHANGED IN A STASH
21
+ system('git stash show --name-only stash@{0}')
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,125 @@
1
+ module BrightpearlCommand
2
+
3
+ class GitUpdate < ::Convoy::ActionCommand::Base
4
+
5
+ def execute
6
+ @git = Brightpearl::Git.new
7
+ @opts = command_options
8
+ opts_validate
9
+ opts_routing
10
+ end
11
+
12
+ def opts_validate
13
+ end
14
+
15
+ def opts_routing
16
+
17
+ if @opts[:all]
18
+
19
+ Brightpearl::Terminal::error('Note yet implemented', "Must write code to update ALL branches.\nCould get complicated as there will likely be merge conflicts.\nMust think about this...", true)
20
+
21
+ # update_branch_all
22
+ else
23
+ update_branch_single
24
+ end
25
+
26
+ end
27
+
28
+ # Updates the current branch.
29
+ # @return void
30
+ def update_branch_single
31
+ ran_smoothly = true
32
+ @git.stash_staged_changes
33
+ @git.repo_loop.each do |repo_dir|
34
+ current_branch = @git.current_branch_for_repo(repo_dir)
35
+ commands = Array.new
36
+ if current_branch != Brightpearl::Git::MASTER
37
+ commands << 'git checkout master'
38
+ end
39
+ commands << 'git pull'
40
+ if current_branch != Brightpearl::Git::MASTER
41
+ commands << "git checkout #{current_branch}"
42
+ commands << 'git pull'
43
+ commands << 'git merge master'
44
+ end
45
+ results = Brightpearl::Terminal::command(commands, repo_dir)
46
+ if results[4] == false
47
+ Brightpearl::Terminal::error('Merge conflict occurred', ["Unable to successfully merge #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)} \xe2\x86\x92 #{Brightpearl::Terminal::format_branch(current_branch)} \xe2\x80\x94 (#{@git.get_repo_shorthand(repo_dir)})", "Please #{Brightpearl::Terminal::format_action('open an IDE')}\x1B[38;5;240m and resolve your conflicts as soon as this script has finished executing."], false)
48
+ ran_smoothly = false
49
+ next
50
+ end
51
+ if @opts[:push] && (current_branch != Brightpearl::Git::MASTER)
52
+ Brightpearl::Terminal::command('git push', repo_dir)
53
+ end
54
+
55
+ end
56
+ if ran_smoothly
57
+ @git.check_for_stash
58
+ end
59
+ end
60
+
61
+ # Updates ALL local branches.
62
+ # @return void
63
+ # def update_branch_all
64
+ # Brightpearl::Tools::verify_internet_access
65
+ # repos = []
66
+ # brightpearl_code, brightpearl_db = @git.get_branches_as_array(Brightpearl::Git::SORT_REFNAME, Brightpearl::Git::LOCAL)
67
+ # Array[brightpearl_code, brightpearl_db].each do |repo_data|
68
+ # branches = []
69
+ # repo_data.each do |branch_name|
70
+ # if branch_name[0..6] != Brightpearl::Git::MERGED_PREFIX
71
+ # branches << branch_name
72
+ # end
73
+ # end
74
+ # repos << branches
75
+ # end
76
+ # message = [
77
+ # "You are about to merge master into ALL of the following branches:\n\n",
78
+ # "\x1B[33mbrightpearl-code \xe2\x86\x92 \x1B[0m\x1B[32m#{repos[0].join(', ')}\x1B[0m",
79
+ # "\x1B[33mbrightpearl-db \xe2\x86\x92 \x1B[0m\x1B[32m#{repos[1].join(', ')}\x1B[0m\n\n",
80
+ # 'This script will pull from master, merge master into ALL of your branches & then push your branches back up to /origin.'
81
+ # ]
82
+ # branch_count = repos[0].length + repos[1].length
83
+ # if (branch_count) > 9
84
+ # message << "\n\x1B[41m WARNING \x1B[0m You're about to update \x1B[32m#{branch_count}\x1B[0m branches. This could take a while.."
85
+ # end
86
+ # Brightpearl::Terminal::prompt_enter(message)
87
+ #
88
+ # # Update master on both repos.
89
+ # @git.repo_loop.each do |repo_dir|
90
+ # current_branch = @git.current_branch_for_repo(repo_dir)
91
+ # commands = Array.new
92
+ # if current_branch != Brightpearl::Git::MASTER
93
+ # commands << 'git checkout master'
94
+ # end
95
+ # commands << 'git pull'
96
+ # Brightpearl::Terminal::command(commands, repo_dir)
97
+ # end
98
+ #
99
+ # # Update ALL the branches, one-by-one.
100
+ # repos[0].each do |branch|
101
+ # update_branch(branch, Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
102
+ # end
103
+ # repos[1].each do |branch|
104
+ # update_branch(branch, Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))
105
+ # end
106
+ #
107
+ # end
108
+
109
+ # Updates a single branch.
110
+ # @return void
111
+ # def update_branch(branch_name, repo_dir)
112
+ # if branch_name != Brightpearl::Git::MASTER
113
+ # puts "\x1B[45m Check-out \x1B[0m \x1B[32m\xe2\x86\x92\x1B[0m \x1B[35m#{branch_name}\x1B[0m"
114
+ # commands = Array.new
115
+ # commands << "git checkout #{branch_name}"
116
+ # # commands << 'git pull'
117
+ # commands << 'git merge --no-commit --no-ff master | grep CONFLICT'
118
+ # # commands << 'git push'
119
+ # Brightpearl::Terminal::command(commands, repo_dir)
120
+ # end
121
+ # end
122
+
123
+ end
124
+
125
+ end
@@ -0,0 +1,51 @@
1
+ module BrightpearlCommand
2
+
3
+ class JiraCard < ::Convoy::ActionCommand::Base
4
+
5
+ def execute
6
+
7
+ @opts = command_options
8
+ @args = arguments
9
+ @jira = Brightpearl::Jira.new
10
+ opts_validate
11
+ opts_routing
12
+
13
+ end
14
+
15
+ def opts_validate
16
+
17
+ if @opts[:card] == false
18
+ if @args.any?
19
+ @opts[:card] = true
20
+ else
21
+ system('bp j -h')
22
+ end
23
+ exit
24
+ end
25
+
26
+ if @opts[:card]
27
+ if @args[0].nil? || @args[0] == ''
28
+ Brightpearl::Terminal::error('Argument required', 'You must supply a valid Jira Number as an argument.', true)
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ def opts_routing
35
+
36
+ if @opts[:card]
37
+ get_card_info
38
+ end
39
+
40
+ end
41
+
42
+ def get_card_info
43
+
44
+ jira_number = @jira.get_jira_number_from_arg(@args[0])
45
+ puts jira_number
46
+
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,37 @@
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
@@ -0,0 +1,33 @@
1
+ module BrightpearlCommand
2
+
3
+ class Reset < ::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
+ if @opts[:fitnesseDump]
21
+ reset_fitnesse_dump
22
+ end
23
+
24
+ end
25
+
26
+ def reset_fitnesse_dump
27
+
28
+
29
+
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,16 @@
1
+ module BrightpearlCommand
2
+
3
+ class Review < ::Convoy::ActionCommand::Base
4
+
5
+ def execute
6
+
7
+ Convoy::Logger.output.puts "Command: #{command_name}"
8
+ Convoy::Logger.output.puts "Options: #{options}"
9
+ Convoy::Logger.output.puts "Command options: #{command_options}"
10
+ Convoy::Logger.output.puts "Arguments: #{arguments}"
11
+
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,36 @@
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