UNPKG

s-bit-agent

Version:

s.BitAgent is a simple Bitwarden CLI wrapper which provides a SSH2 Key Agent solution for Bitwarden.

96 lines 4.14 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SetupCommand = void 0; const nest_commander_1 = require("nest-commander"); const autostart_service_1 = require("../autostart/autostart.service"); const log_service_1 = require("../shared/log.service"); let SetupCommand = class SetupCommand extends nest_commander_1.CommandRunner { constructor(logService, autostartService) { super(); this.logService = logService; this.autostartService = autostartService; } async parseType(value) { return value; } async parseUninstall() { return true; } async parseArgs(value) { return value; } async run(params, options) { const available = await this.autostartService.getAvailableServices(); if (available.length === 0) this.logService.fatal([ 'Your system does not support any autostart services,', 'you will need to manually register a autostart for the daemon command', ].join(' ')); if (!options.type) { this.logService.log('Available services:'); for (const service of available) { this.logService.log(`- ${service.name}: ${service.constructor.name}`); } this.logService.fatal('Please specify a service type'); } const option = available.find((x) => x.constructor.name === options.type); if (!option) { this.logService.fatal('Invalid service type'); } if (options.uninstall) { await this.autostartService.uninstall(option); this.logService.log('Service uninstalled'); return process.exit(0); } const executable = process.argv[1]; const command = `${executable} daemon ${options.args}`; await this.autostartService.install(command, option); this.logService.log('Service installed'); } }; exports.SetupCommand = SetupCommand; __decorate([ (0, nest_commander_1.Option)({ flags: '-t, --type <type>', description: 'The type of autostart service to use.', }), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], SetupCommand.prototype, "parseType", null); __decorate([ (0, nest_commander_1.Option)({ flags: '-u, --uninstall', description: 'Uninstall the daemon service.', }), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], SetupCommand.prototype, "parseUninstall", null); __decorate([ (0, nest_commander_1.Option)({ flags: '--args <args>', description: 'Additional arguments to pass to the daemon service.', }), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], SetupCommand.prototype, "parseArgs", null); exports.SetupCommand = SetupCommand = __decorate([ (0, nest_commander_1.Command)({ name: 'setup', description: 'Install the daemon service to run in the background on system startup.', }), __metadata("design:paramtypes", [log_service_1.LogService, autostart_service_1.AutostartService]) ], SetupCommand); //# sourceMappingURL=setup.command.js.map