Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
a1e2cda010 | |||
d409d3a532 | |||
b4dae84835 | |||
20e27c93d9 | |||
117dc6013c | |||
c6bc433a73 | |||
299815838c | |||
e8318cbf2f | |||
ae60053cff | |||
dca3cf1f08 | |||
eaf379b119 | |||
0074938e57 | |||
eed1c75aba | |||
6de2f36964 | |||
76e777a3ac | |||
165cd3737e | |||
2f11d1ba0f | |||
33692ff417 | |||
f408337186 | |||
bd6d574226 | |||
d5c2d167ec | |||
2af6d5a974 | |||
fdba21d60d | |||
c17ebca309 | |||
a014dcf1ab | |||
44bee7bf6f | |||
7841917058 | |||
f5a674f98d | |||
80ece7c093 | |||
39250b3d47 | |||
ed78c0becf | |||
63c103fde5 | |||
88003bde0f | |||
276a0641e8 | |||
b166269cb4 | |||
3ca1b425bf | |||
ffc07da665 | |||
be2adaf259 |
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: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{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 @shipzone/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: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{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 @shipzone/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 @shipzone/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 @shipzone/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 @shipzone/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
|
127
.gitlab-ci.yml
127
.gitlab-ci.yml
@ -1,127 +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
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
audit:
|
|
||||||
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
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# 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:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
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:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
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
|
|
||||||
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
|
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test.ts",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"test/test.ts"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartenv",
|
"gitrepo": "smartenv",
|
||||||
"shortDescription": "store things about your environment and let them travel across modules",
|
"description": "store things about your environment and let them travel across modules",
|
||||||
"npmPackagename": "@pushrocks/smartenv",
|
"npmPackagename": "@push.rocks/smartenv",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4739
package-lock.json
generated
4739
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@ -1,13 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartenv",
|
"name": "@push.rocks/smartenv",
|
||||||
"version": "4.0.9",
|
"version": "5.0.9",
|
||||||
"description": "store things about your environment and let them travel across modules",
|
"description": "store things about your environment and let them travel across modules",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web && tsbundle npm)",
|
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
|
||||||
"testbrowser": "(npm test) && (node testbrowser.js)"
|
"testbrowser": "(npm test) && (node testbrowser.js)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -23,19 +25,16 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartenv",
|
"homepage": "https://gitlab.com/pushrocks/smartenv",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartparam": "^1.1.6",
|
"@push.rocks/smartpromise": "^4.0.2"
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
|
||||||
"@types/node": "^14.0.14",
|
|
||||||
"is-wsl": "^2.2.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.24",
|
"@git.zone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsrun": "^1.2.12",
|
"@git.zone/tsbundle": "^2.0.8",
|
||||||
"@gitzone/tstest": "^1.0.33",
|
"@git.zone/tsrun": "^1.2.44",
|
||||||
"@pushrocks/tapbundle": "^3.2.1",
|
"@git.zone/tstest": "^1.0.77",
|
||||||
"@types/npm": "^2.0.31",
|
"@push.rocks/tapbundle": "^5.0.8",
|
||||||
"tslint": "^6.1.2",
|
"@types/node": "^20.8.2",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"@types/npm": "^7.19.1"
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
"files": [
|
"files": [
|
||||||
@ -49,5 +48,8 @@
|
|||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
5633
pnpm-lock.yaml
generated
Normal file
5633
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
31
readme.md
31
readme.md
@ -1,40 +1,37 @@
|
|||||||
# @pushrocks/smartenv
|
# @push.rocks/smartenv
|
||||||
store things about your environment and let them travel across modules
|
store things about your environment and let them travel across modules
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartenv)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartenv)
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartenv)
|
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartenv)
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartenv)
|
* [github.com (source mirror)](https://github.com/push.rocks/smartenv)
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartenv/)
|
* [docs (typedoc)](https://push.rocks.gitlab.io/smartenv/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
Status Category | Status Badge
|
Status Category | Status Badge
|
||||||
-- | --
|
-- | --
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
npm | [](https://lossless.cloud)
|
npm | [](https://lossless.cloud)
|
||||||
Snyk | [](https://lossless.cloud)
|
Snyk | [](https://lossless.cloud)
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
Code Style | [](https://lossless.cloud)
|
Code Style | [](https://lossless.cloud)
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
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). :)
|
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). :)
|
||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
## Legal
|
||||||
|
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
|
||||||
|
12
test/test.ts
12
test/test.ts
@ -1,5 +1,5 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
import * as smartenv from '../ts/index';
|
import * as smartenv from '../ts/index.js';
|
||||||
|
|
||||||
let testEnv: smartenv.Smartenv;
|
let testEnv: smartenv.Smartenv;
|
||||||
|
|
||||||
@ -17,20 +17,20 @@ tap.test('should get os', async () => {
|
|||||||
const resultWindows = await testEnv.isWindowsAsync();
|
const resultWindows = await testEnv.isWindowsAsync();
|
||||||
const osModule = await import('os');
|
const osModule = await import('os');
|
||||||
if (resultMac) {
|
if (resultMac) {
|
||||||
expect(osModule.platform()).to.equal('darwin');
|
expect(osModule.platform()).toEqual('darwin');
|
||||||
console.log('platform is Mac!');
|
console.log('platform is Mac!');
|
||||||
} else if (resultLinux) {
|
} else if (resultLinux) {
|
||||||
expect(osModule.platform()).to.equal('linux');
|
expect(osModule.platform()).toEqual('linux');
|
||||||
console.log('platform is Linux!');
|
console.log('platform is Linux!');
|
||||||
} else {
|
} else {
|
||||||
expect(osModule.platform()).to.equal('win32');
|
expect(osModule.platform()).toEqual('win32');
|
||||||
console.log('platform is Windows!');
|
console.log('platform is Windows!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should state wether we are in CI', async () => {
|
tap.test('should state wether we are in CI', async () => {
|
||||||
if (process.env.CI) {
|
if (process.env.CI) {
|
||||||
expect(testEnv.isCI).to.be.true;
|
expect(testEnv.isCI).toBeTrue();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartenv',
|
||||||
|
version: '5.0.9',
|
||||||
|
description: 'store things about your environment and let them travel across modules'
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
export * from './smartenv.classes.smartenv';
|
export * from './smartenv.classes.smartenv.js';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from './smartenv.plugins';
|
import * as plugins from './smartenv.plugins.js';
|
||||||
import * as interfaces from './interfaces';
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
|
||||||
// interfaces
|
// interfaces
|
||||||
export interface IEnvObject {
|
export interface IEnvObject {
|
||||||
@ -11,11 +11,68 @@ export interface IEnvObject {
|
|||||||
* Smartenv class that makes it easy
|
* Smartenv class that makes it easy
|
||||||
*/
|
*/
|
||||||
export class Smartenv {
|
export class Smartenv {
|
||||||
|
public async getEnvAwareModule(optionsArg: {
|
||||||
|
nodeModuleName: string;
|
||||||
|
webUrlArg: string;
|
||||||
|
getFunction: () => any;
|
||||||
|
}) {
|
||||||
|
if (this.isNode) {
|
||||||
|
const moduleResult = await this.getSafeNodeModule(optionsArg.nodeModuleName);
|
||||||
|
return moduleResult;
|
||||||
|
} else if (this.isBrowser) {
|
||||||
|
const moduleResult = await this.getSafeWebModule(
|
||||||
|
optionsArg.webUrlArg,
|
||||||
|
optionsArg.getFunction
|
||||||
|
);
|
||||||
|
return moduleResult;
|
||||||
|
} else {
|
||||||
|
console.error('platform for loading not supported by smartenv');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getSafeNodeModule<T = any>(moduleNameArg: string): Promise<T> {
|
||||||
|
if (!this.isNode) {
|
||||||
|
console.error(`You tried to load a node module in a wrong context: ${moduleNameArg}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// tslint:disable-next-line: function-constructor
|
||||||
|
return new Function(`return import('${moduleNameArg}')`)() as Promise<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
public loadedScripts: string[] = [];
|
||||||
|
public async getSafeWebModule(urlArg: string, getFunctionArg: () => any) {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
console.error('You tried to load a web module in a wrong context');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.loadedScripts.includes(urlArg)) {
|
||||||
|
return getFunctionArg();
|
||||||
|
} else {
|
||||||
|
this.loadedScripts.push(urlArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
const done = plugins.smartpromise.defer();
|
||||||
|
if (globalThis.importScripts) {
|
||||||
|
globalThis.importScripts(urlArg);
|
||||||
|
done.resolve();
|
||||||
|
} else {
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.onload = () => {
|
||||||
|
done.resolve();
|
||||||
|
};
|
||||||
|
script.src = urlArg;
|
||||||
|
document.head.appendChild(script);
|
||||||
|
}
|
||||||
|
await done.promise;
|
||||||
|
return getFunctionArg();
|
||||||
|
}
|
||||||
|
|
||||||
public get runtimeEnv() {
|
public get runtimeEnv() {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof process !== 'undefined') {
|
||||||
return 'browser';
|
|
||||||
} else if (typeof process !== 'undefined') {
|
|
||||||
return 'node';
|
return 'node';
|
||||||
|
} else {
|
||||||
|
return 'browser';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,10 +93,6 @@ export class Smartenv {
|
|||||||
return this.runtimeEnv === 'node';
|
return this.runtimeEnv === 'node';
|
||||||
}
|
}
|
||||||
|
|
||||||
public get isWsl(): boolean {
|
|
||||||
return plugins.isWsl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get nodeVersion(): string {
|
public get nodeVersion(): string {
|
||||||
return process.version;
|
return process.version;
|
||||||
}
|
}
|
||||||
@ -58,7 +111,7 @@ export class Smartenv {
|
|||||||
|
|
||||||
public async isMacAsync(): Promise<boolean> {
|
public async isMacAsync(): Promise<boolean> {
|
||||||
if (this.isNode) {
|
if (this.isNode) {
|
||||||
const os = await import('os');
|
const os = await this.getSafeNodeModule('os');
|
||||||
return os.platform() === 'darwin';
|
return os.platform() === 'darwin';
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -67,7 +120,7 @@ export class Smartenv {
|
|||||||
|
|
||||||
public async isWindowsAsync(): Promise<boolean> {
|
public async isWindowsAsync(): Promise<boolean> {
|
||||||
if (this.isNode) {
|
if (this.isNode) {
|
||||||
const os = await import('os');
|
const os = await this.getSafeNodeModule('os');
|
||||||
return os.platform() === 'win32';
|
return os.platform() === 'win32';
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -76,31 +129,20 @@ export class Smartenv {
|
|||||||
|
|
||||||
public async isLinuxAsync(): Promise<boolean> {
|
public async isLinuxAsync(): Promise<boolean> {
|
||||||
if (this.isNode) {
|
if (this.isNode) {
|
||||||
const os = await import('os');
|
const os = await this.getSafeNodeModule('os');
|
||||||
return os.platform() === 'linux';
|
return os.platform() === 'linux';
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* get environment variables that fit the description
|
|
||||||
*/
|
|
||||||
// get envVars (regexArg: RegExp) {
|
|
||||||
// let EnvironmentArray = []
|
|
||||||
// // TODO: plugins.smartparam.forEachMinimatch()
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* prints the environment to console
|
* prints the environment to console
|
||||||
*/
|
*/
|
||||||
public async printEnv() {
|
public async printEnv() {
|
||||||
if (this.isNode) {
|
if (this.isNode) {
|
||||||
console.log('running on NODE');
|
console.log('running on NODE');
|
||||||
const smartenvVersion = require('../package.json').version;
|
console.log('node version is ' + this.nodeVersion);
|
||||||
console.log(
|
|
||||||
'node version is ' + this.nodeVersion + ' and smartenv version is ' + smartenvVersion
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
console.log('running on BROWSER');
|
console.log('running on BROWSER');
|
||||||
console.log('browser is ' + this.userAgent);
|
console.log('browser is ' + this.userAgent);
|
||||||
|
@ -1,12 +1,3 @@
|
|||||||
import * as smartparam from '@pushrocks/smartparam';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
|
||||||
|
|
||||||
export { smartparam, smartpromise };
|
export { smartpromise };
|
||||||
|
|
||||||
// third party scope
|
|
||||||
|
|
||||||
import isWsl from 'is-wsl';
|
|
||||||
|
|
||||||
export {
|
|
||||||
isWsl
|
|
||||||
};
|
|
||||||
|
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