Permalink
Browse files

Implement a target task to specify deployment targets. Update wordpre…

…ss-client helper accordingly. Fixes #4 - CLI flag for config file
  • Loading branch information...
1 parent e06e6d6 commit 3a10ccc2bd38585ec243bf8fd56b16f115a848b1 @jzaefferer jzaefferer committed with Jul 12, 2012
Showing with 42 additions and 1 deletion.
  1. +28 −0 README.md
  2. +14 −1 tasks/wordpress.js
View
@@ -31,13 +31,41 @@ grunt.initConfig({
});
```
+This works for a single deployment target. If you have multiple targets, you
+can specify url, username and password for each:
+
+```javascript
+grunt.initConfig({
+ wordpress: {
+ dev: {
+ url: "wordpress.dev",
+ username: "admin",
+ password: "admin",
+ },
+ live: {
+ url: "wordpress.com",
+ username: "admin",
+ password: "admin",
+ },
+ _default: "dev",
+ dir: "dist"
+ }
+});
+```
+
+If nothing is specified, the `_default` target is used. Override using the
+target task:
+
+ grunt target:live deploy
+
* `url`: The URL for the WordPress install.
Can be a full URL, e.g., `http://wordpress.dev:123/some/path`
or as short as just the host name.
If the protocol is `https`, then a secure connection will be used.
* `username`: WordPress username.
* `password`: WordPress password.
* `dir`: Directory containing posts, taxonomies, and resources (see [Directory Structure](#directory-structure)).
+* `_default`: The default deployment target, optional.
### Directory Structure
View
@@ -32,9 +32,18 @@ grunt.registerHelper( "wordpress-recurse", function recurse( rootdir, fn, comple
});
});
+function config() {
+ var target = grunt.config( "target" ) || grunt.config( "wordpress._default" ),
+ base = grunt.config( "wordpress" );
+ if ( target ) {
+ return base[ target ];
+ }
+ return base;
+}
+
grunt.registerHelper( "wordpress-client", function() {
if ( !_client ) {
- _client = wordpress.createClient( grunt.config( "wordpress" ) );
+ _client = wordpress.createClient( config() );
}
return _client;
});
@@ -124,6 +133,10 @@ grunt.registerTask( "wordpress-validate", "Validate HTML files for synchronizing
});
});
+grunt.registerTask( "target", "Runtime configuration to choose deployment target", function( target ) {
+ grunt.config.set( "target", target );
+});
+
grunt.registerTask( "wordpress-publish", "wordpress-validate wordpress-sync" );
grunt.registerTask( "wordpress-deploy", "build-wordpress wordpress-publish" );
grunt.registerTask( "deploy", "wordpress-deploy" );

0 comments on commit 3a10ccc

Please sign in to comment.