diff --git a/apps/cli/src/commands/update.command.ts b/apps/cli/src/commands/update.command.ts index 58c5a2a2234..185b272d480 100644 --- a/apps/cli/src/commands/update.command.ts +++ b/apps/cli/src/commands/update.command.ts @@ -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 { - 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); } diff --git a/apps/cli/src/program.ts b/apps/cli/src/program.ts index 79512d3fe5b..01844986834 100644 --- a/apps/cli/src/program.ts +++ b/apps/cli/src/program.ts @@ -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); });