Skip to content

Commit

Permalink
Replace request and then-sleep dependencies (#161)
Browse files Browse the repository at this point in the history
* Change request to node-fetch

* Remove dependency `then-sleep`

* Fix fetch

* Add delay dependency
  • Loading branch information
styfle authored Aug 27, 2019
1 parent 0b421e0 commit 01279b3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 374 deletions.
2 changes: 1 addition & 1 deletion bin/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const open = require('opn');
const checkForUpdate = require('update-check');
const {red} = require('chalk');
const nodeVersion = require('node-version');
const sleep = require('then-sleep');
const sleep = require('delay');

// Utilities
const groupChanges = require('../lib/group');
Expand Down
39 changes: 17 additions & 22 deletions lib/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
const queryString = require('querystring');

// Packages
const request = require('request-promise-native');
const fetch = require('node-fetch');
const open = require('opn');
const randomString = require('random-string');
const retry = require('async-retry');
const Storage = require('configstore');
const GitHubAPI = require('@octokit/rest');
const sleep = require('then-sleep');
const sleep = require('delay');

// Utilities
const pkg = require('../package');
Expand All @@ -26,26 +26,21 @@ const github = new GitHubAPI({
const tokenAPI = state =>
retry(
() =>
new Promise((resolve, reject) => {
request({
uri: 'https://release-auth.zeit.sh',
qs: {
state
},
json: true
})
.then(res => {
if (res.status === 403) {
reject(new Error('Unauthorized'));
}

if (res.error) {
reject(res.error);
}

resolve(res.token);
})
.catch(reject);
new Promise(async (resolve, reject) => {
const qs = queryString.stringify({state});
try {
const res = await fetch(`https://release-auth.zeit.sh/?${qs}`);
if (res.status === 403) {
reject(new Error('Unauthorized'));
}
const data = await res.json();
if (data.error) {
reject(res.error);
}
resolve(data.token);
} catch (error) {
reject(error);
}
}),
{
retries: 500
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"capitalize": "1.0.0",
"chalk": "2.4.0",
"configstore": "3.1.2",
"delay": "4.3.0",
"escape-goat": "1.3.0",
"fs-extra": "5.0.0",
"git-repo-name": "0.6.0",
Expand All @@ -44,15 +45,13 @@
"git-username": "1.0.0",
"github-username": "4.1.0",
"inquirer": "5.2.0",
"node-fetch": "2.6.0",
"node-version": "1.1.3",
"opn": "5.4.0",
"ora": "2.0.0",
"random-string": "0.2.0",
"request": "2.85.0",
"request-promise-native": "1.0.5",
"semver": "5.5.0",
"tagged-versions": "1.3.0",
"then-sleep": "1.0.1",
"update-check": "1.3.2"
},
"eslintConfig": {
Expand Down
Loading

0 comments on commit 01279b3

Please sign in to comment.