@commercetools-frontend/cypress-environments 0.0.11 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,7 +32,7 @@ The contents of the configuration file could look like:
32
32
 
33
33
  ```js
34
34
  const projectKeys = {
35
- gcpEu: 'ctp-gcp-production-eu',
35
+ gcpEu: 'ctp_production_gcp_europe-west1_v1',
36
36
  };
37
37
 
38
38
  module.exports = {
@@ -54,22 +54,22 @@ The package expects configurations for environments to be stored in `cypress/con
54
54
 
55
55
  ```txt
56
56
  cypress/config
57
- ├── ctp-gcp-production-eu
57
+ ├── ctp_production_gcp_europe-west1_v1
58
58
  |──── .env.config
59
59
  |──── .env.secrets.ci (Decrypred from `*.enc`)
60
60
  |──── .env.config.local.template
61
61
  |──── .env.secrets.local.template
62
- ├── ctp-aws-production-fra
63
- └── ctp-vw-production-eu
62
+ ├── ctp_production_aws_eu-central-1_v1
63
+ └── vw_production_aws_eu-central-1_v1
64
64
  ```
65
65
 
66
- Would load the values from `.env.config` anytime the environment is `ctp-gcp-production-eu`. Additionally on CI (when `CI=true`) it would load the `.env.secrets.ci` file, otherwise it would attempt to load values from `.env.config.local` and `.env.secrets.local` (assuming they have been properly configured - see `*.template` files for reference).
66
+ Would load the values from `.env.config` anytime the environment is `ctp_production_gcp_europe-west1_v1`. Additionally on CI (when `CI=true`) it would load the `.env.secrets.ci` file, otherwise it would attempt to load values from `.env.config.local` and `.env.secrets.local` (assuming they have been properly configured - see `*.template` files for reference).
67
67
 
68
68
  Given multiple files can be loaded some values can be overwritten by a subsequently loaded file. First the `.env.config` file will be loaded. After the secrets from `.env.secrets` and then `.env.secrets.ci` or `.env.secrets.local` respectively. Any file loaded later can overwrite values of a file loaded before.
69
69
 
70
70
  ## Provided configuration values
71
71
 
72
- The module provides default values for `ctp-aws-production-fra`, `ctp-gcp-production-eu`, `ctp-gcp-production-us` and `ctp-gcp-production-au`. These values will be loaded first before any custom configuration. These default configurations contain the `API_URL`, `MC_API_URL`, `MC_URL` and `AUTH_URL` for the given environment.
72
+ The module provides default values for `ctp_production_aws_eu-central-1_v1`, `ctp_production_gcp_europe-west1_v1`, `ctp_production_gcp_us-central1_v1` and `ctp_production_gcp_australia-southeast1_v1`. These values will be loaded first before any custom configuration. These default configurations contain the `API_URL`, `MC_API_URL`, `MC_URL` and `AUTH_URL` for the given environment.
73
73
 
74
74
  ## Troubleshooting
75
75
 
@@ -0,0 +1,4 @@
1
+ MC_URL=https://mc-api.eu-central-1.aws.commercetools.com
2
+ MC_API_URL=https://mc-api.eu-central-1.aws.commercetools.com
3
+ API_URL=https://api.eu-central-1.aws.commercetools.com
4
+ AUTH_URL=https://auth.eu-central-1.aws.commercetools.com
@@ -0,0 +1,5 @@
1
+ MC_URL=https://mc.australia-southeast1.gcp.commercetools.com
2
+ MC_API_URL=https://mc-api.australia-southeast1.gcp.commercetools.com
3
+ API_URL=https://api.australia-southeast1.gcp.commercetools.com
4
+ AUTH_URL=https://auth.australia-southeast1.gcp.commercetools.com
5
+
@@ -0,0 +1,5 @@
1
+ MC_URL=https://mc.europe-west1.gcp.commercetools.com
2
+ MC_API_URL=https://mc-api.europe-west1.gcp.commercetools.com
3
+ API_URL=https://api.europe-west1.gcp.commercetools.com
4
+ AUTH_URL=https://auth.europe-west1.gcp.commercetools.com
5
+
@@ -0,0 +1,5 @@
1
+ MC_URL=https://mc.us-central1.gcp.commercetools.com
2
+ MC_API_URL=https://mc-api.us-central1.gcp.commercetools.com
3
+ API_URL=https://api.us-central1.gcp.commercetools.com
4
+ AUTH_URL=https://auth.us-central1.gcp.commercetools.com
5
+
@@ -0,0 +1,5 @@
1
+ MC_API_URL=https://mc-api.europe-west1.gcp.escemo.com
2
+ MC_URL=https://mc.europe-west1.gcp.escemo.com
3
+ API_URL=https://api.europe-west1.gcp.commercetools.com
4
+ AUTH_URL=https://auth.europe-west1.gcp.commercetools.com
5
+
@@ -42,19 +42,19 @@ var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
42
42
  var pkgDir__default = /*#__PURE__*/_interopDefault(pkgDir);
43
43
 
44
44
  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; }
45
- 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; }
45
+ 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; }
46
46
  const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
47
47
  const isCI = String(process.env.CI) === 'true';
48
48
  function getParsedEnvFileContents(envPath) {
49
49
  if (fs__default["default"].existsSync(envPath)) {
50
- console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
50
+ console.log(`✅ Found and loading environment variables from: '${envPath}'`);
51
51
  const envFileContents = fs__default["default"].readFileSync(envPath, {
52
52
  encoding: 'utf8'
53
53
  });
54
54
  const configuration = dotenv__default["default"].parse(envFileContents);
55
55
  return configuration;
56
56
  } else {
57
- console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
57
+ console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
58
58
  return null;
59
59
  }
60
60
  }
@@ -62,27 +62,27 @@ async function loadConfig() {
62
62
  try {
63
63
  return await cypressEnvironmentsConfigExplorer.search();
64
64
  } catch (e) {
65
- throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
65
+ throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
66
66
  }
67
67
  }
68
68
  async function getConfigurationForEnvironment(environmentName) {
69
- var _context, _context2, _context3;
69
+ var _context, _context2;
70
70
  // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
71
71
  // decrypted files are available on a developer's machine.
72
72
  const ignoredGlobs = ['**/*.enc', '**/*.template'];
73
73
  const ignoredCIGlobs = ['**/*.ci'];
74
74
  const allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty__default["default"](ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
75
75
  if (isCI) {
76
- console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
76
+ console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
77
77
  } else {
78
- console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
78
+ console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
79
79
  }
80
- console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
80
+ console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
81
81
  const configResult = await loadConfig();
82
- const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
82
+ const allEnvironmentConfigs = configResult?.config;
83
83
  const configForEnvironment = _findInstanceProperty__default["default"](_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
84
84
  if (!configForEnvironment) {
85
- throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
85
+ throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
86
86
  }
87
87
  const secretsFiles = await glob.glob(configForEnvironment.secrets.glob, {
88
88
  ignore: allIgnoredGlobs
@@ -90,27 +90,27 @@ async function getConfigurationForEnvironment(environmentName) {
90
90
  const configFiles = await glob.glob(configForEnvironment.config.glob, {
91
91
  ignore: allIgnoredGlobs
92
92
  });
93
- 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."));
93
+ console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
94
94
  if (secretsFiles.length === 0 || configFiles.length === 0) {
95
- console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
96
- console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
95
+ console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
96
+ console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
97
97
  }
98
- const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
98
+ const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context2 = [...configFiles, ...secretsFiles]).call(_context2, (previousParsedEnvFileContents, nextEnvFilePath) => {
99
99
  const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
100
100
  let matchingParsedEnvFileContentsForCIOrLocal = null;
101
101
  if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
102
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
102
+ matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
103
103
  }
104
104
  return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
105
105
  }, {});
106
106
  const rootDir = await pkgDir__default["default"](__dirname);
107
107
  let sharedEnvironmentConfiguration = null;
108
108
  if (rootDir) {
109
- const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
109
+ const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', `.env.${environmentName}.config`);
110
110
  if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
111
111
  sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
112
112
  } else {
113
- console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
113
+ console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
114
114
  }
115
115
  }
116
116
  return _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests);
@@ -42,19 +42,19 @@ var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
42
42
  var pkgDir__default = /*#__PURE__*/_interopDefault(pkgDir);
43
43
 
44
44
  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; }
45
- 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; }
45
+ 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; }
46
46
  const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
