lastcall-nightcrawler
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -7,3 +7,9 @@ # Changelog | ||
## [1.1.0] - 2018-07-10 | ||
### Changed | ||
- Updated yargs to 12.0.1. | ||
- Moved crawlerfile to a `--config` flag that is required for all commands. | ||
- Updated Ora to 2.0.0. | ||
## [1.0.1] - 2018-02-25 | ||
@@ -10,0 +16,0 @@ |
@@ -6,13 +6,13 @@ 'use strict'; | ||
describe('Index File', function () { | ||
it('Should export a crawler', function () { | ||
expect(typeof CrawlerExport).toEqual('function'); | ||
}); | ||
it('Should attach drivers as an object on the crawler', function () { | ||
expect(typeof CrawlerExport.drivers.request).toBe('function'); | ||
}); | ||
it('Should attach metrics as an object on the crawler', function () { | ||
expect(typeof CrawlerExport.metrics.Number).toBe('function'); | ||
expect(typeof CrawlerExport.metrics.Milliseconds).toBe('function'); | ||
expect(typeof CrawlerExport.metrics.Percent).toBe('function'); | ||
}); | ||
it('Should export a crawler', function () { | ||
expect(typeof CrawlerExport).toEqual('function'); | ||
}); | ||
it('Should attach drivers as an object on the crawler', function () { | ||
expect(typeof CrawlerExport.drivers.request).toBe('function'); | ||
}); | ||
it('Should attach metrics as an object on the crawler', function () { | ||
expect(typeof CrawlerExport.metrics.Number).toBe('function'); | ||
expect(typeof CrawlerExport.metrics.Milliseconds).toBe('function'); | ||
expect(typeof CrawlerExport.metrics.Percent).toBe('function'); | ||
}); | ||
}); |
@@ -73,3 +73,2 @@ 'use strict'; | ||
expect(argv.silent).toEqual(false); | ||
expect(argv.crawlerfile).toEqual('./nightcrawler.js'); | ||
expect(argv.json).toEqual(''); | ||
@@ -85,7 +84,2 @@ expect(argv.junit).toEqual(''); | ||
}); | ||
it('Passes crawlerfile', function () { | ||
return runWithHandler('crawl ./foo.js', argv => { | ||
expect(argv.crawlerfile).toEqual('foo.js'); | ||
}); | ||
}); | ||
it('Passes junit', function () { | ||
@@ -120,5 +114,4 @@ return runWithHandler('crawl --junit foo/bar.xml', argv => { | ||
return (0, _crawl.handler)({ | ||
crawlerfile: crawler, | ||
stdout | ||
}).then(function () { | ||
}, crawler).then(function () { | ||
expect(called).toEqual(1); | ||
@@ -136,5 +129,4 @@ }); | ||
return (0, _crawl.handler)({ | ||
crawlerfile: crawler, | ||
stdout | ||
}).then(function () { | ||
}, crawler).then(function () { | ||
var output = stdout.read().toString(); | ||
@@ -149,5 +141,4 @@ expect(output).toMatch('Setup\nCrawl\nAnalyze\n'); | ||
return (0, _crawl.handler)({ | ||
crawlerfile: crawler, | ||
stdout | ||
}).then(function () { | ||
}, crawler).then(function () { | ||
expect(stdout.read().toString()).toContain('CONSOLE_ANALYSIS:1:color'); | ||
@@ -164,5 +155,4 @@ }); | ||
const p = (0, _crawl.handler)({ | ||
crawlerfile: crawler, | ||
stdout | ||
}); | ||
}, crawler); | ||
return expect(p).rejects.toBeInstanceOf(_errors.FailedAnalysisError); | ||
@@ -176,5 +166,4 @@ }); | ||
const p = (0, _crawl.handler)({ | ||
crawlerfile: crawler, | ||
stdout | ||
}); | ||
}, crawler); | ||
return expect(p).rejects.toBe('Oh no!'); | ||
@@ -188,6 +177,5 @@ }); | ||
return (0, _crawl.handler)({ | ||
crawlerfile: crawler, | ||
junit: filename, | ||
stdout | ||
}).then(function () { | ||
}, crawler).then(function () { | ||
expect(_junit2.default).toHaveBeenCalledTimes(1); | ||
@@ -203,6 +191,5 @@ expect(_junit2.default.mock.calls[0][0]).toBeInstanceOf(_analysis2.default); | ||
return (0, _crawl.handler)({ | ||
crawlerfile: crawler, | ||
json: filename, | ||
stdout | ||
}).then(function () { | ||
}, crawler).then(function () { | ||
expect(_fs2.default.existsSync(filename)).toEqual(true); | ||
@@ -209,0 +196,0 @@ _fs2.default.unlinkSync(filename); |
'use strict'; | ||
var _util = require('../util'); | ||
var _ora = require('ora'); | ||
@@ -32,8 +30,2 @@ | ||
exports.builder = yargs => { | ||
yargs.positional('crawlerfile', { | ||
describe: 'the name of the crawler file', | ||
default: './nightcrawler.js', | ||
type: 'string', | ||
normalize: true | ||
}); | ||
yargs.option('concurrency', { | ||
@@ -68,4 +60,3 @@ alias: 'c', | ||
exports.handler = (() => { | ||
var _ref = _asyncToGenerator(function* (argv) { | ||
const crawlerfile = argv.crawlerfile; | ||
var _ref = _asyncToGenerator(function* (argv, crawler) { | ||
var _argv$json = argv.json; | ||
@@ -80,3 +71,2 @@ const json = _argv$json === undefined ? '' : _argv$json; | ||
const crawler = (0, _util.requireCrawler)(crawlerfile); | ||
const spunCrawler = new CrawlerSpinnerDecorator(crawler, stdout); | ||
@@ -105,3 +95,3 @@ | ||
return function (_x) { | ||
return function (_x, _x2) { | ||
return _ref.apply(this, arguments); | ||
@@ -108,0 +98,0 @@ }; |
@@ -7,4 +7,29 @@ 'use strict'; | ||
var _util = require('./util'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
_yargs2.default.commandDir('commands').demandCommand(1, '').help().argv; | ||
_yargs2.default.option('config').default('config', './nightcrawler.js'); | ||
try { | ||
const crawler = (0, _util.requireCrawler)(_yargs2.default.argv.config); | ||
} catch (e) { | ||
throw new Error(`Unable to load crawler from ${_yargs2.default.argv.config}`); | ||
} | ||
function visitCommand(command) { | ||
const oldHandler = command.handler; | ||
// Inject the crawler into the command. | ||
command.handler = function (argv) { | ||
return oldHandler(argv, crawler); | ||
}; | ||
return command; | ||
} | ||
// I need environment, sample size, auth. | ||
_yargs2.default.commandDir('commands', { | ||
visit: visitCommand | ||
}).demandCommand(1, '').help().argv; |
@@ -16,3 +16,2 @@ 'use strict'; | ||
const Promise = require('bluebird'); | ||
const request = require('request-promise'); | ||
const EventEmitter = require('events-async'); | ||
@@ -19,0 +18,0 @@ const log = require('debug')('nightcrawler:info'); |
{ | ||
"name": "lastcall-nightcrawler", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"main": "dist/index.js", | ||
@@ -14,6 +14,6 @@ "license": "MIT", | ||
"markdown-table": "^1.1.1", | ||
"ora": "^1.4.0", | ||
"ora": "^2.0.0", | ||
"request": "^2.83.0", | ||
"request-promise": "^4.2.2", | ||
"yargs": "^11.0.0" | ||
"yargs": "^12.0.1" | ||
}, | ||
@@ -25,2 +25,3 @@ "bin": { | ||
"babel-cli": "^6.26.0", | ||
"babel-eslint": "^8.2.5", | ||
"babel-preset-env": "^1.6.1", | ||
@@ -31,6 +32,7 @@ "babel-preset-flow": "^6.23.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-flowtype": "^2.50.0", | ||
"flow": "^0.2.3", | ||
"flow-bin": "^0.65.0", | ||
"jest": "^22.1.4", | ||
"jest-junit": "^3.5.0", | ||
"flow-bin": "^0.76.0", | ||
"jest": "^23.4.0", | ||
"jest-junit": "^5.1.0", | ||
"nock": "^9.1.6", | ||
@@ -64,6 +66,11 @@ "prettier": "^1.10.2" | ||
"extends": [ | ||
"prettier" | ||
"prettier", | ||
"plugin:flowtype/recommended" | ||
], | ||
"plugins": [ | ||
"flowtype" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": 2017 | ||
"ecmaVersion": 2017, | ||
"sourceType": "module" | ||
} | ||
@@ -70,0 +77,0 @@ }, |
52216
14
1170
+ Addedcamelcase@5.3.1(transitive)
+ Addedclone@1.0.4(transitive)
+ Addeddefaults@1.0.4(transitive)
+ Addedfind-up@3.0.0(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedora@2.1.0(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedwcwidth@1.0.1(transitive)
+ Addedy18n@4.0.3(transitive)
+ Addedyargs@12.0.5(transitive)
+ Addedyargs-parser@11.1.1(transitive)
- Removedcamelcase@4.1.0(transitive)
- Removedfind-up@2.1.0(transitive)
- Removedlocate-path@2.0.0(transitive)
- Removedora@1.4.0(transitive)
- Removedp-limit@1.3.0(transitive)
- Removedp-locate@2.0.0(transitive)
- Removedp-try@1.0.0(transitive)
- Removedy18n@3.2.2(transitive)
- Removedyargs@11.1.1(transitive)
- Removedyargs-parser@9.0.2(transitive)
Updatedora@^2.0.0
Updatedyargs@^12.0.1