/
show-github-token.js
38 lines (33 loc) · 1.22 KB
/
show-github-token.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env node
/*
* This file is part of the Fxp Satis Serverless package.
*
* (c) François Pluchino <francois.pluchino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
'use strict';
require('dotenv').config();
const program = require('commander');
const fetch = require('node-fetch');
const utils = require('./utils/utils');
const getEndpoint = require('./utils/endpoint').getEndpoint;
const validateResponse = require('./utils/endpoint').validateResponse;
const createHeaders = require('./utils/endpoint').createHeaders;
program
.description('Show your token for Github Webhooks')
.option('-e, --endpoint [url]', 'Define the endpoint of Satis Serverless API (use for local dev)', false)
.parse(process.argv);
utils.spawn('node bin/config -e')
.then(() => getEndpoint(program))
.then((endpoint) => {
return fetch(endpoint + '/manager/github-token', {
method: 'GET',
headers: createHeaders()
})
})
.then(async (res) => await validateResponse(res))
.then(async (res) => (await res.json()).message)
.then((mess) => console.info(mess))
.catch(utils.displayError);