wp-local-build-script v1.4.1
40digits Local Wordpress Setup
A build script that sets up your local dev environment faster than you can
$ say -v g "Restart apache".
Things it does:
- Renames the theme folder to whatever the site name is, which is typically the repo slug and/or base directory name
- Creates a vhost file
- Writes an entry in your hosts file
- Creates a database
- Creates
wp-config.php - Restarts apache
- Opens url in browser (optional)
Options
Since everyone is a snowflake, here are available options for configuration and their defaults.
siteName: path.basename(path.join(__dirname.toString(), '..', '..')): The name of the site/repo. Defaults to the project directory name, which is normalized based on being atrepo-name/node_modules/wp-local-build-script/. Adjust as needed. No spaces, please.localUrl: 'l.<%= siteName %>': The url you want. This is rendered with ejs based onsiteName.vhostsDir: '/etc/apache2/extra/vhosts/': The directory in which to keep your vhost.conffiles.hostsFile: '/etc/hosts': The location of your hosts file.httpPort: '80': The port number you use in your vhosts.customLog: '/http-logs/<%= siteName %>.log': Log path. This is for the vhost configuration. Rendered with ejs usingsiteName.errorLog: '/http-logs/<%= siteName %>.error.log': The path for the apache error logs. Also rendered with ejs using thesiteName.mysqlUser: 'root': Your MySQL username.mysqlPw: '': Your MySQL password.open: false: Open the newly created url in your default browser.apache24: true: When using apache 2.4, you may experience a 403 when visiting the newly created url. This adds a directive to the vhosts that fixes the issue.
Instructions :rooster::dash:
Create
gulpfile.jsin the project rootvar gulp = require('gulp'), build = require('wp-local-build-script'); gulp.task('build', build);Or using custom configuration. See above for a complete list of available options.
var gulp = require('gulp'), build = require('wp-local-build-script'); gulp.task('build', build({ localUrl: '<%= siteName %>.dev', mysqlUser: 'admin', mysqlPw: '1234' }));$ sudo gulp build$ say -v "Pipe Organ" "CAN YOU DIG IT?"- :feelsgood:
Considerations
I've noticed that if the apache log paths don't exist, you'll get weird behavior. So make sure those are valid paths.