jump-starter 1.1.17 → 1.1.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9706f9216827451fb3e6506ba998c7a5c234bb7423074c078d533fa9e35aff7
4
- data.tar.gz: 006744101b01ed63fc394d5ae554e3fe503393fffb55c02c66d426032a1e5dc3
3
+ metadata.gz: dc8d7d5e98f4cea4e608e6693b79c0f42d4e67c65c7624ad2278002a8d69c150
4
+ data.tar.gz: 2541ab72bdd98f7e9470db1ad80be08daed7a2f977718b235a4fec17b00372c7
5
5
  SHA512:
6
- metadata.gz: c0a6fc532b81d6cbaa6f41a168703b1c779641fbf59a590cbc1737f71de076f18f9292d00b7248acdd1cb9d204b1694076b32a0943806f67ac5131b0502509aa
7
- data.tar.gz: ddbf25c072b29ebf4dd6d279463642ba8e30c11db59b91632d1b8d8a5c7e8cb80cf649f66648dfe878fcafdd868d8b5159992adf138e239f8aeb0b04813cadc0
6
+ metadata.gz: 85871148c91c0c29b7a81aa4051af822e594dc387f0c738d25028f2bba59dddd2175b23337c48463abccf8a694f9f40e088a1c059e5067545639f5a879ab3169
7
+ data.tar.gz: 0fefffadf4bbee4407331625afabc5052d1bb9e7d2e047e910dcd1e17fc0a1b1377d261d8a75e4d114669a3f953534ab7e0163eeb44417cecdb8a7d1b9f3cf28
@@ -1,18 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jump-starter (1.1.16)
4
+ jump-starter (1.1.18)
5
5
  colorize
6
6
  commander
7
+ terminal-table
8
+ xcodeproj
7
9
 
8
10
  GEM
9
11
  remote: https://rubygems.org/
10
12
  specs:
13
+ CFPropertyList (3.0.0)
14
+ atomos (0.1.3)
15
+ claide (1.0.2)
16
+ colored2 (3.1.2)
11
17
  colorize (0.8.1)
12
18
  commander (4.4.6)
13
19
  highline (~> 1.7.2)
14
20
  diff-lcs (1.3)
15
21
  highline (1.7.10)
22
+ nanaimo (0.2.6)
16
23
  rake (12.3.1)
17
24
  rspec (3.8.0)
18
25
  rspec-core (~> 3.8.0)
@@ -27,6 +34,15 @@ GEM
27
34
  diff-lcs (>= 1.2.0, < 2.0)
28
35
  rspec-support (~> 3.8.0)
29
36
  rspec-support (3.8.0)
37
+ terminal-table (1.8.0)
38
+ unicode-display_width (~> 1.1, >= 1.1.1)
39
+ unicode-display_width (1.4.0)
40
+ xcodeproj (1.7.0)
41
+ CFPropertyList (>= 2.3.3, < 4.0)
42
+ atomos (~> 0.1.3)
43
+ claide (>= 1.0.2, < 2.0)
44
+ colored2 (~> 3.1)
45
+ nanaimo (~> 0.2.6)
30
46
 
31
47
  PLATFORMS
32
48
  ruby
