Compare commits

...

62 Commits

Author SHA1 Message Date
f87fa3bf2b update description 2024-05-29 14:16:47 +02:00
8b101369b8 update tsconfig 2024-04-14 18:27:46 +02:00
89d9692701 update tsconfig 2024-04-01 21:41:35 +02:00
69b22df534 update npmextra.json: githost 2024-04-01 19:59:54 +02:00
0b2e88f430 update npmextra.json: githost 2024-03-30 21:48:54 +01:00
dea8ca6021 3.0.1 2022-07-28 22:14:24 +02:00
c5d531fc09 fix(core): update 2022-07-28 22:14:24 +02:00
66db546d67 3.0.0 2022-07-28 22:07:53 +02:00
8956f4be89 BREAKING CHANGE(core): switch to esm 2022-07-28 22:07:52 +02:00
b02ee5e9f4 2.0.10 2021-08-12 23:35:40 +02:00
93153baa95 fix(core): update 2021-08-12 23:35:39 +02:00
b584978287 2.0.9 2019-09-08 15:56:50 +02:00
44bfff2a6b fix(core): update 2019-09-08 15:56:50 +02:00
af07a53053 2.0.8 2019-08-22 15:23:09 +02:00
2ace413435 fix(core): update 2019-08-22 15:23:09 +02:00
16dfec29f4 2.0.7 2019-08-22 13:01:44 +02:00
10ab005343 fix(core): update 2019-08-22 13:01:44 +02:00
9dded0eab5 2.0.6 2019-08-22 02:15:40 +02:00
c54ae3fdb4 fix(core): update 2019-08-22 02:15:40 +02:00
3ae2f9a6b2 2.0.5 2019-08-22 02:14:43 +02:00
48959be97e fix(core): update 2019-08-22 02:14:42 +02:00
658e60475a 2.0.4 2019-08-22 02:14:18 +02:00
f6c64c6583 fix(core): update 2019-08-22 02:14:17 +02:00
e3929a17ed 2.0.3 2019-08-22 01:05:21 +02:00
a4734d9c10 fix(core): update 2019-08-22 01:05:21 +02:00
a1139c5da4 2.0.2 2017-07-31 15:20:43 +02:00
a401fd2e8f update yarn lock 2017-07-31 15:20:38 +02:00
8157371a1d 2.0.1 2017-07-31 15:19:50 +02:00
719a9b32d7 update readme 2017-07-31 15:19:46 +02:00
a732d2a403 2.0.0 2017-07-31 15:17:34 +02:00
11fe4618ba update docs 2017-07-31 15:17:31 +02:00
f4290ca8fa streamline things 2017-07-31 15:16:10 +02:00
04518f28cf 1.0.18 2017-06-30 18:51:44 +02:00
0d6ea31bd2 update to smartq 2017-06-30 18:51:41 +02:00
60bd95093d 1.0.17 2017-05-13 11:16:43 +02:00
05d4e0ff6d add docs 2017-05-13 11:16:39 +02:00
e05f7d32fd 1.0.16 2017-05-13 11:03:40 +02:00
5f0ddc6600 update tests and README 2017-05-13 11:03:24 +02:00
d312d6ae5a 1.0.15 2017-05-13 10:34:38 +02:00
8ca254595d 1.0.14 2017-05-13 10:34:19 +02:00
7661ae506d update ci 2017-05-13 10:34:08 +02:00
4e8dd83839 1.0.13 2017-05-13 10:33:38 +02:00
7ab1a4eec7 update README 2017-05-13 10:33:34 +02:00
3098fbec89 1.0.12 2016-12-11 11:01:07 +01:00
1caa8a7c31 improve README 2016-12-11 11:00:58 +01:00
c689a3c349 update npmextra.json 2016-12-10 22:15:22 +01:00
a8a0778708 1.0.11 2016-12-10 22:12:38 +01:00
82ebb181a0 update README 2016-12-10 22:12:24 +01:00
adabcb3c4a 1.0.10 2016-12-10 19:46:52 +01:00
32db51c49a update to latest standards 2016-12-10 19:46:47 +01:00
62b91adf0e 1.0.9 2016-10-14 04:08:43 +02:00
2f6a56c857 improve README 2016-10-14 04:08:38 +02:00
988cf907a4 1.0.8 2016-10-14 03:28:18 +02:00
18d79cb403 improve README 2016-10-14 03:27:52 +02:00
1d2c073206 1.0.7 2016-10-14 03:24:32 +02:00
fa85e689df add npm as default module loader 2016-10-14 03:24:29 +02:00
e5d18a75f8 1.0.6 2016-10-14 03:07:41 +02:00
87c9556064 now resolving paths with npm 2016-10-14 03:07:37 +02:00
f4b8766dae 1.0.5 2016-10-12 15:41:12 +02:00
ecaaaee54a add keywords, add better path resolution 2016-10-12 15:41:09 +02:00
46693c4bef 1.0.4 2016-10-12 14:15:31 +02:00
cd7361bb96 improve README 2016-10-12 14:15:27 +02:00
23 changed files with 15175 additions and 251 deletions

