Skip to content

Commit 27193c7

Browse files
committed
refactor(scraper): use typed rest client
Typed rest client is already available as a result of dependency of Github toolchains So instead of including additional axios, we'll use already existing lib
1 parent ab5eeee commit 27193c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+28
-7547
lines changed

lib/scraper.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1414
Object.defineProperty(exports, "__esModule", { value: true });
1515
const constants_1 = require("./constants");
1616
const versioning_1 = require("./structures/versioning");
17-
const axios_1 = __importDefault(require("axios"));
17+
const HttpClient_1 = require("typed-rest-client/HttpClient");
1818
const await_to_js_1 = __importDefault(require("await-to-js"));
19+
const client = new HttpClient_1.HttpClient('setup-sp');
1920
function getVersions() {
2021
return __awaiter(this, void 0, void 0, function* () {
21-
const [err, res] = yield await_to_js_1.default(axios_1.default.get(constants_1.ENDPOINT));
22+
const [err, res] = yield await_to_js_1.default(client.get(constants_1.ENDPOINT));
23+
if (err || !res || res.message.statusCode !== 200) {
24+
throw new Error(`Failed to pull major minor versions from ${constants_1.ENDPOINT}`);
25+
}
2226
let versions = {};
2327
if (err) {
2428
return versions;
2529
}
30+
const body = yield res.readBody();
2631
let match, promises = [];
27-
while ((match = constants_1.MM_REGEX.exec(res.data)) !== null) {
32+
while ((match = constants_1.MM_REGEX.exec(body)) !== null) {
2833
match[1] = match[1].replace('/', '');
2934
if (match[1].length <= 0) {
3035
continue;
@@ -39,12 +44,13 @@ function getVersions() {
3944
exports.getVersions = getVersions;
4045
function getBuilds(endpoint, versions, major, minor) {
4146
return __awaiter(this, void 0, void 0, function* () {
42-
const [err, res] = yield await_to_js_1.default(axios_1.default.get(endpoint));
43-
if (err) {
47+
const [err, res] = yield await_to_js_1.default(client.get(endpoint));
48+
if (err || !res || res.message.statusCode !== 200) {
4449
throw new Error(`Failed to pull builds from ${endpoint}`);
4550
}
51+
const body = yield res.readBody();
4652
let match;
47-
while ((match = constants_1.BUILD_REGEX.exec(res.data)) !== null) {
53+
while ((match = constants_1.BUILD_REGEX.exec(body)) !== null) {
4854
let platform = versioning_1.parsePlatform(match[2]);
4955
if (process.platform == 'win32' && platform != versioning_1.Platform.Windows) {
5056
continue;

node_modules/.yarn-integrity

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/axios/CHANGELOG.md

-348
This file was deleted.

node_modules/axios/LICENSE

-19
This file was deleted.

0 commit comments

Comments
 (0)