update directory sync
This commit is contained in:
parent
f4f60a685d
commit
09d96fd94c
5
dist/smartssh.classes.sshdir.d.ts
vendored
5
dist/smartssh.classes.sshdir.d.ts
vendored
@ -3,8 +3,9 @@ import { SshInstance } from "./smartssh.classes.sshinstance";
|
|||||||
import { SshKey } from "./smartssh.classes.sshkey";
|
import { SshKey } from "./smartssh.classes.sshkey";
|
||||||
export declare class SshDir {
|
export declare class SshDir {
|
||||||
path: string;
|
path: string;
|
||||||
constructor(sshDirPathArg: string);
|
sshInstance: SshInstance;
|
||||||
syncToDir(sshInstanceArg: SshInstance): void;
|
constructor(sshInstanceArg: SshInstance, sshDirPathArg?: string);
|
||||||
|
syncToDir(): void;
|
||||||
syncFromDir(): void;
|
syncFromDir(): void;
|
||||||
getKeys(): SshKey[];
|
getKeys(): SshKey[];
|
||||||
}
|
}
|
||||||
|
6
dist/smartssh.classes.sshdir.js
vendored
6
dist/smartssh.classes.sshdir.js
vendored
@ -3,7 +3,7 @@ require("typings-global");
|
|||||||
var plugins = require("./smartssh.plugins");
|
var plugins = require("./smartssh.plugins");
|
||||||
var helpers = require("./smartssh.classes.helpers");
|
var helpers = require("./smartssh.classes.helpers");
|
||||||
var SshDir = (function () {
|
var SshDir = (function () {
|
||||||
function SshDir(sshDirPathArg) {
|
function SshDir(sshInstanceArg, sshDirPathArg) {
|
||||||
var sshDirPath;
|
var sshDirPath;
|
||||||
if (sshDirPathArg) {
|
if (sshDirPathArg) {
|
||||||
sshDirPath = sshDirPathArg;
|
sshDirPath = sshDirPathArg;
|
||||||
@ -13,7 +13,7 @@ var SshDir = (function () {
|
|||||||
}
|
}
|
||||||
this.path = sshDirPath;
|
this.path = sshDirPath;
|
||||||
}
|
}
|
||||||
SshDir.prototype.syncToDir = function (sshInstanceArg) {
|
SshDir.prototype.syncToDir = function () {
|
||||||
};
|
};
|
||||||
;
|
;
|
||||||
SshDir.prototype.syncFromDir = function () {
|
SshDir.prototype.syncFromDir = function () {
|
||||||
@ -25,4 +25,4 @@ var SshDir = (function () {
|
|||||||
}());
|
}());
|
||||||
exports.SshDir = SshDir;
|
exports.SshDir = SshDir;
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuc3NoZGlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsSUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUM5QyxJQUFZLE9BQU8sV0FBTSw0QkFBNEIsQ0FBQyxDQUFBO0FBSXREO0lBRUksZ0JBQVksYUFBb0I7UUFDNUIsSUFBSSxVQUFpQixDQUFDO1FBQ3RCLEVBQUUsQ0FBQSxDQUFDLGFBQWEsQ0FBQyxDQUFBLENBQUM7WUFDZCxVQUFVLEdBQUcsYUFBYSxDQUFDO1FBQy9CLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLFVBQVUsR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUM5QyxDQUFDO1FBQ0QsSUFBSSxDQUFDLElBQUksR0FBRyxVQUFVLENBQUM7SUFDM0IsQ0FBQztJQUNELDBCQUFTLEdBQVQsVUFBVSxjQUEwQjtJQUVwQyxDQUFDOztJQUNELDRCQUFXLEdBQVg7SUFFQSxDQUFDO0lBQ0Qsd0JBQU8sR0FBUDtRQUNJLE1BQU0sQ0FBQyxPQUFPLENBQUMsa0JBQWtCLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ2pELENBQUM7SUFDTCxhQUFDO0FBQUQsQ0FwQkEsQUFvQkMsSUFBQTtBQXBCWSxjQUFNLFNBb0JsQixDQUFBIiwiZmlsZSI6InNtYXJ0c3NoLmNsYXNzZXMuc3NoZGlyLmpzIiwic291cmNlc0NvbnRlbn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LmdldC5ob21lKCk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMucGF0aCA9IHNzaERpclBhdGg7XHJcbiAgICB9XHJcbiAgICBzeW5jVG9EaXIoKXsgLy9zeW5jcyBcclxuICAgICAgICBcclxuICAgIH07XHJcbiAgICBzeW5jRnJvbURpcigpe1xyXG4gICAgICAgIFxyXG4gICAgfVxyXG4gICAgZ2V0S2V5cygpe1xyXG4gICAgICAgIHJldHVybiBoZWxwZXJzLnNzaEtleUFycmF5RnJvbURpcih0aGlzLnBhdGgpO1xyXG4gICAgfVxyXG59Il19
|
||||||
|
10
dist/smartssh.classes.sshinstance.d.ts
vendored
10
dist/smartssh.classes.sshinstance.d.ts
vendored
@ -3,16 +3,16 @@ import { SshKey } from "./smartssh.classes.sshkey";
|
|||||||
export declare class SshInstance {
|
export declare class SshInstance {
|
||||||
private sshConfig;
|
private sshConfig;
|
||||||
private sshDir;
|
private sshDir;
|
||||||
private sshKeys;
|
private sshKeysVar;
|
||||||
private sshSync;
|
private sshSync;
|
||||||
constructor(optionsArg?: {
|
constructor(optionsArg?: {
|
||||||
sshDir?: string;
|
sshDirPath?: string;
|
||||||
sshSync?: boolean;
|
sshSync?: boolean;
|
||||||
});
|
});
|
||||||
addKey(sshKeyArg: SshKey): void;
|
addKey(sshKeyArg: SshKey): void;
|
||||||
getKey(hostArg: string): SshKey;
|
|
||||||
getKeys(): SshKey[];
|
|
||||||
removeKey(sshKeyArg: SshKey): void;
|
removeKey(sshKeyArg: SshKey): void;
|
||||||
replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void;
|
replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void;
|
||||||
sync(): void;
|
getKey(hostArg: string): SshKey;
|
||||||
|
sshKeys: SshKey[];
|
||||||
|
sync(directionArg: string): void;
|
||||||
}
|
}
|
||||||
|
64
dist/smartssh.classes.sshinstance.js
vendored
64
dist/smartssh.classes.sshinstance.js
vendored
File diff suppressed because one or more lines are too long
@ -28,9 +28,11 @@ describe("smartssh", function () {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
it("should return an array of sshKeys", function () {
|
it("should return an array of sshKeys", function () {
|
||||||
testSshInstance.getKeys();
|
var sshKeyArray = testSshInstance.sshKeys;
|
||||||
|
sshKeyArray.should.be.Array();
|
||||||
|
sshKeyArray[0].host.should.equal("gitlab.com");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FDUCxDQUFDLENBRG9CO0FBQ3JCLFFBQU8sUUFBUSxDQUFDLENBQUE7QUFDaEIsSUFBTyxRQUFRLFdBQVcsZUFBZSxDQUFDLENBQUM7QUFDM0MsUUFBUSxDQUFDLFVBQVUsRUFBQztJQUNoQixJQUFJLGVBQW9DLENBQUM7SUFDekMsSUFBSSxVQUEwQixDQUFDO0lBQy9CLFFBQVEsQ0FBQyxhQUFhLEVBQUM7UUFDbkIsRUFBRSxDQUFDLG1EQUFtRCxFQUFDO1lBQ25ELGVBQWUsR0FBRyxJQUFJLFFBQVEsQ0FBQyxXQUFXLEVBQUUsQ0FBQztZQUM3QyxlQUFlLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsUUFBUSxDQUFDLFdBQVcsQ0FBQyxDQUFDO1FBQy9ELENBQUMsQ0FBQyxDQUFDO1FBQ0gsRUFBRSxDQUFDLG1DQUFtQyxFQUFDO1lBQ25DLGVBQWUsQ0FBQyxNQUFNLENBQUMsSUFBSSxRQUFRLENBQUMsTUFBTSxDQUFDO2dCQUN2QyxNQUFNLEVBQUMsZUFBZTtnQkFDdEIsT0FBTyxFQUFDLGdCQUFnQjtnQkFDeEIsSUFBSSxFQUFDLFlBQVk7YUFDcEIsQ0FBQ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m9tIGNsYXNzXCIsZnVuY3Rpb24oKXtcclxuICAgICAgICAgICAgdGVzdFNzaEluc3RhbmNlID0gbmV3IHNtYXJ0c3NoLlNzaEluc3RhbmNlKCk7XHJcbiAgICAgICAgICAgIHRlc3RTc2hJbnN0YW5jZS5zaG91bGQuYmUuaW5zdGFuY2VvZihzbWFydHNzaC5Tc2hJbnN0YW5jZSk7XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgaXQoXCJzaG91bGQgYWNjZXB0IGEgbmV3IFNzaEtleSBvYmplY3RcIixmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICB0ZXN0U3NoSW5zdGFuY2UuYWRkS2V5KG5ldyBzbWFydHNzaC5Tc2hLZXkoe1xyXG4gICAgICAgICAgICAgICAgcHVibGljOlwic29tZVB1YmxpY0tleVwiLFxyXG4gICAgICAgICAgICAgICAgcHJpdmF0ZTpcInNvbWVQcml2YXRlS2V5XCIsXHJcbiAgICAgICAgICAgICAgICBob3N0OlwiZ2l0bGFiLmNvbVwiXHJcbiAgICAgICAgICAgIH0pKTtcclxuICAgICAgICAgICAgdGVzdFNzaEluc3RhbmNlLmFkZEtleShuZXcgc21hcnRzc2guU3NoS2V5KHtcclxuICAgICAgICAgICAgICAgIHB1YmxpYzpcInNvbWVQdWJsaWNLZXlcIixcclxuICAgICAgICAgICAgICAgIHByaXZhdGU6XCJzb21lUHJpdmF0ZUtleVwiLFxyXG4gICAgICAgICAgICAgICAgaG9zdDpcImJpdGJ1Y2tldC5vcmdcIlxyXG4gICAgICAgICAgICB9KSk7XHJcbiAgICAgICAgICAgIHRlc3RTc2hJbnN0YW5jZS5hZGRLZXkobmV3IHNtYXJ0c3NoLlNzaEtleSh7XHJcbiAgICAgICAgICAgICAgICBwdWJsaWM6XCJzb21lUHVibGljS2V5XCIsXHJcbiAgICAgICAgICAgICAgICBwcml2YXRlOlwic29tZVByaXZhdGVLZXlcIixcclxuICAgICAgICAgICAgICAgIGhvc3Q6XCJnaXRodWIuY29tX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Tc2hLZXk7XHJcbiAgICBkZXNjcmliZShcIlNzaEluc3RhbmNlXCIsZnVuY3Rpb24oKXtcclxuICAgICAgICBpdChcInNob3VsZCBjcmVhdGUgYSBuZXcgU3NoSW5zdGFuY2Ugb2JqZWN0IGZyb20gY2xhc3NcIixmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICB0ZXN0U3NoSW5zdGFuY2UgPSBuZXcgc21hcnRzc2guU3NoSW5zdGFuY2UoKTtcclxuICAgICAgICAgICAgdGVzdFNzaEluc3RhbmNlLnNob3VsZC5iZS5pbnN0YW5jZW9mKHNtYXJ0c3NoLlNzaEluc3RhbmNlKTtcclxuICAgICAgICB9KTtcclxuICAgICAgICBpdChcInNob3VsZCBhY2NlcHQgYSBuZXcgU3NoS2V5IG9iamVjdFwiLGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIHRlc3RTc2hJbnN0YW5jZS5hZGRLZXkobmV3IHNtYXJ0c3NoLlNzaEtleSh7XHJcbiAgICAgICAgICAgICAgICBwdWJsaWM6XCJzb21lUHVibGljS2V5XCIsXHJcbiAgICAgICAgICAgICAgICBwcml2YXRlOlwic29tZVByaXZhdGVLZXlcIixcclxuICAgICAgICAgICAgICAgIGhvc3Q6XCJnaXRsYWIuY29tXCJcclxuICAgICAgICAgICAgfSkpO1xyXG4gICAgICAgICAgICB0ZXN0U3NoSW5zdGFuY2UuYWRkS2V5KG5ldyBzbWFydHNzaC5Tc2hLZXkoe1xyXG4gICAgICAgICAgICAgICAgcHVibGljOlwic29tZVB1YmxpY0tleVwiLFxyXG4gICAgICAgICAgICAgICAgcHJpdmF0ZTpcInNvbWVQcml2YXRlS2V5XCIsXHJcbiAgICAgICAgICAgICAgICBob3N0OlwiYml0YnVja2V0Lm9yZ1wiXHJcbiAgICAgICAgICAgIH0pKTtcclxuICAgICAgICAgICAgdGVzdFNzaEluc3RhbmNlLmFkZEtleShuZXcgc21hcnRzc2guU3NoS2V5KHtcclxuICAgICAgICAgICAgICAgIHB1YmxpYzpcInNvbWVQdWJsaWNLZXlcIixcclxuICAgICAgICAgICAgICAgIHByaXZhdGU6XCJzb21lUHJpdmF0ZUtleVwiLFxyXG4gICAgICAgICAgICAgICAgaG9zdDpcImdpdGh1Yi5jb21cIlxyXG4gICAgICAgICAgICB9KSk7XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgaXQoXCJzaG91bGQgcmV0dXJuIGFuIGFycmF5IG9mIHNzaEtleXNcIixmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICBsZXQgc3NoS2V5QXJyYXkgPSB0ZXN0U3NoSW5zdGFuY2Uuc3NoS2V5cztcclxuICAgICAgICAgICAgc3NoS2V5QXJyYXkuc2hvdWxkLmJlLkFycmF5KCk7XHJcbiAgICAgICAgICAgIHNzaEtleUFycmF5WzBdLmhvc3Quc2hvdWxkLmVxdWFsKFwiZ2l0bGFiLmNvbVwiKTtcclxuICAgICAgICB9KTtcclxuICAgIH0pXHJcbn0pIl19
|
||||||
|
@ -27,7 +27,9 @@ describe("smartssh",function(){
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
it("should return an array of sshKeys",function(){
|
it("should return an array of sshKeys",function(){
|
||||||
testSshInstance.getKeys();
|
let sshKeyArray = testSshInstance.sshKeys;
|
||||||
|
sshKeyArray.should.be.Array();
|
||||||
|
sshKeyArray[0].host.should.equal("gitlab.com");
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
})
|
})
|
@ -6,7 +6,8 @@ import {SshKey} from "./smartssh.classes.sshkey";
|
|||||||
import {SshConfig} from "./smartssh.classes.sshconfig";
|
import {SshConfig} from "./smartssh.classes.sshconfig";
|
||||||
export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
|
export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
|
||||||
path:string; // the path of the ssh directory
|
path:string; // the path of the ssh directory
|
||||||
constructor(sshDirPathArg:string){
|
sshInstance:SshInstance;
|
||||||
|
constructor(sshInstanceArg:SshInstance,sshDirPathArg?:string){
|
||||||
let sshDirPath:string;
|
let sshDirPath:string;
|
||||||
if(sshDirPathArg){
|
if(sshDirPathArg){
|
||||||
sshDirPath = sshDirPathArg;
|
sshDirPath = sshDirPathArg;
|
||||||
@ -15,7 +16,7 @@ export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
|
|||||||
}
|
}
|
||||||
this.path = sshDirPath;
|
this.path = sshDirPath;
|
||||||
}
|
}
|
||||||
syncToDir(sshInstanceArg:SshInstance){ //syncs
|
syncToDir(){ //syncs
|
||||||
|
|
||||||
};
|
};
|
||||||
syncFromDir(){
|
syncFromDir(){
|
||||||
|
@ -9,20 +9,39 @@ import {SshKey} from "./smartssh.classes.sshkey";
|
|||||||
export class SshInstance {
|
export class SshInstance {
|
||||||
private sshConfig:SshConfig; // sshConfig (e.g. represents ~/.ssh/config)
|
private sshConfig:SshConfig; // sshConfig (e.g. represents ~/.ssh/config)
|
||||||
private sshDir:SshDir; // points to sshDir class instance.
|
private sshDir:SshDir; // points to sshDir class instance.
|
||||||
private sshKeys:SshKey[]; //holds all ssh keys
|
private sshKeyArray:SshKey[]; //holds all ssh keys
|
||||||
private sshSync:boolean; // if set to true, the ssh dir will be kept in sync automatically
|
private sshSync:boolean; // if set to true, the ssh dir will be kept in sync automatically
|
||||||
constructor(optionsArg:{sshDir?:string,sshSync?:boolean}={}){
|
constructor(optionsArg:{sshDirPath?:string,sshSync?:boolean}={}){
|
||||||
optionsArg ? void(0) : optionsArg = {};
|
optionsArg ? void(0) : optionsArg = {};
|
||||||
this.sshDir = new SshDir(optionsArg.sshDir);
|
|
||||||
this.sshKeys = this.sshDir.getKeys();
|
this.sshDir = new SshDir(this,optionsArg.sshDirPath);
|
||||||
|
this.sshKeyArray = this.sshDir.getKeys();
|
||||||
this.sshSync = optionsArg.sshSync;
|
this.sshSync = optionsArg.sshSync;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//altering methods
|
||||||
addKey(sshKeyArg:SshKey){
|
addKey(sshKeyArg:SshKey){
|
||||||
this.sshKeys.push(sshKeyArg);
|
this.sync("from");
|
||||||
this.sync();
|
this.sshKeyArray.push(sshKeyArg);
|
||||||
|
this.sync("to");
|
||||||
};
|
};
|
||||||
|
removeKey(sshKeyArg:SshKey){
|
||||||
|
this.sync("from");
|
||||||
|
let keyIndex = helpers.getKeyIndex(sshKeyArg.host);
|
||||||
|
this.sshKeyArray.splice(keyIndex,1);
|
||||||
|
this.sync("to");
|
||||||
|
};
|
||||||
|
replaceKey(sshKeyOldArg:SshKey,sshKeyNewArg:SshKey){
|
||||||
|
this.sync("from");
|
||||||
|
let keyIndex = helpers.getKeyIndex(sshKeyOldArg.host);
|
||||||
|
this.sshKeyArray.splice(keyIndex,1,sshKeyNewArg);
|
||||||
|
this.sync("to");
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
getKey(hostArg:string){
|
getKey(hostArg:string){
|
||||||
let filteredArray = this.sshKeys.filter(function(keyArg){
|
this.sync("from");
|
||||||
|
let filteredArray = this.sshKeyArray.filter(function(keyArg){
|
||||||
return (keyArg.host == hostArg);
|
return (keyArg.host == hostArg);
|
||||||
});
|
});
|
||||||
if(filteredArray.length > 0){
|
if(filteredArray.length > 0){
|
||||||
@ -31,24 +50,16 @@ export class SshInstance {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
get sshKeys():SshKey[] {
|
||||||
getKeys(){
|
return this.sshKeyArray;
|
||||||
return this.sshKeys;
|
|
||||||
}
|
}
|
||||||
|
sync(directionArg:string){
|
||||||
removeKey(sshKeyArg:SshKey){
|
if(this.sshSync && directionArg == "from"){
|
||||||
let keyIndex = helpers.getKeyIndex(sshKeyArg.host);
|
this.sshDir.syncFromDir(); // call sync method of sshDir class;
|
||||||
this.sshKeys.splice(keyIndex,1);
|
} else if (this.sshSync && directionArg == "to") {
|
||||||
this.sync();
|
this.sshDir.syncToDir();
|
||||||
};
|
} else {
|
||||||
replaceKey(sshKeyOldArg:SshKey,sshKeyNewArg:SshKey){
|
throw new Error("directionArg not recognised. Must be 'to' or 'from'");
|
||||||
let keyIndex = helpers.getKeyIndex(sshKeyOldArg.host);
|
|
||||||
this.sshKeys.splice(keyIndex,1,sshKeyNewArg);
|
|
||||||
this.sync();
|
|
||||||
};
|
|
||||||
sync(){
|
|
||||||
if(this.sshSync){
|
|
||||||
this.sshDir.sync(this.sshConfig,this.sshKeys); // call sync method of sshDir class;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user