fix(ssh): modernize filesystem handling and package exports for NodeNext compatibility

This commit is contained in:
2026-05-01 18:44:22 +00:00
parent a9820a9e98
commit d8ab8a8d73
14 changed files with 7100 additions and 4960 deletions
+38
View File
@@ -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 -1
View File
@@ -1,6 +1,6 @@
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
of this software and associated documentation files (the "Software"), to deal
+96
View File
@@ -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
View File
@@ -1,14 +1,15 @@
{
"npmci": {
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
"npmRegistryUrl": "registry.npmjs.org"
},
"gitzone": {
"@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",
@@ -22,9 +23,16 @@
"security",
"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"
}
}
+20 -19
View File
@@ -3,13 +3,16 @@
"version": "2.0.2",
"private": false,
"description": "A library for setting up SSH configuration quickly and painlessly.",
"exports": {
".": "./dist_ts/index.js"
},
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(tstest test/)",
"test": "tstest test/",
"testDocker": "tsdocker",
"build": "(tsbuild --allowimplicitany)",
"build": "tsbuild",
"buildDocs": "tsdoc"
},
"repository": {
@@ -26,31 +29,27 @@
"security",
"server management"
],
"author": "Lossless GmbH",
"author": "Task Venture Capital GmbH <hello@task.vc>",
"license": "MIT",
"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",
"dependencies": {
"@push.rocks/smartcrypto": "^2.0.5",
"@push.rocks/smartfile": "^11.0.4",
"@push.rocks/smartjson": "^5.0.10",
"@push.rocks/smartpath": "^5.0.11",
"@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartshell": "^3.0.3",
"@push.rocks/smartstring": "^4.0.13",
"@push.rocks/smartcrypto": "^2.0.4",
"@push.rocks/smartjson": "^6.0.1",
"@push.rocks/smartpath": "^6.0.0",
"@push.rocks/smartstring": "^4.1.1",
"@types/fs-extra": "^11.0.4",
"fs-extra": "^11.2.0",
"minimatch": "^9.0.3",
"node-ssh": "^13.1.0"
"@types/ssh2": "^1.15.5",
"fs-extra": "^11.3.4",
"minimatch": "^10.2.5",
"node-ssh": "^13.2.1"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.72",
"@git.zone/tsrun": "^1.2.46",
"@git.zone/tstest": "^1.0.86",
"@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^20.11.17"
"@git.zone/tsbuild": "^4.4.0",
"@git.zone/tstest": "^3.6.3",
"@types/node": "^25.6.0"
},
"files": [
"ts/**/*",
@@ -61,6 +60,8 @@
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
".smartconfig.json",
"LICENSE",
"npmextra.json",
"readme.md"
],
+6892 -4887
View File
File diff suppressed because it is too large Load Diff
+12 -6
View File
@@ -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 path from 'path';
const testDir = path.join(process.cwd(), '.nogit/test/temp');
let testSshInstance: smartssh.SshInstance;
let testSshKey: smartssh.SshKey;
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;
});
tap.test('.store() should store the file to disk', async () => {
testSshKey.store(path.join(process.cwd(), 'test/temp'));
await testSshKey.store(testDir);
});
// SSH INstance
tap.test("'new' keyword should create a new SshInstance object from class", async () => {
testSshInstance = new smartssh.SshInstance({
sshDirPath: path.join(process.cwd(), 'test/temp/'),
sshDirPath: testDir,
});
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 () => {
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 () => {
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');
});
@@ -81,4 +87,4 @@ tap.test('it should store to disk', async () => {
testSshInstance.writeToDisk();
});
tap.start();
export default tap.start();
+3 -3
View File
@@ -1,8 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartssh',
version: '2.0.2',
description: 'setups SSH quickly and in a painless manner'
version: '2.0.3',
description: 'A library for setting up SSH configuration quickly and painlessly.'
}
+1 -1
View File
@@ -2,6 +2,6 @@ import * as plugins from './smartssh.plugins.js';
import { SshKey } from './smartssh.classes.sshkey.js';
export let sshKeyArrayFromDir = function (dirArg: string): SshKey[] {
let sshKeyArray = []; // TODO
let sshKeyArray: SshKey[] = []; // TODO
return sshKeyArray;
};
+8 -14
View File
@@ -12,11 +12,10 @@ export class SshConfig {
* stores a config file
*/
store(dirPathArg: string) {
let done = plugins.smartpromise.defer();
plugins.fs.ensureDirSync(dirPathArg);
let configArray: configObject[] = [];
let configString;
for (let key in this._sshKeyArray) {
let sshKey = this._sshKeyArray[key];
for (const sshKey of this._sshKeyArray) {
let configString = '';
if (sshKey.host) {
configString =
'Host ' +
@@ -38,18 +37,13 @@ export class SshConfig {
});
}
let configFile: string = '';
for (let key in configArray) {
configFile = configFile + configArray[key].configString + '\n';
for (const config of configArray) {
configFile = configFile + config.configString + '\n';
}
plugins.smartfile.memory.toFsSync(configFile, plugins.path.join(dirPathArg, 'config'));
return done.promise;
plugins.fs.writeFileSync(plugins.path.join(dirPathArg, 'config'), configFile);
}
read(dirPathArg) {
let done = plugins.smartpromise.defer();
let configArray: configObject[];
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg, 'config'));
return done.promise;
read(dirPathArg: string) {
return plugins.fs.readFileSync(plugins.path.join(dirPathArg, 'config'), 'utf8');
}
}
+2 -2
View File
@@ -18,7 +18,7 @@ export class SshInstance {
this._sshKeyArray = [];
this._sshConfig = new SshConfig(this._sshKeyArray);
this._sshDir = new SshDir(this._sshKeyArray, this._sshConfig, optionsArg.sshDirPath);
this._sshSync = optionsArg.sshSync;
this._sshSync = optionsArg.sshSync ?? false;
}
// altering methods
@@ -43,7 +43,7 @@ export class SshInstance {
}
// non altering methods
getKey(hostArg: string): SshKey {
getKey(hostArg: string): SshKey | undefined {
this._syncAuto('from');
let filteredArray = this._sshKeyArray.filter(function (keyArg) {
return keyArg.host === hostArg;
+9 -13
View File
@@ -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);
}
}
}
+1 -7
View File
@@ -1,25 +1,19 @@
// node native
import * as fs from 'fs-extra';
import fs from 'fs-extra';
import * as path from 'path';
export { fs, path };
// @push.rocks scope
import * as smartjson from '@push.rocks/smartjson';
import * as smartfile from '@push.rocks/smartfile';
import * as smartcrypto from '@push.rocks/smartcrypto';
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';
export {
smartjson,
smartfile,
smartcrypto,
smartpath,
smartpromise,
smartshell,
smartstring,
};
+3 -1
View File
@@ -5,8 +5,10 @@
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noImplicitAny": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true
"verbatimModuleSyntax": true,
"types": ["node"]
},
"exclude": [
"dist_*/**/*.d.ts"