Add listtokens action which prints a list of tokens that the crawler already knows about. Requires a crawler with https://github.com/Microsoft/ghcrawler/pull/113 merged.
This commit is contained in:
Родитель
fe909cf5b1
Коммит
e3165cd411
10
bin/cc
10
bin/cc
|
@ -61,6 +61,10 @@ function getCommands() {
|
|||
.command('tokens <tokens...>')
|
||||
.description('Set the GitHub tokens to be used by the crawler. The parameter is a list of <token>#<trait>[,<trait>]* where the possible traits are "admin", "public", and "private"')
|
||||
.action(tokens => setTokens(tokens));
|
||||
commands
|
||||
.command('listtokens')
|
||||
.description('List GitHub tokens being used by the crawler.')
|
||||
.action(getTokens);
|
||||
commands
|
||||
.command('deadletters')
|
||||
.option('-c, --count', 'Count all deadletters')
|
||||
|
@ -128,6 +132,12 @@ function setTokens(tokens) {
|
|||
promise = crawlerClient.setTokens(tokens).then(() => console.log('Tokens set'));
|
||||
}
|
||||
|
||||
function getTokens() {
|
||||
promise = crawlerClient.getTokens().then(tokens => console.log(tokens.map(t => {
|
||||
return `${t.value}#${t.traits.join(",")}`
|
||||
}).join("\n")));
|
||||
}
|
||||
|
||||
function queueRequests(specs, options) {
|
||||
let requests = Array.isArray(specs) ? specs : [specs];
|
||||
requests = requests.map(request => request.trim().startsWith('{') ? JSON.parse(request) : request);
|
||||
|
|
|
@ -38,6 +38,10 @@ class CrawlerClient {
|
|||
return this._call('put', `${this.url}/config/tokens`, `Failed to set tokens`, tokens.join(';'));
|
||||
}
|
||||
|
||||
getTokens(tokens) {
|
||||
return this._call('get', `${this.url}/config/tokens`, `Failed to get tokens`);
|
||||
}
|
||||
|
||||
queueRequests(requests, queueName = 'normal') {
|
||||
return this._call('post', `${this.url}/requests/${encodeURIComponent(queueName)}`, `Failed to queue requests`, requests);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче