@commercetools-frontend/cypress-environments
Advanced tools
Comparing version
@@ -7,3 +7,2 @@ 'use strict'; | ||
var fs = require('fs'); | ||
var url = require('url'); | ||
var util = require('util'); | ||
@@ -18,3 +17,2 @@ var glob = require('glob'); | ||
var fs__default = /*#__PURE__*/_interopDefault(fs); | ||
var url__default = /*#__PURE__*/_interopDefault(url); | ||
var glob__default = /*#__PURE__*/_interopDefault(glob); | ||
@@ -24,7 +22,5 @@ var dotenv__default = /*#__PURE__*/_interopDefault(dotenv); | ||
const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments'); | ||
const isCI = process.env.CI === true || process.env.CI === 'true'; | ||
const isCI = String(process.env.CI) === 'true'; | ||
const promisifiedGlob = util.promisify(glob__default["default"]); | ||
const __dirname$1 = path__default["default"].dirname(url__default["default"].fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('dist/commercetools-frontend-cypress-environments.cjs.dev.js', document.baseURI).href)))); | ||
function getParsedEnvFileContents(envPath) { | ||
@@ -54,5 +50,5 @@ if (fs__default["default"].existsSync(envPath)) { | ||
if (isCI) { | ||
console.log(`ℹ️ 'CI' environment variables are defined. Assuming operating from a CI system.`); | ||
console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`); | ||
} else { | ||
console.log(`ℹ️ 'CI' environment variables are not defined. Assuming you are running locally.`); | ||
console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`); | ||
} // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case | ||
@@ -62,6 +58,7 @@ // decrypted files are available on a developer's machine. | ||
const ignoredGlobs = ['**/*.enc', '**/*.template', !isCI && '**/*.ci'].filter(Boolean); | ||
const { | ||
config: allEnvironmentConfigs | ||
} = await loadConfig(); | ||
const ignoredGlobs = ['**/*.enc', '**/*.template']; | ||
const ignoredCIGlobs = ['**/*.ci']; | ||
const allIgnoredGlobs = isCI ? ignoredGlobs.concat(ignoredCIGlobs) : ignoredGlobs; | ||
const configResult = await loadConfig(); | ||
const allEnvironmentConfigs = configResult?.config; | ||
const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName); | ||
@@ -74,6 +71,6 @@ | ||
const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, { | ||
ignore: ignoredGlobs | ||
ignore: allIgnoredGlobs | ||
}); | ||
const configFiles = await promisifiedGlob(configForEnvironment.config.glob, { | ||
ignore: ignoredGlobs | ||
ignore: allIgnoredGlobs | ||
}); | ||
@@ -89,3 +86,3 @@ console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`); | ||
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath); | ||
let matchingParsedEnvFileContentsForCIOrLocal = {}; | ||
let matchingParsedEnvFileContentsForCIOrLocal = null; | ||
@@ -101,3 +98,3 @@ if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) { | ||
}, {}); | ||
const pathToSharedEnvironmentConfiguration = path__default["default"].join(__dirname$1, 'config', `.env.${environmentName}.config`); | ||
const pathToSharedEnvironmentConfiguration = path__default["default"].join(__dirname, '..', 'config', `.env.${environmentName}.config`); | ||
let sharedEnvironmentConfiguration = null; | ||
@@ -108,3 +105,3 @@ | ||
} else { | ||
console.log(`ℹ️ Not shared configuration for ${environmentName} defined.`); | ||
console.log(`ℹ️ No shared configuration for ${environmentName} defined.`); | ||
} | ||
@@ -111,0 +108,0 @@ |
@@ -7,3 +7,2 @@ 'use strict'; | ||
var fs = require('fs'); | ||
var url = require('url'); | ||
var util = require('util'); | ||
@@ -18,3 +17,2 @@ var glob = require('glob'); | ||
var fs__default = /*#__PURE__*/_interopDefault(fs); | ||
var url__default = /*#__PURE__*/_interopDefault(url); | ||
var glob__default = /*#__PURE__*/_interopDefault(glob); | ||
@@ -24,7 +22,5 @@ var dotenv__default = /*#__PURE__*/_interopDefault(dotenv); | ||
const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments'); | ||
const isCI = process.env.CI === true || process.env.CI === 'true'; | ||
const isCI = String(process.env.CI) === 'true'; | ||
const promisifiedGlob = util.promisify(glob__default["default"]); | ||
const __dirname$1 = path__default["default"].dirname(url__default["default"].fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('dist/commercetools-frontend-cypress-environments.cjs.prod.js', document.baseURI).href)))); | ||
function getParsedEnvFileContents(envPath) { | ||
@@ -54,5 +50,5 @@ if (fs__default["default"].existsSync(envPath)) { | ||
if (isCI) { | ||
console.log(`ℹ️ 'CI' environment variables are defined. Assuming operating from a CI system.`); | ||
console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`); | ||
} else { | ||
console.log(`ℹ️ 'CI' environment variables are not defined. Assuming you are running locally.`); | ||
console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`); | ||
} // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case | ||
@@ -62,6 +58,7 @@ // decrypted files are available on a developer's machine. | ||
const ignoredGlobs = ['**/*.enc', '**/*.template', !isCI && '**/*.ci'].filter(Boolean); | ||
const { | ||
config: allEnvironmentConfigs | ||
} = await loadConfig(); | ||
const ignoredGlobs = ['**/*.enc', '**/*.template']; | ||
const ignoredCIGlobs = ['**/*.ci']; | ||
const allIgnoredGlobs = isCI ? ignoredGlobs.concat(ignoredCIGlobs) : ignoredGlobs; | ||
const configResult = await loadConfig(); | ||
const allEnvironmentConfigs = configResult?.config; | ||
const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName); | ||
@@ -74,6 +71,6 @@ | ||
const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, { | ||
ignore: ignoredGlobs | ||
ignore: allIgnoredGlobs | ||
}); | ||
const configFiles = await promisifiedGlob(configForEnvironment.config.glob, { | ||
ignore: ignoredGlobs | ||
ignore: allIgnoredGlobs | ||
}); | ||
@@ -89,3 +86,3 @@ console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`); | ||
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath); | ||
let matchingParsedEnvFileContentsForCIOrLocal = {}; | ||
let matchingParsedEnvFileContentsForCIOrLocal = null; | ||
@@ -101,3 +98,3 @@ if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) { | ||
}, {}); | ||
const pathToSharedEnvironmentConfiguration = path__default["default"].join(__dirname$1, 'config', `.env.${environmentName}.config`); | ||
const pathToSharedEnvironmentConfiguration = path__default["default"].join(__dirname, '..', 'config', `.env.${environmentName}.config`); | ||
let sharedEnvironmentConfiguration = null; | ||
@@ -108,3 +105,3 @@ | ||
} else { | ||
console.log(`ℹ️ Not shared configuration for ${environmentName} defined.`); | ||
console.log(`ℹ️ No shared configuration for ${environmentName} defined.`); | ||
} | ||
@@ -111,0 +108,0 @@ |
import path from 'path'; | ||
import fs from 'fs'; | ||
import url from 'url'; | ||
import { promisify } from 'util'; | ||
@@ -10,7 +9,5 @@ import glob from 'glob'; | ||
const cypressEnvironmentsConfigExplorer = cosmiconfig('cypress-environments'); | ||
const isCI = process.env.CI === true || process.env.CI === 'true'; | ||
const isCI = String(process.env.CI) === 'true'; | ||
const promisifiedGlob = promisify(glob); | ||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); | ||
function getParsedEnvFileContents(envPath) { | ||
@@ -40,5 +37,5 @@ if (fs.existsSync(envPath)) { | ||
if (isCI) { | ||
console.log(`ℹ️ 'CI' environment variables are defined. Assuming operating from a CI system.`); | ||
console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`); | ||
} else { | ||
console.log(`ℹ️ 'CI' environment variables are not defined. Assuming you are running locally.`); | ||
console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`); | ||
} // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case | ||
@@ -48,6 +45,7 @@ // decrypted files are available on a developer's machine. | ||
const ignoredGlobs = ['**/*.enc', '**/*.template', !isCI && '**/*.ci'].filter(Boolean); | ||
const { | ||
config: allEnvironmentConfigs | ||
} = await loadConfig(); | ||
const ignoredGlobs = ['**/*.enc', '**/*.template']; | ||
const ignoredCIGlobs = ['**/*.ci']; | ||
const allIgnoredGlobs = isCI ? ignoredGlobs.concat(ignoredCIGlobs) : ignoredGlobs; | ||
const configResult = await loadConfig(); | ||
const allEnvironmentConfigs = configResult?.config; | ||
const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName); | ||
@@ -60,6 +58,6 @@ | ||
const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, { | ||
ignore: ignoredGlobs | ||
ignore: allIgnoredGlobs | ||
}); | ||
const configFiles = await promisifiedGlob(configForEnvironment.config.glob, { | ||
ignore: ignoredGlobs | ||
ignore: allIgnoredGlobs | ||
}); | ||
@@ -75,3 +73,3 @@ console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`); | ||
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath); | ||
let matchingParsedEnvFileContentsForCIOrLocal = {}; | ||
let matchingParsedEnvFileContentsForCIOrLocal = null; | ||
@@ -87,3 +85,3 @@ if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) { | ||
}, {}); | ||
const pathToSharedEnvironmentConfiguration = path.join(__dirname, 'config', `.env.${environmentName}.config`); | ||
const pathToSharedEnvironmentConfiguration = path.join(__dirname, '..', 'config', `.env.${environmentName}.config`); | ||
let sharedEnvironmentConfiguration = null; | ||
@@ -94,3 +92,3 @@ | ||
} else { | ||
console.log(`ℹ️ Not shared configuration for ${environmentName} defined.`); | ||
console.log(`ℹ️ No shared configuration for ${environmentName} defined.`); | ||
} | ||
@@ -97,0 +95,0 @@ |
{ | ||
"name": "@commercetools-frontend/cypress-environments", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Cypress package to setup environment configuration using dotenv files", | ||
@@ -10,12 +10,8 @@ "license": "MIT", | ||
"scripts": { | ||
"prepublish": "cp -R src/config dist/config" | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"main": "dist/commercetools-frontend-cypress-environments.cjs.js", | ||
"module": "dist/commercetools-frontend-cypress-environments.esm.js", | ||
"preconstruct": { | ||
"entrypoints": [ | ||
"./index.js" | ||
] | ||
}, | ||
"files": [ | ||
"config", | ||
"dist", | ||
@@ -31,2 +27,7 @@ "package.json", | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.19.1", | ||
"@babel/preset-typescript": "7.18.6", | ||
"typescript": "^4.8.2" | ||
}, | ||
"engines": { | ||
@@ -33,0 +34,0 @@ "node": ">=14", |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
21160
0.3%15
36.36%8
-38.46%3
Infinity%263
-0.38%