Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
71f44f64fb | |||
3eac579317 | |||
f87fa3bf2b | |||
8b101369b8 | |||
89d9692701 | |||
69b22df534 | |||
0b2e88f430 | |||
dea8ca6021 | |||
c5d531fc09 | |||
66db546d67 | |||
8956f4be89 | |||
b02ee5e9f4 | |||
93153baa95 | |||
b584978287 | |||
44bfff2a6b |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -15,8 +15,6 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
121
.gitlab-ci.yml
121
.gitlab-ci.yml
@@ -1,121 +0,0 @@
|
|||||||
# gitzone ci_default
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
variables:
|
|
||||||
GIT_STRATEGY: clone
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .npmci_cache/
|
|
||||||
key: "$CI_BUILD_STAGE"
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- security
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- metadata
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
snyk:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install -g snyk
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command snyk test
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
testLTS:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run build
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
allow_failure: true
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g tslint typescript
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
image: hosttoday/ht-docker-dbase:npmci
|
|
||||||
services:
|
|
||||||
- docker:18-dind
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command tsdoc
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "npm test",
|
||||||
|
"name": "Run npm test",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
46
changelog.md
Normal file
46
changelog.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-08-29 - 3.0.2 - fix(smartsystem)
|
||||||
|
Normalize package scopes, update dev dependencies and tooling, add pnpm workspace and packageManager, remove GitLab CI, and update imports/docs/tests
|
||||||
|
|
||||||
|
- Normalize package scope names from @pushrocks/* to @push.rocks/* across source, commit info and README
|
||||||
|
- Update dependency versions: bump @push.rocks/smartpromise to ^4.0.2 and ensure other @push.rocks packages use caret ranges
|
||||||
|
- Switch dev tooling namespaces to @git.zone (tsbuild/tsrun/tstest) and add @git.zone/tsrun
|
||||||
|
- Enhance npm scripts: make test run with verbose, logfile and increased timeout
|
||||||
|
- Add packageManager field (pnpm@10.14.0+sha512...) to package.json and add pnpm-workspace.yaml with onlyBuiltDependencies: [esbuild]
|
||||||
|
- Remove legacy .gitlab-ci.yml CI configuration
|
||||||
|
- Update imports in ts and test files to match new package namespaces
|
||||||
|
|
||||||
|
## 2024-05-29 - 3.0.1 - chore
|
||||||
|
Update of package metadata and TypeScript configuration.
|
||||||
|
|
||||||
|
- update description
|
||||||
|
- update tsconfig (adjustments to TypeScript config)
|
||||||
|
- update npmextra.json: githost (fixes to githost entries)
|
||||||
|
|
||||||
|
## 2022-07-28 - 3.0.0 - fix(core)
|
||||||
|
Minor core fixes and release of 3.0.0.
|
||||||
|
|
||||||
|
- fix(core): update
|
||||||
|
|
||||||
|
## 2022-07-28 - 2.0.10 - BREAKING (core)
|
||||||
|
Breaking change: module format switched to ESM.
|
||||||
|
|
||||||
|
- BREAKING CHANGE(core): switch to esm
|
||||||
|
- misc maintenance and fixes leading up to this release
|
||||||
|
|
||||||
|
## 2017-07-31 - 2.0.1..2.0.9 - maintenance
|
||||||
|
Series of patch releases with small fixes and upkeep across the 2.0.x line.
|
||||||
|
|
||||||
|
- Multiple patch releases (2.0.1 → 2.0.9) containing repeated core fixes
|
||||||
|
- Updates to README and repository metadata
|
||||||
|
- update yarn lock (notably in 2.0.1)
|
||||||
|
|
||||||
|
## 2017-07-31 - 1.0.0..1.0.18 - initial development & improvements
|
||||||
|
Initial development, feature additions and documentation improvements across 1.0.x.
|
||||||
|
|
||||||
|
- initial releases and basic module structure; first working version
|
||||||
|
- add npm as default module loader (1.0.6)
|
||||||
|
- improve path resolution and add keywords (1.0.4–1.0.5)
|
||||||
|
- add docs, improve README and tests across multiple 1.0.x releases
|
||||||
|
- CI updates and general streamlining of the project
|
@@ -1,69 +0,0 @@
|
|||||||
---
|
|
||||||
name: smartsystem
|
|
||||||
description: simplifies lazy loading with TypeScript
|
|
||||||
---
|
|
||||||
|
|
||||||
# smartsystem
|
|
||||||
|
|
||||||
simplifies lazy loading with TypeScript
|
|
||||||
|
|
||||||
## Availabililty
|
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/smartsystem)
|
|
||||||
[](https://GitLab.com/pushrocks/smartsystem)
|
|
||||||
[](https://github.com/pushrocks/smartsystem)
|
|
||||||
[](https://pushrocks.gitlab.io/smartsystem/)
|
|
||||||
|
|
||||||
## Status for master
|
|
||||||
|
|
||||||
[](https://GitLab.com/pushrocks/smartsystem/commits/master)
|
|
||||||
[](https://GitLab.com/pushrocks/smartsystem/commits/master)
|
|
||||||
[](https://www.npmjs.com/package/smartsystem)
|
|
||||||
[](https://david-dm.org/pushrocks/smartsystem)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartsystem/master/dependencies/npm)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartsystem)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](http://standardjs.com/)
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
We recommend the use of TypeScript for best Intellisense
|
|
||||||
|
|
||||||
smartsystem supports both npm and SystemJs as module loader.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import { LazyModule } from 'smartsystem';
|
|
||||||
|
|
||||||
// plugin does not get loaded here at runtime
|
|
||||||
import * as _myPlugin from 'myPlugin';
|
|
||||||
|
|
||||||
// define the lazy module
|
|
||||||
let myLazyModule = new LazyModule() < typeof _myPlugin > ('myPlugin', __dirname);
|
|
||||||
|
|
||||||
// another plugin
|
|
||||||
import * as _anotherPlugin from 'anotherPlugin'; // plugin does not get loaded here at runtime
|
|
||||||
|
|
||||||
// define lazy module
|
|
||||||
let anotherLazyModule = new LazyModule() < typeof _anotherPlugin > ('anotherPlugin', __dirname);
|
|
||||||
|
|
||||||
myLazyModule.whenLoaded.then(myPlugin => {
|
|
||||||
/* do something with myPlugin.
|
|
||||||
myPlugin receives the typings flow from LazyModule class
|
|
||||||
This does NOT load the module during runtime
|
|
||||||
The promise whenLoaded will be resolved whenever load() is called for the first time */
|
|
||||||
});
|
|
||||||
|
|
||||||
myLazyModule.load().then(myPlugin => {
|
|
||||||
/* do something with myPlugin.
|
|
||||||
myPlugin receives the typings flow from LazyModule class
|
|
||||||
This DOES LOAD the module */
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
|
||||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
|
||||||
|
|
||||||
[](https://push.rocks)
|
|
@@ -4,13 +4,28 @@
|
|||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "code.foss.global",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartsystem",
|
"gitrepo": "smartsystem",
|
||||||
"shortDescription": "interact with the system you are running on",
|
"description": "A TypeScript library for interacting with the system it's running on, including environment, network, and hardware information.",
|
||||||
"npmPackagename": "@pushrocks/smartsystem",
|
"npmPackagename": "@push.rocks/smartsystem",
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"TypeScript",
|
||||||
|
"system information",
|
||||||
|
"environment variables",
|
||||||
|
"network",
|
||||||
|
"hardware info",
|
||||||
|
"OS interaction",
|
||||||
|
"module loading",
|
||||||
|
"async",
|
||||||
|
"cross-platform"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
14997
package-lock.json
generated
14997
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
65
package.json
65
package.json
@@ -1,50 +1,65 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartsystem",
|
"name": "@push.rocks/smartsystem",
|
||||||
"version": "2.0.8",
|
"version": "3.0.2",
|
||||||
"description": "interact with the system you are running on",
|
"description": "A TypeScript library for interacting with the system it's running on, including environment, network, and hardware information.",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/ --verbose --logfile --timeout 60)",
|
||||||
"build": "(tsbuild)"
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+ssh://git@gitlab.com/pushrocks/smartsystem.git"
|
"url": "https://code.foss.global/push.rocks/smartsystem.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"TypeScript",
|
"TypeScript",
|
||||||
"lazy",
|
"system information",
|
||||||
"module loader"
|
"environment variables",
|
||||||
|
"network",
|
||||||
|
"hardware info",
|
||||||
|
"OS interaction",
|
||||||
|
"module loading",
|
||||||
|
"async",
|
||||||
|
"cross-platform"
|
||||||
],
|
],
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/smartsystem/issues"
|
"url": "https://gitlab.com/pushrocks/smartsystem/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartsystem#README",
|
"homepage": "https://code.foss.global/push.rocks/smartsystem",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^3.0.10",
|
"@push.rocks/lik": "^6.0.0",
|
||||||
"@pushrocks/smartenv": "^4.0.7",
|
"@push.rocks/smartenv": "^5.0.2",
|
||||||
"@pushrocks/smartpromise": "^3.0.2"
|
"@push.rocks/smartnetwork": "^3.0.0",
|
||||||
|
"@push.rocks/smartpromise": "^4.0.2",
|
||||||
|
"systeminformation": "^5.12.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.11",
|
"@git.zone/tsbuild": "^2.1.63",
|
||||||
"@gitzone/tstest": "^1.0.24",
|
"@git.zone/tsrun": "^1.3.3",
|
||||||
"@pushrocks/tapbundle": "^3.0.11",
|
"@git.zone/tstest": "^1.0.72",
|
||||||
"tslint": "^5.19.0",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
"files": [
|
"files": [
|
||||||
"ts/*",
|
"ts/**/*",
|
||||||
"ts_web/*",
|
"ts_web/**/*",
|
||||||
"dist/*",
|
"dist/**/*",
|
||||||
"dist_web/*",
|
"dist_*/**/*",
|
||||||
"dist_ts_web/*",
|
"dist_ts/**/*",
|
||||||
"assets/*",
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
]
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
],
|
||||||
|
"packageManager": "pnpm@10.14.0+sha512.ad27a79641b49c3e481a16a805baa71817a04bbe06a38d17e60e2eaee83f6a146c6a688125f5792e48dd5ba30e7da52a5cda4c3992b9ccf333f9ce223af84748"
|
||||||
}
|
}
|
||||||
|
8474
pnpm-lock.yaml
generated
Normal file
8474
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
2
pnpm-workspace.yaml
Normal file
2
pnpm-workspace.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
onlyBuiltDependencies:
|
||||||
|
- esbuild
|
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
159
readme.md
159
readme.md
@@ -1,28 +1,147 @@
|
|||||||
# @pushrocks/smartsystem
|
# @push.rocks/smartsystem
|
||||||
interact with the system you are running on
|
Interact with the system your Node.js app runs on.
|
||||||
|
|
||||||
## Availabililty and Links
|
## Features
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartsystem)
|
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartsystem)
|
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartsystem)
|
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartsystem/)
|
|
||||||
|
|
||||||
## Status for master
|
- Simple class: expose system info through a single `Smartsystem` instance
|
||||||
[](https://gitlab.com/pushrocks/smartsystem/commits/master)
|
- Env access: read and manage env vars via `@push.rocks/smartenv`
|
||||||
[](https://gitlab.com/pushrocks/smartsystem/commits/master)
|
- CPU info: get `os.cpus()` without importing `os`
|
||||||
[](https://www.npmjs.com/package/@pushrocks/smartsystem)
|
- Network utilities: high-level helpers from `@push.rocks/smartnetwork`
|
||||||
[](https://snyk.io/test/npm/@pushrocks/smartsystem)
|
- Deep stats: tap into `systeminformation` for OS, hardware, and load data
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
- TypeScript-first: typed API, works great from TS and JS
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
||||||
[](https://prettier.io/)
|
## Install
|
||||||
|
|
||||||
|
To incorporate @push.rocks/smartsystem into your project, you'll need to install the package via npm. You can do this by running the following command in your project's root directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install @push.rocks/smartsystem --save
|
||||||
|
```
|
||||||
|
|
||||||
|
This command will download @push.rocks/smartsystem and add it to your project's `package.json` file as a dependency.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
We recommend the use of TypeScript for best Intellisense
|
The `@push.rocks/smartsystem` module offers a convenient way to interact with the system your application is running on. Below are detailed examples that demonstrate how to utilize its full potential. These examples are written in TypeScript and showcase different cases and features of the module.
|
||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
### Getting Started
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
First, ensure that you are importing the module correctly in your TypeScript file:
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
```typescript
|
||||||
|
import { Smartsystem } from '@push.rocks/smartsystem';
|
||||||
|
```
|
||||||
|
|
||||||
|
### Creating an Instance of Smartsystem
|
||||||
|
|
||||||
|
To use the functionalities provided by `@push.rocks/smartsystem`, you need to create a new instance of the `Smartsystem` class.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const mySystem = new Smartsystem();
|
||||||
|
```
|
||||||
|
|
||||||
|
## API Overview
|
||||||
|
|
||||||
|
- `Smartsystem.env`: instance of `Smartenv` from `@push.rocks/smartenv`
|
||||||
|
Useful for reading and validating environment variables.
|
||||||
|
- `Smartsystem.cpus`: result of `os.cpus()`
|
||||||
|
Array of CPU core descriptions from Node’s built‑in `os` module.
|
||||||
|
- `Smartsystem.network`: instance of `SmartNetwork` from `@push.rocks/smartnetwork`
|
||||||
|
Inspect interfaces, addresses, and network details.
|
||||||
|
- `Smartsystem.information`: re-export of `systeminformation`
|
||||||
|
Call any method, e.g. `osInfo()`, `system()`, `currentLoad()`, `networkStats()`.
|
||||||
|
|
||||||
|
### Accessing Environment Variables
|
||||||
|
|
||||||
|
`@push.rocks/smartsystem` integrates with `@push.rocks/smartenv` to provide an easy way to handle environment variables.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
console.log(mySystem.env.getEnvVars());
|
||||||
|
```
|
||||||
|
|
||||||
|
### Getting CPU Information
|
||||||
|
|
||||||
|
You can retrieve information about the CPUs of the system:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
console.log(mySystem.cpus[0]); // Logs details about the first CPU
|
||||||
|
```
|
||||||
|
|
||||||
|
### Working with Network Interfaces
|
||||||
|
|
||||||
|
The module allows you to work with network interfaces, making use of `@push.rocks/smartnetwork`:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
(async () => {
|
||||||
|
console.log(await mySystem.network.getNetworkInfo());
|
||||||
|
})();
|
||||||
|
```
|
||||||
|
|
||||||
|
### System Information
|
||||||
|
|
||||||
|
For more detailed system information such as hardware specs or software versions, `@push.rocks/smartsystem` relies on the `systeminformation` library:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
(async () => {
|
||||||
|
console.log(await mySystem.information.system());
|
||||||
|
// Output detailed information about the system like manufacturer, model, etc.
|
||||||
|
|
||||||
|
console.log(await mySystem.information.osInfo());
|
||||||
|
// Output detailed information about the operating system
|
||||||
|
})();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Real-World Scenarios
|
||||||
|
|
||||||
|
Now that we've covered the basics let's dive into some real-world applications:
|
||||||
|
|
||||||
|
#### Monitoring System Load
|
||||||
|
|
||||||
|
You can monitor the current load on the system to make decisions or trigger actions when the system is under heavy use:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
(async () => {
|
||||||
|
const systemLoad = await mySystem.information.currentLoad();
|
||||||
|
if (systemLoad.currentLoad > 80) {
|
||||||
|
console.log("High system load detected. Consider scaling or optimizing your applications.");
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Network Monitoring
|
||||||
|
|
||||||
|
It's often useful to keep an eye on network interfaces, especially when diagnosing connectivity issues or monitoring network traffic:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
(async () => {
|
||||||
|
const defaultInterface = await mySystem.information.networkInterfaceDefault();
|
||||||
|
const interfaceStats = await mySystem.information.networkStats(defaultInterface);
|
||||||
|
console.log(interfaceStats);
|
||||||
|
// Use this information to alert on unusual traffic patterns or drops in speed.
|
||||||
|
})();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Conclusion
|
||||||
|
|
||||||
|
`@push.rocks/smartsystem` offers a comprehensive toolkit for interacting with the underlying system your Node.js application runs on. From retrieving environment variables and CPU information to monitoring network interfaces and system load, this module provides everything you need to ensure your application can intelligently respond to its operating environment.
|
||||||
|
|
||||||
|
Remember, the examples above only scratch the surface of what's possible with `@push.rocks/smartsystem`. For more detailed documentation on all available methods and their capabilities, refer to the [official documentation](https://pushrocks.gitlab.io/smartsystem/).
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
**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
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
15
test/test.ts
15
test/test.ts
@@ -1,15 +1,20 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||||
import * as smartsystem from '../ts/index';
|
import * as smartsystem from '../ts/index.js';
|
||||||
|
import { systeminformation } from '../ts/smartsystem.plugins.js';
|
||||||
|
|
||||||
let smartsystemInstance: smartsystem.Smartsystem;
|
let smartsystemInstance: smartsystem.Smartsystem;
|
||||||
|
|
||||||
tap.test('should create a smartsystem instance', async tools => {
|
tap.test('should create a smartsystem instance', async (tools) => {
|
||||||
smartsystemInstance = new smartsystem.Smartsystem();
|
smartsystemInstance = new smartsystem.Smartsystem();
|
||||||
expect(smartsystemInstance).to.be.instanceOf(smartsystem.Smartsystem);
|
expect(smartsystemInstance).toBeInstanceOf(smartsystem.Smartsystem);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should state the operating system', async () => {
|
tap.test('should state the operating system', async () => {
|
||||||
expect(smartsystemInstance.cpus.length).to.be.greaterThan(0);
|
expect(smartsystemInstance.cpus.length).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should get systeminformation', async () => {
|
||||||
|
console.log(await smartsystemInstance.information.networkInterfaceDefault());
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartsystem',
|
||||||
|
version: '3.0.2',
|
||||||
|
description: 'A TypeScript library for interacting with the system it's running on, including environment, network, and hardware information.'
|
||||||
|
}
|
@@ -1,6 +1,10 @@
|
|||||||
import * as plugins from './smartsystem.plugins';
|
import * as plugins from './smartsystem.plugins.js';
|
||||||
|
|
||||||
export class Smartsystem {
|
export class Smartsystem {
|
||||||
public env = new plugins.smartenv.Smartenv();
|
public env = new plugins.smartenv.Smartenv();
|
||||||
public cpus = plugins.os.cpus();
|
public cpus = plugins.os.cpus();
|
||||||
|
public network = new plugins.smartnetwork.SmartNetwork();
|
||||||
|
public get information() {
|
||||||
|
return plugins.systeminformation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
// node native
|
// node native
|
||||||
import os from 'os'
|
import os from 'os';
|
||||||
|
|
||||||
export {
|
export { os };
|
||||||
os
|
|
||||||
}
|
|
||||||
|
|
||||||
import * as lik from '@pushrocks/lik';
|
import * as lik from '@push.rocks/lik';
|
||||||
import * as smartenv from '@pushrocks/smartenv';
|
import * as smartenv from '@push.rocks/smartenv';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartnetwork from '@push.rocks/smartnetwork';
|
||||||
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
|
|
||||||
export {
|
export { lik, smartenv, smartnetwork, smartpromise };
|
||||||
lik,
|
|
||||||
smartenv,
|
// third party
|
||||||
smartpromise
|
import * as systeminformation from 'systeminformation';
|
||||||
}
|
|
||||||
|
export { systeminformation };
|
||||||
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
17
tslint.json
17
tslint.json
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
|
||||||
"rules": {
|
|
||||||
"semicolon": [true, "always"],
|
|
||||||
"no-console": false,
|
|
||||||
"ordered-imports": false,
|
|
||||||
"object-literal-sort-keys": false,
|
|
||||||
"member-ordering": {
|
|
||||||
"options":{
|
|
||||||
"order": [
|
|
||||||
"static-method"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"defaultSeverity": "warning"
|
|
||||||
}
|
|
Reference in New Issue
Block a user