@mondaycom/apps-sdk
Advanced tools
Comparing version 0.1.1-beta.1 to 0.1.1-beta.2
@@ -41,3 +41,4 @@ "use strict"; | ||
if (!(0, guards_1.isDefined)(environmentDataFileName)) { | ||
throw new Error('Environment file name is not defined'); | ||
logger.error('[EnvironmentVariablesManager] Environment file name is not defined'); | ||
return; | ||
} | ||
@@ -47,3 +48,4 @@ var environmentDataFilePath = "/secrets/".concat(environmentDataFileName); | ||
if (!isEnvironmentFileExists) { | ||
throw new Error('Environment file does not exists in path'); | ||
logger.error('[EnvironmentVariablesManager] Environment file does not exist in path'); | ||
return; | ||
} | ||
@@ -55,3 +57,2 @@ var environmentData = fs_1["default"].readFileSync(environmentDataFilePath, 'utf8'); | ||
function EnvironmentVariablesManager(options) { | ||
this.cachedEnvironmentData = {}; | ||
this.shouldUpdateProcessEnv = !!options.updateProcessEnv; | ||
@@ -68,3 +69,3 @@ this.initEnv(options); | ||
if ((0, env_1.isDevelopmentEnvironment)()) { | ||
logger.info('[EnvironmentVariablesManager.initEnv] Running in development environment, skipping init', { mondayInternal: false }); | ||
logger.info('[EnvironmentVariablesManager] Running in development environment, skipping init', { mondayInternal: false }); | ||
this.cachedEnvironmentData = process.env; | ||
@@ -76,2 +77,5 @@ return; | ||
this.cachedEnvironmentData = readEnvironmentData(); | ||
if (!(0, guards_1.isDefined)(this.cachedEnvironmentData)) { | ||
return; | ||
} | ||
if (this.shouldUpdateProcessEnv) { | ||
@@ -84,6 +88,10 @@ Object.entries(this.cachedEnvironmentData).forEach(function (_a) { | ||
} | ||
logger.info('[EnvironmentVariablesManager.initEnv] Initialized environment variables data', { mondayInternal: false }); | ||
logger.info('[EnvironmentVariablesManager] Initialized environment variables data', { mondayInternal: false }); | ||
}; | ||
EnvironmentVariablesManager.prototype.getKeys = function (options) { | ||
this.initEnvIfNeeded(options); | ||
if (!(0, guards_1.isDefined)(this.cachedEnvironmentData)) { | ||
logger.error('[EnvironmentVariablesManager.getKeys] There is an issue with loading keys', { mondayInternal: false }); | ||
return []; | ||
} | ||
return Object.keys(this.cachedEnvironmentData); | ||
@@ -94,2 +102,6 @@ }; | ||
this.initEnvIfNeeded(options); | ||
if (!(0, guards_1.isDefined)(this.cachedEnvironmentData)) { | ||
logger.error('[EnvironmentVariablesManager.get] There is an issue with loading data for key', { mondayInternal: false }); | ||
return null; | ||
} | ||
return this.cachedEnvironmentData[key]; | ||
@@ -96,0 +108,0 @@ }; |
{ | ||
"name": "@mondaycom/apps-sdk", | ||
"version": "0.1.1-beta.1", | ||
"version": "0.1.1-beta.2", | ||
"description": "monday apps SDK for NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
@@ -12,3 +12,4 @@ import fs from 'fs'; | ||
if (!isDefined(environmentDataFileName)) { | ||
throw new Error('Environment file name is not defined'); | ||
logger.error('[EnvironmentVariablesManager] Environment file name is not defined'); | ||
return; | ||
} | ||
@@ -18,3 +19,4 @@ var environmentDataFilePath = "/secrets/".concat(environmentDataFileName); | ||
if (!isEnvironmentFileExists) { | ||
throw new Error('Environment file does not exists in path'); | ||
logger.error('[EnvironmentVariablesManager] Environment file does not exist in path'); | ||
return; | ||
} | ||
@@ -26,3 +28,2 @@ var environmentData = fs.readFileSync(environmentDataFilePath, 'utf8'); | ||
function EnvironmentVariablesManager(options) { | ||
this.cachedEnvironmentData = {}; | ||
this.shouldUpdateProcessEnv = !!options.updateProcessEnv; | ||
@@ -39,3 +40,3 @@ this.initEnv(options); | ||
if (isDevelopmentEnvironment()) { | ||
logger.info('[EnvironmentVariablesManager.initEnv] Running in development environment, skipping init', { mondayInternal: false }); | ||
logger.info('[EnvironmentVariablesManager] Running in development environment, skipping init', { mondayInternal: false }); | ||
this.cachedEnvironmentData = process.env; | ||
@@ -47,2 +48,5 @@ return; | ||
this.cachedEnvironmentData = readEnvironmentData(); | ||
if (!isDefined(this.cachedEnvironmentData)) { | ||
return; | ||
} | ||
if (this.shouldUpdateProcessEnv) { | ||
@@ -55,6 +59,10 @@ Object.entries(this.cachedEnvironmentData).forEach(function (_a) { | ||
} | ||
logger.info('[EnvironmentVariablesManager.initEnv] Initialized environment variables data', { mondayInternal: false }); | ||
logger.info('[EnvironmentVariablesManager] Initialized environment variables data', { mondayInternal: false }); | ||
}; | ||
EnvironmentVariablesManager.prototype.getKeys = function (options) { | ||
this.initEnvIfNeeded(options); | ||
if (!isDefined(this.cachedEnvironmentData)) { | ||
logger.error('[EnvironmentVariablesManager.getKeys] There is an issue with loading keys', { mondayInternal: false }); | ||
return []; | ||
} | ||
return Object.keys(this.cachedEnvironmentData); | ||
@@ -65,2 +73,6 @@ }; | ||
this.initEnvIfNeeded(options); | ||
if (!isDefined(this.cachedEnvironmentData)) { | ||
logger.error('[EnvironmentVariablesManager.get] There is an issue with loading data for key', { mondayInternal: false }); | ||
return null; | ||
} | ||
return this.cachedEnvironmentData[key]; | ||
@@ -67,0 +79,0 @@ }; |
{ | ||
"name": "@mondaycom/apps-sdk", | ||
"version": "0.1.1-beta.1", | ||
"version": "0.1.1-beta.2", | ||
"description": "monday apps SDK for NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
import { JsonValue } from '../types/general'; | ||
import { GetOptions, IEnvironmentVariablesManager, Options } from '../types/environment-vriable-manager'; | ||
import { GetOptions, IEnvironmentVariablesManager, Options } from '../types/environment-variables-manager'; | ||
export declare class EnvironmentVariablesManager implements IEnvironmentVariablesManager { | ||
private cachedEnvironmentData; | ||
private cachedEnvironmentData?; | ||
private shouldUpdateProcessEnv; | ||
@@ -10,3 +10,3 @@ constructor(options: Options); | ||
getKeys(options?: GetOptions): Array<string>; | ||
get<T extends JsonValue>(key: string, options?: GetOptions): T; | ||
get(key: string, options?: GetOptions): JsonValue; | ||
} |
{ | ||
"name": "@mondaycom/apps-sdk", | ||
"version": "0.1.1-beta.1", | ||
"version": "0.1.1-beta.2", | ||
"description": "monday apps SDK for NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
217935
2938