Compare commits

...

39 Commits

Author SHA1 Message Date
ed78c0becf 4.0.13 2020-09-29 18:38:22 +00:00
63c103fde5 fix(core): update 2020-09-29 18:38:21 +00:00
88003bde0f 4.0.12 2020-09-29 17:49:34 +00:00
276a0641e8 fix(core): update 2020-09-29 17:49:33 +00:00
b166269cb4 4.0.11 2020-09-29 10:23:08 +00:00
3ca1b425bf fix(core): update 2020-09-29 10:23:07 +00:00
ffc07da665 4.0.10 2020-06-25 23:00:33 +00:00
be2adaf259 fix(core): update 2020-06-25 23:00:32 +00:00
7aa9637826 4.0.9 2020-06-25 22:26:05 +00:00
a3c4f87741 fix(core): update 2020-06-25 22:26:04 +00:00
f005f57764 4.0.8 2020-06-25 22:23:10 +00:00
6e418cdbf8 fix(core): update 2020-06-25 22:23:10 +00:00
87155900e1 4.0.8 2019-11-15 20:59:04 +01:00
d24b11f737 fix(core): update 2019-11-15 20:59:02 +01:00
17ebd58951 4.0.7 2019-08-22 00:20:11 +02:00
32bd229f91 fix(core): update 2019-08-22 00:20:10 +02:00
4e5ddf8411 4.0.6 2019-06-17 08:54:47 +02:00
701c7c1b8b fix(core): update 2019-06-17 08:54:46 +02:00
9a272def16 4.0.5 2019-06-17 08:51:04 +02:00
0213950aae fix(core): update 2019-06-17 08:51:03 +02:00
b7342dbf05 4.0.4 2019-06-17 08:46:28 +02:00
677c8d33b9 fix(core): update 2019-06-17 08:46:28 +02:00
ffc781011d 4.0.3 2018-02-14 00:29:00 +01:00
aeec1b36a3 fix CI 2018-02-14 00:28:56 +01:00
4c2e7f9446 4.0.2 2018-02-14 00:15:51 +01:00
dddad457f3 update npmextra 2018-02-14 00:15:47 +01:00
4f110c6e64 4.0.1 2018-02-14 00:13:16 +01:00
12d971c470 update ci 2018-02-14 00:13:12 +01:00
886c245e8d 4.0.0 2018-02-14 00:12:25 +01:00
50d610e5df update smartenv to support os information on nodejs 2018-02-14 00:12:21 +01:00
5edb62c134 3.0.0 2017-05-25 01:33:20 +02:00
38f22a6d95 remove npmts.json 2017-05-25 01:33:15 +02:00
91cdb71388 Merge branch 'master' into 'master'
Update to latest standards

See merge request !1
2017-05-24 23:28:41 +00:00
ab33e97c8d streamline package 2017-05-17 15:59:10 +02:00
47f840841c 2.0.6 2017-04-21 00:11:11 +02:00
fe2210dc9f update readme 2017-04-21 00:11:06 +02:00
489ebab6ee 2.0.5 2017-04-21 00:04:31 +02:00
46baf07551 now has a env vars feature 2017-04-21 00:04:28 +02:00
cf0aabfbfc 2.0.4 2017-04-19 20:18:19 +02:00
34 changed files with 11699 additions and 2327 deletions

26
.gitignore vendored
View File

@ -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

View File

@ -1,38 +1,76 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
key: "$CI_BUILD_STAGE"
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- test
- release
- trigger
- pages
- security
- test
- release
- metadata
testLEGACY:
stage: test
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci test legacy
coverage: /\d+.?\d+?\%\s*coverage/
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
testLTS:
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci test lts
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testSTABLE:
testBuild:
stage: test
script:
- npmci test stable
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
@ -40,32 +78,60 @@ testSTABLE:
release:
stage: release
script:
- npmci publish
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
stage: metadata
script:
- npmci command yarn global add npmpage
- npmci command npmpage --publish gitlab
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

29
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

26
.vscode/settings.json vendored Normal file
View 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"]
}
}
}
}
}
}
]
}

View File

@ -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

View File

