spree_cmd 0.0.4 → 1.0.0.rc2
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.
- data/LICENSE +26 -0
- data/README.md +34 -16
- data/Rakefile +5 -0
- data/bin/spree +2 -147
- data/bin/spree_cmd +6 -0
- data/lib/spree_cmd.rb +20 -2
- data/lib/spree_cmd/extension.rb +65 -0
- data/lib/spree_cmd/installer.rb +139 -0
- data/lib/spree_cmd/templates/extension/Gemfile +13 -0
- data/lib/spree_cmd/templates/extension/LICENSE +26 -0
- data/lib/spree_cmd/templates/extension/README.md +21 -0
- data/lib/spree_cmd/templates/extension/Rakefile +29 -0
- data/lib/spree_cmd/templates/extension/Versionfile +9 -0
- data/lib/spree_cmd/templates/extension/app/assets/javascripts/admin/%file_name%.js +1 -0
- data/lib/spree_cmd/templates/extension/app/assets/javascripts/store/%file_name%.js +1 -0
- data/lib/spree_cmd/templates/extension/app/assets/stylesheets/admin/%file_name%.css +3 -0
- data/lib/spree_cmd/templates/extension/app/assets/stylesheets/store/%file_name%.css +3 -0
- data/lib/spree_cmd/templates/extension/config/locales/en.yml +5 -0
- data/lib/spree_cmd/templates/extension/config/routes.rb +3 -0
- data/lib/spree_cmd/templates/extension/extension.gemspec +26 -0
- data/lib/spree_cmd/templates/extension/gitignore +10 -0
- data/lib/spree_cmd/templates/extension/lib/%file_name%.rb.tt +2 -0
- data/lib/spree_cmd/templates/extension/lib/%file_name%/engine.rb.tt +20 -0
- data/lib/spree_cmd/templates/extension/lib/generators/%file_name%/install/install_generator.rb.tt +29 -0
- data/lib/spree_cmd/templates/extension/rspec +1 -0
- data/lib/spree_cmd/templates/extension/script/rails.tt +5 -0
- data/lib/spree_cmd/templates/extension/spec/spec_helper.rb.tt +32 -0
- data/spec/spec_helper.rb +12 -0
- data/spree_cmd.gemspec +7 -7
- metadata +75 -58
- data/.gitignore +0 -4
- data/Gemfile +0 -4
- data/lib/spree_cmd/version.rb +0 -3
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2007-2012, Spree Commerce, Inc. and other contributors
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1,36 +1,46 @@
|
|
1
1
|
Spree Installer
|
2
2
|
===============
|
3
3
|
|
4
|
+
**Until the release of Spree 1.0 you must use the --edge option**
|
5
|
+
|
4
6
|
Command line utility to create new Spree store applications
|
7
|
+
and extensions
|
5
8
|
|
6
9
|
See the main spree project: https://github.com/spree/spree
|
7
10
|
|
8
|
-
|
9
|
-
|
11
|
+
Installation
|
12
|
+
------------
|
10
13
|
|
11
|
-
|
14
|
+
```ruby
|
15
|
+
gem install spree_cmd
|
16
|
+
```
|
17
|
+
This will make the command line utility 'spree' available.
|
12
18
|
|
13
|
-
|
19
|
+
You can add Spree to an existing rails application
|
14
20
|
|
15
|
-
|
21
|
+
```ruby
|
22
|
+
rails new my_app
|
23
|
+
spree install my_app
|
24
|
+
```
|
16
25
|
|
17
|
-
|
26
|
+
Extensions
|
27
|
+
----------
|
18
28
|
|
19
|
-
|
29
|
+
To build a new Spree Extension, you can run
|
30
|
+
```ruby
|
31
|
+
spree extension my_extension
|
32
|
+
```
|
33
|
+
Examples
|
34
|
+
--------
|
20
35
|
|
21
|
-
|
36
|
+
If you want to accept all the defaults pass --auto_accept
|
22
37
|
|
23
|
-
|
24
|
-
------------
|
38
|
+
spree install my_store --edge --auto_accept
|
25
39
|
|
26
|
-
|
27
|
-
gem install spree_cmd
|
28
|
-
spree new my_store
|
40
|
+
to use a local clone of Spree, pass the --path option
|
29
41
|
|
30
|
-
|
42
|
+
spree install my_store --path=../spree
|
31
43
|
|
32
|
-
spree install existing_rails_app
|
33
|
-
```
|
34
44
|
|
35
45
|
options
|
36
46
|
-------
|
@@ -38,8 +48,16 @@ options
|
|
38
48
|
* --auto_accept - answer yes to all questions
|
39
49
|
* --edge - to use the edge version of Spree
|
40
50
|
* --path=../spree - to use a local version of spree
|
51
|
+
* --git=git@github.com:cmar/spree.git
|
52
|
+
* --branch=my_changes or --ref=23423423423423 or --tag=my_tag
|
41
53
|
|
54
|
+
Older Versions of Spree
|
55
|
+
-----------------------
|
42
56
|
|
57
|
+
Versions of the Spree gem before 1.0 included a spree binary. If you
|
58
|
+
have one of these installed in your gemset, then you can alternatively
|
59
|
+
use the command line utility "spree_cmd". For example "spree_cmd install
|
60
|
+
my_app".
|
43
61
|
|
44
62
|
|
45
63
|
|
data/Rakefile
CHANGED
data/bin/spree
CHANGED
@@ -1,150 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'thor/group'
|
3
|
+
require 'spree_cmd'
|
5
4
|
|
6
|
-
|
7
|
-
class Install < Thor::Group
|
8
|
-
include Thor::Actions
|
9
|
-
|
10
|
-
desc "Creates a new rails project with a spree store"
|
11
|
-
argument :new_or_install, :desc => 'new project_name or install existing_project'
|
12
|
-
argument :app_path, :type => :string, :desc => 'rails app_path', :default => '.'
|
13
|
-
|
14
|
-
class_option :auto_accept, :type => :boolean, :aliases => '-A', :desc => "Answer yes to all prompts"
|
15
|
-
|
16
|
-
class_option :skip_install_data, :type => :boolean, :default => false,
|
17
|
-
:desc => 'Skip running migrations and loading seed and sample data'
|
18
|
-
|
19
|
-
class_option :version, :type => :string, :default => 'current',
|
20
|
-
:desc => 'Spree Version to use (current, edge, local)'
|
21
|
-
|
22
|
-
class_option :edge, :type => :boolean
|
23
|
-
class_option :path, :type => :string
|
24
|
-
|
25
|
-
def prepare_options
|
26
|
-
if options[:edge]
|
27
|
-
@spree_gem_options = { :git => 'https://github.com/spree/spree.git' }
|
28
|
-
elsif options[:path]
|
29
|
-
@spree_gem_options = { :path => options[:path] }
|
30
|
-
else
|
31
|
-
@spree_gem_options = {}
|
32
|
-
end
|
33
|
-
|
34
|
-
if @new_or_install == 'new' && @app_path == '.'
|
35
|
-
say "ERROR: Must provide store name when using new"
|
36
|
-
exit(1)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def ask_questions
|
41
|
-
@install_blue_theme = ask_with_default("Would you like to install the default blue theme?")
|
42
|
-
@install_default_gateways = ask_with_default("Would you like to install the default gateways?")
|
43
|
-
|
44
|
-
if options[:skip_install_data]
|
45
|
-
@run_migrations = false
|
46
|
-
@load_seed_data = false
|
47
|
-
@load_sample_data = false
|
48
|
-
else
|
49
|
-
@run_migrations = ask_with_default("Would you like to run the migrations?")
|
50
|
-
if @run_migrations
|
51
|
-
@load_seed_data = ask_with_default("Would you like to load the seed data?")
|
52
|
-
@load_sample_data = ask_with_default("Would you like to load the sample data?")
|
53
|
-
else
|
54
|
-
@load_seed_data = false
|
55
|
-
@load_sample_data = false
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def rails_app
|
61
|
-
case @new_or_install
|
62
|
-
when 'new'
|
63
|
-
create_rails_app
|
64
|
-
when 'install'
|
65
|
-
if is_rails_project?
|
66
|
-
say :install, "Adding Spree to #{@app_path}"
|
67
|
-
else
|
68
|
-
raise "#{@app_path} rails project not found"
|
69
|
-
end
|
70
|
-
else
|
71
|
-
raise "specify new or install"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def add_gems
|
76
|
-
inside @app_path do
|
77
|
-
|
78
|
-
gem :spree, @spree_gem_options
|
79
|
-
|
80
|
-
if @install_blue_theme
|
81
|
-
gem :spree_blue_theme, { :git => 'git@github.com:spree/spree_blue_theme.git',
|
82
|
-
:ref => '10666404ccb3ed4a4cc9cbe41e822ab2bb55112e' }
|
83
|
-
end
|
84
|
-
|
85
|
-
if @install_default_gateways
|
86
|
-
gem :spree_usa_epay, { :git => 'git@github.com:spree/spree_usa_epay.git',
|
87
|
-
:ref => '2be3faede9594327b9bb548ad042ef28f2836509' }
|
88
|
-
|
89
|
-
gem :spree_skrill, { :git => 'git@github.com:spree/spree_skrill.git',
|
90
|
-
:ref => '6743bcbd0146d1c7145d6befc648005d8d0cf79a' }
|
91
|
-
end
|
92
|
-
|
93
|
-
run 'bundle install'
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def initialize_spree
|
98
|
-
spree_options = []
|
99
|
-
spree_options << "--migrate=#{@run_migrations}"
|
100
|
-
spree_options << "--seed=#{@load_seed_data}"
|
101
|
-
spree_options << "--sample=#{@load_sample_data}"
|
102
|
-
spree_options << "--auto_accept" if options[:auto_accept]
|
103
|
-
|
104
|
-
inside @app_path do
|
105
|
-
run "rails generate spree:install #{spree_options.join(' ')}"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
private
|
110
|
-
|
111
|
-
def gem(name, options={})
|
112
|
-
say_status :gemfile, name
|
113
|
-
parts = ["'#{name}'"]
|
114
|
-
options.each {|key, value| parts << ":#{key} => '#{value}'" }
|
115
|
-
append_file "Gemfile", "gem #{parts.join(', ')}\n", :verbose => false
|
116
|
-
end
|
117
|
-
|
118
|
-
def ask_with_default(message, default='yes')
|
119
|
-
return true if options[:auto_accept]
|
120
|
-
|
121
|
-
valid = false
|
122
|
-
until valid
|
123
|
-
response = ask "#{message} (yes/no) [#{default}]"
|
124
|
-
response = default if response.empty?
|
125
|
-
valid = (response =~ /\Ay(?:es)?|no?\Z/i)
|
126
|
-
end
|
127
|
-
response.downcase[0] == ?y
|
128
|
-
end
|
129
|
-
|
130
|
-
def create_rails_app
|
131
|
-
say :create, @app_path
|
132
|
-
|
133
|
-
rails_cmd = "rails new #{@app_path} --skip-bundle"
|
134
|
-
if options[:template]
|
135
|
-
rails_cmd += " -m #{options[:template]}"
|
136
|
-
end
|
137
|
-
if options[:database]
|
138
|
-
rails_cmd += " -d #{options[:database]}"
|
139
|
-
end
|
140
|
-
run(rails_cmd)
|
141
|
-
end
|
142
|
-
|
143
|
-
def is_rails_project?
|
144
|
-
File.exists? File.join(@app_path, 'script', 'rails')
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
Install.start
|
150
|
-
end
|
5
|
+
SpreeCmd::Command.start
|
data/bin/spree_cmd
ADDED
data/lib/spree_cmd.rb
CHANGED
@@ -1,5 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/group'
|
3
|
+
|
4
|
+
require "spree_cmd/installer"
|
5
|
+
require "spree_cmd/extension"
|
2
6
|
|
3
7
|
module SpreeCmd
|
4
|
-
|
8
|
+
class Command < Thor
|
9
|
+
|
10
|
+
desc "install", "adds spree to an existing rails app"
|
11
|
+
method_option :app_path, :type => :string, :desc => 'path to rails application'
|
12
|
+
def install(app_path='.')
|
13
|
+
invoke Installer
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "extension", "builds a spree extension"
|
17
|
+
method_option :app_path, :type => :string, :desc => 'path to new extension'
|
18
|
+
def extension(app_path)
|
19
|
+
invoke Extension
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
5
23
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module SpreeCmd
|
2
|
+
|
3
|
+
class Extension < Thor::Group
|
4
|
+
include Thor::Actions
|
5
|
+
|
6
|
+
desc "builds a spree extension"
|
7
|
+
argument :file_name, :type => :string, :desc => 'rails app_path', :default => '.'
|
8
|
+
|
9
|
+
source_root File.expand_path('../templates/extension', __FILE__)
|
10
|
+
|
11
|
+
def generate
|
12
|
+
use_prefix "spree_"
|
13
|
+
|
14
|
+
empty_directory file_name
|
15
|
+
|
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
|
+
end
|
32
|
+
|
33
|
+
def final_banner
|
34
|
+
say %Q{
|
35
|
+
#{'*' * 80}
|
36
|
+
|
37
|
+
Your extension has been generated with a gemspec dependency on Spree #{spree_version}.
|
38
|
+
|
39
|
+
Please update the Versionfile to designate compatibilty with different versions of Spree.
|
40
|
+
See http://spreecommerce.com/documentation/extensions.html#versionfile
|
41
|
+
|
42
|
+
Consider listing your extension in the official extension registry http://spreecommerce.com/extensions"
|
43
|
+
|
44
|
+
#{'*' * 80}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
no_tasks do
|
49
|
+
def class_name
|
50
|
+
Thor::Util.camel_case file_name
|
51
|
+
end
|
52
|
+
|
53
|
+
def spree_version
|
54
|
+
'1.0.0'
|
55
|
+
end
|
56
|
+
|
57
|
+
def use_prefix(prefix)
|
58
|
+
unless file_name =~ /^#{prefix}/
|
59
|
+
@file_name = prefix + file_name
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
module SpreeCmd
|
2
|
+
|
3
|
+
class Installer < Thor::Group
|
4
|
+
include Thor::Actions
|
5
|
+
|
6
|
+
desc "Creates a new rails project with a spree store"
|
7
|
+
argument :app_path, :type => :string, :desc => 'rails app_path', :default => '.'
|
8
|
+
|
9
|
+
class_option :auto_accept, :type => :boolean, :aliases => '-A', :desc => "Answer yes to all prompts"
|
10
|
+
|
11
|
+
class_option :skip_install_data, :type => :boolean, :default => false,
|
12
|
+
:desc => 'Skip running migrations and loading seed and sample data'
|
13
|
+
|
14
|
+
class_option :version, :type => :string, :default => 'current',
|
15
|
+
:desc => 'Spree Version to use (current, edge, local)'
|
16
|
+
|
17
|
+
class_option :edge, :type => :boolean
|
18
|
+
|
19
|
+
class_option :path, :type => :string, :desc => 'Spree gem path'
|
20
|
+
class_option :git, :type => :string, :desc => 'Spree gem git url'
|
21
|
+
class_option :ref, :type => :string, :desc => 'Spree gem git ref'
|
22
|
+
class_option :branch, :type => :string, :desc => 'Spree gem git branch'
|
23
|
+
class_option :tag, :type => :string, :desc => 'Spree gem git tag'
|
24
|
+
|
25
|
+
def verify_rails
|
26
|
+
unless is_rails_project?
|
27
|
+
say "#{@app_path} rails project not found"
|
28
|
+
exit(1)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def prepare_options
|
33
|
+
@spree_gem_options = {}
|
34
|
+
|
35
|
+
if options[:edge]
|
36
|
+
@spree_gem_options[:git] = 'https://github.com/spree/spree.git'
|
37
|
+
elsif options[:path]
|
38
|
+
@spree_gem_options[:path] = options[:path]
|
39
|
+
elsif options[:git]
|
40
|
+
@spree_gem_options[:git] = options[:git]
|
41
|
+
@spree_gem_options[:ref] = options[:ref] if options[:ref]
|
42
|
+
@spree_gem_options[:branch] = options[:branch] if options[:branch]
|
43
|
+
@spree_gem_options[:tag] = options[:tag] if options[:tag]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def ask_questions
|
48
|
+
@install_blue_theme = ask_with_default("Would you like to install the default blue theme?")
|
49
|
+
@install_default_gateways = ask_with_default("Would you like to install the default gateways?")
|
50
|
+
|
51
|
+
if options[:skip_install_data]
|
52
|
+
@run_migrations = false
|
53
|
+
@load_seed_data = false
|
54
|
+
@load_sample_data = false
|
55
|
+
else
|
56
|
+
@run_migrations = ask_with_default("Would you like to run the migrations?")
|
57
|
+
if @run_migrations
|
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?")
|
60
|
+
else
|
61
|
+
@load_seed_data = false
|
62
|
+
@load_sample_data = false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def add_gems
|
68
|
+
inside @app_path do
|
69
|
+
|
70
|
+
gem :spree, @spree_gem_options
|
71
|
+
|
72
|
+
if @install_blue_theme
|
73
|
+
gem :spree_blue_theme, { :git => 'git://github.com/spree/spree_blue_theme.git',
|
74
|
+
:ref => '10666404ccb3ed4a4cc9cbe41e822ab2bb55112e' }
|
75
|
+
end
|
76
|
+
|
77
|
+
if @install_default_gateways
|
78
|
+
gem :spree_usa_epay, { :git => 'git://github.com/spree/spree_usa_epay.git',
|
79
|
+
:ref => '0cb57b4afbf1eef6a0ad67a4a1ea506c6418fde1' }
|
80
|
+
|
81
|
+
gem :spree_skrill, { :git => 'git://github.com/spree/spree_skrill.git',
|
82
|
+
:ref => '6743bcbd0146d1c7145d6befc648005d8d0cf79a' }
|
83
|
+
end
|
84
|
+
|
85
|
+
run 'bundle install'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def initialize_spree
|
90
|
+
spree_options = []
|
91
|
+
spree_options << "--migrate=#{@run_migrations}"
|
92
|
+
spree_options << "--seed=#{@load_seed_data}"
|
93
|
+
spree_options << "--sample=#{@load_sample_data}"
|
94
|
+
spree_options << "--auto_accept" if options[:auto_accept]
|
95
|
+
|
96
|
+
inside @app_path do
|
97
|
+
run "rails generate spree:install #{spree_options.join(' ')}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def gem(name, options={})
|
104
|
+
say_status :gemfile, name
|
105
|
+
parts = ["'#{name}'"]
|
106
|
+
options.each {|key, value| parts << ":#{key} => '#{value}'" }
|
107
|
+
append_file "Gemfile", "gem #{parts.join(', ')}\n", :verbose => false
|
108
|
+
end
|
109
|
+
|
110
|
+
def ask_with_default(message, default='yes')
|
111
|
+
return true if options[:auto_accept]
|
112
|
+
|
113
|
+
valid = false
|
114
|
+
until valid
|
115
|
+
response = ask "#{message} (yes/no) [#{default}]"
|
116
|
+
response = default if response.empty?
|
117
|
+
valid = (response =~ /\Ay(?:es)?|no?\Z/i)
|
118
|
+
end
|
119
|
+
response.downcase[0] == ?y
|
120
|
+
end
|
121
|
+
|
122
|
+
def create_rails_app
|
123
|
+
say :create, @app_path
|
124
|
+
|
125
|
+
rails_cmd = "rails new #{@app_path} --skip-bundle"
|
126
|
+
if options[:template]
|
127
|
+
rails_cmd += " -m #{options[:template]}"
|
128
|
+
end
|
129
|
+
if options[:database]
|
130
|
+
rails_cmd += " -d #{options[:database]}"
|
131
|
+
end
|
132
|
+
run(rails_cmd)
|
133
|
+
end
|
134
|
+
|
135
|
+
def is_rails_project?
|
136
|
+
File.exists? File.join(@app_path, 'script', 'rails')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) <%= Date.today.year %> [name of plugin creator]
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= class_name %>
|
2
|
+
<%= "=" * class_name.size %>
|
3
|
+
|
4
|
+
Introduction goes here.
|
5
|
+
|
6
|
+
|
7
|
+
Example
|
8
|
+
=======
|
9
|
+
|
10
|
+
Example goes here.
|
11
|
+
|
12
|
+
Testing
|
13
|
+
-------
|
14
|
+
|
15
|
+
Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
$ bundle exec rake test app
|
19
|
+
$ bundle exec rspec spec
|
20
|
+
|
21
|
+
Copyright (c) <%= Date.today.year %> [name of extension creator], released under the New BSD License
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/packagetask'
|
4
|
+
require 'rubygems/package_task'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'spree/core/testing_support/common_rake'
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new
|
9
|
+
|
10
|
+
task :default => [:spec]
|
11
|
+
|
12
|
+
spec = eval(File.read('<%=file_name%>.gemspec'))
|
13
|
+
|
14
|
+
Gem::PackageTask.new(spec) do |p|
|
15
|
+
p.gem_spec = spec
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Release to gemcutter"
|
19
|
+
task :release => :package do
|
20
|
+
require 'rake/gemcutter'
|
21
|
+
Rake::Gemcutter::Tasks.new(spec).define
|
22
|
+
Rake::Task['gem:push'].invoke
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Generates a dummy app for testing"
|
26
|
+
task :test_app do
|
27
|
+
ENV['LIB_NAME'] = '<%=file_name%>'
|
28
|
+
Rake::Task['common:test_app'].invoke
|
29
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# This file is used to designate compatibilty with different versions of Spree
|
2
|
+
# Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
|
3
|
+
|
4
|
+
# Examples
|
5
|
+
#
|
6
|
+
# "0.70.x" => { :branch => "master"}
|
7
|
+
# "0.60.x" => { :branch => "0-60-stable" }
|
8
|
+
# "0.40.x" => { :tag => "v1.0.0", :version => "1.0.0" }
|
9
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require admin/spree_core
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require store/spree_core
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.platform = Gem::Platform::RUBY
|
4
|
+
s.name = '<%= file_name %>'
|
5
|
+
s.version = '<%= spree_version %>'
|
6
|
+
s.summary = 'TODO: Add gem summary here'
|
7
|
+
s.description = 'TODO: Add (optional) gem description here'
|
8
|
+
s.required_ruby_version = '>= 1.8.7'
|
9
|
+
|
10
|
+
# s.author = 'You'
|
11
|
+
# s.email = 'you@example.com'
|
12
|
+
# s.homepage = 'http://www.spreecommerce.com'
|
13
|
+
|
14
|
+
#s.files = `git ls-files`.split("\n")
|
15
|
+
#s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.requirements << 'none'
|
18
|
+
|
19
|
+
s.add_dependency 'spree_core', '~> <%= spree_version %>'
|
20
|
+
|
21
|
+
s.add_development_dependency 'capybara', '1.0.1'
|
22
|
+
s.add_development_dependency 'factory_girl'
|
23
|
+
s.add_development_dependency 'ffaker'
|
24
|
+
s.add_development_dependency 'rspec-rails', '~> 2.7'
|
25
|
+
s.add_development_dependency 'sqlite3'
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module <%= class_name %>
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
engine_name '<%= file_name %>'
|
4
|
+
|
5
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
6
|
+
|
7
|
+
# use rspec for tests
|
8
|
+
config.generators do |g|
|
9
|
+
g.test_framework :rspec
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.activate
|
13
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
|
14
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
config.to_prepare &method(:activate).to_proc
|
19
|
+
end
|
20
|
+
end
|
data/lib/spree_cmd/templates/extension/lib/generators/%file_name%/install/install_generator.rb.tt
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module <%= class_name %>
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
def add_javascripts
|
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
|
+
end
|
9
|
+
|
10
|
+
def add_stylesheets
|
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
|
+
end
|
14
|
+
|
15
|
+
def add_migrations
|
16
|
+
run 'bundle exec rake railties:install:migrations FROM=<%= file_name %>'
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_migrations
|
20
|
+
res = ask "Would you like to run the migrations now? [Y/n]"
|
21
|
+
if res == "" || res.downcase == "y"
|
22
|
+
run 'bundle exec rake db:migrate'
|
23
|
+
else
|
24
|
+
puts "Skiping rake db:migrate, don't forget to run it!"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
|
6
|
+
require 'rspec/rails'
|
7
|
+
|
8
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
9
|
+
# in spec/support/ and its subdirectories.
|
10
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
11
|
+
|
12
|
+
# Requires factories defined in spree_core
|
13
|
+
require 'spree/core/testing_support/factories'
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
# == Mock Framework
|
17
|
+
#
|
18
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
19
|
+
#
|
20
|
+
# config.mock_with :mocha
|
21
|
+
# config.mock_with :flexmock
|
22
|
+
# config.mock_with :rr
|
23
|
+
config.mock_with :rspec
|
24
|
+
|
25
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
26
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
27
|
+
|
28
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
29
|
+
# examples within a transaction, remove the following line or assign false
|
30
|
+
# instead of true.
|
31
|
+
config.use_transactional_fixtures = true
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
2
|
+
# from the project root directory.
|
3
|
+
ENV["RAILS_ENV"] ||= 'test'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.mock_with :rspec
|
7
|
+
|
8
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
9
|
+
|
10
|
+
config.use_transactional_fixtures = false
|
11
|
+
|
12
|
+
end
|
data/spree_cmd.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
|
3
|
+
version = File.read(File.expand_path("../../SPREE_VERSION", __FILE__)).strip
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "spree_cmd"
|
7
|
-
s.version =
|
7
|
+
s.version = version
|
8
8
|
s.authors = ["Chris Mar"]
|
9
9
|
s.email = ["chris@spreecommerce.com"]
|
10
|
-
s.homepage = ""
|
11
|
-
s.summary = %q{
|
12
|
-
s.description = %q{
|
10
|
+
s.homepage = "http://spreecommerce.com"
|
11
|
+
s.summary = %q{Spree Commerce command line utility}
|
12
|
+
s.description = %q{tools to create new Spree stores and extensions}
|
13
13
|
|
14
14
|
s.rubyforge_project = "spree_cmd"
|
15
15
|
|
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency 'rails', '>= 3.1.1'
|
23
|
-
|
22
|
+
s.add_dependency 'rails', '>= 3.1.1', '<= 3.1.3'
|
23
|
+
s.add_development_dependency 'rspec'
|
24
24
|
end
|
metadata
CHANGED
@@ -1,88 +1,105 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_cmd
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 4
|
10
|
-
version: 0.0.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.rc2
|
5
|
+
prerelease: 6
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Chris Mar
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
date: 2012-01-14 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &70095559783600 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.1.1
|
22
|
+
- - <=
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 3.1.3
|
21
25
|
type: :runtime
|
22
26
|
prerelease: false
|
23
|
-
|
27
|
+
version_requirements: *70095559783600
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec
|
30
|
+
requirement: &70095559782920 !ruby/object:Gem::Requirement
|
24
31
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
version_requirements: *id001
|
35
|
-
name: rails
|
36
|
-
description: command line utility to create new stores or add Spree to existing applications
|
37
|
-
email:
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: *70095559782920
|
39
|
+
description: tools to create new Spree stores and extensions
|
40
|
+
email:
|
38
41
|
- chris@spreecommerce.com
|
39
|
-
executables:
|
42
|
+
executables:
|
40
43
|
- spree
|
44
|
+
- spree_cmd
|
41
45
|
extensions: []
|
42
|
-
|
43
46
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
|
46
|
-
- .gitignore
|
47
|
-
- Gemfile
|
47
|
+
files:
|
48
|
+
- LICENSE
|
48
49
|
- README.md
|
49
50
|
- Rakefile
|
50
51
|
- bin/spree
|
52
|
+
- bin/spree_cmd
|
51
53
|
- lib/spree_cmd.rb
|
52
|
-
- lib/spree_cmd/
|
54
|
+
- lib/spree_cmd/extension.rb
|
55
|
+
- lib/spree_cmd/installer.rb
|
56
|
+
- lib/spree_cmd/templates/extension/Gemfile
|
57
|
+
- lib/spree_cmd/templates/extension/LICENSE
|
58
|
+
- lib/spree_cmd/templates/extension/README.md
|
59
|
+
- lib/spree_cmd/templates/extension/Rakefile
|
60
|
+
- lib/spree_cmd/templates/extension/Versionfile
|
61
|
+
- lib/spree_cmd/templates/extension/app/assets/javascripts/admin/%file_name%.js
|
62
|
+
- lib/spree_cmd/templates/extension/app/assets/javascripts/store/%file_name%.js
|
63
|
+
- lib/spree_cmd/templates/extension/app/assets/stylesheets/admin/%file_name%.css
|
64
|
+
- lib/spree_cmd/templates/extension/app/assets/stylesheets/store/%file_name%.css
|
65
|
+
- lib/spree_cmd/templates/extension/config/locales/en.yml
|
66
|
+
- lib/spree_cmd/templates/extension/config/routes.rb
|
67
|
+
- lib/spree_cmd/templates/extension/extension.gemspec
|
68
|
+
- lib/spree_cmd/templates/extension/gitignore
|
69
|
+
- lib/spree_cmd/templates/extension/lib/%file_name%.rb.tt
|
70
|
+
- lib/spree_cmd/templates/extension/lib/%file_name%/engine.rb.tt
|
71
|
+
- lib/spree_cmd/templates/extension/lib/generators/%file_name%/install/install_generator.rb.tt
|
72
|
+
- lib/spree_cmd/templates/extension/rspec
|
73
|
+
- lib/spree_cmd/templates/extension/script/rails.tt
|
74
|
+
- lib/spree_cmd/templates/extension/spec/spec_helper.rb.tt
|
75
|
+
- spec/spec_helper.rb
|
53
76
|
- spree_cmd.gemspec
|
54
|
-
homepage:
|
77
|
+
homepage: http://spreecommerce.com
|
55
78
|
licenses: []
|
56
|
-
|
57
79
|
post_install_message:
|
58
80
|
rdoc_options: []
|
59
|
-
|
60
|
-
require_paths:
|
81
|
+
require_paths:
|
61
82
|
- lib
|
62
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
84
|
none: false
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
|
68
|
-
segments:
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
segments:
|
69
90
|
- 0
|
70
|
-
|
71
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
hash: 260406061965751448
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
93
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
version: "0"
|
94
|
+
requirements:
|
95
|
+
- - ! '>'
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.3.1
|
80
98
|
requirements: []
|
81
|
-
|
82
99
|
rubyforge_project: spree_cmd
|
83
100
|
rubygems_version: 1.8.10
|
84
101
|
signing_key:
|
85
102
|
specification_version: 3
|
86
|
-
summary:
|
87
|
-
test_files:
|
88
|
-
|
103
|
+
summary: Spree Commerce command line utility
|
104
|
+
test_files:
|
105
|
+
- spec/spec_helper.rb
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/lib/spree_cmd/version.rb
DELETED