Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit.

  • Loading branch information...
commit f82becfdd2a14547955bdb78d4b5e9bdf62bd049 0 parents
@zeekay authored
16 .gitignore
@@ -0,0 +1,16 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+node_modules
+npm-debug.log
+lib
4 .npmignore
@@ -0,0 +1,4 @@
+node_modules/
+Cakefile
+test/
+src/
36 Cakefile
@@ -0,0 +1,36 @@
+exec = require 'executive'
+
+task 'build', 'Build project', ->
+ exec './node_modules/.bin/coffee -bc -o lib/ src/'
+
+task 'test', 'run tests', ->
+ exec "NODE_ENV=test
+ ./node_modules/.bin/mocha
+ --compilers coffee:coffee-script
+ --reporter spec
+ --colors
+ --timeout 60000
+ test/integration test/unit"
+
+task 'test:integration', 'run integration tests', ->
+ exec "NODE_ENV=test
+ ./node_modules/.bin/mocha
+ --compilers coffee:coffee-script
+ --reporter spec
+ --colors
+ test/integration"
+
+task 'test:unit', 'run unit tests', ->
+ exec "NODE_ENV=test
+ ./node_modules/.bin/mocha
+ --compilers coffee:coffee-script
+ --reporter spec
+ --colors
+ test/unit"
+
+task 'publish', 'Publish current version to NPM', ->
+ exec [
+ './node_modules/.bin/coffee -bc -o lib/ src/'
+ 'git push'
+ 'npm publish'
+ ]
3  README.md
@@ -0,0 +1,3 @@
+# Mastermind
+
+Unleash your inner supervillain.
31 package.json
@@ -0,0 +1,31 @@
+{
+ "name": "puppet",
+ "version": "0.0.1",
+ "description": "Do with your machines what you will.",
+ "keywords": [
+ "automation",
+ "ssh"
+ ],
+ "main": "lib/",
+ "scripts": {
+ "test": "cake test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/zeekay/puppet"
+ },
+ "author": "Zach Kelling <zeekayy@gmail.com> (http://whatit.is)",
+ "license": "BSD",
+ "readmeFilename": "README.md",
+ "dependencies": {
+ "shh": "~0.3.0",
+ "async": "~0.1.22"
+ },
+ "devDependencies": {
+ "chai": "~1.3.0",
+ "mocha": "~1.7.0",
+ "sinon": "~1.5.0",
+ "coffee-script": "~1.4.0",
+ "executive": "~0.1.3"
+ }
+}
41 src/index.coffee
@@ -0,0 +1,41 @@
+async = require 'async'
+shh = require 'shh'
+
+class Puppet
+ constructor: (options = {}) ->
+ @host = options.host
+ @port = options.port or 22
+ @username = options.username
+ @privateKey = options.privateKey
+ @publicKey = options.publicKey
+
+ connect: (callback) ->
+ @client = new shh.Client
+ host: @host
+ port: @port
+ username: @username
+ privateKey: @privateKey
+ publicKey: @publicKey
+
+ @client.on 'stdout', (line) ->
+ console.log "[out (#{options.host})]", line
+
+ @client.on 'stderr', (line) ->
+ console.error "[err (#{options.host})]", line
+
+ @client.connect ->
+ callback null
+
+ exec: (options, cmds, callback) ->
+ if not Array.isArray cmds
+ cmds = [cmds]
+
+ async.map cmds
+ , (cmd, _callback) =>
+ @client.exec cmd, (err, out) ->
+ _callback err, out
+ , (err, results) =>
+ @client.close()
+ callback err, results
+
+module.exports = Puppet

0 comments on commit f82becf

Please sign in to comment.
Something went wrong with that request. Please try again.