Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0ee7d8f
Showing
12 changed files
with
358 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
npm-debug.log | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"curly": true, | ||
"eqeqeq": true, | ||
"immed": true, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"sub": true, | ||
"undef": true, | ||
"boss": true, | ||
"eqnull": true, | ||
"node": true, | ||
"es5": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* grunt-svn-fetch | ||
* https://github.com/jones/svn-fetch | ||
* | ||
* Copyright (c) 2013 Stephen Jones | ||
* 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). | ||
svn_fetch: { | ||
default_options: { | ||
options: { | ||
}, | ||
files: { | ||
'tmp/default_options': ['test/fixtures/testing', 'test/fixtures/123'], | ||
}, | ||
}, | ||
custom_options: { | ||
options: { | ||
separator: ': ', | ||
punctuation: ' !!!', | ||
}, | ||
files: { | ||
'tmp/custom_options': ['test/fixtures/testing', 'test/fixtures/123'], | ||
}, | ||
}, | ||
}, | ||
|
||
// 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', 'svn_fetch', 'nodeunit']); | ||
|
||
// By default, lint and run all tests. | ||
grunt.registerTask('default', ['jshint', 'test']); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2013 Stephen Jones | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# grunt-svn-fetch | ||
|
||
> Ensures specified files are checked out or updated from SVN repository. | ||
## Getting Started | ||
This plugin requires Grunt `~0.4.0` | ||
|
||
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: | ||
|
||
npm install grunt-svn-fetch --save-dev | ||
|
||
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: | ||
|
||
grunt.loadNpmTasks('grunt-svn-fetch'); | ||
|
||
## The "svn_fetch" task | ||
|
||
### Overview | ||
In your project's Gruntfile, add a section named `svn_fetch` to the data object passed into `grunt.initConfig()`. | ||
|
||
grunt.initConfig({ | ||
svn_fetch: { | ||
options: { | ||
// Task-specific options go here. | ||
}, | ||
your_target: { | ||
options: { | ||
// Target-specific settings and/or options go here. | ||
} | ||
}, | ||
}, | ||
}) | ||
|
||
The task works by checking for the presence of the ```.svn``` folder under each of the target folders. If present, an update is performed, otherwise a checkout is done. | ||
|
||
### Options | ||
|
||
#### options.bin | ||
Type: `String` | ||
|
||
Default value: `'svn'` | ||
|
||
Specifies the location of the SVN binary. | ||
|
||
|
||
#### options.repository | ||
Type: `String` | ||
|
||
Default value: `''` | ||
|
||
The URL of the SVN repository. | ||
|
||
|
||
#### options.path | ||
Type: `String` | ||
|
||
Default value: `''` | ||
|
||
The base element of the path to where checked out or updated files are placed. | ||
|
||
|
||
### Usage Examples | ||
|
||
grunt.initConfig({ | ||
svn_fetch: { | ||
options: { | ||
'repository': 'https://my_repos.com/projectX/trunk/', | ||
'path': '/svn/projectX/src/' | ||
}, | ||
projectX: { | ||
map: { | ||
'folderX': 'SVNFolderX', | ||
'folderY': 'SVNFolderY' | ||
} | ||
} | ||
}, | ||
}); | ||
|
||
Each entry in ```map``` utilises the ```path``` and ```respository``` options to determine the full path and URL of the items being considered. So, in this case, the first entry would resolve to: | ||
|
||
```/svn/projectX/src/folderX``` | ||
and | ||
```https://my_repos.com/projectX/trunk/SVNFolderX``` | ||
|
||
Note the inclusion of slashes on the option entries. The plugin makes no effort to ensure slashes are correct. | ||
|
||
## Release History | ||
* 2013-03-13 0.1.0 Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "grunt-svn-fetch", | ||
"description": "Ensures specified files are checked out or updated from SVN repository.", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/askelkana/svn-fetch", | ||
"author": { | ||
"name": "askelkana", | ||
"email": "askelkana@gmail.com" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/askelkana/svn-fetch.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/askelkana/svn-fetch/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/askelkana/svn-fetch/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"main": "Gruntfile.js", | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
}, | ||
"scripts": { | ||
"test": "grunt test" | ||
}, | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "~0.1.1", | ||
"grunt-contrib-clean": "~0.4.0", | ||
"grunt-contrib-nodeunit": "~0.1.2", | ||
"grunt": "~0.4.0" | ||
}, | ||
"peerDependencies": { | ||
"grunt": "~0.4.0" | ||
}, | ||
"keywords": [ | ||
"gruntplugin" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* grunt-svn-fetch | ||
* https://github.com/jones/svn-fetch | ||
* | ||
* Copyright (c) 2013 Stephen Jones | ||
* Licensed under the MIT license. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = function (grunt) { | ||
|
||
// Please see the Grunt documentation for more information regarding task | ||
// creation: http://gruntjs.com/creating-tasks | ||
|
||
grunt.registerMultiTask('svn_fetch', 'Updates or checks out the desired files', function () { | ||
var exec = require('child_process').exec; | ||
var options = this.options({ | ||
bin: 'svn', | ||
repository: '', | ||
path: '' | ||
}); | ||
var done = this.async(); | ||
var map = this.data.map; | ||
if (map != undefined) { | ||
processMap(); | ||
} else { | ||
grunt.log.error('\n\'map\' missing.'); | ||
done(true); | ||
} | ||
|
||
function processMap() { | ||
var paths = Object.keys(map); | ||
getNextMapping(); | ||
|
||
function getNextMapping() { | ||
if (paths.length > 0) { | ||
processPath(paths.shift()); | ||
} else { | ||
grunt.log.write('\n'); | ||
done(true); | ||
} | ||
} | ||
|
||
function processPath(path) { | ||
var command = options.bin; | ||
path = options.path + path; | ||
if (grunt.file.exists(path + '/.svn')) { | ||
command = [ command, 'update', path ].join(' '); | ||
} else { | ||
command = [ command, 'checkout', options.repository + map[path], path ].join(' '); | ||
} | ||
grunt.log.write('\nProcessing ' + path); | ||
exec(command, function (error, stdout) { | ||
grunt.log.write(stdout); | ||
if (error !== null) { | ||
grunt.log.error('\n#' + command + "\n" + error); | ||
} | ||
getNextMapping(); | ||
}); | ||
} | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Testing: 1 2 3 !!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Testing, 1 2 3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 2 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
var grunt = require('grunt'); | ||
|
||
/* | ||
======== A Handy Little Nodeunit Reference ======== | ||
https://github.com/caolan/nodeunit | ||
Test methods: | ||
test.expect(numAssertions) | ||
test.done() | ||
Test assertions: | ||
test.ok(value, [message]) | ||
test.equal(actual, expected, [message]) | ||
test.notEqual(actual, expected, [message]) | ||
test.deepEqual(actual, expected, [message]) | ||
test.notDeepEqual(actual, expected, [message]) | ||
test.strictEqual(actual, expected, [message]) | ||
test.notStrictEqual(actual, expected, [message]) | ||
test.throws(block, [error], [message]) | ||
test.doesNotThrow(block, [error], [message]) | ||
test.ifError(value) | ||
*/ | ||
|
||
exports.svn_fetch = { | ||
setUp: function(done) { | ||
// setup here if necessary | ||
done(); | ||
}, | ||
default_options: function(test) { | ||
test.expect(1); | ||
|
||
var actual = grunt.file.read('tmp/default_options'); | ||
var expected = grunt.file.read('test/expected/default_options'); | ||
test.equal(actual, expected, 'should describe what the default behavior is.'); | ||
|
||
test.done(); | ||
}, | ||
custom_options: function(test) { | ||
test.expect(1); | ||
|
||
var actual = grunt.file.read('tmp/custom_options'); | ||
var expected = grunt.file.read('test/expected/custom_options'); | ||
test.equal(actual, expected, 'should describe what the custom option(s) behavior is.'); | ||
|
||
test.done(); | ||
}, | ||
}; |