Permalink
Browse files

reorganisation for npm and moving package build-step code out of kans…

…o core
  • Loading branch information...
1 parent b6f0a9c commit 1b1fec1240fcebcb61e722bfdce993c2580fdbcc @caolan caolan committed Dec 19, 2011
Showing with 32 additions and 544 deletions.
  1. +0 −52 Makefile
  2. +4 −4 scripts/kanso.js → bin/kanso
  3. 0 {src/kanso → lib}/args.js
  4. 0 {src/kanso → lib}/buildsteps.js
  5. 0 {src/kanso → lib}/cache.js
  6. 0 {src/kanso → lib}/commands/clear-cache.js
  7. 0 {src/kanso → lib}/commands/create.js
  8. 0 {src/kanso → lib}/commands/createdb.js
  9. 0 {src/kanso → lib}/commands/deletedb.js
  10. 0 {src/kanso → lib}/commands/help.js
  11. 0 {src/kanso → lib}/commands/index.js
  12. 0 {src/kanso → lib}/commands/install.js
  13. 0 {src/kanso → lib}/commands/listdb.js
  14. 0 {src/kanso → lib}/commands/ls.js
  15. 0 {src/kanso → lib}/commands/pack.js
  16. 0 {src/kanso → lib}/commands/publish.js
  17. 0 {src/kanso → lib}/commands/push.js
  18. 0 {src/kanso → lib}/commands/replicate.js
  19. 0 {src/kanso → lib}/commands/show.js
  20. 0 {src/kanso → lib}/commands/transform.js
  21. 0 {src/kanso → lib}/commands/unpublish.js
  22. 0 {src/kanso → lib}/commands/upload.js
  23. 0 {src/kanso → lib}/commands/uuids.js
  24. 0 {src/kanso → lib}/couchdb.js
  25. 0 {src/kanso → lib}/data-stream/JsonTokenizer.js
  26. 0 {src/kanso → lib}/data-stream/ParseStream.js
  27. 0 {src/kanso → lib}/data-stream/README.md
  28. 0 {src/kanso → lib}/data-stream/Tokenizer.js
  29. 0 {src/kanso → lib}/data-stream/index.js
  30. 0 {src/kanso → lib}/kansorc.js
  31. 0 {src/kanso → lib}/logger.js
  32. 0 {src/kanso → lib}/packages.js
  33. 0 {src/kanso → lib}/repository.js
  34. 0 {src/kanso → lib}/settings.js
  35. 0 {src/kanso → lib}/tar.js
  36. 0 {src/kanso → lib}/utils.js
  37. +1 −1 package.json
  38. +1 −1 scripts/install_autocomp.js
  39. +0 −10 scripts/publish_all_packages.sh
  40. +0 −3 scripts/run_tests.js
  41. +0 −30 scripts/run_tests.sh
  42. +0 −30 src/api.js
  43. +0 −116 src/kanso/attachments.js
  44. +0 −289 src/kanso/modules.js
  45. +4 −1 test/test-lib-buildsteps.js
  46. +4 −1 test/test-lib-couchdb.js
  47. +5 −2 test/test-lib-kansorc.js
  48. +5 −2 test/test-lib-utils.js
  49. +4 −1 test/test-postprocessor-app.js
  50. +4 −1 test/test-preprocessor-app.js
