Skip to content

Commit

Permalink
[ACS-6019] [ACS-6021] [ACS-6023] Replaced request with node-fetch (#8999
Browse files Browse the repository at this point in the history
)

* [ACS-6019] Replaced request with node-fetch

* [ACS-6019] [Non-Functional Change] Added documentation to peopleSelected event emitter - Change to trigger affected E2Es

* [ACS-6019] Added return type to getFileFromRemote function. Removed request dependencies from package.json

* [ACS-6019] Commit package-lock.json

* [ACS-6019] Testing node-fetch v2

* [ACS-6019] Commiting package-lock.json
  • Loading branch information
swapnil-verma-gl authored Oct 17, 2023
1 parent 82fafff commit ef285a1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 52 deletions.
29 changes: 20 additions & 9 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 fetch from 'node-fetch';
import * as fs from 'fs';
import { logger } from './logger';
import { AlfrescoApi, AlfrescoApiConfig } from '@alfresco/js-api';
Expand Down Expand Up @@ -664,19 +664,30 @@ function findFailingApps(deployedApps: any[]): any[] {
* @param url url to file
* @param name name
*/
async function getFileFromRemote(url: string, name: string) {
return new Promise<void>((resolve, reject) => {
request(url)
.pipe(fs.createWriteStream(`${name}.zip`))
.on('finish', () => {
async function getFileFromRemote(url: string, name: string): Promise<void> {
return fetch(url)
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response;
})
.then((response) => new Promise<void>((resolve, reject) => {
const outputFile = fs.createWriteStream(`${name}.zip`);
response.body.pipe(outputFile);
outputFile.on('finish', () => {
logger.info(`The file is finished downloading.`);
resolve();
})
.on('error', (error: any) => {
});
outputFile.on('error', (error) => {
logger.error(`Not possible to download the project form remote`);
reject(error);
});
});
}))
.catch((error) => {
logger.error(`Failed to fetch file from remote: ${error.message}`);
throw error;
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
@ViewChild('inputValue', { static: true })
input: ElementRef;

/** Emitted when a valid user has been highlighted */
@Output()
peopleSelected: EventEmitter<number> = new EventEmitter();

Expand Down
Loading

0 comments on commit ef285a1

Please sign in to comment.