From 43df3d62bdf40b1baa2563bf8a054105700204e4 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Thu, 10 May 2012 14:20:12 +0200 Subject: [PATCH] initial import --- configs/default.js | 30 ++++++++++++++++++++++++++++++ configs/ssh.js | 27 +++++++++++++++++++++++++++ http-adapter/http-adapter-ext.js | 12 ++++++++++++ http-adapter/package.json | 14 ++++++++++++++ local/local-ext.js | 12 ++++++++++++ local/package.json | 10 ++++++++++ package.json | 20 ++++++++++++++++++++ server.js | 17 +++++++++++++++++ ssh/package.json | 10 ++++++++++ ssh/ssh-ext.js | 26 ++++++++++++++++++++++++++ 10 files changed, 178 insertions(+) create mode 100644 configs/default.js create mode 100644 configs/ssh.js create mode 100644 http-adapter/http-adapter-ext.js create mode 100644 http-adapter/package.json create mode 100644 local/local-ext.js create mode 100644 local/package.json create mode 100644 package.json create mode 100755 server.js create mode 100644 ssh/package.json create mode 100644 ssh/ssh-ext.js diff --git a/configs/default.js b/configs/default.js new file mode 100644 index 0000000..1d7dfe0 --- /dev/null +++ b/configs/default.js @@ -0,0 +1,30 @@ +var path = require("path"); +var port = process.env.PORT || 5656; + +module.exports = { + name: "VFS", + tmpdir: __dirname + "/../.architect", + basePath: __dirname + "/..", + containers: { + master: { + title: "VFS", + plugins: [{ + packagePath: "connect-architect/connect", + port: port + }, { + packagePath: "./local", + uid: process.getuid(), + gid: process.getgid(), + umask: 0750, + root: path.normalize(__dirname + "/../"), + skipSearchCheck: false, + httpRoot: "http://localhost:" + port + "/" + }, { + packagePath: "./http-adapter", + mount: "/vfs" + }, { + packagePath: "architect/plugins/architect.log" + }] + } + } +}; \ No newline at end of file diff --git a/configs/ssh.js b/configs/ssh.js new file mode 100644 index 0000000..4566551 --- /dev/null +++ b/configs/ssh.js @@ -0,0 +1,27 @@ +var port = process.env.PORT || 5656; + +module.exports = { + name: "VFS SSH", + tmpdir: __dirname + "/../.architect", + basePath: __dirname + "/..", + containers: { + master: { + title: "VFS SSH", + plugins: [{ + packagePath: "connect-architect/connect", + port: port + }, { + packagePath: "./ssh", + host: "localhost", + root: process.env.HOME + "/", + nodePath: process.execPath, + httpRoot: "http://localhost:" + port + "/" + }, { + packagePath: "./http-adapter", + mount: "/" + }, { + packagePath: "architect/plugins/architect.log" + }] + } + } +}; \ No newline at end of file diff --git a/http-adapter/http-adapter-ext.js b/http-adapter/http-adapter-ext.js new file mode 100644 index 0000000..a0353e8 --- /dev/null +++ b/http-adapter/http-adapter-ext.js @@ -0,0 +1,12 @@ +var assert = require("assert"); + +module.exports = function setup(options, imports, register) { + + assert(options.mount, "option 'mount' is required"); + + imports.connect.useMain(require("vfs/http-adapter/restful")(options.mount, imports.vfs)); + + register(null, { + "vfs-rest": {} + }); +} \ No newline at end of file diff --git a/http-adapter/package.json b/http-adapter/package.json new file mode 100644 index 0000000..49a2b15 --- /dev/null +++ b/http-adapter/package.json @@ -0,0 +1,14 @@ +{ + "name": "vfs.http-adapter", + "version": "0.0.1", + "main": "http-adapter-ext.js", + "private": true, + + "plugin": { + "provides": ["vfs-rest"], + "consumes" : [ + "vfs", + "connect" + ] + } +} \ No newline at end of file diff --git a/local/local-ext.js b/local/local-ext.js new file mode 100644 index 0000000..50241f6 --- /dev/null +++ b/local/local-ext.js @@ -0,0 +1,12 @@ +var assert = require("assert"); + +module.exports = function setup(options, imports, register) { + + assert.equal(typeof options.uid, "number", "option 'uid' is required"); + assert.equal(typeof options.gid, "number", "option 'gid' is required"); + assert(options.root, "option 'root' is required"); + + register(null, { + "vfs": require("vfs/local")(options) + }); +} \ No newline at end of file diff --git a/local/package.json b/local/package.json new file mode 100644 index 0000000..262a350 --- /dev/null +++ b/local/package.json @@ -0,0 +1,10 @@ +{ + "name": "vfs.local", + "version": "0.0.1", + "main": "local-ext.js", + "private": true, + + "plugin": { + "provides": ["vfs"] + } +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..8e967d4 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "vfs-architect", + "description": "architect plugins for vfs", + "version": "0.0.1", + + "author": "ajax.org B.V. ", + "contributors": [ + { "name": "Fabian Jakobs", "email": "fabian@c9.io" } + ], + + "dependencies": { + "architect": "~0.0.3", + "vfs": "~0.0.1" + }, + + "repository" : { + "type" : "git", + "url" : "http://github.com/c9/vfs-architect.git" + } +} \ No newline at end of file diff --git a/server.js b/server.js new file mode 100755 index 0000000..e3055e7 --- /dev/null +++ b/server.js @@ -0,0 +1,17 @@ +#!/usr/bin/env node + +var path = require('path'); +var architect = require("architect"); + +var configName = process.argv[2] || "default"; + +var configPath = path.resolve(__dirname, "./configs/", configName); +var config = require(configPath); + +architect.createApp(config, function (err, app) { + if (err) { + console.error("While starting the '%s':", configPath); + throw err; + } + console.log("Started '%s'!", configPath); +}); \ No newline at end of file diff --git a/ssh/package.json b/ssh/package.json new file mode 100644 index 0000000..1365088 --- /dev/null +++ b/ssh/package.json @@ -0,0 +1,10 @@ +{ + "name": "vfs.ssh", + "version": "0.0.1", + "main": "ssh-ext.js", + "private": true, + + "plugin": { + "provides": ["vfs"] + } +} \ No newline at end of file diff --git a/ssh/ssh-ext.js b/ssh/ssh-ext.js new file mode 100644 index 0000000..ca3e284 --- /dev/null +++ b/ssh/ssh-ext.js @@ -0,0 +1,26 @@ +var assert = require("assert"); + +module.exports = function setup(options, imports, register) { + + assert(options.root, "option 'root' is required"); + assert(options.host, "option 'host' is required"); + assert(options.nodePath, "option 'nodePath' is required"); + + require("vfs/ssh")({ + pingInterval: options.pingInterval || 5000, //ms + serverAliveInterval: options.serverAliveInterval || 10, //sec + nodePath: options.nodePath, + host: options.host, + key: options.keyFile || null, + umask: options.umask || 0750, + uid: options.uid || process.getuid(), + gid: options.uid || process.getgid(), + skipSearchCheck: options.skipSearchCheck || false, + root: options.root, + httpRoot: options.httpRoot || null + }, function(err, vfs) { + register(err, { + "vfs": vfs + }); + }) +} \ No newline at end of file