View
@@ -1,52 +0,0 @@
-PACKAGE = kanso
-NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node)
-
-PREFIX ?= /usr/local
-BINDIR ?= $(PREFIX)/bin
-DATADIR ?= $(PREFIX)/share
-LIBDIR ?= $(PREFIX)/lib
-NODEJSLIBDIR ?= $(LIBDIR)/$(NODEJS)
-
-BUILDDIR = dist
-
-$(shell if [ ! -d $(BUILDDIR) ]; then mkdir $(BUILDDIR); fi)
-
-all: build
-
-build: stamp-build
-
-stamp-build: $(wildcard src/*)
- touch $@;
- mkdir -p $(BUILDDIR)/kanso
- cp -R bin node_modules scripts project src package.json $(BUILDDIR)/kanso
-
-test:
- ./scripts/run_tests.sh test
-
-docs:
- rm -rf www
- mkdir -p www
- mkdir -p www/guides
- cp -R docs/CNAME docs/css docs/images www
- cp -R docs/guides/images www/guides
- $(NODEJS) docs/build_docs.js
-
-install: build
- cp -Ra $(BUILDDIR)/kanso $(NODEJSLIBDIR)
- ln -sf $(NODEJSLIBDIR)/$(PACKAGE)/bin/kanso $(BINDIR)/kanso
-
-autocomplete:
- $(NODEJS) scripts/install_autocomp.js "$(NODEJSLIBDIR)/kanso"
-
-uninstall:
- rm -rf $(NODEJSLIBDIR)/kanso $(NODEJSLIBDIR)/kanso.js $(BINDIR)/kanso
-
-clean:
- rm -rf $(BUILDDIR) stamp-build
-
-reinstall: uninstall clean install
-
-lint:
- nodelint --config nodelint.cfg ./bin/kanso ./src/kanso/*.js ./testsuite/lib/*.js ./testsuite/tests/*.js
-
-.PHONY: test install uninstall build all clean lint docs autocomplete
@@ -1,10 +1,10 @@
#!/usr/bin/env node
var path = require('path'),
- utils = require('../src/kanso/utils'),
- kansorc = require('../src/kanso/kansorc'),
- logger = require('../src/kanso/logger'),
- commands = require('../src/kanso/commands');
+ utils = require('../lib/utils'),
+ kansorc = require('../lib/kansorc'),
+ logger = require('../lib/logger'),
+ commands = require('../lib/commands');
var args = process.argv.slice(2);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -30,5 +30,5 @@
"main": "./src/api",
"bugs": {"url": "http://github.com/caolan/kanso/issues"},
- "bin": {"kanso": "./scripts/kanso.js"}
+ "bin": {"kanso": "./bin/kanso"}
}
@@ -4,7 +4,7 @@ var os = require('os'),
fs = require('fs');
-var KANSO_DIR = process.argv[2];
+var KANSO_DIR = process.argv[2] || '/usr/local/lib/node_modules/kanso'
var HOME = process.env.HOME;
var bash_profile = HOME + '/.bash_profile';
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-DIR=`dirname $0`
-PACKAGES=`ls -d $DIR/../packages/*`
-
-for p in $PACKAGES
-do
- echo "Publishing $p"
- $DIR/../bin/kanso publish $p
-done
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env node
-require('kanso/logger').clean_exit = true;
-require('nodeunit/bin/nodeunit');
View
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-# Test which node.js command to use
-# (debian seems to use nodejs instead of just node)
-if test -f "/usr/bin/nodejs"
-then
- NODEJS="nodejs"
-else
- NODEJS="node"
-fi
-
-# Find the real name of this file, following symlinks
-REALPATH=$0
-while test -L $REALPATH
-do
- REALPATH=`readlink $REALPATH`
-done
-
-# Location of the main kanso.js node script
-SCRIPT_PATH=`dirname $REALPATH`/run_tests.js
-
-# Additional path for looking up node modules.
-# Used so kanso package pre/postprocessors can do require('kanso/lib/foo')
-KANSO_DIR=`dirname $REALPATH`/..
-
-# Extend existing NODE_PATH environment variable
-export NODE_PATH="$KANSO_DIR/src:$KANSO_DIR/deps:$NODE_PATH"
-
-# Run scripts/kanso.js
-exec $NODEJS $SCRIPT_PATH $@
View
@@ -1,30 +0,0 @@
-/**
- * The public kanso API
- */
-
-
-/**
- * Module dependencies
- */
-
-var path = require('path'),
- fs = require('fs');
-
-
-// Assume that everything in ./kanso/* is public. Loop through each filenename
-// and export it.
-var api_directory = path.join(__dirname, 'kanso');
-var filenames = fs.readdirSync(api_directory);
-
-for (var i = 0; i < filenames.length; i++) {
- var filename = filenames[i],
- require_label = './kanso/' + filename,
- module_name = path.basename(filename, '.js');
-
- // It might be wise to lstat and look for files ending in ".js" or any
- // directory. But I'm unsure if that's Windows-compatible. This test
- // filters out Vim .swp files, or whatever randomness gets in there.
- if(filename.match(/\.js$/) || filename.match(/^[a-z]+$/)) {
- exports[module_name] = require(require_label);
- }
-}
View
@@ -1,116 +0,0 @@
-/**
- * Functions related to the loading and manipulation of attachments in
- * Kanso apps.
- *
- * @module
- */
-
-var utils = require('./utils'),
- mime = require('mime'),
- async = require('async'),
- fs = require('fs');
-
-
-/**
- *
- * @param {Object} doc
- * @param {String} path
- * @param {Buffer} content
- * @returns {Object}
- */
-
-exports.add = function (doc, ddoc_path, original_path, content) {
- if (!doc._attachments) {
- doc._attachments = {};
- }
- doc._attachments[ddoc_path] = {
- 'content_type': mime.lookup(original_path),
- 'data': content.toString('base64'),
- // custom addition removed in cleanup postprocessor
- '_original_path': original_path
- };
- return doc;
-};
-
-
-/**
- * Searchs a path for attachments, adding them to the document.
- *
- * @param {String} pkgdir - path to the source package
- * @param {String} p - path to a file or directory
- * @param {Object} doc - the document to extend
- * @param {Function} callback
- */
-
-exports.addPath = function (pkgdir, p, doc, callback) {
- p = utils.abspath(p, pkgdir);
- exports.find(p, function (err, files) {
- if (err) {
- return callback(err);
- }
- async.forEach(files, function (f, cb) {
- exports.addFile(pkgdir, f, doc, cb);
- }, callback);
- });
-};
-
-
-/**
- * Loads an attachment file and adds its contents to the document
- *
- * @param {String} pkgdir
- * @param {String} p
- * @param {Object} doc
- * @param {Function} callback
- */
-
-exports.addFile = function (pkgdir, p, doc, callback) {
- fs.readFile(p, function (err, content) {
- if (err) {
- return callback(err);
- }
- var rel = utils.relpath(p, pkgdir);
- exports.add(doc, rel, p, content);
- callback()
- });
-};
-
-
-/**
- * Find all attachments below or at a given path, recursing through
- * subdirectories
- *
- * @param {String} p - the path to search
- * @param {Function} callback
- */
-
-exports.find = async.memoize(function (p, callback) {
- utils.find(p, exports.filenameFilter(p), callback);
-});
-
-
-/**
- * Creates a filter used when searching for attachments. This function omits
- * hidden dot-preceeded filenames.
- *
- * @param {String} p - the path to the directory being searched
- * @returns {Function}
- */
-
-exports.filenameFilter = function (p) {
- return function (f) {
- if (f === p) {
- return true;
- }
- var relpath = utils.relpath(f, p);
- // should not start with a '.'
- if (/^\.[^\/]?/.test(relpath)) {
- return false;
- }
- // should not contain a file or folder starting with a '.'
- if (/\/\./.test(relpath)) {
- return false;
- }
- return true;
- };
-};
Oops, something went wrong.

0 comments on commit 1b1fec1

Please sign in to comment.