data/README.md CHANGED
@@ -1,4 +1,36 @@
1
- # Jumpstarter
1
+
2
+ # Welcome! 👋 to Jumpstarter ⚡️
3
+
4
+
5
+ ## What is Jumpstarter?
6
+
7
+ We're glad you asked!
8
+
9
+ Barrier to entry is always something we as open source developers are trying to lower. Afterall open source projects are as powerful as its maintainers so wouldn't you want to make becoming a contributor/maintainer easier?
10
+
11
+ From personal experience i've noticed that as hard as a developer tries to write a good contributing guide, getting setup can be a drag. You have to read and re-read each instruction, download additional dependencies and not to mention these instructions are different depending on your OS. Instead of wasting time writing up a guide and then answering and helping people afterwards we have decided to offer the ability to write up a Start file.
12
+
13
+ A start file makes getting setup a breeze for the contributor because they have to do... well... nothing. WHAT?!?!. Here's an example:
14
+
15
+ ```bash
16
+ git fork Huddie/Grade-Notifier
17
+ git clone Grade-Notifier
18
+ cd Grade-Notifier
19
+ bash run ./Depfiles/depinstall.sh
20
+ ```
21
+
22
+ So what does this do?
23
+
24
+ 1. Forks the repository
25
+ 2. Clones it
26
+ 3. Installs all the dependencies
27
+
28
+ This is a fairly simply Start file.
29
+
30
+ Notice how the creator of the Start file didn't have to write instructions for a specific OS. Notice how you can make use of powerful instructions like `git fork`.
31
+
32
+ We hope that Start files will lower the barrier to entry so developers can focus on developing.
33
+
2
34
 
3
35
  ## License
4
36
 
@@ -11,6 +11,9 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.add_dependency 'commander'
13
13
  spec.add_dependency 'colorize'
14
+ spec.add_dependency 'xcodeproj'
15
+ spec.add_dependency 'terminal-table'
16
+
14
17
 
15
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
19
  spec.require_paths = ["lib"]
@@ -0,0 +1,37 @@
1
+ module Jumpstarter
2
+ class Bash
3
+ #******************#
4
+ # Instructions #
5
+ #******************#
6
+ class Run < I_Instructions
7
+ def run!()
8
+ system(@cmd)
9
+ return true
10
+ end
11
+ end
12
+
13
+ class CD < I_Instructions
14
+ def run!()
15
+ Dir.chdir "#{@path}"
16
+ return true
17
+ end
18
+ end
19
+ class << self
20
+ #*****************#
21
+ # Class Methods #
22
+ #*****************#
23
+ def self.installed!()
24
+ # Run version
25
+ version = CommandRunner.execute(
26
+ command: Commands::Pip::Version,
27
+ error: nil
28
+ )
29
+ return (/pip (\d+)(.\d+)?(.\d+)?/ =~ version)
30
+ end
31
+
32
+ def required_imports
33
+ ['instructions', 'writer.rb', 'commandRunner.rb']
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,19 +1,19 @@
1
1
  class StandardError
2
2
  def exit_status
3
- return -1
3
+ return -1
4
4
  end
5
5
  end
6
-
6
+
7
7
  module Jumpstarter
8
8
  class JumpstarterPtyError < StandardError
9
- attr_reader :exit_status
10
- def initialize(e, exit_status)
9
+ attr_reader :exit_status
10
+ def initialize(e, exit_status)
11
11
  super(e)
12
12
  set_backtrace(e.backtrace) if e
13
13
  @exit_status = exit_status
14
- end
15
14
  end
16
-
15
+ end
16
+
17
17
  class JumpstarterPty
18
18
  def self.spawn(command)
19
19
  require 'pty'
@@ -35,7 +35,7 @@ module Jumpstarter
35
35
  require 'open3'
36
36
  Open3.popen2e(command) do |command_stdin, command_stdout, p| # note the inversion
37
37
  yield(command_stdout, command_stdin, p.value.pid)
38
-
38
+
39
39
  command_stdin.close
40
40
  command_stdout.close
41
41
  p.value.exitstatus
@@ -1,5 +1,3 @@
1
- require_relative './OS'
2
-
3
1
  module Jumpstarter
4
2
  class Commands
5
3
  class Pip
@@ -155,6 +153,5 @@ module Jumpstarter
155
153
  end
156
154
  end
157
155
  end
158
-
159
156
  end
160
157
  end
