Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
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
|
110
.gitlab-ci.yml
110
.gitlab-ci.yml
@ -1,71 +1,127 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .yarn/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- security
|
||||||
- release
|
- test
|
||||||
- trigger
|
- release
|
||||||
- pages
|
- metadata
|
||||||
|
|
||||||
testLEGACY:
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci git mirror
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
audit:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
allow_failure: true
|
- priv
|
||||||
|
|
||||||
testLTS:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci npm prepare
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
- npmci node install stable
|
||||||
tags:
|
- npmci npm install
|
||||||
- docker
|
- npmci command npm run build
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test stable
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: trigger
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
stage: metadata
|
||||||
stage: pages
|
|
||||||
script:
|
script:
|
||||||
- npmci command yarn global add npmpage
|
- npmci node install lts
|
||||||
- npmci command npmpage --publish gitlab
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal 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
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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
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=
|
|
@ -1,7 +1,17 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"globalNpmTools": [
|
"npmGlobalTools": [],
|
||||||
"npmts"
|
"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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"mode":"default",
|
|
||||||
"coverageTreshold":75
|
|
||||||
}
|
|
4739
package-lock.json
generated
Normal file
4739
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
44
package.json
44
package.json
@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "smartenv",
|
"name": "@pushrocks/smartenv",
|
||||||
"version": "2.0.3",
|
"version": "4.0.10",
|
||||||
"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",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)",
|
"test": "(tstest test/ --web)",
|
||||||
|
"build": "(tsbuild --web && tsbundle npm)",
|
||||||
"testbrowser": "(npm test) && (node testbrowser.js)"
|
"testbrowser": "(npm test) && (node testbrowser.js)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -15,19 +16,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",
|
"@pushrocks/smartparam": "^1.1.6",
|
||||||
"smartq": "^1.1.1",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
"typings-global": "^1.0.14"
|
"@types/node": "^14.0.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"beautylog": "^6.1.5",
|
"@gitzone/tsbuild": "^2.1.24",
|
||||||
"tapbundle": "^1.0.5"
|
"@gitzone/tsbundle": "^1.0.69",
|
||||||
}
|
"@gitzone/tsrun": "^1.2.12",
|
||||||
|
"@gitzone/tstest": "^1.0.33",
|
||||||
|
"@pushrocks/tapbundle": "^3.2.1",
|
||||||
|
"@types/npm": "^2.0.31",
|
||||||
|
"tslint": "^6.1.2",
|
||||||
|
"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"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
40
readme.md
Normal file
40
readme.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# @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 | [](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)
|
||||||
|
Platform support | [](https://lossless.cloud) [](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 | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
52
test/test.ts
52
test/test.ts
@ -1,27 +1,37 @@
|
|||||||
import * as smartenv from '../dist/index.js'
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
import * as beautylog from 'beautylog'
|
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
|
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()).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
|
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).to.be.true;
|
||||||
// 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!')
|
|
||||||
|
10
ts/index.ts
10
ts/index.ts
@ -1,9 +1 @@
|
|||||||
import {getEnv, printEnv} from './smartenv.environment'
|
export * from './smartenv.classes.smartenv';
|
||||||
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
|
|
||||||
};
|
|
||||||
}
|
|
117
ts/smartenv.classes.smartenv.ts
Normal file
117
ts/smartenv.classes.smartenv.ts
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
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 getSafeNodeModule(moduleNameArg: string) {
|
||||||
|
// tslint:disable-next-line: function-constructor
|
||||||
|
return new Function(
|
||||||
|
'exports',
|
||||||
|
'require',
|
||||||
|
'module',
|
||||||
|
'__filename',
|
||||||
|
'__dirname',
|
||||||
|
`return require('${moduleNameArg}')`
|
||||||
|
)(exports,require,module,__filename,__dirname);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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,5 @@
|
|||||||
import 'typings-global'
|
import * as smartparam from '@pushrocks/smartparam';
|
||||||
import * as smartq from 'smartq'
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as lodash from 'lodash'
|
|
||||||
|
export { smartparam, smartpromise };
|
||||||
|
|
||||||
export {
|
|
||||||
smartq,
|
|
||||||
lodash
|
|
||||||
}
|
|
||||||
|
16
tslint.json
16
tslint.json
@ -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"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user