@ -1,39 +0,0 @@
# smartenv
store things about your environment and let them travel across modules
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartenv)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartenv)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartenv)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartenv/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartenv/badges/master/build.svg)](https://gitlab.com/pushrocks/smartenv/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartenv/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartenv/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartenv.svg)](https://david-dm.org/pushrocks/smartenv)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartenv/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartenv/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartenv/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartenv)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](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"
```
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

3
dist/index.d.ts vendored
View File

@ -1,3 +0,0 @@
import { getEnv, printEnv } from './smartenv.environment';
import { obs } from './smartenv.objectstorage';
export { getEnv, printEnv, obs };

8
dist/index.js vendored
View File

@ -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==

View File

@ -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();
}

View File

@ -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;

View File

@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRlbnYuY2xhc3Nlcy5oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQ1csUUFBQSxZQUFZLEdBQUc7SUFDeEIsRUFBRSxDQUFDLENBQUMsT0FBTyxNQUFNLEtBQUssV0FBVyxDQUFDLENBQUMsQ0FBQztRQUNsQyxNQUFNLENBQUMsU0FBUyxDQUFBO0lBQ2xCLENBQUM7SUFBQyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUMsT0FBTyxPQUFPLEtBQUssV0FBVyxDQUFDLENBQUMsQ0FBQztRQUMxQyxNQUFNLENBQUMsTUFBTSxDQUFBO0lBQ2YsQ0FBQztBQUNILENBQUMsQ0FBQTtBQUVVLFFBQUEsa0JBQWtCLEdBQUc7SUFDOUIsRUFBRSxDQUFDLENBQUMsaUJBQVMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUNoQixNQUFNLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQTtJQUM1QixDQUFDO0lBQUMsSUFBSSxDQUFD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QUMsQ0FBQztRQUNOLE1BQU0sQ0FBQyxLQUFLLENBQUE7SUFDZCxDQUFDO0lBQUEsQ0FBQztBQUNKLENBQUMsQ0FBQSJ9

View File

@ -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==

View File

@ -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;

View File

@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuZW52aXJvbm1lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGVudi5lbnZpcm9ubWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUlBLDhDQUE2QztBQUM3QywwREFBeUQ7QUFHekQsSUFBSSxXQUFnQyxDQUFBO0FBQ3BDLElBQUksYUFBYSxHQUFZLEtBQUssQ0FBQTtBQUVsQzs7O0dBR0c7QUFDUSxRQUFBLE1BQU0sR0FBRztJQUNoQixFQUFFLENBQUMsQ0FBQyxDQUFDLGFBQWEsQ0FBQyxDQUFDLENBQUM7UUFDakIsV0FBVyxHQU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
/**
* Objectstorage allows easy sharing of objects within node
*/
export declare let obs: any;

View File

@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYub2JqZWN0c3RvcmFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52Lm9iamVjdHN0b3JhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSw4Q0FBOEM7QUFFbkMsUUFBQSxRQUFRLEdBQVEsRUFBRSxDQUFBO0FBRTdCOztHQUVHO0FBQ1EsUUFBQSxHQUFHLEdBQVE7SUFDcEIsR0FBRyxFQUFFLFVBQVUsWUFBWSxHQUFHLFdBQVcsRUFBRSxTQUFTLEdBQUcsV0FBVztRQUNoRSxFQUFFLENBQUMsQ0FBQyxZQUF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1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDTixPQUFPLENBQUMsR0FBRyxDQUFDLHFEQUFxRCxDQUFDLENBQUE7UUFDcEUsQ0FBQztJQUNILENBQUM7SUFDRCxHQUFHLEVBQUUsVUFBVSxPQUFPO1FBQ3BCLE1BQU0sQ0FBQyxnQkFBUSxDQUFFLE9BQU8sQ0FBRSxDQUFBO0lBQzVCLENBQUM7SUFDRCxNQUFNLEVBQUU7UUFDTixNQUFNLENBQUMsZ0JBQVEsQ0FBQTtJQUNqQixDQUFDO0lBQ0QsV0FBVyxFQUFFLFVBQVUsUUFBUTtRQUM3QixnQkFBUSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLGdCQUFRLEVBQUUsUUFBUSxDQUFDLENBQUE7UUFDcEQsTUFBTSxDQUFDLGdCQUFRLENBQUE7SUFDakIsQ0FBQztDQUNGLENBQUEifQ==

View File

@ -1,4 +0,0 @@
import 'typings-global';
import * as smartq from 'smartq';
import * as lodash from 'lodash';
export { smartq, lodash };

View File

@ -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=

View File

@ -1,7 +1,17 @@
{
"npmci": {
"globalNpmTools": [
"npmts"
]
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartenv",
"shortDescription": "store things about your environment and let them travel across modules",
"npmPackagename": "@pushrocks/smartenv",
"license": "MIT"
}
}
}

View File

@ -1,4 +0,0 @@
{
"mode":"default",
"coverageTreshold":75
}

11226
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,12 @@
{
"name": "smartenv",
"version": "2.0.3",
"name": "@pushrocks/smartenv",
"version": "4.0.13",
"description": "store things about your environment and let them travel across modules",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
"test": "(npmts)",
"test": "(tstest test/ --web)",
"build": "(tsbuild --web && tsbundle npm)",
"testbrowser": "(npm test) && (node testbrowser.js)"
},
"repository": {
@ -15,19 +16,41 @@
"keywords": [
"environment"
],
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
"author": "Lossless GmbH <hello@lossless.support> (https://lossless.com)",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/smartenv/issues"
},
"homepage": "https://gitlab.com/pushrocks/smartenv",
"dependencies": {
"lodash": "^4.17.4",
"smartq": "^1.1.1",
"typings-global": "^1.0.14"
"@pushrocks/smartparam": "^1.1.6",
"@pushrocks/smartpromise": "^3.0.6",
"@types/node": "^14.11.2"
},
"devDependencies": {
"beautylog": "^6.1.5",
"tapbundle": "^1.0.5"
}
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbundle": "^1.0.78",
"@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.44",
"@pushrocks/tapbundle": "^3.2.9",
"@types/npm": "^2.0.31",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"private": false,
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

39
readme.md Normal file
View File

@ -0,0 +1,39 @@
# @pushrocks/smartenv
store things about your environment and let them travel across modules
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartenv)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartenv)
* [github.com (source mirror)](https://github.com/pushrocks/smartenv)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartenv/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartenv/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartenv/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartenv)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartenv)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartenv)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartenv)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartenv)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](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.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,27 +1,37 @@
import * as smartenv from '../dist/index.js'
import * as beautylog from 'beautylog'
import { tap, expect } from '@pushrocks/tapbundle';
import * as smartenv from '../ts/index';
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
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
tap.test('should print a overview to console', async () => {
testEnv.printEnv();
});
// test smartenv.obs.replace
smartenv.obs.replace('myTestObject',{key1:'Klaus'})
beautylog.log(smartenv.obs.get('myTestObject').key1) // this should be Klaus
tap.test('should get os', async () => {
const resultMac = await testEnv.isMacAsync();
const resultLinux = await testEnv.isLinuxAsync();
const resultWindows = await testEnv.isWindowsAsync();
const osModule = await import('os');
if (resultMac) {
expect(osModule.platform()).to.equal('darwin');
console.log('platform is Mac!');
} else if (resultLinux) {
expect(osModule.platform()).to.equal('linux');
console.log('platform is Linux!');
} else {
expect(osModule.platform()).to.equal('win32');
console.log('platform is Windows!');
}
});
// 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 state wether we are in CI', async () => {
if (process.env.CI) {
expect(testEnv.isCI).to.be.true;
}
});
let key2 = 'hello'
smartenv.obs.get('myTestObject').key2 = key2
beautylog.log(smartenv.obs.get('myTestObject').key2)
beautylog.success('Success!')
tap.start();

View File

@ -1,9 +1 @@
import {getEnv, printEnv} from './smartenv.environment'
import { obs } from './smartenv.objectstorage'
export {
getEnv,
printEnv,
obs
}
export * from './smartenv.classes.smartenv';

9
ts/interfaces/index.ts Normal file
View File

@ -0,0 +1,9 @@
export let defaultme = null;
declare global {
namespace NodeJS {
interface Global {
window: any;
navigator: any;
}
}
}

View File

@ -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
};
}

View File

@ -0,0 +1,165 @@
import * as plugins from './smartenv.plugins';
import * as interfaces from './interfaces';
// 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);
} else {
console.error('platform for loading not supported by smartenv');
}
}
public getSafeNodeModule<T = any>(moduleNameArg: string): T {
if (!this.isNode) {
console.error('You tried to load a node module in a wrong context');
return;
}
// tslint:disable-next-line: function-constructor
return new Function(
'exports',
'require',
'module',
'__filename',
'__dirname',
`return require('${moduleNameArg}')`
)(exports, require, module, __filename, __dirname);
}
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;
} 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 window !== 'undefined') {
return 'browser';
} else if (typeof process !== 'undefined') {
return 'node';
}
}
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 = this.getSafeNodeModule('os');
return os.platform() === 'darwin';
} else {
return false;
}
}
public async isWindowsAsync(): Promise<boolean> {
if (this.isNode) {
const os = this.getSafeNodeModule('os');
return os.platform() === 'win32';
} else {
return false;
}
}
public async isLinuxAsync(): Promise<boolean> {
if (this.isNode) {
const os = this.getSafeNodeModule('os');
return os.platform() === 'linux';
} else {
return false;
}
}
/**
* get environment variables that fit the description
*/
// get envVars (regexArg: RegExp) {
// let EnvironmentArray = []
// // TODO: plugins.smartparam.forEachMinimatch()
// }
/**
* prints the environment to console
*/
public async printEnv() {
if (this.isNode) {
console.log('running on NODE');
const smartenvVersion = require('../package.json').version;
console.log(
'node version is ' + this.nodeVersion + ' and smartenv version is ' + smartenvVersion
);
} else {
console.log('running on BROWSER');
console.log('browser is ' + this.userAgent);
}
}
}

View File

@ -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()
};
}

View File

@ -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()))
}

View File

@ -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
}
}

View File

@ -1,8 +1,4 @@
import 'typings-global'
import * as smartq from 'smartq'
import * as lodash from 'lodash'
import * as smartparam from '@pushrocks/smartparam';
import * as smartpromise from '@pushrocks/smartpromise';
export {
smartq,
lodash
}
export { smartparam, smartpromise };

View File

@ -1,3 +1,17 @@
{
"extends": "tslint-config-standard"
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}

1829
yarn.lock

File diff suppressed because it is too large Load Diff