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.
@@ -1,4 +1,4 @@
1
- class ForgeCLI::AbilityInstaller < ForgeCLI::App
1
+ class ForgeCLI::AbilityInstaller
2
2
  class << self
3
3
  def install_abilities!(app, ability_class)
4
4
  @app = app
data/lib/forge-cli/app.rb CHANGED
@@ -1,6 +1,4 @@
1
1
  class ForgeCLI::App < Thor
2
- include Thor::Actions
3
-
4
2
  desc 'new', 'Create a new Forge app'
5
3
  def new(app, modules = '')
6
4
  modules = modules.split(',')
@@ -1,4 +1,4 @@
1
- class ForgeCLI::ApplicationCreator < ForgeCLI::App
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
- 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
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
- # Remove some base Rails files that we don't want
20
- STDOUT.puts "\nRemoving unneccessary base Rails files..."
21
- remove_file File.join(@app, 'app', 'views', 'layouts', 'application.html.erb')
22
- remove_file File.join(@app, 'app', 'assets', 'stylesheets', 'application.css')
23
- remove_file File.join(@app, 'public', 'index.html')
24
- remove_file File.join(@app, 'Gemfile.lock')
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
- # Copy custom files from ~/.forge
27
- if File.exist?(File.join(ENV["HOME"], '.forge'))
28
- STDOUT.puts "\nCopying your custom files from ~/.forge"
29
- ForgeCLI::CustomFileCopier.copy_files!(@app)
30
- end
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
- # Rewrite Forge3::Application
33
- rewrite_app_name
31
+ # Rewrite Forge3::Application
32
+ rewrite_app_name
34
33
 
35
- STDOUT.puts completed_message
36
- end
34
+ STDOUT.puts completed_message
35
+ end
37
36
 
38
- def completed_message
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
- end
44
+ }
45
+ end
47
46
 
48
- private
49
- def remove_file(file)
50
- if File.exist?(file)
51
- STDOUT.puts " #{"remove".foreground(93, 255, 85)} #{file.gsub(@app + '/', '')}"
52
- FileUtils.rm(file)
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
- def rewrite_app_name
57
- files = [
58
- '/config/environments/production.rb',
59
- '/config/application.rb'
60
- ]
61
- files.each do |file|
62
- old_content = File.read(File.join(@app, file))
63
- app_name = File.basename(@app).classify
64
- new_content = old_content.gsub('Forge3', app_name)
65
- File.open(File.join(@app, file), 'w') do |f|
66
- f.puts new_content
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
- - 'config/initializers/forge/controllers/ecommerce.rb'
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
- - config/initializers/forge/controllers/posts.rb
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 < Thor
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
- 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
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
- def routes
28
- @routes ||= get_routes
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
- def forge_routes
32
- @forge_routes ||= get_routes('forge_')
33
- end
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
- 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
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
@@ -1,3 +1,3 @@
1
1
  class ForgeCLI
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.13'
3
3
  end
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: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 12
10
- version: 0.0.12
9
+ - 13
10
+ version: 0.0.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - factor[e] design initiative