grunt-deployinator
Advanced tools
| language: node_js | ||
| node_js: | ||
| - "0.8" | ||
| - "0.10" | ||
| before_script: | ||
| - npm install -g grunt-cli |
| var exec = require('child_process').exec, | ||
| Promise = require('promise'), | ||
| version = require('./version.js'); | ||
| function deployPull(options) { | ||
| var host = options.host, | ||
| directory = options.directory; | ||
| function checkoutVersion(currentTag, done) { | ||
| 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; | ||
| } | ||
| done(stdout); | ||
| }); | ||
| } | ||
| function pushTags(fn) { | ||
| exec('git push --tags', function (error/*, stdout, stderr*/) { | ||
| if (error) { | ||
| throw error; | ||
| } | ||
| fn(); | ||
| }); | ||
| } | ||
| return new Promise(function(resolve, reject) { | ||
| tagRelease().then(function(currentTag) { | ||
| pushTags(function() { | ||
| checkoutVersion(currentTag, resolve); | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| function tagRelease() { | ||
| return new Promise(function(resolve, reject) { | ||
| version.fetchLastTag(function(lastTag) { | ||
| var currentTag = version.getNextTag(lastTag); | ||
| version.createTag(currentTag, function() { | ||
| resolve(currentTag); | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| module.exports.deployPull = deployPull; | ||
| module.exports.tagRelease = tagRelease; |
| var exec = require('child_process').exec; | ||
| /* istanbul ignore next */ | ||
| function createTag(tag, fn) { | ||
| exec('git tag ' + tag, function(error/*, stdout, stderr*/) { | ||
| if (error) { | ||
| throw error; | ||
| } | ||
| fn(); | ||
| }); | ||
| } | ||
| function getNextTag(lastTag) { | ||
| var nextTag = lastTag.split('.'), | ||
| i; | ||
| nextTag = nextTag.map(function (value) { | ||
| return parseInt(value, 10); | ||
| }); | ||
| for (i = 0; i < 3; i ++) { | ||
| if (!nextTag[i]) { | ||
| nextTag[i] = 0; | ||
| } | ||
| } | ||
| nextTag[2] += 1; | ||
| nextTag = nextTag.join('.'); | ||
| return nextTag; | ||
| } | ||
| /* istanbul ignore next */ | ||
| 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); | ||
| }); | ||
| } | ||
| module.exports.createTag = createTag; | ||
| module.exports.fetchLastTag = fetchLastTag; | ||
| module.exports.getNextTag = getNextTag; |
| var version = require('../lib/version.js'); | ||
| describe('Version utilities', function () { | ||
| it('should be able to handle partial version numbers', function () { | ||
| expect(version.getNextTag('0.3')).to.equal('0.3.1'); | ||
| }); | ||
| }); |
| global.chai = require('chai'); | ||
| global.expect = chai.expect; |
+116
-60
@@ -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']); | ||
| }; |
@@ -5,4 +5,8 @@ <?xml version="1.0" encoding="UTF-8"?> | ||
| <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> | ||
| <group/> | ||
| <group> | ||
| <file>file:/Users/void/Developer/grunt-deployinator/spec/versionSpec.js</file> | ||
| <file>file:/Users/void/Developer/grunt-deployinator/package.json</file> | ||
| <file>file:/Users/void/Developer/grunt-deployinator/Gruntfile.js</file> | ||
| </group> | ||
| </open-files> | ||
| </project-private> |
+13
-6
| { | ||
| "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" | ||
| } | ||
| } |
+17
-51
@@ -1,2 +0,2 @@ | ||
| # grunt-deployinator | ||
| # grunt-deployinator [](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 |
+18
-81
@@ -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']); | ||
| }; |
-13
| { | ||
| "curly": true, | ||
| "eqeqeq": true, | ||
| "immed": true, | ||
| "latedef": true, | ||
| "newcap": true, | ||
| "noarg": true, | ||
| "sub": true, | ||
| "undef": true, | ||
| "boss": true, | ||
| "eqnull": true, | ||
| "node": true | ||
| } |
| '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.deployinator = { | ||
| 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(); | ||
| }, | ||
| }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
12513
5.99%246
37.43%2
100%8
100%15
-6.25%56
-37.78%4
100%+ Added
+ Added
+ Added