Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
bc19c21949 | |||
dba1855eb6 | |||
db01586eb9 | |||
172fce2466 | |||
f7f009e0d4 | |||
e5111f0433 | |||
554a7d9647 | |||
76d30b7618 | |||
eee90810da | |||
5bf7d19bf7 | |||
2fa6da38c6 | |||
e11157fe44 | |||
28d99ecb77 | |||
d8f409c191 | |||
bcfa3be58b |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm publish
|
||||
|
||||
metadata:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,7 +3,6 @@
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
@ -17,4 +16,4 @@ node_modules/
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
||||
#------# custom
|
141
.gitlab-ci.yml
141
.gitlab-ci.yml
@ -1,141 +0,0 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- npm install -g @shipzone/npmci
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- 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:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- 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:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- 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:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
193
changelog.md
Normal file
193
changelog.md
Normal file
@ -0,0 +1,193 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-04-28 - 3.0.4 - fix(ci/config)
|
||||
Improve CI workflows, update project configuration, and clean up code formatting
|
||||
|
||||
- Added new Gitea workflow files (default_nottags.yaml and default_tags.yaml) to replace GitLab CI
|
||||
- Updated package.json with new buildDocs script, revised homepage URL, bug tracking info, and pnpm overrides
|
||||
- Refined code formatting in TypeScript files, including improved error handling in Cloudflare speed tests and consistent callback structure
|
||||
- Enhanced tsconfig.json by adding baseUrl and paths for better module resolution
|
||||
- Introduced readme.plan.md outlining future improvements and feature enhancements
|
||||
|
||||
## 2025-04-28 - 3.0.3 - fix(deps)
|
||||
Update dependency namespaces and bump package versions in CI configuration and source imports
|
||||
|
||||
- Renamed dependency imports from '@pushrocks/...' to '@push.rocks/...' in package.json, test files, and source files
|
||||
- Updated devDependencies versions and package references (e.g., tsbuild, tsrun, tstest, smartenv, tapbundle, smartpromise, smartstring, public-ip, and @types packages)
|
||||
- Fixed CI command to install '@git.zone/tsdoc' instead of the misspelled '@gitzone/tsdoc'
|
||||
- Updated commit info file to reflect the correct package namespace
|
||||
|
||||
## 2024-05-29 - 3.0.2 - misc
|
||||
Various documentation, configuration, and organizational updates.
|
||||
- Updated project description.
|
||||
- Updated tsconfig configuration.
|
||||
- Updated npmextra.json (githost configuration) across multiple commits.
|
||||
- Switched to a new organizational scheme.
|
||||
|
||||
## 2022-10-22 - 3.0.1 - core
|
||||
Core fixes and maintenance applied.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2022-10-21 - 3.0.0 - core
|
||||
Core updates and fixes.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2022-03-24 - 2.0.14 - core
|
||||
Breaking changes introduced.
|
||||
- BREAKING CHANGE: Switched core to an ECMAScript Modules (ESM) approach.
|
||||
|
||||
## 2022-02-16 - 2.0.13 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2022-02-16 - 2.0.12 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2022-02-16 - 2.0.11 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2022-02-16 - 2.0.10 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2021-04-29 - 2.0.9 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2021-04-28 - 2.0.8 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2021-04-28 - 2.0.7 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2021-04-28 - 2.0.6 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2021-04-28 - 2.0.5 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2021-04-27 - 2.0.4 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2021-04-13 - 2.0.3 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2021-04-13 - 2.0.2 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2021-04-13 - 2.0.1 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2021-04-13 - 2.0.0 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2021-04-13 - 1.1.22 - core
|
||||
Breaking update in core functionality.
|
||||
- BREAKING CHANGE: Updated core functionality.
|
||||
|
||||
## 2020-08-13 - 1.1.21 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2020-08-13 - 1.1.20 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2020-08-12 - 1.1.19 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2020-08-12 - 1.1.18 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-11-23 - 1.1.17 - minor
|
||||
Release with no notable changes.
|
||||
- No significant changes.
|
||||
|
||||
## 2019-11-23 - 1.1.16 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-11-19 - 1.1.15 - security
|
||||
Security enhancement.
|
||||
- Added Snyk configuration for improved security.
|
||||
|
||||
## 2019-11-19 - 1.1.14 - dependencies
|
||||
Dependency update.
|
||||
- Updated dependencies.
|
||||
|
||||
## 2019-09-08 - 1.1.13 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-09-08 - 1.1.12 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-09-08 - 1.1.11 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-09-08 - 1.1.10 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-09-08 - 1.1.9 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-09-06 - 1.1.8 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-09-06 - 1.1.7 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-09-06 - 1.1.6 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-04-17 - 1.1.5 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-04-17 - 1.1.4 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-04-17 - 1.1.3 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-04-17 - 1.1.2 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-04-16 - 1.1.1 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2019-04-16 - 1.1.0 - core
|
||||
Core maintenance update.
|
||||
- Fixed core issues.
|
||||
|
||||
## 2018-07-17 - 1.0.2 - feature
|
||||
New feature added.
|
||||
- Added port checking functionality.
|
||||
|
||||
## 2017-12-12 - 1.0.1 - initial
|
||||
Initial commit.
|
||||
- Initial project setup.
|
@ -6,12 +6,27 @@
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartnetwork",
|
||||
"description": "network diagnostics",
|
||||
"npmPackagename": "@pushrocks/smartnetwork",
|
||||
"license": "MIT"
|
||||
"description": "A toolkit for network diagnostics including speed tests, port availability checks, and more.",
|
||||
"npmPackagename": "@push.rocks/smartnetwork",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"network diagnostics",
|
||||
"ping",
|
||||
"port check",
|
||||
"speed test",
|
||||
"network interface",
|
||||
"public IP retrieval",
|
||||
"Cloudflare speed test",
|
||||
"network performance",
|
||||
"network utility",
|
||||
"TypeScript"
|
||||
]
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
18396
package-lock.json
generated
18396
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
55
package.json
55
package.json
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@pushrocks/smartnetwork",
|
||||
"version": "3.0.0",
|
||||
"name": "@push.rocks/smartnetwork",
|
||||
"version": "3.0.4",
|
||||
"private": false,
|
||||
"description": "network diagnostics",
|
||||
"description": "A toolkit for network diagnostics including speed tests, port availability checks, and more.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
@ -10,21 +10,24 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.61",
|
||||
"@gitzone/tstest": "^1.0.69",
|
||||
"@pushrocks/smartenv": "^5.0.0",
|
||||
"@pushrocks/tapbundle": "^5.0.3"
|
||||
"@git.zone/tsbuild": "^2.1.61",
|
||||
"@git.zone/tsrun": "^1.2.39",
|
||||
"@git.zone/tstest": "^1.0.69",
|
||||
"@push.rocks/smartenv": "^5.0.0",
|
||||
"@push.rocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^22.15.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smartstring": "^4.0.2",
|
||||
"@types/default-gateway": "^3.0.1",
|
||||
"icmp": "^2.0.1",
|
||||
"@push.rocks/smartping": "^1.0.7",
|
||||
"@push.rocks/smartpromise": "^4.2.3",
|
||||
"@push.rocks/smartstring": "^4.0.2",
|
||||
"@types/default-gateway": "^7.2.2",
|
||||
"isopen": "^1.3.0",
|
||||
"public-ip": "^4.0.4",
|
||||
"public-ip": "^7.0.1",
|
||||
"systeminformation": "^5.11.9"
|
||||
},
|
||||
"files": [
|
||||
@ -41,5 +44,29 @@
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
],
|
||||
"keywords": [
|
||||
"network diagnostics",
|
||||
"ping",
|
||||
"port check",
|
||||
"speed test",
|
||||
"network interface",
|
||||
"public IP retrieval",
|
||||
"Cloudflare speed test",
|
||||
"network performance",
|
||||
"network utility",
|
||||
"TypeScript"
|
||||
],
|
||||
"homepage": "https://code.foss.global/push.rocks/smartnetwork#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://code.foss.global/push.rocks/smartnetwork.git"
|
||||
},
|
||||
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6",
|
||||
"bugs": {
|
||||
"url": "https://code.foss.global/push.rocks/smartnetwork/issues"
|
||||
},
|
||||
"pnpm": {
|
||||
"overrides": {}
|
||||
}
|
||||
}
|
||||
|
9958
pnpm-lock.yaml
generated
Normal file
9958
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
183
readme.md
183
readme.md
@ -1,61 +1,150 @@
|
||||
# @pushrocks/smartnetwork
|
||||
# @push.rocks/smartnetwork
|
||||
|
||||
network diagnostics
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartnetwork)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartnetwork)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/smartnetwork)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartnetwork/)
|
||||
## Install
|
||||
|
||||
## Status for master
|
||||
To install `@push.rocks/smartnetwork`, run the following command in your terminal:
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
```bash
|
||||
npm install @push.rocks/smartnetwork --save
|
||||
```
|
||||
|
||||
This command will download `@push.rocks/smartnetwork` and add it to your project's `package.json` file.
|
||||
|
||||
## Usage
|
||||
|
||||
In this section, we will dive deep into the capabilities of the `@push.rocks/smartnetwork` package, exploring its various features through TypeScript examples. The package is designed to simplify network diagnostics tasks, including speed tests, port availability checks, ping operations, and more.
|
||||
|
||||
### Basic Setup
|
||||
|
||||
First, import the package into your project:
|
||||
|
||||
```typescript
|
||||
import * as smartnetwork from 'smartnetwork';
|
||||
const testSmartNetwork = new smartnetwork.SmartNetwork();
|
||||
const run = async () => {
|
||||
// measure average speed over a period of 5 seconds
|
||||
// the structure of speedResult is self explanatory using TypeScript (or the linked TypeDoc above)
|
||||
const speedResult: smartnetwork.SpeedResult = testSmartNetwork.getSpeed(5000);
|
||||
|
||||
// you can check for local ports before trying to bind to it from your nodejs program
|
||||
const isLocalPortUnused: boolean = await testSmartNetwork.isLocalPortUnused(1234);
|
||||
|
||||
// you can run basic port checks on remote domains.
|
||||
const isRemotePortAvailable: boolean = await testSmartNetwork.isRemotePortAvailable(
|
||||
'google.com:80'
|
||||
);
|
||||
|
||||
// just another way to call for the same thing as above
|
||||
const isRemotePortAvailable: boolean = await testSmartNetwork.isRemotePortAvailable(
|
||||
'google.com',
|
||||
80
|
||||
);
|
||||
};
|
||||
import { SmartNetwork } from '@push.rocks/smartnetwork';
|
||||
```
|
||||
|
||||
## Contribution
|
||||
Then, create an instance of `SmartNetwork`:
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
```typescript
|
||||
const myNetwork = new SmartNetwork();
|
||||
```
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
### Performing a Speed Test
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
You can measure the network speed using the `getSpeed` method. This feature leverages Cloudflare's speed test capabilities to assess your internet connection's download and upload speeds.
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
```typescript
|
||||
const speedTest = async () => {
|
||||
const speedResult = await myNetwork.getSpeed();
|
||||
console.log(`Download speed: ${speedResult.downloadSpeed} Mbps`);
|
||||
console.log(`Upload speed: ${speedResult.uploadSpeed} Mbps`);
|
||||
console.log(`Latency: ${speedResult.averageTime} ms`);
|
||||
};
|
||||
|
||||
speedTest();
|
||||
```
|
||||
|
||||
### Checking Port Availability Locally
|
||||
|
||||
The `isLocalPortUnused` method allows you to check if a specific port on your local machine is available for use.
|
||||
|
||||
```typescript
|
||||
const checkLocalPort = async (port: number) => {
|
||||
const isUnused = await myNetwork.isLocalPortUnused(port);
|
||||
if (isUnused) {
|
||||
console.log(`Port ${port} is available.`);
|
||||
} else {
|
||||
console.log(`Port ${port} is in use.`);
|
||||
}
|
||||
};
|
||||
|
||||
checkLocalPort(8080); // Example port number
|
||||
```
|
||||
|
||||
### Checking Remote Port Availability
|
||||
|
||||
To verify if a certain port is available on a remote server, use `isRemotePortAvailable`. This can help determine if a service is up and reachable.
|
||||
|
||||
```typescript
|
||||
const checkRemotePort = async (hostname: string, port: number) => {
|
||||
const isAvailable = await myNetwork.isRemotePortAvailable(hostname, port);
|
||||
if (isAvailable) {
|
||||
console.log(`Port ${port} on ${hostname} is available.`);
|
||||
} else {
|
||||
console.log(`Port ${port} on ${hostname} is not available.`);
|
||||
}
|
||||
};
|
||||
|
||||
checkRemotePort('example.com', 443); // Checking HTTPS port on example.com
|
||||
```
|
||||
|
||||
### Using Ping
|
||||
|
||||
The `ping` method allows you to send ICMP packets to a host to measure round-trip time and determine if the host is reachable.
|
||||
|
||||
```typescript
|
||||
const pingHost = async (hostname: string) => {
|
||||
const pingResult = await myNetwork.ping(hostname);
|
||||
if (pingResult.alive) {
|
||||
console.log(`${hostname} is reachable. RTT: ${pingResult.time} ms`);
|
||||
} else {
|
||||
console.log(`${hostname} is not reachable.`);
|
||||
}
|
||||
};
|
||||
|
||||
pingHost('google.com');
|
||||
```
|
||||
|
||||
### Getting Network Gateways
|
||||
|
||||
You can also retrieve information about your network gateways, including the default gateway used by your machine.
|
||||
|
||||
```typescript
|
||||
const showGateways = async () => {
|
||||
const gateways = await myNetwork.getGateways();
|
||||
console.log(gateways);
|
||||
|
||||
const defaultGateway = await myNetwork.getDefaultGateway();
|
||||
console.log(`Default Gateway: `, defaultGateway);
|
||||
};
|
||||
|
||||
showGateways();
|
||||
```
|
||||
|
||||
### Discovering Public IP Addresses
|
||||
|
||||
To find out your public IPv4 and IPv6 addresses, the following method can be used:
|
||||
|
||||
```typescript
|
||||
const showPublicIps = async () => {
|
||||
const publicIps = await myNetwork.getPublicIps();
|
||||
console.log(`Public IPv4: ${publicIps.v4}`);
|
||||
console.log(`Public IPv6: ${publicIps.v6}`);
|
||||
};
|
||||
|
||||
showPublicIps();
|
||||
```
|
||||
|
||||
The `@push.rocks/smartnetwork` package provides an easy-to-use, comprehensive suite of tools for network diagnostics and monitoring, encapsulating complex network operations into simple asynchronous methods. By leveraging TypeScript, developers can benefit from type checking, ensuring that they can work with clear structures and expectations.
|
||||
|
||||
These examples offer a glimpse into the module's utility in real-world scenarios, demonstrating its versatility in handling common network tasks. Whether you're developing a network-sensitive application, diagnosing connectivity issues, or simply curious about your network performance, `@push.rocks/smartnetwork` equips you with the tools you need.
|
||||
|
||||
## 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.
|
||||
|
47
readme.plan.md
Normal file
47
readme.plan.md
Normal file
@ -0,0 +1,47 @@
|
||||
# Plan to Enhance Code Quality, Feature Set & Documentation
|
||||
|
||||
This plan focuses on three pillars to elevate `@push.rocks/smartnetwork`: 1) Code Quality, 2) Feature Enhancements, and 3) Documentation.
|
||||
|
||||
## 1. Code Quality Improvements
|
||||
- Enable strict TypeScript (`strict`, `noImplicitAny`, `strictNullChecks`).
|
||||
- Enforce linting (ESLint) and formatting (Prettier) with pre-commit hooks.
|
||||
- Audit and refactor core modules for:
|
||||
- Clear separation of concerns (IO, business logic, helpers).
|
||||
- Removal of duplicated logic and dead code.
|
||||
- Consistent use of async/await and error propagation.
|
||||
- Introduce custom error classes (e.g., `NetworkError`, `TimeoutError`) for predictable failure handling.
|
||||
- Augment logging support via injectable logger interface.
|
||||
- Establish a baseline of ≥90% unit-test coverage and enforce via CI.
|
||||
|
||||
## 2. Feature Enhancements
|
||||
- Expand diagnostics:
|
||||
- Traceroute functionality with hop-by-hop latency.
|
||||
- DNS lookup (A, AAAA, MX records).
|
||||
- HTTP(s) endpoint health check (status codes, headers, latency).
|
||||
- Improve existing methods:
|
||||
- `getSpeed`: allow configurable test duration and parallel streams.
|
||||
- `ping`: add statistical summary (min, max, stddev) and continuous mode.
|
||||
- `isRemotePortAvailable`: support TCP/UDP checks with timeout and retry.
|
||||
- Introduce plugin architecture:
|
||||
- Define `Plugin` interface for third-party extensions.
|
||||
- Enable runtime registration/unregistration.
|
||||
- Provide sample plugins (e.g., custom ping strategies, alternate speed providers).
|
||||
- Optional in-memory caching with TTL for expensive calls (`getPublicIps`, `getGateways`).
|
||||
|
||||
## 3. Documentation & Examples
|
||||
- Upgrade README:
|
||||
- Detailed API reference with method signatures and option parameters.
|
||||
- Real-world usage snippets and full example projects.
|
||||
- Add TSDoc comments to all public classes, methods, and types.
|
||||
- Create a `docs/` folder with:
|
||||
- Getting Started guide.
|
||||
- Advanced topics (plugin development, custom error handling).
|
||||
- FAQ and troubleshooting section.
|
||||
- Integrate TypeDoc for automated documentation site generation.
|
||||
- Update `CONTRIBUTING.md` and `CHANGELOG.md` to reflect development and release practices.
|
||||
|
||||
## Next Steps
|
||||
1. Review and prioritize high-impact items per pillar.
|
||||
2. Kick off Phase 1 (Code Quality) with linting, TS config, and core refactor.
|
||||
3. Schedule sprints for Feature and Documentation phases.
|
||||
4. Configure CI pipeline to enforce quality gates and publish docs.
|
@ -1,4 +1,4 @@
|
||||
import { tap, expect, expectAsync } from '@pushrocks/tapbundle';
|
||||
import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
|
||||
|
||||
import * as smartnetwork from '../ts/index.js';
|
||||
|
||||
@ -10,9 +10,16 @@ tap.test('should create a vlid instance of SmartNetwork', async () => {
|
||||
});
|
||||
|
||||
tap.test('should send a ping to Google', async () => {
|
||||
expectAsync(testSmartnetwork.ping('https://lossless.com')).toBeTrue();
|
||||
expectAsync(testSmartnetwork.ping('https://notthere.lossless.com')).toBeTrue();
|
||||
expectAsync(testSmartnetwork.ping('192.168.186.999')).toBeFalse();
|
||||
console.log(await testSmartnetwork.ping('google.com'));
|
||||
await expectAsync(testSmartnetwork.ping('google.com')).property('alive').toBeTrue();
|
||||
});
|
||||
|
||||
tap.test('should state when a ping is not alive ', async () => {
|
||||
await expectAsync(testSmartnetwork.ping('notthere.lossless.com')).property('alive').toBeFalse();
|
||||
});
|
||||
|
||||
tap.test('should send a ping to an IP', async () => {
|
||||
await expectAsync(testSmartnetwork.ping('192.168.186.999')).property('alive').toBeFalse();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
||||
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
||||
import * as smartnetwork from '../ts/index.js';
|
||||
|
||||
let testSmartNetwork: smartnetwork.SmartNetwork;
|
||||
|
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/smartnetwork',
|
||||
version: '3.0.4',
|
||||
description: 'A toolkit for network diagnostics including speed tests, port availability checks, and more.'
|
||||
}
|
@ -50,7 +50,7 @@ export class CloudflareSpeed {
|
||||
},
|
||||
(error) => {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ export class CloudflareSpeed {
|
||||
},
|
||||
(error) => {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ export class CloudflareSpeed {
|
||||
},
|
||||
(error) => {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ export class CloudflareSpeed {
|
||||
req.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
req.end();
|
||||
|
@ -16,17 +16,13 @@ export class SmartNetwork {
|
||||
return test;
|
||||
}
|
||||
|
||||
public async ping(hostArg: string, timeoutArg: number = 500): Promise<boolean> {
|
||||
if (process.getuid() !== 0) {
|
||||
console.log('icmp not allowed for nonroot!');
|
||||
return;
|
||||
}
|
||||
const result = await plugins.icmp.ping(hostArg, timeoutArg).catch();
|
||||
if (result) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public async ping(
|
||||
hostArg: string,
|
||||
timeoutArg: number = 500,
|
||||
): Promise<ReturnType<typeof plugins.smartping.Smartping.prototype.ping>> {
|
||||
const smartpingInstance = new plugins.smartping.Smartping();
|
||||
const pingResult = await smartpingInstance.ping(hostArg, timeoutArg);
|
||||
return pingResult;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,10 +123,22 @@ export class SmartNetwork {
|
||||
|
||||
public async getPublicIps() {
|
||||
return {
|
||||
v4: await plugins.publicIp.v4({
|
||||
timeout: 1000,
|
||||
onlyHttps: true,
|
||||
}),
|
||||
v4: await plugins.publicIp
|
||||
.publicIpv4({
|
||||
timeout: 1000,
|
||||
onlyHttps: true,
|
||||
})
|
||||
.catch(async (err) => {
|
||||
return null;
|
||||
}),
|
||||
v6: await plugins.publicIp
|
||||
.publicIpv6({
|
||||
timeout: 1000,
|
||||
onlyHttps: true,
|
||||
})
|
||||
.catch(async (err) => {
|
||||
return null;
|
||||
}),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,18 +6,17 @@ import * as perfHooks from 'perf_hooks';
|
||||
export { os, https, perfHooks };
|
||||
|
||||
// @pushrocks scope
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
import * as smartping from '@push.rocks/smartping';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartstring from '@push.rocks/smartstring';
|
||||
|
||||
export { smartpromise, smartstring };
|
||||
export { smartpromise, smartping, smartstring };
|
||||
|
||||
// @third party scope
|
||||
// @ts-ignore
|
||||
import isopen from 'isopen';
|
||||
// @ts-ignore
|
||||
import icmp from 'icmp';
|
||||
// @ts-ignore
|
||||
import publicIp from 'public-ip';
|
||||
import * as publicIp from 'public-ip';
|
||||
import * as systeminformation from 'systeminformation';
|
||||
|
||||
export { isopen, icmp, publicIp, systeminformation };
|
||||
export { isopen, publicIp, systeminformation };
|
||||
|
@ -3,7 +3,14 @@
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
}
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {}
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user