Skip to content

Commit

Permalink
fix build in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanfbrito committed Oct 23, 2023
1 parent 899caa6 commit 03f711a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/servers/supportedVersions/downloadFromCloud.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
import fs from 'fs';
import path from 'path';

import type { AxiosResponse } from 'axios';
import axios from 'axios';

const apiUrl =
'https://releases.rocket.chat/v2/server/supportedVersions?source=desktop';
const outputFilePath = './app/supportedVersions.jwt';
const outputFilePath = path.join('.', 'app', 'supportedVersions.jwt');

interface SupportedVersionsResponse {
signed?: string;
}

export async function downloadAndSaveSupportedVersionsFromCloud(): Promise<void> {
console.log('Getting Supported Versions from Cloud...');

try {
const response: AxiosResponse<SupportedVersionsResponse> = await axios.get(
apiUrl
);

if (response.status === 200) {
const jsonData: SupportedVersionsResponse = response.data;

if (jsonData && jsonData.signed) {
const signedContent: string = jsonData.signed;
const directory = path.dirname(outputFilePath);
if (!fs.existsSync(directory)) {
fs.mkdirSync(directory, { recursive: true });
}

fs.writeFileSync(outputFilePath, signedContent);
console.log('Signed content saved successfully.');
Expand All @@ -35,7 +40,10 @@ export async function downloadAndSaveSupportedVersionsFromCloud(): Promise<void>
console.error('Failed to retrieve data from Cloud.');
}
} catch (error: any) {
console.error('Error getting the Supported Versions from Cloud:', error);
console.error(
'Error getting the Supported Versions from Cloud:',
error.message
);
}
}

Expand Down

0 comments on commit 03f711a

Please sign in to comment.