forge-cli 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/forge-cli/ability_installer.rb +1 -1
- data/lib/forge-cli/app.rb +0 -2
- data/lib/forge-cli/application_creator.rb +44 -47
- data/lib/forge-cli/modules/ecommerce/manifest.yml +1 -1
- data/lib/forge-cli/modules/ecommerce/post_hooks.rb +1 -0
- data/lib/forge-cli/modules/posts/manifest.yml +1 -1
- data/lib/forge-cli/modules/posts/post_hooks.rb +1 -0
- data/lib/forge-cli/route_installer.rb +28 -30
- data/lib/forge-cli/version.rb +1 -1
- metadata +3 -3
data/lib/forge-cli/app.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class ForgeCLI::ApplicationCreator
|
1
|
+
class ForgeCLI::ApplicationCreator
|
2
2
|
def self.create!(app, modules = [])
|
3
3
|
new(app, modules).create_application!
|
4
4
|
end
|
@@ -8,65 +8,62 @@ class ForgeCLI::ApplicationCreator < ForgeCLI::App
|
|
8
8
|
@modules = modules
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
11
|
+
def create_application!
|
12
|
+
system("/usr/bin/env rails new #{@app}")
|
13
|
+
ForgeCLI::ModuleInstaller.install_module!(:base, @app)
|
14
|
+
@modules.each do |mod|
|
15
|
+
ForgeCLI::ModuleInstaller.install_module!(mod, @app)
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
# Remove some base Rails files that we don't want
|
19
|
+
STDOUT.puts "\nRemoving unneccessary base Rails files..."
|
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')
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
# Copy custom files from ~/.forge
|
26
|
+
if File.exist?(File.join(ENV["HOME"], '.forge'))
|
27
|
+
STDOUT.puts "\nCopying your custom files from ~/.forge"
|
28
|
+
ForgeCLI::CustomFileCopier.copy_files!(@app)
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
31
|
+
# Rewrite Forge3::Application
|
32
|
+
rewrite_app_name
|
34
33
|
|
35
|
-
|
36
|
-
|
34
|
+
STDOUT.puts completed_message
|
35
|
+
end
|
37
36
|
|
38
|
-
|
39
|
-
|
37
|
+
def completed_message
|
38
|
+
%{
|
40
39
|
#{"Your new Forge site is almost ready! Next steps:".foreground(:cyan)}
|
41
40
|
1. Run 'bundle install'
|
42
41
|
2. Set up config/database.yml
|
43
42
|
3. Run 'rake db:migrate'
|
44
43
|
4. Run 'rake forge:create_admin
|
45
|
-
|
46
|
-
|
44
|
+
}
|
45
|
+
end
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
47
|
+
private
|
48
|
+
def remove_file(file)
|
49
|
+
if File.exist?(file)
|
50
|
+
STDOUT.puts " #{"remove".foreground(93, 255, 85)} #{file.gsub(@app + '/', '')}"
|
51
|
+
FileUtils.rm(file)
|
54
52
|
end
|
53
|
+
end
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
55
|
+
def rewrite_app_name
|
56
|
+
files = [
|
57
|
+
'/config/environments/production.rb',
|
58
|
+
'/config/application.rb'
|
59
|
+
]
|
60
|
+
files.each do |file|
|
61
|
+
old_content = File.read(File.join(@app, file))
|
62
|
+
app_name = File.basename(@app).classify
|
63
|
+
new_content = old_content.gsub('Forge3', app_name)
|
64
|
+
File.open(File.join(@app, file), 'w') do |f|
|
65
|
+
f.puts new_content
|
68
66
|
end
|
69
67
|
end
|
70
|
-
|
71
|
-
end
|
68
|
+
end
|
72
69
|
end
|
@@ -33,7 +33,7 @@ files:
|
|
33
33
|
- 'app/views/forge/products'
|
34
34
|
- 'app/views/forge/sales'
|
35
35
|
- 'app/views/forge/tax_rates'
|
36
|
-
- '
|
36
|
+
- 'lib/forge/shared_controller_methods/ecommerce.rb'
|
37
37
|
- 'lib/models/order'
|
38
38
|
- 'lib/forge/config/ecommerce.rb'
|
39
39
|
|
@@ -10,6 +10,7 @@ class ForgeCLI::EcommercePostHooks < ForgeCLI::PostHooks
|
|
10
10
|
'class ApplicationController < ActionController::Base',
|
11
11
|
"class ApplicationController < ActionController::Base\n include Forge::Controllers::ECommerce\n"
|
12
12
|
)
|
13
|
+
content = "require 'forge/shared_controller_methods/ecommerce.rb'\n" + content
|
13
14
|
File.open(app_controller_path, 'w') do |f|
|
14
15
|
f.puts content
|
15
16
|
end
|
@@ -7,7 +7,7 @@ files:
|
|
7
7
|
- app/controllers/forge/post_categories_controller.rb
|
8
8
|
- app/models/post.rb
|
9
9
|
- app/models/post_category.rb
|
10
|
-
-
|
10
|
+
- lib/forge/shared_controller_methods/posts.rb
|
11
11
|
- app/views/forge/shared/menu_items/_posts.html.haml
|
12
12
|
|
13
13
|
migrations:
|
@@ -10,6 +10,7 @@ class ForgeCLI::PostPostHooks < ForgeCLI::PostHooks
|
|
10
10
|
'class ApplicationController < ActionController::Base',
|
11
11
|
"class ApplicationController < ActionController::Base\n include Forge::Controllers::Posts\n"
|
12
12
|
)
|
13
|
+
content = "require 'forge/shared_controller_methods/posts.rb'\n" + content
|
13
14
|
File.open(app_controller_path, 'w') do |f|
|
14
15
|
f.puts content
|
15
16
|
end
|
@@ -1,42 +1,40 @@
|
|
1
|
-
class ForgeCLI::RouteInstaller
|
1
|
+
class ForgeCLI::RouteInstaller
|
2
2
|
def initialize(app, module_path)
|
3
3
|
@app = app
|
4
4
|
@module_path = module_path
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
7
|
+
def install_routes(type = :normal)
|
8
|
+
file = File.join(@app, 'config', 'routes.rb')
|
9
|
+
existing_routes = File.read(file)
|
10
|
+
if type.to_sym == :normal
|
11
|
+
routes_to_add = routes
|
12
|
+
line = "Application.routes.draw do"
|
13
|
+
indent = 2
|
14
|
+
else
|
15
|
+
routes_to_add = self.send("#{type}_routes")
|
16
|
+
line = "namespace :#{type} do"
|
17
|
+
indent = 4
|
25
18
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
29
23
|
end
|
24
|
+
end
|
30
25
|
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
def routes
|
27
|
+
@routes ||= get_routes
|
28
|
+
end
|
29
|
+
|
30
|
+
def forge_routes
|
31
|
+
@forge_routes ||= get_routes('forge_')
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
34
|
+
def get_routes(prefix = '')
|
35
|
+
file = File.join(@module_path, "#{prefix}routes.rb")
|
36
|
+
if File.exist?(file)
|
37
|
+
File.open(file, "r").read
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
data/lib/forge-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forge-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 13
|
10
|
+
version: 0.0.13
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- factor[e] design initiative
|