Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
03f4b62
Updated npm deps and engine in package.json; updated travis nvm version
EvanK Feb 10, 2016
3dedd38
Node 4 improvements
EvanK Feb 10, 2016
313cead
Updating generator and yeoman test hooks
EvanK Feb 10, 2016
c408432
Slight template engine syntax change
EvanK Feb 10, 2016
95fad57
Reordered methods within running contexts
EvanK Feb 10, 2016
64dc947
Ripping out bower, in favor of npm
EvanK Feb 16, 2016
8885f27
Javascript cleanup, mainly strict mode and replacing deprecated fs.ex…
EvanK Feb 17, 2016
4ea6e06
Fixed flipped private/public logic, and added cleanup of old bower co…
EvanK Feb 17, 2016
7d06023
Removing bower, updating ansible and node, and all that entails
EvanK Feb 17, 2016
442c03b
Misc cleanup
EvanK Feb 18, 2016
65206fa
Merge branch 'master' into 89-update-dependencies
EvanK Feb 18, 2016
6be39e1
Merge branch 'master' into 89-update-dependencies
EvanK Feb 19, 2016
edadec3
Tweaking travis yml
EvanK Feb 19, 2016
db742a9
Troubleshooting travis build errors
EvanK Feb 19, 2016
778ecf2
Try recursive copy without trailing slashes
EvanK Feb 19, 2016
5b7d6ec
Normalize line endings in fetched wp-config
EvanK Feb 19, 2016
6ebf7f0
Merge branch 'master' into 89-update-dependencies
EvanK Mar 13, 2016
f8120f5
Warn but allow outdated dep versions
EvanK Mar 13, 2016
0544690
Merge branch 'master' into 89-update-dependencies
EvanK Oct 28, 2016
9822299
Updated ruby setup for CI
EvanK Oct 29, 2016
65c4e70
Several updates to get this branch working:
EvanK Oct 31, 2016
73df0f4
Fetch node apt key on control machine
EvanK Oct 31, 2016
1078c28
Replacing zombie with nightmare, working around electron dns/hostfile…
EvanK Nov 12, 2016
09b0e12
Updated tests (more or less working locally!)
EvanK Nov 13, 2016
34f38ca
Couple minor changes
EvanK Nov 13, 2016
d87a6dd
Install several python packages, for SNI support in CI env
EvanK Nov 13, 2016
66a6336
Updated node repo task for ansible 2.2
EvanK Nov 13, 2016
0a96c2f
Tweak order of provision/install for CI
EvanK Nov 13, 2016
063773c
Install composer after local provision (again for CI)
EvanK Nov 13, 2016
e3ca2e9
Supress composer interaction (maybe whats timing out in CI?)
EvanK Nov 13, 2016
d9191b5
Configured virtual display server for CI
EvanK Nov 13, 2016
490e883
Increase composer verbosity
EvanK Nov 13, 2016
3f29432
Still trying to get headless tests working with nightmare on CI
EvanK Nov 13, 2016
f202774
While tests are /mostly/ passing, headless tests are dropping out ent…
EvanK Nov 15, 2016
ed27585
More headless test tweaks
EvanK Nov 15, 2016
edb520d
One more try for headless tests
EvanK Nov 15, 2016
1ed989d
Start caching composer deps, expand nightmare/electron debug messaging
EvanK Nov 15, 2016
bd3af6b
Adding electron deps
EvanK Nov 15, 2016
a548aae
Wait longer for tests to run
EvanK Nov 15, 2016
8df75c1
Log provision/deploy output as we go in travis, so the build doesn't …
EvanK Nov 15, 2016
f672d67
Skip local fetching of purge kernel script -- not necessary on CI anyway
EvanK Nov 15, 2016
9870061
Work around SNI local_action, when in CI
EvanK Nov 15, 2016
42fa31a
Fix local_action tmp file permissions (CI only)
EvanK Nov 15, 2016
4761299
Use local abs path for npm install, just on CI
EvanK Nov 15, 2016
ab695e4
Tweak permissions for npm install from local fs
EvanK Nov 15, 2016
7a45163
Use github committish for npm install, just on CI
EvanK Nov 15, 2016
267df05
More tweaks for nightmare
EvanK Nov 15, 2016
6c7dfbc
Try running xvfb from background
EvanK Nov 15, 2016
e2d0c1a
Mock package.json to bypass npm registry for evo install
EvanK Nov 16, 2016
8568555
Removed nightmare debug, added test matrix for ansible and node versions
EvanK Nov 16, 2016
1ffa75c
Fixed build matrix ¯\_(ツ)_/¯
EvanK Nov 16, 2016
03841c0
Removed Ansible 2.0 from build matrix (SNI bug again), moved rvm cmds…
EvanK Nov 16, 2016
37bbde0
Reduced build matrix to ansible 2.1-2.2, on node 4.0
EvanK Nov 16, 2016
87d155a
Cache more deps in Travis, to speed up CI builds
EvanK Nov 16, 2016
af8b8b7
Gracefully clean up old bower files
EvanK Nov 20, 2016
37a1709
Re-adding support for bower deps, when a bower.json is found
EvanK Nov 20, 2016
982b5e3
Updated generator's dep checking to use semver for minimum versions
EvanK Nov 20, 2016
a515243
Globally install yeoman 1.8 (for CI)
EvanK Nov 20, 2016
8694e96
Test yeoman lowest possible version compatibility"
EvanK Nov 20, 2016
af252b5
Adding (commented out) build matrix entry for ansible 2.0
EvanK Nov 20, 2016
e4f64ab
Parse existing playbooks and group vars as yaml, in the generator
EvanK Nov 20, 2016
860f3cc
Added upgrade notice for 1.x sites
EvanK Nov 21, 2016
0f50afa
Changed newrelic groupvar name
EvanK Nov 21, 2016
573866c
Replaced sudo with become, to address deprecation warnings
EvanK Nov 21, 2016
36e7a55
Dropped ansible 1.x version of nested_dict lookup
EvanK Nov 21, 2016
112317c
Rewrote ansible tasks in long form
EvanK Nov 23, 2016
173ae16
Ensure outdated node package is removed, along with any source lists
EvanK Nov 23, 2016
d609acb
Output unescaped values in provision playbook template
EvanK Nov 23, 2016
db6b394
Use absolute paths in post-deploy bower install
EvanK Nov 23, 2016
0406d77
Detect and remove otherwise empty bowerrc file, after removing postin…
EvanK Nov 23, 2016
f49f5f3
Merge branch 'master' into 89-update-dependencies
EvanK Jun 1, 2017
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ test/temp/
vendor/
composer.phar
*.pyc