20
.gitignore vendored
View File

@ -1,4 +1,20 @@
node_modules/ .nogit/
# artifacts
coverage/ coverage/
pages/
public/ public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,53 +1,128 @@
image: hosttoday/ht-docker-node:npmts # gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages: stages:
- test - security
- release - test
- trigger - release
- page - metadata
testLEGACY:
stage: test before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script: script:
- npmci test legacy - npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- docker - docker
allow_failure: true allow_failure: true
testLTS:
stage: test auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script: script:
- npmci test lts - npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags: tags:
- docker - docker
allow_failure: true
testSTABLE:
# ====================
# test stage
# ====================
testStable:
stage: test stage: test
script: script:
- npmci test stable - npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release: release:
stage: release stage: release
script: script:
- npmci publish - npmci node install stable
- npmci npm publish
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
tags:
- lossless
- docker
- priv
trigger: trigger:
stage: trigger stage: metadata
script: script:
- npmci trigger - npmci trigger
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmpage stage: metadata
stage: page
script: script:
- npmci command npmpage --host gitlab - npmci node install stable
- npmci npm prepare
- npmci npm install
- npmci command npm run buildDocs
tags:
- lossless
- docker
- notpriv
only: only:
- tags - tags
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
- public - public
allow_failure: true

11
.vscode/launch.json vendored Normal file
View 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
View 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"]
}
}
}
}
}
}
]
}

View File

