mirror of
https://github.com/bitwarden/clients.git
synced 2026-07-13 21:19:12 +08:00
* Rename service-factory folder
* Move cryptographic service factories
* Move crypto models
* Move crypto services
* Move domain base class
* Platform code owners
* Move desktop log services
* Move log files
* Establish component library ownership
* Move background listeners
* Move background background
* Move localization to Platform
* Move browser alarms to Platform
* Move browser state to Platform
* Move CLI state to Platform
* Move Desktop native concerns to Platform
* Move flag and misc to Platform
* Lint fixes
* Move electron state to platform
* Move web state to Platform
* Move lib state to Platform
* Fix broken tests
* Rename interface to idiomatic TS
* `npm run prettier` 🤖
* Resolve review feedback
* Set platform as owners of web core and shared
* Expand moved services
* Fix test types
---------
Co-authored-by: Hinton <hinton@users.noreply.github.com>
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import * as program from "commander";
|
|
|
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
|
|
|
import { Response } from "../models/response";
|
|
import { MessageResponse } from "../models/response/message.response";
|
|
import { StringResponse } from "../models/response/string.response";
|
|
|
|
export class ConfigCommand {
|
|
constructor(private environmentService: EnvironmentService) {}
|
|
|
|
async run(setting: string, value: string, options: program.OptionValues): Promise<Response> {
|
|
setting = setting.toLowerCase();
|
|
switch (setting) {
|
|
case "server":
|
|
return await this.getOrSetServer(value, options);
|
|
default:
|
|
return Response.badRequest("Unknown setting.");
|
|
}
|
|
}
|
|
|
|
private async getOrSetServer(url: string, options: program.OptionValues): Promise<Response> {
|
|
if (
|
|
(url == null || url.trim() === "") &&
|
|
!options.webVault &&
|
|
!options.api &&
|
|
!options.identity &&
|
|
!options.icons &&
|
|
!options.notifications &&
|
|
!options.events
|
|
) {
|
|
const stringRes = new StringResponse(
|
|
this.environmentService.hasBaseUrl()
|
|
? this.environmentService.getUrls().base
|
|
: "https://bitwarden.com"
|
|
);
|
|
return Response.success(stringRes);
|
|
}
|
|
|
|
url = url === "null" || url === "bitwarden.com" || url === "https://bitwarden.com" ? null : url;
|
|
await this.environmentService.setUrls({
|
|
base: url,
|
|
webVault: options.webVault || null,
|
|
api: options.api || null,
|
|
identity: options.identity || null,
|
|
icons: options.icons || null,
|
|
notifications: options.notifications || null,
|
|
events: options.events || null,
|
|
keyConnector: options.keyConnector || null,
|
|
});
|
|
const res = new MessageResponse("Saved setting `config`.", null);
|
|
return Response.success(res);
|
|
}
|
|
}
|