@@ -14,17 +14,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
15
15
const constants_1 = require ( "./constants" ) ;
16
16
const versioning_1 = require ( "./structures/versioning" ) ;
17
- const axios_1 = __importDefault ( require ( "axios" ) ) ;
17
+ const HttpClient_1 = require ( "typed-rest-client/HttpClient" ) ;
18
18
const await_to_js_1 = __importDefault ( require ( "await-to-js" ) ) ;
19
+ const client = new HttpClient_1 . HttpClient ( 'setup-sp' ) ;
19
20
function getVersions ( ) {
20
21
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
+ }
22
26
let versions = { } ;
23
27
if ( err ) {
24
28
return versions ;
25
29
}
30
+ const body = yield res . readBody ( ) ;
26
31
let match , promises = [ ] ;
27
- while ( ( match = constants_1 . MM_REGEX . exec ( res . data ) ) !== null ) {
32
+ while ( ( match = constants_1 . MM_REGEX . exec ( body ) ) !== null ) {
28
33
match [ 1 ] = match [ 1 ] . replace ( '/' , '' ) ;
29
34
if ( match [ 1 ] . length <= 0 ) {
30
35
continue ;
@@ -39,12 +44,13 @@ function getVersions() {
39
44
exports . getVersions = getVersions ;
40
45
function getBuilds ( endpoint , versions , major , minor ) {
41
46
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 ) {
44
49
throw new Error ( `Failed to pull builds from ${ endpoint } ` ) ;
45
50
}
51
+ const body = yield res . readBody ( ) ;
46
52
let match ;
47
- while ( ( match = constants_1 . BUILD_REGEX . exec ( res . data ) ) !== null ) {
53
+ while ( ( match = constants_1 . BUILD_REGEX . exec ( body ) ) !== null ) {
48
54
let platform = versioning_1 . parsePlatform ( match [ 2 ] ) ;
49
55
if ( process . platform == 'win32' && platform != versioning_1 . Platform . Windows ) {
50
56
continue ;
0 commit comments