@@ -0,0 +1,91 @@
1
+ module Jumpstarter
2
+ class Git
3
+ #******************#
4
+ # Instructions #
5
+ #******************#
6
+ class Install < Jumpstarter::I_Instructions
7
+ def run!()
8
+ # install pip
9
+ CommandRunner.execute(
10
+ command: Commands::Git::Install,
11
+ error: nil
12
+ )
13
+ return true
14
+ end
15
+ end
16
+
17
+ class Fork < I_Instructions
18
+ def run!()
19
+ # Check if git is installed
20
+ if not Jumpstarter::Git.installed!
21
+ # Install git
22
+ CommandRunner.execute(
23
+ command: Commands::Git::Install,
24
+ error: nil
25
+ )
26
+ end
27
+ # clone
28
+ CommandRunner.execute(
29
+ command: "curl -u #{@username}:#{@password} https://api.github.com/repos/#{@remote}/forks -d ''",
30
+ error: nil
31
+ )
32
+ return true
33
+ end
34
+ end
35
+
36
+ class Pull < I_Instructions
37
+ def run!()
38
+ # Check if git is installed
39
+ if not Jumpstarter::Git.installed!
40
+ # Install git
41
+ CommandRunner.execute(
42
+ command: Commands::Git::Install,
43
+ error: nil
44
+ )
45
+ end
46
+ # clone
47
+ CommandRunner.execute(
48
+ command: "git pull #{@remote} #{@branch}",
49
+ error: nil
50
+ )
51
+ return true
52
+ end
53
+ end
54
+
55
+ class Clone < I_Instructions
56
+ def run!()
57
+ # Check if git is installed
58
+ if not Jumpstarter::Git.installed!
59
+ # Install git
60
+ CommandRunner.execute(
61
+ command: Commands::Git::Install,
62
+ error: nil
63
+ )
64
+ end
65
+ # clone
66
+ CommandRunner.execute(
67
+ command: "git clone https://github.com/#{@username}/#{@remote}.git",
68
+ error: nil
69
+ )
70
+ return true
71
+ end
72
+ end
73
+ class << self
74
+ #*****************#
75
+ # Class Methods #
76
+ #*****************#
77
+ def installed!()
78
+ # Run version
79
+ version = CommandRunner.execute(
80
+ command: Commands::Git::Version,
81
+ error: nil
82
+ )
83
+ return (/git version (\d+)(.\d+)?(.\d+)?/ =~ version)
84
+ end
85
+
86
+ def required_imports
87
+ ['instructions', 'writer.rb', 'commandRunner.rb']
88
+ end
89
+ end
90
+ end
91
+ end
@@ -1,429 +1,86 @@
1
- require_relative './commandRunner'
2
- require_relative './commands'
3
1
  require 'io/console'
4
-
2
+ require 'xcodeproj'
3
+ require 'plist'
4
+ require 'terminal-table'
5
5
  module Jumpstarter
6
6
 
7
+ DEFAULTS = {
8
+ msg_success: 'Success',
9
+ msg_error: 'Error',
10
+ should_crash: false,
11
+ }
12
+
13
+ # I_Instrcutions
14
+ # This is an abstract class. And should not be init.
15
+ # This lays out the blueprint for all instructions
16
+ # The only method that must be overwritten is the run!
17
+ # method.
7
18
  class I_Instructions
8
-
9
- def initialize(msg_success, msg_error, should_crash)
10
- @msg_success = msg_success
11
- @msg_error = msg_error
12
- @should_crash = should_crash
13
- end
14
-
15
- def run!()
16
- return true
17
- end
18
-
19
- def crash_on_error!()
20
- return false
21
- end
22
-
23
- def success_message!()
24
- if not @msg_success or @msg_success.empty?
25
- return "[Success]"
26
- end
27
- return "#{@msg_success}"
28
- end
29
-
30
- def error_message!()
31
- if not @msg_error or @msg_error.empty?
32
- return "[Error]"
19
+ def initialize(opts = {})
20
+ @dec = nil
21
+ options = DEFAULTS.merge(opts)
22
+ options.each do |k, v|
23
+ v = self.clean_value(v)
24
+ @dec = "#{@dec}\n\t#{k}: #{v},"
25
+ instance_variable_set("@#{k}", v)
26
+ self.class.send(:attr_reader, k)
33
27
  end
