Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelkuijpers committed Sep 26, 2013
0 parents commit 478f9be
Show file tree
Hide file tree
Showing 12 changed files with 452 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
node_modules
npm-debug.log
tmp
.idea/
13 changes: 13 additions & 0 deletions .jshintrc
@@ -0,0 +1,13 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true,
"node": true
}
67 changes: 67 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,67 @@
/*
* grunt-webdav-sync
* https://github.com/mitchel/grunt-webdav-sync
*
* Copyright (c) 2013 Mitchel Kuijpers
* Licensed under the MIT license.
*/

'use strict';

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'<%= nodeunit.tests %>'
],
options: {
jshintrc: '.jshintrc'
}
},

// Before generating any new files, remove any previously-created files.
clean: {
tests: ['tmp']
},

// Configuration to be run (and then tested).
webdav_sync: {
default: {
options: {
local_path: 'test/assets/upload/**',
remote_path: 'http://127.0.0.1:9001'
}
}
},

start_webdav_server: {
default: {}
},

// Unit tests.
nodeunit: {
tests: ['test/*_test.js']
}

});

// Actually load this plugin's task(s).
grunt.loadTasks('tasks');

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-nodeunit');

// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'start_webdav_server', 'webdav_sync', 'nodeunit']);

// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test']);

};
22 changes: 22 additions & 0 deletions LICENSE-MIT
@@ -0,0 +1,22 @@
Copyright (c) 2013 Mitchel Kuijpers

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
75 changes: 75 additions & 0 deletions README.md
@@ -0,0 +1,75 @@
# grunt-webdav-sync

> Synchronizes a local folder to a remote webdav folder
## Getting Started
This plugin requires Grunt `~0.4.1`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-webdav-sync --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-webdav-sync');
```

## The "webdav_sync" task

### Overview
In your project's Gruntfile, add a section named `webdav_sync` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
webdav_sync: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
```

### Options

#### options.local_path
Type: `String`
Default value: `none`

A local path pattern to load files from. the `local_path` is relative from the Gruntfile.js root. The files from `local_path` will be copied from the ** directory so if upload contains for example `test.json` and the `remote_path` is `http://user:password@localhost:9001/path/to` it will upload to `http://user:password@localhost:9001/path/to/test.json`.

#### options.remote_path
Type: `String`
Default value: `none`

The server to upload the file to. This accepts all default URL's so you can add username, password or a port.

### Usage Examples

#### Default Options
In this example, the default options are used to copy files from a directory to a remote webdav server.

```js
grunt.initConfig({
webdav_sync: {
default: {
options: {
local_path: 'test/assets/upload/**',
remote_path: 'http://user:password@localhost:9001/path/to'
}
}
},
})
```


## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

## Release History
_(Nothing yet)_
1 change: 1 addition & 0 deletions local_path
@@ -0,0 +1 @@
1 2 3, Testing.
44 changes: 44 additions & 0 deletions package.json
@@ -0,0 +1,44 @@
{
"name": "grunt-webdav-sync",
"description": "Synchronizes a local folder to a remote webdav folder",
"version": "0.1.0",
"homepage": "https://github.com/mitchel/grunt-webdav-sync",
"author": {
"name": "Mitchel Kuijpers",
"email": "m.kuijpers@avisi.nl"
},
"repository": {
"type": "git",
"url": "git://github.com/mitchel/grunt-webdav-sync.git"
},
"bugs": {
"url": "https://github.com/mitchel/grunt-webdav-sync/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/mitchel/grunt-webdav-sync/blob/master/LICENSE-MIT"
}
],
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.8.0"
},
"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",
"async": "~0.2.9",
"jsDAV": "~0.3.2"
},
"peerDependencies": {
"grunt": "~0.4.1"
},
"keywords": [
"gruntplugin"
]
}
24 changes: 24 additions & 0 deletions tasks/start_webdav_server.js
@@ -0,0 +1,24 @@
var jsDAV = require("jsDAV/lib/jsdav");
var jsDAV_Server = require("jsDAV/lib/DAV/server");
var jsDAV_Locks_Backend_FS = require("jsDAV/lib/DAV/plugins/locks/fs");
var path = require("path");

module.exports = function(grunt) {

grunt.registerMultiTask('start_webdav_server', 'Simple webdav server for testing', function() {
var done = this.async();
grunt.log.writeln("Starting test webdav server");
var nodeDir = grunt.file.mkdir("tmp/assets");
var server = jsDAV.createServer({
node: path.resolve("tmp/assets"),
locksBackend: jsDAV_Locks_Backend_FS.new(path.resolve("tmp/assets")),
}, 9001);

setTimeout(function(){
grunt.log.ok("Hopefully the server is started..");
done();
}, 3000);

});

};

0 comments on commit 478f9be

Please sign in to comment.