47
47
  const isCI = String(process.env.CI) === 'true';
48
48
  function getParsedEnvFileContents(envPath) {
49
49
  if (fs__default["default"].existsSync(envPath)) {
50
- console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
50
+ console.log(`✅ Found and loading environment variables from: '${envPath}'`);
51
51
  const envFileContents = fs__default["default"].readFileSync(envPath, {
52
52
  encoding: 'utf8'
53
53
  });
54
54
  const configuration = dotenv__default["default"].parse(envFileContents);
55
55
  return configuration;
56
56
  } else {
57
- console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
57
+ console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
58
58
  return null;
59
59
  }
60
60
  }
@@ -62,27 +62,27 @@ async function loadConfig() {
62
62
  try {
63
63
  return await cypressEnvironmentsConfigExplorer.search();
64
64
  } catch (e) {
65
- throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
65
+ throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
66
66
  }
67
67
  }
68
68
  async function getConfigurationForEnvironment(environmentName) {
69
- var _context, _context2, _context3;
69
+ var _context, _context2;
70
70
  // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
71
71
  // decrypted files are available on a developer's machine.
72
72
  const ignoredGlobs = ['**/*.enc', '**/*.template'];
73
73
  const ignoredCIGlobs = ['**/*.ci'];
74
74
  const allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty__default["default"](ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
75
75
  if (isCI) {
76
- console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
76
+ console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
77
77
  } else {
78
- console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
78
+ console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
79
79
  }
80
- console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
80
+ console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
81
81
  const configResult = await loadConfig();
82
- const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
82
+ const allEnvironmentConfigs = configResult?.config;
83
83
  const configForEnvironment = _findInstanceProperty__default["default"](_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
84
84
  if (!configForEnvironment) {
85
- throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
85
+ throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
86
86
  }
87
87
  const secretsFiles = await glob.glob(configForEnvironment.secrets.glob, {
88
88
  ignore: allIgnoredGlobs
@@ -90,27 +90,27 @@ async function getConfigurationForEnvironment(environmentName) {
90
90
  const configFiles = await glob.glob(configForEnvironment.config.glob, {
91
91
  ignore: allIgnoredGlobs
92
92
  });
93
- 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."));
93
+ console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
94
94
  if (secretsFiles.length === 0 || configFiles.length === 0) {
95
- console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
96
- console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
95
+ console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
96
+ console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
97
97
  }
98
- const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
98
+ const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context2 = [...configFiles, ...secretsFiles]).call(_context2, (previousParsedEnvFileContents, nextEnvFilePath) => {
99
99
  const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
100
100
  let matchingParsedEnvFileContentsForCIOrLocal = null;
101
101
  if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
102
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
102
+ matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
103
103
  }
104
104
  return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
105
105
  }, {});
106
106
  const rootDir = await pkgDir__default["default"](__dirname);
107
107
  let sharedEnvironmentConfiguration = null;
108
108
  if (rootDir) {
109
- const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
109
+ const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', `.env.${environmentName}.config`);
110
110
  if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
111
111
  sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
112
112
  } else {
113
- console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
113
+ console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
114
114
  }
115
115
  }
116
116
  return _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests);
@@ -19,19 +19,19 @@ import pkgDir from 'pkg-dir';
19
19
  import { cosmiconfig } from 'cosmiconfig';
20
20
 
21
21
  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; }
22
- 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; }
22
+ 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; }
23
23
  const cypressEnvironmentsConfigExplorer = cosmiconfig('cypress-environments');
