application data directory
This commit is contained in:
parent
70c7b182ae
commit
ad2fa7efbb
|
@ -2,7 +2,6 @@ import * as program from 'commander';
|
||||||
|
|
||||||
import { AuthService } from 'jslib/services/auth.service';
|
import { AuthService } from 'jslib/services/auth.service';
|
||||||
|
|
||||||
|
|
||||||
import { LoginCommand } from './commands/login.command';
|
import { LoginCommand } from './commands/login.command';
|
||||||
|
|
||||||
import { CryptoService } from 'jslib/services/crypto.service';
|
import { CryptoService } from 'jslib/services/crypto.service';
|
||||||
|
@ -19,13 +18,12 @@ import { NodeMessagingService } from './services/nodeMessaging.service';
|
||||||
|
|
||||||
const platformUtilsService = new NodePlatformUtilsService();
|
const platformUtilsService = new NodePlatformUtilsService();
|
||||||
const cryptoFunctionService = new NodeCryptoFunctionService();
|
const cryptoFunctionService = new NodeCryptoFunctionService();
|
||||||
const storageService = new NodeStorageService('./scratch');
|
const storageService = new NodeStorageService('Bitwarden CLI');
|
||||||
const cryptoService = new CryptoService(storageService, storageService, cryptoFunctionService);
|
const cryptoService = new CryptoService(storageService, storageService, cryptoFunctionService);
|
||||||
const appIdService = new AppIdService(storageService);
|
const appIdService = new AppIdService(storageService);
|
||||||
const tokenService = new TokenService(storageService);
|
const tokenService = new TokenService(storageService);
|
||||||
const messagingService = new NodeMessagingService();
|
const messagingService = new NodeMessagingService();
|
||||||
const apiService = new ApiService(tokenService, platformUtilsService,
|
const apiService = new ApiService(tokenService, platformUtilsService, (expired: boolean) => { });
|
||||||
(expired: boolean) => { });
|
|
||||||
const environmentService = new EnvironmentService(apiService, storageService);
|
const environmentService = new EnvironmentService(apiService, storageService);
|
||||||
const userService = new UserService(tokenService, storageService);
|
const userService = new UserService(tokenService, storageService);
|
||||||
const containerService = new ContainerService(cryptoService, platformUtilsService);
|
const containerService = new ContainerService(cryptoService, platformUtilsService);
|
||||||
|
|
|
@ -4,10 +4,19 @@ import { Utils } from 'jslib/misc/utils';
|
||||||
let localStorage = Utils.isBrowser ? window.localStorage : null;
|
let localStorage = Utils.isBrowser ? window.localStorage : null;
|
||||||
|
|
||||||
export class NodeStorageService implements StorageService {
|
export class NodeStorageService implements StorageService {
|
||||||
constructor(dirLocation: string) {
|
constructor(appDirName: string) {
|
||||||
if (Utils.isNode && localStorage == null) {
|
if (Utils.isNode && localStorage == null) {
|
||||||
const LocalStorage = require('node-localstorage').LocalStorage;
|
const LocalStorage = require('node-localstorage').LocalStorage;
|
||||||
localStorage = new LocalStorage(dirLocation);
|
let path = null;
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
path = process.env.HOME + 'Library/Application Support';
|
||||||
|
} else if (process.platform === 'win32') {
|
||||||
|
path = process.env.APPDATA;
|
||||||
|
} else {
|
||||||
|
path = process.env.HOME + '.config';
|
||||||
|
}
|
||||||
|
path += ('/' + appDirName + '/data');
|
||||||
|
localStorage = new LocalStorage(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue