couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject [1/2] git commit: updated refs/heads/1989-move-couchjs-node-to-extra to 6d66d5b
Date Sun, 05 Jan 2014 09:23:33 GMT
Updated Branches:
  refs/heads/1989-move-couchjs-node-to-extra [created] 6d66d5bf7


move couchjs-node from src to extra

Since the build of couchjs-node is optional we should put it outside of
the src/ folder and move it to an `extra` folder (and the same for all
extras). The reasoning behind is that we should separate more clearly
what is an addon from what is the core product.

fix #COUCHDB-1989


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/6d66d5bf
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/6d66d5bf
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/6d66d5bf

Branch: refs/heads/1989-move-couchjs-node-to-extra
Commit: 6d66d5bf79327ce620c319e909d3c5f01ec0cd41
Parents: 12c9ee0
Author: Benoit Chesneau <benoitc@apache.org>
Authored: Sun Jan 5 10:20:20 2014 +0100
Committer: Benoit Chesneau <benoitc@apache.org>
Committed: Sun Jan 5 10:22:53 2014 +0100

----------------------------------------------------------------------
 Makefile.am                           |   2 +-
 configure.ac                          |  13 +--
 extra/Makefile.am                     |  13 +++
 extra/couchjs-node/Makefile.am        |  24 ++++++
 extra/couchjs-node/README.md          |  32 +++++++
 extra/couchjs-node/cli.js             |  89 +++++++++++++++++++
 extra/couchjs-node/console.js         |  66 ++++++++++++++
 extra/couchjs-node/couchdb.js         |  29 +++++++
 extra/couchjs-node/couchjs.js         | 133 +++++++++++++++++++++++++++++
 extra/couchjs-node/inspector.js       | 101 ++++++++++++++++++++++
 extra/couchjs-node/package.json       |  40 +++++++++
 extra/couchjs-node/sandbox.js         |  47 ++++++++++
 extra/couchjs-node/stream.js          | 115 +++++++++++++++++++++++++
 extra/couchjs-node/test/experiment.js | 125 +++++++++++++++++++++++++++
 extra/couchjs-node/xml.js             |  22 +++++
 license.skip                          |  12 +--
 share/doc/src/experimental.rst        |   2 +-
 src/Makefile.am                       |   3 +-
 src/couchjs-node/Makefile.am          |  24 ------
 src/couchjs-node/README.md            |  32 -------
 src/couchjs-node/cli.js               |  89 -------------------
 src/couchjs-node/console.js           |  66 --------------
 src/couchjs-node/couchdb.js           |  29 -------
 src/couchjs-node/couchjs.js           | 133 -----------------------------
 src/couchjs-node/inspector.js         | 101 ----------------------
 src/couchjs-node/package.json         |  40 ---------
 src/couchjs-node/sandbox.js           |  47 ----------
 src/couchjs-node/stream.js            | 115 -------------------------
 src/couchjs-node/test/experiment.js   | 125 ---------------------------
 src/couchjs-node/xml.js               |  22 -----
 30 files changed, 853 insertions(+), 838 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 22809f8..9dbfc12 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,7 +10,7 @@
 ## License for the specific language governing permissions and limitations under
 ## the License.
 
-SUBDIRS = bin etc src share test var utils
+SUBDIRS = bin etc extra src share test var utils
 
 ACLOCAL_AMFLAGS = -I m4
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 57a4268..434c7df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -445,7 +445,7 @@ has_crypto=`\
 
 if test -n "$has_crypto"; then
     AC_MSG_ERROR([Could not find the Erlang crypto library.
-    
+
 Has Erlang been compiled with OpenSSL support?])
 fi
 
@@ -453,7 +453,7 @@ AC_PATH_PROG([ERLC], [erlc])
 
 if test x${ERLC} = x; then
     AC_MSG_ERROR([Could not find the `erlc' executable.
-    
+
 Is Erlang installed?])
 fi
 
@@ -566,7 +566,7 @@ AC_CHECK_PROG([HAS_PDFLATEX], [pdflatex], [yes])
 if test x${HAS_PDFLATEX} = x; then
     if test x${strictness_enabled} = xyes; then
         AC_MSG_ERROR([Could not find the `pdflatex' executable.
-    
+
 Is LaTeX installed?])
     else
         AC_MSG_WARN([You will be unable to regenerate PDF documentation.])
@@ -578,7 +578,7 @@ AC_CHECK_PROG([HAS_MAKEINFO], [makeinfo], [yes])
 if test x${HAS_MAKEINFO} = x; then
     if test x${strictness_enabled} = xyes; then
         AC_MSG_ERROR([Could not find the `makeinfo' executable.
-    
+
 Is GNU Texinfo installed?])
     else
         AC_MSG_WARN([You will be unable to regenerate info documentation.])
