spree_cmd 1.0.7 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/spree_cmd/extension.rb +18 -18
- data/lib/spree_cmd/installer.rb +46 -45
- data/lib/spree_cmd/templates/extension/Gemfile +3 -7
- data/lib/spree_cmd/templates/extension/Rakefile +2 -2
- data/lib/spree_cmd/templates/extension/Versionfile +5 -3
- data/lib/spree_cmd/templates/extension/extension.gemspec +7 -7
- data/lib/spree_cmd/templates/extension/lib/%file_name%/engine.rb.tt +1 -1
- data/lib/spree_cmd/templates/extension/lib/generators/%file_name%/install/install_generator.rb.tt +7 -7
- data/lib/spree_cmd/templates/extension/script/rails.tt +5 -3
- data/lib/spree_cmd/templates/extension/spec/spec_helper.rb.tt +4 -3
- data/lib/spree_cmd/version.rb +12 -0
- data/lib/spree_cmd.rb +11 -5
- metadata +10 -17
data/lib/spree_cmd/extension.rb
CHANGED
@@ -9,25 +9,25 @@ module SpreeCmd
|
|
9
9
|
source_root File.expand_path('../templates/extension', __FILE__)
|
10
10
|
|
11
11
|
def generate
|
12
|
-
use_prefix
|
12
|
+
use_prefix 'spree_'
|
13
13
|
|
14
14
|
empty_directory file_name
|
15
15
|
|
16
|
-
directory
|
17
|
-
directory
|
18
|
-
directory
|
19
|
-
|
20
|
-
template
|
21
|
-
template
|
22
|
-
template
|
23
|
-
template
|
24
|
-
template
|
25
|
-
template
|
26
|
-
template
|
27
|
-
template
|
28
|
-
template
|
29
|
-
template
|
30
|
-
template
|
16
|
+
directory 'app', "#{file_name}/app"
|
17
|
+
directory 'lib', "#{file_name}/lib"
|
18
|
+
directory 'script', "#{file_name}/script"
|
19
|
+
|
20
|
+
template 'extension.gemspec', "#{file_name}/#{file_name}.gemspec"
|
21
|
+
template 'Gemfile', "#{file_name}/Gemfile"
|
22
|
+
template 'gitignore', "#{file_name}/.gitignore"
|
23
|
+
template 'LICENSE', "#{file_name}/LICENSE"
|
24
|
+
template 'Rakefile', "#{file_name}/Rakefile"
|
25
|
+
template 'README.md', "#{file_name}/README.md"
|
26
|
+
template 'config/routes.rb', "#{file_name}/config/routes.rb"
|
27
|
+
template 'config/locales/en.yml', "#{file_name}/config/locales/en.yml"
|
28
|
+
template 'rspec', "#{file_name}/.rspec"
|
29
|
+
template 'spec/spec_helper.rb.tt', "#{file_name}/spec/spec_helper.rb"
|
30
|
+
template 'Versionfile', "#{file_name}/Versionfile"
|
31
31
|
end
|
32
32
|
|
33
33
|
def final_banner
|
@@ -51,12 +51,12 @@ module SpreeCmd
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def spree_version
|
54
|
-
'1.0
|
54
|
+
'1.1.0'
|
55
55
|
end
|
56
56
|
|
57
57
|
def use_prefix(prefix)
|
58
58
|
unless file_name =~ /^#{prefix}/
|
59
|
-
@file_name = prefix + file_name
|
59
|
+
@file_name = prefix + Thor::Util.snake_case(file_name)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
data/lib/spree_cmd/installer.rb
CHANGED
@@ -3,10 +3,11 @@ module SpreeCmd
|
|
3
3
|
class Installer < Thor::Group
|
4
4
|
include Thor::Actions
|
5
5
|
|
6
|
-
desc
|
6
|
+
desc 'Creates a new rails project with a spree store'
|
7
7
|
argument :app_path, :type => :string, :desc => 'rails app_path', :default => '.'
|
8
8
|
|
9
|
-
class_option :auto_accept, :type => :boolean, :aliases => '-A',
|
9
|
+
class_option :auto_accept, :type => :boolean, :aliases => '-A',
|
10
|
+
:desc => 'Answer yes to all prompts'
|
10
11
|
|
11
12
|
class_option :skip_install_data, :type => :boolean, :default => false,
|
12
13
|
:desc => 'Skip running migrations and loading seed and sample data'
|
@@ -24,7 +25,7 @@ module SpreeCmd
|
|
24
25
|
|
25
26
|
def verify_rails
|
26
27
|
unless is_rails_project?
|
27
|
-
say "#{@app_path} rails project
|
28
|
+
say "#{@app_path} is not a rails project."
|
28
29
|
exit(1)
|
29
30
|
end
|
30
31
|
end
|
@@ -45,17 +46,17 @@ module SpreeCmd
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def ask_questions
|
48
|
-
@install_default_gateways = ask_with_default(
|
49
|
+
@install_default_gateways = ask_with_default('Would you like to install the default gateways?')
|
49
50
|
|
50
51
|
if options[:skip_install_data]
|
51
52
|
@run_migrations = false
|
52
53
|
@load_seed_data = false
|
53
54
|
@load_sample_data = false
|
54
55
|
else
|
55
|
-
@run_migrations = ask_with_default(
|
56
|
+
@run_migrations = ask_with_default('Would you like to run the migrations?')
|
56
57
|
if @run_migrations
|
57
|
-
@load_seed_data = ask_with_default(
|
58
|
-
@load_sample_data = ask_with_default(
|
58
|
+
@load_seed_data = ask_with_default('Would you like to load the seed data?')
|
59
|
+
@load_sample_data = ask_with_default('Would you like to load the sample data?')
|
59
60
|
else
|
60
61
|
@load_seed_data = false
|
61
62
|
@load_sample_data = false
|
@@ -97,7 +98,7 @@ module SpreeCmd
|
|
97
98
|
end
|
98
99
|
|
99
100
|
def precompile_assets
|
100
|
-
say_status :precompiling,
|
101
|
+
say_status :precompiling, 'assets'
|
101
102
|
inside @app_path do
|
102
103
|
run 'bundle exec rake assets:precompile', :verbose => false
|
103
104
|
end
|
@@ -105,51 +106,51 @@ module SpreeCmd
|
|
105
106
|
|
106
107
|
private
|
107
108
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
109
|
+
def gem(name, options={})
|
110
|
+
say_status :gemfile, name
|
111
|
+
parts = ["'#{name}'"]
|
112
|
+
options.each { |key, value| parts << ":#{key} => '#{value}'" }
|
113
|
+
append_file 'Gemfile', "gem #{parts.join(', ')}\n", :verbose => false
|
114
|
+
end
|
114
115
|
|
115
|
-
|
116
|
-
|
116
|
+
def ask_with_default(message, default = 'yes')
|
117
|
+
return true if options[:auto_accept]
|
117
118
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
119
|
+
valid = false
|
120
|
+
until valid
|
121
|
+
response = ask "#{message} (yes/no) [#{default}]"
|
122
|
+
response = default if response.empty?
|
123
|
+
valid = (response =~ /\Ay(?:es)?|no?\Z/i)
|
124
|
+
end
|
125
|
+
response.downcase[0] == ?y
|
123
126
|
end
|
124
|
-
response.downcase[0] == ?y
|
125
|
-
end
|
126
127
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
128
|
+
def ask_string(message, default, valid_regex = /\w/)
|
129
|
+
return default if options[:auto_accept]
|
130
|
+
valid = false
|
131
|
+
until valid
|
132
|
+
response = ask "#{message} [#{default}]"
|
133
|
+
response = default if response.empty?
|
134
|
+
valid = (response =~ valid_regex)
|
135
|
+
end
|
136
|
+
response
|
134
137
|
end
|
135
|
-
response
|
136
|
-
end
|
137
138
|
|
138
|
-
|
139
|
-
|
139
|
+
def create_rails_app
|
140
|
+
say :create, @app_path
|
140
141
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
142
|
+
rails_cmd = "rails new #{@app_path} --skip-bundle"
|
143
|
+
if options[:template]
|
144
|
+
rails_cmd += " -m #{options[:template]}"
|
145
|
+
end
|
146
|
+
if options[:database]
|
147
|
+
rails_cmd += " -d #{options[:database]}"
|
148
|
+
end
|
149
|
+
run(rails_cmd)
|
147
150
|
end
|
148
|
-
run(rails_cmd)
|
149
|
-
end
|
150
151
|
|
151
|
-
|
152
|
-
|
153
|
-
|
152
|
+
def is_rails_project?
|
153
|
+
File.exists? File.join(@app_path, 'script', 'rails')
|
154
|
+
end
|
154
155
|
end
|
155
156
|
end
|
@@ -15,14 +15,14 @@ Gem::PackageTask.new(spec) do |p|
|
|
15
15
|
p.gem_spec = spec
|
16
16
|
end
|
17
17
|
|
18
|
-
desc
|
18
|
+
desc 'Release to gemcutter'
|
19
19
|
task :release => :package do
|
20
20
|
require 'rake/gemcutter'
|
21
21
|
Rake::Gemcutter::Tasks.new(spec).define
|
22
22
|
Rake::Task['gem:push'].invoke
|
23
23
|
end
|
24
24
|
|
25
|
-
desc
|
25
|
+
desc 'Generates a dummy app for testing'
|
26
26
|
task :test_app do
|
27
27
|
ENV['LIB_NAME'] = '<%=file_name%>'
|
28
28
|
Rake::Task['common:test_app'].invoke
|
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
# Examples
|
5
5
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
6
|
+
# '1.2.x' => { :branch => 'master' }
|
7
|
+
# '1.1.x' => { :branch => '1-1-stable' }
|
8
|
+
# '1.0.x' => { :branch => '1-0-stable' }
|
9
|
+
# '0.70.x' => { :branch => '0-70-stable' }
|
10
|
+
# '0.40.x' => { :tag => 'v1.0.0', :version => '1.0.0' }
|
9
11
|
|
@@ -7,20 +7,20 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.description = 'TODO: Add (optional) gem description here'
|
8
8
|
s.required_ruby_version = '>= 1.8.7'
|
9
9
|
|
10
|
-
# s.author
|
11
|
-
# s.email
|
12
|
-
# s.homepage
|
10
|
+
# s.author = 'You'
|
11
|
+
# s.email = 'you@example.com'
|
12
|
+
# s.homepage = 'http://www.spreecommerce.com'
|
13
13
|
|
14
|
-
#s.files
|
15
|
-
#s.test_files
|
14
|
+
#s.files = `git ls-files`.split("\n")
|
15
|
+
#s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
s.require_path = 'lib'
|
17
17
|
s.requirements << 'none'
|
18
18
|
|
19
19
|
s.add_dependency 'spree_core', '~> <%= spree_version %>'
|
20
20
|
|
21
21
|
s.add_development_dependency 'capybara', '1.0.1'
|
22
|
-
s.add_development_dependency 'factory_girl'
|
22
|
+
s.add_development_dependency 'factory_girl', '~> 2.6.4'
|
23
23
|
s.add_development_dependency 'ffaker'
|
24
|
-
s.add_development_dependency 'rspec-rails', '~> 2.
|
24
|
+
s.add_development_dependency 'rspec-rails', '~> 2.9'
|
25
25
|
s.add_development_dependency 'sqlite3'
|
26
26
|
end
|
@@ -10,7 +10,7 @@ module <%= class_name %>
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.activate
|
13
|
-
Dir.glob(File.join(File.dirname(__FILE__),
|
13
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
14
14
|
Rails.configuration.cache_classes ? require(c) : load(c)
|
15
15
|
end
|
16
16
|
end
|
data/lib/spree_cmd/templates/extension/lib/generators/%file_name%/install/install_generator.rb.tt
CHANGED
@@ -3,13 +3,13 @@ module <%= class_name %>
|
|
3
3
|
class InstallGenerator < Rails::Generators::Base
|
4
4
|
|
5
5
|
def add_javascripts
|
6
|
-
append_file
|
7
|
-
append_file
|
6
|
+
append_file 'app/assets/javascripts/store/all.js', "//= require store/<%= file_name %>\n"
|
7
|
+
append_file 'app/assets/javascripts/admin/all.js', "//= require admin/<%= file_name %>\n"
|
8
8
|
end
|
9
9
|
|
10
10
|
def add_stylesheets
|
11
|
-
inject_into_file
|
12
|
-
inject_into_file
|
11
|
+
inject_into_file 'app/assets/stylesheets/store/all.css', " *= require store/<%= file_name %>\n", :before => /\*\//, :verbose => true
|
12
|
+
inject_into_file 'app/assets/stylesheets/admin/all.css', " *= require admin/<%= file_name %>\n", :before => /\*\//, :verbose => true
|
13
13
|
end
|
14
14
|
|
15
15
|
def add_migrations
|
@@ -17,11 +17,11 @@ module <%= class_name %>
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def run_migrations
|
20
|
-
res = ask
|
21
|
-
if res ==
|
20
|
+
res = ask 'Would you like to run the migrations now? [Y/n]'
|
21
|
+
if res == '' || res.downcase == 'y'
|
22
22
|
run 'bundle exec rake db:migrate'
|
23
23
|
else
|
24
|
-
puts
|
24
|
+
puts 'Skiping rake db:migrate, don\'t forget to run it!'
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
4
|
+
ENGINE_PATH = File.expand_path('../../lib/<%= file_name -%>/engine', __FILE__)
|
5
|
+
|
6
|
+
require 'rails/all'
|
7
|
+
require 'rails/engine/commands'
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# Configure Rails Environment
|
2
|
-
ENV[
|
2
|
+
ENV['RAILS_ENV'] = 'test'
|
3
3
|
|
4
|
-
require File.expand_path(
|
4
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
5
5
|
|
6
6
|
require 'rspec/rails'
|
7
|
+
require 'ffaker'
|
7
8
|
|
8
9
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
9
10
|
# in spec/support/ and its subdirectories.
|
10
|
-
Dir[File.join(File.dirname(__FILE__),
|
11
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
11
12
|
|
12
13
|
# Requires factories defined in spree_core
|
13
14
|
require 'spree/core/testing_support/factories'
|
data/lib/spree_cmd.rb
CHANGED
@@ -1,23 +1,29 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'thor/group'
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require 'spree_cmd/installer'
|
5
|
+
require 'spree_cmd/extension'
|
6
|
+
require 'spree_cmd/version'
|
6
7
|
|
7
8
|
module SpreeCmd
|
8
9
|
class Command < Thor
|
9
10
|
|
10
|
-
desc
|
11
|
+
desc 'install', 'adds spree to an existing rails app'
|
11
12
|
method_option :app_path, :type => :string, :desc => 'path to rails application'
|
12
|
-
def install(app_path='.')
|
13
|
+
def install(app_path = '.')
|
13
14
|
invoke Installer
|
14
15
|
end
|
15
16
|
|
16
|
-
desc
|
17
|
+
desc 'extension', 'builds a spree extension'
|
17
18
|
method_option :app_path, :type => :string, :desc => 'path to new extension'
|
18
19
|
def extension(app_path)
|
19
20
|
invoke Extension
|
20
21
|
end
|
21
22
|
|
23
|
+
desc 'version', 'display spree_cmd version'
|
24
|
+
def version
|
25
|
+
invoke Version
|
26
|
+
end
|
27
|
+
|
22
28
|
end
|
23
29
|
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_cmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Chris Mar
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70358889984660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,12 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
24
|
+
version_requirements: *70358889984660
|
30
25
|
description: tools to create new Spree stores and extensions
|
31
26
|
email:
|
32
27
|
- chris@spreecommerce.com
|
@@ -63,6 +58,7 @@ files:
|
|
63
58
|
- lib/spree_cmd/templates/extension/rspec
|
64
59
|
- lib/spree_cmd/templates/extension/script/rails.tt
|
65
60
|
- lib/spree_cmd/templates/extension/spec/spec_helper.rb.tt
|
61
|
+
- lib/spree_cmd/version.rb
|
66
62
|
- spec/spec_helper.rb
|
67
63
|
- spree_cmd.gemspec
|
68
64
|
homepage: http://spreecommerce.com
|
@@ -79,19 +75,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
75
|
version: '0'
|
80
76
|
segments:
|
81
77
|
- 0
|
82
|
-
hash:
|
78
|
+
hash: -1956711376775405443
|
83
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
80
|
none: false
|
85
81
|
requirements:
|
86
|
-
- - ! '
|
82
|
+
- - ! '>'
|
87
83
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
89
|
-
segments:
|
90
|
-
- 0
|
91
|
-
hash: 3336770305767231125
|
84
|
+
version: 1.3.1
|
92
85
|
requirements: []
|
93
86
|
rubyforge_project: spree_cmd
|
94
|
-
rubygems_version: 1.8.
|
87
|
+
rubygems_version: 1.8.10
|
95
88
|
signing_key:
|
96
89
|
specification_version: 3
|
97
90
|
summary: Spree Commerce command line utility
|