34
- return "#{@msg_error}"
35
- end
36
-
37
- end
38
-
39
- class PIPInstall < I_Instructions
40
-
41
- def initialize(pkg, msg_success, msg_error, should_crash)
42
- @package = pkg
43
- @msg_success = msg_success
44
- @msg_error = msg_error
45
- @should_crash = should_crash
46
28
  end
47
29
 
48
30
  def run!()
49
- # Check if pip is installed
50
- if not InstallPIP.installed!
51
- # Install PIP
52
- CommandRunner.execute(
53
- command: Commands::Pip::Install,
54
- error: nil
55
- )
56
- end
57
- # pip is installed
58
- CommandRunner.execute(
59
- command: "pip3 install #{@package}",
60
- error: nil
61
- )
62
31
  return true
63
32
  end
64
33
 
65
34
  def crash_on_error!()
66
- return false
35
+ return @should_crash
67
36
  end
68
37
 
69
38
  def success_message!()
39
+ message = ""
70
40
  if not @msg_success or @msg_success.empty?
71
- return "[Installed] #{@package}"
41
+ message = "[Success]"
72
42
  end
73
- return "#{@msg_success}"
43
+ message = @msg_success
44
+ return message
74
45
  end
75
46
 
76
47
  def error_message!()
48
+ message = ""
77
49
  if not @msg_error or @msg_error.empty?
78
- return "[Error] #{@package}"
79
- end
80
- return "#{@msg_error}"
81
- end
82
- end
83
-
84
-
85
- class InstallPIP < I_Instructions
86
-
87
- def self.installed!()
88
-
89
- # Run version
90
- version = CommandRunner.execute(
91
- command: Commands::Pip::Version,
92
- error: nil
93
- )
94
- return (/pip (\d+)(.\d+)?(.\d+)?/ =~ version)
95
- end
96
-
97
- def run!()
98
- # install pip
99
- CommandRunner.execute(
100
- command: Commands::Pip::Install,
101
- error: nil
102
- )
103
- return true
104
- end
105
-
106
- def crash_on_error!()
107
- return false
108
- end
109
- end
110
-
111
- class InstallGIT < I_Instructions
112
-
113
- def self.installed!()
114
-
115
- # Run version
116
- version = CommandRunner.execute(
117
- command: Commands::Git::Version,
118
- error: nil
119
- )
120
- return (/git version (\d+)(.\d+)?(.\d+)?/ =~ version)
121
- end
122
-
123
- def run!()
124
- # install pip
125
- CommandRunner.execute(
126
- command: Commands::Git::Install,
127
- error: nil
128
- )
129
- return true
130
- end
131
-
132
- def crash_on_error!()
133
- return false
134
- end
135
- end
136
-
137
- class GITFork < I_Instructions
138
-
139
- def initialize(remote, username, password, msg_success, msg_error, should_crash)
140
- @remote = remote
141
- @username = username
142
- @password = password
143
- @msg_success = msg_success
144
- @msg_error = msg_error
145
- @should_crash = should_crash
146
- end
147
-
148
- def run!()
149
- # Check if git is installed
150
- if not InstallGIT.installed!
151
- # Install git
152
- CommandRunner.execute(
153
- command: Commands::Git::Install,
154
- error: nil
155
- )
50
+ message "[Error]"
156
51
  end
157
-
158
- # clone
159
- CommandRunner.execute(
160
- command: "curl -u #{@username}:#{@password} https://api.github.com/repos/#{@remote}/forks -d ''",
161
- error: nil
162
- )
163
- return true
52
+ message = @msg_success
53
+ return message
164
54
  end
165
55
 
