1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 21:33:27 +00:00

Add support for using a proxy when running bw update (#7347)

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Daniel James Smith
2024-12-10 15:36:14 +01:00
committed by GitHub
parent 2fd2d2759d
commit 99008267e6
2 changed files with 10 additions and 5 deletions

View File

@@ -1,7 +1,6 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as fetch from "node-fetch";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Response } from "../models/response";
@@ -14,12 +13,15 @@ const UPDATE_COMMAND = "npm install -g @bitwarden/cli";
export class UpdateCommand {
inPkg = false;
constructor(private platformUtilsService: PlatformUtilsService) {
constructor(
private platformUtilsService: PlatformUtilsService,
protected apiService: ApiService,
) {
this.inPkg = !!(process as any).pkg;
}
async run(): Promise<Response> {
const response = await fetch.default(CLIENTS_RELEASE_LIST_ENDPOINT);
const response = await this.apiService.nativeFetch(new Request(CLIENTS_RELEASE_LIST_ENDPOINT));
if (response.status !== 200) {
return Response.error("Error contacting update API: " + response.status);
}

View File

@@ -428,7 +428,10 @@ export class Program extends BaseProgram {
writeLn("", true);
})
.action(async () => {
const command = new UpdateCommand(this.serviceContainer.platformUtilsService);
const command = new UpdateCommand(
this.serviceContainer.platformUtilsService,
this.serviceContainer.apiService,
);
const response = await command.run();
this.processResponse(response);
});