fix(ssh): modernize filesystem handling and package exports for NodeNext compatibility
This commit is contained in:
@@ -7,20 +7,16 @@ export class SshKey {
|
||||
private _hostVar: string;
|
||||
private _authorized: boolean;
|
||||
|
||||
private _smarthshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
});
|
||||
|
||||
/**
|
||||
* the constructor for class SshKey
|
||||
*/
|
||||
constructor(
|
||||
optionsArg: { private?: string; public?: string; host?: string; authorized?: boolean } = {}
|
||||
) {
|
||||
this._privKey = optionsArg.private;
|
||||
this._pubKey = optionsArg.public;
|
||||
this._hostVar = optionsArg.host;
|
||||
this._authorized = optionsArg.authorized;
|
||||
this._privKey = optionsArg.private ?? '';
|
||||
this._pubKey = optionsArg.public ?? '';
|
||||
this._hostVar = optionsArg.host ?? '';
|
||||
this._authorized = optionsArg.authorized ?? false;
|
||||
}
|
||||
|
||||
// this.host
|
||||
@@ -87,20 +83,20 @@ export class SshKey {
|
||||
}
|
||||
|
||||
// methods
|
||||
read(filePathArg) {}
|
||||
read(filePathArg: string) {}
|
||||
|
||||
async store(dirPathArg: string) {
|
||||
plugins.fs.ensureDirSync(dirPathArg);
|
||||
let fileNameBase = this.host;
|
||||
if (this._privKey) {
|
||||
let filePath = plugins.path.join(dirPathArg, fileNameBase);
|
||||
plugins.smartfile.memory.toFsSync(this._privKey, filePath);
|
||||
await this._smarthshellInstance.exec(`chmod 0600 ${filePath}`);
|
||||
plugins.fs.writeFileSync(filePath, this._privKey);
|
||||
plugins.fs.chmodSync(filePath, 0o600);
|
||||
}
|
||||
if (this._pubKey) {
|
||||
let filePath = plugins.path.join(dirPathArg, fileNameBase + '.pub');
|
||||
plugins.smartfile.memory.toFsSync(this._pubKey, filePath);
|
||||
await this._smarthshellInstance.exec(`chmod 0600 ${filePath}`);
|
||||
plugins.fs.writeFileSync(filePath, this._pubKey);
|
||||
plugins.fs.chmodSync(filePath, 0o600);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user