@ -1,44 +0,0 @@
# smartsystem
simplifies lazy loading with TypeScript
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartsystem)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartsystem)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartsystem)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartsystem/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartsystem/badges/master/build.svg)](https://gitlab.com/pushrocks/smartsystem/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartsystem/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartsystem/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartsystem.svg)](https://david-dm.org/pushrocks/smartsystem)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartsystem/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartsystem/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartsystem/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartsystem)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
We recommend the use of TypeScript for best Intellisense
```typescript
import { LazyModule } from 'smartsystem'
import * as _myPlugin from 'myPlugin' // plugin does not get loaded here at runtime
let myPluginLazy = new LazyModule<typeof _myPlugin>('myPlugin')
import * as _anotherPlugin from 'anotherPlugin' // plugin does not get loaded here at runtime
let anotherPluginPromised = LazyModule<typeof _anotherPlugin>('anotherPlugin')
myPluginLazy.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 */
})
myPluginLazy.load().then(myPlugin => {
/* do something with myPlugin.
myPlugin receives the typings flow from LazyModule class
This DOES LOAD the module */
})
```

22
dist/index.d.ts vendored
View File

@ -1,22 +0,0 @@
/// <reference types="q" />
import 'typings-global';
import * as q from 'q';
/**
* defines a LazyModule
*/
export declare class LazyModule<T> {
name: string;
nameIsPath: boolean;
cwd: string;
whenLoaded: q.Promise<T>;
private whenLoadedDeferred;
constructor(nameArg: string, cwdArg?: string);
/**
* loads the module
*/
load(): q.Promise<T>;
/**
* loads additional lazy modules specified as arguments and returns them in the promise for easy use
*/
loadAlso(...args: LazyModule<any>[]): void;
}

51
dist/index.js vendored
View File

@ -1,51 +0,0 @@
"use strict";
require("typings-global");
const q = require("q");
const lik_1 = require("lik");
let systemjs = require('systemjs');
class Smartsystem {
constructor() {
this.lazyModules = new lik_1.Objectmap();
}
/**
* add lazyModule to Smartsystem
*/
addLazyModule(lazyModuleArg) {
this.lazyModules.add(lazyModuleArg);
}
}
// create the internal smartsystem
let smartsystem = new Smartsystem();
/**
* defines a LazyModule
*/
class LazyModule {
constructor(nameArg, cwdArg = process.cwd()) {
this.name = nameArg;
this.cwd = cwdArg;
smartsystem.addLazyModule(this); // add module to smartsystem instance
this.nameIsPath = /\.\//.test(this.name); // figure out if name is path
this.whenLoadedDeferred = q.defer();
this.whenLoaded = this.whenLoadedDeferred.promise;
}
/**
* loads the module
*/
load() {
let done = q.defer();
let loadedModule;
systemjs.import(this.name).then((m) => {
loadedModule = m;
this.whenLoadedDeferred.resolve(loadedModule);
done.resolve(loadedModule);
}).catch(err => { console.log(err); });
return done.promise;
}
/**
* loads additional lazy modules specified as arguments and returns them in the promise for easy use
*/
loadAlso(...args) {
}
}
exports.LazyModule = LazyModule;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBRXZCLHVCQUFzQjtBQUN0Qiw2QkFBK0I7QUFDL0IsSUFBSSxRQUFRLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFBO0FBRWxDO0lBQUE7UUFDSSxnQkFBVyxHQUFHLElBQUksZUFBUyxFQUFtQixDQUFBO0lBUWxELENBQUM7SUFORzs7T0FFRztJQUNILGFBQWEsQ0FBQyxhQUE4QjtRQUN4QyxJQUFJLENBQUMsV0FBVyxDQUFDLEdBQUcsQ0FBQyxhQUFhLENBQUMsQ0FBQTtJQUN2QyxDQUFDO0NBQ0o7QUFFRCxrQ0FBa0M7QUFDbEMsSUFBSSxXQUFXLEdBQUcsSUFBSSxXQUFXLEVBQUUsQ0FBQTtBQUVuQzs7R0FFRztBQUNIO0lBTUksWUFBWSxPQUFlLEVBQUUsTUFBTSxHQUFXLE9BQU8sQ0FBQyxHQUFHLEVBQUU7UUFDdkQsSUFBSSxDQUFDLElBQUksR0FBRyxPQUFPLENBQUE7UUFDbkIsSUFBSSxDQUFDLEdBQUcsR0FBRyxNQUFNLENBQUE7UUFDakIsV0FBVyxDQUFDLGFBQWEsQ0FBQyxJQUFJLENBQUMsQ0FBQSxDQUFDLHFDQUFxQztRQUNyRSxJQUFJLENBQUMsVUFBVSxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFBLENBQUMsNkJBQTZCO1FBQ3RFLElBQUksQ0FBQyxrQkFBa0IsR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFLLENBQUE7UUFDdEMsSUFBSSxDQUFDLFVBQVUsR0FBRyxJQUFJLENBQUMsa0JBQWtCLENBQUMsT0FBTyxDQUFBO0lBQ3JELENBQUM7SUFFRDs7T0FFRztJQUNILElBQUk7UUFDQSxJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFLLENBQUE7UUFDdkIsSUFBSSxZQUFlLENBQUE7UUFDbkIsUUFBUSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQztZQUM5QixZQUFZLEdBQUcsQ0FBQyxDQUFBO1lBQ2hCLElBQUksQ0FBQyxrQkFBa0IsQ0FBQyxPQUFPLENBQUMsWUFBWSxDQUFDLENBQUE7WUFDN0MsSUFBSSxDQUFDLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBQTtRQUM5QixDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsR0FBRyxNQUFNLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUEsQ0FBQyxDQUFDLENBQUMsQ0FBQTtRQUNyQyxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUN2QixDQUFDO0lBRUQ7O09BRUc7SUFDSCxRQUFRLENBQUMsR0FBRyxJQUF1QjtJQUVuQyxDQUFDO0NBQ0o7QUFuQ0QsZ0NBbUNDIn0=

31
npmextra.json Normal file
View File

@ -0,0 +1,31 @@
{
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartsystem",
"description": "A TypeScript library for interacting with the system it's running on, including environment, network, and hardware information.",
"npmPackagename": "@push.rocks/smartsystem",
"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"
}
}

