jump-starter 1.1.16

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 065d1051849f8f951ad9336f220d384e8a82dcb045e755ced81a22cf2d9cac29
4
+ data.tar.gz: 4f0e0ccb067010588592233b7a76627ccfe2fe78c73693d724fd005049daf83d
5
+ SHA512:
6
+ metadata.gz: b6cae6e59459ab6b494e74764a199d0eb562a31b6debfa9dc71866c94bbc727908adc8402484530cc7e94663ddd31224aa13d005df06ee957650b8f53c2eb2f8
7
+ data.tar.gz: a396c0d0aea2f7e8682093a2183e3f6e1820bd522dba7b59d1e91742c6c5da9898015e532c6745c300ffeac68d5ce11ba0e8d2bddaec3b4b3043c1d7e1504daa
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at easports96@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in maintainer.gemspec
6
+ gemspec
7
+
8
+ gem 'rake'
9
+ gem 'rspec'
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pkg-maintainer (1.1.15)
5
+ colorize
6
+ commander
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ colorize (0.8.1)
12
+ commander (4.4.6)
13
+ highline (~> 1.7.2)
14
+ diff-lcs (1.3)
15
+ highline (1.7.10)
16
+ rake (12.3.1)
17
+ rspec (3.8.0)
18
+ rspec-core (~> 3.8.0)
19
+ rspec-expectations (~> 3.8.0)
20
+ rspec-mocks (~> 3.8.0)
21
+ rspec-core (3.8.0)
22
+ rspec-support (~> 3.8.0)
23
+ rspec-expectations (3.8.2)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.8.0)
26
+ rspec-mocks (3.8.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.8.0)
29
+ rspec-support (3.8.0)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ pkg-maintainer!
36
+ rake
37
+ rspec
38
+
39
+ BUNDLED WITH
40
+ 1.16.6
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Ehud Adler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Ehud Adler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Jumpstarter
2
+
3
+ ## License
4
+
5
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
6
+
7
+ ## Code of Conduct
8
+
9
+ Everyone interacting in the Maintainer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/maintainer/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "maintainer"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/jumpstart ADDED
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'commander'
5
+ require 'maintainer'
6
+
7
+ module Maintainer
8
+ class Kernal
9
+ include Commander::Methods
10
+ # include whatever modules you need
11
+ def run
12
+ program :name, 'maintainer'
13
+ program :version, '0.0.1'
14
+ program :description, 'Helps maintain dependencies'
15
+
16
+ command :setup do |c|
17
+ c.syntax = 'maintainer setup [options]'
18
+ c.summary = ''
19
+ c.description = ''
20
+ c.example 'description', 'command example'
21
+ c.option '--some-switch', 'Some switch that does something'
22
+ c.action do |args, options|
23
+ Maintainer::Runner.setup
24
+ end
25
+ end
26
+
27
+ # command :install do |c|
28
+ # c.syntax = 'maintainer setup [options]'
29
+ # c.summary = ''
30
+ # c.description = ''
31
+ # c.example 'description', 'command example'
32
+ # c.option '--some-switch', 'Some switch that does something'
33
+ # c.action do |args, options|
34
+ # if args[0] == "cocoapods"
35
+ # Maintainer::Runner.install_cocoapods
36
+ # elsif args[0] == "git"
37
+ # Maintainer::Runner.install_git
38
+ # elsif args[0] == "pip"
39
+ # Maintainer::Runner.install_pip
40
+ # end
41
+ # end
42
+ # end
43
+
44
+ # command :uninstall do |c|
45
+ # c.syntax = 'maintainer setup [options]'
46
+ # c.summary = ''
47
+ # c.description = ''
48
+ # c.example 'description', 'command example'
49
+ # c.option '--some-switch', 'Some switch that does something'
50
+ # c.action do |args, options|
51
+ # if args[0] == "cocoapods"
52
+ # Maintainer::Runner.uninstall_cocoapods
53
+ # end
54
+ # end
55
+ # end
56
+
57
+ # command :pip do |c|
58
+ # c.syntax = 'maintainer pod [options]'
59
+ # c.summary = ''
60
+ # c.description = ''
61
+ # c.example 'description', 'command example'
62
+ # c.option '--some-switch', 'Some switch that does something'
63
+ # c.action do |args, options|
64
+ # Maintainer::Runner.pip(pkg: "#{args[0]}")
65
+ # end
66
+ # end
67
+
68
+ # command :pod do |c|
69
+ # c.syntax = 'maintainer pod [options]'
70
+ # c.summary = ''
71
+ # c.description = ''
72
+ # c.example 'description', 'command example'
73
+ # c.option '--some-switch', 'Some switch that does something'
74
+ # c.action do |args, options|
75
+ # Maintainer::Runner.pod(podname: "#{args[0]}")
76
+ # end
77
+ # end
78
+
79
+ # command :update do |c|
80
+ # c.syntax = 'maintainer pod [options]'
81
+ # c.summary = ''
82
+ # c.description = ''
83
+ # c.example 'description', 'command example'
84
+ # c.option '--some-switch', 'Some switch that does something'
85
+ # c.action do |args, options|
86
+ # if args[0] == "all"
87
+ # Maintainer::Runner.update_all!
88
+ # end
89
+ # end
90
+ # end
91
+
92
+ # command :help do |c|
93
+ # c.syntax = 'maintainer help [options]'
94
+ # c.summary = ''
95
+ # c.description = ''
96
+ # c.example 'description', 'command example'
97
+ # c.option '--some-switch', 'Some switch that does something'
98
+ # c.action do |args, options|
99
+ # # Do something or c.when_called Maintainer::Commands::Help
100
+ # end
101
+ # end
102
+ run!
103
+ end
104
+ end
105
+ end
106
+
107
+ Maintainer::Kernal.new.run
108
+
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,22 @@
1
+ require File.expand_path('../lib/jumpstarter_core/version', __FILE__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "jump-starter"
5
+ spec.version = Jumpstarter::VERSION
6
+ spec.authors = ["Ehud Adler"]
7
+ spec.email = ["adlerehud@gmail.com"]
8
+
9
+ spec.files = `git ls-files`.split($\)
10
+ spec.executables = ["jumpstart"]
11
+
12
+ spec.add_dependency 'commander'
13
+ spec.add_dependency 'colorize'
14
+
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.summary = %q{blah}
19
+ spec.description = %q{bla...etc}
20
+ spec.homepage = "http://www.ehudadler.com"
21
+ spec.license = "MIT"
22
+ end
@@ -0,0 +1,10 @@
1
+ require_relative './jumpstarter_core/setup'
2
+ module Jumpstarter
3
+ class Runner
4
+ class << self
5
+ def setup
6
+ Setup.setup!
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ module Jumpstarter
2
+ class OS
3
+ class << self
4
+
5
+ def unix?
6
+ !OS.isWindows?
7
+ end
8
+
9
+ def isLinix?
10
+ OS.unix? and not OS.isMac?
11
+ end
12
+
13
+ def isMac?
14
+ (/darwin/ =~ RUBY_PLATFORM) != nil
15
+ end
16
+
17
+ def isWindows?
18
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,127 @@
1
+ class StandardError
2
+ def exit_status
3
+ return -1
4
+ end
5
+ end
6
+
7
+ module Jumpstarter
8
+ class JumpstarterPtyError < StandardError
9
+ attr_reader :exit_status
10
+ def initialize(e, exit_status)
11
+ super(e)
12
+ set_backtrace(e.backtrace) if e
13
+ @exit_status = exit_status
14
+ end
15
+ end
16
+
17
+ class JumpstarterPty
18
+ def self.spawn(command)
19
+ require 'pty'
20
+ PTY.spawn(command) do |command_stdout, command_stdin, pid|
21
+ begin
22
+ yield(command_stdout, command_stdin, pid)
23
+ rescue Errno::EIO
24
+
25
+ ensure
26
+ begin
27
+ Process.wait(pid)
28
+ rescue Errno::ECHILD, PTY::ChildExited
29
+ # The process might have exited.
30
+ end
31
+ end
32
+ end
33
+ $?.exitstatus
34
+ rescue LoadError
35
+ require 'open3'
36
+ Open3.popen2e(command) do |command_stdin, command_stdout, p| # note the inversion
37
+ yield(command_stdout, command_stdin, p.value.pid)
38
+
39
+ command_stdin.close
40
+ command_stdout.close
41
+ p.value.exitstatus
42
+ end
43
+ rescue StandardError => e
44
+ puts "ERROR: #{e}"
45
+ raise JumpstarterPtyError.new(e, $?.exitstatus)
46
+ end
47
+ end
48
+
49
+ class CommandRunner
50
+
51
+ class << self
52
+
53
+ def execute_sudo(command: nil)
54
+ system("sudo #{command}")
55
+ end
56
+
57
+ def execute(command: nil, error:nil)
58
+ output = []
59
+ if command.is_a? String
60
+ output << _execute(command: command, error: error)
61
+ else
62
+ command.command!.each do |item|
63
+ output << _execute(command: item, error: error)
64
+ end
65
+ end
66
+ return output.join("\n")
67
+ end
68
+
69
+ def _execute(command: nil, error:nil)
70
+
71
+ print_all = true
72
+ prefix ||= {}
73
+
74
+ output = []
75
+
76
+ Writer.write(message: "#{command}")
77
+
78
+ begin
79
+ status = Jumpstarter::JumpstarterPty.spawn(command) do |command_stdout, command_stdin, pid|
80
+ command_stdout.each do |l|
81
+ line = l.strip # strip so that \n gets removed
82
+ output << line
83
+
84
+ next unless print_all
85
+
86
+ # Prefix the current line with a string
87
+ prefix.each do |element|
88
+ line = element[:prefix] + line if element[:block] && element[:block].call(line)
89
+ end
90
+ Writer.write(message: "#{line}")
91
+ end
92
+ end
93
+ rescue => ex
94
+ # FastlanePty adds exit_status on to StandardError so every error will have a status code
95
+ status = ex.exit_status
96
+
97
+ # This could happen when the environment is wrong:
98
+ # > invalid byte sequence in US-ASCII (ArgumentError)
99
+ output << ex.to_s
100
+ o = output.join("\n")
101
+ puts(o)
102
+ if error
103
+ error.call(o, nil)
104
+ else
105
+ raise ex
106
+ end
107
+ end
108
+
109
+ # Exit status for build command, should be 0 if build succeeded
110
+ if status != 0
111
+ o = output.join("\n")
112
+ puts(o)
113
+ Writer.write(message: ("Exit status: #{status}"))
114
+ if error
115
+ error.call(o, status)
116
+ else
117
+ Writer.write(message: ("Exit status: #{status}"))
118
+ end
119
+ end
120
+ return output.join("\n")
121
+ end
122
+ end
123
+ end
124
+ end
125
+
126
+
127
+
@@ -0,0 +1,160 @@
1
+ require_relative './OS'
2
+
3
+ module Jumpstarter
4
+ class Commands
5
+ class Pip
6
+ class Install
7
+ class << self
8
+ def requires_sudo!()
9
+ return true
10
+ end
11
+ def command!()
12
+ if OS.isLinix?
13
+ return ['apt install python3-pip']
14
+ elsif OS.isMac?
15
+ return ['brew install python', 'brew unlink python && brew link python']
16
+ elsif OS.isWindows?
17
+ puts "Windows is not currently supported"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ class Uninstall
23
+ class << self
24
+ def dependencies()
25
+
26
+ end
27
+ def requires_sudo!()
28
+ return true
29
+ end
30
+ def command!()
31
+ return ['gem uninstall cocoapods']
32
+ end
33
+ end
34
+ end
35
+ class Version
36
+ class << self
37
+ def requires_sudo!()
38
+ return false
39
+ end
40
+ def command!()
41
+ return ['pip3 --version']
42
+ end
43
+ end
44
+ end
45
+ class Update
46
+ class << self
47
+ def requires_sudo!()
48
+ return false
49
+ end
50
+ def command!()
51
+ return ['pip3 update']
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ class Cocoapods
58
+ class Install
59
+ class << self
60
+ def requires_sudo!()
61
+ return true
62
+ end
63
+ def command!()
64
+ return ['gem install cocoapods']
65
+ end
66
+ end
67
+ end
68
+ class Uninstall
69
+ class << self
70
+ def requires_sudo!()
71
+ return true
72
+ end
73
+ def command!()
74
+ return ['gem uninstall cocoapods']
75
+ end
76
+ end
77
+ end
78
+ class Version
79
+ class << self
80
+ def requires_sudo!()
81
+ return false
82
+ end
83
+ def command!()
84
+ return ['pod --version']
85
+ end
86
+ end
87
+ end
88
+ class Init
89
+ class << self
90
+ def requires_sudo!()
91
+ return false
92
+ end
93
+ def command!()
94
+ return ['pod init']
95
+ end
96
+ end
97
+ end
98
+ class Update
99
+ class << self
100
+ def requires_sudo!()
101
+ return false
102
+ end
103
+ def command!()
104
+ return ['pod update']
105
+ end
106
+ end
107
+ end
108
+ end
109
+
110
+ class Git
111
+ class Install
112
+ class << self
113
+ def requires_sudo!()
114
+ return true
115
+ end
116
+ def command!()
117
+ if OS.isLinix?
118
+ return ['sudo apt update', 'sudo apt install git']
119
+ elsif OS.isMac?
120
+ return ['git --version']
121
+ elsif OS.isWindows?
122
+ puts "Windows is not currently supported"
123
+ end
124
+ end
125
+ end
126
+ end
127
+ class Version
128
+ class << self
129
+ def requires_sudo!()
130
+ return false
131
+ end
132
+ def command!()
133
+ return ['git --version']
134
+ end
135
+ end
136
+ end
137
+ class Init
138
+ class << self
139
+ def requires_sudo!()
140
+ return false
141
+ end
142
+ def command!()
143
+ return ['git init']
144
+ end
145
+ end
146
+ end
147
+ class Update
148
+ class << self
149
+ def requires_sudo!()
150
+ return false
151
+ end
152
+ def command!()
153
+ return ['sudo apt install git']
154
+ end
155
+ end
156
+ end
157
+ end
158
+
159
+ end
160
+ end
@@ -0,0 +1,429 @@
1
+ require_relative './commandRunner'
2
+ require_relative './commands'
3
+ require 'io/console'
4
+
5
+ module Jumpstarter
6
+
7
+ 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]"
33
+ 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
+ end
47
+
48
+ 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
+ return true
63
+ end
64
+
65
+ def crash_on_error!()
66
+ return false
67
+ end
68
+
69
+ def success_message!()
70
+ if not @msg_success or @msg_success.empty?
71
+ return "[Installed] #{@package}"
72
+ end
73
+ return "#{@msg_success}"
74
+ end
75
+
76
+ def error_message!()
77
+ 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
+ )
156
+ 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
164
+ end
165
+
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}"
173
+ end
174
+ return "#{@msg_success}"
175
+ end
176
+
177
+ def error_message!()
178
+ if not @msg_error or @msg_error.empty?
179
+ return "[Error] #{@remote}"
180
+ end
181
+ return "#{@msg_error}"
182
+ 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
+
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
426
+ end
427
+ end
428
+ end
429
+ end
@@ -0,0 +1,47 @@
1
+ require_relative './instructions'
2
+
3
+ module Jumpstarter
4
+ class Setup
5
+ class << self
6
+
7
+ FILE = 'Setup'
8
+
9
+ def setup!()
10
+ ## Find path to maintainfile
11
+ path = Dir.glob("./**/#{FILE}")
12
+ if path.length == 1
13
+ puts "Found Setup file at #{path[0]}"
14
+ proccess_file(path[0])
15
+ end
16
+ end
17
+
18
+ def parse_into_inst(line)
19
+ return Jumpstarter::InstructionParser.parse(line)
20
+ end
21
+
22
+ def process_instruction(inst)
23
+ puts "[Next Instruction]"
24
+ result = inst.run!
25
+ return result
26
+ end
27
+ def proccess_file(path)
28
+ File.open(path, "r") do |f|
29
+ f.each_line do |line|
30
+ inst = parse_into_inst(line)
31
+ result = process_instruction(inst)
32
+ if result
33
+ # Success
34
+ puts "#{inst.success_message!}"
35
+ else
36
+ # Error
37
+ puts "#{inst.error_message!}"
38
+ if inst.crash_on_error!
39
+ # CRASH
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module Jumpstarter
2
+ VERSION = "1.1.16"
3
+ end
@@ -0,0 +1,35 @@
1
+ require 'colorize'
2
+
3
+ module Jumpstarter
4
+ class Writer
5
+ class << self
6
+ def welcome!()
7
+ print "\nHi there!".green
8
+ puts " Welcome to Jumpstarter 🤘\n"
9
+ puts "\nUnsure what this is? Read below!"
10
+ end
11
+ def setup_guide!()
12
+ puts "Starting setup guide...\n".green
13
+ end
14
+ def newline!()
15
+ puts"\n"
16
+ end
17
+ def show_success(message: nil)
18
+ puts "#{message}".green
19
+ end
20
+ def show_error(message: nil)
21
+ puts "#{message}".red
22
+ end
23
+ def write(message: nil)
24
+ puts message
25
+ end
26
+ def file_replace(filepath, regexp, *args, &block)
27
+ content = File.read(filepath).gsub(regexp, *args, &block)
28
+ File.open(filepath, 'wb') { |file| file.write(content) }
29
+ end
30
+ def file_write(filepath, text)
31
+ filepath.puts "#{text}"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,9 @@
1
+ RSpec.describe Jumpstarter do
2
+ it "has a version number" do
3
+ expect(Jumpstarter::VERSION).not_to be nil
4
+ end
5
+
6
+ it "does something useful" do
7
+ expect(false).to eq(true)
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ require "bundler/setup"
2
+ require "jumpstarter"
3
+
4
+ RSpec.configure do |config|
5
+ # Enable flags like --only-failures and --next-failure
6
+ config.example_status_persistence_file_path = ".rspec_status"
7
+
8
+ # Disable RSpec exposing methods globally on `Module` and `main`
9
+ config.disable_monkey_patching!
10
+
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jump-starter
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.16
5
+ platform: ruby
6
+ authors:
7
+ - Ehud Adler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: commander
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colorize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: bla...etc
42
+ email:
43
+ - adlerehud@gmail.com
44
+ executables:
45
+ - jumpstart
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/console
58
+ - bin/jumpstart
59
+ - bin/setup
60
+ - jumpstarter.gemspec
61
+ - lib/jumpstarter.rb
62
+ - lib/jumpstarter_core/OS.rb
63
+ - lib/jumpstarter_core/commandRunner.rb
64
+ - lib/jumpstarter_core/commands.rb
65
+ - lib/jumpstarter_core/instructions.rb
66
+ - lib/jumpstarter_core/setup.rb
67
+ - lib/jumpstarter_core/version.rb
68
+ - lib/jumpstarter_core/writer.rb
69
+ - spec/jumpstarter_spec.rb
70
+ - spec/spec_helper.rb
71
+ homepage: http://www.ehudadler.com
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubygems_version: 3.0.2
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: blah
94
+ test_files:
95
+ - spec/jumpstarter_spec.rb
96
+ - spec/spec_helper.rb