Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/mock
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ helpers.testDirectory(outputDir, function(err) {
ssl: true,
name: 'Example.com',
domain: 'example.com',
www: false,
roles: WordpressGenerator.roles.map(function(role) { return role.value; }),
ip: '192.168.137.137',
DB_NAME: 'example_db',
Expand Down
33 changes: 33 additions & 0 deletions lib/yeoman/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,39 @@ var WordpressGenerator = yeoman.generators.Base.extend({
});
},

promptForWww: function() {
var choices = [
{
name: 'No, just the domain',
value: false,
},
{
name: 'Yes, www is preferred',
value: true,
},
];
var existing = function() {
try {
var match = this.readFileAsString(path.join(this.env.cwd, 'lib', 'ansible', 'group_vars', 'all'))
.match(/www[ ]*:[ ]*(true)/i);

return match[1];
} catch(e) {};
}.bind(this);

if(existing()) {
choices.reverse();
}

this.prompts.push({
required: true,
type: 'list',
name: 'www',
message: 'Should this site enforce a www subdomain in production? (e.g. www.mysite.com)',
choices: choices
});
},

promptForRoles: function() {
try {
var provisionYml = this.readFileAsString(path.join(this.env.cwd, 'lib', 'ansible', 'provision.yml'));
Expand Down
1 change: 1 addition & 0 deletions lib/yeoman/templates/lib/ansible/group_vars/all
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
evolve_version: <%= pkg.version %>
domain: <%= props.domain %>
www: <%= props.www %>

mysql:
name: <%= props.DB_NAME %>
Expand Down
1 change: 1 addition & 0 deletions lib/yeoman/templates/lib/capistrano/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
set :deploy_to, "/var/www/#{fetch(:domain)}/#{fetch(:stage)}/#{fetch(:branch)}"
set :linked_dirs, %w{web/wp-content/uploads}
set :wp_path, "#{release_path}/web/wp"
set :www, <%= props.www ? 'true' : 'false' %>

namespace :deploy do
after :updated, :bower_install do
Expand Down
4 changes: 4 additions & 0 deletions lib/yeoman/templates/web/_htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Force <%= props.www ? '' : 'non-' %>www for production
RewriteCond %{HTTP_HOST} ^<%= props.www ? '' : 'www\\.' %><%= props.domain.replace('.', '\\.') %>$ [NC]
RewriteCond %{HTTP:X-Forwarded-Proto} ^http(s)| [NC]
RewriteRule ^(.*)$ http%1://<%= props.www ? 'www.' : '' %><%= props.domain %>/$1 [L,R=301,NC]
# Prevent spidering of non-canonical URLs, such as `[*.]staging.*` and `production.*`.
RewriteCond %{HTTP_HOST} (^local|staging|^production)\.<%= props.domain.replace('.', '\\.') %>$ [NC]
RewriteRule ^robots.txt$ no_robots.txt [L]
Expand Down