14753
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +1,64 @@
{ {
"name": "smartsystem", "name": "@push.rocks/smartsystem",
"version": "1.0.3", "version": "3.0.1",
"description": "wraps systemjs for smarter workflows", "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": "(npmts)" "test": "(tstest test/)",
"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": [
"TypeScript",
"system information",
"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": {
"@types/q": "0.0.32", "@pushrocks/lik": "^6.0.0",
"lik": "^1.0.24", "@pushrocks/smartenv": "^5.0.2",
"q": "^1.4.1", "@pushrocks/smartnetwork": "^3.0.0",
"systemjs": "^0.19.39", "@pushrocks/smartpromise": "^3.1.7",
"typings-global": "^1.0.14" "systeminformation": "^5.12.1"
}, },
"devDependencies": { "devDependencies": {
"@types/should": "^8.1.30", "@gitzone/tsbuild": "^2.1.63",
"should": "^11.1.1", "@gitzone/tstest": "^1.0.72",
"typings-test": "^1.0.3" "@pushrocks/tapbundle": "^5.0.4",
} "tslint": "^6.1.3",
} "tslint-config-prettier": "^1.18.0"
},
"private": false,
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

127
readme.md Normal file
View File

@ -0,0 +1,127 @@
# @push.rocks/smartsystem
interact with the system you are running on
## 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
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.
### Getting Started
First, ensure that you are importing the module correctly in your TypeScript file:
```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();
```
### Accessing Environment Variables
`@push.rocks/smartsystem` integrates with `@pushrocks/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 `@pushrocks/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.

View File

@ -1 +0,0 @@
export declare let exportedTestBoolean: boolean;

View File

@ -1,4 +0,0 @@
"use strict";
exports.exportedTestBoolean = true;
console.log('moduleExample loaded successfully');
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlRXhhbXBsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIm1vZHVsZUV4YW1wbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFXLFFBQUEsbUJBQW1CLEdBQUcsSUFBSSxDQUFBO0FBQ3JDLE9BQU8sQ0FBQyxHQUFHLENBQUMsbUNBQW1DLENBQUMsQ0FBQSJ9

View File

@ -1,2 +0,0 @@
export let exportedTestBoolean = true
console.log('moduleExample loaded successfully')

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

View File

@ -1,13 +0,0 @@
"use strict";
require("typings-test");
const smartsystem = require("../dist/index");
describe('smartsystem', function () {
it('should load a module lazily', function (done) {
let lazyModuleExample = new smartsystem.LazyModule('./test/moduleExample.js');
lazyModuleExample.load().then(m => {
console.log(m.exportedTestBoolean);
done();
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQiw2Q0FBNEM7QUFJNUMsUUFBUSxDQUFDLGFBQWEsRUFBRTtJQUNwQixFQUFFLENBQUMsNkJBQTZCLEVBQUUsVUFBVSxJQUFJO1FBQzVDLElBQUksaUJBQWlCLEdBQUcsSUFBSSxXQUFXLENBQUMsVUFBVSxDQUF3Qix5QkFBeUIsQ0FBQyxDQUFBO1FBRXBHLGlCQUFpQixDQUFDLElBQUksRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDO1lBQzNCLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLG1CQUFtQixDQUFDLENBQUE7WUFDbEMsSUFBSSxFQUFFLENBQUE7UUFDVixDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==

View File

@ -1,16 +1,20 @@
import 'typings-test' import { tap, expect } from '@pushrocks/tapbundle';
import * as should from 'should' import * as smartsystem from '../ts/index.js';
import * as smartsystem from '../dist/index' import { systeminformation } from '../ts/smartsystem.plugins.js';
import * as _moduleExample from './moduleExample' let smartsystemInstance: smartsystem.Smartsystem;
describe('smartsystem', function () { tap.test('should create a smartsystem instance', async (tools) => {
it('should load a module lazily', function (done) { smartsystemInstance = new smartsystem.Smartsystem();
let lazyModuleExample = new smartsystem.LazyModule<typeof _moduleExample>('./test/moduleExample.js') expect(smartsystemInstance).toBeInstanceOf(smartsystem.Smartsystem);
});
lazyModuleExample.load().then(m => { tap.test('should state the operating system', async () => {
console.log(m.exportedTestBoolean) expect(smartsystemInstance.cpus.length).toBeGreaterThan(0);
done() });
})
}) tap.test('should get systeminformation', async () => {
}) console.log(await smartsystemInstance.information.networkInterfaceDefault());
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartsystem',
version: '3.0.1',
description: 'interact with the system you are running on'
}

View File

@ -1,59 +1,10 @@
import 'typings-global' import * as plugins from './smartsystem.plugins.js';
import * as q from 'q' export class Smartsystem {
import { Objectmap } from 'lik' public env = new plugins.smartenv.Smartenv();
let systemjs = require('systemjs') public cpus = plugins.os.cpus();
public network = new plugins.smartnetwork.SmartNetwork();
class Smartsystem { public get information() {
lazyModules = new Objectmap<LazyModule<any>>() return plugins.systeminformation;
}
/**
* add lazyModule to Smartsystem
*/
addLazyModule(lazyModuleArg: LazyModule<any>) {
this.lazyModules.add(lazyModuleArg)
}
} }
// create the internal smartsystem
let smartsystem = new Smartsystem()
/**
* defines a LazyModule
*/
export class LazyModule<T> {
name: string
nameIsPath: boolean
cwd: string
whenLoaded: q.Promise<T>
private whenLoadedDeferred: q.Deferred<T>
constructor(nameArg: string, cwdArg: string = process.cwd()) {
this.name = nameArg
this.cwd = cwdArg
smartsystem.addLazyModule(this) // add module to smartsystem instance
this.nameIsPath = /\.\//.test(this.name) // figure out if name is path
this.whenLoadedDeferred = q.defer<T>()
this.whenLoaded = this.whenLoadedDeferred.promise
}
/**
* loads the module
*/
load(): q.Promise<T> {
let done = q.defer<T>()
let loadedModule: T
systemjs.import(this.name).then((m) => {
loadedModule = m
this.whenLoadedDeferred.resolve(loadedModule)
done.resolve(loadedModule)
}).catch(err => { console.log(err) })
return done.promise
}
/**
* loads additional lazy modules specified as arguments and returns them in the promise for easy use
*/
loadAlso(...args: LazyModule<any>[]) {
}
}

16
ts/smartsystem.plugins.ts Normal file
View File

@ -0,0 +1,16 @@
// node native
import os from 'os';
export { os };
import * as lik from '@pushrocks/lik';
import * as smartenv from '@pushrocks/smartenv';
import * as smartnetwork from '@pushrocks/smartnetwork';
import * as smartpromise from '@pushrocks/smartpromise';
export { lik, smartenv, smartnetwork, smartpromise };
// third party
import * as systeminformation from 'systeminformation';
export { systeminformation };

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

View File

@ -1,3 +0,0 @@
{
"extends": "tslint-config-standard"
}