Permalink
Browse files

Added basic build script

  • Loading branch information...
aduston committed Jan 9, 2012
1 parent 0f0cce8 commit a7b49f570613d731463c66fe5d29a1a145088f20
Showing with 62 additions and 10 deletions.
  1. +2 −0 .gitignore
  2. +52 −0 build.py
  3. +2 −0 incrwd/build-local.php
  4. +2 −0 incrwd/build-production.php
  5. +4 −10 incrwd/incrwd.php
View
@@ -1 +1,3 @@
*~
+incrwd/build.php
+build/*
View
@@ -0,0 +1,52 @@
+import subprocess
+import getopt
+import shutil
+import re
+import os
+import sys
+
+PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
+
+def _rel(*x):
+ return os.path.join(PROJECT_ROOT, *x)
+
+def _run(cmd):
+ print("Running {0}".format(" ".join(cmd)))
+ process = subprocess.Popen(
+ cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ output, err = process.communicate()
+ print(output)
+ print(err)
+
+def _find_version():
+ with open(_rel('incrwd/incrwd.php')) as f:
+ text = f.read()
+ return re.search(r"Version:\s*([\d\.]+)", text).group(1)
+
+def _copy_build(local_only):
+ file_name = "incrwd/build-{0}.php".format(
+ "local" if local_only else "production")
+ shutil.copy(_rel(file_name), _rel("incrwd/build.php"))
+
+def _zip(version):
+ _run(["zip", "-r",
+ _rel("build/incrwd-{0}.zip".format(version)),
+ "incrwd",
+ "-x", "*~"])
+
+def _main(argv):
+ opts, args = getopt.getopt(argv, "r", ["release"])
+ local_only = True
+ for opt, arg in opts:
+ if opt in ("-r", "--release"):
+ local_only = False
+ print("You are running the {0} deployment.\n".format(
+ "local" if local_only else "production"))
+ version = _find_version()
+ _copy_build(local_only)
+ _zip(version)
+
+
+_main(sys.argv[1:])
View
@@ -0,0 +1,2 @@
+<?php
+define('INCRWD_LOCAL', true);
@@ -0,0 +1,2 @@
+<?php
+define('INCRWD_LOCAL', false);
View
@@ -1,25 +1,19 @@
<?php
/*
Plugin Name: Incrwd Engagement Rewards System
-Plugin URI: http://myincrwd.com/
+Plugin URI: http://www.myincrwd.com/
Description: The Incrwd Engagement Rewards System adds an awesome rewards widget to your site that will measurably improve the metrics you care about the most.
Author: Incrwd <team@myincrwd.com>
Version: 3
Author URI: http://myincrwd.com/
*/
-/*.
- require_module 'standard';
- require_module 'pcre';
-.*/
-
+require_once(dirname(__FILE__) . '/build.php');
require_once(dirname(__FILE__) . '/lib/utils.php');
require_once(dirname(__FILE__) . '/incrwd-embed.php');
require_once(dirname(__FILE__) . '/lib/wp-api.php');
-define('INCRWD_LOCAL', true);
-
-if (defined('INCRWD_LOCAL')) { // Incrwd defines this for local dev
+if (defined('INCRWD_LOCAL') && INCRWD_LOCAL) { // Incrwd defines this for local dev
define('INCRWD_API_URL', 'http://incrwd.example.com/w/api/');
define('INCRWD_JS_URL', '');
} else {
@@ -35,7 +29,7 @@ function incrwd_options() {
function incrwd_output_footer() {
incrwd_embed(get_option('incrwd_site_id'),
- defined('INCRWD_LOCAL'),
+ defined('INCRWD_LOCAL') && INCRWD_LOCAL,
INCRWD_JS_URL, incrwd_sso());
}
add_action('wp_footer', 'incrwd_output_footer');

0 comments on commit a7b49f5

Please sign in to comment.