This commit is contained in:
Philipp Kunz 2016-09-24 21:49:53 +02:00
parent b1f8c79b8d
commit 513bb686ef
4 changed files with 51 additions and 50 deletions

View File

@ -1,18 +0,0 @@
export declare type keyValueStoreTypes = 'path' | 'gitProject';
export declare class KeyValueStore {
constructor(optionsArg: {
type: keyValueStoreTypes;
});
/**
* reads a keyValueFile from disk
*/
kvRead(): void;
/**
* writes a key value file to disk
*/
kvWrite(): void;
/**
* wipes a key value store from disk
*/
kevWipe(): void;
}

View File

@ -1,22 +0,0 @@
"use strict";
class KeyValueStore {
constructor(optionsArg) {
}
/**
* reads a keyValueFile from disk
*/
kvRead() {
}
/**
* writes a key value file to disk
*/
kvWrite() {
}
/**
* wipes a key value store from disk
*/
kevWipe() {
}
}
exports.KeyValueStore = KeyValueStore;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEuY2xhc3Nlcy5rZXl2YWx1ZXN0b3JlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZXh0cmEuY2xhc3Nlcy5rZXl2YWx1ZXN0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFLQTtJQUNJLFlBQVksVUFFWDtJQUVELENBQUM7SUFDRDs7R0FFRDtJQUNDLE1BQU07SUFFTixDQUFDO0lBRUQ7O09BRUc7SUFDSCxPQUFPO0lBRVAsQ0FBQztJQUVEOztPQUVHO0lBQ0gsT0FBTztJQUVQLENBQUM7Q0FDSjtBQTFCRCxzQ0EwQkMifQ==

View File

@ -1,32 +1,67 @@
import * as plugins from './npmextra.plugins'
import * as paths from './npmextra.paths'
export type keyValueStoreTypes = 'path' | 'gitProject'
export type keyValueStoreTypes = 'path' | 'gitProject' | 'customString'
export class KeyValueStore {
constructor(optionsArg: {
type: keyValueStoreTypes
}) {
type: string // the type of the kvStore
identity: string // the identity of the kvStore
filePath: string // the filePath of the kvStore
constructor(typeArg: keyValueStoreTypes, identityStringArg?: string) {
// set kvStoreType
this.type = typeArg
this.initIdentity(identityStringArg)
this.initFilePath()
}
/**
* reads a keyValueFile from disk
*/
kvRead() {
read() {
}
/**
* writes a key value file to disk
*/
kvWrite() {
write() {
}
/**
* wipes a key value store from disk
*/
kevWipe() {
wipe() {
}
/**
* updates a value
*/
update() {
}
/**
* computes the identity
*/
private initIdentity(identityStringArg: string){
}
/**
* computes the filePath
*/
private initFilePath() {
let baseDir: string
if (this.type === 'customString') {
baseDir = paths.kvCusomDir
} else if (this.type === 'gitProject') {
baseDir = paths.kvGitDir
} else if (this.type === 'path') {
baseDir = paths.kvPathDir
}
this.filePath = plugins.path.join(baseDir, this.identity + '.json')
}
}

View File

@ -4,5 +4,11 @@ import * as plugins from './npmextra.plugins'
export let cwd = process.cwd()
export let packageDir = plugins.path.join(__dirname,'../')
// keyValueStore specific
export let kvBase = '~/.npmextra/kv'
export let kvCusomDir = plugins.path.join(kvBase, 'custom')
export let kvGitDir = plugins.path.join(kvBase, 'git')
export let kvPathDir = plugins.path.join(kvBase, 'path')
// files
export let configFile = plugins.path.join(cwd,'npmextra.json')