Skip to content

Commit

Permalink
[ACS-5271] - replace deprecated 'request' library (#8916)
Browse files Browse the repository at this point in the history
* [ACS-5271] - replace deprecated 'request' library
  • Loading branch information
dominikiwanekhyland authored Sep 19, 2023
1 parent 9ca7dbd commit 16ab6e3
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 61 deletions.
26 changes: 19 additions & 7 deletions lib/cli/scripts/init-aae-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import program from 'commander';
import request = require('request');
import https from 'https';
import * as fs from 'fs';
import { logger } from './logger';
import { AlfrescoApi, AlfrescoApiConfig } from '@alfresco/js-api';
Expand Down Expand Up @@ -543,16 +543,28 @@ function findFailingApps(deployedApps: any[]) {

async function getFileFromRemote(url: string, name: string) {
return new Promise<void>((resolve, reject) => {
request(url)
.pipe(fs.createWriteStream(`${name}.zip`))
.on('finish', () => {
https.get(url, (response) => {
if (response.statusCode !== 200) {
reject(new Error(`HTTP error! Status: ${response.statusCode}`));
return;
}

const outputFile = fs.createWriteStream(`${name}.zip`);
response.pipe(outputFile);

outputFile.on('finish', () => {
logger.info(`The file is finished downloading.`);
resolve();
})
.on('error', (error: any) => {
logger.error(`Not possible to download the project form remote`);
});

outputFile.on('error', (error) => {
logger.error(`Not possible to download the project from remote`);
reject(error);
});
}).on('error', (error) => {
logger.error(`Failed to fetch file from remote: ${error.message}`);
reject(error);
});
});
}

Expand Down
150 changes: 97 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
"@types/minimatch": "^3.0.3",
"@types/node": "18.0.0",
"@types/pdfjs-dist": "^2.10.378",
"@types/request": "^2.48.5",
"@types/selenium-webdriver": "^4.0.11",
"@typescript-eslint/eslint-plugin": "5.59.8",
"@typescript-eslint/parser": "5.62.0",
Expand Down

0 comments on commit 16ab6e3

Please sign in to comment.