marv 0.2.5 → 0.3.0
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/.rspec +1 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +3 -4
- data/Gemfile.lock +70 -28
- data/LICENSE +24 -0
- data/Rakefile +7 -1
- data/VERSION +1 -1
- data/layouts/bramble/functions/functions.php.erb +12 -12
- data/layouts/bramble/includes/options.php.erb +4 -4
- data/layouts/config/{config.tt → project-config.rb} +4 -1
- data/layouts/config/rack-config.ru +38 -0
- data/layouts/config/wp-config.php.erb +105 -0
- data/layouts/default/functions/functions.php.erb +25 -25
- data/layouts/default/includes/filters-admin.php.erb +8 -8
- data/layouts/default/includes/filters.php.erb +11 -11
- data/layouts/default/includes/helpers.php.erb +1 -1
- data/layouts/default/templates/404.php.erb +2 -2
- data/layouts/default/templates/archive.php.erb +5 -5
- data/layouts/default/templates/author.php.erb +1 -1
- data/layouts/default/templates/partials/comments.php.erb +8 -8
- data/layouts/default/templates/partials/content-none.php.erb +3 -3
- data/layouts/default/templates/partials/content.php.erb +2 -2
- data/layouts/default/templates/partials/searchform.php.erb +3 -3
- data/layouts/default/templates/search.php.erb +2 -2
- data/lib/guard/marv/assets.rb +11 -3
- data/lib/guard/marv/config.rb +2 -0
- data/lib/guard/marv/folders.rb +37 -0
- data/lib/guard/marv/functions.rb +13 -9
- data/lib/guard/marv/templates.rb +12 -3
- data/lib/marv.rb +1 -0
- data/lib/marv/builder.rb +49 -15
- data/lib/marv/cli.rb +135 -10
- data/lib/marv/engines.rb +3 -1
- data/lib/marv/generator.rb +13 -8
- data/lib/marv/guard.rb +4 -1
- data/lib/marv/project.rb +18 -10
- data/lib/marv/server.rb +301 -0
- data/lib/marv/version.rb +1 -1
- data/marv.gemspec +18 -16
- data/spec/lib/marv/project_spec.rb +3 -4
- metadata +27 -38
@@ -1,17 +1,17 @@
|
|
1
1
|
<div class="no-results not-found">
|
2
2
|
<header class="page-header">
|
3
|
-
<h1 class="page-title"><?php _e( 'Nothing Found', '<%=
|
3
|
+
<h1 class="page-title"><?php _e( 'Nothing Found', '<%= project_id %>' ); ?></h1>
|
4
4
|
</header>
|
5
5
|
|
6
6
|
<div class="page-content">
|
7
7
|
<?php if( is_search() ) : ?>
|
8
8
|
|
9
|
-
<p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', '<%=
|
9
|
+
<p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', '<%= project_id %>' ); ?></p>
|
10
10
|
<?php get_search_form(); ?>
|
11
11
|
|
12
12
|
<?php else : ?>
|
13
13
|
|
14
|
-
<p><?php _e( 'It seems we can’t find what you’re looking for. Perhaps searching can help.', '<%=
|
14
|
+
<p><?php _e( 'It seems we can’t find what you’re looking for. Perhaps searching can help.', '<%= project_id %>' ); ?></p>
|
15
15
|
<?php get_search_form(); ?>
|
16
16
|
|
17
17
|
<?php endif; ?>
|
@@ -6,11 +6,11 @@
|
|
6
6
|
<?php if ( is_search() ) : ?>
|
7
7
|
<div class="entry-summary">
|
8
8
|
<?php the_excerpt(); ?>
|
9
|
-
<a href="<?php the_permalink(); ?>"><?php _e('Read more', '<%=
|
9
|
+
<a href="<?php the_permalink(); ?>"><?php _e('Read more', '<%= project_id %>') ?></a>
|
10
10
|
</div>
|
11
11
|
<?php else : ?>
|
12
12
|
<div class="entry-content">
|
13
|
-
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', '<%=
|
13
|
+
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', '<%= project_id %>' ) ); ?>
|
14
14
|
</div>
|
15
15
|
<?php endif; ?>
|
16
16
|
</div>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
|
2
|
-
<label for="s" class="assistive-text"><?php _e( 'Search', '<%=
|
3
|
-
<input type="text" class="field" name="s" id="s" placeholder="<?php esc_attr_e( 'Search', '<%=
|
4
|
-
<button type="submit" class="submit" name="submit" id="searchsubmit"><?php _e( 'Search', '<%=
|
2
|
+
<label for="s" class="assistive-text"><?php _e( 'Search', '<%= project_id %>' ); ?></label>
|
3
|
+
<input type="text" class="field" name="s" id="s" placeholder="<?php esc_attr_e( 'Search', '<%= project_id %>' ); ?>" />
|
4
|
+
<button type="submit" class="submit" name="submit" id="searchsubmit"><?php _e( 'Search', '<%= project_id %>' ); ?></button>
|
5
5
|
</form>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<?php if ( have_posts() ) : ?>
|
6
6
|
|
7
7
|
<header class="page-header">
|
8
|
-
<h1 class="page-title"><?php printf( __( 'Search Results for: %s', '<%=
|
8
|
+
<h1 class="page-title"><?php printf( __( 'Search Results for: %s', '<%= project_id %>' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
|
9
9
|
</header>
|
10
10
|
|
11
11
|
<?php while ( have_posts() ) : the_post(); ?>
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
<?php endwhile; ?>
|
16
16
|
|
17
|
-
<?php <%=
|
17
|
+
<?php <%= project_id %>_paging_nav(); ?>
|
18
18
|
|
19
19
|
<?php else : ?>
|
20
20
|
|
data/lib/guard/marv/assets.rb
CHANGED
@@ -10,22 +10,30 @@ module Guard
|
|
10
10
|
|
11
11
|
def start
|
12
12
|
UI.info "Building all assets"
|
13
|
-
|
13
|
+
build_assets
|
14
14
|
end
|
15
15
|
|
16
16
|
# Called on Ctrl-\ signal
|
17
17
|
# This method should be principally used for long action like running all specs/tests/...
|
18
18
|
def run_all
|
19
19
|
UI.info "Rebuilding all assets"
|
20
|
-
|
21
|
-
::Marv::Guard.builder.build_assets
|
20
|
+
clean_build_assets
|
22
21
|
end
|
23
22
|
|
24
23
|
# Called on file(s) modifications
|
25
24
|
def run_on_change(paths)
|
26
25
|
UI.info "Assets have changed, rebuilding..."
|
26
|
+
clean_build_assets
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_assets
|
30
|
+
::Marv::Guard.builder.build_assets
|
31
|
+
end
|
32
|
+
|
33
|
+
def clean_build_assets
|
27
34
|
::Marv::Guard.builder.clean_images
|
28
35
|
::Marv::Guard.builder.build_assets
|
29
36
|
end
|
37
|
+
|
30
38
|
end
|
31
39
|
end
|
data/lib/guard/marv/config.rb
CHANGED
@@ -3,6 +3,7 @@ require 'guard/guard'
|
|
3
3
|
|
4
4
|
module Guard
|
5
5
|
class MarvConfig < ::Guard::Guard
|
6
|
+
|
6
7
|
def initialize(watchers=[], options={})
|
7
8
|
super
|
8
9
|
end
|
@@ -30,5 +31,6 @@ module Guard
|
|
30
31
|
# Rebuild everything if the config changes
|
31
32
|
::Marv::Guard.builder.build
|
32
33
|
end
|
34
|
+
|
33
35
|
end
|
34
36
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
|
4
|
+
module Guard
|
5
|
+
class MarvFolders < ::Guard::Guard
|
6
|
+
|
7
|
+
def initialize(watchers=[], options={})
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def start
|
12
|
+
UI.info "Copying folders over"
|
13
|
+
copy_folders
|
14
|
+
end
|
15
|
+
|
16
|
+
def run_all
|
17
|
+
UI.info "Rebuilding all folders"
|
18
|
+
clean_copy_folders
|
19
|
+
end
|
20
|
+
|
21
|
+
# Called on file(s) modifications
|
22
|
+
def run_on_change(paths)
|
23
|
+
UI.info "Folders have changed, copying over"
|
24
|
+
clean_copy_folders
|
25
|
+
end
|
26
|
+
|
27
|
+
def copy_folders
|
28
|
+
::Marv::Guard.builder.copy_folders
|
29
|
+
end
|
30
|
+
|
31
|
+
def clean_copy_folders
|
32
|
+
::Marv::Guard.builder.clean_folders
|
33
|
+
::Marv::Guard.builder.copy_folders
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/guard/marv/functions.rb
CHANGED
@@ -3,34 +3,38 @@ require 'guard/guard'
|
|
3
3
|
|
4
4
|
module Guard
|
5
5
|
class MarvFunctions < ::Guard::Guard
|
6
|
+
|
6
7
|
def initialize(watchers=[], options={})
|
7
8
|
super
|
8
9
|
end
|
9
10
|
|
10
11
|
def start
|
11
12
|
UI.info "Copying functions over"
|
12
|
-
|
13
|
-
::Marv::Guard.builder.copy_includes
|
14
|
-
::Marv::Guard.builder.copy_extras
|
13
|
+
copy_functions
|
15
14
|
end
|
16
15
|
|
17
16
|
def run_all
|
18
17
|
UI.info "Rebuilding all functions"
|
19
|
-
|
20
|
-
::Marv::Guard.builder.copy_functions
|
21
|
-
::Marv::Guard.builder.clean_includes
|
22
|
-
::Marv::Guard.builder.copy_includes
|
23
|
-
::Marv::Guard.builder.copy_extras
|
18
|
+
clean_copy_functions
|
24
19
|
end
|
25
20
|
|
26
21
|
# Called on file(s) modifications
|
27
22
|
def run_on_change(paths)
|
28
23
|
UI.info "Functions have changed, copying over"
|
24
|
+
clean_copy_functions
|
25
|
+
end
|
26
|
+
|
27
|
+
def copy_functions
|
28
|
+
::Marv::Guard.builder.copy_functions
|
29
|
+
::Marv::Guard.builder.copy_includes
|
30
|
+
end
|
31
|
+
|
32
|
+
def clean_copy_functions
|
29
33
|
::Marv::Guard.builder.clean_functions
|
30
34
|
::Marv::Guard.builder.copy_functions
|
31
35
|
::Marv::Guard.builder.clean_includes
|
32
36
|
::Marv::Guard.builder.copy_includes
|
33
|
-
::Marv::Guard.builder.copy_extras
|
34
37
|
end
|
38
|
+
|
35
39
|
end
|
36
40
|
end
|
data/lib/guard/marv/templates.rb
CHANGED
@@ -3,26 +3,35 @@ require 'guard/guard'
|
|
3
3
|
|
4
4
|
module Guard
|
5
5
|
class MarvTemplates < ::Guard::Guard
|
6
|
+
|
6
7
|
def initialize(watchers=[], options={})
|
7
8
|
super
|
8
9
|
end
|
9
10
|
|
10
11
|
def start
|
11
12
|
UI.info "Copying templates over"
|
12
|
-
|
13
|
+
copy_templates
|
13
14
|
end
|
14
15
|
|
15
16
|
def run_all
|
16
17
|
UI.info "Rebuilding all templates"
|
17
|
-
|
18
|
-
::Marv::Guard.builder.copy_templates
|
18
|
+
clean_copy_templates
|
19
19
|
end
|
20
20
|
|
21
21
|
# Called on file(s) modifications
|
22
22
|
def run_on_change(paths)
|
23
23
|
UI.info "Templates have changed, copying over"
|
24
|
+
clean_copy_templates
|
25
|
+
end
|
26
|
+
|
27
|
+
def copy_templates
|
28
|
+
::Marv::Guard.builder.copy_templates
|
29
|
+
end
|
30
|
+
|
31
|
+
def clean_copy_templates
|
24
32
|
::Marv::Guard.builder.clean_templates
|
25
33
|
::Marv::Guard.builder.copy_templates
|
26
34
|
end
|
35
|
+
|
27
36
|
end
|
28
37
|
end
|
data/lib/marv.rb
CHANGED
data/lib/marv/builder.rb
CHANGED
@@ -6,6 +6,7 @@ require 'marv/engines'
|
|
6
6
|
|
7
7
|
module Marv
|
8
8
|
class Builder
|
9
|
+
|
9
10
|
def initialize(project)
|
10
11
|
@project = project
|
11
12
|
@task = project.task
|
@@ -13,7 +14,6 @@ module Marv
|
|
13
14
|
@assets_path = @project.assets_path
|
14
15
|
@functions_path = @project.functions_path
|
15
16
|
@includes_path = @project.includes_path
|
16
|
-
@extras_path = @project.extras_path
|
17
17
|
@package_path = @project.package_path
|
18
18
|
|
19
19
|
init_sprockets
|
@@ -25,7 +25,7 @@ module Marv
|
|
25
25
|
copy_templates
|
26
26
|
copy_functions
|
27
27
|
copy_includes
|
28
|
-
|
28
|
+
copy_folders
|
29
29
|
build_assets
|
30
30
|
end
|
31
31
|
|
@@ -97,13 +97,18 @@ module Marv
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def clean_functions
|
100
|
-
|
101
|
-
FileUtils.
|
100
|
+
#remove functions php
|
101
|
+
FileUtils.rm File.join(@project.build_path, 'functions.php') if File.exists?(File.join(@project.build_path, 'functions.php'))
|
102
|
+
# Remove plugin file
|
103
|
+
FileUtils.rm File.join(@project.build_path, @project.project_php_file) if File.exists?(@project.project_php_file)
|
104
|
+
# Remove functions folder
|
105
|
+
FileUtils.rm_rf File.join(@project.build_path, 'functions') if File.directory?(File.join(@project.build_path, 'functions'))
|
102
106
|
end
|
103
107
|
|
104
108
|
def copy_functions
|
105
109
|
functions_erb_path = File.join(@functions_path, 'functions.php.erb')
|
106
110
|
functions_php_path = File.join(@functions_path, 'functions.php')
|
111
|
+
plugin_php_path = File.join(@functions_path, @project.project_php_file)
|
107
112
|
|
108
113
|
if File.exists?(functions_erb_path)
|
109
114
|
destination = File.join(@project.build_path, 'functions.php')
|
@@ -112,8 +117,12 @@ module Marv
|
|
112
117
|
FileUtils.cp functions_php_path, @project.build_path
|
113
118
|
end
|
114
119
|
|
120
|
+
if File.exists?(plugin_php_path)
|
121
|
+
FileUtils.cp plugin_php_path, @project.build_path
|
122
|
+
end
|
123
|
+
|
115
124
|
functions_paths = Dir.glob(File.join(@functions_path, '*')).reject do |filename|
|
116
|
-
[functions_erb_path, functions_php_path].include?(filename)
|
125
|
+
[functions_erb_path, functions_php_path, plugin_php_path].include?(filename)
|
117
126
|
end
|
118
127
|
|
119
128
|
unless functions_paths.empty?
|
@@ -121,7 +130,7 @@ module Marv
|
|
121
130
|
FileUtils.mkdir_p(File.join(@project.build_path, 'functions'))
|
122
131
|
|
123
132
|
# Iterate over all files in source/functions, skipping the actual functions.php file
|
124
|
-
paths = Dir.glob(File.join(@functions_path, '**', '*')).reject {|filename| [functions_erb_path, functions_php_path].include?(filename) }
|
133
|
+
paths = Dir.glob(File.join(@functions_path, '**', '*')).reject {|filename| [functions_erb_path, functions_php_path, plugin_php_path].include?(filename) }
|
125
134
|
|
126
135
|
copy_paths_with_erb(paths, @functions_path, File.join(@project.build_path, 'functions'))
|
127
136
|
end
|
@@ -142,12 +151,27 @@ module Marv
|
|
142
151
|
end
|
143
152
|
end
|
144
153
|
|
145
|
-
def
|
146
|
-
|
154
|
+
def clean_folders
|
155
|
+
Dir.glob(File.join(@project.source_path, '*')).each do |folder|
|
156
|
+
unless [@assets_path, @templates_path, @functions_path, @includes_path].include?(folder)
|
157
|
+
if File.directory?(folder)
|
158
|
+
relative_path = folder.gsub(@project.source_path, '')
|
159
|
+
destination = File.join(@project.build_path, relative_path)
|
147
160
|
|
148
|
-
|
149
|
-
|
150
|
-
|
161
|
+
FileUtils.rm_rf destination
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def copy_folders
|
168
|
+
Dir.glob(File.join(@project.source_path, '*')).each do |folder|
|
169
|
+
unless [@assets_path, @templates_path, @functions_path, @includes_path].include?(folder)
|
170
|
+
if File.directory?(folder)
|
171
|
+
paths = Dir.glob(File.join(folder, '**', '*'))
|
172
|
+
copy_paths_with_erb(paths, @project.source_path, @project.build_path)
|
173
|
+
end
|
174
|
+
end
|
151
175
|
end
|
152
176
|
end
|
153
177
|
|
@@ -156,7 +180,16 @@ module Marv
|
|
156
180
|
end
|
157
181
|
|
158
182
|
def build_assets
|
159
|
-
[['style.css'], ['admin.css'], ['javascripts', 'theme.js'], ['javascripts', 'admin.js']]
|
183
|
+
default_assets = [['style.css'], ['admin.css'], ['javascripts', 'theme.js'], ['javascripts', 'admin.js']]
|
184
|
+
additional_assets = @project.config[:additional_assets]
|
185
|
+
|
186
|
+
if additional_assets
|
187
|
+
assets = default_assets + additional_assets
|
188
|
+
else
|
189
|
+
assets = default_assets
|
190
|
+
end
|
191
|
+
|
192
|
+
assets.each do |asset|
|
160
193
|
destination = File.join(@project.build_path, asset)
|
161
194
|
|
162
195
|
# Catch any sprockets errors and continue the process
|
@@ -169,7 +202,7 @@ module Marv
|
|
169
202
|
end
|
170
203
|
rescue Exception => e
|
171
204
|
@task.say "Error while building #{asset.last}:"
|
172
|
-
@task.say e.message,
|
205
|
+
@task.say e.message, :red
|
173
206
|
|
174
207
|
File.open(destination, 'w') do |file|
|
175
208
|
file.puts(e.message)
|
@@ -273,9 +306,10 @@ module Marv
|
|
273
306
|
end
|
274
307
|
rescue Exception => e
|
275
308
|
@task.say "Error while building #{File.basename(source)}:"
|
276
|
-
@task.say e.message + "\n",
|
309
|
+
@task.say e.message + "\n", :red
|
277
310
|
exit
|
278
|
-
|
311
|
+
end
|
279
312
|
end
|
313
|
+
|
280
314
|
end
|
281
315
|
end
|
data/lib/marv/cli.rb
CHANGED
@@ -3,38 +3,68 @@ require 'guard/marv/assets'
|
|
3
3
|
require 'guard/marv/config'
|
4
4
|
require 'guard/marv/templates'
|
5
5
|
require 'guard/marv/functions'
|
6
|
+
require 'guard/marv/folders'
|
6
7
|
|
7
8
|
module Marv
|
8
9
|
class CLI < Thor
|
10
|
+
|
9
11
|
include Thor::Actions
|
10
12
|
|
11
13
|
def self.source_root
|
12
14
|
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'layouts'))
|
13
15
|
end
|
14
16
|
|
15
|
-
desc "create DIRECTORY", "Creates a Marv project"
|
17
|
+
desc "create DIRECTORY", "Creates a Marv project into specified directory"
|
16
18
|
long_desc "Creates a new project. Use the layout option to choose a scaffold"
|
17
19
|
method_option :layout, :type => :string, :default => 'default', :desc => "Name of alternate layout"
|
20
|
+
method_option :local, :type => :boolean, :force => false, :desc => "Use local layout from .marv folder"
|
18
21
|
def create(dir)
|
19
22
|
theme = {}
|
20
23
|
theme[:name] = dir
|
21
24
|
|
22
|
-
project = Marv::Project.create(dir, theme, self, options[:layout])
|
25
|
+
project = Marv::Project.create(dir, theme, self, options[:layout], options[:local])
|
23
26
|
end
|
24
27
|
|
25
|
-
desc "link
|
26
|
-
long_desc "This command will symlink the compiled version of the
|
27
|
-
|
28
|
-
|
28
|
+
desc "link SERVER", "Create a symbolic link to the compilation directory"
|
29
|
+
long_desc "This command will symlink the compiled version of the project to the specified server or WordPress install path"
|
30
|
+
method_option :folder, :type => :string, :aliases => "-f" , :enum => %w{themes plugins}, :required => true, :desc => "Link Marv project in themes or plugins folfer"
|
31
|
+
method_option :global, :type => :boolean, :aliases => "-g" , :force => false, :desc => "Link Marv project in global folder"
|
32
|
+
method_option :path, :type => :string, :aliases => "-p" , :desc => "Create a symbolic link to a WordPress folder"
|
33
|
+
def link(server=nil)
|
29
34
|
project = Marv::Project.new('.', self)
|
35
|
+
project_folder = project.project_id.gsub('_', '-')
|
30
36
|
|
31
37
|
FileUtils.mkdir_p project.build_path unless File.directory?(project.build_path)
|
32
38
|
|
33
|
-
|
39
|
+
unless server.nil?
|
40
|
+
server_path = File.join(ENV['HOME'], '.marv', 'servers', server, 'wp-content', options[:folder])
|
41
|
+
|
42
|
+
unless options[:global]
|
43
|
+
do_link(project, File.join(server_path, project_folder))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
if options[:global]
|
48
|
+
global_folder = File.join(ENV['HOME'], '.marv', options[:folder])
|
49
|
+
FileUtils.mkdir_p global_folder unless File.directory?(global_folder)
|
50
|
+
|
51
|
+
do_link(project, File.join(global_folder, project_folder))
|
52
|
+
|
53
|
+
servers = Dir.glob(File.join(ENV['HOME'], '.marv', 'servers' , '*'))
|
54
|
+
|
55
|
+
servers.each do |server|
|
56
|
+
shell.mute { do_link(project, File.join(server, 'wp-content', options[:folder], project_folder)) }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
if options[:path]
|
61
|
+
wp_path = File.join(options[:path], 'wp-content', options[:folder])
|
62
|
+
do_link(project, File.join(wp_path, project_folder))
|
63
|
+
end
|
34
64
|
end
|
35
65
|
|
36
66
|
desc "watch", "Start watch process"
|
37
|
-
long_desc "Watches the source directory in your project for changes, and reflects those changes in a compile folder"
|
67
|
+
long_desc "Watches the source directory in your Marv project for changes, and reflects those changes in a compile folder"
|
38
68
|
method_option :config, :type => :string, :desc => "Name of alternate config file"
|
39
69
|
def watch
|
40
70
|
project = Marv::Project.new('.', self, nil, options[:config])
|
@@ -61,7 +91,7 @@ module Marv
|
|
61
91
|
directory(project.build_path, dir)
|
62
92
|
end
|
63
93
|
|
64
|
-
desc "package FILENAME", "Compile and zip your project to FILENAME.zip"
|
94
|
+
desc "package FILENAME", "Compile and zip your Marv project to FILENAME.zip"
|
65
95
|
method_option :config, :type => :string, :desc => "Name of alternate config file"
|
66
96
|
def package(filename=nil)
|
67
97
|
project = Marv::Project.new('.', self, nil, options[:config])
|
@@ -71,8 +101,102 @@ module Marv
|
|
71
101
|
builder.zip(filename)
|
72
102
|
end
|
73
103
|
|
104
|
+
desc "server SERVER", "Start a Marv server by name"
|
105
|
+
method_option :create, :type => :boolean, :aliases => "-c" , :force => false, :desc => "Create a new Marv server"
|
106
|
+
method_option :stop, :type => :boolean, :aliases => "-s" , :force => false, :desc => "Stop a running Marv server"
|
107
|
+
method_option :restart, :type => :boolean, :aliases => "-r" , :force => false, :desc => "Restart a Marv server"
|
108
|
+
# method_option :backup, :type => :boolean, :force => false, :desc => "Backup a Marv server"
|
109
|
+
# method_option :restore, :type => :boolean, :force => false, :desc => "Restore a Marv server"
|
110
|
+
method_option :remove, :type => :boolean, :force => false, :desc => "Remove a Marv server"
|
111
|
+
def server(name)
|
112
|
+
config = {}
|
113
|
+
|
114
|
+
if options[:create]
|
115
|
+
say "This will create a new Marv server with WordPress installed:", :green
|
116
|
+
config[:user] = ask("Mysql username:", nil, {:default => "root"})
|
117
|
+
config[:password] = ask("Mysql user password:", nil, {:default => "required"})
|
118
|
+
config[:host] = ask("Mysql host:", nil, {:default => "localhost"})
|
119
|
+
config[:port] = ask("Mysql port:", nil, {:default => "3306"})
|
120
|
+
config[:version] = ask("WordPress version:", nil, {:default => "latest"})
|
121
|
+
|
122
|
+
server = Marv::Server.new(name, self, config)
|
123
|
+
server.create_server
|
124
|
+
else
|
125
|
+
server = Marv::Server.new(name, self, nil)
|
126
|
+
|
127
|
+
if options.empty?
|
128
|
+
server.start_server
|
129
|
+
end
|
130
|
+
|
131
|
+
if options[:stop]
|
132
|
+
server.stop_server
|
133
|
+
end
|
134
|
+
|
135
|
+
if options[:restart]
|
136
|
+
server.restart_server
|
137
|
+
end
|
138
|
+
|
139
|
+
if options[:remove]
|
140
|
+
say "This will remove the specified Marv server:", :green
|
141
|
+
config[:user] = ask("Mysql username:", nil, {:default => "root"})
|
142
|
+
config[:password] = ask("Mysql user password:", nil, {:default => "required"})
|
143
|
+
config[:host] = ask("Mysql host:", nil, {:default => "localhost"})
|
144
|
+
config[:port] = ask("Mysql port:", nil, {:default => "3306"})
|
145
|
+
config[:version] = "latest"
|
146
|
+
|
147
|
+
server = Marv::Server.new(name, self, config)
|
148
|
+
server.remove_server
|
149
|
+
end
|
150
|
+
end
|
151
|
+
exit
|
152
|
+
end
|
153
|
+
|
154
|
+
desc "servers OPTION", "List all available Marv servers"
|
155
|
+
method_option :remove, :type => :boolean, :force => false, :desc => "Remove all Marv servers"
|
156
|
+
# method_option :backup, :type => :boolean, :force => false, :desc => "Backup existing Marv servers"
|
157
|
+
# method_option :restore, :type => :boolean, :force => false, :desc => "Restore Marv servers from backup file"
|
158
|
+
def servers
|
159
|
+
if options.empty?
|
160
|
+
list_all_servers
|
161
|
+
end
|
162
|
+
|
163
|
+
if options[:remove]
|
164
|
+
config = {}
|
165
|
+
|
166
|
+
say "This will remove all available Marv servers:", :green
|
167
|
+
config[:user] = ask("Mysql username:", nil, {:default => "root"})
|
168
|
+
config[:password] = ask("Mysql user password:", nil, {:default => "required"})
|
169
|
+
config[:host] = ask("Mysql host:", nil, {:default => "localhost"})
|
170
|
+
config[:port] = ask("Mysql port:", nil, {:default => "3306"})
|
171
|
+
config[:version] = "latest"
|
172
|
+
|
173
|
+
remove_all_servers(config)
|
174
|
+
end
|
175
|
+
exit
|
176
|
+
end
|
177
|
+
|
74
178
|
protected
|
75
179
|
|
180
|
+
def list_all_servers
|
181
|
+
servers_root = File.join(ENV['HOME'], '.marv', 'servers')
|
182
|
+
servers = Dir.glob(File.join(servers_root, '*'))
|
183
|
+
|
184
|
+
servers.each do |server|
|
185
|
+
say "Available marv servers:", :yellow
|
186
|
+
say '- ' + File.basename(server), :green
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def remove_all_servers(config)
|
191
|
+
servers_root = File.join(ENV['HOME'], '.marv', 'servers')
|
192
|
+
servers = Dir.glob(File.join(servers_root, '*'))
|
193
|
+
|
194
|
+
servers.each do |server|
|
195
|
+
server = Marv::Server.new(File.basename(server), self, config)
|
196
|
+
server.remove_server
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
76
200
|
def do_link(project, path)
|
77
201
|
begin
|
78
202
|
project.link(path)
|
@@ -80,9 +204,10 @@ module Marv
|
|
80
204
|
say_status :error, "The path #{File.dirname(path)} does not exist", :red
|
81
205
|
exit 2
|
82
206
|
rescue Errno::EEXIST
|
83
|
-
say_status :error, "The path #{path} already
|
207
|
+
say_status :error, "The path #{path} already exists", :red
|
84
208
|
exit 2
|
85
209
|
end
|
86
210
|
end
|
211
|
+
|
87
212
|
end
|
88
213
|
end
|