.vimrc

.browserData
59 changes: 41 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,79 @@
sudo: required
dist: trusty
language: generic
cache:
directories:
- $HOME/.rvm
- $HOME/.nvm
- $TRAVIS_BUILD_DIR/vendor
- $TRAVIS_BUILD_DIR/node_modules
addons:
hosts:
- example.com
- local.example.com
- production.example.com
- www.example.com
apt:
packages:
- xvfb
- libgconf2-dev
env:
global:
# DEBUG: "nightmare:*,electron:*"
- DISPLAY: ":99.0"
matrix:
# ANSIBLE_VERSION: "2.0.2"
- ANSIBLE_VERSION: "2.1.3"
- ANSIBLE_VERSION: "2.2.0"
before_install:
# node setup (for yeoman/bower)
- nvm install 0.10
- node --version
- npm --version
- nvm --version
- npm install -g bower
- npm install
# ruby setup (for capistrano)
- rvm install 1.9.3
- rvm use 1.9.3
- gem install bundler
- ruby --version
- rvm --version
- gem --version
- bundle --version
# node setup (for yeoman)
- nvm install 4.0
- node --version
- npm --version
- nvm --version
- npm install -g yo@1.7.1
- yo --version
- npm install
# python setup (for ansible)
- sudo pip install ansible==1.9.4
- sudo pip install urllib3 pyopenssl ndg-httpsclient pyasn1
- sudo pip install ansible==$ANSIBLE_VERSION
- python --version
- pip --version
- ansible --version
# mock up test project, and move to /vagrant for end-user tests
- $PWD/bin/mock
- sudo mv $PWD/temp /vagrant
- ln -s /vagrant $PWD/temp
# copy our local evolution-wordpress as bower dependency
- rm -rf /vagrant/bower_components/evolution-wordpress
- cp -RP $PWD /vagrant/bower_components/evolution-wordpress/
# invoke local provision (as default user with elevated permissions)
# copy our local evolution-wordpress as npm dependency
- mkdir -p /vagrant/node_modules
- cp -RP $PWD /vagrant/node_modules/evolution-wordpress
# set up local provisioner
- sudo cp $PWD/.travis.provision.bin $PWD/bin/provision
- sudo chmod +x $PWD/bin/provision
- sudo $PWD/bin/provision
- sudo chown -Rf $USER:$USER $HOME/.ansible
# mock vagrant binary (for parity with local/remote stages)
- sudo cp $PWD/.travis.vagrant.bin /bin/vagrant
- sudo chmod +x /bin/vagrant
# ensure known ssh fingerprints for remote stages
- ssh-keyscan -H production.example.com >> $HOME/.ssh/known_hosts
- ssh-keyscan -H www.example.com >> $HOME/.ssh/known_hosts
- ssh-keyscan -H example.com >> $HOME/.ssh/known_hosts
# install composer (for phpunit)
- curl -sS https://getcomposer.org/installer | php
# run xvfb as background service
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1024x768x24"
install:
- echo "Provision locally and fix permissions afterward"
- sudo $PWD/bin/provision
- sudo chown -Rf $USER:$USER $HOME/.ansible
- echo "Install Composer dependencies"
- php composer.phar install --dev
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install -n --dev -vv
script:
- ./vendor/bin/phpunit
- npm test
- ./bin/test
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Evolution lets you generate an entirely versioned, multi-environment Wordpress s

