From 5afaf80cf8740784a46a2d47157b6c6835453c42 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 16:02:44 -0600 Subject: [PATCH 01/31] Revert "Merge pull request #82 from AntJanus/67-move-events-after-deploy" This reverts commit 6b4c20cafe06eb085b7043c287e35eb51f1f39a4, reversing changes made to 63a9d21ee3147e41e4ed474efc34313ac98463e1. --- deployment/lib/events.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/deployment/lib/events.rb b/deployment/lib/events.rb index ee4bc78..3b78cb0 100644 --- a/deployment/lib/events.rb +++ b/deployment/lib/events.rb @@ -2,15 +2,15 @@ deploy.setup end -after "deploy:update_code" do +after "deploy:update" do run "cd #{release_path} && bower install" end -after "deploy:finalize_update", "genesis:permissions" -after "genesis:up:files", "genesis:permissions" +after "deploy:update", "genesis:permissions" +after "genesis:up:files", "genesis:permissions" -after "deploy:restart", "genesis:restart" -after "genesis:provision", "genesis:restart" -after "genesis:up", "genesis:restart" -after "genesis:up:db", "genesis:restart" -after "genesis:up:files", "genesis:restart" +after "deploy:restart", "genesis:restart" +after "genesis:provision", "genesis:restart" +after "genesis:up", "genesis:restart" +after "genesis:up:db", "genesis:restart" +after "genesis:up:files", "genesis:restart" From 64cc1db6543982e157d8ddddfcacc88f4cb84b7d Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 22:17:11 -0600 Subject: [PATCH 02/31] Generated test site correctly uses local & mounted library --- test/support/generator.js | 60 +++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/test/support/generator.js b/test/support/generator.js index bccc13e..60155b7 100644 --- a/test/support/generator.js +++ b/test/support/generator.js @@ -1,15 +1,25 @@ -#!/usr/bin/env node - +var fs = require('fs'); var hooker = require('hooker'); -var path = require('path'); var helpers = require('yeoman-generator').test; +var path = require('path'); -var Generator = function() {}; +var Generator = function(outputDir) { + this.outputDir = __dirname + '/../temp'; +}; Generator.prototype.create = function() { this.app = helpers.createGenerator('genesis-wordpress:app', [ [require('../../generator/app'), 'genesis-wordpress:app'] ]); + + this.app.options['skip-install'] = true; +}; + +Generator.prototype.prepare = function() { + this.privatePath = this.outputDir + '/provisioning/files/ssh/id_rsa'; + this.privateKey = fs.existsSync(this.privatePath) ? fs.readFileSync(this.privatePath) : null; + this.publicPath = this.outputDir + '/provisioning/files/ssh/id_rsa.pub'; + this.publicKey = fs.existsSync(this.publicPath) ? fs.readFileSync(this.publicPath) : null; }; Generator.prototype.prompts = function() { @@ -44,17 +54,55 @@ Generator.prototype.prompts = function() { }; Generator.prototype.run = function() { - helpers.testDirectory(path.join(__dirname, '..', 'temp'), function(err) { + helpers.testDirectory(this.outputDir, function(err) { if (err) { throw err; } this.create(); + this.prepare(); this.prompts(); - this.app.run({}, function() {}); + this.app.run({}, this.finalize.bind(this)); }.bind(this)); }; +Generator.prototype.finalize = function() { + fs.appendFileSync(this.outputDir + '/deployment/deploy.rb', [ + '', + '# Use local repository for testing', + 'set :deploy_via, :copy', + 'set :repository, "."', + 'set :local_repository, "."', + // '# set :check_revision, false', + // '# set :branch, "master"', + '' + ].join('\n')); + + if (this.privateKey) { + fs.writeFileSync(this.privatePath, this.privateKey); + } + + if (this.publicKey) { + fs.writeFileSync(this.publicPath, this.publicKey); + } + + var vagrantFile = fs.readFileSync(this.outputDir + '/Vagrantfile', 'utf8') + .replace( + new RegExp('(# Remount)'), + [ + '# Mount library for testing', + ' box.vm.synced_folder "../../", "/wordpress", :nfs => true', + '', + ' $1' + ].join('\n') + ) + ; + + fs.writeFileSync(this.outputDir + '/Vagrantfile', vagrantFile); + + fs.mkdirSync(this.outputDir + '/bower_components'); + fs.symlinkSync('../../../../wordpress', this.outputDir + '/bower_components/genesis-wordpress'); +}; module.exports = Generator; From 3148625619db33c5750c762c2017ab819cd71db2 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 22:23:55 -0600 Subject: [PATCH 03/31] Install bower components before symlink creation --- deployment/lib/events.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/lib/events.rb b/deployment/lib/events.rb index 3b78cb0..76421e2 100644 --- a/deployment/lib/events.rb +++ b/deployment/lib/events.rb @@ -2,7 +2,7 @@ deploy.setup end -after "deploy:update" do +after "deploy:update_code" do run "cd #{release_path} && bower install" end From 8f057c2c58bc5e5b604fd779499c9853d60d48a9 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 22:24:08 -0600 Subject: [PATCH 04/31] Fix permissions after finalize_update --- deployment/lib/events.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/deployment/lib/events.rb b/deployment/lib/events.rb index 76421e2..f958eac 100644 --- a/deployment/lib/events.rb +++ b/deployment/lib/events.rb @@ -6,11 +6,11 @@ run "cd #{release_path} && bower install" end -after "deploy:update", "genesis:permissions" -after "genesis:up:files", "genesis:permissions" +after "deploy:finalize_update", "genesis:permissions" +after "genesis:up:files", "genesis:permissions" -after "deploy:restart", "genesis:restart" -after "genesis:provision", "genesis:restart" -after "genesis:up", "genesis:restart" -after "genesis:up:db", "genesis:restart" -after "genesis:up:files", "genesis:restart" +after "deploy:restart", "genesis:restart" +after "genesis:provision", "genesis:restart" +after "genesis:up", "genesis:restart" +after "genesis:up:db", "genesis:restart" +after "genesis:up:files", "genesis:restart" From 3229860dcfe32aa79d76254abefba2be49f369d8 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 22:50:29 -0600 Subject: [PATCH 05/31] Restructure testing --- package.json | 2 +- test/{support/generate => bin/mock} | 2 +- test/bin/test | 22 +++++++++++++++++++ test/generator.js | 1 - .../{site.install.js => support/bootstrap.js} | 0 .../{generator.js => mock-generator.js} | 14 ++++++------ 6 files changed, 31 insertions(+), 10 deletions(-) rename test/{support/generate => bin/mock} (57%) create mode 100755 test/bin/test rename test/{site.install.js => support/bootstrap.js} (100%) rename test/support/{generator.js => mock-generator.js} (89%) diff --git a/package.json b/package.json index fe7c5ff..e1be7cd 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "zombie": "~2.0.0-alpha24" }, "scripts": { - "test": "mocha --reporter spec" + "test": "./test/bin/test" }, "repository": { "type": "git", diff --git a/test/support/generate b/test/bin/mock similarity index 57% rename from test/support/generate rename to test/bin/mock index 8b56146..ef5ab4d 100755 --- a/test/support/generate +++ b/test/bin/mock @@ -1,6 +1,6 @@ #!/usr/bin/env node -var Generator = require('./generator'); +var Generator = require('../support/mock-generator'); var generator = new Generator(); generator.run(); diff --git a/test/bin/test b/test/bin/test new file mode 100755 index 0000000..7058d1b --- /dev/null +++ b/test/bin/test @@ -0,0 +1,22 @@ +#!/usr/bin/env node + +var fs = require('fs'); +var Mocha = require('mocha'); +var mocha = new Mocha(); +var testDir = __dirname + '/../'; + +// Setup environment first +mocha.addFile(testDir + '/support/bootstrap.js'); + +// Add all other tests +fs.readdirSync(testDir).filter(function(file) { + return '.js' === file.substr(-3); +}).forEach(function(file) { + mocha.addFile(testDir + file); +}); + +mocha + .reporter('spec') + .ui('bdd') + .run(process.exit) +; diff --git a/test/generator.js b/test/generator.js index 33fcb71..d135e50 100644 --- a/test/generator.js +++ b/test/generator.js @@ -1,7 +1,6 @@ 'use strict'; var assert = require('assert'); -var Browser = require('zombie'); var fs = require('fs'); var path = require('path'); diff --git a/test/site.install.js b/test/support/bootstrap.js similarity index 100% rename from test/site.install.js rename to test/support/bootstrap.js diff --git a/test/support/generator.js b/test/support/mock-generator.js similarity index 89% rename from test/support/generator.js rename to test/support/mock-generator.js index 60155b7..f0863b2 100644 --- a/test/support/generator.js +++ b/test/support/mock-generator.js @@ -3,11 +3,11 @@ var hooker = require('hooker'); var helpers = require('yeoman-generator').test; var path = require('path'); -var Generator = function(outputDir) { +var MockGenerator = function(outputDir) { this.outputDir = __dirname + '/../temp'; }; -Generator.prototype.create = function() { +MockGenerator.prototype.create = function() { this.app = helpers.createGenerator('genesis-wordpress:app', [ [require('../../generator/app'), 'genesis-wordpress:app'] ]); @@ -15,14 +15,14 @@ Generator.prototype.create = function() { this.app.options['skip-install'] = true; }; -Generator.prototype.prepare = function() { +MockGenerator.prototype.prepare = function() { this.privatePath = this.outputDir + '/provisioning/files/ssh/id_rsa'; this.privateKey = fs.existsSync(this.privatePath) ? fs.readFileSync(this.privatePath) : null; this.publicPath = this.outputDir + '/provisioning/files/ssh/id_rsa.pub'; this.publicKey = fs.existsSync(this.publicPath) ? fs.readFileSync(this.publicPath) : null; }; -Generator.prototype.prompts = function() { +MockGenerator.prototype.prompts = function() { hooker.hook(this.app, 'prompt', function(prompts, done) { var answers = { name: 'GeneratorTest.com', @@ -53,7 +53,7 @@ Generator.prototype.prompts = function() { }.bind(this)); }; -Generator.prototype.run = function() { +MockGenerator.prototype.run = function() { helpers.testDirectory(this.outputDir, function(err) { if (err) { throw err; @@ -67,7 +67,7 @@ Generator.prototype.run = function() { }.bind(this)); }; -Generator.prototype.finalize = function() { +MockGenerator.prototype.finalize = function() { fs.appendFileSync(this.outputDir + '/deployment/deploy.rb', [ '', '# Use local repository for testing', @@ -105,4 +105,4 @@ Generator.prototype.finalize = function() { fs.symlinkSync('../../../../wordpress', this.outputDir + '/bower_components/genesis-wordpress'); }; -module.exports = Generator; +module.exports = MockGenerator; From a88750817cf306b6c672a92f0759383e1ba75abd Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 23:03:33 -0600 Subject: [PATCH 06/31] Revert "Fix permissions after finalize_update" This reverts commit 8f057c2c58bc5e5b604fd779499c9853d60d48a9. --- deployment/lib/events.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/deployment/lib/events.rb b/deployment/lib/events.rb index f958eac..76421e2 100644 --- a/deployment/lib/events.rb +++ b/deployment/lib/events.rb @@ -6,11 +6,11 @@ run "cd #{release_path} && bower install" end -after "deploy:finalize_update", "genesis:permissions" -after "genesis:up:files", "genesis:permissions" +after "deploy:update", "genesis:permissions" +after "genesis:up:files", "genesis:permissions" -after "deploy:restart", "genesis:restart" -after "genesis:provision", "genesis:restart" -after "genesis:up", "genesis:restart" -after "genesis:up:db", "genesis:restart" -after "genesis:up:files", "genesis:restart" +after "deploy:restart", "genesis:restart" +after "genesis:provision", "genesis:restart" +after "genesis:up", "genesis:restart" +after "genesis:up:db", "genesis:restart" +after "genesis:up:files", "genesis:restart" From 4183b13d3697665d53b1d65a1d1da4281fa3cfb6 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 23:05:55 -0600 Subject: [PATCH 07/31] Add test for genesis:deploy --- test/cap.genesis.deploy.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/cap.genesis.deploy.js diff --git a/test/cap.genesis.deploy.js b/test/cap.genesis.deploy.js new file mode 100644 index 0000000..38da853 --- /dev/null +++ b/test/cap.genesis.deploy.js @@ -0,0 +1,21 @@ +'use strict'; + +var assert = require('assert'); +var exec = require('child_process').exec; + +describe('Genesis WordPress', function () { + describe('cap', function() { + this.timeout(0); + + describe('deploy', function(done) { + it('should not fail', function(done) { + exec('cap local deploy', { + cwd: __dirname + '/temp' + }, function(err, stdout, stderr) { + assert.ifError(err); + done(); + }); + }); + }); + }); +}); From 0fd090f2f6bb3fac47714ec005064c95c208b6a2 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 23:08:20 -0600 Subject: [PATCH 08/31] Clean up test namespacing --- test/cap.genesis.deploy.js | 20 +++++------- test/generator.js | 38 +++++++++++----------- test/support/bootstrap.js | 66 ++++++++++++++++++-------------------- 3 files changed, 58 insertions(+), 66 deletions(-) diff --git a/test/cap.genesis.deploy.js b/test/cap.genesis.deploy.js index 38da853..1a90592 100644 --- a/test/cap.genesis.deploy.js +++ b/test/cap.genesis.deploy.js @@ -3,19 +3,15 @@ var assert = require('assert'); var exec = require('child_process').exec; -describe('Genesis WordPress', function () { - describe('cap', function() { - this.timeout(0); +describe('cap deploy', function(done) { + this.timeout(0); - describe('deploy', function(done) { - it('should not fail', function(done) { - exec('cap local deploy', { - cwd: __dirname + '/temp' - }, function(err, stdout, stderr) { - assert.ifError(err); - done(); - }); - }); + it('should not fail', function(done) { + exec('cap local deploy', { + cwd: __dirname + '/temp' + }, function(err, stdout, stderr) { + assert.ifError(err); + done(); }); }); }); diff --git a/test/generator.js b/test/generator.js index d135e50..243382f 100644 --- a/test/generator.js +++ b/test/generator.js @@ -4,27 +4,25 @@ var assert = require('assert'); var fs = require('fs'); var path = require('path'); -describe('Genesis WordPress', function () { - describe('generator', function() { - it('should create required files', function(done) { - [ - 'bin/provision', - 'deployment/deploy.rb', - 'provisioning/provision.yml', - 'provisioning/files/ssh/id_rsa', - 'provisioning/files/ssh/id_rsa.pub', - 'web/wp-config.php', - 'bower.json', - 'Capfile', - 'README.md', - 'Vagrantfile', - ].forEach(function(file) { - var filePath = path.join(__dirname, 'temp', file); +describe('Generator', function() { + it('should create required files', function(done) { + [ + 'bin/provision', + 'deployment/deploy.rb', + 'provisioning/provision.yml', + 'provisioning/files/ssh/id_rsa', + 'provisioning/files/ssh/id_rsa.pub', + 'web/wp-config.php', + 'bower.json', + 'Capfile', + 'README.md', + 'Vagrantfile', + ].forEach(function(file) { + var filePath = path.join(__dirname, 'temp', file); - assert.ok(fs.existsSync(filePath), 'File not created: ' + filePath); - }); - - done(); + assert.ok(fs.existsSync(filePath), 'File not created: ' + filePath); }); + + done(); }); }); diff --git a/test/support/bootstrap.js b/test/support/bootstrap.js index f839a13..29db6f5 100644 --- a/test/support/bootstrap.js +++ b/test/support/bootstrap.js @@ -5,43 +5,41 @@ var Browser = require('zombie'); var fs = require('fs'); var path = require('path'); -describe('Genesis WordPress', function () { - describe('site', function() { - it('may not be installed', function(done) { - var browser = new Browser(); +describe('Mock site', function() { + it('may not be installed', function(done) { + var browser = new Browser(); - this.timeout(0); + this.timeout(0); - browser - .visit('http://local.generatortest.com/wp-admin/install.php') - .then(function() { - if (browser.button('Install WordPress')) { - browser - .fill('Site Title', 'Genesis WordPress Test') - .fill('Username', 'test') - .fill('admin_password', 'test') - .fill('admin_password2', 'test') - .fill('Your E-mail', 'test@example.com') - .uncheck('blog_public') - ; + browser + .visit('http://local.generatortest.com/wp-admin/install.php') + .then(function() { + if (browser.button('Install WordPress')) { + browser + .fill('Site Title', 'Genesis WordPress Test') + .fill('Username', 'test') + .fill('admin_password', 'test') + .fill('admin_password2', 'test') + .fill('Your E-mail', 'test@example.com') + .uncheck('blog_public') + ; - return browser.pressButton('Install WordPress'); - } - }) - .then(done, done) - ; - }); + return browser.pressButton('Install WordPress'); + } + }) + .then(done, done) + ; + }); - it('should be installed', function(done) { - var browser = new Browser(); + it('should be installed', function(done) { + var browser = new Browser(); - browser - .visit('http://local.generatortest.com/wp-admin/install.php') - .then(function() { - assert.equal('Log In', browser.text('a.button')); - }) - .then(done, done) - ; - }) - }); + browser + .visit('http://local.generatortest.com/wp-admin/install.php') + .then(function() { + assert.equal('Log In', browser.text('a.button')); + }) + .then(done, done) + ; + }) }); From 5a3640f914f56c0d172dcd818ec31df51b610a7e Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 23:19:35 -0600 Subject: [PATCH 09/31] Update .travis.yml to match test Vagrantfile --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b3ece21..5dd16d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,9 @@ install: - npm install -g bower before_script: - npm install - - ./test/support/generate - - sudo mkdir /vagrant - - sudo ln -s "${PWD}/test/temp/web" /vagrant/web + - ./test/bin/generate + - sudo ln -s "${PWD}/test/temp" /vagrant + - sudo ln -s "${PWD}" /wordpress + - mkdir -p "${PWD}/bower_components" + - sudo ln -s /wordpress "${PWD}/bower_components/genesis-wordpress" - sudo ./test/temp/bin/provision From 839060b5cb399875e945a0783eb6f11ae258cb68 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 23:21:18 -0600 Subject: [PATCH 10/31] generate -> mock --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5dd16d8..13bdeb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ install: - npm install -g bower before_script: - npm install - - ./test/bin/generate + - ./test/bin/mock - sudo ln -s "${PWD}/test/temp" /vagrant - sudo ln -s "${PWD}" /wordpress - mkdir -p "${PWD}/bower_components" From 2dc74b359c209ee46d94c2e9bf1c294136b6dc0a Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 23:25:19 -0600 Subject: [PATCH 11/31] Fix paths --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 13bdeb4..0861698 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,9 @@ install: - npm install -g bower before_script: - npm install - - ./test/bin/mock + - "${PWD}/test/bin/mock" - sudo ln -s "${PWD}/test/temp" /vagrant - sudo ln -s "${PWD}" /wordpress - - mkdir -p "${PWD}/bower_components" - - sudo ln -s /wordpress "${PWD}/bower_components/genesis-wordpress" - - sudo ./test/temp/bin/provision + - mkdir -p "${PWD}/test/temp/bower_components" + - ln -s /wordpress "${PWD}/test/temp/bower_components/genesis-wordpress" + - sudo "${PWD}/test/temp/bin/provision" From e9b7ac723572566d41038652295041bcb9b433fb Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 23:34:07 -0600 Subject: [PATCH 12/31] Install capistrano on travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0861698..1002222 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ addons: - local.generatortest.com install: - npm install -g bower + - gem install capistrano -v 2.15 capistrano-ext colored before_script: - npm install - "${PWD}/test/bin/mock" From 21015a4e98d770787eef23ac135430038e1801ac Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 23:40:42 -0600 Subject: [PATCH 13/31] "ERROR: Can't use --version w/ multiple gems. Use name:ver instead." --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1002222..8cd11f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,8 @@ addons: - local.generatortest.com install: - npm install -g bower - - gem install capistrano -v 2.15 capistrano-ext colored + - gem install capistrano -v 2.15 + - gem install capistrano-ext colored before_script: - npm install - "${PWD}/test/bin/mock" From adc030354f1a8d284c0892348e9194eab88ea2ff Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 26 Dec 2013 23:54:03 -0600 Subject: [PATCH 14/31] Attempt to fix detached symlink --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8cd11f9..957808e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,14 +6,14 @@ addons: hosts: - local.generatortest.com install: - - npm install -g bower - gem install capistrano -v 2.15 - gem install capistrano-ext colored + - npm install -g bower before_script: + - echo "Running from ${PWD}" - npm install - "${PWD}/test/bin/mock" - - sudo ln -s "${PWD}/test/temp" /vagrant + - sudo mkdir -p /vagrant/web - sudo ln -s "${PWD}" /wordpress - - mkdir -p "${PWD}/test/temp/bower_components" - - ln -s /wordpress "${PWD}/test/temp/bower_components/genesis-wordpress" + - sudo ln -s "${PWD}/test/temp/web" /vagrant/web - sudo "${PWD}/test/temp/bin/provision" From 87ce338cec5d4d4c69f1739c280e8279d64051ed Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Fri, 27 Dec 2013 00:00:18 -0600 Subject: [PATCH 15/31] Back to 7b969d204067d1163695ba68005b56fc3cea2d9a --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 957808e..4a4a924 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,6 @@ before_script: - echo "Running from ${PWD}" - npm install - "${PWD}/test/bin/mock" - - sudo mkdir -p /vagrant/web - - sudo ln -s "${PWD}" /wordpress + - sudo mkdir /vagrant - sudo ln -s "${PWD}/test/temp/web" /vagrant/web - sudo "${PWD}/test/temp/bin/provision" From 932559f0b3c63412b77a49fe10b10b3fef7ab6c3 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Fri, 27 Dec 2013 13:12:20 -0600 Subject: [PATCH 16/31] No more docs --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a4a924..befddaf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,13 +6,14 @@ addons: hosts: - local.generatortest.com install: - - gem install capistrano -v 2.15 - - gem install capistrano-ext colored + - gem install --no-rdoc --no-ri capistrano -v 2.15 + - gem install --no-rdoc --no-ri capistrano-ext colored - npm install -g bower before_script: - echo "Running from ${PWD}" - npm install - "${PWD}/test/bin/mock" - - sudo mkdir /vagrant + - ln -fs "${PWD}" "${PWD}/test/temp/bower_components/genesis-wordpress" + - sudo mkdir -p /vagrant - sudo ln -s "${PWD}/test/temp/web" /vagrant/web - sudo "${PWD}/test/temp/bin/provision" From b08b95ed8363c3204e26b1c92fd1660860e45eac Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Fri, 27 Dec 2013 13:12:26 -0600 Subject: [PATCH 17/31] Fix sftp tmp path --- test/support/mock-generator.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/support/mock-generator.js b/test/support/mock-generator.js index f0863b2..9c93b95 100644 --- a/test/support/mock-generator.js +++ b/test/support/mock-generator.js @@ -74,8 +74,7 @@ MockGenerator.prototype.finalize = function() { 'set :deploy_via, :copy', 'set :repository, "."', 'set :local_repository, "."', - // '# set :check_revision, false', - // '# set :branch, "master"', + 'set :copy_remote_dir, "/var/www/#{domain}/#{branch}"', '' ].join('\n')); From fa66143100e32f7236a247a4bdca7d13e761aab3 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Fri, 27 Dec 2013 15:12:59 -0600 Subject: [PATCH 18/31] sudo gem install --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index befddaf..3e080de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ addons: hosts: - local.generatortest.com install: - - gem install --no-rdoc --no-ri capistrano -v 2.15 - - gem install --no-rdoc --no-ri capistrano-ext colored + - sudo gem install --no-rdoc --no-ri capistrano -v 2.15 + - sudo gem install --no-rdoc --no-ri capistrano-ext colored - npm install -g bower before_script: - echo "Running from ${PWD}" From 637f11fd20cc0436e1f32d73f922a69ce634da9b Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Fri, 27 Dec 2013 15:23:21 -0600 Subject: [PATCH 19/31] Revert "sudo gem install" This reverts commit fa66143100e32f7236a247a4bdca7d13e761aab3. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3e080de..befddaf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ addons: hosts: - local.generatortest.com install: - - sudo gem install --no-rdoc --no-ri capistrano -v 2.15 - - sudo gem install --no-rdoc --no-ri capistrano-ext colored + - gem install --no-rdoc --no-ri capistrano -v 2.15 + - gem install --no-rdoc --no-ri capistrano-ext colored - npm install -g bower before_script: - echo "Running from ${PWD}" From 82a4934ba0d021f74eafd0fae181fc2a1d5f9369 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Wed, 5 Feb 2014 16:06:27 -0600 Subject: [PATCH 20/31] Copy current project into bower by default --- .travis.yml | 4 ---- test/README.md | 2 +- test/support/mock-generator.js | 15 ++++++++++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3c6bcd0..b9277f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,5 @@ before_script: - "${PWD}/test/bin/mock" - echo "Move mock project to /vagrant" - sudo mv "${PWD}/test/temp" /vagrant - - echo "Remove Bower's Genesis WordPress" - - rm -rf "/vagrant/bower_components/genesis-wordpress" - - echo "Replace with this Genesis WordPress" - - cp -R "${PWD}" /vagrant/bower_components/genesis-wordpress - echo "Provision server" - sudo /vagrant/bin/provision diff --git a/test/README.md b/test/README.md index 50a2de3..0b8c882 100644 --- a/test/README.md +++ b/test/README.md @@ -13,7 +13,7 @@ $ npm install Generate test project scaffolding: ```shell -$ ./test/bin/generate +$ ./test/bin/mock ``` ### Testing Provisioning diff --git a/test/support/mock-generator.js b/test/support/mock-generator.js index 14ee333..b513147 100644 --- a/test/support/mock-generator.js +++ b/test/support/mock-generator.js @@ -1,4 +1,4 @@ -var fs = require('fs'); +var fs = require('fs-extra'); var hooker = require('hooker'); var helpers = require('yeoman-generator').test; var path = require('path'); @@ -99,6 +99,19 @@ MockGenerator.prototype.finalize = function() { ; fs.writeFileSync(this.outputDir + '/Vagrantfile', vagrantFile); + + // Copy current library into bower location, except for test + fs.copy( + path.resolve(this.outputDir, '../../'), + this.outputDir + '/bower_components/genesis-wordpress', + function(path) { + return !path.match('test'); + }, function(err) { + if (err) { + return console.error(err); + } + } + ); }; module.exports = MockGenerator; From 7c05a1db5a7923cf0dc702ae94b78e3c000675df Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 10 Feb 2014 18:04:49 -0600 Subject: [PATCH 21/31] Add Gemfile Closes #103 --- README.md | 46 ++++++++++++++++----------------- generator/app/index.js | 23 +++++++++++++++++ generator/app/templates/Gemfile | 5 ++++ test/README.md | 14 +++++++--- test/cap.genesis.deploy.js | 4 +-- test/generator.js | 1 + 6 files changed, 65 insertions(+), 28 deletions(-) create mode 100644 generator/app/templates/Gemfile diff --git a/README.md b/README.md index 6b150e1..8b50fbc 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,9 @@ If you get EMFILE issues, try running: `$ ulimit -n 4096`. ### Deployment -Install [Capistrano v2.15.*][5] & [Ansible][7]: +Install [Capistrano v2.15.*][5] via [Bundler][1] & [Ansible][7]: - $ sudo gem install capistrano -v 2.15 capistrano-ext colored + $ sudo bundle install $ sudo easy_install pip $ sudo pip install ansible @@ -95,7 +95,7 @@ access the project's *Settings -> Deploy Keys* in Github and add `provisioning/f Next, assuming the server has been provisioned, deploy your code on Github: - $ cap production deploy + $ bundle exec cap production deploy The latest code is now live: @@ -107,7 +107,7 @@ If you deploy to `staging`, the name of the current branch (e.g. `my-feature`) i In the rare event the changes weren't supposed to go live, you can rollback to the previous release: - $ cap production deploy:rollback + $ bundle exec cap production deploy:rollback **Note that deployments use the project's *Github repository* as the source, not your local machine!** @@ -121,15 +121,15 @@ a database or uploaded images. You can **overwrite the remote database** with your local VM's: - $ cap production genesis:up:db + $ bundle exec cap production genesis:up:db You can sync your local files to the remote filesystem: - $ cap production genesis:up:files + $ bundle exec cap production genesis:up:files Or, you can perform both actions together: - $ cap production genesis:up + $ bundle exec cap production genesis:up Once a site is live, you *rarely* need to sync anything up to the remote server. If anything, you usually sync changes *down*. @@ -140,9 +140,9 @@ you usually sync changes *down*. Suppose you have a live site that you need to work on locally. Like the previous section, you can sync down the database, the files (e.g. uploaded images), or both: - $ cap production genesis:down:db - $ cap production genesis:down:files - $ cap production genesis:down + $ bundle exec cap production genesis:down:db + $ bundle exec cap production genesis:down:files + $ bundle exec cap production genesis:down ## Provisioning @@ -155,11 +155,11 @@ The following environments are expected to exist and resolve via DNS to simplify If you're deploying to a new machine (e.g. production.mysite.com), you first need to provision it: - $ cap production genesis:provision + $ bundle exec cap production genesis:provision If there is an error, you may be prompted to re-run the command with an explicit username/password: - $ cap production genesis:provision -S user=myuser -S password=mypassword + $ bundle exec cap production genesis:provision -S user=myuser -S password=mypassword *From that point on, tasks will use a private key (`provisioning/files/ssh/id_rsa`).* @@ -170,14 +170,14 @@ migrate the old server to a new server: $ vagrant up # Provision the new server - $ cap production provision - $ cap production deploy + $ bundle exec cap production provision + $ bundle exec cap production deploy # Download the old site to local - $ cap old genesis:down + $ bundle exec cap old genesis:down # Upload the old site to production - $ cap production genesis:up + $ bundle exec cap production genesis:up Now you can switch DNS for http://www.mysite.com/ to point to http://production.mysite.com/'s IP! @@ -186,7 +186,7 @@ Now you can switch DNS for http://www.mysite.com/ to point to http://production. Most of the functionality regarding remote servers are handled by custom [Capistrano][5] tasks, which you can see by running: - $ cap -T genesis + $ bundle exec cap -T genesis cap genesis:down # Downloads both remote database & syncs remote files into Vagrant cap genesis:down:db # Downloads remote database into Vagrant cap genesis:down:files # Downloads remote files to Vagrant @@ -204,7 +204,7 @@ which you can see by running: Now run any one of those commands against an environemnt: - $ cap local genesis:restart + $ bundle exec cap local genesis:restart ## Troubleshooting @@ -212,7 +212,7 @@ Now run any one of those commands against an environemnt: If you're seeing this: - $ cap staging genesis:ssh + $ bundle exec cap staging genesis:ssh deploy@staging.example.com's password: Then the `deploy` user's ssh keys on your remote server *do not match* the keys in your local repository. @@ -221,17 +221,17 @@ You should first ensure that your local repository is up to date, thereby ensuri $ git checkout master $ git pull origin master - $ cap staging genesis:ssh + $ bundle exec cap staging genesis:ssh If the problem persists, this means that the keys on your remote server are out of date or otherwise incorrect, and you must re-provision by specifying a username and password: - $ cap staging genesis:provision -S user=userWithRootOrSudoAccess -S password=usersHopefullyStrongPassword + $ bundle exec cap staging genesis:provision -S user=userWithRootOrSudoAccess -S password=usersHopefullyStrongPassword ### SSH - Host key mismatch If you're seeing this: - $ cap staging genesis:ssh + $ bundle exec cap staging genesis:ssh @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -394,7 +394,7 @@ sudo /Library/StartupItems/VirtualBox/VirtualBox restart [7]: http://www.ansibleworks.com/ [8]: https://www.virtualbox.org/ [9]: http://nodejs.org/ - +[10]: http://bundler.io/ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/genesis/wordpress/trend.png)](https://bitdeli.com/free "Bitdeli Badge") diff --git a/generator/app/index.js b/generator/app/index.js index 396be1f..d93ce96 100644 --- a/generator/app/index.js +++ b/generator/app/index.js @@ -275,6 +275,7 @@ WordpressGenerator.prototype.writeProjectFiles = function() { this.template('gitignore', '.gitignore'); this.template('bower.json', 'bower.json'); this.template('Capfile', 'Capfile'); + this.template('Gemfile', 'Gemfile'); this.template('editorconfig', '.editorconfig'); this.template('README.md', 'README.md'); this.template('Vagrantfile', 'Vagrantfile'); @@ -383,4 +384,26 @@ WordpressGenerator.prototype.setupDeployment = function() { this.template('deployment/stages/production.rb', 'deployment/stages/production.rb'); }; +WordpressGenerator.prototype.installGems = function() { + var done = this.async(); + var installer = 'bundle'; + + this.log.info(chalk.green('Installing Gems...')); + + this.emit(installer + 'Install'); + + this + .spawnCommand('sudo', [installer, 'install'], done) + .on('error', done) + .on('exit', this.emit.bind(this, installer + 'Install:end')) + .on('exit', function (err) { + if (err === 127) { + this.log.error('Could not run bundler. Please install with `sudo ' + installer + ' install`.'); + } + + done(err); + }.bind(this)) + ; +}; + module.exports = WordpressGenerator; diff --git a/generator/app/templates/Gemfile b/generator/app/templates/Gemfile new file mode 100644 index 0000000..cfdf9ef --- /dev/null +++ b/generator/app/templates/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gem 'capistrano', '~> 2.15' +gem 'capistrano-ext', '~> 1.2.1' +gem 'colored', '~> 1.2' diff --git a/test/README.md b/test/README.md index 0b8c882..5c0821e 100644 --- a/test/README.md +++ b/test/README.md @@ -24,12 +24,20 @@ Start test project server: $ (cd test/temp && vagrant up) ``` -Tests will be ran against: +### End-User Testing -> http://local.generatortest.com +Install Gems: -### End-User Testing +```shell +$ (cd test/temp && sudo bundle install) +``` + +Run tests: ```shell $ npm test ``` + +Tests will be ran against: + +> http://local.generatortest.com diff --git a/test/cap.genesis.deploy.js b/test/cap.genesis.deploy.js index 1a90592..102661c 100644 --- a/test/cap.genesis.deploy.js +++ b/test/cap.genesis.deploy.js @@ -3,11 +3,11 @@ var assert = require('assert'); var exec = require('child_process').exec; -describe('cap deploy', function(done) { +describe('bundle exec cap local deploy', function(done) { this.timeout(0); it('should not fail', function(done) { - exec('cap local deploy', { + exec('bundle exec cap local deploy', { cwd: __dirname + '/temp' }, function(err, stdout, stderr) { assert.ifError(err); diff --git a/test/generator.js b/test/generator.js index 243382f..a4a8f9d 100644 --- a/test/generator.js +++ b/test/generator.js @@ -15,6 +15,7 @@ describe('Generator', function() { 'web/wp-config.php', 'bower.json', 'Capfile', + 'Gemfile', 'README.md', 'Vagrantfile', ].forEach(function(file) { From d9a0210685853b38b90115a557d155e5651ca808 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 10 Feb 2014 18:10:32 -0600 Subject: [PATCH 22/31] Replace gems with bundler --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b9277f1..e656b9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,7 @@ addons: hosts: - local.generatortest.com install: - - gem install --no-rdoc --no-ri capistrano -v 2.15 - - gem install --no-rdoc --no-ri capistrano-ext colored + - gem install bundle - npm install -g bower before_script: - echo "Running from ${PWD}" From 72759416c3923160fa9986e10a15dd0b8442ee69 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 10 Feb 2014 18:14:03 -0600 Subject: [PATCH 23/31] Sudo make me a sandwhich? --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e656b9b..d238314 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ addons: hosts: - local.generatortest.com install: - - gem install bundle + - sudo gem install bundle - npm install -g bower before_script: - echo "Running from ${PWD}" From 0daf75f56fafb92f7b885e055884a1e62bc63a6b Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 10 Feb 2014 18:20:02 -0600 Subject: [PATCH 24/31] Let's try bundle install without the sudo --- .travis.yml | 2 +- generator/app/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d238314..e656b9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ addons: hosts: - local.generatortest.com install: - - sudo gem install bundle + - gem install bundle - npm install -g bower before_script: - echo "Running from ${PWD}" diff --git a/generator/app/index.js b/generator/app/index.js index d93ce96..aac03cf 100644 --- a/generator/app/index.js +++ b/generator/app/index.js @@ -393,7 +393,7 @@ WordpressGenerator.prototype.installGems = function() { this.emit(installer + 'Install'); this - .spawnCommand('sudo', [installer, 'install'], done) + .spawnCommand(installer, ['install'], done) .on('error', done) .on('exit', this.emit.bind(this, installer + 'Install:end')) .on('exit', function (err) { From 04f8f8abe4e1cdfdd26b3ad61d6afda7b4bae969 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 10 Feb 2014 19:26:12 -0600 Subject: [PATCH 25/31] Echo PATH --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e656b9b..98ff350 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ addons: install: - gem install bundle - npm install -g bower + - echo "PATH: $path" before_script: - echo "Running from ${PWD}" - echo "Install NPM dependencies" From 54093a5158da605757edc00dcf3ebd556f7a0322 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 10 Feb 2014 19:27:56 -0600 Subject: [PATCH 26/31] bundler !== bundle --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98ff350..425d6d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ addons: hosts: - local.generatortest.com install: - - gem install bundle + - gem install bundler - npm install -g bower - echo "PATH: $path" before_script: From 84e7ea2d85ec440c115f061bae2c8e71628e0546 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 10 Feb 2014 19:28:36 -0600 Subject: [PATCH 27/31] Remove PATH echo --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 425d6d1..1c30ed9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ addons: install: - gem install bundler - npm install -g bower - - echo "PATH: $path" before_script: - echo "Running from ${PWD}" - echo "Install NPM dependencies" From d6c98ca66c530568fea0fc010c72ec681c130c6a Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 10 Feb 2014 19:34:38 -0600 Subject: [PATCH 28/31] Switch to before_install & rvm --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1c30ed9..759e8c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,8 @@ node_js: addons: hosts: - local.generatortest.com -install: +before_install: + - rvm use 2.0.0 - gem install bundler - npm install -g bower before_script: From c8f6a4c196bb77cc950f0d95d316a94c2d79fa43 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 10 Feb 2014 19:36:17 -0600 Subject: [PATCH 29/31] rvm 1.9.3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 759e8c2..2a5e558 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ addons: hosts: - local.generatortest.com before_install: - - rvm use 2.0.0 + - rvm use 1.9.3 - gem install bundler - npm install -g bower before_script: From 5951f28e5fd2c2de25d11762a63e2b6b5691545c Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 10 Feb 2014 20:48:38 -0600 Subject: [PATCH 30/31] Copy, not move test project --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2a5e558..fd4e926 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ before_script: - npm install - echo "Mock test project" - "${PWD}/test/bin/mock" - - echo "Move mock project to /vagrant" - - sudo mv "${PWD}/test/temp" /vagrant - echo "Provision server" - - sudo /vagrant/bin/provision + - sudo "${PWD}/test/temp/bin/provision" + - echo "Copy mock project to /vagrant for end-user tests" + - sudo cp -R "${PWD}/test/temp" /vagrant From 4b22441579e8c3c8c0d750f1d3361eb4979bbe91 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Mon, 16 Jun 2014 14:06:15 -0500 Subject: [PATCH 31/31] Remove duplicate Gemfile copying --- generator/app/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/generator/app/index.js b/generator/app/index.js index 2a68703..ec1c553 100644 --- a/generator/app/index.js +++ b/generator/app/index.js @@ -275,7 +275,6 @@ WordpressGenerator.prototype.writeProjectFiles = function() { this.template('gitignore', '.gitignore'); this.template('bower.json', 'bower.json'); this.template('Capfile', 'Capfile'); - this.template('Gemfile', 'Gemfile'); this.template('editorconfig', '.editorconfig'); this.template('Gemfile', 'Gemfile'); this.template('Gemfile.lock', 'Gemfile.lock');