Compare commits
96 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
47f840841c | |||
fe2210dc9f | |||
489ebab6ee | |||
46baf07551 | |||
cf0aabfbfc | |||
a5005aeb96 | |||
a7e9f1303d | |||
92a6508c6a | |||
32f6b5cbf8 | |||
bdfbcead8d | |||
e73e704886 | |||
efa818680a | |||
572d85b3d3 | |||
41e1386a8d | |||
98d6f9e483 | |||
f295776bea | |||
cde63e95a8 | |||
6e4804a5ad | |||
137592a19b | |||
b850bc48cd | |||
e1ce867493 |
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,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)
|
||||
|
||||
Copyright (c) 2015 Push.Rocks
|
||||
Copyright (c) 2015 Lossless GmbH
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
33
README.md
33
README.md
@ -1,33 +0,0 @@
|
||||
# smartenv
|
||||
store things about your environment and let them travel across modules
|
||||
|
||||
## Status
|
||||
[](https://travis-ci.org/pushrocks/smartenv)
|
||||
[](https://david-dm.org/pushrocks/smartenv)
|
||||
[](https://david-dm.org/pushrocks/smartenv#info=devDependencies)
|
||||
[](https://www.bithound.io/github/pushrocks/smartenv/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartenv)
|
||||
|
||||
## Install
|
||||
Install the package through npm
|
||||
|
||||
```
|
||||
npm install smartenv
|
||||
```
|
||||
|
||||
## 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"
|
||||
```
|
||||
|
||||
## About the authors:
|
||||
[](https://lossless.com/)
|
||||
|
||||
[](https://paypal.me/lossless)
|
7
dist/index.d.ts
vendored
7
dist/index.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
import * as classes from './smartenv.classes';
|
||||
declare let smartenv: {
|
||||
getEnv: () => classes.Environment;
|
||||
printEnv: () => void;
|
||||
obs: any;
|
||||
};
|
||||
export = smartenv;
|
10
dist/index.js
vendored
10
dist/index.js
vendored
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
const SmartenvEnvironment = require("./smartenv.environment");
|
||||
const SmartenvObjectstorage = require("./smartenv.objectstorage");
|
||||
let smartenv = {
|
||||
getEnv: SmartenvEnvironment.getEnv,
|
||||
printEnv: SmartenvEnvironment.printEnv,
|
||||
obs: SmartenvObjectstorage.obs
|
||||
}; // create smartenv object
|
||||
module.exports = smartenv;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsOERBQTZEO0FBQzdELGtFQUFpRTtBQUVqRSxJQUFJLFFBQVEsR0FBRztJQUNYLE1BQU0sRUFBRSxtQkFBbUIsQ0FBQyxNQUFNO0lBQ2xDLFFBQVEsRUFBRSxtQkFBbUIsQ0FBQyxRQUFRO0lBQ3RDLEdBQUcsRUFBRSxxQkFBcUIsQ0FBQyxHQUFHO0NBQ2pDLENBQUEsQ0FBQyx5QkFBeUI7QUFFM0IsaUJBQVMsUUFBUSxDQUFBIn0=
|
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 var getEnvString: () => string;
|
||||
export declare var getUserAgentString: () => string;
|
||||
export declare var isNode: () => boolean;
|
||||
export declare var getNodeVersion: () => string;
|
||||
export declare var isBrowser: () => boolean;
|
||||
export declare var isCI: () => boolean;
|
||||
export declare var isC9: () => boolean;
|
||||
export declare var isTravis: () => boolean;
|
53
dist/smartenv.classes.helpers.js
vendored
53
dist/smartenv.classes.helpers.js
vendored
@ -1,53 +0,0 @@
|
||||
"use strict";
|
||||
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;
|
||||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BQ25CLE1BQU0sQ0FBQyxDQUFDLGNBQU0sRUFBRSxDQUFBO0FBQ3BCLENBQUMsQ0FBQTtBQUVVLFFBQUEsSUFBSSxHQUFHO0lBQ2QsRUFBRSxDQUFDLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO1FBQ2pCLE1BQU0sQ0FBQyxJQUFJLENBQUE7SUFDZixDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixNQUFNLENBQUMsS0FBSyxDQUFBO0lBQ2hCLENBQUM7SUFBQSxDQUFDO0FBQ04sQ0FBQyxDQUFBO0FBRVUsUUFBQSxJQUFJLEdBQUc7SUFDZCxFQUFFLENBQUMsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUM7UUFDMUIsTUFBTSxDQUFDLElBQUksQ0FBQTtJQUNmLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNKLE1BQU0sQ0FBQyxLQUFLLENBQUE7SUFDaEIsQ0FBQztBQUNMLENBQUMsQ0FBQTtBQUVVLFFBQUEsUUFBUSxHQUFHO0lBQ2xCLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztRQUNyQixNQUFNLENBQUMsSUFBSSxDQUFBO0lBQ2YsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0osTUFBTSxDQUFDLEtBQUssQ0FBQTtJQUNoQixDQUFDO0lBQUEsQ0FBQztBQUNOLENBQUMsQ0FBQSJ9
|
17
dist/smartenv.classes.js
vendored
17
dist/smartenv.classes.js
vendored
@ -1,17 +0,0 @@
|
||||
"use strict";
|
||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuY2xhc3Nlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LmNsYXNzZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHNEQUFzRDtBQUV0RDtJQVNJO1FBQ0ksSUFBSSxDQUFDLFVBQVUsR0FBRyxPQUFPLENBQUMsWUFBWSxFQUFFLENBQUE7UUFDeEMsSUFBSSxDQUFDLFNBQVMsR0FBRyxPQUFPLENBQUMsU0FBUyxFQUFFLENBQUE7UUFDcEMsSUFBSSxDQUFDLFNBQVMsR0FBRyxPQUFPLENBQUMsa0JBQWtCLEVBQUUsQ0FBQTtRQUM3QyxJQUFJLENBQUMsTUFBTSxHQUFHLE9BQU8sQ0FBQyxNQUFNLEVBQUUsQ0FBQTtRQUM5QixJQUFJLENBQUMsV0FBVyxHQUFHLE9BQU8sQ0FBQyxjQUFjLEVBQUUsQ0FBQTtRQUMzQyxJQUFJLENBQUMsSUFBSSxHQUFHLE9BQU8sQ0FBQyxJQUFJLEVBQUUsQ0FBQTtRQUMxQixJQUFJLENBQUMsUUFBUSxHQUFHLE9BQU8sQ0FBQyxRQUFRLEVBQUUsQ0FBQTtRQUNsQyxJQUFJLENBQUMsSUFBSSxHQUFHLE9BQU8sQ0FBQyxJQUFJLEVBQUUsQ0FBQTtJQUM5QixDQUFDO0lBQUEsQ0FBQztDQUNMO0FBbkJELGtDQW1CQyJ9
|
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;
|
34
dist/smartenv.environment.js
vendored
34
dist/smartenv.environment.js
vendored
@ -1,34 +0,0 @@
|
||||
"use strict";
|
||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuZW52aXJvbm1lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGVudi5lbnZpcm9ubWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBSUEsOENBQTZDO0FBQzdDLDBEQUF5RDtBQUd6RCxJQUFJLFdBQWdDLENBQUE7QUFDcEMsSUFBSSxhQUFhLEdBQVksS0FBSyxDQUFBO0FBRWxDOzs7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NQUFNLEVBQUUsQ0FBQyxDQUFDLENBQUE7QUFDdkUsQ0FBQyxDQUFBIn0=
|
2
dist/smartenv.objectstorage.d.ts
vendored
2
dist/smartenv.objectstorage.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
export declare var obs: any;
|
||||
export declare var obsItems: any;
|
43
dist/smartenv.objectstorage.js
vendored
43
dist/smartenv.objectstorage.js
vendored
@ -1,43 +0,0 @@
|
||||
"use strict";
|
||||
const plugins = require("./smartenv.plugins");
|
||||
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._.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._.assign(exports.obsItems, itemsArg);
|
||||
return exports.obsItems;
|
||||
}
|
||||
};
|
||||
exports.obsItems = {};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYub2JqZWN0c3RvcmFnZS5qcyI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EMsRUFBRSxDQUFDLENBQUMsQ0FBQyxDQUFDLE9BQU8sZ0JBQVEsQ0FBQyxZQUFZLENBQUMsS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDbkQsZ0JBQVEsQ0FBQyxZQUFZLENBQUMsR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxnQkFBUSxDQUFDLFlBQVksQ0FBQyxFQUFDLFNBQVMsQ0FBQyxDQUFBO1FBQy9FLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLE9BQU8sQ0FBQyxHQUFHLENBQUMscURBQXFELENBQUMsQ0FBQTtRQUN0RSxDQUFDO0lBQ0wsQ0FBQztJQUNELEdBQUcsRUFBRSxVQUFTLE9BQU87UUFDakIsTUFBTSxDQUFDLGdCQUFRLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDNUIsQ0FBQztJQUNELE1BQU0sRUFBRTtRQUNKLE1BQU0sQ0FBQyxnQkFBUSxDQUFBO0lBQ25CLENBQUM7SUFDRCxXQUFXLEVBQUUsVUFBUyxRQUFRO1FBQzFCLGdCQUFRLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxNQUFNLENBQUMsZ0JBQVEsRUFBQyxRQUFRLENBQUMsQ0FBQTtRQUM5QyxNQUFNLENBQUMsZ0JBQVEsQ0FBQTtJQUNuQixDQUFDO0NBQ0osQ0FBQTtBQUNVLFFBQUEsUUFBUSxHQUFRLEVBQUUsQ0FBQSJ9
|
4
dist/smartenv.plugins.d.ts
vendored
4
dist/smartenv.plugins.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
import 'typings-global';
|
||||
import * as Q from 'q';
|
||||
import * as _ from 'lodash';
|
||||
export { Q, _ };
|
7
dist/smartenv.plugins.js
vendored
7
dist/smartenv.plugins.js
vendored
@ -1,7 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
const Q = require("q");
|
||||
exports.Q = Q;
|
||||
const _ = require("lodash");
|
||||
exports._ = _;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2Qix1QkFBc0I7QUFJbEIsY0FBQztBQUhMLDRCQUEyQjtBQUl2QixjQUFDIn0=
|
32
npmextra.json
Normal file
32
npmextra.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"npmci": {
|
||||
"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
|
||||
}
|
71
package.json
71
package.json
@ -1,35 +1,64 @@
|
||||
{
|
||||
"name": "smartenv",
|
||||
"version": "1.2.7",
|
||||
"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.12",
|
||||
"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://github.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": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||
"author": "Lossless GmbH <hello@lossless.support> (https://lossless.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pushrocks/smartenv/issues"
|
||||
"url": "https://gitlab.com/pushrocks/smartenv/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/smartenv",
|
||||
"homepage": "https://code.foss.global/push.rocks/smartenv",
|
||||
"dependencies": {
|
||||
"@types/q": "x.x.x",
|
||||
"lodash": "^4.17.2",
|
||||
"q": "^1.4.1",
|
||||
"typings-global": "^1.0.14"
|
||||
"@push.rocks/smartpromise": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/should": "^8.1.30",
|
||||
"beautylog": "^6.0.0",
|
||||
"should": "^11.1.1"
|
||||
}
|
||||
}
|
||||
"@git.zone/tsbuild": "^2.1.72",
|
||||
"@git.zone/tsbundle": "^2.0.15",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
"@git.zone/tstest": "^1.0.86",
|
||||
"@push.rocks/tapbundle": "^5.0.8",
|
||||
"@types/node": "^20.11.24",
|
||||
"@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
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
123
readme.md
Normal file
123
readme.md
Normal file
@ -0,0 +1,123 @@
|
||||
# @push.rocks/smartenv
|
||||
|
||||
store things about your environment and let them travel across modules
|
||||
|
||||
## Install
|
||||
|
||||
To install `@push.rocks/smartenv`, you need Node.js and npm installed. Then, run the following command:
|
||||
|
||||
```bash
|
||||
npm install @push.rocks/smartenv --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`@push.rocks/smartenv` is a valuable utility for managing and accessing environment-specific information within your application, enabling your code to adapt to different environments, such as development, testing, and production seamlessly. Here we delve into how to utilize `@push.rocks/smartenv` effectively within a TypeScript project. We'll cover initializing the package, checking the execution environment, loading modules conditionally based on the environment, and accessing environment variables securely.
|
||||
|
||||
### Getting Started
|
||||
First, ensure to import `Smartenv` from the package:
|
||||
|
||||
```typescript
|
||||
import { Smartenv } from '@push.rocks/smartenv';
|
||||
```
|
||||
|
||||
### Initializing Smartenv
|
||||
You can begin by creating an instance of `Smartenv`. This instance will be your gateway to accessing and managing the environment properties throughout your application.
|
||||
|
||||
```typescript
|
||||
const smartEnv = new Smartenv();
|
||||
```
|
||||
|
||||
### Checking Execution Environment
|
||||
`Smartenv` offers straightforward methods to determine whether your code is running in a Node.js or browser environment. This can be particularly useful for isomorphic code.
|
||||
|
||||
```typescript
|
||||
// Check if running in a Node.js environment
|
||||
console.log(`Is Node: ${smartEnv.isNode}`);
|
||||
|
||||
// Check if running in a browser environment
|
||||
console.log(`Is Browser: ${smartEnv.isBrowser}`);
|
||||
```
|
||||
|
||||
### Loading Modules Conditionally
|
||||
One of the core functionalities of `@push.rocks/smartenv` is to load modules based on the execution environment. This feature is immensely useful for isomorphic applications that need to run both in the browser and Node.js environments.
|
||||
|
||||
```typescript
|
||||
// Node.js module and equivalent browser module URLs
|
||||
const nodeModuleName = 'example-node-module';
|
||||
const browserModuleUrl = 'https://example.com/example-browser-module.js';
|
||||
|
||||
// Function to access the module in the browser
|
||||
const getBrowserModule = () => window.exampleBrowserModule;
|
||||
|
||||
const module = await smartEnv.getEnvAwareModule({
|
||||
nodeModuleName: nodeModuleName,
|
||||
webUrlArg: browserModuleUrl,
|
||||
getFunction: getBrowserModule
|
||||
});
|
||||
|
||||
console.log(module);
|
||||
```
|
||||
|
||||
### Accessing Environment Variables Securely
|
||||
For Node.js environments, accessing environment variables is a common task. `Smartenv` does not directly manipulate environment variables but encourages best practices for accessing them, ensuring your application remains secure and performs optimally.
|
||||
|
||||
```typescript
|
||||
if(smartEnv.isNode) {
|
||||
console.log(`Your environment variable value: ${process.env.YOUR_ENV_VAR}`);
|
||||
}
|
||||
```
|
||||
|
||||
### Detecting CI Environments
|
||||
Detect if your application is running in a Continuous Integration (CI) environment. This can be useful for modifying behavior during testing or deployment.
|
||||
|
||||
```typescript
|
||||
console.log(`Is CI: ${smartEnv.isCI}`);
|
||||
```
|
||||
|
||||
### Platform-Specific Checks
|
||||
`Smartenv` enables you to perform checks for specific operating systems when running in a Node.js environment, which can be particularly useful for tasks that depend on OS-specific features or paths.
|
||||
|
||||
```typescript
|
||||
const isMac = await smartEnv.isMacAsync();
|
||||
const isWindows = await smartEnv.isWindowsAsync();
|
||||
const isLinux = await smartEnv.isLinuxAsync();
|
||||
|
||||
console.log(`Is Mac: ${isMac}, Is Windows: ${isWindows}, Is Linux: ${isLinux}`);
|
||||
```
|
||||
|
||||
### Printing Environment for Debugging
|
||||
To assist with debugging, `Smartenv` offers a method to print the current environment and some relevant information to the console. This feature is particularly useful during development or when troubleshooting environment-specific issues.
|
||||
|
||||
```typescript
|
||||
smartEnv.printEnv();
|
||||
```
|
||||
|
||||
### Usage within Browser
|
||||
While `Smartenv` primarily facilitates handling different environments in server-side applications, it also provides functionalities to manage and load scripts dynamically in the browser. This allows for more flexible and environment-aware code sharing between server and client-side.
|
||||
|
||||
For instance, using `getSafeWebModule` to dynamically load a script only if it hasn't been already and then utilizing a globally available function or object that the script provides.
|
||||
|
||||
### Conclusion
|
||||
`@push.rocks/smartenv` is a comprehensive solution for managing environment-specific logic and configurations in your JavaScript and TypeScript projects. By leveraging its functionalities, developers can create more robust, flexible, and maintainable applications that seamlessly adapt to different execution contexts, whether in Node.js, the browser, or CI environments.
|
||||
|
||||
Always refer to the official documentation and source code for the most up-to-date usage examples and features.
|
||||
|
||||
## 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.
|
0
test/test.d.ts
vendored
0
test/test.d.ts
vendored
21
test/test.js
21
test/test.js
@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
const smartenv = require("../dist/index.js");
|
||||
const beautylog = require("beautylog");
|
||||
smartenv.printEnv();
|
||||
// test smartenv.obs.add
|
||||
smartenv.obs.add('myTestObject', { key1: 'Peter' });
|
||||
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
|
||||
smartenv.obs.replace('myTestObject', { key1: 'Klaus' });
|
||||
beautylog.log(smartenv.obs.get('myTestObject').key1); // this should be Klaus
|
||||
// test smartenv.obs.merge
|
||||
smartenv.obs.merge('myTestObject', { key2: 'Peter' });
|
||||
beautylog.log(smartenv.obs.get('myTestObject').key1 + smartenv.obs.get('myTestObject').key2);
|
||||
// this should be KlausPeter
|
||||
let key2 = 'hello';
|
||||
smartenv.obs.get('myTestObject').key2 = key2;
|
||||
beautylog.log(smartenv.obs.get('myTest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,CAAC,CAAC,CAAC,uBAAuB;AAE7E,2BAA2B;AAC3B,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC;AACpD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,uBAAuB;AAE7E,yBAAyB;AACzB,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC;AAClD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,4BAA4B;AAE1H,IAAI,IAAI,GAAG,OAAO,CAAC;AACnB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;AAC7C,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC;AAErD,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC"}
|
51
test/test.ts
51
test/test.ts
@ -1,24 +1,37 @@
|
||||
import * as smartenv from '../dist/index.js'
|
||||
import * as beautylog from 'beautylog'
|
||||
smartenv.printEnv()
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
import * as smartenv from '../ts/index.js';
|
||||
|
||||
// test smartenv.obs.add
|
||||
smartenv.obs.add('myTestObject',{key1:'Peter'})
|
||||
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
|
||||
let testEnv: smartenv.Smartenv;
|
||||
|
||||
// test smartenv.obs.replace
|
||||
smartenv.obs.replace('myTestObject',{key1:'Klaus'})
|
||||
beautylog.log(smartenv.obs.get('myTestObject').key1) // this should be Klaus
|
||||
tap.test('should print env', async () => {
|
||||
testEnv = new smartenv.Smartenv();
|
||||
});
|
||||
|
||||
// test smartenv.obs.merge
|
||||
smartenv.obs.merge('myTestObject',{key2:'Peter'})
|
||||
beautylog.log(smartenv.obs.get('myTestObject').key1 + smartenv.obs.get('myTestObject').key2)
|
||||
// this should be KlausPeter
|
||||
tap.test('should print a overview to console', async () => {
|
||||
testEnv.printEnv();
|
||||
});
|
||||
|
||||
let key2 = 'hello'
|
||||
smartenv.obs.get('myTestObject').key2 = key2
|
||||
beautylog.log(smartenv.obs.get('myTestObject').key2)
|
||||
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!');
|
||||
}
|
||||
});
|
||||
|
||||
beautylog.success('Success!')
|
||||
tap.test('should state wether we are in CI', async () => {
|
||||
if (process.env.CI) {
|
||||
expect(testEnv.isCI).toBeTrue();
|
||||
}
|
||||
});
|
||||
|
||||
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'
|
||||
}
|
13
ts/index.ts
13
ts/index.ts
@ -1,12 +1 @@
|
||||
import * as plugins from './smartenv.plugins'
|
||||
import * as classes from './smartenv.classes'
|
||||
import * as SmartenvEnvironment from './smartenv.environment'
|
||||
import * as SmartenvObjectstorage from './smartenv.objectstorage'
|
||||
|
||||
let smartenv = {
|
||||
getEnv: SmartenvEnvironment.getEnv,
|
||||
printEnv: SmartenvEnvironment.printEnv,
|
||||
obs: SmartenvObjectstorage.obs
|
||||
} // create smartenv object
|
||||
|
||||
export = smartenv
|
||||
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,51 +0,0 @@
|
||||
export var getEnvString = function(): string {
|
||||
if (typeof window !== 'undefined') {
|
||||
return 'browser'
|
||||
} else if (typeof process !== 'undefined') {
|
||||
return 'node'
|
||||
}
|
||||
}
|
||||
|
||||
export var getUserAgentString = function(): string{
|
||||
if (isBrowser()) {
|
||||
return navigator.userAgent
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
export var isNode = function(): boolean {
|
||||
return getEnvString() === 'node'
|
||||
}
|
||||
|
||||
export var getNodeVersion = function(): string {
|
||||
return process.version
|
||||
}
|
||||
|
||||
export var isBrowser = function(): boolean {
|
||||
return !isNode()
|
||||
}
|
||||
|
||||
export var isCI = function(){
|
||||
if (process.env.CI) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
};
|
||||
}
|
||||
|
||||
export var isC9 = function(){
|
||||
if (process.env.C9_HOSTNAME) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export var 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,39 +0,0 @@
|
||||
import plugins = require('./smartenv.plugins')
|
||||
export var 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._.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._.assign(obsItems,itemsArg)
|
||||
return obsItems
|
||||
}
|
||||
}
|
||||
export var obsItems: any = {}
|
@ -1,8 +1,3 @@
|
||||
import 'typings-global'
|
||||
import * as Q from 'q'
|
||||
import * as _ from 'lodash'
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
|
||||
export {
|
||||
Q,
|
||||
_
|
||||
}
|
||||
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"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user