homesteading 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,44 +1,44 @@
|
|
1
|
-
|
2
|
-
class Init
|
3
|
-
class << self
|
1
|
+
require "homesteading/command"
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
puts
|
3
|
+
module Homesteading
|
4
|
+
class Init < Command
|
5
|
+
register "init"
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
def default(constellation_dir)
|
8
|
+
puts
|
9
|
+
puts "* Setting up all apps"
|
10
|
+
puts
|
13
11
|
|
14
|
-
|
12
|
+
Dir.glob("#{Dir.pwd}/#{constellation_dir}/homesteading-*/").each do |app_dir|
|
13
|
+
app = app_dir.split("/").last.sub(/homesteading-/, "").downcase
|
14
|
+
app_file_path = app_dir + "app.json"
|
15
15
|
|
16
|
-
|
17
|
-
app_file = JSON.parse(File.read(app_file_path))
|
18
|
-
app_postdeploy = app_file["scripts"]["postdeploy"]
|
16
|
+
puts "* Setting up: #{app}"
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
system "rake hs:db:config"
|
24
|
-
end
|
18
|
+
if File.exist?(app_file_path)
|
19
|
+
app_file = JSON.parse(File.read(app_file_path))
|
20
|
+
app_postdeploy = app_file["scripts"]["postdeploy"]
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
FileUtils.cd app_dir do
|
23
|
+
if File.exist?("#{app_dir}/config/database.example.yml")
|
24
|
+
puts "* Copying database config file"
|
25
|
+
system "rake hs:db:config"
|
26
|
+
end
|
31
27
|
|
28
|
+
unless app_postdeploy.nil? && app_postdeploy.empty?
|
29
|
+
puts "* Running postdeploy command on #{app}:"
|
32
30
|
puts
|
31
|
+
system app_postdeploy if app_postdeploy
|
33
32
|
end
|
34
|
-
end
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
puts
|
34
|
+
puts
|
35
|
+
end
|
39
36
|
end
|
40
|
-
end
|
41
37
|
|
38
|
+
puts "* Setup up complete for: #{app}"
|
39
|
+
puts
|
40
|
+
puts
|
41
|
+
end
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -1,84 +1,68 @@
|
|
1
|
+
require "homesteading/command"
|
1
2
|
require "homesteading/commands/init"
|
2
3
|
|
3
|
-
|
4
|
-
class New
|
5
|
-
|
6
|
-
PUBLISHER_APPS = ["article", "bookmark", "event", "note", "photo", "sound", "video", "walk", "weight"]
|
7
|
-
NONPUBLISHER_APPS = ["router-rack"] # TODO "hub", "syndicator"
|
4
|
+
module Homesteading
|
5
|
+
class New < Command
|
6
|
+
register "new"
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
PUBLISHER_APPS = ["article", "bookmark", "event", "note", "photo", "sound", "video", "walk", "weight"]
|
9
|
+
NONPUBLISHER_APPS = ["router-rack"] # TODO "hub", "syndicator"
|
11
10
|
|
12
|
-
|
11
|
+
def default
|
12
|
+
puts
|
13
13
|
|
14
|
-
|
15
|
-
constellation_dir = ARGV.shift
|
16
|
-
constellation_path = "#{Dir.pwd}/#{constellation_dir}"
|
14
|
+
options = parse_options
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
puts "* Using #{constellation_path}"
|
22
|
-
end
|
23
|
-
else
|
24
|
-
unless options[:quiet]
|
25
|
-
puts "* Creating homesteading directory: #{constellation_dir}"
|
26
|
-
end
|
27
|
-
unless options[:pretend]
|
28
|
-
FileUtils.mkpath constellation_dir
|
29
|
-
end
|
30
|
-
end
|
16
|
+
# Install location
|
17
|
+
constellation_dir = ARGV.shift
|
18
|
+
constellation_path = "#{Dir.pwd}/#{constellation_dir}"
|
31
19
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
20
|
+
if File.exist?(constellation_path)
|
21
|
+
unless options[:quiet]
|
22
|
+
puts "* #{constellation_path} already exists"
|
23
|
+
puts "* Using #{constellation_path}"
|
36
24
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
25
|
+
else
|
26
|
+
unless options[:quiet]
|
27
|
+
puts "* Creating homesteading directory: #{constellation_dir}"
|
40
28
|
end
|
29
|
+
unless options[:pretend]
|
30
|
+
FileUtils.mkpath constellation_dir
|
31
|
+
end
|
32
|
+
end
|
41
33
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
unless options[:quiet]
|
52
|
-
puts "* #{app_dir} already exists"
|
53
|
-
puts "* Skipping homesteading-#{app}"
|
54
|
-
end
|
55
|
-
elsif options[:force]
|
56
|
-
unless options[:quiet]
|
57
|
-
puts "* #{app_dir} already exists"
|
58
|
-
puts "* Removing homesteading-#{app}"
|
59
|
-
end
|
34
|
+
# Apps to install
|
35
|
+
apps = [NONPUBLISHER_APPS, PUBLISHER_APPS].flatten
|
36
|
+
if options[:only]
|
37
|
+
apps = options[:only].split(",").map { |a| a.downcase }
|
38
|
+
end
|
39
|
+
if options[:except]
|
40
|
+
only_list = options[:except].split(",").map { |a| a.downcase }
|
41
|
+
apps = apps.delete_if { |a| only_list.include?(a) }
|
42
|
+
end
|
60
43
|
|
61
|
-
|
62
|
-
|
63
|
-
|
44
|
+
apps.each do |app|
|
45
|
+
unless options[:pretend]
|
46
|
+
puts
|
47
|
+
end
|
64
48
|
|
65
|
-
|
66
|
-
puts "* Cloning homesteading app from GitHub: #{app}"
|
67
|
-
end
|
49
|
+
app_dir = "#{constellation_path}/homesteading-#{app}"
|
68
50
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
51
|
+
if File.exist?(app_dir)
|
52
|
+
if options[:skip]
|
53
|
+
unless options[:quiet]
|
54
|
+
puts "* #{app_dir} already exists"
|
55
|
+
puts "* Skipping homesteading-#{app}"
|
56
|
+
end
|
57
|
+
elsif options[:force]
|
58
|
+
unless options[:quiet]
|
59
|
+
puts "* #{app_dir} already exists"
|
60
|
+
puts "* Removing homesteading-#{app}"
|
79
61
|
end
|
80
62
|
|
81
|
-
|
63
|
+
unless options[:pretend]
|
64
|
+
FileUtils.rm_rf app_dir
|
65
|
+
end
|
82
66
|
|
83
67
|
unless options[:quiet]
|
84
68
|
puts "* Cloning homesteading app from GitHub: #{app}"
|
@@ -89,56 +73,73 @@ class Homesteading
|
|
89
73
|
system "git clone git@github.com:homesteading/homesteading-#{app}.git"
|
90
74
|
end
|
91
75
|
end
|
76
|
+
else
|
77
|
+
unless options[:quiet]
|
78
|
+
puts "* #{app_dir} already exists"
|
79
|
+
puts "* TODO gets user input on what to do about the conflict"
|
80
|
+
end
|
92
81
|
end
|
93
|
-
end
|
94
82
|
|
95
|
-
|
96
|
-
Homesteading::Init.default(constellation_dir)
|
83
|
+
else
|
97
84
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
85
|
+
unless options[:quiet]
|
86
|
+
puts "* Cloning homesteading app from GitHub: #{app}"
|
87
|
+
end
|
88
|
+
|
89
|
+
unless options[:pretend]
|
90
|
+
FileUtils.cd constellation_dir do
|
91
|
+
system "git clone git@github.com:homesteading/homesteading-#{app}.git"
|
92
|
+
end
|
93
|
+
end
|
102
94
|
end
|
95
|
+
end
|
103
96
|
|
104
|
-
|
97
|
+
puts
|
98
|
+
Homesteading::Init.default(constellation_dir)
|
99
|
+
|
100
|
+
unless options[:quiet]
|
101
|
+
puts "* Next up, do this:"
|
102
|
+
puts " cd #{constellation_dir}"
|
103
|
+
puts " homesteading server"
|
105
104
|
end
|
106
105
|
|
107
|
-
|
108
|
-
|
109
|
-
# Parse command line options
|
110
|
-
options = {}
|
106
|
+
puts
|
107
|
+
end
|
111
108
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
109
|
+
private
|
110
|
+
def parse_options
|
111
|
+
# Parse command line options
|
112
|
+
options = {}
|
116
113
|
|
117
|
-
|
118
|
-
|
119
|
-
|
114
|
+
optparse = OptionParser.new do |opts|
|
115
|
+
opts.on("-e", "--except EXCEPT", "Comma separated list of apps to not install") do |except|
|
116
|
+
options[:except] = except
|
117
|
+
end
|
120
118
|
|
121
|
-
|
122
|
-
|
123
|
-
|
119
|
+
opts.on("-f", "--force", "Overwrite apps that already exist") do |force|
|
120
|
+
options[:force] = force
|
121
|
+
end
|
124
122
|
|
125
|
-
|
126
|
-
|
127
|
-
|
123
|
+
opts.on("-o", "--only ONLY", "Comma separated list of apps to install") do |only|
|
124
|
+
options[:only] = only
|
125
|
+
end
|
128
126
|
|
129
|
-
|
130
|
-
|
131
|
-
|
127
|
+
opts.on("-p", "--pretend", "Run but do not make any changes") do |pretend|
|
128
|
+
options[:pretend] = pretend
|
129
|
+
end
|
132
130
|
|
133
|
-
|
134
|
-
|
135
|
-
end
|
131
|
+
opts.on("-q", "--quiet", "Suppress status output") do |quiet|
|
132
|
+
options[:quiet] = quiet
|
136
133
|
end
|
137
134
|
|
138
|
-
|
139
|
-
|
135
|
+
opts.on("-s", "--skip", "Skip apps that already exist") do |skip|
|
136
|
+
options[:skip] = skip
|
137
|
+
end
|
140
138
|
end
|
141
139
|
|
140
|
+
optparse.parse!
|
141
|
+
options
|
142
142
|
end
|
143
|
+
|
143
144
|
end
|
144
145
|
end
|
@@ -1,48 +1,49 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
require "homesteading/command"
|
2
|
+
|
3
|
+
module Homesteading
|
4
|
+
class Run < Command
|
5
|
+
register "run"
|
6
|
+
|
7
|
+
def default
|
8
|
+
puts
|
9
|
+
options = parse_options
|
10
|
+
app = options[:app]
|
11
|
+
command = ARGV.join(" ")
|
12
|
+
|
13
|
+
app_dirs = if app
|
14
|
+
["#{Dir.pwd}/homesteading-#{app}/"]
|
15
|
+
else
|
16
|
+
Dir.glob("#{Dir.pwd}/homesteading-*/")
|
17
|
+
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
app_dirs.each do |app_dir|
|
20
|
+
app = app_dir.split("/").last.sub(/homesteading-/, "").downcase
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
puts "* Running command on #{app}:"
|
23
|
+
puts " #{command}"
|
24
|
+
puts
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
puts
|
26
|
+
FileUtils.cd app_dir do
|
27
|
+
system command
|
28
28
|
end
|
29
|
+
puts
|
29
30
|
end
|
31
|
+
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
private
|
34
|
+
def parse_options
|
35
|
+
# Parse command line options
|
36
|
+
options = {}
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
38
|
+
optparse = OptionParser.new do |opts|
|
39
|
+
opts.on("-a", "--app APP", "Name of Homesteading app on GitHub") do |app|
|
40
|
+
options[:app] = app
|
40
41
|
end
|
41
|
-
|
42
|
-
optparse.parse!
|
43
|
-
options
|
44
42
|
end
|
45
43
|
|
44
|
+
optparse.parse!
|
45
|
+
options
|
46
46
|
end
|
47
|
+
|
47
48
|
end
|
48
49
|
end
|
@@ -1,117 +1,118 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Signal.trap("INT") do
|
14
|
-
servers.each do |io|
|
15
|
-
puts "Stopping HS:Publisher app at PID: #{io.pid}"
|
16
|
-
Process.kill "SIGINT", io.pid
|
17
|
-
end
|
1
|
+
require "homesteading/command"
|
2
|
+
require "puma"
|
3
|
+
|
4
|
+
module Homesteading
|
5
|
+
class Server < Command
|
6
|
+
register "server", "s"
|
7
|
+
|
8
|
+
def default
|
9
|
+
puts
|
10
|
+
options = parse_options
|
11
|
+
|
12
|
+
router_port = options[:port] || 3000
|
18
13
|
|
19
|
-
|
20
|
-
|
14
|
+
# Kill all Homesteading apps when `hs server` is stopped
|
15
|
+
servers = []
|
16
|
+
Signal.trap("INT") do
|
17
|
+
servers.each do |io|
|
18
|
+
puts "Stopping HS:Publisher app at PID: #{io.pid}"
|
19
|
+
Process.kill "SIGINT", io.pid
|
21
20
|
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
app_port += 1
|
59
|
-
routes << "#{app_path}:#{app_port}"
|
60
|
-
end
|
61
|
-
|
62
|
-
if app_name =~ /homesteading-assets|homesteading-router-rack/
|
63
|
-
# TODO TEMP FIXME serve assets from hub
|
64
|
-
# skipping assets and router
|
65
|
-
elsif app_name == "homesteading-feed"
|
66
|
-
# TODO TEMP FIXME no bin/rails
|
67
|
-
puts "* Starting on port #{app_port} : #{app_name.sub(/homesteading-/, "")}"
|
68
|
-
servers << IO.popen("cd #{directory} && rails server -p #{app_port}", "w")
|
69
|
-
else
|
70
|
-
puts "* Starting on port #{app_port} : #{app_name.sub(/homesteading-/, "")}"
|
71
|
-
servers << IO.popen("cd #{directory} && bin/rails server -d --port #{app_port}", "w")
|
72
|
-
end
|
22
|
+
system "homesteading server:stop"
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
homesteading_info = "#{Homesteading::VERSION}, codename: #{Homesteading::CODENAME}"
|
27
|
+
ruby_info = RUBY_DESCRIPTION
|
28
|
+
puma_info = "#{Puma::Const::PUMA_VERSION}, codename: #{Puma::Const::CODE_NAME}"
|
29
|
+
env_info = "development"
|
30
|
+
|
31
|
+
puts "* Homesteading: #{homesteading_info}"
|
32
|
+
puts "* Puma: #{puma_info}"
|
33
|
+
puts "* Ruby: #{ruby_info}"
|
34
|
+
puts "* Environment: #{env_info}"
|
35
|
+
puts "* Running on: http://0.0.0.0:#{router_port}"
|
36
|
+
puts
|
37
|
+
|
38
|
+
puts "* Homesteading servers starting..."
|
39
|
+
puts
|
40
|
+
|
41
|
+
routes = []
|
42
|
+
|
43
|
+
app_port = 3000
|
44
|
+
Dir.glob("#{Dir.pwd}/homesteading-*/").each_with_index do |directory, index|
|
45
|
+
app_file_path = directory + "app.json"
|
46
|
+
|
47
|
+
if File.exist?(app_file_path)
|
48
|
+
app_file = JSON.parse(File.read(app_file_path))
|
49
|
+
app_route = app_file["routes"]
|
50
|
+
|
51
|
+
if app_route
|
52
|
+
app_name = directory.split("/").last
|
53
|
+
|
54
|
+
app_path = app_route["path"]
|
55
|
+
if app_name =~ /feed/
|
56
|
+
app_path = "feed"
|
73
57
|
end
|
74
58
|
|
59
|
+
unless app_name == "homesteading-router-rack"
|
60
|
+
app_port += 1
|
61
|
+
routes << "#{app_path}:#{app_port}"
|
62
|
+
end
|
63
|
+
|
64
|
+
if app_name =~ /homesteading-assets|homesteading-router-rack/
|
65
|
+
# TODO TEMP FIXME serve assets from hub
|
66
|
+
# skipping assets and router
|
67
|
+
elsif app_name == "homesteading-feed"
|
68
|
+
# TODO TEMP FIXME no bin/rails
|
69
|
+
puts "* Starting on port #{app_port} : #{app_name.sub(/homesteading-/, "")}"
|
70
|
+
servers << IO.popen("cd #{directory} && rails server -p #{app_port}", "w")
|
71
|
+
else
|
72
|
+
puts "* Starting on port #{app_port} : #{app_name.sub(/homesteading-/, "")}"
|
73
|
+
servers << IO.popen("cd #{directory} && bin/rails server -d --port #{app_port}", "w")
|
74
|
+
end
|
75
75
|
end
|
76
|
+
|
76
77
|
end
|
78
|
+
end
|
77
79
|
|
78
|
-
|
79
|
-
|
80
|
+
# write routes to an env var for hs:router's routes table
|
81
|
+
ENV["HOMESTEADING_ROUTES"] = routes.join(",")
|
80
82
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
83
|
+
# start up router after ENV var is set
|
84
|
+
puts
|
85
|
+
puts "* Starting on port #{router_port} : router"
|
86
|
+
servers << IO.popen("cd #{Dir.pwd}/homesteading-router-rack/ && rackup -p #{router_port}", "w")
|
85
87
|
|
86
88
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
puts
|
90
|
+
puts "* To stop Homesteading servers:"
|
91
|
+
puts " ctrl-c"
|
92
|
+
puts " homesteading server:stop"
|
93
|
+
puts
|
94
|
+
end
|
93
95
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
def stop
|
97
|
+
# TEMP HACK TODO FIXME
|
98
|
+
# This is overly aggressive, but Signal.trap isn't working
|
99
|
+
system "killall ruby"
|
100
|
+
end
|
99
101
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
102
|
+
private
|
103
|
+
def parse_options
|
104
|
+
# Parse command line options
|
105
|
+
options = {}
|
104
106
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
107
|
+
optparse = OptionParser.new do |opts|
|
108
|
+
opts.on("-p", "--port PORT", "Run homesteading site on a specific port (default: 3000)") do |port|
|
109
|
+
options[:port] = port
|
109
110
|
end
|
110
|
-
|
111
|
-
optparse.parse!
|
112
|
-
options
|
113
111
|
end
|
114
112
|
|
113
|
+
optparse.parse!
|
114
|
+
options
|
115
115
|
end
|
116
|
+
|
116
117
|
end
|
117
118
|
end
|