update structure
This commit is contained in:
		
							
								
								
									
										4
									
								
								dist/smartssh.classes.sshdir.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								dist/smartssh.classes.sshdir.d.ts
									
									
									
									
										vendored
									
									
								
							| @@ -5,7 +5,7 @@ export declare class SshDir { | ||||
|     path: string; | ||||
|     sshInstance: SshInstance; | ||||
|     constructor(sshInstanceArg: SshInstance, sshDirPathArg?: string); | ||||
|     syncToDir(): void; | ||||
|     syncFromDir(): void; | ||||
|     writeToDir(): void; | ||||
|     readFromDir(): void; | ||||
|     getKeys(): SshKey[]; | ||||
| } | ||||
|   | ||||
							
								
								
									
										6
									
								
								dist/smartssh.classes.sshdir.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								dist/smartssh.classes.sshdir.js
									
									
									
									
										vendored
									
									
								
							| @@ -13,10 +13,10 @@ var SshDir = (function () { | ||||
|         } | ||||
|         this.path = sshDirPath; | ||||
|     } | ||||
|     SshDir.prototype.syncToDir = function () { | ||||
|     SshDir.prototype.writeToDir = function () { | ||||
|     }; | ||||
|     ; | ||||
|     SshDir.prototype.syncFromDir = function () { | ||||
|     SshDir.prototype.readFromDir = function () { | ||||
|     }; | ||||
|     SshDir.prototype.getKeys = function () { | ||||
|         return helpers.sshKeyArrayFromDir(this.path); | ||||
| @@ -25,4 +25,4 @@ var SshDir = (function () { | ||||
| }()); | ||||
| exports.SshDir = SshDir; | ||||
|  | ||||
| //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuc3NoZGlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsSUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUM5QyxJQUFZLE9BQU8sV0FBTSw0QkFBNEIsQ0FBQyxDQUFBO0FBSX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zaEtleUFycmF5RnJvbURpcih0aGlzLnBhdGgpO1xuICAgIH1cbn0iXX0= | ||||
|   | ||||
							
								
								
									
										24
									
								
								dist/smartssh.classes.sshinstance.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								dist/smartssh.classes.sshinstance.d.ts
									
									
									
									
										vendored
									
									
								
							| @@ -1,10 +1,11 @@ | ||||
| import "typings-global"; | ||||
| import { SshDir } from "./smartssh.classes.sshdir"; | ||||
| import { SshKey } from "./smartssh.classes.sshkey"; | ||||
| export declare class SshInstance { | ||||
|     private sshConfig; | ||||
|     private sshDir; | ||||
|     private _sshConfig; | ||||
|     sshDir: SshDir; | ||||
|     protected sshKeyArray: SshKey[]; | ||||
|     private sshSync; | ||||
|     private _sshSync; | ||||
|     constructor(optionsArg?: { | ||||
|         sshDirPath?: string; | ||||
|         sshSync?: boolean; | ||||
| @@ -14,5 +15,20 @@ export declare class SshInstance { | ||||
|     replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void; | ||||
|     getKey(hostArg: string): SshKey; | ||||
|     sshKeys: SshKey[]; | ||||
|     sync(directionArg: string): void; | ||||
|     /** | ||||
|      * write SshInstance to disk | ||||
|      */ | ||||
|     writeToDisk(): void; | ||||
|     /** | ||||
|      * read ab SshInstance from disk | ||||
|      */ | ||||
|     readFromDisk(): void; | ||||
|     /** | ||||
|      * method to invoke SshInstance _sync automatically when sshSync is true | ||||
|      */ | ||||
|     private _syncAuto(directionArg); | ||||
|     /** | ||||
|      * private method to sync SshInstance | ||||
|      */ | ||||
|     private _sync(directionArg); | ||||
| } | ||||
|   | ||||
							
								
								
									
										58
									
								
								dist/smartssh.classes.sshinstance.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										58
									
								
								dist/smartssh.classes.sshinstance.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -23,11 +23,11 @@ | ||||
|   }, | ||||
|   "homepage": "https://gitlab.com/pushrocks/smartssh#readme", | ||||
|   "dependencies": { | ||||
|     "beautylog": "^5.0.10", | ||||
|     "beautylog": "^5.0.12", | ||||
|     "fs-extra": "^0.30.0", | ||||
|     "js-base64": "^2.1.9", | ||||
|     "minimatch": "^3.0.0", | ||||
|     "smartfile": "^3.0.10", | ||||
|     "minimatch": "^3.0.2", | ||||
|     "smartfile": "^4.0.4", | ||||
|     "smartpath": "^3.2.2", | ||||
|     "typings-global": "^1.0.3", | ||||
|     "typings-test": "^1.0.1" | ||||
|   | ||||
| @@ -16,10 +16,10 @@ export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE | ||||
|         } | ||||
|         this.path = sshDirPath; | ||||
|     } | ||||
|     syncToDir(){ // syncs sshInstance to directory | ||||
|     writeToDir(){ // syncs sshInstance to directory | ||||
|          | ||||
|     }; | ||||
|     syncFromDir(){ // syncs sshInstance from directory | ||||
|     readFromDir(){ // syncs sshInstance from directory | ||||
|          | ||||
|     } | ||||
|     getKeys(){ | ||||
|   | ||||
| @@ -7,41 +7,41 @@ import {SshConfig} from "./smartssh.classes.sshconfig"; | ||||
| import {SshKey} from "./smartssh.classes.sshkey"; | ||||
|  | ||||
| export class SshInstance { | ||||
|     private sshConfig:SshConfig; // sshConfig (e.g. represents ~/.ssh/config) | ||||
|     private sshDir:SshDir; // points to sshDir class instance. | ||||
|     private _sshConfig:SshConfig; // sshConfig (e.g. represents ~/.ssh/config) | ||||
|     sshDir:SshDir; // points to sshDir class instance. | ||||
|     protected 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:{sshDirPath?:string,sshSync?:boolean}={}){ | ||||
|         optionsArg ? void(0) : optionsArg = {}; | ||||
|         this.sshDir = new SshDir(this,optionsArg.sshDirPath); | ||||
|         this.sshKeyArray = []; | ||||
|         this.sshSync = optionsArg.sshSync; | ||||
|         this._sshSync = optionsArg.sshSync; | ||||
|         this.sshDir = new SshDir(this,optionsArg.sshDirPath); | ||||
|     }; | ||||
|      | ||||
|     //altering methods | ||||
|     addKey(sshKeyArg:SshKey){ | ||||
|         this.sync("from"); | ||||
|         this._syncAuto("from"); | ||||
|         this.sshKeyArray.push(sshKeyArg); | ||||
|         this.sync("to"); | ||||
|         this._syncAuto("to"); | ||||
|     }; | ||||
|     removeKey(sshKeyArg:SshKey){ | ||||
|         this.sync("from"); | ||||
|         this._syncAuto("from"); | ||||
|         let filteredArray = this.sshKeyArray.filter((sshKeyArg2:SshKey) => { | ||||
|             return (sshKeyArg != sshKeyArg2); | ||||
|         }); | ||||
|         this.sshKeyArray = filteredArray; | ||||
|         this.sync("to"); | ||||
|         this._syncAuto("to"); | ||||
|     }; | ||||
|     replaceKey(sshKeyOldArg:SshKey,sshKeyNewArg:SshKey){ | ||||
|         this.sync("from"); | ||||
|         this._syncAuto("from"); | ||||
|         this.removeKey(sshKeyOldArg); | ||||
|         this.addKey(sshKeyNewArg); | ||||
|         this.sync("to"); | ||||
|         this._syncAuto("to"); | ||||
|     }; | ||||
|      | ||||
|     // | ||||
|     getKey(hostArg:string):SshKey{ | ||||
|         this.sync("from"); | ||||
|         this._syncAuto("from"); | ||||
|         let filteredArray = this.sshKeyArray.filter(function(keyArg){ | ||||
|             return (keyArg.host == hostArg); | ||||
|         }); | ||||
| @@ -52,15 +52,42 @@ export class SshInstance { | ||||
|         } | ||||
|     }; | ||||
|     get sshKeys():SshKey[] { | ||||
|         this.sync("from"); | ||||
|         this._syncAuto("from"); | ||||
|         return this.sshKeyArray; | ||||
|     }; | ||||
|  | ||||
|     //FS methods | ||||
|  | ||||
|     /** | ||||
|      * write SshInstance to disk | ||||
|      */ | ||||
|     writeToDisk(){ | ||||
|         this._sync("to"); | ||||
|     } | ||||
|     sync(directionArg:string){ | ||||
|         if(this.sshSync && directionArg == "from"){ | ||||
|             this.sshDir.syncFromDir(); // call sync method of sshDir class; | ||||
|         } else if(this.sshSync && directionArg == "to") { | ||||
|             this.sshDir.syncToDir(); | ||||
|         } else if(this.sshSync) { | ||||
|  | ||||
|     /** | ||||
|      * read ab SshInstance from disk | ||||
|      */ | ||||
|     readFromDisk(){ | ||||
|         this._sync("from"); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * method to invoke SshInstance _sync automatically when sshSync is true | ||||
|      */ | ||||
|     private _syncAuto(directionArg){ | ||||
|         if(this._sshSync) this._sync(directionArg); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * private method to sync SshInstance | ||||
|      */ | ||||
|     private _sync(directionArg:string){ | ||||
|         if(directionArg == "from"){ | ||||
|             this.sshDir.readFromDir(); // call sync method of sshDir class; | ||||
|         } else if(directionArg == "to") { | ||||
|             this.sshDir.writeToDir(); | ||||
|         } else { | ||||
|             throw new Error("directionArg not recognised. Must be 'to' or 'from'"); | ||||
|         } | ||||
|     }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user