24
24
  const isCI = String(process.env.CI) === 'true';
25
25
  function getParsedEnvFileContents(envPath) {
26
26
  if (fs.existsSync(envPath)) {
27
- console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
27
+ console.log(`✅ Found and loading environment variables from: '${envPath}'`);
28
28
  const envFileContents = fs.readFileSync(envPath, {
29
29
  encoding: 'utf8'
30
30
  });
31
31
  const configuration = dotenv.parse(envFileContents);
32
32
  return configuration;
33
33
  } else {
34
- console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
34
+ console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
35
35
  return null;
36
36
  }
37
37
  }
@@ -39,27 +39,27 @@ async function loadConfig() {
39
39
  try {
40
40
  return await cypressEnvironmentsConfigExplorer.search();
41
41
  } catch (e) {
42
- throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
42
+ throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
43
43
  }
44
44
  }
45
45
  async function getConfigurationForEnvironment(environmentName) {
46
- var _context, _context2, _context3;
46
+ var _context, _context2;
47
47
  // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
48
48
  // decrypted files are available on a developer's machine.
49
49
  const ignoredGlobs = ['**/*.enc', '**/*.template'];
50
50
  const ignoredCIGlobs = ['**/*.ci'];
51
51
  const allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty(ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
52
52
  if (isCI) {
53
- console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
53
+ console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
54
54
  } else {
55
- console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
55
+ console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
56
56
  }
57
- console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
57
+ console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
58
58
  const configResult = await loadConfig();
59
- const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
59
+ const allEnvironmentConfigs = configResult?.config;
60
60
  const configForEnvironment = _findInstanceProperty(_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
61
61
  if (!configForEnvironment) {
62
- throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
62
+ throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
63
63
  }
64
64
  const secretsFiles = await glob(configForEnvironment.secrets.glob, {
65
65
  ignore: allIgnoredGlobs
@@ -67,27 +67,27 @@ async function getConfigurationForEnvironment(environmentName) {
67
67
  const configFiles = await glob(configForEnvironment.config.glob, {
68
68
  ignore: allIgnoredGlobs
69
69
  });
70
- 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."));
70
+ console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
71
71
  if (secretsFiles.length === 0 || configFiles.length === 0) {
72
- console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
73
- console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
72
+ console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
73
+ console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
74
74
  }
75
- const mergedConfigurationAndSecrests = _reduceInstanceProperty(_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
75
+ const mergedConfigurationAndSecrests = _reduceInstanceProperty(_context2 = [...configFiles, ...secretsFiles]).call(_context2, (previousParsedEnvFileContents, nextEnvFilePath) => {
76
76
  const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
77
77
  let matchingParsedEnvFileContentsForCIOrLocal = null;
78
78
  if (!_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
79
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
79
+ matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
80
80
  }
81
81
  return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
82
82
  }, {});
83
83
  const rootDir = await pkgDir(__dirname);
84
84
  let sharedEnvironmentConfiguration = null;
85
85
  if (rootDir) {
86
- const pathToSharedEnvironmentConfiguration = path.join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
86
+ const pathToSharedEnvironmentConfiguration = path.join(rootDir, 'config', `.env.${environmentName}.config`);
87
87
  if (fs.existsSync(pathToSharedEnvironmentConfiguration)) {
88
88
  sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
89
89
  } else {
90
- console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
90
+ console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
91
91
  }
92
92
  }
93
93
  return _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/cypress-environments",
3
- "version": "0.0.11",
3
+ "version": "0.1.0",
4
4
  "description": "Cypress package to setup environment configuration using dotenv files",
5
5
  "license": "MIT",
6
6
  "publishConfig": {