forge-cli 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/forge-cli/app.rb +1 -1
- data/lib/forge-cli/application_creator.rb +18 -16
- data/lib/forge-cli/route_installer.rb +29 -27
- data/lib/forge-cli/version.rb +1 -1
- metadata +1 -1
data/lib/forge-cli/app.rb
CHANGED
@@ -8,30 +8,32 @@ class ForgeCLI::ApplicationCreator < ForgeCLI::App
|
|
8
8
|
@modules = modules
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
no_commands do
|
12
|
+
def create_application!
|
13
|
+
system("/usr/bin/env rails new #{@app}")
|
14
|
+
ForgeCLI::ModuleInstaller.install_module!(:base, @app)
|
15
|
+
@modules.each do |mod|
|
16
|
+
ForgeCLI::ModuleInstaller.install_module!(mod, @app)
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
# Remove some base Rails files that we don't want
|
20
|
+
remove_file File.join(@app, 'app', 'views', 'layouts', 'application.html.erb')
|
21
|
+
remove_file File.join(@app, 'app', 'assets', 'stylesheets', 'application.css')
|
22
|
+
remove_file File.join(@app, 'public', 'index.html')
|
23
|
+
remove_file File.join(@app, 'Gemfile.lock')
|
23
24
|
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
STDOUT.puts completed_message
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
def completed_message
|
30
|
+
%{
|
30
31
|
#{"Your new Forge site is almost ready! Next steps:".foreground(:cyan)}
|
31
32
|
1. Run 'bundle install'
|
32
33
|
2. Set up config/database.yml
|
33
34
|
3. Run 'rake db:migrate'
|
34
35
|
4. Run 'rake forge:create_admin
|
35
|
-
|
36
|
+
}
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
@@ -4,37 +4,39 @@ class ForgeCLI::RouteInstaller < Thor
|
|
4
4
|
@module_path = module_path
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
no_commands do
|
8
|
+
def install_routes(type = :normal)
|
9
|
+
file = File.join(@app, 'config', 'routes.rb')
|
10
|
+
existing_routes = File.read(file)
|
11
|
+
if type.to_sym == :normal
|
12
|
+
routes_to_add = routes
|
13
|
+
line = "Application.routes.draw do"
|
14
|
+
indent = 2
|
15
|
+
else
|
16
|
+
routes_to_add = self.send("#{type}_routes")
|
17
|
+
line = "namespace :#{type} do"
|
18
|
+
indent = 4
|
19
|
+
end
|
20
|
+
routes = routes_to_add.split("\n").map {|r| " " * indent + r }.join("\n")
|
21
|
+
updated_routes = existing_routes.gsub(line, "#{line}\n#{routes}")
|
22
|
+
File.open(file, 'w') do |f|
|
23
|
+
f.puts updated_routes
|
24
|
+
end
|
18
25
|
end
|
19
|
-
routes = routes_to_add.split("\n").map {|r| " " * indent + r }.join("\n")
|
20
|
-
updated_routes = existing_routes.gsub(line, "#{line}\n#{routes}")
|
21
|
-
File.open(file, 'w') do |f|
|
22
|
-
f.puts updated_routes
|
23
|
-
end
|
24
|
-
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
def routes
|
28
|
+
@routes ||= get_routes
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
def forge_routes
|
32
|
+
@forge_routes ||= get_routes('forge_')
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
def get_routes(prefix = '')
|
36
|
+
file = File.join(@module_path, "#{prefix}routes.rb")
|
37
|
+
if File.exist?(file)
|
38
|
+
File.open(file, "r").read
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
data/lib/forge-cli/version.rb
CHANGED