Comparing version 0.3.0 to 0.3.1
@@ -28,6 +28,6 @@ 'use strict'; | ||
pass: { type: 'string' }, | ||
a: { $ref: '#/definitions/dateTime' }, | ||
b: { $ref: '#/definitions/dateTime' }, | ||
after: { $ref: '#/definitions/dateTime' }, | ||
before: { $ref: '#/definitions/dateTime' }, | ||
a: { $ref: '#/definitions/dateTimeOrInt' }, | ||
b: { $ref: '#/definitions/dateTimeOrInt' }, | ||
after: { $ref: '#/definitions/dateTimeOrInt' }, | ||
before: { $ref: '#/definitions/dateTimeOrInt' }, | ||
tap: { type: 'boolean' } | ||
@@ -34,0 +34,0 @@ } |
@@ -12,3 +12,4 @@ 'use strict'; | ||
const DEFINITIONS = { | ||
dateTime: { | ||
dateTimeOrInt: { | ||
type: ['string', 'integer'], | ||
anyOf: [ | ||
@@ -59,4 +60,4 @@ { format: 'date' }, | ||
const before = argv.b || argv.before; | ||
if (after) opts.after = new Date(after); | ||
if (before) opts.before = new Date(before); | ||
if (after) opts.after = getRangeDate(after); | ||
if (before) opts.before = getRangeDate(before); | ||
@@ -73,1 +74,6 @@ opts.tap = argv.tap; | ||
} | ||
function getRangeDate(param) { | ||
return new Date(typeof param == 'string' ? param | ||
: Date.now() - param * 86400000); // days | ||
} |
{ | ||
"name": "gh-lint", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Rule-based command-line tool for auditing GitHub repositories", | ||
@@ -5,0 +5,0 @@ "main": "lib/execute/index.js", |
@@ -32,3 +32,3 @@ # gh-lint | ||
- `-p` (or `--pass`) - GitHub password. | ||
- `-a` (or `--after`) / `-b` (or `--before`) - only validate repositories in organizations and in teams that were changed **after**/**before** this date (or date-time). These options have no effect on repositories that are explicitely specified. | ||
- `-a` (or `--after`) / `-b` (or `--before`) - only validate repositories in organizations and in teams that were changed **after**/**before** this date (also can be date-time or the integer number of days). These options have no effect on repositories that are explicitely specified. | ||
- `--tap` - output results in TAP format | ||
@@ -35,0 +35,0 @@ |
@@ -80,2 +80,23 @@ 'use strict'; | ||
it('should check repos in orgs changed in the last X days', () => { | ||
githubMock.repos.organization.MailOnline.list(); | ||
githubMock.repos.organization.milojs.list(); | ||
githubMock.mock('/repos/MailOnline/json-schema-test', '../fixtures/mailonline_repos/json-schema-test'); | ||
githubMock.mock('/repos/MailOnline/ImageViewer', '../fixtures/mailonline_repos/ImageViewer'); | ||
githubMock.mock('/repos/milojs/milo', '../fixtures/milojs_repos/milo'); | ||
return ok(run([ | ||
'--config', './spec/fixtures/config-orgs.json', | ||
'--after', getDays('2017-01-20'), '--before', getDays('2017-02-01') | ||
], false)).then(() => { | ||
assert.equal(log, 'warning MailOnline/json-schema-test: repo-homepage - not satisfied\n' + | ||
'warning MailOnline/ImageViewer: repo-homepage - not satisfied'); | ||
assert(nock.isDone()); | ||
}); | ||
function getDays(dateStr) { | ||
return Math.floor((Date.now() - new Date(dateStr).getTime())/86400000) + 1; | ||
} | ||
}); | ||
it('should output results in TAP format', () => { | ||
@@ -82,0 +103,0 @@ githubMock.mock('/repos/MailOnline/videojs-vast-vpaid', '../fixtures/videojs-vast-vpaid-repo-meta'); |
730436
13447