fix(ssh): modernize filesystem handling and package exports for NodeNext compatibility
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"@ship.zone/szci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmRegistryUrl": "registry.npmjs.org"
|
||||||
|
},
|
||||||
|
"@git.zone/cli": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "code.foss.global",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartssh",
|
||||||
|
"shortDescription": "SSH configuration utilities",
|
||||||
|
"description": "A library for setting up SSH configuration quickly and painlessly.",
|
||||||
|
"npmPackagename": "@push.rocks/smartssh",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"SSH",
|
||||||
|
"SSH configuration",
|
||||||
|
"SSH keys management",
|
||||||
|
"automation",
|
||||||
|
"development tools",
|
||||||
|
"node.js",
|
||||||
|
"security",
|
||||||
|
"server management"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"registries": [
|
||||||
|
"https://verdaccio.lossless.digital",
|
||||||
|
"https://registry.npmjs.org"
|
||||||
|
],
|
||||||
|
"accessLevel": "public"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@git.zone/tsdoc": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2016 Task Venture Capital GmbH
|
Copyright (c) 2026 Task Venture Capital GmbH <hello@task.vc>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-05-01 - 2.0.3 - fix(ssh)
|
||||||
|
modernize filesystem handling and package exports for NodeNext compatibility
|
||||||
|
|
||||||
|
- replace smartfile, smartpromise, and shell-based chmod usage with direct fs operations
|
||||||
|
- add package exports and tighten TypeScript settings with noImplicitAny and Node types
|
||||||
|
- update tests to the current tstest runner and move them to a node-specific entry file
|
||||||
|
- refresh package metadata and dependency versions to match the updated toolchain
|
||||||
|
|
||||||
|
## 2024-05-29 - 2.0.2 - maintenance
|
||||||
|
Release 2.0.2 focused on repository and TypeScript configuration housekeeping.
|
||||||
|
|
||||||
|
- Updated project description
|
||||||
|
- Refined TypeScript configuration
|
||||||
|
- Updated npm metadata for git host configuration
|
||||||
|
- Summarizes trivial maintenance commits across 2024-02-09 to 2024-05-29
|
||||||
|
|
||||||
|
## 2024-02-09 - 2.0.1 - core
|
||||||
|
Delivered a core update in the 2.0.1 release line.
|
||||||
|
|
||||||
|
- Updated core implementation
|
||||||
|
|
||||||
|
## 2023-07-27 - 2.0.0 - core
|
||||||
|
Delivered a core update for the 2.0.0 release.
|
||||||
|
|
||||||
|
- Updated core implementation
|
||||||
|
|
||||||
|
## 2022-10-11 - 1.2.7 - core
|
||||||
|
Introduced a breaking core change by switching the package to ESM.
|
||||||
|
|
||||||
|
- BREAKING: switched core package output to ESM
|
||||||
|
|
||||||
|
## 2022-10-11 - 1.2.4 to 1.2.6 - core
|
||||||
|
This release range contained small core maintenance updates.
|
||||||
|
|
||||||
|
- Repeated core update fixes delivered across versions 1.2.4, 1.2.5, and 1.2.6
|
||||||
|
|
||||||
|
## 2017-06-15 - 1.2.2 - maintenance
|
||||||
|
Refined project structure in the 1.2.2 release.
|
||||||
|
|
||||||
|
- Updated project structure
|
||||||
|
|
||||||
|
## 2016-11-23 - 1.2.0 to 1.2.1 - maintenance
|
||||||
|
This release range focused on standards and documentation improvements.
|
||||||
|
|
||||||
|
- Updated project to latest standards
|
||||||
|
- Improved README documentation
|
||||||
|
|
||||||
|
## 2016-06-26 - 1.1.2 to 1.1.5 - core
|
||||||
|
This release range delivered several core configuration and path-handling improvements.
|
||||||
|
|
||||||
|
- Added more flexible path handling
|
||||||
|
- Created config generation as a standard behavior
|
||||||
|
- Set rights for stored keys
|
||||||
|
- Included general maintenance and standards updates
|
||||||
|
|
||||||
|
## 2016-06-25 - 1.1.0 to 1.1.1 - core
|
||||||
|
This release range reworked the internal structure around SSH configuration and key storage.
|
||||||
|
|
||||||
|
- Updated structure of `SshConfig`
|
||||||
|
- Updated `SshKey.store()`
|
||||||
|
- Performed related structural cleanup
|
||||||
|
|
||||||
|
## 2016-06-24 - 1.0.6 to 1.0.7 - core
|
||||||
|
This release range focused on structural changes in the core implementation.
|
||||||
|
|
||||||
|
- Major structural updates
|
||||||
|
- Additional structure refinements
|
||||||
|
|
||||||
|
## 2016-06-01 - 1.0.2 to 1.0.5 - features
|
||||||
|
This release range added testing, packaging, CI, and key-handling improvements.
|
||||||
|
|
||||||
|
- Renamed `Ssh` class to `SshInstance`
|
||||||
|
- Added support for base64-encoded keys
|
||||||
|
- Added typings to package metadata
|
||||||
|
- Expanded and improved test coverage, including an 80% coverage milestone
|
||||||
|
- Updated dependency and CI configuration
|
||||||
|
- Improved directory synchronization behavior
|
||||||
|
|
||||||
|
## 2016-04-25 - 1.0.1 - core
|
||||||
|
Expanded the initial API and improved class structure after the first stable release.
|
||||||
|
|
||||||
|
- Added `removeKey` and `replaceKey` methods
|
||||||
|
- Improved sync triggering
|
||||||
|
- Restructured class files
|
||||||
|
- Standardized class names to start with capital letters
|
||||||
|
- Added supporting logic and typing updates
|
||||||
|
|
||||||
|
## 2016-04-24 - 1.0.0 - project
|
||||||
|
Initial public release of the project.
|
||||||
|
|
||||||
|
- Started the project structure
|
||||||
|
- Created `package.json` and enabled CI
|
||||||
|
- Added `.gitignore`
|
||||||
|
- Added and improved README documentation
|
||||||
+12
-4
@@ -1,14 +1,15 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"@ship.zone/szci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmRegistryUrl": "registry.npmjs.org"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"@git.zone/cli": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "code.foss.global",
|
"githost": "code.foss.global",
|
||||||
"gitscope": "push.rocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartssh",
|
"gitrepo": "smartssh",
|
||||||
|
"shortDescription": "SSH configuration utilities",
|
||||||
"description": "A library for setting up SSH configuration quickly and painlessly.",
|
"description": "A library for setting up SSH configuration quickly and painlessly.",
|
||||||
"npmPackagename": "@push.rocks/smartssh",
|
"npmPackagename": "@push.rocks/smartssh",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -22,9 +23,16 @@
|
|||||||
"security",
|
"security",
|
||||||
"server management"
|
"server management"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"registries": [
|
||||||
|
"https://verdaccio.lossless.digital",
|
||||||
|
"https://registry.npmjs.org"
|
||||||
|
],
|
||||||
|
"accessLevel": "public"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tsdoc": {
|
"@git.zone/tsdoc": {
|
||||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+20
-19
@@ -3,13 +3,16 @@
|
|||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A library for setting up SSH configuration quickly and painlessly.",
|
"description": "A library for setting up SSH configuration quickly and painlessly.",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist_ts/index.js"
|
||||||
|
},
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "tstest test/",
|
||||||
"testDocker": "tsdocker",
|
"testDocker": "tsdocker",
|
||||||
"build": "(tsbuild --allowimplicitany)",
|
"build": "tsbuild",
|
||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -26,31 +29,27 @@
|
|||||||
"security",
|
"security",
|
||||||
"server management"
|
"server management"
|
||||||
],
|
],
|
||||||
"author": "Lossless GmbH",
|
"author": "Task Venture Capital GmbH <hello@task.vc>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/smartssh/issues"
|
"url": "https://code.foss.global/push.rocks/smartssh/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://code.foss.global/push.rocks/smartssh",
|
"homepage": "https://code.foss.global/push.rocks/smartssh",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/smartcrypto": "^2.0.5",
|
"@push.rocks/smartcrypto": "^2.0.4",
|
||||||
"@push.rocks/smartfile": "^11.0.4",
|
"@push.rocks/smartjson": "^6.0.1",
|
||||||
"@push.rocks/smartjson": "^5.0.10",
|
"@push.rocks/smartpath": "^6.0.0",
|
||||||
"@push.rocks/smartpath": "^5.0.11",
|
"@push.rocks/smartstring": "^4.1.1",
|
||||||
"@push.rocks/smartpromise": "^4.0.3",
|
|
||||||
"@push.rocks/smartshell": "^3.0.3",
|
|
||||||
"@push.rocks/smartstring": "^4.0.13",
|
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"fs-extra": "^11.2.0",
|
"@types/ssh2": "^1.15.5",
|
||||||
"minimatch": "^9.0.3",
|
"fs-extra": "^11.3.4",
|
||||||
"node-ssh": "^13.1.0"
|
"minimatch": "^10.2.5",
|
||||||
|
"node-ssh": "^13.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.72",
|
"@git.zone/tsbuild": "^4.4.0",
|
||||||
"@git.zone/tsrun": "^1.2.46",
|
"@git.zone/tstest": "^3.6.3",
|
||||||
"@git.zone/tstest": "^1.0.86",
|
"@types/node": "^25.6.0"
|
||||||
"@push.rocks/tapbundle": "^5.0.15",
|
|
||||||
"@types/node": "^20.11.17"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
@@ -61,6 +60,8 @@
|
|||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
|
".smartconfig.json",
|
||||||
|
"LICENSE",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
],
|
],
|
||||||
|
|||||||
Generated
+6892
-4887
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,9 @@
|
|||||||
import { expect, tap } from '@push.rocks/tapbundle';
|
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||||
import * as smartssh from '../ts/index.js';
|
import * as smartssh from '../ts/index.js';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
|
const testDir = path.join(process.cwd(), '.nogit/test/temp');
|
||||||
|
|
||||||
let testSshInstance: smartssh.SshInstance;
|
let testSshInstance: smartssh.SshInstance;
|
||||||
let testSshKey: smartssh.SshKey;
|
let testSshKey: smartssh.SshKey;
|
||||||
tap.test('should create a valid SshKey object', async () => {
|
tap.test('should create a valid SshKey object', async () => {
|
||||||
@@ -26,13 +28,13 @@ tap.test('.publicKeyBase64 should be public key base 64 encoded', async () => {
|
|||||||
testSshKey.pubKeyBase64;
|
testSshKey.pubKeyBase64;
|
||||||
});
|
});
|
||||||
tap.test('.store() should store the file to disk', async () => {
|
tap.test('.store() should store the file to disk', async () => {
|
||||||
testSshKey.store(path.join(process.cwd(), 'test/temp'));
|
await testSshKey.store(testDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
// SSH INstance
|
// SSH INstance
|
||||||
tap.test("'new' keyword should create a new SshInstance object from class", async () => {
|
tap.test("'new' keyword should create a new SshInstance object from class", async () => {
|
||||||
testSshInstance = new smartssh.SshInstance({
|
testSshInstance = new smartssh.SshInstance({
|
||||||
sshDirPath: path.join(process.cwd(), 'test/temp/'),
|
sshDirPath: testDir,
|
||||||
});
|
});
|
||||||
expect(testSshInstance).toBeInstanceOf(smartssh.SshInstance);
|
expect(testSshInstance).toBeInstanceOf(smartssh.SshInstance);
|
||||||
});
|
});
|
||||||
@@ -69,11 +71,15 @@ tap.test('.sshKeys should point to an array of sshKeys', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tap.test('.getKey() should get a specific key selected by host', async () => {
|
tap.test('.getKey() should get a specific key selected by host', async () => {
|
||||||
expect(testSshInstance.getKey('github.com').pubKey).toEqual('someGitHubPublicKey');
|
const sshKey = testSshInstance.getKey('github.com');
|
||||||
|
expect(sshKey).toBeInstanceOf(smartssh.SshKey);
|
||||||
|
expect(sshKey?.pubKey).toEqual('someGitHubPublicKey');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('.removeKey() should remove a key', async () => {
|
tap.test('.removeKey() should remove a key', async () => {
|
||||||
testSshInstance.removeKey(testSshInstance.getKey('bitbucket.org'));
|
const sshKey = testSshInstance.getKey('bitbucket.org');
|
||||||
|
expect(sshKey).toBeInstanceOf(smartssh.SshKey);
|
||||||
|
testSshInstance.removeKey(sshKey!);
|
||||||
expect(testSshInstance.sshKeys[1].host).toEqual('github.com');
|
expect(testSshInstance.sshKeys[1].host).toEqual('github.com');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -81,4 +87,4 @@ tap.test('it should store to disk', async () => {
|
|||||||
testSshInstance.writeToDisk();
|
testSshInstance.writeToDisk();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
export default tap.start();
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartssh',
|
name: '@push.rocks/smartssh',
|
||||||
version: '2.0.2',
|
version: '2.0.3',
|
||||||
description: 'setups SSH quickly and in a painless manner'
|
description: 'A library for setting up SSH configuration quickly and painlessly.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ import * as plugins from './smartssh.plugins.js';
|
|||||||
import { SshKey } from './smartssh.classes.sshkey.js';
|
import { SshKey } from './smartssh.classes.sshkey.js';
|
||||||
|
|
||||||
export let sshKeyArrayFromDir = function (dirArg: string): SshKey[] {
|
export let sshKeyArrayFromDir = function (dirArg: string): SshKey[] {
|
||||||
let sshKeyArray = []; // TODO
|
let sshKeyArray: SshKey[] = []; // TODO
|
||||||
return sshKeyArray;
|
return sshKeyArray;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,11 +12,10 @@ export class SshConfig {
|
|||||||
* stores a config file
|
* stores a config file
|
||||||
*/
|
*/
|
||||||
store(dirPathArg: string) {
|
store(dirPathArg: string) {
|
||||||
let done = plugins.smartpromise.defer();
|
plugins.fs.ensureDirSync(dirPathArg);
|
||||||
let configArray: configObject[] = [];
|
let configArray: configObject[] = [];
|
||||||
let configString;
|
for (const sshKey of this._sshKeyArray) {
|
||||||
for (let key in this._sshKeyArray) {
|
let configString = '';
|
||||||
let sshKey = this._sshKeyArray[key];
|
|
||||||
if (sshKey.host) {
|
if (sshKey.host) {
|
||||||
configString =
|
configString =
|
||||||
'Host ' +
|
'Host ' +
|
||||||
@@ -38,18 +37,13 @@ export class SshConfig {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
let configFile: string = '';
|
let configFile: string = '';
|
||||||
for (let key in configArray) {
|
for (const config of configArray) {
|
||||||
configFile = configFile + configArray[key].configString + '\n';
|
configFile = configFile + config.configString + '\n';
|
||||||
}
|
}
|
||||||
plugins.smartfile.memory.toFsSync(configFile, plugins.path.join(dirPathArg, 'config'));
|
plugins.fs.writeFileSync(plugins.path.join(dirPathArg, 'config'), configFile);
|
||||||
return done.promise;
|
|
||||||
}
|
}
|
||||||
read(dirPathArg) {
|
read(dirPathArg: string) {
|
||||||
let done = plugins.smartpromise.defer();
|
return plugins.fs.readFileSync(plugins.path.join(dirPathArg, 'config'), 'utf8');
|
||||||
let configArray: configObject[];
|
|
||||||
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg, 'config'));
|
|
||||||
|
|
||||||
return done.promise;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export class SshInstance {
|
|||||||
this._sshKeyArray = [];
|
this._sshKeyArray = [];
|
||||||
this._sshConfig = new SshConfig(this._sshKeyArray);
|
this._sshConfig = new SshConfig(this._sshKeyArray);
|
||||||
this._sshDir = new SshDir(this._sshKeyArray, this._sshConfig, optionsArg.sshDirPath);
|
this._sshDir = new SshDir(this._sshKeyArray, this._sshConfig, optionsArg.sshDirPath);
|
||||||
this._sshSync = optionsArg.sshSync;
|
this._sshSync = optionsArg.sshSync ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// altering methods
|
// altering methods
|
||||||
@@ -43,7 +43,7 @@ export class SshInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// non altering methods
|
// non altering methods
|
||||||
getKey(hostArg: string): SshKey {
|
getKey(hostArg: string): SshKey | undefined {
|
||||||
this._syncAuto('from');
|
this._syncAuto('from');
|
||||||
let filteredArray = this._sshKeyArray.filter(function (keyArg) {
|
let filteredArray = this._sshKeyArray.filter(function (keyArg) {
|
||||||
return keyArg.host === hostArg;
|
return keyArg.host === hostArg;
|
||||||
|
|||||||
@@ -7,20 +7,16 @@ export class SshKey {
|
|||||||
private _hostVar: string;
|
private _hostVar: string;
|
||||||
private _authorized: boolean;
|
private _authorized: boolean;
|
||||||
|
|
||||||
private _smarthshellInstance = new plugins.smartshell.Smartshell({
|
|
||||||
executor: 'bash',
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the constructor for class SshKey
|
* the constructor for class SshKey
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
optionsArg: { private?: string; public?: string; host?: string; authorized?: boolean } = {}
|
optionsArg: { private?: string; public?: string; host?: string; authorized?: boolean } = {}
|
||||||
) {
|
) {
|
||||||
this._privKey = optionsArg.private;
|
this._privKey = optionsArg.private ?? '';
|
||||||
this._pubKey = optionsArg.public;
|
this._pubKey = optionsArg.public ?? '';
|
||||||
this._hostVar = optionsArg.host;
|
this._hostVar = optionsArg.host ?? '';
|
||||||
this._authorized = optionsArg.authorized;
|
this._authorized = optionsArg.authorized ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.host
|
// this.host
|
||||||
@@ -87,20 +83,20 @@ export class SshKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
read(filePathArg) {}
|
read(filePathArg: string) {}
|
||||||
|
|
||||||
async store(dirPathArg: string) {
|
async store(dirPathArg: string) {
|
||||||
plugins.fs.ensureDirSync(dirPathArg);
|
plugins.fs.ensureDirSync(dirPathArg);
|
||||||
let fileNameBase = this.host;
|
let fileNameBase = this.host;
|
||||||
if (this._privKey) {
|
if (this._privKey) {
|
||||||
let filePath = plugins.path.join(dirPathArg, fileNameBase);
|
let filePath = plugins.path.join(dirPathArg, fileNameBase);
|
||||||
plugins.smartfile.memory.toFsSync(this._privKey, filePath);
|
plugins.fs.writeFileSync(filePath, this._privKey);
|
||||||
await this._smarthshellInstance.exec(`chmod 0600 ${filePath}`);
|
plugins.fs.chmodSync(filePath, 0o600);
|
||||||
}
|
}
|
||||||
if (this._pubKey) {
|
if (this._pubKey) {
|
||||||
let filePath = plugins.path.join(dirPathArg, fileNameBase + '.pub');
|
let filePath = plugins.path.join(dirPathArg, fileNameBase + '.pub');
|
||||||
plugins.smartfile.memory.toFsSync(this._pubKey, filePath);
|
plugins.fs.writeFileSync(filePath, this._pubKey);
|
||||||
await this._smarthshellInstance.exec(`chmod 0600 ${filePath}`);
|
plugins.fs.chmodSync(filePath, 0o600);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,19 @@
|
|||||||
// node native
|
// node native
|
||||||
import * as fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export { fs, path };
|
export { fs, path };
|
||||||
|
|
||||||
// @push.rocks scope
|
// @push.rocks scope
|
||||||
import * as smartjson from '@push.rocks/smartjson';
|
import * as smartjson from '@push.rocks/smartjson';
|
||||||
import * as smartfile from '@push.rocks/smartfile';
|
|
||||||
import * as smartcrypto from '@push.rocks/smartcrypto';
|
import * as smartcrypto from '@push.rocks/smartcrypto';
|
||||||
import * as smartpath from '@push.rocks/smartpath';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
import * as smartpromise from '@push.rocks/smartpromise';
|
|
||||||
import * as smartshell from '@push.rocks/smartshell';
|
|
||||||
import * as smartstring from '@push.rocks/smartstring';
|
import * as smartstring from '@push.rocks/smartstring';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
smartjson,
|
smartjson,
|
||||||
smartfile,
|
|
||||||
smartcrypto,
|
smartcrypto,
|
||||||
smartpath,
|
smartpath,
|
||||||
smartpromise,
|
|
||||||
smartshell,
|
|
||||||
smartstring,
|
smartstring,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -5,8 +5,10 @@
|
|||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
|
"noImplicitAny": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"verbatimModuleSyntax": true
|
"verbatimModuleSyntax": true,
|
||||||
|
"types": ["node"]
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist_*/**/*.d.ts"
|
"dist_*/**/*.d.ts"
|
||||||
|
|||||||
Reference in New Issue
Block a user