pkg-maintainer 1.1.15 → 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 +4 -4
- data/bin/maintain +70 -70
- data/lib/maintainer.rb +4 -1
- data/lib/maintainer_core/commandRunner.rb +4 -2
- data/lib/maintainer_core/commands.rb +10 -2
- data/lib/maintainer_core/dependencies.rb +0 -0
- data/lib/maintainer_core/gitRunner.rb +0 -1
- data/lib/maintainer_core/init.rb +30 -0
- data/lib/maintainer_core/instructions.rb +429 -0
- data/lib/maintainer_core/setup.rb +33 -16
- data/lib/maintainer_core/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13e57c1967681981cfaf5045e8cf2d2c6725b66bbfb6356eb855e12cc0120d17
|
|
4
|
+
data.tar.gz: f587028a7d76ae19d0b3ead851cccb7f9c00fc5bb8d619942bd49df8df935552
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 396c0a5df3478d3e0d9f50cb6f26ae76e0fce748bcdc761259135e991161bcc21838109720e1900cba102e2df9ea9f5621f0e1e5fd97aa2cbd7bdbecb4403df3
|
|
7
|
+
data.tar.gz: a24f739d672d26914f3adfaeab856dfffa18075e689af5baaf94aacd0fabec8c94851333196f26c77832c1ab52f3d214f0a36a713ae282f9545288528fb8e109
|
data/bin/maintain
CHANGED
|
@@ -24,81 +24,81 @@ module Maintainer
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
command :install do |c|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
end
|
|
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
43
|
|
|
44
|
-
command :uninstall do |c|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
end
|
|
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
56
|
|
|
57
|
-
command :pip do |c|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
end
|
|
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
67
|
|
|
68
|
-
command :pod do |c|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
end
|
|
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
78
|
|
|
79
|
-
command :update do |c|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
end
|
|
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
91
|
|
|
92
|
-
command :help do |c|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
end
|
|
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
102
|
run!
|
|
103
103
|
end
|
|
104
104
|
end
|
data/lib/maintainer.rb
CHANGED
|
@@ -9,9 +9,12 @@ module Maintainer
|
|
|
9
9
|
class Runner
|
|
10
10
|
class << self
|
|
11
11
|
def setup
|
|
12
|
-
Writer.welcome!
|
|
13
12
|
Setup.setup!
|
|
14
13
|
end
|
|
14
|
+
def init
|
|
15
|
+
Writer.welcome!
|
|
16
|
+
#Setup.setup!
|
|
17
|
+
end
|
|
15
18
|
def pod(podname: nil)
|
|
16
19
|
Writer.write(message: "Adding the pod: #{podname}")
|
|
17
20
|
CocoapodRunner.add_pod(pod: podname)
|
|
@@ -55,13 +55,15 @@ module Maintainer
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def execute(command: nil, error:nil)
|
|
58
|
+
output = []
|
|
58
59
|
if command.is_a? String
|
|
59
|
-
_execute(command: command, error: error)
|
|
60
|
+
output << _execute(command: command, error: error)
|
|
60
61
|
else
|
|
61
62
|
command.command!.each do |item|
|
|
62
|
-
_execute(command: item, error: error)
|
|
63
|
+
output << _execute(command: item, error: error)
|
|
63
64
|
end
|
|
64
65
|
end
|
|
66
|
+
return output.join("\n")
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
def _execute(command: nil, error:nil)
|
|
@@ -3,7 +3,6 @@ require_relative './OS'
|
|
|
3
3
|
|
|
4
4
|
module Maintainer
|
|
5
5
|
class Commands
|
|
6
|
-
|
|
7
6
|
class Pip
|
|
8
7
|
class Install
|
|
9
8
|
class << self
|
|
@@ -23,6 +22,9 @@ module Maintainer
|
|
|
23
22
|
end
|
|
24
23
|
class Uninstall
|
|
25
24
|
class << self
|
|
25
|
+
def dependencies()
|
|
26
|
+
|
|
27
|
+
end
|
|
26
28
|
def requires_sudo!()
|
|
27
29
|
return true
|
|
28
30
|
end
|
|
@@ -113,7 +115,13 @@ module Maintainer
|
|
|
113
115
|
return true
|
|
114
116
|
end
|
|
115
117
|
def command!()
|
|
116
|
-
|
|
118
|
+
if OS.isLinix?
|
|
119
|
+
return ['sudo apt update', 'sudo apt install git']
|
|
120
|
+
elsif OS.isMac?
|
|
121
|
+
return ['git --version']
|
|
122
|
+
elsif OS.isWindows?
|
|
123
|
+
puts "Windows is not currently supported"
|
|
124
|
+
end
|
|
117
125
|
end
|
|
118
126
|
end
|
|
119
127
|
end
|
|
File without changes
|
|
@@ -6,7 +6,6 @@ module Maintainer
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def install_git!()
|
|
9
|
-
Writer.write(message: "Setting up git..\n This will require sudo access. Sudo access means .... but don't worry, you'll be entering it directly into your machine, I can't see what you type.")
|
|
10
9
|
CommandRunner.execute(command: Commands::Git::Install, error: nil)
|
|
11
10
|
end
|
|
12
11
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Maintainer
|
|
2
|
+
class Init
|
|
3
|
+
class << self
|
|
4
|
+
|
|
5
|
+
MAINTAIN_FOLDER = 'maintain'
|
|
6
|
+
MAINTAIN_FILE = 'Maintainfile'
|
|
7
|
+
|
|
8
|
+
def setup!()
|
|
9
|
+
self.create_folder!
|
|
10
|
+
self.create_maintainfile!
|
|
11
|
+
end
|
|
12
|
+
def create_folder!(path = nil)
|
|
13
|
+
maintainfolder_path = File.join(path || '.', MAINTAIN_FOLDER)
|
|
14
|
+
|
|
15
|
+
# Sanity check
|
|
16
|
+
return if File.directory?(maintainfolder_path)
|
|
17
|
+
|
|
18
|
+
Writer.write(message: "\n\nYou already have a maintain folder...skipping creation") if File.exist?(maintainfolder_path)
|
|
19
|
+
FileUtils.mkdir_p(maintainfolder_path)
|
|
20
|
+
Writer.write(message: "\nCreated new folder '#{maintainfolder_path}'.")
|
|
21
|
+
end
|
|
22
|
+
def create_maintainfile!(path = nil)
|
|
23
|
+
Writer.write(message: "Creating Maintainfile...")
|
|
24
|
+
FileUtils.cd "./#{MAINTAIN_FOLDER}"
|
|
25
|
+
FileUtils.touch "#{MAINTAIN_FILE}"
|
|
26
|
+
Writer.write(message: "Maintainfile Created")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
require_relative './commandRunner'
|
|
2
|
+
require_relative './commands'
|
|
3
|
+
require 'io/console'
|
|
4
|
+
|
|
5
|
+
module Maintainer
|
|
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
|
|
@@ -1,29 +1,46 @@
|
|
|
1
|
+
require_relative './instructions'
|
|
2
|
+
|
|
1
3
|
module Maintainer
|
|
2
4
|
class Setup
|
|
3
5
|
class << self
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
MAINTAIN_FILE = 'Maintainfile'
|
|
7
|
+
FILE = 'Setup'
|
|
7
8
|
|
|
8
9
|
def setup!()
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
11
16
|
end
|
|
12
|
-
def create_folder!(path = nil)
|
|
13
|
-
maintainfolder_path = File.join(path || '.', MAINTAIN_FOLDER)
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
return
|
|
18
|
+
def parse_into_inst(line)
|
|
19
|
+
return Maintainer::InstructionParser.parse(line)
|
|
20
|
+
end
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
def process_instruction(inst)
|
|
23
|
+
puts "[Next Instruction]"
|
|
24
|
+
result = inst.run!
|
|
25
|
+
return result
|
|
21
26
|
end
|
|
22
|
-
def
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
27
44
|
end
|
|
28
45
|
end
|
|
29
46
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pkg-maintainer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ehud Adler
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-01-
|
|
11
|
+
date: 2019-01-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: commander
|
|
@@ -63,7 +63,10 @@ files:
|
|
|
63
63
|
- lib/maintainer_core/cocoapodRunner.rb
|
|
64
64
|
- lib/maintainer_core/commandRunner.rb
|
|
65
65
|
- lib/maintainer_core/commands.rb
|
|
66
|
+
- lib/maintainer_core/dependencies.rb
|
|
66
67
|
- lib/maintainer_core/gitRunner.rb
|
|
68
|
+
- lib/maintainer_core/init.rb
|
|
69
|
+
- lib/maintainer_core/instructions.rb
|
|
67
70
|
- lib/maintainer_core/maintainFileUpdater.rb
|
|
68
71
|
- lib/maintainer_core/pipRunner.rb
|
|
69
72
|
- lib/maintainer_core/setup.rb
|
|
@@ -92,8 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
92
95
|
- !ruby/object:Gem::Version
|
|
93
96
|
version: '0'
|
|
94
97
|
requirements: []
|
|
95
|
-
|
|
96
|
-
rubygems_version: 2.7.6
|
|
98
|
+
rubygems_version: 3.0.2
|
|
97
99
|
signing_key:
|
|
98
100
|
specification_version: 4
|
|
99
101
|
summary: blah
|