streamline package
This commit is contained in:
parent
47f840841c
commit
ab33e97c8d
4
dist/index.d.ts
vendored
4
dist/index.d.ts
vendored
@ -1,3 +1 @@
|
|||||||
import { getEnv, printEnv, getEnvVars } from './smartenv.export';
|
export * from './smartenv.classes.smartenv';
|
||||||
import { obs } from './smartenv.objectstorage';
|
|
||||||
export { getEnv, getEnvVars, printEnv, obs };
|
|
||||||
|
12
dist/index.js
vendored
12
dist/index.js
vendored
@ -1,9 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
function __export(m) {
|
||||||
|
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||||
|
}
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const smartenv_export_1 = require("./smartenv.export");
|
__export(require("./smartenv.classes.smartenv"));
|
||||||
exports.getEnv = smartenv_export_1.getEnv;
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLGlEQUEyQyJ9
|
||||||
exports.printEnv = smartenv_export_1.printEnv;
|
|
||||||
exports.getEnvVars = smartenv_export_1.getEnvVars;
|
|
||||||
const smartenv_objectstorage_1 = require("./smartenv.objectstorage");
|
|
||||||
exports.obs = smartenv_objectstorage_1.obs;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHVEQUE4RDtBQUs1RCxpQkFMTSx3QkFBTSxDQUtOO0FBRU4sbUJBUGMsMEJBQVEsQ0FPZDtBQURSLHFCQU53Qiw0QkFBVSxDQU14QjtBQUxaLHFFQUE4QztBQU81QyxjQVBPLDRCQUFHLENBT1AifQ==
|
|
11
dist/smartenv.classes.environment.d.ts
vendored
11
dist/smartenv.classes.environment.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();
|
|
||||||
}
|
|
18
dist/smartenv.classes.environment.js
vendored
18
dist/smartenv.classes.environment.js
vendored
@ -1,18 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const helpers = require("./smartenv.envhelpers");
|
|
||||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuY2xhc3Nlcy5lbnZpcm9ubWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LmNsYXNzZXMuZW52aXJvbm1lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxpREFBaUQ7QUFFakQ7SUFTRTtRQUNFLElBQUksQ0FBQyxVQUFVLEdBQUcsT0FBTyxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQ3hDLElBQUksQ0FBQyxTQUFTLEdBQUcsT0FBTyxDQUFDLFNBQVMsRUFBRSxDQUFBO1FBQ3BDLElBQUksQ0FBQyxTQUFTLEdBQUcsT0FBTyxDQUFDLGtCQUFrQixFQUFFLENBQUE7UUFDN0MsSUFBSSxDQUFDLE1BQU0sR0FBRyxPQUFPLENBQUMsTUFBTSxFQUFFLENBQUE7UUFDOUIsSUFBSSxDQUFDLFdBQVcsR0FBRyxPQUFPLENBQUMsY0FBYyxFQUFFLENBQUE7UUFDM0MsSUFBSSxDQUFDLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxFQUFFLENBQUE7UUFDMUIsSUFBSSxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUMsUUFBUSxFQUFFLENBQUE7UUFDbEMsSUFBSSxDQUFDLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxFQUFFLENBQUE7SUFDNUIsQ0FBQztJQUFBLENBQUM7Q0FDSDtBQW5CRCxrQ0FtQkMifQ==
|
|
21
dist/smartenv.classes.smartenv.d.ts
vendored
Normal file
21
dist/smartenv.classes.smartenv.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
export interface IEnvObject {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
export declare class Smartenv {
|
||||||
|
runtimeEnv: string;
|
||||||
|
isBrowser: boolean;
|
||||||
|
userAgent: string;
|
||||||
|
isNode: boolean;
|
||||||
|
nodeVersion: string;
|
||||||
|
isCI: boolean;
|
||||||
|
constructor();
|
||||||
|
/**
|
||||||
|
* get environment variables that fit the description
|
||||||
|
*/
|
||||||
|
getEnvVars(regexArg: RegExp): Promise<void>;
|
||||||
|
/**
|
||||||
|
* prints the environment to console
|
||||||
|
*/
|
||||||
|
printEnv(): Promise<void>;
|
||||||
|
}
|
49
dist/smartenv.classes.smartenv.js
vendored
Normal file
49
dist/smartenv.classes.smartenv.js
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
"use strict";
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const helpers = require("./smartenv.envhelpers");
|
||||||
|
class Smartenv {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
;
|
||||||
|
/**
|
||||||
|
* get environment variables that fit the description
|
||||||
|
*/
|
||||||
|
getEnvVars(regexArg) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let EnvironmentArray = [];
|
||||||
|
// TODO: plugins.smartparam.forEachMinimatch()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* prints the environment to console
|
||||||
|
*/
|
||||||
|
printEnv() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (this.isNode) {
|
||||||
|
console.log('running on NODE');
|
||||||
|
let 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);
|
||||||
|
}
|
||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LElBQUksZUFBZSxHQUFHLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDLE9BQU8sQ0FBQTtnQkFDeEQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxrQkFBa0IsR0FBRyxJQUFJLENBQUMsV0FBVyxHQUFHLDJCQUEyQixHQUFHLGVBQWUsQ0FBQyxDQUFBO1lBQ3BHLENBQUM7WUFBQyxJQUFJLENBQUMsQ0FBQztnQkFDTixPQUFPLENBQUMsR0FBRyxDQUFDLG9CQUFvQixDQUFDLENBQUE7Z0JBQ2pDLE9BQU8sQ0FBQyxHQUFHLENBQUMsYUFBYSxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtZQUM3QyxDQUFDO1FBQ0gsQ0FBQztLQUFBO0NBQ0Y7QUFyQ0QsNEJBcUNDIn0=
|
5
dist/smartenv.envhelpers.d.ts
vendored
5
dist/smartenv.envhelpers.d.ts
vendored
@ -1,8 +1,9 @@
|
|||||||
export declare let getEnvString: () => string;
|
export declare let getEnvString: () => string;
|
||||||
|
/**
|
||||||
|
* gets the user agent string in a browser
|
||||||
|
*/
|
||||||
export declare let getUserAgentString: () => string;
|
export declare let getUserAgentString: () => string;
|
||||||
export declare let isNode: () => boolean;
|
export declare let isNode: () => boolean;
|
||||||
export declare let getNodeVersion: () => string;
|
export declare let getNodeVersion: () => string;
|
||||||
export declare let isBrowser: () => boolean;
|
export declare let isBrowser: () => boolean;
|
||||||
export declare let isCI: () => boolean;
|
export declare let isCI: () => boolean;
|
||||||
export declare let isC9: () => boolean;
|
|
||||||
export declare let isTravis: () => boolean;
|
|
||||||
|
24
dist/smartenv.envhelpers.js
vendored
24
dist/smartenv.envhelpers.js
vendored
@ -8,12 +8,15 @@ exports.getEnvString = function () {
|
|||||||
return 'node';
|
return 'node';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* gets the user agent string in a browser
|
||||||
|
*/
|
||||||
exports.getUserAgentString = function () {
|
exports.getUserAgentString = function () {
|
||||||
if (exports.isBrowser()) {
|
if (exports.isBrowser()) {
|
||||||
return navigator.userAgent;
|
return navigator.userAgent;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return undefined;
|
return 'undefined';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
exports.isNode = function () {
|
exports.isNode = function () {
|
||||||
@ -34,21 +37,4 @@ exports.isCI = function () {
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
exports.isC9 = function () {
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuZW52aGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LmVudmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFDVyxRQUFBLFlBQVksR0FBRztJQUN4QixFQUFFLENBQUMsQ0FBQyxPQUFPLE1BQU0sS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQ2xDLE1BQU0sQ0FBQyxTQUFTLENBQUE7SUFDbEIsQ0FBQztJQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxPQUFPLE9BQU8sS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQzFDLE1BQU0sQ0FBQyxNQUFNLENBQUE7SUFDZixDQUFDO0FBQ0gsQ0FBQyxDQUFBO0FBRUQ7O0dBRUc7QUFDUSxRQUFBLGtCQUFrQixHQUFHO0lBQzlCLEVBQUUsQ0FBQyxDQUFDLGlCQUFTLEVBQUUsQ0FBQyxDQUFDLENBQUM7UUFDaEIsTUFBTSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUE7SUFDNUIsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ04sTUFBTSxDQUFDLFdBQVcsQ0FBQTtJQUNwQixDQUFDO0FBQ0gsQ0FBQyxDQUFBO0FBRVUsUUFBQSxNQUFNLEdBQUc7SUFDbEIsTUFBTSxDQUFDLG9CQUFZLEVBQUUsS0FBSyxNQUFNLENBQUE7QUFDbEMsQ0FBQyxDQUFBO0FBRVUsUUFBQSxjQUFjLEdBQUc7SUFDMUIsTUFBTSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUE7QUFDeEIsQ0FBQyxDQUFBO0FBRVUsUUFBQSxTQUFTLEdBQUc7SUFDckIsTUFBTSxDQUFDLENBQUMsY0FBTSxFQUFFLENBQUE7QUFDbEIsQ0FBQyxDQUFBO0FBRVUsUUFBQSxJQUFJLEdBQUc7SUFDaEIsRUFBRSxDQUFDLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO1FBQ25CLE1BQU0sQ0FBQyxJQUFJLENBQUE7SUFDYixDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDTixNQUFNLENBQUMsS0FBSyxDQUFBO0lBQ2QsQ0FBQztJQUFBLENBQUM7QUFDSixDQUFDLENBQUEifQ==
|
||||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuZW52aGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LmVudmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFDVyxRQUFBLFlBQVksR0FBRztJQUN4QixFQUFFLENBQUMsQ0FBQyxPQUFPLE1BQU0sS0FBS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Q0osQ0FBQyxDQUFBO0FBRVUsUUFBQSxJQUFJLEdBQUc7SUFDaEIsRUFBRSxDQUFDLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQzVCLE1BQU0sQ0FBQyxJQUFJLENBQUE7SUFDYixDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDTixNQUFNLENBQUMsS0FBSyxDQUFBO0lBQ2QsQ0FBQztBQUNILENBQUMsQ0FBQTtBQUVVLFFBQUEsUUFBUSxHQUFHO0lBQ3BCLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztRQUN2QixNQUFNLENBQUMsSUFBSSxDQUFBO0lBQ2IsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ04sTUFBTSxDQUFDLEtBQUssQ0FBQTtJQUNkLENBQUM7SUFBQSxDQUFDO0FBQ0osQ0FBQyxDQUFBIn0=
|
|
15
dist/smartenv.export.d.ts
vendored
15
dist/smartenv.export.d.ts
vendored
@ -1,15 +0,0 @@
|
|||||||
import * as classes from './smartenv.classes.environment';
|
|
||||||
/**
|
|
||||||
* returns the environment
|
|
||||||
* @returns {Environment}
|
|
||||||
*/
|
|
||||||
export declare let getEnv: () => classes.Environment;
|
|
||||||
/**
|
|
||||||
* prints the environment to console
|
|
||||||
*/
|
|
||||||
export declare let printEnv: () => void;
|
|
||||||
export interface IEnvObject {
|
|
||||||
name: string;
|
|
||||||
value: string;
|
|
||||||
}
|
|
||||||
export declare let getEnvVars: (regexArg: RegExp) => Promise<IEnvObject[]>;
|
|
53
dist/smartenv.export.js
vendored
53
dist/smartenv.export.js
vendored
@ -1,53 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const classes = require("./smartenv.classes.environment");
|
|
||||||
const objectStorage = require("./smartenv.objectstorage");
|
|
||||||
let environment = null;
|
|
||||||
/**
|
|
||||||
* returns the environment
|
|
||||||
* @returns {Environment}
|
|
||||||
*/
|
|
||||||
exports.getEnv = function () {
|
|
||||||
if (!environment) {
|
|
||||||
environment = new classes.Environment();
|
|
||||||
}
|
|
||||||
;
|
|
||||||
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()));
|
|
||||||
};
|
|
||||||
exports.getEnvVars = (regexArg) => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let resultArray = [];
|
|
||||||
for (let key in process.env) {
|
|
||||||
if (regexArg.test(key)) {
|
|
||||||
resultArray.push({
|
|
||||||
name: key,
|
|
||||||
value: process.env[key]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resultArray;
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base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SxDQUFDLE1BQU0sRUFBRSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQ3RELENBQUM7SUFDRCxPQUFPLENBQUMsR0FBRyxDQUFDLDJFQUEyRSxDQUFDLENBQUE7SUFDeEYsT0FBTyxDQUFDLEdBQUcsQ0FBQyxNQUFNLENBQUMsbUJBQW1CLENBQUMsYUFBYSxDQUFDLEdBQUcsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDLENBQUE7QUFDckUsQ0FBQyxDQUFBO0FBT1UsUUFBQSxVQUFVLEdBQUcsQ0FBTyxRQUFnQjtJQUM3QyxJQUFJLFdBQVcsR0FBaUIsRUFBRSxDQUFBO0lBQ2xDLEdBQUcsQ0FBQyxDQUFDLElBQUksR0FBRyxJQUFJLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO1FBQzVCLEVBQUUsQ0FBQyxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ3ZCLFdBQVcsQ0FBQyxJQUFJLENBQUM7Z0JBQ2YsSUFBSSxFQUFFLEdBQUc7Z0JBQ1QsS0FBSyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDO2FBQ3hCLENBQUMsQ0FBQTtRQUNKLENBQUM7SUFDSCxDQUFDO0lBQ0QsTUFBTSxDQUFDLFdBQVcsQ0FBQTtBQUNwQixDQUFDLENBQUEsQ0FBQSJ9
|
|
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: (keyNameArg, objectArg) => {
|
|
||||||
if (!keyNameArg) {
|
|
||||||
console.log('keyName is undefined');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!objectArg) {
|
|
||||||
console.log('objectArg is undefined');
|
|
||||||
}
|
|
||||||
if (!(exports.obsItems[keyNameArg])) {
|
|
||||||
exports.obsItems[keyNameArg] = objectArg;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log('object is already present, so add operation has failed.');
|
|
||||||
}
|
|
||||||
return exports.obsItems[keyNameArg];
|
|
||||||
},
|
|
||||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYub2JqZWN0c3RvcmFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52Lm9iamVjdHN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sZ0JBQVEsQ0FBRSxZQUFZLENBQUUsS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDdkQsZ0JBQVEsQ0FBRSxZQUFZLENBQUUsR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxnQkFBUSxDQUFFLFlBQVksQ0FBRSxFQUFFLFNBQVMsQ0FBQyxDQUFBO1FBQ3ZGLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNOLE9BQU8sQ0FBQyxHQUFHLENBQUMscURBQXFELENBQUMsQ0FBQTtRQUNwRSxDQUFDO0lBQ0gsQ0FBQztJQUNELEdBQUcsRUFBRSxVQUFVLE9BQU87UUFDcEIsTUFBTSxDQUFDLGdCQUFRLENBQUUsT0FBTyxDQUFFLENBQUE7SUFDNUIsQ0FBQztJQUNELE1BQU0sRUFBRTtRQUNOLE1BQU0sQ0FBQyxnQkFBUSxDQUFBO0lBQ2pCLENBQUM7SUFDRCxXQUFXLEVBQUUsVUFBVSxRQUFRO1FBQzdCLGdCQUFRLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsZ0JBQVEsRUFBRSxRQUFRLENBQUMsQ0FBQTtRQUNwRCxNQUFNLENBQUMsZ0JBQVEsQ0FBQTtJQUNqQixDQUFDO0NBQ0YsQ0FBQSJ9
|
|
3
dist/smartenv.plugins.d.ts
vendored
3
dist/smartenv.plugins.d.ts
vendored
@ -1,4 +1,5 @@
|
|||||||
import 'typings-global';
|
import 'typings-global';
|
||||||
|
import * as smartparam from 'smartparam';
|
||||||
import * as smartq from 'smartq';
|
import * as smartq from 'smartq';
|
||||||
import * as lodash from 'lodash';
|
import * as lodash from 'lodash';
|
||||||
export { smartq, lodash };
|
export { lodash, smartparam, smartq };
|
||||||
|
4
dist/smartenv.plugins.js
vendored
4
dist/smartenv.plugins.js
vendored
@ -1,8 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
|
const smartparam = require("smartparam");
|
||||||
|
exports.smartparam = smartparam;
|
||||||
const smartq = require("smartq");
|
const smartq = require("smartq");
|
||||||
exports.smartq = smartq;
|
exports.smartq = smartq;
|
||||||
const lodash = require("lodash");
|
const lodash = require("lodash");
|
||||||
exports.lodash = lodash;
|
exports.lodash = lodash;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIsaUNBQWdDO0FBSTVCLHdCQUFNO0FBSFYsaUNBQWdDO0FBSTVCLHdCQUFNIn0=
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIseUNBQXdDO0FBTXBDLGdDQUFVO0FBTGQsaUNBQWdDO0FBTTVCLHdCQUFNO0FBTFYsaUNBQWdDO0FBRzVCLHdCQUFNIn0=
|
@ -23,11 +23,11 @@
|
|||||||
"homepage": "https://gitlab.com/pushrocks/smartenv",
|
"homepage": "https://gitlab.com/pushrocks/smartenv",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
|
"smartparam": "^0.1.1",
|
||||||
"smartq": "^1.1.1",
|
"smartq": "^1.1.1",
|
||||||
"typings-global": "^1.0.14"
|
"typings-global": "^1.0.16"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"beautylog": "^6.1.5",
|
|
||||||
"tapbundle": "^1.0.5"
|
"tapbundle": "^1.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
38
test/test.ts
38
test/test.ts
@ -1,38 +1,14 @@
|
|||||||
import * as smartenv from '../dist/index.js'
|
|
||||||
import * as beautylog from 'beautylog'
|
|
||||||
|
|
||||||
import { tap, expect } from 'tapbundle'
|
import { tap, expect } from 'tapbundle'
|
||||||
|
import * as smartenv from '../dist/index'
|
||||||
|
|
||||||
|
let testEnv: smartenv.Smartenv
|
||||||
|
|
||||||
tap.test('should print env', async () => {
|
tap.test('should print env', async () => {
|
||||||
smartenv.printEnv()
|
testEnv = new smartenv.Smartenv()
|
||||||
}).catch(tap.threw)
|
|
||||||
|
|
||||||
// test smartenv.obs.add
|
|
||||||
tap.test('obs add something', async () => {
|
|
||||||
smartenv.obs.add('myTestObject', { key1: 'Peter' })
|
|
||||||
smartenv.obs.add('myTestObject', { key1: 'Klaus' }) // now trying to add a second
|
|
||||||
return expect(smartenv.obs.get('myTestObject').key1).to.equal('Peter')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// test smartenv.obs.replace
|
tap.test('should print a overview to console', async () => {
|
||||||
tap.test('', async () => {
|
testEnv.printEnv()
|
||||||
smartenv.obs.replace('myTestObject', { key1: 'Klaus' })
|
|
||||||
expect(smartenv.obs.get('myTestObject').key1).to.equal('Klaus')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
tap.test('should merge things', async () => {
|
tap.start()
|
||||||
smartenv.obs.merge('myTestObject', { key2: 'Peter' })
|
|
||||||
expect(smartenv.obs.get('myTestObject').key1).to.equal('Klaus')
|
|
||||||
return expect(smartenv.obs.get('myTestObject').key2).to.equal('Peter')
|
|
||||||
})
|
|
||||||
|
|
||||||
tap.test('set via get', async () => {
|
|
||||||
smartenv.obs.get('myTestObject').key2 = 'hello'
|
|
||||||
return expect(smartenv.obs.get('myTestObject').key2).to.equal('hello')
|
|
||||||
})
|
|
||||||
|
|
||||||
tap.test('should get regex env array', async () => {
|
|
||||||
process.env.CUSTOM = 'some'
|
|
||||||
let resultArray = await smartenv.getEnvVars(/CUSTOM/)
|
|
||||||
return expect(resultArray).to.be.length(1)
|
|
||||||
})
|
|
||||||
|
11
ts/index.ts
11
ts/index.ts
@ -1,10 +1 @@
|
|||||||
import {getEnv, printEnv, getEnvVars} from './smartenv.export'
|
export * from './smartenv.classes.smartenv'
|
||||||
import { obs } from './smartenv.objectstorage'
|
|
||||||
|
|
||||||
|
|
||||||
export {
|
|
||||||
getEnv,
|
|
||||||
getEnvVars,
|
|
||||||
printEnv,
|
|
||||||
obs
|
|
||||||
}
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
import helpers = require('./smartenv.envhelpers')
|
|
||||||
|
|
||||||
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()
|
|
||||||
};
|
|
||||||
}
|
|
47
ts/smartenv.classes.smartenv.ts
Normal file
47
ts/smartenv.classes.smartenv.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import * as plugins from './smartenv.plugins'
|
||||||
|
import helpers = require('./smartenv.envhelpers')
|
||||||
|
|
||||||
|
// interfaces
|
||||||
|
export interface IEnvObject {
|
||||||
|
name: string
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Smartenv {
|
||||||
|
runtimeEnv: string
|
||||||
|
isBrowser: boolean
|
||||||
|
userAgent: string
|
||||||
|
isNode: boolean
|
||||||
|
nodeVersion: string
|
||||||
|
isCI: 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()
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get environment variables that fit the description
|
||||||
|
*/
|
||||||
|
async getEnvVars (regexArg: RegExp) {
|
||||||
|
let EnvironmentArray = []
|
||||||
|
// TODO: plugins.smartparam.forEachMinimatch()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prints the environment to console
|
||||||
|
*/
|
||||||
|
async printEnv () {
|
||||||
|
if (this.isNode) {
|
||||||
|
console.log('running on NODE')
|
||||||
|
let 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,11 +7,14 @@ export let getEnvString = function (): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the user agent string in a browser
|
||||||
|
*/
|
||||||
export let getUserAgentString = function (): string {
|
export let getUserAgentString = function (): string {
|
||||||
if (isBrowser()) {
|
if (isBrowser()) { // make sure we are in Browser
|
||||||
return navigator.userAgent
|
return navigator.userAgent
|
||||||
} else {
|
} else {
|
||||||
return undefined
|
return 'undefined'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,19 +37,3 @@ export let isCI = function () {
|
|||||||
return false
|
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
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
@ -1,56 +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.environment'
|
|
||||||
import * as objectStorage from './smartenv.objectstorage'
|
|
||||||
|
|
||||||
|
|
||||||
let environment: classes.Environment = null
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the environment
|
|
||||||
* @returns {Environment}
|
|
||||||
*/
|
|
||||||
export let getEnv = function () {
|
|
||||||
if (!environment) {
|
|
||||||
environment = new classes.Environment()
|
|
||||||
};
|
|
||||||
return environment
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* prints the environment to console
|
|
||||||
*/
|
|
||||||
export let 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()))
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IEnvObject {
|
|
||||||
name: string
|
|
||||||
value: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export let getEnvVars = async (regexArg: RegExp) => {
|
|
||||||
let resultArray: IEnvObject[] = []
|
|
||||||
for (let key in process.env) {
|
|
||||||
if (regexArg.test(key)) {
|
|
||||||
resultArray.push({
|
|
||||||
name: key,
|
|
||||||
value: process.env[key]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resultArray
|
|
||||||
}
|
|
@ -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: (keyNameArg, objectArg) => {
|
|
||||||
if (!keyNameArg) {
|
|
||||||
console.log('keyName is undefined')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!objectArg) {
|
|
||||||
console.log('objectArg is undefined')
|
|
||||||
}
|
|
||||||
if (!(obsItems[ keyNameArg ])) {
|
|
||||||
obsItems[ keyNameArg ] = objectArg
|
|
||||||
} else {
|
|
||||||
console.log('object is already present, so add operation has failed.')
|
|
||||||
}
|
|
||||||
return obsItems[ keyNameArg ]
|
|
||||||
},
|
|
||||||
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,10 @@
|
|||||||
import 'typings-global'
|
import 'typings-global'
|
||||||
|
import * as smartparam from 'smartparam'
|
||||||
import * as smartq from 'smartq'
|
import * as smartq from 'smartq'
|
||||||
import * as lodash from 'lodash'
|
import * as lodash from 'lodash'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
smartq,
|
lodash,
|
||||||
lodash
|
smartparam,
|
||||||
|
smartq
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user