mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +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:
committed by
GitHub
parent
2fd2d2759d
commit
99008267e6
@@ -1,7 +1,6 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
// FIXME: Update this file to be type safe and remove this and next line
|
||||||
// @ts-strict-ignore
|
// @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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
|
|
||||||
import { Response } from "../models/response";
|
import { Response } from "../models/response";
|
||||||
@@ -14,12 +13,15 @@ const UPDATE_COMMAND = "npm install -g @bitwarden/cli";
|
|||||||
export class UpdateCommand {
|
export class UpdateCommand {
|
||||||
inPkg = false;
|
inPkg = false;
|
||||||
|
|
||||||
constructor(private platformUtilsService: PlatformUtilsService) {
|
constructor(
|
||||||
|
private platformUtilsService: PlatformUtilsService,
|
||||||
|
protected apiService: ApiService,
|
||||||
|
) {
|
||||||
this.inPkg = !!(process as any).pkg;
|
this.inPkg = !!(process as any).pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(): Promise<Response> {
|
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) {
|
if (response.status !== 200) {
|
||||||
return Response.error("Error contacting update API: " + response.status);
|
return Response.error("Error contacting update API: " + response.status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -428,7 +428,10 @@ export class Program extends BaseProgram {
|
|||||||
writeLn("", true);
|
writeLn("", true);
|
||||||
})
|
})
|
||||||
.action(async () => {
|
.action(async () => {
|
||||||
const command = new UpdateCommand(this.serviceContainer.platformUtilsService);
|
const command = new UpdateCommand(
|
||||||
|
this.serviceContainer.platformUtilsService,
|
||||||
|
this.serviceContainer.apiService,
|
||||||
|
);
|
||||||
const response = await command.run();
|
const response = await command.run();
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user