#!/usr/bin/env node

/*!
 * Chameleon
 *
 * Copyright 2014 ghostwords.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 */

var moment = require('moment'),
	shell = require('shelljs');

var package_name = [
	'chameleon',
	require('../chrome/manifest.json').version,
	moment().format('YYYY-MM-DD')
].join('_');

// copy chrome/** to dist/
shell.cp('-R', 'chrome/**', 'dist/' + package_name);

// create the drag-and-drop installable CRX package
shell.exit(shell.exec(
	'cd dist && ../tools/crxmake.sh ' + package_name + ' ~/.ssh/chameleon.pem'
).code);

// TODO create the zip for uploading to Chrome Web Store
// TODO make this is the "release" task (also tags, ...)
// https://developer.chrome.com/extensions/packaging
// 1. Rename the private key that was generated when you created the .crx file to key.pem.
// 2. Put key.pem in the top directory of your extension.
// 3. Compress that directory into a ZIP file.
// 4. Upload the ZIP file using the Chrome Developer Dashboard.
// TODO No need to do the key.pem thing for updates, right?

@@ -550,24 +550,65 @@
 ;%0A%0A// create
+ the builds%0Avar result = shell.exec(%5B%0A%09//
  the drag-an
@@ -642,31 +642,8 @@
 age%0A
-shell.exit(shell.exec(%0A
 %09'cd
@@ -651,12 +651,13 @@
 dist
- && 
+',%0A%09'
 ../t
@@ -718,135 +718,244 @@
 pem'
-%0A).code);%0A%0A// TODO create the zip for uploading to Chrome Web Store%0A// TODO make this is the %22release%22 task (also tags, ...)%0A//
+,%0A%09// the zip file for Web Store (only good for updates, see note below)%0A%09'cd ../chrome',%0A%09'zip -qr -9 -X ../dist/' + package_name + '.zip .'%0A%5D.join(' && ')).code;%0A%0Ashell.exit(result);%0A%0A/*%0A * for new Web Store uploads (not updates), see
  htt
@@ -1001,18 +1001,21 @@
 ckaging%0A
-//
+ *%0A *
  1. Rena
@@ -1095,18 +1095,18 @@
 ey.pem.%0A
-//
+ *
  2. Put 
@@ -1153,18 +1153,18 @@
 ension.%0A
-//
+ *
  3. Comp
@@ -1200,18 +1200,18 @@
 P file.%0A
-//
+ *
  4. Uplo
@@ -1268,64 +1268,8 @@
 rd.%0A
-// TODO No need to do the key.pem thing for updates, right?
+ */
 %0A

Create ZIP builds (for Web Store).