homesteading 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -3
- data/bin/homesteading +37 -20
- data/lib/homesteading/command.rb +19 -0
- data/lib/homesteading/commands/apps.rb +242 -242
- data/lib/homesteading/commands/help.rb +26 -25
- data/lib/homesteading/commands/init.rb +29 -29
- data/lib/homesteading/commands/new.rb +100 -99
- data/lib/homesteading/commands/run.rb +36 -35
- data/lib/homesteading/commands/server.rb +98 -97
- data/lib/homesteading/commands/update.rb +55 -56
- data/lib/homesteading/commands/version.rb +7 -8
- data/lib/homesteading/version.rb +2 -2
- metadata +3 -4
- data/lib/homesteading/commands/h.rb +0 -13
- data/lib/homesteading/commands/s.rb +0 -17
@@ -1,105 +1,87 @@
|
|
1
|
-
|
2
|
-
class Apps
|
3
|
-
class << self
|
1
|
+
require "homesteading/command"
|
4
2
|
|
5
|
-
|
6
|
-
|
3
|
+
module Homesteading
|
4
|
+
class Apps < Command
|
5
|
+
register "apps"
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
nonpublisher_apps = []
|
7
|
+
def default
|
8
|
+
puts
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
constellation_path = Dir.pwd
|
11
|
+
publisher_apps = []
|
12
|
+
nonpublisher_apps = []
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
app_keywords = app_file["keywords"]
|
20
|
-
end
|
14
|
+
Dir.glob("#{Dir.pwd}/homesteading-*/").each do |directory|
|
15
|
+
app = directory.split("/").last.sub(/homesteading-/, "").downcase
|
16
|
+
app_file_path = directory + "app.json"
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
18
|
+
app_keywords = []
|
19
|
+
if File.exist?(app_file_path)
|
20
|
+
app_file = JSON.parse(File.read(app_file_path))
|
21
|
+
app_keywords = app_file["keywords"]
|
27
22
|
end
|
28
23
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
puts
|
24
|
+
if app_keywords.include?("hs:publisher")
|
25
|
+
publisher_apps << app
|
26
|
+
else
|
27
|
+
nonpublisher_apps << app
|
35
28
|
end
|
29
|
+
end
|
36
30
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
31
|
+
unless publisher_apps.empty?
|
32
|
+
puts "* Publisher Apps"
|
33
|
+
publisher_apps.each do |app|
|
34
|
+
puts " #{app}"
|
42
35
|
end
|
43
|
-
|
44
36
|
puts
|
45
37
|
end
|
46
38
|
|
47
|
-
|
48
|
-
puts
|
49
|
-
|
50
|
-
|
51
|
-
if options[:app].nil? && options[:app].nil?
|
52
|
-
puts "* This requires an '--app' or '--url'"
|
53
|
-
puts "* Example:"
|
54
|
-
puts " homesteading apps:create --app note"
|
55
|
-
puts " homesteading apps:create --url git@github.com:homesteading/homesteading-note.git"
|
56
|
-
puts
|
57
|
-
exit
|
39
|
+
unless nonpublisher_apps.empty?
|
40
|
+
puts "* Non-Publisher Apps"
|
41
|
+
nonpublisher_apps.each do |app|
|
42
|
+
puts " #{app}"
|
58
43
|
end
|
44
|
+
end
|
59
45
|
|
60
|
-
|
61
|
-
|
62
|
-
else
|
63
|
-
options[:url]
|
64
|
-
end
|
46
|
+
puts
|
47
|
+
end
|
65
48
|
|
66
|
-
|
49
|
+
def create
|
50
|
+
puts
|
51
|
+
options = parse_options
|
67
52
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
puts "* #{app_dir} already exists"
|
77
|
-
puts "* Removing homesteading-#{options[:app]}"
|
78
|
-
end
|
53
|
+
if options[:app].nil? && options[:app].nil?
|
54
|
+
puts "* This requires an '--app' or '--url'"
|
55
|
+
puts "* Example:"
|
56
|
+
puts " homesteading apps:create --app note"
|
57
|
+
puts " homesteading apps:create --url git@github.com:homesteading/homesteading-note.git"
|
58
|
+
puts
|
59
|
+
exit
|
60
|
+
end
|
79
61
|
|
80
|
-
|
81
|
-
|
82
|
-
|
62
|
+
git_url = if options[:app]
|
63
|
+
"git@github.com:homesteading/homesteading-#{options[:app]}.git"
|
64
|
+
else
|
65
|
+
options[:url]
|
66
|
+
end
|
83
67
|
|
84
|
-
|
85
|
-
if options[:app]
|
86
|
-
puts "* Cloning homesteading app from GitHub: #{options[:app]}"
|
87
|
-
else
|
88
|
-
puts "* Cloning from: #{options[:url]}"
|
89
|
-
end
|
90
|
-
end
|
68
|
+
app_dir = git_url.split("/").last.split(".git").first
|
91
69
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
70
|
+
if File.exist?(app_dir)
|
71
|
+
if options[:skip]
|
72
|
+
unless options[:quiet]
|
73
|
+
puts "* #{app_dir} already exists"
|
74
|
+
puts "* Skipping homesteading-#{options[:app]}"
|
75
|
+
end
|
76
|
+
elsif options[:force]
|
77
|
+
unless options[:quiet]
|
78
|
+
puts "* #{app_dir} already exists"
|
79
|
+
puts "* Removing homesteading-#{options[:app]}"
|
100
80
|
end
|
101
81
|
|
102
|
-
|
82
|
+
unless options[:pretend]
|
83
|
+
FileUtils.rm_rf app_dir
|
84
|
+
end
|
103
85
|
|
104
86
|
unless options[:quiet]
|
105
87
|
if options[:app]
|
@@ -112,227 +94,245 @@ class Homesteading
|
|
112
94
|
unless options[:pretend]
|
113
95
|
system "git clone #{git_url}"
|
114
96
|
end
|
97
|
+
else
|
98
|
+
unless options[:quiet]
|
99
|
+
puts "* #{app_dir} already exists"
|
100
|
+
puts "* TODO gets user input on what to do about the conflict"
|
101
|
+
end
|
115
102
|
end
|
116
103
|
|
117
|
-
|
118
|
-
end
|
104
|
+
else
|
119
105
|
|
120
|
-
|
121
|
-
|
122
|
-
|
106
|
+
unless options[:quiet]
|
107
|
+
if options[:app]
|
108
|
+
puts "* Cloning homesteading app from GitHub: #{options[:app]}"
|
109
|
+
else
|
110
|
+
puts "* Cloning from: #{options[:url]}"
|
111
|
+
end
|
112
|
+
end
|
123
113
|
|
124
|
-
|
125
|
-
|
126
|
-
puts
|
127
|
-
exit
|
114
|
+
unless options[:pretend]
|
115
|
+
system "git clone #{git_url}"
|
128
116
|
end
|
117
|
+
end
|
129
118
|
|
130
|
-
|
131
|
-
|
132
|
-
app_dir = "#{constellation_path}/homesteading-#{app}"
|
119
|
+
puts
|
120
|
+
end
|
133
121
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
122
|
+
def destroy
|
123
|
+
puts
|
124
|
+
options = parse_options
|
125
|
+
|
126
|
+
if options[:app].nil?
|
127
|
+
puts "* '--app APP' is required for this command"
|
128
|
+
puts
|
129
|
+
exit
|
130
|
+
end
|
131
|
+
|
132
|
+
app = options[:app].downcase
|
133
|
+
constellation_path = Dir.pwd
|
134
|
+
app_dir = "#{constellation_path}/homesteading-#{app}"
|
135
|
+
|
136
|
+
unless File.exist?(app_dir)
|
137
|
+
puts "* #{app} does not exist"
|
138
|
+
puts "* Did you mean one of these?"
|
139
|
+
Dir.glob("#{Dir.pwd}/homesteading-*/").each do |ff|
|
140
|
+
puts " - #{ff.split("/").last.sub(/homesteading-/, "")}"
|
142
141
|
end
|
142
|
+
puts
|
143
|
+
exit
|
144
|
+
end
|
143
145
|
|
144
|
-
|
146
|
+
if options[:confirm] == app || options[:confirm] == "homesteading-#{app}"
|
147
|
+
puts "* Destroying #{app} permananently..."
|
148
|
+
FileUtils.rm_rf app_dir
|
149
|
+
puts "* ...done"
|
150
|
+
else
|
151
|
+
puts "! WARNING: Potentially Destructive Action"
|
152
|
+
puts "! This command will destroy #{app}"
|
153
|
+
puts "! To proceed, type '#{app}' or re-run this command with '--confirm #{app}'"
|
154
|
+
puts
|
155
|
+
confirmation_input = gets.chomp
|
156
|
+
puts
|
157
|
+
|
158
|
+
if confirmation_input == app
|
145
159
|
puts "* Destroying #{app} permananently..."
|
146
160
|
FileUtils.rm_rf app_dir
|
147
161
|
puts "* ...done"
|
148
162
|
else
|
149
|
-
puts "!
|
150
|
-
puts "! This command will destroy #{app}"
|
151
|
-
puts "! To proceed, type '#{app}' or re-run this command with '--confirm #{app}'"
|
152
|
-
puts
|
153
|
-
confirmation_input = gets.chomp
|
154
|
-
puts
|
155
|
-
|
156
|
-
if confirmation_input == app
|
157
|
-
puts "* Destroying #{app} permananently..."
|
158
|
-
FileUtils.rm_rf app_dir
|
159
|
-
puts "* ...done"
|
160
|
-
else
|
161
|
-
puts "! Confirmation did not match #{app}. Aborted."
|
162
|
-
end
|
163
|
+
puts "! Confirmation did not match #{app}. Aborted."
|
163
164
|
end
|
165
|
+
end
|
166
|
+
|
167
|
+
puts
|
168
|
+
end
|
164
169
|
|
170
|
+
def info
|
171
|
+
puts
|
172
|
+
options = parse_options
|
173
|
+
|
174
|
+
if options[:app].nil?
|
175
|
+
puts "* '--app APP' is required for this command"
|
165
176
|
puts
|
177
|
+
exit
|
166
178
|
end
|
167
179
|
|
168
|
-
|
169
|
-
|
170
|
-
|
180
|
+
app = options[:app].downcase
|
181
|
+
constellation_path = Dir.pwd
|
182
|
+
app_dir = "#{constellation_path}/homesteading-#{app}/"
|
183
|
+
app_file_path = app_dir + "app.json"
|
171
184
|
|
172
|
-
|
173
|
-
|
185
|
+
if File.exist?(app_dir)
|
186
|
+
if File.exist?(app_file_path)
|
187
|
+
app_file = JSON.parse(File.read(app_file_path))
|
188
|
+
puts app_file.to_yaml
|
189
|
+
else
|
190
|
+
puts "* No app.json found for #{app}"
|
174
191
|
puts
|
175
192
|
exit
|
176
193
|
end
|
194
|
+
else
|
195
|
+
puts "* #{app} does not exist"
|
196
|
+
puts "* Did you mean one of these?"
|
197
|
+
Dir.glob("#{Dir.pwd}/homesteading-*/").each do |ff|
|
198
|
+
puts " - #{ff.split("/").last.sub(/homesteading-/, "")}"
|
199
|
+
end
|
200
|
+
puts
|
201
|
+
exit
|
202
|
+
end
|
177
203
|
|
178
|
-
|
179
|
-
|
180
|
-
app_dir = "#{constellation_path}/homesteading-#{app}/"
|
181
|
-
app_file_path = app_dir + "app.json"
|
204
|
+
puts
|
205
|
+
end
|
182
206
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
puts app_file.to_yaml
|
187
|
-
else
|
188
|
-
puts "* No app.json found for #{app}"
|
189
|
-
puts
|
190
|
-
exit
|
191
|
-
end
|
192
|
-
else
|
193
|
-
puts "* #{app} does not exist"
|
194
|
-
puts "* Did you mean one of these?"
|
195
|
-
Dir.glob("#{Dir.pwd}/homesteading-*/").each do |ff|
|
196
|
-
puts " - #{ff.split("/").last.sub(/homesteading-/, "")}"
|
197
|
-
end
|
198
|
-
puts
|
199
|
-
exit
|
200
|
-
end
|
207
|
+
def rename
|
208
|
+
puts
|
209
|
+
options = parse_options
|
201
210
|
|
211
|
+
if options[:app].nil?
|
212
|
+
puts "* '--app APP' is required for this command"
|
202
213
|
puts
|
214
|
+
exit
|
203
215
|
end
|
204
216
|
|
205
|
-
|
217
|
+
new_name = ARGV.shift
|
218
|
+
if new_name.nil?
|
219
|
+
puts "* New app name is required for this command"
|
220
|
+
puts "* Example:"
|
221
|
+
puts " homesteading apps:rename status --app note"
|
206
222
|
puts
|
207
|
-
|
223
|
+
exit
|
224
|
+
end
|
208
225
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
226
|
+
app = options[:app].downcase
|
227
|
+
constellation_path = Dir.pwd
|
228
|
+
app_dir = "#{constellation_path}/homesteading-#{app}"
|
229
|
+
new_app_dir = "#{constellation_path}/homesteading-#{new_name}"
|
230
|
+
|
231
|
+
if File.exist?(app_dir)
|
232
|
+
puts "* Renaming #{app} to #{new_name}..."
|
233
|
+
FileUtils.mv app_dir, new_app_dir
|
234
|
+
puts "* ...done"
|
235
|
+
else
|
236
|
+
puts "* #{app} does not exist"
|
237
|
+
puts "* Did you mean one of these?"
|
238
|
+
Dir.glob("#{Dir.pwd}/homesteading-*/").each do |ff|
|
239
|
+
puts " - #{ff.split("/").last.sub(/homesteading-/, "")}"
|
213
240
|
end
|
241
|
+
puts
|
242
|
+
exit
|
243
|
+
end
|
214
244
|
|
215
|
-
|
216
|
-
|
217
|
-
puts "* New app name is required for this command"
|
218
|
-
puts "* Example:"
|
219
|
-
puts " homesteading apps:rename status --app note"
|
220
|
-
puts
|
221
|
-
exit
|
222
|
-
end
|
245
|
+
puts
|
246
|
+
end
|
223
247
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
new_app_dir = "#{constellation_path}/homesteading-#{new_name}"
|
228
|
-
|
229
|
-
if File.exist?(app_dir)
|
230
|
-
puts "* Renaming #{app} to #{new_name}..."
|
231
|
-
FileUtils.mv app_dir, new_app_dir
|
232
|
-
puts "* ...done"
|
233
|
-
else
|
234
|
-
puts "* #{app} does not exist"
|
235
|
-
puts "* Did you mean one of these?"
|
236
|
-
Dir.glob("#{Dir.pwd}/homesteading-*/").each do |ff|
|
237
|
-
puts " - #{ff.split("/").last.sub(/homesteading-/, "")}"
|
238
|
-
end
|
239
|
-
puts
|
240
|
-
exit
|
241
|
-
end
|
248
|
+
def reroute
|
249
|
+
puts
|
250
|
+
options = parse_options
|
242
251
|
|
252
|
+
if options[:app].nil?
|
253
|
+
puts "* '--app APP' is required for this command"
|
243
254
|
puts
|
255
|
+
exit
|
244
256
|
end
|
245
257
|
|
246
|
-
|
258
|
+
new_route = ARGV.shift
|
259
|
+
if new_route.nil?
|
260
|
+
puts "* New app route is required for this command"
|
261
|
+
puts "* Example:"
|
262
|
+
puts " homesteading apps:reroute statuses --app note"
|
247
263
|
puts
|
248
|
-
|
249
|
-
|
250
|
-
if options[:app].nil?
|
251
|
-
puts "* '--app APP' is required for this command"
|
252
|
-
puts
|
253
|
-
exit
|
254
|
-
end
|
255
|
-
|
256
|
-
new_route = ARGV.shift
|
257
|
-
if new_route.nil?
|
258
|
-
puts "* New app route is required for this command"
|
259
|
-
puts "* Example:"
|
260
|
-
puts " homesteading apps:reroute statuses --app note"
|
261
|
-
puts
|
262
|
-
exit
|
263
|
-
end
|
264
|
+
exit
|
265
|
+
end
|
264
266
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
267
|
+
app = options[:app].downcase
|
268
|
+
constellation_path = Dir.pwd
|
269
|
+
app_dir = "#{constellation_path}/homesteading-#{app}/"
|
270
|
+
app_file_path = app_dir + "app.json"
|
269
271
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
272
|
+
if File.exist?(app_dir)
|
273
|
+
if File.exist?(app_file_path)
|
274
|
+
app_file = JSON.parse(File.read(app_file_path))
|
275
|
+
app_file["routes"]["path"] = new_route
|
274
276
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
else
|
280
|
-
puts "* No app.json found for #{app}"
|
281
|
-
puts
|
282
|
-
exit
|
283
|
-
end
|
277
|
+
puts "* Rerouting note to /statuses..."
|
278
|
+
new_app_file = JSON.pretty_generate(app_file)
|
279
|
+
File.write(app_file_path, new_app_file)
|
280
|
+
puts "* ...done"
|
284
281
|
else
|
285
|
-
puts "* #{app}
|
286
|
-
puts "* Did you mean one of these?"
|
287
|
-
Dir.glob("#{Dir.pwd}/homesteading-*/").each do |ff|
|
288
|
-
puts " - #{ff.split("/").last.sub(/homesteading-/, "")}"
|
289
|
-
end
|
282
|
+
puts "* No app.json found for #{app}"
|
290
283
|
puts
|
291
284
|
exit
|
292
285
|
end
|
293
|
-
|
286
|
+
else
|
287
|
+
puts "* #{app} does not exist"
|
288
|
+
puts "* Did you mean one of these?"
|
289
|
+
Dir.glob("#{Dir.pwd}/homesteading-*/").each do |ff|
|
290
|
+
puts " - #{ff.split("/").last.sub(/homesteading-/, "")}"
|
291
|
+
end
|
294
292
|
puts
|
293
|
+
exit
|
295
294
|
end
|
296
295
|
|
297
|
-
|
298
|
-
|
299
|
-
# Parse command line options
|
300
|
-
options = {}
|
296
|
+
puts
|
297
|
+
end
|
301
298
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
299
|
+
private
|
300
|
+
def parse_options
|
301
|
+
# Parse command line options
|
302
|
+
options = {}
|
306
303
|
|
307
|
-
|
308
|
-
|
309
|
-
|
304
|
+
optparse = OptionParser.new do |opts|
|
305
|
+
opts.on("-a", "--app APP", "Name of Homesteading app on GitHub") do |app|
|
306
|
+
options[:app] = app
|
307
|
+
end
|
310
308
|
|
311
|
-
|
312
|
-
|
313
|
-
|
309
|
+
opts.on("-c", "--confirm CONFIRM", "Confirm the app name to delete") do |confirm|
|
310
|
+
options[:confirm] = confirm
|
311
|
+
end
|
314
312
|
|
315
|
-
|
316
|
-
|
317
|
-
|
313
|
+
opts.on("-f", "--force", "Overwrite apps that already exist") do |force|
|
314
|
+
options[:force] = force
|
315
|
+
end
|
318
316
|
|
319
|
-
|
320
|
-
|
321
|
-
|
317
|
+
opts.on("-p", "--pretend", "Run but do not make any changes") do |pretend|
|
318
|
+
options[:pretend] = pretend
|
319
|
+
end
|
322
320
|
|
323
|
-
|
324
|
-
|
325
|
-
|
321
|
+
opts.on("-q", "--quiet", "Suppress status output") do |quiet|
|
322
|
+
options[:quiet] = quiet
|
323
|
+
end
|
326
324
|
|
327
|
-
|
328
|
-
|
329
|
-
end
|
325
|
+
opts.on("-s", "--skip", "Skip apps that already exist") do |skip|
|
326
|
+
options[:skip] = skip
|
330
327
|
end
|
331
328
|
|
332
|
-
|
333
|
-
|
329
|
+
opts.on("-u", "--url URL", "URL of Homesteading app") do |url|
|
330
|
+
options[:url] = url
|
331
|
+
end
|
334
332
|
end
|
335
333
|
|
334
|
+
optparse.parse!
|
335
|
+
options
|
336
336
|
end
|
337
337
|
end
|
338
338
|
end
|
@@ -1,36 +1,37 @@
|
|
1
|
-
|
2
|
-
class Help
|
3
|
-
class << self
|
4
|
-
DEFAULT_HELP_DOC = "README"
|
1
|
+
require "homesteading/command"
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
elsif ARGV.first.match(/:/)
|
10
|
-
ARGV.first.sub(":", "-")
|
11
|
-
else
|
12
|
-
ARGV.first
|
13
|
-
end
|
3
|
+
module Homesteading
|
4
|
+
class Help < Command
|
5
|
+
register "help", "h"
|
14
6
|
|
15
|
-
|
16
|
-
end
|
7
|
+
DEFAULT_HELP_DOC = "README"
|
17
8
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
def default
|
10
|
+
help_doc_path = if ARGV.empty?
|
11
|
+
DEFAULT_HELP_DOC
|
12
|
+
elsif ARGV.first.match(/:/)
|
13
|
+
ARGV.first.sub(":", "-")
|
14
|
+
else
|
15
|
+
ARGV.first
|
16
|
+
end
|
22
17
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
print(help_doc_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def print(path)
|
22
|
+
# TODO better way?
|
23
|
+
help_dir = File.expand_path("../../../../help/", __FILE__)
|
24
|
+
file = "#{help_dir}/#{path}.md"
|
29
25
|
|
30
|
-
|
26
|
+
puts
|
27
|
+
unless File.exist?(file)
|
28
|
+
file = "#{help_dir}/#{DEFAULT_HELP_DOC}.md"
|
29
|
+
puts "Unknown command. No help docs about that."
|
31
30
|
puts
|
32
31
|
end
|
33
32
|
|
33
|
+
puts File.read(file)
|
34
|
+
puts
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|