Compare commits
127 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 | |||
a5005aeb96 | |||
a7e9f1303d | |||
92a6508c6a | |||
32f6b5cbf8 | |||
bdfbcead8d | |||
e73e704886 | |||
efa818680a | |||
572d85b3d3 | |||
41e1386a8d | |||
98d6f9e483 | |||
f295776bea | |||
cde63e95a8 | |||
6e4804a5ad | |||
137592a19b | |||
b850bc48cd | |||
e1ce867493 | |||
8e94ca9a60 | |||
81eaaaca90 | |||
340e7716f0 | |||
af7b9c46d2 | |||
56d4432d31 | |||
324abf821e | |||
fde407a762 | |||
c9ac84954f | |||
e0b4a93f1c | |||
70015b5ffc | |||
5a4d47411a | |||
1730706034 | |||
7ecf342548 | |||
7f10392757 | |||
9e229eee85 | |||
74c2c87f22 | |||
0e0ee89263 | |||
a0e8f2f5e2 | |||
043c5a0c6e | |||
a1d5b4fc4e | |||
cd0b8f18af | |||
d5387ddc05 | |||
3487b348df | |||
81036f8da3 | |||
b1464d97bf | |||
5636cf330e | |||
2e8b49fa18 | |||
df6036fbf1 | |||
8ec33947b6 | |||
50100115a6 | |||
8251e878c2 | |||
4a18d648c6 | |||
f9b89cc9db | |||
190aab3a11 | |||
cd26fffaf2 | |||
c2e48fa8b9 | |||
0db5ec169a | |||
0a29fafaeb | |||
0806fa9714 | |||
ef00c0d180 | |||
b79c5fa293 | |||
ae8a09c294 | |||
32a00aff01 | |||
77d96aaeff | |||
beb65789dc | |||
4a63b6a2c6 | |||
340e971738 | |||
1d488c308e | |||
bfb9ebb994 | |||
84c25f3a67 | |||
1f4ffaff2a | |||
101e7a86cd | |||
acc0e5221b | |||
a6839420f1 | |||
2df7cf1467 | |||
bae4305dec | |||
1737075753 | |||
1a74ee8bb6 | |||
28538001e9 | |||
9ec0b49716 | |||
cab52e1b02 | |||
d601a0eeb0 | |||
491f22ffca | |||
1fec5323d9 | |||
582afc0361 | |||
c054ecb0c7 | |||
249b626bb5 | |||
08d743477f | |||
fb64e8004d | |||
f5e48e4fd3 | |||
d2de8231cc | |||
0f784e2d74 | |||
f994c34bc7 | |||
503f030089 | |||
d120dd129c | |||
512fc4a67e | |||
eb09f756cb | |||
ce56916db7 |
21
.gitignore
vendored
21
.gitignore
vendored
@ -1,3 +1,20 @@
|
|||||||
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
|
coverage/
|
||||||
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
node_modules/
|
node_modules/
|
||||||
.settings/
|
|
||||||
.idea/
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
127
.gitlab-ci.yml
Normal file
127
.gitlab-ci.yml
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
# gitzone ci_default
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- security
|
||||||
|
- test
|
||||||
|
- release
|
||||||
|
- metadata
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# 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
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
script:
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- 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:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
pages:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- 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
|
||||||
|
allow_failure: true
|
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
4
.npmignore
Normal file
4
.npmignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
node_modules/
|
||||||
|
coverage/
|
||||||
|
test/
|
||||||
|
ts/typings/
|
16
.travis.yml
16
.travis.yml
@ -1,16 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- 4.2.2
|
|
||||||
before_install:
|
|
||||||
- npm install -g tsd
|
|
||||||
deploy:
|
|
||||||
provider: npm
|
|
||||||
email: npm@smart-coordination.com
|
|
||||||
api_key:
|
|
||||||
secure: uNjLbNelm8nj9R/tRlwRvcXWLS1QtA0QEbDKPDTWHNo68wAHgdwXIdzkVkNcihZYVasR/LqGuSLfzoD4H8mKmCXD+v85h048VmmtWniZQRp/OVWl0uzRwDDryhiYlhY5U9oOFEQsMO96C8qPqcGchq+DA7Gi3ZnAl7pmeb54xp9H+7jmLyZTyO8Hq00anV5PopBOW23mZEnWHznzYeg83BlWmLdbyfyZKT4W5Urg1BAMgxt9PdtrQoiPy4LP6AHXG88kvY3Iz8OBG+h/06bura8MPfeupGoktodN9krb+sRE/COybATWImMh9Z5gI5TWqUR7tp7XivpgolYY41gaN93oUQ9EOTdJ5kFku1dnPrNFqXO/97slVTMR6fMMgRXwzTz6BiKI1NsAZeW7oLUONw06APZ6VBhVY6Po3Rioun8OE9Q0wXm/BvnRqVHt3sew4MIgmEBwQSQE14gLJGGgNojzmcPstc0czQp+kzV5DpGiW3IWIWZ7MsBJOOJ13RHeb6koFdBR7JZj0QzzBcWD7juJVOS45MlP7hU/sKRDO/fN3nu8TNwHvJab6XYP5/gqlbh/3h2vb7bxyDXiKGi2Ds8hZOHoyWoCrU3sbH3eKKkKo+LFI3J7PbY11T6TkSAdszLsQzcvC2QlsGQRWVywYMm32R6BVfxF3AlLX5a8JsI=
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: pushrocks/smartenv
|
|
||||||
notifications:
|
|
||||||
slack:
|
|
||||||
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
|
|
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
|
||||||
|
28
index.js
28
index.js
@ -1,28 +0,0 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
|
||||||
var beautylog = require("beautylog")("os");
|
|
||||||
var addToGlobal = function (objectArg, paramName) {
|
|
||||||
global[paramName] = objectArg;
|
|
||||||
};
|
|
||||||
var smartenv = {}; //create smartenv object
|
|
||||||
smartenv.items = {}; // create the items object to store items to.
|
|
||||||
smartenv.makeGlobal = function () {
|
|
||||||
addToGlobal(smartenv, "smartenv"); //add object smartenv as global["smartenv"]
|
|
||||||
};
|
|
||||||
smartenv.info = function () {
|
|
||||||
var pck = require("./package.json");
|
|
||||||
beautylog.log("node version is " + process.version + " and smartenv version is " + pck.version);
|
|
||||||
beautylog.log("the smartenv module currently holds the following properties:");
|
|
||||||
console.log(Object.getOwnPropertyNames(smartenv.items).sort());
|
|
||||||
};
|
|
||||||
smartenv.register = function (objectArg, paramName) {
|
|
||||||
if (paramName === void 0) { paramName = "undefined"; }
|
|
||||||
if (paramName == "undefined") {
|
|
||||||
beautylog.error("paramName is undefined");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
smartenv.items[paramName] = objectArg;
|
|
||||||
};
|
|
||||||
smartenv.get = function (keyName) {
|
|
||||||
return smartenv.items[keyName];
|
|
||||||
};
|
|
||||||
module.exports = smartenv;
|
|
17
npmextra.json
Normal file
17
npmextra.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartenv",
|
||||||
|
"shortDescription": "store things about your environment and let them travel across modules",
|
||||||
|
"npmPackagename": "@pushrocks/smartenv",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4739
package-lock.json
generated
Normal file
4739
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
51
package.json
51
package.json
@ -1,32 +1,53 @@
|
|||||||
{
|
{
|
||||||
"name": "smartenv",
|
"name": "@pushrocks/smartenv",
|
||||||
"version": "0.0.1",
|
"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": "index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(cd ts/compile && node compile.js) && (node test.js)",
|
"test": "(tstest test/ --web)",
|
||||||
"reinstall": "(rm -r node_modules && npm install)",
|
"build": "(tsbuild --web && tsbundle npm)",
|
||||||
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
|
"testbrowser": "(npm test) && (node testbrowser.js)"
|
||||||
"startdev": "(git checkout master && git pull origin master && npm install)"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pushrocks/smartenv.git"
|
"url": "https://gitlab.com/pushrocks/smartenv.git"
|
||||||
},
|
},
|
||||||
"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://github.com/pushrocks/smartenv/issues"
|
"url": "https://gitlab.com/pushrocks/smartenv/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/smartenv",
|
"homepage": "https://gitlab.com/pushrocks/smartenv",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^1.0.4"
|
"@pushrocks/smartparam": "^1.1.6",
|
||||||
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
|
"@types/node": "^14.0.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^3.9.0",
|
"@gitzone/tsbuild": "^2.1.24",
|
||||||
"gulp-typescript": "^2.9.2"
|
"@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)
|
11
test.js
11
test.js
@ -1,11 +0,0 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
|
||||||
var smartenv = require("./index.js");
|
|
||||||
var beautylog = require("beautylog")("os");
|
|
||||||
beautylog.info("Now testing the smartenv module");
|
|
||||||
smartenv.info();
|
|
||||||
smartenv.register({ key1: "Peter" }, "docit");
|
|
||||||
smartenv.info();
|
|
||||||
beautylog.log(smartenv.get("docit").key1);
|
|
||||||
smartenv.makeGlobal();
|
|
||||||
beautylog.log(global.smartenv.get("docit").key1);
|
|
||||||
beautylog.success("Success!");
|
|
37
test/test.ts
Normal file
37
test/test.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
import * as smartenv from '../ts/index';
|
||||||
|
|
||||||
|
let testEnv: smartenv.Smartenv;
|
||||||
|
|
||||||
|
tap.test('should print env', async () => {
|
||||||
|
testEnv = new smartenv.Smartenv();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should print a overview to console', async () => {
|
||||||
|
testEnv.printEnv();
|
||||||
|
});
|
||||||
|
|
||||||
|
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!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should state wether we are in CI', async () => {
|
||||||
|
if (process.env.CI) {
|
||||||
|
expect(testEnv.isCI).to.be.true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
@ -1,28 +0,0 @@
|
|||||||
// import gulp
|
|
||||||
var gulp = require("gulp");
|
|
||||||
var gulpTypescript = require("gulp-typescript");
|
|
||||||
var bl = require("beautylog")("os");
|
|
||||||
|
|
||||||
gulp.task('compileTS', function() {
|
|
||||||
var stream = gulp.src('../index.ts')
|
|
||||||
.pipe(gulpTypescript({
|
|
||||||
out: "index.js"
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest("../../"));
|
|
||||||
return stream;
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('compileTestTS', function() {
|
|
||||||
var stream = gulp.src('../test.ts')
|
|
||||||
.pipe(gulpTypescript({
|
|
||||||
out: "test.js"
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest("../../"));
|
|
||||||
return stream;
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('default',['compileTS','compileTestTS'], function() {
|
|
||||||
bl.success('Typescript compiled');
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.start.apply(gulp, ['default']);
|
|
@ -1,2 +0,0 @@
|
|||||||
# How to compile.
|
|
||||||
Make sure gulp and gulp-taypescript from npm are available. Then run the gulpfile in this directory.
|
|
29
ts/index.js
29
ts/index.js
@ -1,29 +0,0 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
|
||||||
var beautylog = require("beautylog")("os");
|
|
||||||
var addToGlobal = function (objectArg, paramName) {
|
|
||||||
global[paramName] = objectArg;
|
|
||||||
};
|
|
||||||
var smartenv = {}; //create smartenv object
|
|
||||||
smartenv.items = {}; // create the items object to store items to.
|
|
||||||
smartenv.makeGlobal = function () {
|
|
||||||
addToGlobal(smartenv, "smartenv"); //add object smartenv as global["smartenv"]
|
|
||||||
};
|
|
||||||
smartenv.info = function () {
|
|
||||||
var pck = require("./package.json");
|
|
||||||
beautylog.log("node version is " + process.version + " and smartenv version is " + pck.version);
|
|
||||||
beautylog.log("the smartenv module currently holds the following properties:");
|
|
||||||
console.log(Object.getOwnPropertyNames(smartenv.items).sort());
|
|
||||||
};
|
|
||||||
smartenv.register = function (objectArg, paramName) {
|
|
||||||
if (paramName === void 0) { paramName = "undefined"; }
|
|
||||||
if (paramName == "undefined") {
|
|
||||||
beautylog.error("paramName is undefined");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
smartenv.items[paramName] = objectArg;
|
|
||||||
};
|
|
||||||
smartenv.get = function (keyName) {
|
|
||||||
return smartenv.items[keyName];
|
|
||||||
};
|
|
||||||
module.exports = smartenv;
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3C,IAAI,WAAW,GAAG,UAAS,SAAS,EAAC,SAAS;IAC1C,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAClC,CAAC,CAAC;AACF,IAAI,QAAQ,GAAO,EAAE,CAAC,CAAC,wBAAwB;AAC/C,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,6CAA6C;AAClE,QAAQ,CAAC,UAAU,GAAG;IAClB,WAAW,CAAC,QAAQ,EAAC,UAAU,CAAC,CAAC,CAAA,2CAA2C;AAChF,CAAC,CAAC;AAGF,QAAQ,CAAC,IAAI,GAAG;IACZ,IAAI,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACpC,SAAS,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,CAAC,OAAO,GAAG,2BAA2B,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;IAChG,SAAS,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;IAC/E,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF,QAAQ,CAAC,QAAQ,GAAG,UAAS,SAAS,EAAC,SAAuB;IAAvB,yBAAuB,GAAvB,uBAAuB;IAC1D,EAAE,CAAC,CAAC,SAAS,IAAI,WAAW,CAAC,CAAA,CAAC;QAC1B,SAAS,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC1C,MAAM,CAAC;IACX,CAAC;IACD,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAC1C,CAAC,CAAC;AACF,QAAQ,CAAC,GAAG,GAAG,UAAS,OAAO;IAC3B,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC,CAAA;AAED,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC"}
|
|
32
ts/index.ts
32
ts/index.ts
@ -1,31 +1 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
export * from './smartenv.classes.smartenv';
|
||||||
var beautylog = require("beautylog")("os");
|
|
||||||
var addToGlobal = function(objectArg,paramName) {
|
|
||||||
global[paramName] = objectArg;
|
|
||||||
};
|
|
||||||
var smartenv:any = {}; //create smartenv object
|
|
||||||
smartenv.items = {}; // create the items object to store items to.
|
|
||||||
smartenv.makeGlobal = function() {
|
|
||||||
addToGlobal(smartenv,"smartenv");//add object smartenv as global["smartenv"]
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
smartenv.info = function() {
|
|
||||||
var pck = require("./package.json");
|
|
||||||
beautylog.log("node version is " + process.version + " and smartenv version is " + pck.version);
|
|
||||||
beautylog.log("the smartenv module currently holds the following properties:");
|
|
||||||
console.log(Object.getOwnPropertyNames(smartenv.items).sort());
|
|
||||||
};
|
|
||||||
|
|
||||||
smartenv.register = function(objectArg,paramName = "undefined") {
|
|
||||||
if (paramName == "undefined"){
|
|
||||||
beautylog.error("paramName is undefined");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
smartenv.items[paramName] = objectArg;
|
|
||||||
};
|
|
||||||
smartenv.get = function(keyName) {
|
|
||||||
return smartenv.items[keyName];
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = smartenv;
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
ts/smartenv.plugins.ts
Normal file
5
ts/smartenv.plugins.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import * as smartparam from '@pushrocks/smartparam';
|
||||||
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
|
export { smartparam, smartpromise };
|
||||||
|
|
12
ts/test.js
12
ts/test.js
@ -1,12 +0,0 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
|
||||||
var smartenv = require("./index.js");
|
|
||||||
var beautylog = require("beautylog")("os");
|
|
||||||
beautylog.info("Now testing the smartenv module");
|
|
||||||
smartenv.info();
|
|
||||||
smartenv.register({ key1: "Peter" }, "docit");
|
|
||||||
smartenv.info();
|
|
||||||
beautylog.log(smartenv.get("docit").key1);
|
|
||||||
smartenv.makeGlobal();
|
|
||||||
beautylog.log(global.smartenv.get("docit").key1);
|
|
||||||
beautylog.success("Success!");
|
|
||||||
//# sourceMappingURL=test.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,IAAI,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACrC,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3C,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AAClD,QAAQ,CAAC,IAAI,EAAE,CAAC;AAChB,QAAQ,CAAC,QAAQ,CAAC,EAAC,IAAI,EAAC,OAAO,EAAC,EAAC,OAAO,CAAC,CAAC;AAC1C,QAAQ,CAAC,IAAI,EAAE,CAAC;AAChB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAC1C,QAAQ,CAAC,UAAU,EAAE,CAAC;AACtB,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AACjD,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC"}
|
|
11
ts/test.ts
11
ts/test.ts
@ -1,11 +0,0 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
|
||||||
var smartenv = require("./index.js");
|
|
||||||
var beautylog = require("beautylog")("os");
|
|
||||||
beautylog.info("Now testing the smartenv module");
|
|
||||||
smartenv.info();
|
|
||||||
smartenv.register({key1:"Peter"},"docit");
|
|
||||||
smartenv.info();
|
|
||||||
beautylog.log(smartenv.get("docit").key1);
|
|
||||||
smartenv.makeGlobal();
|
|
||||||
beautylog.log(global.smartenv.get("docit").key1);
|
|
||||||
beautylog.success("Success!");
|
|
12
ts/tsd.json
12
ts/tsd.json
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "v4",
|
|
||||||
"repo": "borisyankov/DefinitelyTyped",
|
|
||||||
"ref": "master",
|
|
||||||
"path": "typings",
|
|
||||||
"bundle": "typings/tsd.d.ts",
|
|
||||||
"installed": {
|
|
||||||
"node/node.d.ts": {
|
|
||||||
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
2079
ts/typings/node/node.d.ts
vendored
2079
ts/typings/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
1
ts/typings/tsd.d.ts
vendored
1
ts/typings/tsd.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
/// <reference path="node/node.d.ts" />
|
|
17
tslint.json
Normal file
17
tslint.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"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