## Project Status

Evolution is _largely_ stable and usable at this point, but features are still being added and bugs being fixed. This documentation is also a work in progress.
Evolution is stable and usable in a production environment, but features are still being added and bugs being fixed. Suggestions, bug reports, and pull requests are welcome.

This and [futher documentation](./docs/) are a constant work in progress. Contributions to documentation are _always_ welcome.

## Quick Start

Expand All @@ -37,15 +39,15 @@ You will need:
* [Vagrant](https://www.vagrantup.com/downloads.html) 1.8+
* [VirtualBox](https://www.virtualbox.org/wiki/Downloads) 5+
* [Hostmanager for Vagrant](https://github.com/smdahlen/vagrant-hostmanager#installation)
* [npm](https://docs.npmjs.com/getting-started/installing-node)
* [Node](https://nodejs.org/en/download/) 4.0+
* [Bundler](http://bundler.io/)
* [Ansible](http://docs.ansible.com/intro_installation.html) 1.6+
* [Ansible](http://docs.ansible.com/intro_installation.html) 2.0+
* [sshpass](https://gist.github.com/arunoda/7790979)

You can then use npm to install Bower and the Yeoman generator:
You can then use npm to install the Yeoman generator:

```
npm install -g bower yo generator-evolve
npm install -g yo generator-evolve
```

### Common Workflows
Expand Down
28 changes: 14 additions & 14 deletions bin/import
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/usr/bin/env node

var fs = require('fs');
var fsx = require('fs-extra');
'use strict'

var fs = require('fs-extra');
var os = require('os');
var path = require('path');
var cp = require('child_process');
var util = require('util');
var chalk = require('chalk');
var deasync = require('deasync');
var inquirer = require('inquirer');
var replace = require("replace");
var replace = require('replace');
var yauzl = require('yauzl');

// Evolution site working directory
Expand All @@ -36,7 +37,7 @@ catch(e) {

// extract zip to tmpdir
var extractedPath = path.join(os.tmpdir(), path.basename(answers.zipfile, '.zip'));
fsx.emptyDirSync(extractedPath);
fs.emptyDirSync(extractedPath);

console.log('Extracting', chalk.yellow(answers.zipfile), 'to', chalk.green(extractedPath));
var extractedFiles = 0,
Expand All @@ -52,7 +53,7 @@ yauzl.open(answers.zipfile, {lazyEntries: true}, function(err, zipfile) {
if (/\/$/.test(entry.fileName)) {
// create directories (names ending in '/')
extractedDirs++;
fsx.mkdirs(extractedName, function(err) {
fs.mkdirs(extractedName, function(err) {
if (err) throw err;
zipfile.readEntry();
});
Expand All @@ -62,7 +63,7 @@ yauzl.open(answers.zipfile, {lazyEntries: true}, function(err, zipfile) {
zipfile.openReadStream(entry, function(err, readStream) {
if (err) throw err;
// ensure parent directory exists
fsx.mkdirs(path.dirname(extractedName), function(err) {
fs.mkdirs(path.dirname(extractedName), function(err) {
if (err) throw err;
readStream.pipe(fs.createWriteStream(extractedName));
readStream.on('end', function() {
Expand Down Expand Up @@ -163,21 +164,20 @@ function zipPostProcessing() {
}

// remove known host, only as necessary
var cpExec = deasync(cp.exec);
var execMaxBuffer = 1024*1024*1024;
var cpCmd = '(ssh-keygen -F ' + siteDomain + ' && ssh-keygen -R ' + siteDomain + ') || :';
console.log('checking for (and removing) any existing known host:', chalk.cyan(cpCmd));
cpExec(cpCmd, {cwd: siteDirectory, env: process.env, stdio: 'inherit', maxBuffer: execMaxBuffer});
cp.execSync(cpCmd, {cwd: siteDirectory, env: process.env, stdio: 'inherit', maxBuffer: execMaxBuffer});

// run sql against db
cpCmd = 'bundle exec cap local evolve:db:exec[' + path.join(extractedPath, 'wordpress.sql') + ']';
console.log('importing sql via:', chalk.cyan(cpCmd));
cpExec(cpCmd, {cwd: siteDirectory, env: util._extend(process.env, {evolution_non_interactive: 1}), stdio: 'inherit', maxBuffer: execMaxBuffer});
cp.execSync(cpCmd, {cwd: siteDirectory, env: util._extend(process.env, {evolution_non_interactive: 1}), stdio: 'inherit', maxBuffer: execMaxBuffer});

// list all users via wp-cli
cpCmd = 'bundle exec cap local wp:user:list:--fields=ID,user_login,roles:--format=json';
console.log('listing users via:', chalk.cyan(cpCmd));
var capOut = cpExec(cpCmd, {cwd: siteDirectory, env: process.env, stdio: 'inherit', maxBuffer: execMaxBuffer});
var capOut = cp.execSync(cpCmd, {cwd: siteDirectory, env: process.env, stdio: 'inherit', maxBuffer: execMaxBuffer});

// prompt for role of any users lacking one
var existingUsers = capOut.match(/\s+(\[\{"ID":[^\r\n]+)/);
Expand Down Expand Up @@ -206,26 +206,26 @@ function zipPostProcessing() {

cpCmd = 'bundle exec cap local wp:user:add-role:'+user.ID+':'+answers.role;
console.log('assigning user role via:', chalk.cyan(cpCmd));
cpExec(cpCmd, {cwd: siteDirectory, env: process.env, stdio: 'inherit', maxBuffer: execMaxBuffer});
cp.execSync(cpCmd, {cwd: siteDirectory, env: process.env, stdio: 'inherit', maxBuffer: execMaxBuffer});
}
});
}

// Copying Themes / Plugins / Uploads
var pluginsPath = path.join(extractedPath, 'plugins');
console.log('installing plugins from', chalk.cyan(pluginsPath));
fsx.copySync(pluginsPath, path.join(siteDirectory, 'web', 'wp-content', 'plugins'), {clobber: true});
fs.copySync(pluginsPath, path.join(siteDirectory, 'web', 'wp-content', 'plugins'), {clobber: true});

var themesPath = path.join(extractedPath, 'themes');
console.log('installing themes from', chalk.cyan(themesPath));
fsx.copySync(themesPath, path.join(siteDirectory, 'web', 'wp-content', 'themes'), {clobber: true});
fs.copySync(themesPath, path.join(siteDirectory, 'web', 'wp-content', 'themes'), {clobber: true});

var uploadsPath = path.join(extractedPath, 'uploads');
if (manifest.is_multisite) {
uploadsPath = path.join(uploadsPath, 'sites', manifest.blogid);
}
console.log('installing uploads from', chalk.cyan(uploadsPath));
fsx.copySync(uploadsPath, path.join(siteDirectory, 'web', 'wp-content', 'uploads'), {clobber: true});
fs.copySync(uploadsPath, path.join(siteDirectory, 'web', 'wp-content', 'uploads'), {clobber: true});

console.log(chalk.green('looks like we\'re done here!'));
}
Expand Down
37 changes: 30 additions & 7 deletions bin/mock
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/usr/bin/env node

'use strict'

var fs = require('fs-extra');
var exec = require('child_process').exec;
var helpers = require('yeoman-generator').test;
var cp = require('child_process');
var helpers = require('yeoman-test');
var path = require('path');

var outputDir = path.join(__dirname, '..', 'temp');
var libDir = path.normalize(path.join(__dirname, '..'));
var outputDir = path.join(libDir, 'temp');
var privatePath = path.join(outputDir, '/lib/ansible/files/ssh/id_rsa');
var privateKey = fs.existsSync(privatePath) ? fs.readFileSync(privatePath) : null;
var publicPath = path.join(outputDir, '/lib/ansible/files/ssh/id_rsa.pub');
Expand All @@ -30,14 +33,14 @@ helpers.testDirectory(outputDir, function(err) {
}
else {
var prep = [
'git clone git@github.com:evolution/wordpress-example.git ' + outputDir,
'git clone https://github.com/evolution/wordpress-example.git ' + outputDir,
'cd ' + outputDir,
'git rm -rf .',
];
}

console.log('Executing `%s`', prep.join(' && '));
exec(prep.join(' && '), function(err, stdout, stderr) {
cp.exec(prep.join(' && '), function(err, stdout, stderr) {
if (err) {
throw err;
}
Expand Down Expand Up @@ -111,19 +114,39 @@ helpers.testDirectory(outputDir, function(err) {

fs.writeFileSync(outputDir + '/Vagrantfile', vagrantFile);

var committish;
if (isCI) {
committish = process.env.TRAVIS_COMMIT;
} else {
committish = cp.execSync('git rev-parse --verify HEAD', { cwd: libDir })
.toString().trim();
}

var packageJson = fs.readFileSync(outputDir + '/package.json', 'utf8')
.replace(
new RegExp('("evolution-wordpress":[ ]*)"[^"]+"'),
[
'$1',
`"evolution/wordpress#${committish}"`,
].join('')
)
;

fs.writeFileSync(outputDir + '/package.json', packageJson);

var wrap = [
'git add .',
];

if (isCI) {
Array.prototype.push.apply(wrap, [
'git commit -m "Something to deploy"',
'git remote add origin ' + outputDir + '/.git',
'git remote add origin /vagrant/.git',
]);
}

console.log('Executing `%s`', wrap.join(' && '));
exec(wrap.join(' && '), { cwd: outputDir });
cp.exec(wrap.join(' && '), { cwd: outputDir });
});
});
});
Loading