fix(deps): bump dependencies, adjust build script and npmextra publish config, and refresh documentation
This commit is contained in:
@@ -1,5 +1,14 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-02-13 - 3.0.8 - fix(deps)
|
||||||
|
bump dependencies, adjust build script and npmextra publish config, and refresh documentation
|
||||||
|
|
||||||
|
- Bumped runtime deps: @push.rocks/lik ^6.0.0 -> ^6.2.2, @push.rocks/smartenv ^5.0.2 -> ^6.0.0, @push.rocks/smartnetwork ^3.0.0 -> ^4.4.0, @push.rocks/smartpromise ^4.0.2 -> ^4.2.3, systeminformation ^5.12.1 -> ^5.30.7
|
||||||
|
- Updated devDependencies: @git.zone/tsbuild ^2.1.63 -> ^4.1.2, @git.zone/tsrun ^1.3.3 -> ^2.0.1, @git.zone/tstest ^1.0.72 -> ^3.1.8; removed tslint and tslint-config-prettier
|
||||||
|
- Changed build script to remove --allowimplicitany ("build": "(tsbuild tsfolders)")
|
||||||
|
- Updated npmextra.json: migrated keys to scoped entries (@git.zone/cli, @git.zone/tsdoc, @ship.zone/szci), added release registries (verdaccio + npm) and accessLevel
|
||||||
|
- Documentation updates: expanded readme.md with examples, runtime detection, network and system usage, legal/licensing clarifications; added readme.hints.md
|
||||||
|
|
||||||
## 2025-08-29 - 3.0.7 - fix(build)
|
## 2025-08-29 - 3.0.7 - fix(build)
|
||||||
Switch build script to run tsbuild on tsfolders instead of using the --web flag
|
Switch build script to run tsbuild on tsfolders instead of using the --web flag
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"@git.zone/cli": {
|
||||||
"npmGlobalTools": [],
|
|
||||||
"npmAccessLevel": "public"
|
|
||||||
},
|
|
||||||
"gitzone": {
|
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "code.foss.global",
|
"githost": "code.foss.global",
|
||||||
@@ -23,9 +19,19 @@
|
|||||||
"async",
|
"async",
|
||||||
"cross-platform"
|
"cross-platform"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
"@ship.zone/szci": {
|
||||||
|
"npmGlobalTools": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
20
package.json
20
package.json
@@ -7,7 +7,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --verbose --logfile --timeout 60)",
|
"test": "(tstest test/ --verbose --logfile --timeout 60)",
|
||||||
"build": "(tsbuild tsfolders --allowimplicitany)",
|
"build": "(tsbuild tsfolders)",
|
||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -32,18 +32,16 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://code.foss.global/push.rocks/smartsystem",
|
"homepage": "https://code.foss.global/push.rocks/smartsystem",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/lik": "^6.0.0",
|
"@push.rocks/lik": "^6.2.2",
|
||||||
"@push.rocks/smartenv": "^5.0.2",
|
"@push.rocks/smartenv": "^6.0.0",
|
||||||
"@push.rocks/smartnetwork": "^3.0.0",
|
"@push.rocks/smartnetwork": "^4.4.0",
|
||||||
"@push.rocks/smartpromise": "^4.0.2",
|
"@push.rocks/smartpromise": "^4.2.3",
|
||||||
"systeminformation": "^5.12.1"
|
"systeminformation": "^5.30.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.63",
|
"@git.zone/tsbuild": "^4.1.2",
|
||||||
"@git.zone/tsrun": "^1.3.3",
|
"@git.zone/tsrun": "^2.0.1",
|
||||||
"@git.zone/tstest": "^1.0.72",
|
"@git.zone/tstest": "^3.1.8"
|
||||||
"tslint": "^6.1.3",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
3797
pnpm-lock.yaml
generated
3797
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1 +1,26 @@
|
|||||||
|
# @push.rocks/smartsystem - Project Hints
|
||||||
|
|
||||||
|
## Project Overview
|
||||||
|
A TypeScript library providing a unified interface for system interaction: environment detection, CPU info, network utilities, and deep system information.
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
- Single main class `Smartsystem` in `ts/index.ts`
|
||||||
|
- Plugins file `ts/smartsystem.plugins.ts` imports all dependencies
|
||||||
|
- Dependencies: `@push.rocks/smartenv`, `@push.rocks/smartnetwork`, `@push.rocks/lik`, `@push.rocks/smartpromise`, `systeminformation`, plus Node.js `os`
|
||||||
|
|
||||||
|
## Build & Test
|
||||||
|
- Build: `pnpm build` (uses `tsbuild tsfolders`)
|
||||||
|
- Test: `pnpm test` (uses `tstest test/ --verbose --logfile --timeout 60`)
|
||||||
|
- All 3 tests passing as of last check
|
||||||
|
|
||||||
|
## Dependencies (all at latest as of 2026-02-12)
|
||||||
|
- `@push.rocks/lik`: ^6.2.2
|
||||||
|
- `@push.rocks/smartenv`: ^6.0.0
|
||||||
|
- `@push.rocks/smartnetwork`: ^4.4.0
|
||||||
|
- `@push.rocks/smartpromise`: ^4.2.3
|
||||||
|
- `systeminformation`: ^5.30.7
|
||||||
|
- Dev: `@git.zone/tsbuild`: ^4.1.2, `@git.zone/tsrun`: ^2.0.1, `@git.zone/tstest`: ^3.1.8
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
- No license file at project root (readme references `./LICENSE`)
|
||||||
|
- No tspublish-based submodules
|
||||||
|
|||||||
184
readme.md
184
readme.md
@@ -1,32 +1,32 @@
|
|||||||
# @push.rocks/smartsystem 🚀
|
# @push.rocks/smartsystem 🚀
|
||||||
**Smart System Interaction for Node.js**
|
|
||||||
|
Smart System Interaction for Node.js — your unified gateway to hardware, OS, environment, and network intelligence.
|
||||||
|
|
||||||
> Zero-hassle system information and environment management for modern Node.js applications.
|
> Zero-hassle system information and environment management for modern Node.js applications.
|
||||||
|
|
||||||
|
## Issue Reporting and Security
|
||||||
|
|
||||||
|
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
||||||
|
|
||||||
## 🌟 Features
|
## 🌟 Features
|
||||||
|
|
||||||
`@push.rocks/smartsystem` consolidates system interaction into a single, elegant TypeScript-first API:
|
`@push.rocks/smartsystem` consolidates system interaction into a single, elegant TypeScript-first API:
|
||||||
|
|
||||||
- 🔧 **Unified System Interface** - One `Smartsystem` instance to rule them all
|
- 🔧 **Unified System Interface** — One `Smartsystem` instance to rule them all
|
||||||
- 🌍 **Environment Management** - Smart env variable handling via [@push.rocks/smartenv](https://www.npmjs.com/package/@push.rocks/smartenv)
|
- 🌍 **Runtime Detection** — Identify Node.js, Deno, Bun, or browser environments via [@push.rocks/smartenv](https://www.npmjs.com/package/@push.rocks/smartenv)
|
||||||
- 💻 **CPU Information** - Direct access to CPU specs without the boilerplate
|
- 💻 **CPU Information** — Direct access to CPU core specs without the boilerplate
|
||||||
- 🌐 **Network Intelligence** - Advanced networking utilities from [@push.rocks/smartnetwork](https://www.npmjs.com/package/@push.rocks/smartnetwork)
|
- 🌐 **Network Intelligence** — Port scanning, speed tests, DNS resolution, traceroutes, and more via [@push.rocks/smartnetwork](https://www.npmjs.com/package/@push.rocks/smartnetwork)
|
||||||
- 📊 **Deep System Insights** - Comprehensive hardware and OS data via [systeminformation](https://www.npmjs.com/package/systeminformation)
|
- 📊 **Deep System Insights** — Comprehensive hardware, OS, Docker, and performance data via [systeminformation](https://www.npmjs.com/package/systeminformation)
|
||||||
- ⚡ **TypeScript Native** - Built with TypeScript, for TypeScript (but works great with JS too!)
|
- ⚡ **TypeScript Native** — Built with TypeScript, for TypeScript (but works great with JS too!)
|
||||||
|
|
||||||
## 📦 Installation
|
## 📦 Installation
|
||||||
|
|
||||||
Get started with your package manager of choice:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Using npm
|
|
||||||
npm install @push.rocks/smartsystem
|
|
||||||
|
|
||||||
# Using pnpm (recommended)
|
# Using pnpm (recommended)
|
||||||
pnpm add @push.rocks/smartsystem
|
pnpm add @push.rocks/smartsystem
|
||||||
|
|
||||||
# Using yarn
|
# Using npm
|
||||||
yarn add @push.rocks/smartsystem
|
npm install @push.rocks/smartsystem
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🚀 Quick Start
|
## 🚀 Quick Start
|
||||||
@@ -37,7 +37,12 @@ import { Smartsystem } from '@push.rocks/smartsystem';
|
|||||||
// Create your system interface
|
// Create your system interface
|
||||||
const mySystem = new Smartsystem();
|
const mySystem = new Smartsystem();
|
||||||
|
|
||||||
// You're ready to rock! 🎸
|
// CPU cores at a glance
|
||||||
|
console.log(`Running on ${mySystem.cpus.length} CPU cores`);
|
||||||
|
|
||||||
|
// Deep system data
|
||||||
|
const osInfo = await mySystem.information.osInfo();
|
||||||
|
console.log(`OS: ${osInfo.distro} ${osInfo.release}`);
|
||||||
```
|
```
|
||||||
|
|
||||||
## 📖 API Overview
|
## 📖 API Overview
|
||||||
@@ -46,48 +51,92 @@ The `Smartsystem` class provides these powerful properties:
|
|||||||
|
|
||||||
| Property | Type | Description |
|
| Property | Type | Description |
|
||||||
|----------|------|-------------|
|
|----------|------|-------------|
|
||||||
| `env` | `Smartenv` | Environment variable management with validation and type safety |
|
| `env` | `Smartenv` | Runtime environment detection — identify Node.js, Deno, Bun, browser, CI, and OS platform |
|
||||||
| `cpus` | `os.CpuInfo[]` | Direct access to CPU core information |
|
| `cpus` | `os.CpuInfo[]` | Direct access to CPU core information (model, speed, times) |
|
||||||
| `network` | `SmartNetwork` | Network interface inspection and utilities |
|
| `network` | `SmartNetwork` | Network utilities — port scanning, speed tests, DNS, ping, traceroute |
|
||||||
| `information` | `systeminformation` | Full access to the systeminformation library |
|
| `information` | `systeminformation` | Full access to 50+ system data functions (CPU, memory, disk, GPU, Docker, etc.) |
|
||||||
|
|
||||||
## 💡 Usage Examples
|
## 💡 Usage Examples
|
||||||
|
|
||||||
### Environment Variables Made Easy
|
### 🌍 Runtime Environment Detection
|
||||||
|
|
||||||
|
Detect where your code is running and adapt accordingly:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const mySystem = new Smartsystem();
|
const mySystem = new Smartsystem();
|
||||||
|
|
||||||
// Get all environment variables
|
// Runtime identification
|
||||||
const envVars = mySystem.env.getEnvVars();
|
console.log(`Runtime: ${mySystem.env.runtimeEnv}`); // 'node', 'deno', 'bun', or 'browser'
|
||||||
|
console.log(`Is Node.js: ${mySystem.env.isNode}`);
|
||||||
|
console.log(`Is CI: ${mySystem.env.isCI}`);
|
||||||
|
|
||||||
// Access specific variables with type safety
|
// OS detection
|
||||||
const apiKey = mySystem.env.getEnvVarOnDemand('API_KEY');
|
if (await mySystem.env.isLinuxAsync()) {
|
||||||
|
console.log('🐧 Running on Linux');
|
||||||
|
} else if (await mySystem.env.isMacAsync()) {
|
||||||
|
console.log('🍎 Running on macOS');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conditionally load modules based on runtime
|
||||||
|
const fsModule = await mySystem.env.getSafeModuleFor<typeof import('fs')>('node', 'fs');
|
||||||
```
|
```
|
||||||
|
|
||||||
### CPU Information at Your Fingertips
|
### 💻 CPU Information at Your Fingertips
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const mySystem = new Smartsystem();
|
const mySystem = new Smartsystem();
|
||||||
|
|
||||||
// Get CPU details
|
console.log(`CPU Cores: ${mySystem.cpus.length}`);
|
||||||
console.log(`Running on ${mySystem.cpus.length} CPU cores`);
|
|
||||||
console.log(`Primary CPU: ${mySystem.cpus[0].model}`);
|
console.log(`Primary CPU: ${mySystem.cpus[0].model}`);
|
||||||
|
console.log(`Speed: ${mySystem.cpus[0].speed} MHz`);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Network Intelligence
|
### 🌐 Network Intelligence
|
||||||
|
|
||||||
|
Leverage the full power of `SmartNetwork`:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const mySystem = new Smartsystem();
|
const mySystem = new Smartsystem();
|
||||||
|
|
||||||
// Get comprehensive network information
|
// Check if a local port is available
|
||||||
const networkInfo = await mySystem.network.getNetworkInfo();
|
const portFree = await mySystem.network.isLocalPortUnused(3000);
|
||||||
console.log('Network interfaces:', networkInfo);
|
console.log(`Port 3000 available: ${portFree}`);
|
||||||
|
|
||||||
|
// Find a free port in a range
|
||||||
|
const freePort = await mySystem.network.findFreePort(8000, 9000);
|
||||||
|
console.log(`Free port found: ${freePort}`);
|
||||||
|
|
||||||
|
// Check remote port availability
|
||||||
|
const isReachable = await mySystem.network.isRemotePortAvailable('example.com', { port: 443 });
|
||||||
|
console.log(`Remote HTTPS reachable: ${isReachable}`);
|
||||||
|
|
||||||
|
// DNS resolution
|
||||||
|
const dns = await mySystem.network.resolveDns('example.com');
|
||||||
|
console.log(`A records: ${dns.A.join(', ')}`);
|
||||||
|
|
||||||
|
// Ping a host
|
||||||
|
const pingResult = await mySystem.network.ping('8.8.8.8', { count: 3 });
|
||||||
|
|
||||||
|
// Get public IP addresses
|
||||||
|
const publicIps = await mySystem.network.getPublicIps();
|
||||||
|
console.log(`Public IPv4: ${publicIps.v4}`);
|
||||||
|
|
||||||
|
// Run a speed test
|
||||||
|
const speed = await mySystem.network.getSpeed();
|
||||||
|
console.log(`Download: ${speed.downloadSpeed} | Upload: ${speed.uploadSpeed}`);
|
||||||
|
|
||||||
|
// HTTP endpoint health check
|
||||||
|
const health = await mySystem.network.checkEndpoint('https://example.com');
|
||||||
|
console.log(`Status: ${health.status}, RTT: ${health.rtt}ms`);
|
||||||
|
|
||||||
|
// Traceroute
|
||||||
|
const hops = await mySystem.network.traceroute('example.com', { maxHops: 15 });
|
||||||
|
hops.forEach(hop => console.log(`TTL ${hop.ttl}: ${hop.ip} (${hop.rtt}ms)`));
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deep System Insights
|
### 📊 Deep System Insights
|
||||||
|
|
||||||
Access detailed system information for advanced use cases:
|
Access detailed system information via `systeminformation`:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const mySystem = new Smartsystem();
|
const mySystem = new Smartsystem();
|
||||||
@@ -100,20 +149,32 @@ console.log(`System: ${systemInfo.manufacturer} ${systemInfo.model}`);
|
|||||||
const osInfo = await mySystem.information.osInfo();
|
const osInfo = await mySystem.information.osInfo();
|
||||||
console.log(`OS: ${osInfo.distro} ${osInfo.release}`);
|
console.log(`OS: ${osInfo.distro} ${osInfo.release}`);
|
||||||
|
|
||||||
// Real-time system metrics
|
// Real-time CPU metrics
|
||||||
const load = await mySystem.information.currentLoad();
|
const load = await mySystem.information.currentLoad();
|
||||||
console.log(`CPU Load: ${load.currentLoad.toFixed(2)}%`);
|
console.log(`CPU Load: ${load.currentLoad.toFixed(2)}%`);
|
||||||
|
|
||||||
// Memory usage
|
// Memory usage
|
||||||
const mem = await mySystem.information.mem();
|
const mem = await mySystem.information.mem();
|
||||||
console.log(`Memory: ${(mem.used / mem.total * 100).toFixed(2)}% used`);
|
console.log(`Memory: ${(mem.used / mem.total * 100).toFixed(2)}% used`);
|
||||||
|
|
||||||
|
// Disk information
|
||||||
|
const disk = await mySystem.information.fsSize();
|
||||||
|
disk.forEach(fs => console.log(`${fs.mount}: ${fs.use.toFixed(1)}% used`));
|
||||||
|
|
||||||
|
// GPU details
|
||||||
|
const gpu = await mySystem.information.graphics();
|
||||||
|
gpu.controllers.forEach(c => console.log(`GPU: ${c.model} (${c.vram}MB VRAM)`));
|
||||||
|
|
||||||
|
// Network interfaces
|
||||||
|
const defaultIface = await mySystem.information.networkInterfaceDefault();
|
||||||
|
console.log(`Default network interface: ${defaultIface}`);
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🎯 Real-World Use Cases
|
## 🎯 Real-World Use Cases
|
||||||
|
|
||||||
### System Health Monitoring
|
### System Health Monitoring
|
||||||
|
|
||||||
Create a simple health check for your application:
|
Build a health check endpoint for your application:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const mySystem = new Smartsystem();
|
const mySystem = new Smartsystem();
|
||||||
@@ -137,18 +198,17 @@ async function healthCheck() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Network Traffic Analysis
|
### Network Traffic Monitoring
|
||||||
|
|
||||||
Monitor network activity for debugging or performance optimization:
|
Track bandwidth in real time:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const mySystem = new Smartsystem();
|
const mySystem = new Smartsystem();
|
||||||
|
|
||||||
async function monitorNetwork() {
|
async function monitorNetwork() {
|
||||||
const defaultInterface = await mySystem.information.networkInterfaceDefault();
|
const defaultInterface = await mySystem.information.networkInterfaceDefault();
|
||||||
const baseline = await mySystem.information.networkStats(defaultInterface);
|
await mySystem.information.networkStats(defaultInterface); // baseline
|
||||||
|
|
||||||
// Check again after 1 second
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
|
||||||
const current = await mySystem.information.networkStats(defaultInterface);
|
const current = await mySystem.information.networkStats(defaultInterface);
|
||||||
@@ -161,7 +221,7 @@ async function monitorNetwork() {
|
|||||||
|
|
||||||
### Smart Resource Scaling
|
### Smart Resource Scaling
|
||||||
|
|
||||||
Make intelligent decisions based on system resources:
|
Dynamically scale workers based on available resources:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const mySystem = new Smartsystem();
|
const mySystem = new Smartsystem();
|
||||||
@@ -171,7 +231,6 @@ async function getOptimalWorkerCount() {
|
|||||||
const load = await mySystem.information.currentLoad();
|
const load = await mySystem.information.currentLoad();
|
||||||
const mem = await mySystem.information.mem();
|
const mem = await mySystem.information.mem();
|
||||||
|
|
||||||
// Scale workers based on available resources
|
|
||||||
const memoryConstraint = Math.floor(mem.available / (512 * 1024 * 1024)); // 512MB per worker
|
const memoryConstraint = Math.floor(mem.available / (512 * 1024 * 1024)); // 512MB per worker
|
||||||
const cpuConstraint = Math.max(1, Math.floor(cpuCount * (1 - load.currentLoad / 100)));
|
const cpuConstraint = Math.max(1, Math.floor(cpuCount * (1 - load.currentLoad / 100)));
|
||||||
|
|
||||||
@@ -179,38 +238,33 @@ async function getOptimalWorkerCount() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🔧 Advanced Features
|
### 🐳 Docker & Container Awareness
|
||||||
|
|
||||||
### Cross-Platform Compatibility
|
Inspect Docker state from within your app:
|
||||||
|
|
||||||
`@push.rocks/smartsystem` works seamlessly across different operating systems:
|
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const mySystem = new Smartsystem();
|
const mySystem = new Smartsystem();
|
||||||
|
|
||||||
const osInfo = await mySystem.information.osInfo();
|
const dockerInfo = await mySystem.information.dockerInfo();
|
||||||
const platform = osInfo.platform; // 'linux', 'darwin', 'win32', etc.
|
console.log(`Docker containers: ${dockerInfo.containers} (${dockerInfo.containersRunning} running)`);
|
||||||
|
|
||||||
// Platform-specific logic
|
const containers = await mySystem.information.dockerContainers();
|
||||||
if (platform === 'linux') {
|
containers.forEach(c => console.log(` ${c.name}: ${c.state}`));
|
||||||
// Linux-specific operations
|
|
||||||
} else if (platform === 'darwin') {
|
|
||||||
// macOS-specific operations
|
|
||||||
} else if (platform === 'win32') {
|
|
||||||
// Windows-specific operations
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker & Container Detection
|
### Cross-Platform Logic
|
||||||
|
|
||||||
Detect if your application is running in a containerized environment:
|
Write platform-aware code cleanly:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const mySystem = new Smartsystem();
|
const mySystem = new Smartsystem();
|
||||||
|
|
||||||
const virt = await mySystem.information.dockerInfo();
|
if (await mySystem.env.isLinuxAsync()) {
|
||||||
if (virt.dockerContainers && virt.dockerContainers.length > 0) {
|
// Linux-specific setup
|
||||||
console.log('🐳 Running in Docker');
|
} else if (await mySystem.env.isMacAsync()) {
|
||||||
|
// macOS-specific setup
|
||||||
|
} else if (await mySystem.env.isWindowsAsync()) {
|
||||||
|
// Windows-specific setup
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -235,19 +289,21 @@ For complete API documentation, visit: [https://code.foss.global/push.rocks/smar
|
|||||||
|
|
||||||
## License and Legal Information
|
## License and Legal Information
|
||||||
|
|
||||||
This 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.
|
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
|
||||||
|
|
||||||
**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.
|
**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.
|
||||||
|
|
||||||
### Trademarks
|
### Trademarks
|
||||||
|
|
||||||
This 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.
|
This 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 or third parties, 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 or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
|
||||||
|
|
||||||
### Company Information
|
### Company Information
|
||||||
|
|
||||||
Task Venture Capital GmbH
|
Task Venture Capital GmbH
|
||||||
Registered at District court Bremen HRB 35230 HB, Germany
|
Registered at District Court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
By 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.
|
By 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.
|
||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartsystem',
|
name: '@push.rocks/smartsystem',
|
||||||
version: '3.0.7',
|
version: '3.0.8',
|
||||||
description: 'A TypeScript library for interacting with the system it is running on, including environment, network, and hardware information.'
|
description: 'A TypeScript library for interacting with the system it is running on, including environment, network, and hardware information.'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user