Commits

Anonymous committed 6abf1b2

first commit

  • Participants

Comments (0)

Files changed (5)

+syntax: glob
+.idea
+node_modules
+tests/
+.idea
+.hg
+tests/
+node_modules
+module.exports = function(grunt) {
+
+    grunt.initConfig({
+
+        'sftp2sync': {
+            build: {
+                auth: {
+                    host: 'xxx.xxx.xxx.xxx',
+                    port: 22,
+                    username: 'root',
+                    privateKey: 'keys',
+                    passphrase: ''
+                },
+
+                src: './',
+                dest: '/home/xxx/public_html',
+                excludes: ['\.DS_Store|\.Thumbs.db|Gruntfile.js|\.idea*|.hg*|.keys|node_modules']
+            }
+        },
+
+        // Unit tests.
+        nodeunit: {
+            tests: ['test/*_test.js']
+        }
+    });
+
+    grunt.loadTasks('tasks');
+    //grunt.loadNpmTasks('sftp2sync');
+
+    // By default, lint and run all tests.
+    grunt.registerTask('default', ['test']);
+}
+{
+  "author": {
+    "name": "Daisuke Yamashita",
+    "email": "yamashita@sena-networks.co.jp",
+    "url": "http://sena-networks.co.jp"
+  },
+  "name": "grunt-sftp2sync",
+  "description": "grunt sftp2sync (like rsync) use windows ok!!",
+  "homepage": "https://bitbucket.org/dai_yamashita/grunt-sftp2sync",
+  "repository": {
+    "type": "hg",
+    "url": "https://bitbucket.org/dai_yamashita/grunt-sftp2sync"
+  },
+  "version": "0.0.1",
+  "engines": {
+    "node": ">=0.8.1"
+  },
+  "dependencies": {
+    "sftp2sync": "*"
+  },
+  "scripts": {
+      "test": "grunt test"
+  },
+  "devDependencies": {
+    "grunt-contrib-jshint": "~0.6.0",
+    "grunt-contrib-clean": "~0.4.0",
+    "grunt-contrib-nodeunit": "~0.2.0",
+    "grunt": "~0.4.1"
+  },
+  "peerDependencies": {
+    "grunt": "~0.4.1"
+  },
+  "keywords": [
+    "gruntplugin", "rsync", "deploy", "sftp", "grunt"
+  ]
+}

tasks/sftp2sync.js

+//
+// Grunt Task File
+// ---------------
+//
+// Task: sftp2sync
+// Description: Deploy code over SFTP
+// Dependencies: ssh2
+//
+
+var grunt = require('grunt');
+var sftp2sync = require('sftp2sync');
+
+// The main grunt task
+grunt.registerMultiTask('sftp2sync', 'rsync like sftp', function() {
+
+    var done = this.async();
+
+    var options = new Object();
+    options.host = this.data.auth.host
+    options.port = this.data.auth.port
+    options.username = this.data.auth.username
+    options.privateKey = require('fs').readFileSync(this.data.auth.privateKey);
+    options.passphrase = this.data.auth.passphrase;
+
+    var src = this.data.src;
+    var dest = this.data.dest;
+    var force = true;
+    var excludes = this.data.excludes;
+
+    sftp2sync.upload(src, dest, force, excludes, options, function(result){
+        console.log('sync finish');
+        done();
+    });
+
+});