grunt-deployinator
Advanced tools
Comparing version 0.1.0 to 0.2.0
176
Gruntfile.js
@@ -8,67 +8,123 @@ /* | ||
*/ | ||
'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). | ||
deployinator: { | ||
default_options: { | ||
options: { | ||
module.exports = function (grunt) { | ||
'use strict'; | ||
var jsHintOptions; | ||
jsHintOptions = { | ||
bitwise: true, | ||
curly: true, | ||
camelcase: true, | ||
eqeqeq: true, | ||
freeze: true, | ||
immed: true, | ||
latedef: true, | ||
newcap: true, | ||
noarg: true, | ||
forin: true, | ||
sub: true, | ||
undef: true, | ||
unused: true, | ||
noempty: true, | ||
boss: false, | ||
eqnull: true, | ||
browser: true, | ||
indent: 4, | ||
maxcomplexity: 7, | ||
maxstatements: 36, | ||
maxparams: 5, | ||
maxdepth: 3, | ||
maxlen: 100, | ||
trailing: true, | ||
maxerr: 5, | ||
globals: { | ||
module: true, | ||
require: true, | ||
exports: true, | ||
grunt: true, | ||
describe: true, | ||
it: true, | ||
expect: true | ||
} | ||
}; | ||
// Project configuration. | ||
grunt.initConfig({ | ||
jshint: { | ||
all: [ | ||
'Gruntfile.js', | ||
'tasks/*.js', | ||
'spec/*.js' | ||
], | ||
options: jsHintOptions, | ||
}, | ||
files: { | ||
'tmp/default_options': ['test/fixtures/testing', 'test/fixtures/123'], | ||
clean: { | ||
coverage: { | ||
src: ['coverage/'] | ||
} | ||
}, | ||
}, | ||
custom_options: { | ||
options: { | ||
separator: ': ', | ||
punctuation: ' !!!', | ||
copy: { | ||
coverage: { | ||
src: ['spec/**'], | ||
dest: 'coverage/' | ||
} | ||
}, | ||
files: { | ||
'tmp/custom_options': ['test/fixtures/testing', 'test/fixtures/123'], | ||
instrument: { | ||
files: 'lib/*.js', | ||
options: { | ||
lazy: true, | ||
basePath: 'coverage/' | ||
} | ||
}, | ||
}, | ||
}, | ||
mochaTest: { | ||
all: { | ||
options: { | ||
reporter: 'spec', | ||
require: './testHelper.js' | ||
}, | ||
src: ['coverage/spec/*.js'] | ||
} | ||
}, | ||
storeCoverage: { | ||
options: { | ||
dir: 'coverage/reports' | ||
} | ||
}, | ||
coverage: { | ||
options: { | ||
thresholds: { | ||
'statements': 100, | ||
'branches': 100, | ||
'lines': 100, | ||
'functions': 100 | ||
}, | ||
dir: 'coverage/reports', | ||
root: '.' | ||
} | ||
}, | ||
makeReport: { | ||
src: 'coverage/reports/**/*.json', | ||
options: { | ||
type: 'lcov', | ||
dir: 'coverage/reports', | ||
print: 'detail' | ||
} | ||
} | ||
}); | ||
grunt.loadTasks('tasks'); | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-mocha-test'); | ||
grunt.loadNpmTasks('grunt-contrib-clean'); | ||
grunt.loadNpmTasks('grunt-contrib-copy'); | ||
grunt.loadNpmTasks('grunt-istanbul'); | ||
grunt.loadNpmTasks('grunt-istanbul-coverage'); | ||
// 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', 'deployinator', 'nodeunit']); | ||
// By default, lint and run all tests. | ||
grunt.registerTask('default', ['jshint', 'test']); | ||
grunt.registerTask('test', | ||
['clean', 'instrument', 'copy', 'mochaTest', 'storeCoverage', 'makeReport', 'coverage'] | ||
); | ||
grunt.registerTask('check', ['jshint', 'test']); | ||
grunt.registerTask('default', ['jshint', 'test']); | ||
}; |
{ | ||
"name": "grunt-deployinator", | ||
"description": "Grunt plugin that deploys git repositories on remote servers.", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/istvan-antal/grunt-deployinator", | ||
@@ -31,5 +31,9 @@ "author": { | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "^0.9.2", | ||
"grunt-contrib-clean": "^0.5.0", | ||
"grunt-contrib-nodeunit": "^0.3.3", | ||
"grunt-contrib-jshint": "0.9.2", | ||
"chai": "1.9.1", | ||
"grunt-mocha-test": "~0.9.0", | ||
"grunt-istanbul": "~0.2.4", | ||
"grunt-contrib-clean": "0.5.0", | ||
"grunt-contrib-copy": "0.5.0", | ||
"grunt-istanbul-coverage": "0.0.5", | ||
"grunt": "~0.4.4" | ||
@@ -42,3 +46,6 @@ }, | ||
"gruntplugin" | ||
] | ||
} | ||
], | ||
"dependencies": { | ||
"promise": "^4.0.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# grunt-deployinator | ||
# grunt-deployinator [![Build Status](https://travis-ci.org/istvan-antal/grunt-deployinator.png?branch=master)](https://travis-ci.org/istvan-antal/grunt-deployinator) | ||
@@ -25,12 +25,14 @@ > Grunt plugin that deploys git repositories on remote servers. | ||
Pull to deploy configuration: | ||
```js | ||
grunt.initConfig({ | ||
deployinator: { | ||
options: { | ||
// Task-specific options go here. | ||
}, | ||
your_target: { | ||
// Target-specific file lists and/or options go here. | ||
}, | ||
}, | ||
deployinator: { | ||
app: { | ||
options: { | ||
host: "yourhost", | ||
directory: "/opt/location-of-your-repository" | ||
} | ||
} | ||
} | ||
}); | ||
@@ -41,47 +43,10 @@ ``` | ||
#### options.separator | ||
Type: `String` | ||
Default value: `', '` | ||
#### options.host | ||
A string value that is used to do something with whatever. | ||
The ssh host of the production system. | ||
#### options.punctuation | ||
Type: `String` | ||
Default value: `'.'` | ||
#### options.directory | ||
A string value that is used to do something else with whatever else. | ||
Location of the production source location on the production system. | ||
### Usage Examples | ||
#### Default Options | ||
In this example, the default options are used to do something with whatever. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result would be `Testing, 1 2 3.` | ||
```js | ||
grunt.initConfig({ | ||
deployinator: { | ||
options: {}, | ||
files: { | ||
'dest/default_options': ['src/testing', 'src/123'], | ||
}, | ||
}, | ||
}); | ||
``` | ||
#### Custom Options | ||
In this example, custom options are used to do something else with whatever else. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result in this case would be `Testing: 1 2 3 !!!` | ||
```js | ||
grunt.initConfig({ | ||
deployinator: { | ||
options: { | ||
separator: ': ', | ||
punctuation: ' !!!', | ||
}, | ||
files: { | ||
'dest/default_options': ['src/testing', 'src/123'], | ||
}, | ||
}, | ||
}); | ||
``` | ||
## Contributing | ||
@@ -91,2 +56,3 @@ 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)_ | ||
* 0.1.0 initial version that is capabil of performing the deployment |
@@ -9,7 +9,7 @@ /* | ||
'use strict'; | ||
module.exports = function(grunt) { | ||
grunt.registerMultiTask('deployinator', 'Grunt plugin that deploys git repositories on remote servers.', function() { | ||
// Merge task-specific and/or target-specific options with these defaults. | ||
var deployinator = require('../lib/deployinator.js'); | ||
grunt.registerMultiTask('deployPull', | ||
'SSH into a server and do a pull', function() { | ||
var options = this.options(); | ||
@@ -21,82 +21,19 @@ | ||
var exec = require('child_process').exec, | ||
done = this.async(), | ||
host = options.host, | ||
directory = options.directory; | ||
function checkoutVersion(currentTag) { | ||
var command = "ssh " + host + " '"; | ||
command += "cd " + directory + ';'; | ||
command += "git fetch --tags;"; | ||
command += "git checkout " + currentTag + ";"; | ||
command += "npm install;"; | ||
command += "grunt build"; | ||
command += "'"; | ||
exec(command, function (error, stdout/*, stderr*/) { | ||
if (error) { | ||
throw error; | ||
} | ||
grunt.log.writeln(stdout); | ||
done(); | ||
}); | ||
} | ||
function pushTags(fn) { | ||
exec('git push --tags', function (error/*, stdout, stderr*/) { | ||
if (error) { | ||
throw error; | ||
} | ||
fn(); | ||
}); | ||
} | ||
var done = this.async(); | ||
function tagVersion(lastTag) { | ||
var currentTag = getNextTag(lastTag); | ||
exec('git tag ' + currentTag, function (error/*, stdout, stderr*/) { | ||
if (error) { | ||
throw error; | ||
} | ||
pushTags(function () { | ||
checkoutVersion(currentTag); | ||
}); | ||
}); | ||
} | ||
function getNextTag(lastTag) { | ||
var nextTag = lastTag.split('.'); | ||
nextTag[2] = parseInt(nextTag[2], 10) + 1; | ||
nextTag = nextTag.join('.'); | ||
return nextTag; | ||
} | ||
deployinator.deployPull(options).then(function (output) { | ||
grunt.log.writeln(output); | ||
done(); | ||
}); | ||
}); | ||
grunt.registerTask('tagRelease', | ||
'Creates a git tag for the release.', function() { | ||
function fetchLastTag(fn) { | ||
exec('git tag -l', function (error, stdout/*, stderr*/) { | ||
if (error) { | ||
throw error; | ||
} | ||
var tags = String(stdout).split("\n").filter(function (line) { | ||
return !!line; | ||
}).sort(), | ||
lastTag = '0.0.0'; | ||
if (tags.length) { | ||
lastTag = tags[tags.length - 1]; | ||
} | ||
fn(lastTag); | ||
}); | ||
} | ||
var done = this.async(); | ||
fetchLastTag(tagVersion); | ||
deployinator.tagRelease().then(done); | ||
}); | ||
}; | ||
grunt.registerMultiTask('deployinator', ['deployPull']); | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12513
246
2
8
15
56
3
+ Addedpromise@^4.0.0
+ Addedasap@1.0.0(transitive)
+ Addedpromise@4.0.0(transitive)