Skip to content

Commit

Permalink
feat: Remove request and use r2
Browse files Browse the repository at this point in the history
  • Loading branch information
HazAT committed Nov 8, 2017
1 parent 8177116 commit f7648e5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 72 deletions.
2 changes: 1 addition & 1 deletion lib/steps/Initial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ try {
projectPackage = require('../../package.json');
} catch {
projectPackage = require(`${process.cwd()}/package.json`);
wizardPackage = require(`${process.cwd()}/node_modules/@sentry/setup-wizard/package.json`);
wizardPackage = require(`${process.cwd()}/node_modules/@sentry/wizard/package.json`);
}

export class Initial extends BaseStep {
Expand Down
6 changes: 3 additions & 3 deletions lib/steps/OpenSentry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Answers } from 'inquirer';
import * as request from 'request-promise';
import { BottomBar, dim, green, l, nl } from '../Helper';
import { BaseStep } from './Step';
const open = require('open');
const r2 = require('r2');

export class OpenSentry extends BaseStep {
public async emit(answers: Answers) {
Expand All @@ -12,7 +12,7 @@ export class OpenSentry extends BaseStep {
this.debug(`Loading wizard for ${baseUrl}`);

try {
const data = JSON.parse(await request.get(`${baseUrl}api/0/wizard`));
const data = await r2.get(`${baseUrl}api/0/wizard`).json;

BottomBar.hide();

Expand All @@ -27,7 +27,7 @@ export class OpenSentry extends BaseStep {

return { hash: data.hash };
} catch (e) {
throw new Error(`Could not connect to wizard @ ${baseUrl} try --url`);
throw e;
}
}
}
24 changes: 11 additions & 13 deletions lib/steps/WaitForSentry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Answers } from 'inquirer';
import * as request from 'request-promise';
import { BottomBar, dim, green, l, nl } from '../Helper';
import { BaseStep } from './Step';
const r2 = require('r2');

export class WaitForSentry extends BaseStep {
public async emit(answers: Answers) {
Expand All @@ -11,18 +11,16 @@ export class WaitForSentry extends BaseStep {
BottomBar.show('Waiting for Sentry...');
const baseUrl = this.argv.url;

function poll() {
request
.get(`${baseUrl}api/0/wizard/${answers.hash}/`)
.then(async (data: any) => {
// Delete the wizard hash since we were able to fetch the data
await request.delete(`${baseUrl}api/0/wizard/${answers.hash}/`);
BottomBar.hide();
resolve({ wizard: JSON.parse(data) });
})
.catch((error: any) => {
setTimeout(poll, 1000);
});
async function poll() {
try {
const data = await r2.get(`${baseUrl}api/0/wizard/${answers.hash}/`).json;
// Delete the wizard hash since we were able to fetch the data
await r2.delete(`${baseUrl}api/0/wizard/${answers.hash}/`);
BottomBar.hide();
resolve({ wizard: data });
} catch (e) {
setTimeout(poll, 1000);
}
}
poll();
});
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@
"definition": "dist/index.d.ts"
},
"dependencies": {
"@types/lodash": "^4.14.82",
"@types/request-promise": "^4.1.39",
"chalk": "^2.3.0",
"glob": "^7.1.2",
"inquirer": "^3.3.0",
"lodash": "^4.17.4",
"open": "^0.0.5",
"request-promise": "^4.2.2",
"r2": "^2.0.0",
"sentry-cli-binary": "^1.21.0",
"xcode": "^1.0.0",
"yargs": "^10.0.3"
},
"devDependencies": {
"@types/inquirer": "^0.0.35",
"@types/jest": "^21.1.2",
"@types/lodash": "^4.14.82",
"@types/node": "^8.0.32",
"jest": "^21.2.1",
"prettier": "^1.7.4",
Expand All @@ -45,7 +44,7 @@
"scripts": {
"install": "npm run dist",
"clean": "rm -rf ./dist",
"dist": "npm run clean && tsc -p tsconfig.json",
"dist": "npm run clean && tsc -p tsconfig.json && chmod +x ./dist/index.js",
"test": "npm run dist && jest",
"try": "yarn dist && ts-node index.ts --url=http://localhost:8000/",
"try:debug": "yarn dist && ts-node index.ts --url=http://localhost:8000/ --debug",
Expand Down
73 changes: 22 additions & 51 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
# yarn lockfile v1


"@types/bluebird@*":
version "3.5.18"
resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.18.tgz#6a60435d4663e290f3709898a4f75014f279c4d6"

"@types/form-data@*":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@types/form-data/-/form-data-2.2.0.tgz#a98aac91dc99857b6af24caef7ca6df302f31565"
dependencies:
"@types/node" "*"

"@types/inquirer@^0.0.35":
version "0.0.35"
resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-0.0.35.tgz#e054657cf2d10963823957d4d06ec244f05c65be"
Expand All @@ -31,20 +21,6 @@
version "8.0.49"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.49.tgz#417f86ab4829c629fe561779ee48751e0fe2a11b"

"@types/request-promise@^4.1.39":
version "4.1.39"
resolved "https://registry.yarnpkg.com/@types/request-promise/-/request-promise-4.1.39.tgz#5c082bd20ae0a0caff83ba3a13e589ddacec5326"
dependencies:
"@types/bluebird" "*"
"@types/request" "*"

"@types/request@*":
version "2.0.7"
resolved "https://registry.yarnpkg.com/@types/request/-/request-2.0.7.tgz#a2aa5a57317c21971d9b024e393091ab2c99ab98"
dependencies:
"@types/form-data" "*"
"@types/node" "*"

"@types/rx-core-binding@*":
version "4.0.4"
resolved "https://registry.yarnpkg.com/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz#d969d32f15a62b89e2862c17b3ee78fe329818d3"
Expand Down Expand Up @@ -485,10 +461,6 @@ block-stream@*:
dependencies:
inherits "~2.0.0"

bluebird@^3.5.0:
version "3.5.1"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9"

[email protected]:
version "2.10.1"
resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f"
Expand Down Expand Up @@ -562,7 +534,7 @@ camelcase@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"

caseless@~0.12.0:
caseless@^0.12.0, caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"

Expand Down Expand Up @@ -1326,7 +1298,7 @@ is-stream@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"

is-typedarray@~1.0.0:
is-typedarray@^1.0.0, is-typedarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"

Expand Down Expand Up @@ -1791,7 +1763,7 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"

lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.4, lodash@^4.3.0:
lodash@^4.14.0, lodash@^4.17.4, lodash@^4.3.0:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"

Expand Down Expand Up @@ -1900,6 +1872,10 @@ natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"

node-fetch@^2.0.0-alpha.8:
version "2.0.0-alpha.9"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.0.0-alpha.9.tgz#990c0634f510f76449a0d6f6eaec96b22f273628"

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down Expand Up @@ -2218,6 +2194,14 @@ qs@~6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"

r2@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/r2/-/r2-2.0.0.tgz#fadc6558ac96f230d3dfa5bc039f0f97771968d9"
dependencies:
caseless "^0.12.0"
node-fetch "^2.0.0-alpha.8"
typedarray-to-buffer "^3.1.2"

randomatic@^1.1.3:
version "1.1.7"
resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c"
Expand Down Expand Up @@ -2304,21 +2288,6 @@ repeating@^2.0.0:
dependencies:
is-finite "^1.0.0"

[email protected]:
version "1.1.1"
resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.1.tgz#3eee00b2c5aa83239cfb04c5700da36f81cd08b6"
dependencies:
lodash "^4.13.1"

request-promise@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/request-promise/-/request-promise-4.2.2.tgz#d1ea46d654a6ee4f8ee6a4fea1018c22911904b4"
dependencies:
bluebird "^3.5.0"
request-promise-core "1.1.1"
stealthy-require "^1.1.0"
tough-cookie ">=2.3.3"

[email protected]:
version "2.81.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0"
Expand Down Expand Up @@ -2562,10 +2531,6 @@ sshpk@^1.7.0:
jsbn "~0.1.0"
tweetnacl "~0.14.0"

stealthy-require@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"

stream-buffers@~2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4"
Expand Down Expand Up @@ -2705,7 +2670,7 @@ to-fast-properties@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47"

tough-cookie@>=2.3.3, tough-cookie@^2.3.2, tough-cookie@~2.3.0, tough-cookie@~2.3.3:
tough-cookie@^2.3.2, tough-cookie@~2.3.0, tough-cookie@~2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.3.tgz#0b618a5565b6dea90bf3425d04d55edc475a7561"
dependencies:
Expand Down Expand Up @@ -2814,6 +2779,12 @@ type-check@~0.3.2:
dependencies:
prelude-ls "~1.1.2"

typedarray-to-buffer@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.2.tgz#1017b32d984ff556eba100f501589aba1ace2e04"
dependencies:
is-typedarray "^1.0.0"

typescript@^2.6.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.1.tgz#ef39cdea27abac0b500242d6726ab90e0c846631"
Expand Down

0 comments on commit f7648e5

Please sign in to comment.