Compare commits
79 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
47f840841c | |||
fe2210dc9f | |||
489ebab6ee | |||
46baf07551 | |||
cf0aabfbfc | |||
a5005aeb96 | |||
a7e9f1303d | |||
92a6508c6a | |||
32f6b5cbf8 |
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/
|
.nogit/
|
||||||
.settings/
|
|
||||||
.idea/
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
docs/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
#npm devug
|
# installs
|
||||||
npm-debug.log
|
node_modules/
|
||||||
|
|
||||||
ts/*.js
|
# caches
|
||||||
ts/*.js.map
|
.yarn/
|
||||||
ts/typings/
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
test/browser/browserified/
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
@ -1,59 +0,0 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- trigger
|
|
||||||
- pages
|
|
||||||
|
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test legacy
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test lts
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test stable
|
|
||||||
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:npmpage
|
|
||||||
stage: pages
|
|
||||||
script:
|
|
||||||
- npmci command npmpage --host gitlab
|
|
||||||
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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2015 Push.Rocks
|
Copyright (c) 2015 Lossless GmbH
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
39
README.md
39
README.md
@ -1,39 +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://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/)
|
|
||||||
|
|
||||||
## Install
|
|
||||||
Install the package through npm
|
|
||||||
|
|
||||||
```
|
|
||||||
npm install smartenv --save
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var smartenv = require("smartenv");
|
|
||||||
|
|
||||||
smartenv.info(); //prints an output about your current environment and registered objects
|
|
||||||
smartenv.register({akey:"a text"},"somevalue"); // register a new object
|
|
||||||
smartenv.makeGlobal() // make smartenv available from gobal.smartenv
|
|
||||||
smartenv.get("somevalue").akey; // returns "a text"
|
|
||||||
smartenv.items.somevalue.akey; // also returns "a text"
|
|
||||||
```
|
|
||||||
|
|
||||||
[](https://push.rocks)
|
|
3
dist/index.d.ts
vendored
3
dist/index.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
import { getEnv, printEnv } from './smartenv.environment';
|
|
||||||
import { obs } from './smartenv.objectstorage';
|
|
||||||
export { getEnv, printEnv, obs };
|
|
8
dist/index.js
vendored
8
dist/index.js
vendored
@ -1,8 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const smartenv_environment_1 = require("./smartenv.environment");
|
|
||||||
exports.getEnv = smartenv_environment_1.getEnv;
|
|
||||||
exports.printEnv = smartenv_environment_1.printEnv;
|
|
||||||
const smartenv_objectstorage_1 = require("./smartenv.objectstorage");
|
|
||||||
exports.obs = smartenv_objectstorage_1.obs;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUNBLGlFQUF1RDtBQUtyRCxpQkFMTSw2QkFBTSxDQUtOO0FBQ04sbUJBTmMsK0JBQVEsQ0FNZDtBQUxWLHFFQUE4QztBQU01QyxjQU5PLDRCQUFHLENBTVAifQ==
|
|
11
dist/smartenv.classes.d.ts
vendored
11
dist/smartenv.classes.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();
|
|
||||||
}
|
|
8
dist/smartenv.classes.helpers.d.ts
vendored
8
dist/smartenv.classes.helpers.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.classes.helpers.js
vendored
54
dist/smartenv.classes.helpers.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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRlbnYuY2xhc3Nlcy5oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQ1csUUFBQSxZQUFZLEdBQUc7SUFDeEIsRUFBRSxDQUFDLENBQUMsT0FBTyxNQUFNLEtBQUssV0FBVyxDQUFDLENBQUMsQ0FBQztRQUNsQyxNQUFNLENBQUMsU0FBUyxDQUFBO0lBQ2xCLENBQUM7SUFBQyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUMsT0FBTyxPQUFPLEtBQUssV0FBVyxDQUFDLENBQUMsQ0FBQztRQUMxQyxNQUFNLENBQUMsTUFBTSxDQUFBO0lBQ2YsQ0FBQztBQUNILENBQUMsQ0FBQTtBQUVVLFFBQUEsa0JBQWtCLEdBQUc7SUFDOUIsRUFBRSxDQUFDLENBQUMsaUJBQVMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUNoQixNQUFNLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQTtJQUM1QixDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDTixNQUFNLENBQUMsU0FBUyxDQUFBO0lBQ2xCLENBQUM7QUFDSCxDQUFDLENBQUE7QUFFVSxRQUFBLE1BQU0sR0FBRztJQUNsQixNQUFNLENBQUMsb0JBQVksRUFBRSxLQUFLLE1BQU0sQ0FBQTtBQUNsQyxDQUFDLENBQUE7QUFFVSxRQUFBLGNBQWMsR0FBRztJQUMxQixNQUFNLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQTtBQUN4QixDQUFDLENBQUE7QUFFVSxRQUFBLFNBQVMsR0FBRztJQUNyQixNQUFNLENBQUMsQ0FBQyxjQUFNLEVBQUUsQ0FBQTtBQUNsQixDQUFDLENBQUE7QUFFVSxRQUFBLElBQUksR0FBRztJQUNoQixFQUFFLENBQUMsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUM7UUFDbkIsTUFBTSxDQUFDLElBQUksQ0FBQTtJQUNiLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNOLE1BQU0sQ0FBQyxLQUFLLENBQUE7SUFDZCxDQUFDO0lBQUEsQ0FBQztBQUNKLENBQUMsQ0FBQTtBQUVVLFFBQUEsSUFBSSxHQUFHO0lBQ2hCLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQztRQUM1QixNQUFNLENBQUMsSUFBSSxDQUFBO0lBQ2IsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ04sTUFBTSxDQUFDLEtBQUssQ0FBQTtJQUNkLENBQUM7QUFDSCxDQUFDLENBQUE7QUFFVSxRQUFBLFFBQVEsR0FBRztJQUNwQixFQUFFLENBQUMsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUM7UUFDdkIsTUFBTSxDQUFDLElBQUksQ0FBQTtJQUNiLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNOLE1BQU0sQ0FBQyxLQUFLLENBQUE7SUFDZCxDQUFDO0lBQUEsQ0FBQztBQUNKLENBQUMsQ0FBQSJ9
|
|
18
dist/smartenv.classes.js
vendored
18
dist/smartenv.classes.js
vendored
@ -1,18 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const helpers = require("./smartenv.classes.helpers");
|
|
||||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuY2xhc3Nlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LmNsYXNzZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxzREFBc0Q7QUFFdEQ7SUFTSTtRQUNJLElBQUksQ0FBQyxVQUFVLEdBQUcsT0FBTyxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQ3hDLElBQUksQ0FBQyxTQUFTLEdBQUcsT0FBTyxDQUFDLFNBQVMsRUFBRSxDQUFBO1FBQ3BDLElBQUksQ0FBQyxTQUFTLEdBQUcsT0FBTyxDQUFDLGtCQUFrQixFQUFFLENBQUE7UUFDN0MsSUFBSSxDQUFDLE1BQU0sR0FBRyxPQUFPLENBQUMsTUFBTSxFQUFFLENBQUE7UUFDOUIsSUFBSSxDQUFDLFdBQVcsR0FBRyxPQUFPLENBQUMsY0FBYyxFQUFFLENBQUE7UUFDM0MsSUFBSSxDQUFDLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxFQUFFLENBQUE7UUFDMUIsSUFBSSxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUMsUUFBUSxFQUFFLENBQUE7UUFDbEMsSUFBSSxDQUFDLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxFQUFFLENBQUE7SUFDOUIsQ0FBQztJQUFBLENBQUM7Q0FDTDtBQW5CRCxrQ0FtQkMifQ==
|
|
10
dist/smartenv.environment.d.ts
vendored
10
dist/smartenv.environment.d.ts
vendored
@ -1,10 +0,0 @@
|
|||||||
import * as classes from './smartenv.classes';
|
|
||||||
/**
|
|
||||||
* returns the environment
|
|
||||||
* @returns {Environment}
|
|
||||||
*/
|
|
||||||
export declare var getEnv: () => classes.Environment;
|
|
||||||
/**
|
|
||||||
* prints the environment to console
|
|
||||||
*/
|
|
||||||
export declare var printEnv: () => void;
|
|
35
dist/smartenv.environment.js
vendored
35
dist/smartenv.environment.js
vendored
@ -1,35 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const classes = require("./smartenv.classes");
|
|
||||||
const objectStorage = require("./smartenv.objectstorage");
|
|
||||||
let environment;
|
|
||||||
let envDetermined = false;
|
|
||||||
/**
|
|
||||||
* returns the environment
|
|
||||||
* @returns {Environment}
|
|
||||||
*/
|
|
||||||
exports.getEnv = function () {
|
|
||||||
if (!envDetermined) {
|
|
||||||
environment = new classes.Environment();
|
|
||||||
envDetermined = true; // ensure code above only runs once
|
|
||||||
}
|
|
||||||
;
|
|
||||||
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()));
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuZW52aXJvbm1lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGVudi5lbnZpcm9ubWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUlBLDhDQUE2QztBQUM3QywwREFBeUQ7QUFHekQsSUFBSSxXQUFnQyxDQUFBO0FBQ3BDLElBQUksYUFBYSxHQUFZLEtBQUssQ0FBQTtBQUVsQzs7O0dBR0c7QUFDUSxRQUFBLE1BQU0sR0FBRztJQUNoQixFQUFFLENBQUMsQ0FBQyxDQUFDLGFBQWEsQ0FBQyxDQUFDLENBQUM7UUFDakIsV0FBVyxHQUFHLElBQUksT0FBTyxDQUFDLFdBQVcsRUFBRSxDQUFBO1FBQ3ZDLGFBQWEsR0FBRyxJQUFJLENBQUEsQ0FBQyxtQ0FBbUM7SUFDNUQsQ0FBQztJQUFBLENBQUM7SUFDRixNQUFNLENBQUMsV0FBVyxDQUFBO0FBQ3RCLENBQUMsQ0FBQTtBQUVEOztHQUVHO0FBQ1MsUUFBQSxRQUFRLEdBQUc7SUFDbkIsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUM7UUFDdkIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxpQkFBaUIsQ0FBQyxDQUFBO1FBQzlCLElBQUksZUFBZSxHQUFHLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDLE9BQU8sQ0FBQTtRQUN4RCxPQUFPLENBQUMsR0FBRyxDQUFDLGtCQUFrQixHQUFHLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQyxXQUFXLEdBQUcsMkJBQTJCLEdBQUcsZUFBZSxDQUFDLENBQUE7SUFDL0csQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0osT0FBTyxDQUFDLEdBQUcsQ0FBQyxvQkFBb0IsQ0FBQyxDQUFBO1FBQ2pDLE9BQU8sQ0FBQyxHQUFHLENBQUMsYUFBYSxHQUFHLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUN4RCxDQUFDO0lBQ0QsT0FBTyxDQUFDLEdBQUcsQ0FBQywyRUFBMkUsQ0FBQyxDQUFBO0lBQ3hGLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLG1CQUFtQixDQUFDLGFBQWEsQ0FBQyxHQUFHLENBQUMsTUFBTSxFQUFFLENBQUMsQ0FBQyxDQUFBO0FBQ3ZFLENBQUMsQ0FBQSJ9
|
|
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: function (paramNameArg = 'undefined', objectArg = 'undefined') {
|
|
||||||
if (paramNameArg === 'undefined') {
|
|
||||||
console.log('paramName is undefined');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (objectArg === 'undefined') {
|
|
||||||
console.log('objectArg is undefined');
|
|
||||||
}
|
|
||||||
if (typeof exports.obsItems[paramNameArg] === 'undefined') {
|
|
||||||
exports.obsItems[paramNameArg] = objectArg;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log('object is already present, so add operation has failed.');
|
|
||||||
}
|
|
||||||
return exports.obsItems[paramNameArg];
|
|
||||||
},
|
|
||||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYub2JqZWN0c3RvcmFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52Lm9iamVjdHN0b3JhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSw4Q0FBOEM7QUFFbkMsUUFBQSxRQUFRLEdBQVEsRUFBRSxDQUFBO0FBRTdCOztHQUVHO0FBQ1EsUUFBQSxHQUFHLEdBQVE7SUFDcEIsR0FBRyxFQUFFLFVBQVUsWUFBWSxHQUFHLFdBQVcsRUFBRSxTQUFTLEdBQUcsV0FBVztRQUNoRSxFQUFFLENBQUMsQ0FBQyxZQUFZLEtBQUssV0FBVyxDQUFDLENBQUMsQ0FBQztZQUNqQyxPQUFPLENBQUMsR0FBRyxDQUFDLHdCQUF3QixDQUFDLENBQUE7WUFDckMsTUFBTSxDQUFBO1FBQ1IsQ0FBQztRQUNELEVBQUUsQ0FBQyxDQUFDLFNBQVMsS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDO1lBQzlCLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQTtRQUN2QyxDQUFDO1FBQ0QsRUFBRSxDQUFDLENBQUMsT0FBTyxnQkFBUSxDQUFFLFlBQVksQ0FBRSxLQUFLLFdBQVcsQ0FBQyxDQUFDLENBQUM7WUFDcEQsZ0JBQVEsQ0FBRSxZQUFZLENBQUUsR0FBRyxTQUFTLENBQUE7UUFDdEMsQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ04sT0FBTyxDQUFDLEdBQUcsQ0FBQyx5REFBeUQsQ0FBQyxDQUFBO1FBQ3hFLENBQUM7UUFDRCxNQUFNLENBQUMsZ0JBQVEsQ0FBRSxZQUFZLENBQUUsQ0FBQTtJQUNqQyxDQUFDO0lBQ0QsT0FBTyxFQUFFLFVBQVUsWUFBWSxFQUFFLFNBQVM7UUFDeEMsZ0JBQVEsQ0FBRSxZQUFZLENBQUUsR0FBRyxTQUFTLENBQUE7SUFDdEMsQ0FBQztJQUNELEtBQUssRUFBRSxVQUFVLFlBQVksRUFBRSxTQUFTO1FBQ3RDLEVBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxPQUFPLGdCQUFRLENBQUUsWUFBWSxDQUFFLEtBQUssV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ3ZELGdCQUFRLENBQUUsWUFBWSxDQUFFLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsZ0JBQVEsQ0FBRSxZQUFZLENBQUUsRUFBRSxTQUFTLENBQUMsQ0FBQTtRQUN2RixDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDTixPQUFPLENBQUMsR0FBRyxDQUFDLHFEQUFxRCxDQUFDLENBQUE7UUFDcEUsQ0FBQztJQUNILENBQUM7SUFDRCxHQUFHLEVBQUUsVUFBVSxPQUFPO1FBQ3BCLE1BQU0sQ0FBQyxnQkFBUSxDQUFFLE9BQU8sQ0FBRSxDQUFBO0lBQzVCLENBQUM7SUFDRCxNQUFNLEVBQUU7UUFDTixNQUFNLENBQUMsZ0JBQVEsQ0FBQTtJQUNqQixDQUFDO0lBQ0QsV0FBVyxFQUFFLFVBQVUsUUFBUTtRQUM3QixnQkFBUSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLGdCQUFRLEVBQUUsUUFBUSxDQUFDLENBQUE7UUFDcEQsTUFBTSxDQUFDLGdCQUFRLENBQUE7SUFDakIsQ0FBQztDQUNGLENBQUEifQ==
|
|
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=
|
|
17
npmextra.json
Normal file
17
npmextra.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartenv",
|
||||||
|
"description": "store things about your environment and let them travel across modules",
|
||||||
|
"npmPackagename": "@push.rocks/smartenv",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"mode":"default",
|
|
||||||
"coverageTreshold":75
|
|
||||||
}
|
|
48
package.json
48
package.json
@ -1,12 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "smartenv",
|
"name": "@push.rocks/smartenv",
|
||||||
"version": "2.0.1",
|
"version": "5.0.12",
|
||||||
"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/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)",
|
"test": "(tstest test/ --web)",
|
||||||
"testbrowser": "(npm test) && (node testbrowser.js)"
|
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
|
||||||
|
"testbrowser": "(npm test) && (node testbrowser.js)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -15,19 +18,38 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"environment"
|
"environment"
|
||||||
],
|
],
|
||||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
"author": "Lossless GmbH <hello@lossless.support> (https://lossless.com)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/smartenv/issues"
|
"url": "https://gitlab.com/pushrocks/smartenv/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartenv",
|
"homepage": "https://gitlab.com/pushrocks/smartenv",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash": "^4.17.4",
|
"@push.rocks/smartpromise": "^4.0.2"
|
||||||
"smartq": "^1.1.1",
|
|
||||||
"typings-global": "^1.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"beautylog": "^6.1.5",
|
"@git.zone/tsbuild": "^2.1.66",
|
||||||
"tapbundle": "^1.0.5"
|
"@git.zone/tsbundle": "^2.0.10",
|
||||||
}
|
"@git.zone/tsrun": "^1.2.44",
|
||||||
|
"@git.zone/tstest": "^1.0.77",
|
||||||
|
"@push.rocks/tapbundle": "^5.0.8",
|
||||||
|
"@types/node": "^20.9.0",
|
||||||
|
"@types/npm": "^7.19.3"
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
5729
pnpm-lock.yaml
generated
Normal file
5729
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
37
readme.md
Normal file
37
readme.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# @push.rocks/smartenv
|
||||||
|
store things about your environment and let them travel across modules
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartenv)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartenv)
|
||||||
|
* [github.com (source mirror)](https://github.com/push.rocks/smartenv)
|
||||||
|
* [docs (typedoc)](https://push.rocks.gitlab.io/smartenv/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
## 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). :)
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
## 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)
|
52
test/test.ts
52
test/test.ts
@ -1,27 +1,37 @@
|
|||||||
import * as smartenv from '../dist/index.js'
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
import * as beautylog from 'beautylog'
|
import * as smartenv from '../ts/index.js';
|
||||||
|
|
||||||
import { tap, expect } from 'tapbundle'
|
let testEnv: smartenv.Smartenv;
|
||||||
|
|
||||||
smartenv.printEnv()
|
tap.test('should print env', async () => {
|
||||||
|
testEnv = new smartenv.Smartenv();
|
||||||
|
});
|
||||||
|
|
||||||
// test smartenv.obs.add
|
tap.test('should print a overview to console', async () => {
|
||||||
smartenv.obs.add('myTestObject',{key1:'Peter'})
|
testEnv.printEnv();
|
||||||
smartenv.obs.add('myTestObject',{key1:'Klaus'}) // now trying to add a second
|
});
|
||||||
smartenv.printEnv()
|
|
||||||
beautylog.log(smartenv.obs.get('myTestObject').key1) // this should be Peter
|
|
||||||
|
|
||||||
// test smartenv.obs.replace
|
tap.test('should get os', async () => {
|
||||||
smartenv.obs.replace('myTestObject',{key1:'Klaus'})
|
const resultMac = await testEnv.isMacAsync();
|
||||||
beautylog.log(smartenv.obs.get('myTestObject').key1) // this should be Klaus
|
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!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// test smartenv.obs.merge
|
tap.test('should state wether we are in CI', async () => {
|
||||||
smartenv.obs.merge('myTestObject',{key2:'Peter'})
|
if (process.env.CI) {
|
||||||
beautylog.log(smartenv.obs.get('myTestObject').key1 + smartenv.obs.get('myTestObject').key2)
|
expect(testEnv.isCI).toBeTrue();
|
||||||
// this should be KlausPeter
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let key2 = 'hello'
|
tap.start();
|
||||||
smartenv.obs.get('myTestObject').key2 = key2
|
|
||||||
beautylog.log(smartenv.obs.get('myTestObject').key2)
|
|
||||||
|
|
||||||
beautylog.success('Success!')
|
|
||||||
|
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 @@
|
|||||||
|
export * from './smartenv.classes.smartenv.js';
|
||||||
import {getEnv, printEnv} from './smartenv.environment'
|
|
||||||
import { obs } from './smartenv.objectstorage'
|
|
||||||
|
|
||||||
|
|
||||||
export {
|
|
||||||
getEnv,
|
|
||||||
printEnv,
|
|
||||||
obs
|
|
||||||
}
|
|
||||||
|
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,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
|
|
||||||
};
|
|
||||||
}
|
|
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}`);
|
||||||
|
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,22 +0,0 @@
|
|||||||
import helpers = require('./smartenv.classes.helpers')
|
|
||||||
|
|
||||||
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()
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,38 +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'
|
|
||||||
import * as objectStorage from './smartenv.objectstorage'
|
|
||||||
|
|
||||||
|
|
||||||
let environment: classes.Environment
|
|
||||||
let envDetermined: boolean = false
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the environment
|
|
||||||
* @returns {Environment}
|
|
||||||
*/
|
|
||||||
export var getEnv = function(){
|
|
||||||
if (!envDetermined) {
|
|
||||||
environment = new classes.Environment()
|
|
||||||
envDetermined = true // ensure code above only runs once
|
|
||||||
};
|
|
||||||
return environment
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* prints the environment to console
|
|
||||||
*/
|
|
||||||
export var 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()))
|
|
||||||
}
|
|
@ -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: function (paramNameArg = 'undefined', objectArg = 'undefined') {
|
|
||||||
if (paramNameArg === 'undefined') {
|
|
||||||
console.log('paramName is undefined')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (objectArg === 'undefined') {
|
|
||||||
console.log('objectArg is undefined')
|
|
||||||
}
|
|
||||||
if (typeof obsItems[ paramNameArg ] === 'undefined') {
|
|
||||||
obsItems[ paramNameArg ] = objectArg
|
|
||||||
} else {
|
|
||||||
console.log('object is already present, so add operation has failed.')
|
|
||||||
}
|
|
||||||
return obsItems[ paramNameArg ]
|
|
||||||
},
|
|
||||||
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 smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartq from 'smartq'
|
|
||||||
import * as lodash from 'lodash'
|
|
||||||
|
|
||||||
export {
|
export { smartpromise };
|
||||||
smartq,
|
|
||||||
lodash
|
|
||||||
}
|
|
||||||
|
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