🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@commercetools-frontend/cypress-environments

Package Overview
Dependencies
Maintainers
0
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercetools-frontend/cypress-environments - npm Package Compare versions

Comparing version

to
0.1.5

34

dist/commercetools-frontend-cypress-environments.cjs.dev.js

@@ -45,3 +45,3 @@ 'use strict';

function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments', {

@@ -61,3 +61,3 @@ searchStrategy: 'project'

if (doesFileExist(envPath)) {
console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
console.log(`✅ Found and loading environment variables from: '${envPath}'`);
const envFileContents = fs__default["default"].readFileSync(envPath, {

@@ -69,3 +69,3 @@ encoding: 'utf8'

} else {
console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
return null;

@@ -78,7 +78,7 @@ }

} catch (e) {
throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
}
}
async function getConfigurationForEnvironment(environmentName) {
var _context, _context2, _context3;
var _context, _context2;
// NOTE: On CI the *.ci secrests are not excluded. Locally the are in case

@@ -90,12 +90,12 @@ // decrypted files are available on a developer's machine.

if (isCI) {
console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
} else {
console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
}
console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
const configResult = await loadConfig();
const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
const allEnvironmentConfigs = configResult?.config;
const configForEnvironment = _findInstanceProperty__default["default"](_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
if (!configForEnvironment) {
throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
}

@@ -108,12 +108,12 @@ const secretsFiles = await glob.glob(configForEnvironment.secrets.glob, {

});
console.log(_concatInstanceProperty__default["default"](_context2 = "\u2139\uFE0F Found ".concat(secretsFiles.length, " secret file(s) and ")).call(_context2, configFiles.length, " config file(s) matching the defined globs."));
console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
if (secretsFiles.length === 0 || configFiles.length === 0) {
console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
}
const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context2 = [...configFiles, ...secretsFiles]).call(_context2, (previousParsedEnvFileContents, nextEnvFilePath) => {
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
let matchingParsedEnvFileContentsForCIOrLocal = null;
if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
}

@@ -125,7 +125,7 @@ return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);

if (rootDir) {
const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', `.env.${environmentName}.config`);
if (doesFileExist(pathToSharedEnvironmentConfiguration)) {
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
} else {
console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
}

@@ -132,0 +132,0 @@ }

@@ -45,3 +45,3 @@ 'use strict';

function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments', {

@@ -61,3 +61,3 @@ searchStrategy: 'project'

if (doesFileExist(envPath)) {
console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
console.log(`✅ Found and loading environment variables from: '${envPath}'`);
const envFileContents = fs__default["default"].readFileSync(envPath, {

@@ -69,3 +69,3 @@ encoding: 'utf8'

} else {
console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
return null;

@@ -78,7 +78,7 @@ }

} catch (e) {
throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
}
}
async function getConfigurationForEnvironment(environmentName) {
var _context, _context2, _context3;
var _context, _context2;
// NOTE: On CI the *.ci secrests are not excluded. Locally the are in case

@@ -90,12 +90,12 @@ // decrypted files are available on a developer's machine.

if (isCI) {
console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
} else {
console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
}
console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
const configResult = await loadConfig();
const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
const allEnvironmentConfigs = configResult?.config;
const configForEnvironment = _findInstanceProperty__default["default"](_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
if (!configForEnvironment) {
throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
}

@@ -108,12 +108,12 @@ const secretsFiles = await glob.glob(configForEnvironment.secrets.glob, {

});
console.log(_concatInstanceProperty__default["default"](_context2 = "\u2139\uFE0F Found ".concat(secretsFiles.length, " secret file(s) and ")).call(_context2, configFiles.length, " config file(s) matching the defined globs."));
console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
if (secretsFiles.length === 0 || configFiles.length === 0) {
console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
}
const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context2 = [...configFiles, ...secretsFiles]).call(_context2, (previousParsedEnvFileContents, nextEnvFilePath) => {
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
let matchingParsedEnvFileContentsForCIOrLocal = null;
if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
}

@@ -125,7 +125,7 @@ return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);

if (rootDir) {
const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', `.env.${environmentName}.config`);
if (doesFileExist(pathToSharedEnvironmentConfiguration)) {
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
} else {
console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
}

@@ -132,0 +132,0 @@ }

@@ -22,3 +22,3 @@ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';

function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
const cypressEnvironmentsConfigExplorer = cosmiconfig('cypress-environments', {

@@ -38,3 +38,3 @@ searchStrategy: 'project'

if (doesFileExist(envPath)) {
console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
console.log(`✅ Found and loading environment variables from: '${envPath}'`);
const envFileContents = fs.readFileSync(envPath, {

@@ -46,3 +46,3 @@ encoding: 'utf8'

} else {
console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
return null;

@@ -55,7 +55,7 @@ }

} catch (e) {
throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
}
}
async function getConfigurationForEnvironment(environmentName) {
var _context, _context2, _context3;
var _context, _context2;
// NOTE: On CI the *.ci secrests are not excluded. Locally the are in case

@@ -67,12 +67,12 @@ // decrypted files are available on a developer's machine.

if (isCI) {
console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
} else {
console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
}
console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
const configResult = await loadConfig();
const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
const allEnvironmentConfigs = configResult?.config;
const configForEnvironment = _findInstanceProperty(_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
if (!configForEnvironment) {
throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
}

@@ -85,12 +85,12 @@ const secretsFiles = await glob(configForEnvironment.secrets.glob, {

});
console.log(_concatInstanceProperty(_context2 = "\u2139\uFE0F Found ".concat(secretsFiles.length, " secret file(s) and ")).call(_context2, configFiles.length, " config file(s) matching the defined globs."));
console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
if (secretsFiles.length === 0 || configFiles.length === 0) {
console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
}
const mergedConfigurationAndSecrests = _reduceInstanceProperty(_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
const mergedConfigurationAndSecrests = _reduceInstanceProperty(_context2 = [...configFiles, ...secretsFiles]).call(_context2, (previousParsedEnvFileContents, nextEnvFilePath) => {
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
let matchingParsedEnvFileContentsForCIOrLocal = null;
if (!_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
}

@@ -102,7 +102,7 @@ return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);

if (rootDir) {
const pathToSharedEnvironmentConfiguration = path.join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
const pathToSharedEnvironmentConfiguration = path.join(rootDir, 'config', `.env.${environmentName}.config`);
if (doesFileExist(pathToSharedEnvironmentConfiguration)) {
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
} else {
console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
}

@@ -109,0 +109,0 @@ }

{
"name": "@commercetools-frontend/cypress-environments",
"version": "0.1.4",
"version": "0.1.5",
"description": "Cypress package to setup environment configuration using dotenv files",

@@ -24,3 +24,3 @@ "license": "MIT",

"dotenv": "16.4.5",
"glob": "10.4.2",
"glob": "10.4.5",
"pkg-dir": "5.0.0"

@@ -31,3 +31,3 @@ },

"@types/glob": "8.1.0",
"@types/node": "20.14.9",
"@types/node": "20.14.14",
"typescript": "5.2.2"

@@ -34,0 +34,0 @@ },