166
- def crash_on_error!()
167
- return false
168
- end
169
-
170
- def success_message!()
171
- if not @msg_success or @msg_success.empty?
172
- return "[Successfully forked] #{@remote}"
56
+ def clean_value(arg)
57
+ if arg == nil
58
+ return "''"
59
+ elsif !!arg == arg or (not "#{arg}".match(" "))
60
+ return arg
173
61
  end
174
- return "#{@msg_success}"
62
+ return "#{arg}"
175
63
  end
176
64
 
177
- def error_message!()
178
- if not @msg_error or @msg_error.empty?
179
- return "[Error] #{@remote}"
180
- end
181
- return "#{@msg_error}"
65
+ def compose!()
66
+ str = "_inst_ret = #{self.class}.new(#{@dec.chomp(',')}".chomp()
67
+ str = "#{str}\n).run!"
68
+ str = "#{str}\nif _inst_ret"
69
+ str = "#{str}\n\tJumpstarter::Writer.show_success(message: #{self.success_message!})"
70
+ str = "#{str}\nelse"
71
+ str = "#{str}\n\tJumpstarter::Writer.show_error(message: #{self.error_message!})"
72
+ str = "#{str}\nend"
73
+ return str
182
74
  end
183
- end
184
-
185
- class GITPull < I_Instructions
186
-
187
- def initialize(remote, branch, msg_success, msg_error, should_crash)
188
- @remote = remote
189
- @branch = branch
190
- @msg_success = msg_success
191
- @msg_error = msg_error
192
- @should_crash = should_crash
193
- end
194
-
195
- def run!()
196
- # Check if git is installed
197
- if not InstallGIT.installed!
198
- # Install git
199
- CommandRunner.execute(
200
- command: Commands::Git::Install,
201
- error: nil
202
- )
203
- end
204
-
205
- # clone
206
- CommandRunner.execute(
207
- command: "git pull #{@remote} #{@branch}",
208
- error: nil
209
- )
210
- return true
211
- end
212
-
213
- def crash_on_error!()
214
- return false
215
- end
216
-
217
- def success_message!()
218
- if not @msg_success or @msg_success.empty?
219
- return "[Successfully pulled] #{@remote}/#{@branch}"
220
- end
221
- return "#{@msg_success}"
222
- end
223
-
224
- def error_message!()
225
- if not @msg_error or @msg_error.empty?
226
- return "[Error] #{@remote}"
227
- end
228
- return "#{@msg_error}"
229
- end
230
- end
231
-
232
- class GITClone < I_Instructions
233
-
234
- def initialize(remote, username, msg_success, msg_error, should_crash)
235
- @remote = remote
236
- @username = username
237
- @msg_success = msg_success
238
- @msg_error = msg_error
239
- @should_crash = should_crash
240
- end
241
-
242
- def run!()
243
- # Check if git is installed
244
- if not InstallGIT.installed!
245
- # Install git
246
- CommandRunner.execute(
247
- command: Commands::Git::Install,
248
- error: nil
249
- )
250
- end
251
-
252
- # clone
253
- CommandRunner.execute(
254
- command: "git clone https://github.com/#{@username}/#{@remote}.git",
255
- error: nil
256
- )
257
- return true
258
- end
259
-
260
- def crash_on_error!()
261
- return false
262
- end
263
-
264
- def success_message!()
265
- if not @msg_success or @msg_success.empty?
266
- return "[Successfully pulled] #{@username}/#{@remote}"
267
- end
268
- return "#{@msg_success}"
269
- end
270
-
271
- def error_message!()
272
- if not @msg_error or @msg_error.empty?
273
- return "[Error] #{@username}/#{@remote}"
274
- end
275
- return "#{@msg_error}"
276
- end
277
- end
278
-
279
- class BashRun < I_Instructions
280
-
281
- def initialize(path, msg_success, msg_error, should_crash)
282
- @path = path
283
- @msg_success = msg_success
284
- @msg_error = msg_error
285
- @should_crash = should_crash
286
- end
287
-
288
- def run!()
289
- CommandRunner.execute(
290
- command: "bash #{@path}",
291
- error: nil
292
- )
293
- return true
294
- end
295
-
296
- def crash_on_error!()
297
- return false
298
- end
299
-
300
- def success_message!()
301
- if not @msg_success or @msg_success.empty?
302
- return "[Successfully Exec] #{@path}"
303
- end
304
- return "#{@msg_success}"
305
- end
306
-
307
- def error_message!()
308
- if not @msg_error or @msg_error.empty?
309
- return "[Error exec] #{@path}"
310
- end
311
- return "#{@msg_error}"
312
- end
313
- end
314
-
315
- class CDInst < I_Instructions
316
-
317
- def initialize(path, msg_success, msg_error, should_crash)
318
- @path = path
319
- @msg_success = msg_success
320
- @msg_error = msg_error
321
- @should_crash = should_crash
322
- end
323
-
324
- def run!()
325
- Dir.chdir "#{@path}"
326
- return true
327
- end
328
-
329
- def crash_on_error!()
330
- return false
331
- end
332
-
333
- def success_message!()
334
- if not @msg_success or @msg_success.empty?
335
- return "[Successfully moved to] #{@path}"
336
- end
337
- return "#{@msg_success}"
338
- end
339
-
340
- def error_message!()
341
- if not @msg_error or @msg_error.empty?
342
- return "[Error moving to] #{@path}"
343
- end
344
- return "#{@msg_error}"
345
- end
346
- end
347
75
 