@@ -590,7 +590,7 @@ AC_CHECK_PROG([HAS_INSTALLINFO], [install-info], [yes])
 if test x${HAS_INSTALLINFO} = x; then
     if test x${strictness_enabled} = xyes; then
         AC_MSG_ERROR([Could not find the `install-info' executable.
-    
+
 Is GNU Texinfo installed?])
     else
         AC_MSG_WARN([You will be unable to install info documentation.])
@@ -727,6 +727,8 @@ AC_CONFIG_FILES([etc/logrotate.d/couchdb.tpl])
 AC_CONFIG_FILES([etc/logrotate.d/Makefile])
 AC_CONFIG_FILES([etc/windows/Makefile])
 AC_CONFIG_FILES([etc/Makefile])
+AC_CONFIG_FILES([extra/couchjs-node/Makefile])
+AC_CONFIG_FILES([extra/Makefile])
 AC_CONFIG_FILES([share/Makefile])
 AC_CONFIG_FILES([share/doc/Makefile])
 AC_CONFIG_FILES([share/doc/build/Makefile])
@@ -736,7 +738,6 @@ AC_CONFIG_FILES([src/couch_index/Makefile])
 AC_CONFIG_FILES([src/couch_mrview/Makefile])
 AC_CONFIG_FILES([src/couch_plugins/Makefile])
 AC_CONFIG_FILES([src/couch_replicator/Makefile])
-AC_CONFIG_FILES([src/couchjs-node/Makefile])
 AC_CONFIG_FILES([src/couchdb/couch.app.tpl])
 AC_CONFIG_FILES([src/couchdb/Makefile])
 AC_CONFIG_FILES([src/couchdb/priv/Makefile])

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/Makefile.am
----------------------------------------------------------------------
diff --git a/extra/Makefile.am b/extra/Makefile.am
new file mode 100644
index 0000000..65b0da2
--- /dev/null
+++ b/extra/Makefile.am
@@ -0,0 +1,13 @@
+## Licensed under the Apache License, Version 2.0 (the "License"); you may not
+## use this file except in compliance with the License. You may obtain a copy of
+## the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+## License for the specific language governing permissions and limitations under
+## the License.
+
+SUBDIRS = couchjs-node

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/Makefile.am
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/Makefile.am b/extra/couchjs-node/Makefile.am
new file mode 100644
index 0000000..2e402ae
--- /dev/null
+++ b/extra/couchjs-node/Makefile.am
@@ -0,0 +1,24 @@
+e# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+## use this file except in compliance with the License. You may obtain a copy of
+## the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+## License for the specific language governing permissions and limitations under
+## the License.
+
+EXTRA_DIST = \
+  cli.js \
+  console.js \
+  couchdb.js \
+  couchjs.js \
+  inspector.js \
+  package.json \
+  README.md \
+  sandbox.js \
+  stream.js \
+  test/experiment.js \
+  xml.js

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/README.md
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/README.md b/extra/couchjs-node/README.md
new file mode 100644
index 0000000..551c3df
--- /dev/null
+++ b/extra/couchjs-node/README.md
@@ -0,0 +1,32 @@
+# CouchJS
+
+## Drop-in replacement JavaScript engine for Apache CouchDB
+
+CouchJS is a command-line Node.js program. It is 100% compatible with Apache CouchDB's built-in JavaScript system.
+
+By using CouchJS, you will get 100% CouchDB compatibility (the test suite completely passes) but your JavaScript environment is V8, or Node.js.
+
+See share/doc/src/experimental.rst for installation instructions.
+
+## Idea
+
+JavaScript is decoupled from the CouchDB core. To do JavaScript stuff, CouchDB runs a normal Unix subprocess, `couchjs`. This subprocess is just a read-eval-print loop on standard i/o. CouchDB passes `couchjs` a file name, and *that file* contains the view server  implementation.
+
+This tool duplicates the "REPL" look and feel of `couchjs` and supports the exact same view server implementation.
+
+## Security
+
+I have no idea. I would not trust it for production use.
+
+## Log
+
+If you create a file, `/tmp/couchjs.log` then *couchjs* will output debugging messages there.
+
+## License
+
+Apache 2.0
+
+See the [Apache 2.0 license](named/blob/master/LICENSE).
+
+[tap]: https://github.com/isaacs/node-tap
+[def]: https://github.com/iriscouch/defaultable

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/cli.js
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/cli.js b/extra/couchjs-node/cli.js
new file mode 100755
index 0000000..5447dd5
--- /dev/null
+++ b/extra/couchjs-node/cli.js
@@ -0,0 +1,89 @@
+#!/usr/bin/env node
+
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+var fs = require('fs');
+var Fiber = require('fibers');
+var optimist = require('optimist');
+
+var couchjs = require('./couchjs');
+var package_json = require('./package.json');
+var LineStream = require('./stream');
+var inspector = require('./inspector');
+var log = require('./console').log;
+
+
+var opts = optimist.boolean(['h', 'V', 'H'])
+                   .describe({ 'h': 'display a short help message and exit',
+                             'V': 'display version information and exit',
+                             'H': 'enable couchjs cURL bindings (not implemented)'
+                             })
+                   .usage('$0 <path to main.js>');
+
+
+function main() {
+
+  'use strict';
+
+  var main_js = opts.argv._[0];
+
+  if (!main_js) {
+    return console.error(opts.help());
+  }
+
+  log('couchjs/%s %s: %s', package_json.version, process.pid, main_js);
+
+  if (process.env.COUCHJS_DEBUG_PORT) {
+    inspector(+process.env.COUCHJS_DEBUG_PORT);
+  }
+
+  fs.readFile(main_js, 'utf8', function(er, body) {
+    if (er) {
+      throw er;
+    }
+
+    var stdin = new LineStream.v2();
+
+    stdin.on('readable', function() {
+      var buf = stdin.read();
+
+      if (buf) {
+        couchjs.stdin(buf);
+      }
+    });
+
+    stdin.on('end', function() {
+      log('Terminate; connection to parent closed');
+      process.exit(0);
+    });
+
+    process.stdin.setEncoding('utf8');
+    process.stdin.pipe(stdin);
+
+    var main_func = Function(['print', 'readline', 'evalcx', 'gc', 'quit'], body);
+
+    log('Call main');
+
+    new Fiber(function() {
+      main_func(couchjs.print, couchjs.readline, couchjs.evalcx, couchjs.gc);
+    }).run();
+  });
+
+  process.on('uncaughtException', function(er) {
+    log('Error:\n%s', er.stack);
+  });
+}
+
+if (require.main === module) {
+  main();
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/console.js
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/console.js b/extra/couchjs-node/console.js
new file mode 100644
index 0000000..18e7241
--- /dev/null
+++ b/extra/couchjs-node/console.js
@@ -0,0 +1,66 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+var fs = require('fs');
+var util = require('util');
+
+var noop = function() {};
+
+module.exports = {};
+module.exports.log = noop;
+module.exports.debug = noop;
+module.exports.info = noop;
+module.exports.warn = noop;
+module.exports.error = noop;
+
+var LOG_PATH = '/tmp/couchjs.log';
+var stat = null;
+var LOG = null;
+
+try {
+  stat = fs.statSync(LOG_PATH);
+} catch(er) {}
+
+if (stat) {
+  LOG = fs.createWriteStream(LOG_PATH, {
+    'flags':'a'
+  });
+
+  var log = function () {
+    var str = util.format.apply(this, arguments);
+    LOG.write(str + '\n');
+  };
+
+  var on_err = function (er) {
+    module.exports.error('Uncaught error:\n%s', er.stack || er.message || JSON.stringify(er));
+
+    if (er.stack) {
+      er = ['fatal', 'unknown_error', er.stack];
+    }
+
+    process.stdout.write(JSON.stringify(er) + '\n');
+    process.exit(1);
+  };
+
+  module.exports.log = log;
+  module.exports.debug = log;
+  module.exports.info = log;
+  module.exports.warn = log;
+  module.exports.error = log;
+
+  process.on('exit', function() {
+    module.exports.log('Exit %d', process.pid);
+  });
+
+  process.on('uncaughtException', on_err);
+}
+

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/couchdb.js
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/couchdb.js b/extra/couchjs-node/couchdb.js
new file mode 100755
index 0000000..d420540
--- /dev/null
+++ b/extra/couchjs-node/couchdb.js
@@ -0,0 +1,29 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+
+var http = require('http');
+
+function handler(req, res) {
+  res.writeHead(200);
+  res.end('Hello: ' + req.url + '\n');
+}
+
+if (require.main === module) {
+  var http = require('http');
+  var server = http.createServer(handler);
+
+  server.listen(3000);
+  console.log('Listening on :3000');
+}
+
+module.exports = handler;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/couchjs.js
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/couchjs.js b/extra/couchjs-node/couchjs.js
new file mode 100644
index 0000000..ccc1aa9
--- /dev/null
+++ b/extra/couchjs-node/couchjs.js
@@ -0,0 +1,133 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+
+
+var vm = require('vm');
+var Fiber = require('fibers');
+var util = require('util');
+
+var XML = require('./xml');
+var log = require('./console').log;
+
+var INPUT = {
+  'queue':[],
+  'waiting':null
+};
+
+
+function print(line) {
+  log('STDOUT %s: %s', process.pid, line);
+  process.stdout.write(line + '\n');
+
+  try {
+    line = JSON.parse(line);
+  } catch(er) {
+    return;
+  }
+
+  if (line[0] === 'log') {
+    log('LOG: %s', line[1]);
+  }
+}
+
+function stdin (line) {
+  log('STDIN %s: %s', process.pid, line.trim());
+
+  if (INPUT.waiting) {
+    INPUT.waiting.run(line);
+  } else {
+    INPUT.queue.push(line);
+  }
+}
+
+function readline () {
+  var line = INPUT.queue.shift();
+
+  if (line) {
+    return line;
+  }
+
+  INPUT.waiting = Fiber.current;
+  line = Fiber.yield();
+  INPUT.waiting = null;
+
+  return line;
+}
+
+
+function evalcx (source, sandbox) {
+  sandbox = sandbox || {};
+  var func;
+  //log('evalcx in %j: %j', Object.keys(sandbox), source)
+
+  if (source === '') {
+    return sandbox;
+  }
+
+  // source might be "function(doc) { emit(doc._id, 1) }"
+  source = source.replace(/;+$/, '');
+
+  sandbox.XML = sandbox.XML || XML;
+  source = '(' + source + ')';
+
+  try {
+    var id = Math.floor(Math.random() * 1000*1000);
+    var filename = '_couchdb:' + id + '.js';
+    var script = vm.createScript(source, filename);
+    func = script.runInNewContext(sandbox);
+  } catch (er) {
+    log('Error making code: %s', er.stack);
+    return sandbox;
+  }
+
+  return func;
+}
+
+function quit(code) {
+  code = code || 1;
+  if (code < 0) {
+    code = -code;
+  }
+
+  process.exit(code);
+}
+
+function gc() { }
+
+
+function toSource() {
+  if (typeof this === 'function') {
+    return '' + this;
+  }
+
+  if (this instanceof Error) {
+    return this.stack;
+  }
+
+  return util.inspect(this);
+}
+
+Error.prototype.toSource = Error.prototype.toSource || toSource;
+Error.prototype.toString = Error.prototype.toString || toSource;
+Function.prototype.toSource = Function.prototype.toSource || toSource;
+Function.prototype.toString = Function.prototype.toString || toSource;
+
+module.exports = {
+  'print': print,
+  'readline': readline,
+  'stdin': stdin,
+  'evalcx': evalcx,
+  'quit': quit,
+  'gc': gc
+};
+

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/inspector.js
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/inspector.js b/extra/couchjs-node/inspector.js
new file mode 100755
index 0000000..48182e5
--- /dev/null
+++ b/extra/couchjs-node/inspector.js
@@ -0,0 +1,101 @@
+#!/usr/bin/env node
+
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+
+
+var cp = require('child_process');
+var log = require('./console').log;
+
+function watchInspector(child) {
+
+  child.stderr.on('data', function(body) {
+    log('Inspector STDERR: %s', body);
+  });
+
+  child.stdout.on('data', function(body) {
+    log('Inspector STDOUT: %s', body);
+  });
+
+  child.on('exit', function(code, signal) {
+    log('Inspector exited %d signal=%j', code, signal);
+    process.exit(code);
+  });
+
+  process.on('exit', function() {
+    log('Kill inspector upon exit: %d', child.pid);
+    process.kill(child.pid, 'SIGTERM');
+  });
+
+}
+
+function start (debugPort) {
+
+  if (!debugPort || typeof debugPort !== 'number') {
+    throw new Error('Need a listen debugPort');
+  }
+
+  var webPort = debugPort + 1;
+  var cmd = __filename;
+  var args = [debugPort, webPort];
+  var opts = {
+    'cwd': __dirname,
+    'stdio': 'pipe',
+    'detached': false
+  };
+
+  log('Start inspector: %s %j %j', cmd, args, opts);
+
+  var inspector = cp.spawn(cmd, args, opts);
+
+  watchInspector(inspector);
+
+  log('Enable remote debug pid=%d port=%d', process.pid, debugPort);
+
+  process.debugPort = debugPort;
+  process.kill(process.pid, 'SIGUSR1');
+}
+
+function main() {
+  var debugPort = +process.argv[2];
+  var webPort = +process.argv[3];
+
+  if (!debugPort || !webPort) {
+    throw new Error('Bad arguments: need debugPort and webPort');
+  }
+
+  console.log('Start inspector debugPort=%j webPort=%j', debugPort, webPort);
+
+  var DebugServer = require('node-inspector/lib/debug-server');
+  var server = new DebugServer();
+
+  server.on('close', function() {
+    console.log('Server closed');
+    process.exit(0);
+  });
+
+  server.start({
+    'webPort':webPort,
+    'debugPort':debugPort
+  });
+
+  process.on('uncaughtException', function(er) {
+    console.log('Error:\n%s', er.stack);
+  });
+}
+
+module.exports = start;
+
+if (require.main === module) {
+  main();
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/package.json
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/package.json b/extra/couchjs-node/package.json
new file mode 100644
index 0000000..445f3b9
--- /dev/null
+++ b/extra/couchjs-node/package.json
@@ -0,0 +1,40 @@
+{
+  "name": "couchjs",
+  "description": "Drop-in replacement for CouchDB JavaScript view server",
+  "keywords": [ "couchdb", "couchjs" ],
+  "version": "0.3.2",
+  "author": "Jason Smith <jhs@iriscouch.com> (http://www.iriscouch.com)",
+  "repository": {
+    "type":"git",
+    "url":"https://github.com/iriscouch/couchjs"
+  },
+  "engines": {
+    "node": ">= 0.8"
+  },
+  "main": "./couchjs.js",
+  "bin": {
+    "couchjs-node":"./cli.js"
+  },
+  "couchdb": {
+    "main":"./couchdb.js",
+    "vhosts": [
+      "127.0.0.1.xip.io"
+    ]
+  },
+  "bundledDependencies": [
+    "node-inspector"
+  ],
+  "dependencies": {
+    "optimist": "~0.3.4",
+    "async"   : "~0.2.5",
+    "mkdirp"  : "~0.3.4",
+    "fibers"  : "~1.0.0",
+    "request" : "~2.9.203",
+    "pushover": "~1.2.1",
+    "defaultable": "~0.7.2",
+    "node-inspector": "git://github.com/iriscouch/node-inspector#couchjs"
+  },
+  "devDependencies": {
+    "tap": "~0.2.5"
+  }
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/sandbox.js
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/sandbox.js b/extra/couchjs-node/sandbox.js
new file mode 100644
index 0000000..5c18ef4
--- /dev/null
+++ b/extra/couchjs-node/sandbox.js
@@ -0,0 +1,47 @@
+// from https://github.com/KlausTrainer/sandbox.js
+exports.runInSandbox = function(src, ctx, whitelist) {
+  var vm = require('vm');
+  var sandbox;
+
+  if (ctx && ctx.require) {
+
+    whitelist = whitelist || [];
+
+    var insecureRequire = ctx.require;
+    var module = require('module');
+    var oldModulePrototype = module.prototype;
+
+    var secureRequire = function(moduleName) {
+
+      if (whitelist.indexOf(moduleName) === -1) {
+        module.prototype = oldModulePrototype;
+
+        throw new Error("'" + moduleName + "' is not whitelisted");
+
+      } else {
+        var requiredModule = insecureRequire(moduleName);
+
+        module.prototype = oldModulePrototype;
+
+        return requiredModule;
+      }
+    };
+
+    module.prototype = {
+      require: secureRequire,
+      load: module.prototype.load,
+      _compile: module.prototype._compile
+    };
+
+    module._cache = {};
+
+    ctx.require = secureRequire;
+    sandbox = Object.freeze(vm.createContext(ctx));
+    ctx.require = insecureRequire;
+
+  } else {
+    sandbox = Object.freeze(vm.createContext(ctx || {}));
+  }
+
+  return vm.createScript('(function() {"use strict"; return (' + src + ')()}())').runInContext(sandbox);
+};

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/stream.js
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/stream.js b/extra/couchjs-node/stream.js
new file mode 100644
index 0000000..ebffc30
--- /dev/null
+++ b/extra/couchjs-node/stream.js
@@ -0,0 +1,115 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+// Text line stream
+
+var stream = require('stream');
+var util = require('util');
+
+
+function LineStream() {
+
+  var self = this;
+  stream.call(self);
+
+  self.readable = true;
+  self.writable = true;
+
+  self.buffer = '';
+  self.downstream = null;
+
+  self.on('pipe', function(upstream) {
+    upstream.on('end', function(data, encoding) {
+      self.emit('end', data, encoding);
+    });
+  });
+}
+
+function LineStream2() {
+
+  if (!(this instanceof LineStream2)) {
+    return new LineStream2();
+  }
+
+  stream.Transform.call(this);
+  this.setEncoding('utf8');
+}
+
+util.inherits(LineStream2, stream.Transform);
+
+LineStream2.prototype._transform = function(message, encoding, done) {
+  var self = this;
+
+  message = message.toString(encoding);
+  var lines = message.split(/\n/);
+
+  // If the data ends in "\n" this will be ""; otherwise the final partial line.
+  var remainder = lines.pop();
+  if (remainder) {
+    this.unshift(remainder);
+  }
+
+  lines.forEach(function(line) {
+    self.push(line);
+  });
+
+  done();
+};
+
+util.inherits(LineStream, stream);
+
+
+
+LineStream.prototype.write = function(data) {
+  var self = this;
+
+  data = data || '';
+  if (typeof data !== 'string') {
+    return self.error(new Error('Data was not a string: ' + util.inspect(data)));
+  }
+
+  self.buffer += data;
+  var lines = self.buffer.split(/\n/);
+  self.buffer = lines.pop(); // If the data ended in "\n" this will be ""; otherwise the final partial line.
+
+  lines.forEach(function(line) {
+    self.emit('data', line);
+  });
+};
+
+
+LineStream.prototype.end = function(data) {
+  var self = this;
+
+  self.is_ending = true;
+  self.writable = false;
+
+  // Always call write, even with no data, so it can fire the "end" event.
+  self.write(data);
+};
+
+
+LineStream.prototype.error = function(er) {
+  var self = this;
+
+  self.readable = false;
+  self.writable = false;
+  self.emit('error', er);
+
+  // The write() method sometimes returns this value, so if there was an error, make write() return false.
+  return false;
+};
+
+
+module.exports = LineStream;
+module.exports.v2 = LineStream2;
+

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/test/experiment.js
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/test/experiment.js b/extra/couchjs-node/test/experiment.js
new file mode 100644
index 0000000..9197ec6
--- /dev/null
+++ b/extra/couchjs-node/test/experiment.js
@@ -0,0 +1,125 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+var vm = require('vm');
+var util = require('util');
+
+var STATE = 'wait';
+
+function main() {
+  process.debugPort = 5859;
+  process.kill(process.pid, 'SIGUSR1');
+
+  setTimeout(function() {
+    stuff(0);
+  }, 1000);
+}
+
+function stuff(count) {
+
+  console.log('Doing stuff: %d', count);
+  STATE = 'vm';
+  console.log('More stuff: %d', count);
+
+  if (STATE === 'done') {
+    console.log('Done');
+  } else if (STATE === 'code') {
+    setTimeout(code, 1000);
+  } else if(STATE === 'eval') {
+    test_eval();
+  } else if(STATE === 'vm') {
+    test_vm();
+  } else if(STATE === 'wait') {
+    setTimeout(function() {
+      stuff(count+1);
+    }, 1000);
+  } else {
+    throw new Error('Unknown state: ' + STATE);
+  }
+}
+
+function code() {
+  var code = [
+    'var foo = "in the code"',
+    'console.log("This is some code")',
+    'debugger',
+    'console.log("foo = " + foo)'
+    ].join('\n');
+
+  var runner = Function([], code);
+
+  console.log('Run runner in 1s');
+
+  setTimeout(run_runner, 1000)
+
+  function run_runner() {
+    console.log('About to run runner');
+    debugger;
+    runner();
+    console.log('Runner done');
+  }
+}
+
+function test_eval() {
+  console.log('Test eval in 1s');
+  setTimeout(run_eval, 1000);
+
+  var code = [
+    'var foo = "in eval"',
+    'console.log("This is eval")',
+    'debugger',
+    'console.log("foo = " + foo)'
+    ].join('\n');
+
+  function run_eval() {
+    console.log('Run eval now');
+    debugger;
+    eval(code);
+  }
+}
+
+function test_vm() {
+  console.log('Test vm');
+
+  var code = [
+    'var i = 10',
+    'setTimeout(hello, 1000)',
+    '',
+    'function hello() {',
+    '  debugger',
+    '  console.log("Hello: " + i)',
+    '  if(--i)',
+    '    setTimeout(hello, 1000)',
+    '}'
+  ].join('\n');
+
+  console.log('Run vm now');
+  var filename = '_couchdb:code.js';
+
+  var sandbox = {};
+  var ok = ['console', 'setTimeout'];
+
+  ok.forEach(function(key) {
+    sandbox[key] = global[key];
+  });
+
+  var ctx = vm.createContext(sandbox);
+  var script = vm.createScript(code, filename);
+
+  var r = script.runInNewContext(sandbox);
+  console.log('Result:\n%s', util.inspect(r, false, 10));
+  return r;
+}
+
+if (require.main === module) {
+  main();
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/extra/couchjs-node/xml.js
----------------------------------------------------------------------
diff --git a/extra/couchjs-node/xml.js b/extra/couchjs-node/xml.js
new file mode 100644
index 0000000..b64d221
--- /dev/null
+++ b/extra/couchjs-node/xml.js
@@ -0,0 +1,22 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+
+function XML () {
+  this.foo = 'bar';
+}
+
+XML.prototype.toXMLString = function() {
+  return '<xml>\n  <title>test</title>\n</xml>';
+};
+
+module.exports = XML;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/license.skip
----------------------------------------------------------------------
diff --git a/license.skip b/license.skip
index 0895cf8..5009532 100644
--- a/license.skip
+++ b/license.skip
@@ -52,6 +52,13 @@
 ^etc/logrotate.d/couchdb.*
 ^etc/windows/Makefile
 ^etc/windows/README.txt.tpl
+^extra/Makefile
+^extra/Makefile.in
+^extra/couchjs-node/package.json
+^extra/couchjs-node/sandbox.js
+^extra/couchjs-node/README.md
+^extra/couchjs-node/Makefile
+^extra/couchjs-node/Makefile.in
 ^libtool
 ^license.skip
 ^m4/.*
@@ -114,11 +121,6 @@
 ^src/couchdb/priv/couchjs
 ^src/couchdb/priv/couchspawnkillable
 ^src/couchdb/priv/stat_descriptions.cfg
-^src/couchjs-node/package.json
-^src/couchjs-node/sandbox.js
-^src/couchjs-node/README.md
-^src/couchjs-node/Makefile
-^src/couchjs-node/Makefile.in
 ^src/erlang-oauth/.*
 ^src/couch_dbupdates
 ^src/ejson/.*

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/share/doc/src/experimental.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/experimental.rst b/share/doc/src/experimental.rst
index 3157f53..8cd5765 100644
--- a/share/doc/src/experimental.rst
+++ b/share/doc/src/experimental.rst
@@ -40,7 +40,7 @@ Downloads <http://nodejs.org/download/>`_ for options.
 
 1. Install the `couchjs-node` binary. Either from the CouchDB sources::
 
-    cd src/couchjs-node
+    cd extra/couchjs-node
     npm link
 
 Or via NPM::

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 378f82b..c06a091 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,8 +22,7 @@ SUBDIRS = \
     etap \
     ibrowse \
     mochiweb \
-    snappy \
-    couchjs-node
+    snappy
 
 EXTRA_DIST = \
     $(MY_FIRST_COUCHDB_PLUGIN_FILES) \

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/Makefile.am
----------------------------------------------------------------------
diff --git a/src/couchjs-node/Makefile.am b/src/couchjs-node/Makefile.am
deleted file mode 100644
index 2144970..0000000
--- a/src/couchjs-node/Makefile.am
+++ /dev/null
@@ -1,24 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-##   http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-EXTRA_DIST = \
-  cli.js \
-  console.js \
-  couchdb.js \
-  couchjs.js \
-  inspector.js \
-  package.json \
-  README.md \
-  sandbox.js \
-  stream.js \
-  test/experiment.js \
-  xml.js

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/README.md
----------------------------------------------------------------------
diff --git a/src/couchjs-node/README.md b/src/couchjs-node/README.md
deleted file mode 100644
index 551c3df..0000000
--- a/src/couchjs-node/README.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# CouchJS
-
-## Drop-in replacement JavaScript engine for Apache CouchDB
-
-CouchJS is a command-line Node.js program. It is 100% compatible with Apache CouchDB's built-in JavaScript system.
-
-By using CouchJS, you will get 100% CouchDB compatibility (the test suite completely passes) but your JavaScript environment is V8, or Node.js.
-
-See share/doc/src/experimental.rst for installation instructions.
-
-## Idea
-
-JavaScript is decoupled from the CouchDB core. To do JavaScript stuff, CouchDB runs a normal Unix subprocess, `couchjs`. This subprocess is just a read-eval-print loop on standard i/o. CouchDB passes `couchjs` a file name, and *that file* contains the view server  implementation.
-
-This tool duplicates the "REPL" look and feel of `couchjs` and supports the exact same view server implementation.
-
-## Security
-
-I have no idea. I would not trust it for production use.
-
-## Log
-
-If you create a file, `/tmp/couchjs.log` then *couchjs* will output debugging messages there.
-
-## License
-
-Apache 2.0
-
-See the [Apache 2.0 license](named/blob/master/LICENSE).
-
-[tap]: https://github.com/isaacs/node-tap
-[def]: https://github.com/iriscouch/defaultable

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/cli.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/cli.js b/src/couchjs-node/cli.js
deleted file mode 100755
index 5447dd5..0000000
--- a/src/couchjs-node/cli.js
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/env node
-
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-var fs = require('fs');
-var Fiber = require('fibers');
-var optimist = require('optimist');
-
-var couchjs = require('./couchjs');
-var package_json = require('./package.json');
-var LineStream = require('./stream');
-var inspector = require('./inspector');
-var log = require('./console').log;
-
-
-var opts = optimist.boolean(['h', 'V', 'H'])
-                   .describe({ 'h': 'display a short help message and exit',
-                             'V': 'display version information and exit',
-                             'H': 'enable couchjs cURL bindings (not implemented)'
-                             })
-                   .usage('$0 <path to main.js>');
-
-
-function main() {
-
-  'use strict';
-
-  var main_js = opts.argv._[0];
-
-  if (!main_js) {
-    return console.error(opts.help());
-  }
-
-  log('couchjs/%s %s: %s', package_json.version, process.pid, main_js);
-
-  if (process.env.COUCHJS_DEBUG_PORT) {
-    inspector(+process.env.COUCHJS_DEBUG_PORT);
-  }
-
-  fs.readFile(main_js, 'utf8', function(er, body) {
-    if (er) {
-      throw er;
-    }
-
-    var stdin = new LineStream.v2();
-
-    stdin.on('readable', function() {
-      var buf = stdin.read();
-
-      if (buf) {
-        couchjs.stdin(buf);
-      }
-    });
-
-    stdin.on('end', function() {
-      log('Terminate; connection to parent closed');
-      process.exit(0);
-    });
-
-    process.stdin.setEncoding('utf8');
-    process.stdin.pipe(stdin);
-
-    var main_func = Function(['print', 'readline', 'evalcx', 'gc', 'quit'], body);
-
-    log('Call main');
-
-    new Fiber(function() {
-      main_func(couchjs.print, couchjs.readline, couchjs.evalcx, couchjs.gc);
-    }).run();
-  });
-
-  process.on('uncaughtException', function(er) {
-    log('Error:\n%s', er.stack);
-  });
-}
-
-if (require.main === module) {
-  main();
-}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/console.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/console.js b/src/couchjs-node/console.js
deleted file mode 100644
index 18e7241..0000000
--- a/src/couchjs-node/console.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-var fs = require('fs');
-var util = require('util');
-
-var noop = function() {};
-
-module.exports = {};
-module.exports.log = noop;
-module.exports.debug = noop;
-module.exports.info = noop;
-module.exports.warn = noop;
-module.exports.error = noop;
-
-var LOG_PATH = '/tmp/couchjs.log';
-var stat = null;
-var LOG = null;
-
-try {
-  stat = fs.statSync(LOG_PATH);
-} catch(er) {}
-
-if (stat) {
-  LOG = fs.createWriteStream(LOG_PATH, {
-    'flags':'a'
-  });
-
-  var log = function () {
-    var str = util.format.apply(this, arguments);
-    LOG.write(str + '\n');
-  };
-
-  var on_err = function (er) {
-    module.exports.error('Uncaught error:\n%s', er.stack || er.message || JSON.stringify(er));
-
-    if (er.stack) {
-      er = ['fatal', 'unknown_error', er.stack];
-    }
-
-    process.stdout.write(JSON.stringify(er) + '\n');
-    process.exit(1);
-  };
-
-  module.exports.log = log;
-  module.exports.debug = log;
-  module.exports.info = log;
-  module.exports.warn = log;
-  module.exports.error = log;
-
-  process.on('exit', function() {
-    module.exports.log('Exit %d', process.pid);
-  });
-
-  process.on('uncaughtException', on_err);
-}
-

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/couchdb.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/couchdb.js b/src/couchjs-node/couchdb.js
deleted file mode 100755
index d420540..0000000
--- a/src/couchjs-node/couchdb.js
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-
-var http = require('http');
-
-function handler(req, res) {
-  res.writeHead(200);
-  res.end('Hello: ' + req.url + '\n');
-}
-
-if (require.main === module) {
-  var http = require('http');
-  var server = http.createServer(handler);
-
-  server.listen(3000);
-  console.log('Listening on :3000');
-}
-
-module.exports = handler;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/couchjs.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/couchjs.js b/src/couchjs-node/couchjs.js
deleted file mode 100644
index ccc1aa9..0000000
--- a/src/couchjs-node/couchjs.js
+++ /dev/null
@@ -1,133 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-
-
-var vm = require('vm');
-var Fiber = require('fibers');
-var util = require('util');
-
-var XML = require('./xml');
-var log = require('./console').log;
-
-var INPUT = {
-  'queue':[],
-  'waiting':null
-};
-
-
-function print(line) {
-  log('STDOUT %s: %s', process.pid, line);
-  process.stdout.write(line + '\n');
-
-  try {
-    line = JSON.parse(line);
-  } catch(er) {
-    return;
-  }
-
-  if (line[0] === 'log') {
-    log('LOG: %s', line[1]);
-  }
-}
-
-function stdin (line) {
-  log('STDIN %s: %s', process.pid, line.trim());
-
-  if (INPUT.waiting) {
-    INPUT.waiting.run(line);
-  } else {
-    INPUT.queue.push(line);
-  }
-}
-
-function readline () {
-  var line = INPUT.queue.shift();
-
-  if (line) {
-    return line;
-  }
-
-  INPUT.waiting = Fiber.current;
-  line = Fiber.yield();
-  INPUT.waiting = null;
-
-  return line;
-}
-
-
-function evalcx (source, sandbox) {
-  sandbox = sandbox || {};
-  var func;
-  //log('evalcx in %j: %j', Object.keys(sandbox), source)
-
-  if (source === '') {
-    return sandbox;
-  }
-
-  // source might be "function(doc) { emit(doc._id, 1) }"
-  source = source.replace(/;+$/, '');
-
-  sandbox.XML = sandbox.XML || XML;
-  source = '(' + source + ')';
-
-  try {
-    var id = Math.floor(Math.random() * 1000*1000);
-    var filename = '_couchdb:' + id + '.js';
-    var script = vm.createScript(source, filename);
-    func = script.runInNewContext(sandbox);
-  } catch (er) {
-    log('Error making code: %s', er.stack);
-    return sandbox;
-  }
-
-  return func;
-}
-
-function quit(code) {
-  code = code || 1;
-  if (code < 0) {
-    code = -code;
-  }
-
-  process.exit(code);
-}
-
-function gc() { }
-
-
-function toSource() {
-  if (typeof this === 'function') {
-    return '' + this;
-  }
-
-  if (this instanceof Error) {
-    return this.stack;
-  }
-
-  return util.inspect(this);
-}
-
-Error.prototype.toSource = Error.prototype.toSource || toSource;
-Error.prototype.toString = Error.prototype.toString || toSource;
-Function.prototype.toSource = Function.prototype.toSource || toSource;
-Function.prototype.toString = Function.prototype.toString || toSource;
-
-module.exports = {
-  'print': print,
-  'readline': readline,
-  'stdin': stdin,
-  'evalcx': evalcx,
-  'quit': quit,
-  'gc': gc
-};
-

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/inspector.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/inspector.js b/src/couchjs-node/inspector.js
deleted file mode 100755
index 48182e5..0000000
--- a/src/couchjs-node/inspector.js
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env node
-
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-
-
-var cp = require('child_process');
-var log = require('./console').log;
-
-function watchInspector(child) {
-
-  child.stderr.on('data', function(body) {
-    log('Inspector STDERR: %s', body);
-  });
-
-  child.stdout.on('data', function(body) {
-    log('Inspector STDOUT: %s', body);
-  });
-
-  child.on('exit', function(code, signal) {
-    log('Inspector exited %d signal=%j', code, signal);
-    process.exit(code);
-  });
-
-  process.on('exit', function() {
-    log('Kill inspector upon exit: %d', child.pid);
-    process.kill(child.pid, 'SIGTERM');
-  });
-
-}
-
-function start (debugPort) {
-
-  if (!debugPort || typeof debugPort !== 'number') {
-    throw new Error('Need a listen debugPort');
-  }
-
-  var webPort = debugPort + 1;
-  var cmd = __filename;
-  var args = [debugPort, webPort];
-  var opts = {
-    'cwd': __dirname,
-    'stdio': 'pipe',
-    'detached': false
-  };
-
-  log('Start inspector: %s %j %j', cmd, args, opts);
-
-  var inspector = cp.spawn(cmd, args, opts);
-
-  watchInspector(inspector);
-
-  log('Enable remote debug pid=%d port=%d', process.pid, debugPort);
-
-  process.debugPort = debugPort;
-  process.kill(process.pid, 'SIGUSR1');
-}
-
-function main() {
-  var debugPort = +process.argv[2];
-  var webPort = +process.argv[3];
-
-  if (!debugPort || !webPort) {
-    throw new Error('Bad arguments: need debugPort and webPort');
-  }
-
-  console.log('Start inspector debugPort=%j webPort=%j', debugPort, webPort);
-
-  var DebugServer = require('node-inspector/lib/debug-server');
-  var server = new DebugServer();
-
-  server.on('close', function() {
-    console.log('Server closed');
-    process.exit(0);
-  });
-
-  server.start({
-    'webPort':webPort,
-    'debugPort':debugPort
-  });
-
-  process.on('uncaughtException', function(er) {
-    console.log('Error:\n%s', er.stack);
-  });
-}
-
-module.exports = start;
-
-if (require.main === module) {
-  main();
-}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/package.json
----------------------------------------------------------------------
diff --git a/src/couchjs-node/package.json b/src/couchjs-node/package.json
deleted file mode 100644
index 445f3b9..0000000
--- a/src/couchjs-node/package.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
-  "name": "couchjs",
-  "description": "Drop-in replacement for CouchDB JavaScript view server",
-  "keywords": [ "couchdb", "couchjs" ],
-  "version": "0.3.2",
-  "author": "Jason Smith <jhs@iriscouch.com> (http://www.iriscouch.com)",
-  "repository": {
-    "type":"git",
-    "url":"https://github.com/iriscouch/couchjs"
-  },
-  "engines": {
-    "node": ">= 0.8"
-  },
-  "main": "./couchjs.js",
-  "bin": {
-    "couchjs-node":"./cli.js"
-  },
-  "couchdb": {
-    "main":"./couchdb.js",
-    "vhosts": [
-      "127.0.0.1.xip.io"
-    ]
-  },
-  "bundledDependencies": [
-    "node-inspector"
-  ],
-  "dependencies": {
-    "optimist": "~0.3.4",
-    "async"   : "~0.2.5",
-    "mkdirp"  : "~0.3.4",
-    "fibers"  : "~1.0.0",
-    "request" : "~2.9.203",
-    "pushover": "~1.2.1",
-    "defaultable": "~0.7.2",
-    "node-inspector": "git://github.com/iriscouch/node-inspector#couchjs"
-  },
-  "devDependencies": {
-    "tap": "~0.2.5"
-  }
-}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/sandbox.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/sandbox.js b/src/couchjs-node/sandbox.js
deleted file mode 100644
index 5c18ef4..0000000
--- a/src/couchjs-node/sandbox.js
+++ /dev/null
@@ -1,47 +0,0 @@
-// from https://github.com/KlausTrainer/sandbox.js
-exports.runInSandbox = function(src, ctx, whitelist) {
-  var vm = require('vm');
-  var sandbox;
-
-  if (ctx && ctx.require) {
-
-    whitelist = whitelist || [];
-
-    var insecureRequire = ctx.require;
-    var module = require('module');
-    var oldModulePrototype = module.prototype;
-
-    var secureRequire = function(moduleName) {
-
-      if (whitelist.indexOf(moduleName) === -1) {
-        module.prototype = oldModulePrototype;
-
-        throw new Error("'" + moduleName + "' is not whitelisted");
-
-      } else {
-        var requiredModule = insecureRequire(moduleName);
-
-        module.prototype = oldModulePrototype;
-
-        return requiredModule;
-      }
-    };
-
-    module.prototype = {
-      require: secureRequire,
-      load: module.prototype.load,
-      _compile: module.prototype._compile
-    };
-
-    module._cache = {};
-
-    ctx.require = secureRequire;
-    sandbox = Object.freeze(vm.createContext(ctx));
-    ctx.require = insecureRequire;
-
-  } else {
-    sandbox = Object.freeze(vm.createContext(ctx || {}));
-  }
-
-  return vm.createScript('(function() {"use strict"; return (' + src + ')()}())').runInContext(sandbox);
-};

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/stream.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/stream.js b/src/couchjs-node/stream.js
deleted file mode 100644
index ebffc30..0000000
--- a/src/couchjs-node/stream.js
+++ /dev/null
@@ -1,115 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-// Text line stream
-
-var stream = require('stream');
-var util = require('util');
-
-
-function LineStream() {
-
-  var self = this;
-  stream.call(self);
-
-  self.readable = true;
-  self.writable = true;
-
-  self.buffer = '';
-  self.downstream = null;
-
-  self.on('pipe', function(upstream) {
-    upstream.on('end', function(data, encoding) {
-      self.emit('end', data, encoding);
-    });
-  });
-}
-
-function LineStream2() {
-
-  if (!(this instanceof LineStream2)) {
-    return new LineStream2();
-  }
-
-  stream.Transform.call(this);
-  this.setEncoding('utf8');
-}
-
-util.inherits(LineStream2, stream.Transform);
-
-LineStream2.prototype._transform = function(message, encoding, done) {
-  var self = this;
-
-  message = message.toString(encoding);
-  var lines = message.split(/\n/);
-
-  // If the data ends in "\n" this will be ""; otherwise the final partial line.
-  var remainder = lines.pop();
-  if (remainder) {
-    this.unshift(remainder);
-  }
-
-  lines.forEach(function(line) {
-    self.push(line);
-  });
-
-  done();
-};
-
-util.inherits(LineStream, stream);
-
-
-
-LineStream.prototype.write = function(data) {
-  var self = this;
-
-  data = data || '';
-  if (typeof data !== 'string') {
-    return self.error(new Error('Data was not a string: ' + util.inspect(data)));
-  }
-
-  self.buffer += data;
-  var lines = self.buffer.split(/\n/);
-  self.buffer = lines.pop(); // If the data ended in "\n" this will be ""; otherwise the final partial line.
-
-  lines.forEach(function(line) {
-    self.emit('data', line);
-  });
-};
-
-
-LineStream.prototype.end = function(data) {
-  var self = this;
-
-  self.is_ending = true;
-  self.writable = false;
-
-  // Always call write, even with no data, so it can fire the "end" event.
-  self.write(data);
-};
-
-
-LineStream.prototype.error = function(er) {
-  var self = this;
-
-  self.readable = false;
-  self.writable = false;
-  self.emit('error', er);
-
-  // The write() method sometimes returns this value, so if there was an error, make write() return false.
-  return false;
-};
-
-
-module.exports = LineStream;
-module.exports.v2 = LineStream2;
-

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/test/experiment.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/test/experiment.js b/src/couchjs-node/test/experiment.js
deleted file mode 100644
index 9197ec6..0000000
--- a/src/couchjs-node/test/experiment.js
+++ /dev/null
@@ -1,125 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-var vm = require('vm');
-var util = require('util');
-
-var STATE = 'wait';
-
-function main() {
-  process.debugPort = 5859;
-  process.kill(process.pid, 'SIGUSR1');
-
-  setTimeout(function() {
-    stuff(0);
-  }, 1000);
-}
-
-function stuff(count) {
-
-  console.log('Doing stuff: %d', count);
-  STATE = 'vm';
-  console.log('More stuff: %d', count);
-
-  if (STATE === 'done') {
-    console.log('Done');
-  } else if (STATE === 'code') {
-    setTimeout(code, 1000);
-  } else if(STATE === 'eval') {
-    test_eval();
-  } else if(STATE === 'vm') {
-    test_vm();
-  } else if(STATE === 'wait') {
-    setTimeout(function() {
-      stuff(count+1);
-    }, 1000);
-  } else {
-    throw new Error('Unknown state: ' + STATE);
-  }
-}
-
-function code() {
-  var code = [
-    'var foo = "in the code"',
-    'console.log("This is some code")',
-    'debugger',
-    'console.log("foo = " + foo)'
-    ].join('\n');
-
-  var runner = Function([], code);
-
-  console.log('Run runner in 1s');
-
-  setTimeout(run_runner, 1000)
-
-  function run_runner() {
-    console.log('About to run runner');
-    debugger;
-    runner();
-    console.log('Runner done');
-  }
-}
-
-function test_eval() {
-  console.log('Test eval in 1s');
-  setTimeout(run_eval, 1000);
-
-  var code = [
-    'var foo = "in eval"',
-    'console.log("This is eval")',
-    'debugger',
-    'console.log("foo = " + foo)'
-    ].join('\n');
-
-  function run_eval() {
-    console.log('Run eval now');
-    debugger;
-    eval(code);
-  }
-}
-
-function test_vm() {
-  console.log('Test vm');
-
-  var code = [
-    'var i = 10',
-    'setTimeout(hello, 1000)',
-    '',
-    'function hello() {',
-    '  debugger',
-    '  console.log("Hello: " + i)',
-    '  if(--i)',
-    '    setTimeout(hello, 1000)',
-    '}'
-  ].join('\n');
-
-  console.log('Run vm now');
-  var filename = '_couchdb:code.js';
-
-  var sandbox = {};
-  var ok = ['console', 'setTimeout'];
-
-  ok.forEach(function(key) {
-    sandbox[key] = global[key];
-  });
-
-  var ctx = vm.createContext(sandbox);
-  var script = vm.createScript(code, filename);
-
-  var r = script.runInNewContext(sandbox);
-  console.log('Result:\n%s', util.inspect(r, false, 10));
-  return r;
-}
-
-if (require.main === module) {
-  main();
-}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d66d5bf/src/couchjs-node/xml.js
----------------------------------------------------------------------
diff --git a/src/couchjs-node/xml.js b/src/couchjs-node/xml.js
deleted file mode 100644
index b64d221..0000000
--- a/src/couchjs-node/xml.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-
-function XML () {
-  this.foo = 'bar';
-}
-
-XML.prototype.toXMLString = function() {
-  return '<xml>\n  <title>test</title>\n</xml>';
-};
-
-module.exports = XML;


Mime
View raw message