Compare commits
76 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ce338e27ea | ||
b4897d238f | |||
df69e46697 | |||
1493430d9f | |||
78afde963b | |||
a4a633e936 | |||
27fbe00cb0 | |||
f3cc468eda | |||
b303799b8d | |||
590ed5b180 | |||
ddcf52de19 | |||
c1b3af09ef | |||
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 | |||
7aa9637826 | |||
a3c4f87741 | |||
f005f57764 | |||
6e418cdbf8 | |||
87155900e1 | |||
d24b11f737 | |||
17ebd58951 | |||
32bd229f91 | |||
4e5ddf8411 | |||
701c7c1b8b | |||
9a272def16 | |||
0213950aae | |||
b7342dbf05 | |||
677c8d33b9 | |||
ffc781011d | |||
aeec1b36a3 | |||
4c2e7f9446 | |||
dddad457f3 | |||
4f110c6e64 | |||
12d971c470 | |||
886c245e8d | |||
50d610e5df | |||
5edb62c134 | |||
38f22a6d95 | |||
|
91cdb71388 | ||
ab33e97c8d |
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
|
26
.gitignore
vendored
26
.gitignore
vendored
@@ -1,14 +1,20 @@
|
||||
node_modules/
|
||||
.settings/
|
||||
.idea/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
docs/
|
||||
public/
|
||||
pages/
|
||||
|
||||
#npm devug
|
||||
npm-debug.log
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
ts/typings/
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
test/browser/browserified/
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
@@ -1,71 +0,0 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .yarn/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: pages
|
||||
script:
|
||||
- npmci command yarn global add npmpage
|
||||
- npmci command npmpage --publish gitlab
|
||||
tags:
|
||||
- docker
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
29
README.md
29
README.md
@@ -1,29 +0,0 @@
|
||||
# smartenv
|
||||
store things about your environment and let them travel across modules
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/smartenv)
|
||||
[](https://GitLab.com/pushrocks/smartenv)
|
||||
[](https://github.com/pushrocks/smartenv)
|
||||
[](https://pushrocks.gitlab.io/smartenv/)
|
||||
|
||||
## Status for master
|
||||
[](https://GitLab.com/pushrocks/smartenv/commits/master)
|
||||
[](https://GitLab.com/pushrocks/smartenv/commits/master)
|
||||
[](https://www.npmjs.com/package/smartenv)
|
||||
[](https://david-dm.org/pushrocks/smartenv)
|
||||
[](https://www.bithound.io/github/pushrocks/smartenv/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartenv)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://push.rocks)
|
8
changelog.md
Normal file
8
changelog.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
## [5.0.13] - 2025-07-28
|
||||
|
||||
### Fixed
|
||||
- Updated readme.md with comprehensive documentation including API reference, core features, and usage examples
|
||||
- Added readme.hints.md with architecture and implementation details for future reference
|
||||
- Improved documentation structure and clarity
|
3
dist/index.d.ts
vendored
3
dist/index.d.ts
vendored
@@ -1,3 +0,0 @@
|
||||
import { getEnv, printEnv, getEnvVars } from './smartenv.export';
|
||||
import { obs } from './smartenv.objectstorage';
|
||||
export { getEnv, getEnvVars, printEnv, obs };
|
9
dist/index.js
vendored
9
dist/index.js
vendored
@@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const smartenv_export_1 = require("./smartenv.export");
|
||||
exports.getEnv = smartenv_export_1.getEnv;
|
||||
exports.printEnv = smartenv_export_1.printEnv;
|
||||
exports.getEnvVars = smartenv_export_1.getEnvVars;
|
||||
const smartenv_objectstorage_1 = require("./smartenv.objectstorage");
|
||||
exports.obs = smartenv_objectstorage_1.obs;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHVEQUE4RDtBQUs1RCxpQkFMTSx3QkFBTSxDQUtOO0FBRU4sbUJBUGMsMEJBQVEsQ0FPZDtBQURSLHFCQU53Qiw0QkFBVSxDQU14QjtBQUxaLHFFQUE4QztBQU81QyxjQVBPLDRCQUFHLENBT1AifQ==
|
11
dist/smartenv.classes.environment.d.ts
vendored
11
dist/smartenv.classes.environment.d.ts
vendored
@@ -1,11 +0,0 @@
|
||||
export declare class Environment {
|
||||
runtimeEnv: string;
|
||||
isBrowser: boolean;
|
||||
userAgent: string;
|
||||
isNode: boolean;
|
||||
nodeVersion: string;
|
||||
isCI: boolean;
|
||||
isTravis: boolean;
|
||||
isC9: boolean;
|
||||
constructor();
|
||||
}
|
18
dist/smartenv.classes.environment.js
vendored
18
dist/smartenv.classes.environment.js
vendored
@@ -1,18 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const helpers = require("./smartenv.envhelpers");
|
||||
class Environment {
|
||||
constructor() {
|
||||
this.runtimeEnv = helpers.getEnvString();
|
||||
this.isBrowser = helpers.isBrowser();
|
||||
this.userAgent = helpers.getUserAgentString();
|
||||
this.isNode = helpers.isNode();
|
||||
this.nodeVersion = helpers.getNodeVersion();
|
||||
this.isCI = helpers.isCI();
|
||||
this.isTravis = helpers.isTravis();
|
||||
this.isC9 = helpers.isC9();
|
||||
}
|
||||
;
|
||||
}
|
||||
exports.Environment = Environment;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuY2xhc3Nlcy5lbnZpcm9ubWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LmNsYXNzZXMuZW52aXJvbm1lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxpREFBaUQ7QUFFakQ7SUFTRTtRQUNFLElBQUksQ0FBQyxVQUFVLEdBQUcsT0FBTyxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQ3hDLElBQUksQ0FBQyxTQUFTLEdBQUcsT0FBTyxDQUFDLFNBQVMsRUFBRSxDQUFBO1FBQ3BDLElBQUksQ0FBQyxTQUFTLEdBQUcsT0FBTyxDQUFDLGtCQUFrQixFQUFFLENBQUE7UUFDN0MsSUFBSSxDQUFDLE1BQU0sR0FBRyxPQUFPLENBQUMsTUFBTSxFQUFFLENBQUE7UUFDOUIsSUFBSSxDQUFDLFdBQVcsR0FBRyxPQUFPLENBQUMsY0FBYyxFQUFFLENBQUE7UUFDM0MsSUFBSSxDQUFDLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxFQUFFLENBQUE7UUFDMUIsSUFBSSxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUMsUUFBUSxFQUFFLENBQUE7UUFDbEMsSUFBSSxDQUFDLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxFQUFFLENBQUE7SUFDNUIsQ0FBQztJQUFBLENBQUM7Q0FDSDtBQW5CRCxrQ0FtQkMifQ==
|
8
dist/smartenv.envhelpers.d.ts
vendored
8
dist/smartenv.envhelpers.d.ts
vendored
@@ -1,8 +0,0 @@
|
||||
export declare let getEnvString: () => string;
|
||||
export declare let getUserAgentString: () => string;
|
||||
export declare let isNode: () => boolean;
|
||||
export declare let getNodeVersion: () => string;
|
||||
export declare let isBrowser: () => boolean;
|
||||
export declare let isCI: () => boolean;
|
||||
export declare let isC9: () => boolean;
|
||||
export declare let isTravis: () => boolean;
|
54
dist/smartenv.envhelpers.js
vendored
54
dist/smartenv.envhelpers.js
vendored
@@ -1,54 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getEnvString = function () {
|
||||
if (typeof window !== 'undefined') {
|
||||
return 'browser';
|
||||
}
|
||||
else if (typeof process !== 'undefined') {
|
||||
return 'node';
|
||||
}
|
||||
};
|
||||
exports.getUserAgentString = function () {
|
||||
if (exports.isBrowser()) {
|
||||
return navigator.userAgent;
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
exports.isNode = function () {
|
||||
return exports.getEnvString() === 'node';
|
||||
};
|
||||
exports.getNodeVersion = function () {
|
||||
return process.version;
|
||||
};
|
||||
exports.isBrowser = function () {
|
||||
return !exports.isNode();
|
||||
};
|
||||
exports.isCI = function () {
|
||||
if (process.env.CI) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
;
|
||||
};
|
||||
exports.isC9 = function () {
|
||||
if (process.env.C9_HOSTNAME) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
exports.isTravis = function () {
|
||||
if (process.env.TRAVIS) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuZW52aGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LmVudmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFDVyxRQUFBLFlBQVksR0FBRztJQUN4QixFQUFFLENBQUMsQ0FBQyxPQUFPLE1BQU0sS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQ2xDLE1BQU0sQ0FBQyxTQUFTLENBQUE7SUFDbEIsQ0FBQztJQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxPQUFPLE9BQU8sS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQzFDLE1BQU0sQ0FBQyxNQUFNLENBQUE7SUFDZixDQUFDO0FBQ0gsQ0FBQyxDQUFBO0FBRVUsUUFBQSxrQkFBa0IsR0FBRztJQUM5QixFQUFFLENBQUMsQ0FBQyxpQkFBUyxFQUFFLENBQUMsQ0FBQyxDQUFDO1FBQ2hCLE1BQU0sQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFBO0lBQzVCLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNOLE1BQU0sQ0FBQyxTQUFTLENBQUE7SUFDbEIsQ0FBQztBQUNILENBQUMsQ0FBQTtBQUVVLFFBQUEsTUFBTSxHQUFHO0lBQ2xCLE1BQU0sQ0FBQyxvQkFBWSxFQUFFLEtBQUssTUFBTSxDQUFBO0FBQ2xDLENBQUMsQ0FBQTtBQUVVLFFBQUEsY0FBYyxHQUFHO0lBQzFCLE1BQU0sQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFBO0FBQ3hCLENBQUMsQ0FBQTtBQUVVLFFBQUEsU0FBUyxHQUFHO0lBQ3JCLE1BQU0sQ0FBQyxDQUFDLGNBQU0sRUFBRSxDQUFBO0FBQ2xCLENBQUMsQ0FBQTtBQUVVLFFBQUEsSUFBSSxHQUFHO0lBQ2hCLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUNuQixNQUFNLENBQUMsSUFBSSxDQUFBO0lBQ2IsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ04sTUFBTSxDQUFDLEtBQUssQ0FBQTtJQUNkLENBQUM7SUFBQSxDQUFDO0FBQ0osQ0FBQyxDQUFBO0FBRVUsUUFBQSxJQUFJLEdBQUc7SUFDaEIsRUFBRSxDQUFDLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQzVCLE1BQU0sQ0FBQyxJQUFJLENBQUE7SUFDYixDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDTixNQUFNLENBQUMsS0FBSyxDQUFBO0lBQ2QsQ0FBQztBQUNILENBQUMsQ0FBQTtBQUVVLFFBQUEsUUFBUSxHQUFHO0lBQ3BCLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztRQUN2QixNQUFNLENBQUMsSUFBSSxDQUFBO0lBQ2IsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ04sTUFBTSxDQUFDLEtBQUssQ0FBQTtJQUNkLENBQUM7SUFBQSxDQUFDO0FBQ0osQ0FBQyxDQUFBIn0=
|
15
dist/smartenv.export.d.ts
vendored
15
dist/smartenv.export.d.ts
vendored
@@ -1,15 +0,0 @@
|
||||
import * as classes from './smartenv.classes.environment';
|
||||
/**
|
||||
* returns the environment
|
||||
* @returns {Environment}
|
||||
*/
|
||||
export declare let getEnv: () => classes.Environment;
|
||||
/**
|
||||
* prints the environment to console
|
||||
*/
|
||||
export declare let printEnv: () => void;
|
||||
export interface IEnvObject {
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
export declare let getEnvVars: (regexArg: RegExp) => Promise<IEnvObject[]>;
|
53
dist/smartenv.export.js
vendored
53
dist/smartenv.export.js
vendored
@@ -1,53 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const classes = require("./smartenv.classes.environment");
|
||||
const objectStorage = require("./smartenv.objectstorage");
|
||||
let environment = null;
|
||||
/**
|
||||
* returns the environment
|
||||
* @returns {Environment}
|
||||
*/
|
||||
exports.getEnv = function () {
|
||||
if (!environment) {
|
||||
environment = new classes.Environment();
|
||||
}
|
||||
;
|
||||
return environment;
|
||||
};
|
||||
/**
|
||||
* prints the environment to console
|
||||
*/
|
||||
exports.printEnv = function () {
|
||||
if (this.getEnv().isNode) {
|
||||
console.log('running on NODE');
|
||||
let smartenvVersion = require('../package.json').version;
|
||||
console.log('node version is ' + this.getEnv().nodeVersion + ' and smartenv version is ' + smartenvVersion);
|
||||
}
|
||||
else {
|
||||
console.log('running on BROWSER');
|
||||
console.log('browser is ' + this.getEnv().userAgent);
|
||||
}
|
||||
console.log('the smartenv registration store currently holds the following properties:');
|
||||
console.log(Object.getOwnPropertyNames(objectStorage.obs.getAll()));
|
||||
};
|
||||
exports.getEnvVars = (regexArg) => __awaiter(this, void 0, void 0, function* () {
|
||||
let resultArray = [];
|
||||
for (let key in process.env) {
|
||||
if (regexArg.test(key)) {
|
||||
resultArray.push({
|
||||
name: key,
|
||||
value: process.env[key]
|
||||
});
|
||||
}
|
||||
}
|
||||
return resultArray;
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuZXhwb3J0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRlbnYuZXhwb3J0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFJQSwwREFBeUQ7QUFDekQsMERBQXlEO0FBR3pELElBQUksV0FBVyxHQUF3QixJQUFJLENBQUE7QUFFM0M7OztHQUdHO0FBQ1EsUUFBQSxNQUFNLEdBQUc7SUFDbEIsRUFBRSxDQUFDLENBQUMsQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQ2pCLFdBQVcsR0FBRyxJQUFJLE9BQU8sQ0FBQyxXQUFXLEVBQUUsQ0FBQTtJQUN6QyxDQUFDO0lBQUEsQ0FBQztJQUNGLE1BQU0sQ0FBQyxXQUFXLENBQUE7QUFDcEIsQ0FBQyxDQUFBO0FBSUQ7O0dBRUc7QUFDUSxRQUFBLFFBQVEsR0FBRztJQUNwQixFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztRQUN6QixPQUFPLENBQUMsR0FBRyxDQUFDLGlCQUFpQixDQUFDLENBQUE7UUFDOUIsSUFBSSxlQUFlLEdBQUcsT0FBTyxDQUFDLGlCQUFpQixDQUFDLENBQUMsT0FBTyxDQUFBO1FBQ3hELE9BQU8sQ0FBQyxHQUFHLENBQUMsa0JBQWtCLEdBQUcsSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDLFdBQVcsR0FBRywyQkFBMkIsR0FBRyxlQUFlLENBQUMsQ0FBQTtJQUM3RyxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDTixPQUFPLENBQUMsR0FBRyxDQUFDLG9CQUFvQixDQUFDLENBQUE7UUFDakMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxhQUFhLEdBQUcsSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQ3RELENBQUM7SUFDRCxPQUFPLENBQUMsR0FBRyxDQUFDLDJFQUEyRSxDQUFDLENBQUE7SUFDeEYsT0FBTyxDQUFDLEdBQUcsQ0FBQyxNQUFNLENBQUMsbUJBQW1CLENBQUMsYUFBYSxDQUFDLEdBQUcsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDLENBQUE7QUFDckUsQ0FBQyxDQUFBO0FBT1UsUUFBQSxVQUFVLEdBQUcsQ0FBTyxRQUFnQjtJQUM3QyxJQUFJLFdBQVcsR0FBaUIsRUFBRSxDQUFBO0lBQ2xDLEdBQUcsQ0FBQyxDQUFDLElBQUksR0FBRyxJQUFJLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO1FBQzVCLEVBQUUsQ0FBQyxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ3ZCLFdBQVcsQ0FBQyxJQUFJLENBQUM7Z0JBQ2YsSUFBSSxFQUFFLEdBQUc7Z0JBQ1QsS0FBSyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDO2FBQ3hCLENBQUMsQ0FBQTtRQUNKLENBQUM7SUFDSCxDQUFDO0lBQ0QsTUFBTSxDQUFDLFdBQVcsQ0FBQTtBQUNwQixDQUFDLENBQUEsQ0FBQSJ9
|
5
dist/smartenv.objectstorage.d.ts
vendored
5
dist/smartenv.objectstorage.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
export declare let obsItems: any;
|
||||
/**
|
||||
* Objectstorage allows easy sharing of objects within node
|
||||
*/
|
||||
export declare let obs: any;
|
47
dist/smartenv.objectstorage.js
vendored
47
dist/smartenv.objectstorage.js
vendored
@@ -1,47 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const plugins = require("./smartenv.plugins");
|
||||
exports.obsItems = {};
|
||||
/**
|
||||
* Objectstorage allows easy sharing of objects within node
|
||||
*/
|
||||
exports.obs = {
|
||||
add: (keyNameArg, objectArg) => {
|
||||
if (!keyNameArg) {
|
||||
console.log('keyName is undefined');
|
||||
return;
|
||||
}
|
||||
if (!objectArg) {
|
||||
console.log('objectArg is undefined');
|
||||
}
|
||||
if (!(exports.obsItems[keyNameArg])) {
|
||||
exports.obsItems[keyNameArg] = objectArg;
|
||||
}
|
||||
else {
|
||||
console.log('object is already present, so add operation has failed.');
|
||||
}
|
||||
return exports.obsItems[keyNameArg];
|
||||
},
|
||||
replace: function (paramNameArg, objectArg) {
|
||||
exports.obsItems[paramNameArg] = objectArg;
|
||||
},
|
||||
merge: function (paramNameArg, objectArg) {
|
||||
if (!(typeof exports.obsItems[paramNameArg] === 'undefined')) {
|
||||
exports.obsItems[paramNameArg] = plugins.lodash.assign(exports.obsItems[paramNameArg], objectArg);
|
||||
}
|
||||
else {
|
||||
console.log('object is not present, so there is nothing to merge');
|
||||
}
|
||||
},
|
||||
get: function (keyName) {
|
||||
return exports.obsItems[keyName];
|
||||
},
|
||||
getAll: function () {
|
||||
return exports.obsItems;
|
||||
},
|
||||
addComplete: function (itemsArg) {
|
||||
exports.obsItems = plugins.lodash.assign(exports.obsItems, itemsArg);
|
||||
return exports.obsItems;
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYub2JqZWN0c3RvcmFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52Lm9iamVjdHN0b3JhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSw4Q0FBOEM7QUFFbkMsUUFBQSxRQUFRLEdBQVEsRUFBRSxDQUFBO0FBRTdCOztHQUVHO0FBQ1EsUUFBQSxHQUFHLEdBQVE7SUFDcEIsR0FBRyxFQUFFLENBQUMsVUFBVSxFQUFFLFNBQVM7UUFDekIsRUFBRSxDQUFDLENBQUMsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDO1lBQ2hCLE9BQU8sQ0FBQyxHQUFHLENBQUMsc0JBQXNCLENBQUMsQ0FBQTtZQUNuQyxNQUFNLENBQUE7UUFDUixDQUFDO1FBQ0QsRUFBRSxDQUFDLENBQUMsQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDO1lBQ2YsT0FBTyxDQUFDLEdBQUcsQ0FBQyx3QkFBd0IsQ0FBQyxDQUFBO1FBQ3ZDLENBQUM7UUFDRCxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUMsZ0JBQVEsQ0FBRSxVQUFVLENBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUM5QixnQkFBUSxDQUFFLFVBQVUsQ0FBRSxHQUFHLFNBQVMsQ0FBQTtRQUNwQyxDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDTixPQUFPLENBQUMsR0FBRyxDQUFDLHlEQUF5RCxDQUFDLENBQUE7UUFDeEUsQ0FBQztRQUNELE1BQU0sQ0FBQyxnQkFBUSxDQUFFLFVBQVUsQ0FBRSxDQUFBO0lBQy9CLENBQUM7SUFDRCxPQUFPLEVBQUUsVUFBVSxZQUFZLEVBQUUsU0FBUztRQUN4QyxnQkFBUSxDQUFFLFlBQVksQ0FBRSxHQUFHLFNBQVMsQ0FBQTtJQUN0QyxDQUFDO0lBQ0QsS0FBSyxFQUFFLFVBQVUsWUFBWSxFQUFFLFNBQVM7UUFDdEMsRUFBRSxDQUFDLENBQUMsQ0FBQyxDQUFDLE9BQU8sZ0JBQVEsQ0FBRSxZQUFZLENBQUUsS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDdkQsZ0JBQVEsQ0FBRSxZQUFZLENBQUUsR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxnQkFBUSxDQUFFLFlBQVksQ0FBRSxFQUFFLFNBQVMsQ0FBQyxDQUFBO1FBQ3ZGLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNOLE9BQU8sQ0FBQyxHQUFHLENBQUMscURBQXFELENBQUMsQ0FBQTtRQUNwRSxDQUFDO0lBQ0gsQ0FBQztJQUNELEdBQUcsRUFBRSxVQUFVLE9BQU87UUFDcEIsTUFBTSxDQUFDLGdCQUFRLENBQUUsT0FBTyxDQUFFLENBQUE7SUFDNUIsQ0FBQztJQUNELE1BQU0sRUFBRTtRQUNOLE1BQU0sQ0FBQyxnQkFBUSxDQUFBO0lBQ2pCLENBQUM7SUFDRCxXQUFXLEVBQUUsVUFBVSxRQUFRO1FBQzdCLGdCQUFRLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsZ0JBQVEsRUFBRSxRQUFRLENBQUMsQ0FBQTtRQUNwRCxNQUFNLENBQUMsZ0JBQVEsQ0FBQTtJQUNqQixDQUFDO0NBQ0YsQ0FBQSJ9
|
4
dist/smartenv.plugins.d.ts
vendored
4
dist/smartenv.plugins.d.ts
vendored
@@ -1,4 +0,0 @@
|
||||
import 'typings-global';
|
||||
import * as smartq from 'smartq';
|
||||
import * as lodash from 'lodash';
|
||||
export { smartq, lodash };
|
8
dist/smartenv.plugins.js
vendored
8
dist/smartenv.plugins.js
vendored
@@ -1,8 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
const smartq = require("smartq");
|
||||
exports.smartq = smartq;
|
||||
const lodash = require("lodash");
|
||||
exports.lodash = lodash;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIsaUNBQWdDO0FBSTVCLHdCQUFNO0FBSFYsaUNBQWdDO0FBSTVCLHdCQUFNIn0=
|
@@ -1,7 +1,32 @@
|
||||
{
|
||||
"npmci": {
|
||||
"globalNpmTools": [
|
||||
"npmts"
|
||||
]
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartenv",
|
||||
"description": "A module for storing and accessing environment details across different platforms.",
|
||||
"npmPackagename": "@push.rocks/smartenv",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"environment detection",
|
||||
"cross-platform",
|
||||
"node.js",
|
||||
"browser",
|
||||
"module loading",
|
||||
"CI detection",
|
||||
"OS detection",
|
||||
"runtime environment",
|
||||
"typescript",
|
||||
"async"
|
||||
]
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"mode":"default",
|
||||
"coverageTreshold":75
|
||||
}
|
62
package.json
62
package.json
@@ -1,33 +1,63 @@
|
||||
{
|
||||
"name": "smartenv",
|
||||
"version": "2.0.6",
|
||||
"description": "store things about your environment and let them travel across modules",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"name": "@push.rocks/smartenv",
|
||||
"version": "5.0.13",
|
||||
"description": "A module for storing and accessing environment details across different platforms.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "(npmts)",
|
||||
"testbrowser": "(npm test) && (node testbrowser.js)"
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
|
||||
"testbrowser": "(npm test) && (node testbrowser.js)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitlab.com/pushrocks/smartenv.git"
|
||||
"url": "https://code.foss.global/push.rocks/smartenv.git"
|
||||
},
|
||||
"keywords": [
|
||||
"environment"
|
||||
"environment detection",
|
||||
"cross-platform",
|
||||
"node.js",
|
||||
"browser",
|
||||
"module loading",
|
||||
"CI detection",
|
||||
"OS detection",
|
||||
"runtime environment",
|
||||
"typescript",
|
||||
"async"
|
||||
],
|
||||
"author": "Lossless GmbH <hello@lossless.support> (https://lossless.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/smartenv/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartenv",
|
||||
"homepage": "https://code.foss.global/push.rocks/smartenv",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.4",
|
||||
"smartq": "^1.1.1",
|
||||
"typings-global": "^1.0.14"
|
||||
"@push.rocks/smartpromise": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"beautylog": "^6.1.5",
|
||||
"tapbundle": "^1.0.5"
|
||||
}
|
||||
"@git.zone/tsbuild": "^2.1.72",
|
||||
"@git.zone/tsbundle": "^2.0.15",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
"@git.zone/tstest": "^2.3.2",
|
||||
"@types/node": "^22.0.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"
|
||||
],
|
||||
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
|
||||
}
|
||||
|
8935
pnpm-lock.yaml
generated
Normal file
8935
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
readme.hints.md
Normal file
23
readme.hints.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# SmartEnv Hints
|
||||
|
||||
## Architecture Overview
|
||||
- Single main class `Smartenv` that provides all functionality
|
||||
- Uses dependency injection pattern with plugins imported from smartenv.plugins.ts
|
||||
- Utilizes @push.rocks/smartpromise for async operations
|
||||
|
||||
## Key Implementation Details
|
||||
- Runtime detection based on checking if `process` is defined
|
||||
- Dynamic module loading using Function constructor for Node.js modules
|
||||
- Script tag injection for browser module loading with duplicate prevention
|
||||
- OS detection uses the native Node.js 'os' module loaded dynamically
|
||||
|
||||
## Testing Approach
|
||||
- Tests use @git.zone/tstest with tap-based testing
|
||||
- Test file demonstrates OS detection and CI environment detection
|
||||
- Tests can run in both Node.js and browser environments
|
||||
|
||||
## Important Notes
|
||||
- The `getSafeNodeModule` uses dynamic import via Function constructor to avoid bundler issues
|
||||
- Browser module loading tracks loaded scripts to prevent duplicate loads
|
||||
- All OS detection methods are async and return false in browser environments
|
||||
- The package is isomorphic and designed for use in both Node.js and browser contexts
|
256
readme.md
Normal file
256
readme.md
Normal file
@@ -0,0 +1,256 @@
|
||||
# @push.rocks/smartenv
|
||||
|
||||
A cross-platform TypeScript library for detecting and managing runtime environments. It provides comprehensive environment detection capabilities and safe module loading for both Node.js and browser contexts.
|
||||
|
||||
## Install
|
||||
|
||||
To install `@push.rocks/smartenv`, you need Node.js and pnpm installed. Then, run the following command:
|
||||
|
||||
```bash
|
||||
pnpm install @push.rocks/smartenv --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`@push.rocks/smartenv` is a powerful utility for managing and accessing environment-specific information within your application. It enables your code to adapt seamlessly to different environments such as development, testing, and production.
|
||||
|
||||
### Getting Started
|
||||
|
||||
First, import the `Smartenv` class from the package:
|
||||
|
||||
```typescript
|
||||
import { Smartenv } from '@push.rocks/smartenv';
|
||||
```
|
||||
|
||||
### Initializing Smartenv
|
||||
|
||||
Create an instance of `Smartenv` to access all environment detection and module loading features:
|
||||
|
||||
```typescript
|
||||
const smartEnv = new Smartenv();
|
||||
```
|
||||
|
||||
## Core Features
|
||||
|
||||
- **Runtime Environment Detection**: Instantly detect whether your code is running in Node.js or browser
|
||||
- **Operating System Detection**: Identify Mac, Windows, or Linux platforms in Node.js environments
|
||||
- **CI Environment Detection**: Detect if running in a continuous integration environment
|
||||
- **Safe Module Loading**: Load modules conditionally based on the runtime environment
|
||||
- **Browser Information**: Access user agent information in browser contexts
|
||||
- **Node.js Version**: Get the current Node.js version when running in Node.js
|
||||
|
||||
## API Reference
|
||||
|
||||
### Environment Detection
|
||||
|
||||
#### `isNode: boolean`
|
||||
Returns `true` if running in a Node.js environment.
|
||||
|
||||
```typescript
|
||||
if (smartEnv.isNode) {
|
||||
console.log('Running in Node.js');
|
||||
}
|
||||
```
|
||||
|
||||
#### `isBrowser: boolean`
|
||||
Returns `true` if running in a browser environment.
|
||||
|
||||
```typescript
|
||||
if (smartEnv.isBrowser) {
|
||||
console.log('Running in browser');
|
||||
}
|
||||
```
|
||||
|
||||
#### `runtimeEnv: string`
|
||||
Returns the runtime environment as a string ('node' or 'browser').
|
||||
|
||||
```typescript
|
||||
console.log(`Runtime: ${smartEnv.runtimeEnv}`);
|
||||
```
|
||||
|
||||
#### `isCI: boolean`
|
||||
Returns `true` if running in a CI environment (checks for CI environment variable).
|
||||
|
||||
```typescript
|
||||
if (smartEnv.isCI) {
|
||||
console.log('Running in CI environment');
|
||||
}
|
||||
```
|
||||
|
||||
### Platform Detection (Node.js only)
|
||||
|
||||
#### `isMacAsync(): Promise<boolean>`
|
||||
Asynchronously checks if running on macOS.
|
||||
|
||||
```typescript
|
||||
const isMac = await smartEnv.isMacAsync();
|
||||
if (isMac) {
|
||||
console.log('Running on macOS');
|
||||
}
|
||||
```
|
||||
|
||||
#### `isWindowsAsync(): Promise<boolean>`
|
||||
Asynchronously checks if running on Windows.
|
||||
|
||||
```typescript
|
||||
const isWindows = await smartEnv.isWindowsAsync();
|
||||
if (isWindows) {
|
||||
console.log('Running on Windows');
|
||||
}
|
||||
```
|
||||
|
||||
#### `isLinuxAsync(): Promise<boolean>`
|
||||
Asynchronously checks if running on Linux.
|
||||
|
||||
```typescript
|
||||
const isLinux = await smartEnv.isLinuxAsync();
|
||||
if (isLinux) {
|
||||
console.log('Running on Linux');
|
||||
}
|
||||
```
|
||||
|
||||
### Runtime Information
|
||||
|
||||
#### `nodeVersion: string`
|
||||
Returns the Node.js version (only available in Node.js environment).
|
||||
|
||||
```typescript
|
||||
if (smartEnv.isNode) {
|
||||
console.log(`Node.js version: ${smartEnv.nodeVersion}`);
|
||||
}
|
||||
```
|
||||
|
||||
#### `userAgent: string`
|
||||
Returns the browser user agent string (only available in browser environment).
|
||||
|
||||
```typescript
|
||||
if (smartEnv.isBrowser) {
|
||||
console.log(`Browser: ${smartEnv.userAgent}`);
|
||||
}
|
||||
```
|
||||
|
||||
### Module Loading
|
||||
|
||||
#### `getEnvAwareModule(options)`
|
||||
Loads a module appropriate for the current environment. In Node.js, it uses dynamic import; in browsers, it loads a script via URL.
|
||||
|
||||
```typescript
|
||||
const module = await smartEnv.getEnvAwareModule({
|
||||
nodeModuleName: 'node-fetch',
|
||||
webUrlArg: 'https://unpkg.com/whatwg-fetch@3.6.2/dist/fetch.umd.js',
|
||||
getFunction: () => window.fetch
|
||||
});
|
||||
```
|
||||
|
||||
#### `getSafeNodeModule<T>(moduleName, runAfterFunc?)`
|
||||
Safely loads a Node.js module with error handling. Only works in Node.js environment.
|
||||
|
||||
```typescript
|
||||
const fs = await smartEnv.getSafeNodeModule('fs');
|
||||
if (fs) {
|
||||
// Use fs module
|
||||
}
|
||||
|
||||
// With post-load function
|
||||
const express = await smartEnv.getSafeNodeModule('express', async (mod) => {
|
||||
console.log('Express loaded successfully');
|
||||
});
|
||||
```
|
||||
|
||||
#### `getSafeWebModule(url, getFunction)`
|
||||
Safely loads a web module via script tag. Only works in browser environment. Prevents duplicate loading of the same script.
|
||||
|
||||
```typescript
|
||||
const jQuery = await smartEnv.getSafeWebModule(
|
||||
'https://code.jquery.com/jquery-3.6.0.min.js',
|
||||
() => window.jQuery
|
||||
);
|
||||
```
|
||||
|
||||
### Debugging
|
||||
|
||||
#### `printEnv()`
|
||||
Prints the current environment information to the console for debugging purposes.
|
||||
|
||||
```typescript
|
||||
await smartEnv.printEnv();
|
||||
// Output in Node.js: "running on NODE" + version
|
||||
// Output in browser: "running on BROWSER" + user agent
|
||||
```
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
### 1. Isomorphic Module Loading
|
||||
|
||||
```typescript
|
||||
// Define environment-specific implementations
|
||||
const cryptoModule = await smartEnv.getEnvAwareModule({
|
||||
nodeModuleName: 'crypto',
|
||||
webUrlArg: 'https://unpkg.com/crypto-js@4.1.1/crypto-js.js',
|
||||
getFunction: () => window.CryptoJS
|
||||
});
|
||||
```
|
||||
|
||||
### 2. Platform-Specific Operations
|
||||
|
||||
```typescript
|
||||
if (smartEnv.isNode) {
|
||||
const os = await smartEnv.getSafeNodeModule('os');
|
||||
console.log(`Home directory: ${os.homedir()}`);
|
||||
} else {
|
||||
console.log('Browser environment - no filesystem access');
|
||||
}
|
||||
```
|
||||
|
||||
### 3. CI/CD Pipeline Detection
|
||||
|
||||
```typescript
|
||||
if (smartEnv.isCI) {
|
||||
// Run extended tests or different build configuration
|
||||
console.log('Running in CI - enabling extended test suite');
|
||||
} else {
|
||||
console.log('Local development environment');
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Dynamic Script Loading in Browser
|
||||
|
||||
```typescript
|
||||
if (smartEnv.isBrowser) {
|
||||
// Load analytics only in browser
|
||||
await smartEnv.getSafeWebModule(
|
||||
'https://www.google-analytics.com/analytics.js',
|
||||
() => window.ga
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## TypeScript Support
|
||||
|
||||
The package is written in TypeScript and provides full type definitions. The main type export is:
|
||||
|
||||
```typescript
|
||||
export interface IEnvObject {
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
```
|
||||
|
||||
## 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.
|
61
test/test.ts
61
test/test.ts
@@ -1,38 +1,37 @@
|
||||
import * as smartenv from '../dist/index.js'
|
||||
import * as beautylog from 'beautylog'
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import * as smartenv from '../ts/index.js';
|
||||
|
||||
import { tap, expect } from 'tapbundle'
|
||||
let testEnv: smartenv.Smartenv;
|
||||
|
||||
tap.test('should print env', async () => {
|
||||
smartenv.printEnv()
|
||||
}).catch(tap.threw)
|
||||
testEnv = new smartenv.Smartenv();
|
||||
});
|
||||
|
||||
// test smartenv.obs.add
|
||||
tap.test('obs add something', async () => {
|
||||
smartenv.obs.add('myTestObject', { key1: 'Peter' })
|
||||
smartenv.obs.add('myTestObject', { key1: 'Klaus' }) // now trying to add a second
|
||||
return expect(smartenv.obs.get('myTestObject').key1).to.equal('Peter')
|
||||
})
|
||||
tap.test('should print a overview to console', async () => {
|
||||
testEnv.printEnv();
|
||||
});
|
||||
|
||||
// test smartenv.obs.replace
|
||||
tap.test('', async () => {
|
||||
smartenv.obs.replace('myTestObject', { key1: 'Klaus' })
|
||||
expect(smartenv.obs.get('myTestObject').key1).to.equal('Klaus')
|
||||
})
|
||||
tap.test('should get os', async () => {
|
||||
const resultMac = await testEnv.isMacAsync();
|
||||
const resultLinux = await testEnv.isLinuxAsync();
|
||||
const resultWindows = await testEnv.isWindowsAsync();
|
||||
const osModule = await import('os');
|
||||
if (resultMac) {
|
||||
expect(osModule.platform()).toEqual('darwin');
|
||||
console.log('platform is Mac!');
|
||||
} else if (resultLinux) {
|
||||
expect(osModule.platform()).toEqual('linux');
|
||||
console.log('platform is Linux!');
|
||||
} else {
|
||||
expect(osModule.platform()).toEqual('win32');
|
||||
console.log('platform is Windows!');
|
||||
}
|
||||
});
|
||||
|
||||
tap.test('should merge things', async () => {
|
||||
smartenv.obs.merge('myTestObject', { key2: 'Peter' })
|
||||
expect(smartenv.obs.get('myTestObject').key1).to.equal('Klaus')
|
||||
return expect(smartenv.obs.get('myTestObject').key2).to.equal('Peter')
|
||||
})
|
||||
tap.test('should state wether we are in CI', async () => {
|
||||
if (process.env.CI) {
|
||||
expect(testEnv.isCI).toBeTrue();
|
||||
}
|
||||
});
|
||||
|
||||
tap.test('set via get', async () => {
|
||||
smartenv.obs.get('myTestObject').key2 = 'hello'
|
||||
return expect(smartenv.obs.get('myTestObject').key2).to.equal('hello')
|
||||
})
|
||||
|
||||
tap.test('should get regex env array', async () => {
|
||||
process.env.CUSTOM = 'some'
|
||||
let resultArray = await smartenv.getEnvVars(/CUSTOM/)
|
||||
return expect(resultArray).to.be.length(1)
|
||||
})
|
||||
tap.start();
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartenv',
|
||||
version: '5.0.12',
|
||||
description: 'store things about your environment and let them travel across modules'
|
||||
}
|
11
ts/index.ts
11
ts/index.ts
@@ -1,10 +1 @@
|
||||
import {getEnv, printEnv, getEnvVars} from './smartenv.export'
|
||||
import { obs } from './smartenv.objectstorage'
|
||||
|
||||
|
||||
export {
|
||||
getEnv,
|
||||
getEnvVars,
|
||||
printEnv,
|
||||
obs
|
||||
}
|
||||
export * from './smartenv.classes.smartenv.js';
|
||||
|
9
ts/interfaces/index.ts
Normal file
9
ts/interfaces/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export let defaultme = null;
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
window: any;
|
||||
navigator: any;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
import helpers = require('./smartenv.envhelpers')
|
||||
|
||||
export class Environment {
|
||||
runtimeEnv: string
|
||||
isBrowser: boolean
|
||||
userAgent: string
|
||||
isNode: boolean
|
||||
nodeVersion: string
|
||||
isCI: boolean
|
||||
isTravis: boolean
|
||||
isC9: boolean
|
||||
constructor () {
|
||||
this.runtimeEnv = helpers.getEnvString()
|
||||
this.isBrowser = helpers.isBrowser()
|
||||
this.userAgent = helpers.getUserAgentString()
|
||||
this.isNode = helpers.isNode()
|
||||
this.nodeVersion = helpers.getNodeVersion()
|
||||
this.isCI = helpers.isCI()
|
||||
this.isTravis = helpers.isTravis()
|
||||
this.isC9 = helpers.isC9()
|
||||
};
|
||||
}
|
155
ts/smartenv.classes.smartenv.ts
Normal file
155
ts/smartenv.classes.smartenv.ts
Normal file
@@ -0,0 +1,155 @@
|
||||
import * as plugins from './smartenv.plugins.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
|
||||
// interfaces
|
||||
export interface IEnvObject {
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Smartenv class that makes it easy
|
||||
*/
|
||||
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, runAfterFunc?: (moduleArg: T) => Promise<any>): Promise<T> {
|
||||
if (!this.isNode) {
|
||||
console.error(`You tried to load a node module in a wrong context: ${moduleNameArg}. This does not throw.`);
|
||||
return;
|
||||
}
|
||||
// tslint:disable-next-line: function-constructor
|
||||
const returnValue: T = await (new Function(`return import('${moduleNameArg}')`)() as Promise<T>);
|
||||
if (runAfterFunc) {
|
||||
await runAfterFunc(returnValue);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
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() {
|
||||
if (typeof process !== 'undefined') {
|
||||
return 'node';
|
||||
} else {
|
||||
return 'browser';
|
||||
}
|
||||
}
|
||||
|
||||
public get isBrowser(): boolean {
|
||||
return !this.isNode;
|
||||
}
|
||||
|
||||
public get userAgent(): string {
|
||||
if (this.isBrowser) {
|
||||
// make sure we are in Browser
|
||||
return navigator.userAgent;
|
||||
} else {
|
||||
return 'undefined';
|
||||
}
|
||||
}
|
||||
|
||||
public get isNode(): boolean {
|
||||
return this.runtimeEnv === 'node';
|
||||
}
|
||||
|
||||
public get nodeVersion(): string {
|
||||
return process.version;
|
||||
}
|
||||
|
||||
public get isCI(): boolean {
|
||||
if (this.isNode) {
|
||||
if (process.env.CI) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async isMacAsync(): Promise<boolean> {
|
||||
if (this.isNode) {
|
||||
const os = await this.getSafeNodeModule('os');
|
||||
return os.platform() === 'darwin';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async isWindowsAsync(): Promise<boolean> {
|
||||
if (this.isNode) {
|
||||
const os = await this.getSafeNodeModule('os');
|
||||
return os.platform() === 'win32';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async isLinuxAsync(): Promise<boolean> {
|
||||
if (this.isNode) {
|
||||
const os = await this.getSafeNodeModule('os');
|
||||
return os.platform() === 'linux';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* prints the environment to console
|
||||
*/
|
||||
public async printEnv() {
|
||||
if (this.isNode) {
|
||||
console.log('running on NODE');
|
||||
console.log('node version is ' + this.nodeVersion);
|
||||
} else {
|
||||
console.log('running on BROWSER');
|
||||
console.log('browser is ' + this.userAgent);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,52 +0,0 @@
|
||||
import * as plugins from './smartenv.plugins'
|
||||
export let getEnvString = function (): string {
|
||||
if (typeof window !== 'undefined') {
|
||||
return 'browser'
|
||||
} else if (typeof process !== 'undefined') {
|
||||
return 'node'
|
||||
}
|
||||
}
|
||||
|
||||
export let getUserAgentString = function (): string {
|
||||
if (isBrowser()) {
|
||||
return navigator.userAgent
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
export let isNode = function (): boolean {
|
||||
return getEnvString() === 'node'
|
||||
}
|
||||
|
||||
export let getNodeVersion = function (): string {
|
||||
return process.version
|
||||
}
|
||||
|
||||
export let isBrowser = function (): boolean {
|
||||
return !isNode()
|
||||
}
|
||||
|
||||
export let isCI = function () {
|
||||
if (process.env.CI) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
};
|
||||
}
|
||||
|
||||
export let isC9 = function () {
|
||||
if (process.env.C9_HOSTNAME) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export let isTravis = function () {
|
||||
if (process.env.TRAVIS) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
};
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
/**
|
||||
* Deals with the environment the current JS script is running in.
|
||||
*/
|
||||
import * as plugins from './smartenv.plugins'
|
||||
import * as classes from './smartenv.classes.environment'
|
||||
import * as objectStorage from './smartenv.objectstorage'
|
||||
|
||||
|
||||
let environment: classes.Environment = null
|
||||
|
||||
/**
|
||||
* returns the environment
|
||||
* @returns {Environment}
|
||||
*/
|
||||
export let getEnv = function () {
|
||||
if (!environment) {
|
||||
environment = new classes.Environment()
|
||||
};
|
||||
return environment
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* prints the environment to console
|
||||
*/
|
||||
export let printEnv = function () {
|
||||
if (this.getEnv().isNode) {
|
||||
console.log('running on NODE')
|
||||
let smartenvVersion = require('../package.json').version
|
||||
console.log('node version is ' + this.getEnv().nodeVersion + ' and smartenv version is ' + smartenvVersion)
|
||||
} else {
|
||||
console.log('running on BROWSER')
|
||||
console.log('browser is ' + this.getEnv().userAgent)
|
||||
}
|
||||
console.log('the smartenv registration store currently holds the following properties:')
|
||||
console.log(Object.getOwnPropertyNames(objectStorage.obs.getAll()))
|
||||
}
|
||||
|
||||
export interface IEnvObject {
|
||||
name: string
|
||||
value: string
|
||||
}
|
||||
|
||||
export let getEnvVars = async (regexArg: RegExp) => {
|
||||
let resultArray: IEnvObject[] = []
|
||||
for (let key in process.env) {
|
||||
if (regexArg.test(key)) {
|
||||
resultArray.push({
|
||||
name: key,
|
||||
value: process.env[key]
|
||||
})
|
||||
}
|
||||
}
|
||||
return resultArray
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
import plugins = require('./smartenv.plugins')
|
||||
|
||||
export let obsItems: any = {}
|
||||
|
||||
/**
|
||||
* Objectstorage allows easy sharing of objects within node
|
||||
*/
|
||||
export let obs: any = {
|
||||
add: (keyNameArg, objectArg) => {
|
||||
if (!keyNameArg) {
|
||||
console.log('keyName is undefined')
|
||||
return
|
||||
}
|
||||
if (!objectArg) {
|
||||
console.log('objectArg is undefined')
|
||||
}
|
||||
if (!(obsItems[ keyNameArg ])) {
|
||||
obsItems[ keyNameArg ] = objectArg
|
||||
} else {
|
||||
console.log('object is already present, so add operation has failed.')
|
||||
}
|
||||
return obsItems[ keyNameArg ]
|
||||
},
|
||||
replace: function (paramNameArg, objectArg) {
|
||||
obsItems[ paramNameArg ] = objectArg
|
||||
},
|
||||
merge: function (paramNameArg, objectArg) {
|
||||
if (!(typeof obsItems[ paramNameArg ] === 'undefined')) {
|
||||
obsItems[ paramNameArg ] = plugins.lodash.assign(obsItems[ paramNameArg ], objectArg)
|
||||
} else {
|
||||
console.log('object is not present, so there is nothing to merge')
|
||||
}
|
||||
},
|
||||
get: function (keyName) {
|
||||
return obsItems[ keyName ]
|
||||
},
|
||||
getAll: function () {
|
||||
return obsItems
|
||||
},
|
||||
addComplete: function (itemsArg) {
|
||||
obsItems = plugins.lodash.assign(obsItems, itemsArg)
|
||||
return obsItems
|
||||
}
|
||||
}
|
@@ -1,8 +1,3 @@
|
||||
import 'typings-global'
|
||||
import * as smartq from 'smartq'
|
||||
import * as lodash from 'lodash'
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
|
||||
export {
|
||||
smartq,
|
||||
lodash
|
||||
}
|
||||
export { smartpromise };
|
||||
|
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"
|
||||
]
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Reference in New Issue
Block a user