348
- class InstructionParser
349
- class << self
350
- def parse(line)
351
- inst_elm = line.split
352
- cmd = inst_elm[0]
353
- case cmd
354
- when "pip"
355
- package = inst_elm[1]
356
- msg_success = inst_elm[2] if inst_elm[2]
357
- msg_error = inst_elm[3] if inst_elm[3]
358
- should_crash = inst_elm[4] == "true" if inst_elm[4]
359
- return PIPInstall.new(
360
- package,
361
- msg_success,
362
- msg_error,
363
- should_crash
364
- )
365
- when "git"
366
- subcmd = inst_elm[1]
367
- remote = inst_elm[2]
368
- branch = inst_elm[3] if inst_elm[3]
369
- case subcmd
370
- when "fork"
371
- puts "github username: "
372
- username = STDIN.gets.chomp
373
- password = STDIN.getpass("Password: ")
374
- return GITFork.new(
375
- remote,
376
- username,
377
- password,
378
- msg_success,
379
- msg_error,
380
- should_crash
381
- )
382
- when "pull"
383
- return GITPull.new(
384
- remote,
385
- branch,
386
- msg_success,
387
- msg_error,
388
- should_crash
389
- )
390
- when "clone"
391
- puts "github username: "
392
- username = STDIN.gets.chomp
393
- return GITClone.new(
394
- remote,
395
- username,
396
- msg_success,
397
- msg_error,
398
- should_crash
399
- )
400
- else
401
- end
402
- when "bash"
403
- subcmd = inst_elm[1]
404
- path = inst_elm[2]
405
- case subcmd
406
- when "run"
407
- return BashRun.new(
408
- path,
409
- msg_success,
410
- msg_error,
411
- should_crash
412
- )
413
- else
414
- end
415
- when "cd"
416
- path = inst_elm[1]
417
- return CDInst.new(
418
- path,
419
- msg_success,
420
- msg_error,
421
- should_crash
422
- )
423
- else
424
- puts "The command #{cmd} is not supported"
425
- end
76
+ def options(ops)
77
+ rows = []
78
+ c = 0
79
+ ops.each do |v|
80
+ rows << [v, c]
81
+ c = c + 1
426
82
  end
83
+ return Terminal::Table.new :rows => rows
427
84
  end
428
85
  end
429
86
  end