grunt-github-manifest
Advanced tools
Comparing version 0.1.7 to 0.2.0
@@ -32,3 +32,3 @@ module.exports = function(grunt) { | ||
github: { | ||
user: "christriddle", | ||
user: "opentable", | ||
repo: "grunt-github-manifest" | ||
@@ -44,3 +44,3 @@ } | ||
grunt.loadNpmTasks('grunt-mocha-test'); | ||
grunt.registerTask('test', ['jshint', 'start-date-server', 'create-manifest:test', 'mochaTest']); | ||
grunt.registerTask('test', ['jshint', 'start-date-server', 'clean-manifest', 'create-manifest:test', 'mochaTest']); | ||
grunt.registerTask('local_test', ['jshint', 'create-manifest:test']); | ||
@@ -50,2 +50,11 @@ grunt.registerTask('default', ['test']); | ||
grunt.loadTasks('tests/tasks'); | ||
}; | ||
grunt.registerTask('clean-manifest', 'Deletes the manifest created by the test', function() { | ||
var fs = require('fs'); | ||
try { | ||
fs.unlinkSync('tests/data/commit_history.json'); | ||
} | ||
catch (err) {} | ||
}); | ||
}; |
{ | ||
"name": "grunt-github-manifest", | ||
"version": "0.1.7", | ||
"version": "0.2.0", | ||
"description": "Saves to file the commit history for a Github project from a specified date", | ||
@@ -11,3 +11,3 @@ "main": "Gruntfile.js", | ||
"type": "git", | ||
"url": "git://github.com/christriddle/grunt-github-manifest.git" | ||
"url": "git://github.com/opentable/grunt-github-manifest.git" | ||
}, | ||
@@ -17,8 +17,8 @@ "keywords": [ | ||
], | ||
"author": "christriddle", | ||
"author": "opentable", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/christriddle/grunt-github-manifest/issues" | ||
"url": "https://github.com/opentable/grunt-github-manifest/issues" | ||
}, | ||
"homepage": "https://github.com/christriddle/grunt-github-manifest", | ||
"homepage": "https://github.com/opentable/grunt-github-manifest", | ||
"peerDependencies": { | ||
@@ -30,4 +30,3 @@ "grunt": "~0.4.2" | ||
"q": "~1.0.1", | ||
"JSONPath": "~0.10.0", | ||
"github": "~0.1.16" | ||
"JSONPath": "~0.10.0" | ||
}, | ||
@@ -34,0 +33,0 @@ "devDependencies": { |
@@ -5,3 +5,3 @@ # grunt-github-manifest | ||
[![Build Status](https://travis-ci.org/christriddle/grunt-github-manifest.svg?branch=master)](https://travis-ci.org/christriddle/grunt-github-manifest) | ||
[![Build Status](https://travis-ci.org/opentable/grunt-github-manifest.svg?branch=master)](https://travis-ci.org/opentable/grunt-github-manifest) | ||
@@ -39,3 +39,4 @@ [![NPM](https://nodei.co/npm/grunt-github-manifest.png)](https://nodei.co/npm/grunt-github-manifest) | ||
user: "christriddle", | ||
repo: "grunt-github-manifest" | ||
repo: "grunt-github-manifest", | ||
proxy: null | ||
} | ||
@@ -57,2 +58,3 @@ } | ||
- `repo` | ||
- `o_auth_token` | ||
- `o_auth_token` | ||
- `proxy` - Full url including port |
@@ -7,3 +7,2 @@ 'use string'; | ||
q = require('q'), | ||
GitHubApi = require('github'), | ||
fs = require('fs'); | ||
@@ -20,2 +19,6 @@ | ||
if (!options.commitHistoryStartDate) { | ||
grunt.fatal("Must supply either commitHistoryStartDateOptions or commitHistoryStartDate in task options."); | ||
} | ||
var getDateFromUrlAndPath = function(options){ | ||
@@ -73,42 +76,34 @@ | ||
var getCommitHistoryFromGithub = function(startDate){ | ||
grunt.verbose.writeln(util.format("Getting commit history from %s/%s since %s", options.github.user, options.github.repo, startDate)); | ||
var url = util.format("https://api.github.com/repos/%s/%s/commits?since=%s", options.github.user, options.github.repo, startDate.toISOString()); | ||
if (options.github.o_auth_token) { | ||
url += "&access_token=" + options.github.o_auth_token; | ||
} | ||
grunt.verbose.writeln("Sending GET request to: " + url); | ||
var deferred = q.defer(); | ||
var github = new GitHubApi({ | ||
version: "3.0.0", | ||
request({ | ||
uri: url, | ||
proxy: options.github.proxy, | ||
port: options.github.port, | ||
debug: options.github.debug | ||
// todo: add User Agent | ||
}); | ||
if (options.github.o_auth_token) { | ||
try{ | ||
github.authenticate({ | ||
type: "oauth", | ||
token: options.github.o_auth_token | ||
}); | ||
headers: { | ||
Accept: 'application/vnd.github.v3+json', | ||
"User-Agent": "NodeJS Request" | ||
}, | ||
method: 'GET' | ||
}, function(error, response, body) { | ||
if (error){ | ||
deferred.reject(error); | ||
} | ||
catch(err){ | ||
deferred.reject(err); | ||
else if (response.statusCode >= 300) { | ||
deferred.reject(new Error("Bad status code: " + response.statusCode + ". Body: " + body)); | ||
} | ||
} | ||
github.repos.getCommits({ | ||
user: options.github.user, | ||
repo: options.github.repo, | ||
since: startDate | ||
}, function(err, res) { | ||
if (err){ | ||
grunt.verbose.writeln(err); | ||
deferred.reject(err); | ||
else { | ||
var jsonBody = JSON.parse(body); | ||
grunt.verbose.writeln(JSON.stringify(jsonBody, null, 4)); | ||
deferred.resolve(jsonBody); | ||
} | ||
else{ | ||
grunt.verbose.writeln("Github getCommits response received"); | ||
var prettyPrintedJson = JSON.stringify(res, null, 4); | ||
grunt.verbose.writeln(prettyPrintedJson); | ||
deferred.resolve(res); | ||
} | ||
}); | ||
@@ -137,23 +132,17 @@ | ||
if (options.commitHistoryStartDate){ | ||
getDateFromUrlAndPath(options.commitHistoryStartDate) | ||
.then(function(date){ | ||
return getCommitHistoryFromGithub(date); | ||
}) | ||
.then(function(manifest){ | ||
return saveManifest(manifest); | ||
}) | ||
.catch(function(err){ | ||
grunt.fatal(err); | ||
}) | ||
.done(function(){ | ||
grunt.verbose.writeln("Done!"); | ||
done(); | ||
}); | ||
} | ||
else{ | ||
grunt.fatal("Must supply either commitHistoryStartDateOptions or commitHistoryStartDate in task options."); | ||
} | ||
getDateFromUrlAndPath(options.commitHistoryStartDate) | ||
.then(function(date){ | ||
return getCommitHistoryFromGithub(date); | ||
}) | ||
.then(function(manifest){ | ||
return saveManifest(manifest); | ||
}) | ||
.catch(function(err){ | ||
grunt.fatal(err); | ||
}) | ||
.done(function(){ | ||
grunt.verbose.writeln("Done!"); | ||
done(); | ||
}); | ||
}); | ||
}; |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
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
15884
4
58
250
2
2
4
- Removedgithub@~0.1.16
- Removedgithub@0.1.16(transitive)