@commercetools-frontend/cypress-environments 0.0.3 → 0.0.5

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.
@@ -2,6 +2,22 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
6
+ var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
7
+ var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
8
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
9
+ var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
10
+ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
11
+ var _endsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
12
+ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
13
+ var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
14
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
15
+ var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
16
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
17
+ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
18
+ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
19
+ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
20
+ var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
5
21
  var path = require('path');
6
22
  var fs = require('fs');
7
23
  var util = require('util');
@@ -12,102 +28,149 @@ var cosmiconfig = require('cosmiconfig');
12
28
 
13
29
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
30
 
31
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
32
+ var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
33
+ var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
34
+ var _endsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_endsWithInstanceProperty);
35
+ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
36
+ var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
37
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
38
+ var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
39
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
40
+ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
41
+ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
42
+ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
43
+ var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
15
44
  var path__default = /*#__PURE__*/_interopDefault(path);
16
45
  var fs__default = /*#__PURE__*/_interopDefault(fs);
17
46
  var glob__default = /*#__PURE__*/_interopDefault(glob);
18
47
  var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
19
48
  var pkgDir__default = /*#__PURE__*/_interopDefault(pkgDir);
20
49
 
21
- const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
22
- const isCI = String(process.env.CI) === 'true';
23
- const promisifiedGlob = util.promisify(glob__default["default"]);
24
-
50
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
51
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context7, _context8; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(source), !0)).call(_context7, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(source))).call(_context8, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
52
+ var cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
53
+ var isCI = String(process.env.CI) === 'true';
54
+ var promisifiedGlob = util.promisify(glob__default["default"]);
25
55
  function getParsedEnvFileContents(envPath) {
26
56
  if (fs__default["default"].existsSync(envPath)) {
27
- console.log(`✅ Found and loading environment variables from: '${envPath}'`);
28
- const envFileContents = fs__default["default"].readFileSync(envPath, {
57
+ console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
58
+ var envFileContents = fs__default["default"].readFileSync(envPath, {
29
59
  encoding: 'utf8'
30
60
  });
31
- const configuration = dotenv__default["default"].parse(envFileContents);
61
+ var configuration = dotenv__default["default"].parse(envFileContents);
32
62
  return configuration;
33
63
  } else {
34
- console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
64
+ console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
35
65
  return null;
36
66
  }
37
67
  }
38
-
39
- async function loadConfig() {
40
- try {
41
- return await cypressEnvironmentsConfigExplorer.search();
42
- } catch (e) {
43
- throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
44
- }
68
+ function loadConfig() {
69
+ return _loadConfig.apply(this, arguments);
45
70
  }
46
-
47
- async function getConfigurationForEnvironment(environmentName) {
48
- // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
49
- // decrypted files are available on a developer's machine.
50
- const ignoredGlobs = ['**/*.enc', '**/*.template'];
51
- const ignoredCIGlobs = ['**/*.ci'];
52
- const allIgnoredGlobs = isCI ? ignoredGlobs : ignoredGlobs.concat(ignoredCIGlobs);
53
-
54
- if (isCI) {
55
- console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
56
- } else {
57
- console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
58
- }
59
-
60
- console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
61
- const configResult = await loadConfig();
62
- const allEnvironmentConfigs = configResult?.config;
63
- const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName);
64
-
65
- if (!configForEnvironment) {
66
- throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
67
- }
68
-
69
- const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, {
70
- ignore: allIgnoredGlobs
71
- });
72
- const configFiles = await promisifiedGlob(configForEnvironment.config.glob, {
73
- ignore: allIgnoredGlobs
74
- });
75
- console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
76
-
77
- if (secretsFiles.length === 0 || configFiles.length === 0) {
78
- console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
79
- console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
80
- }
81
-
82
- const mergedConfigurationAndSecrests = [...configFiles, ...secretsFiles].reduce((previousParsedEnvFileContents, nextEnvFilePath) => {
83
- const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
84
- let matchingParsedEnvFileContentsForCIOrLocal = null;
85
-
86
- if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) {
87
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
88
- }
89
-
90
- return { ...previousParsedEnvFileContents,
91
- ...parsedEnvFileContents,
92
- ...matchingParsedEnvFileContentsForCIOrLocal
93
- };
94
- }, {});
95
- const rootDir = await pkgDir__default["default"](__dirname);
96
- let sharedEnvironmentConfiguration = null;
97
-
98
- if (rootDir) {
99
- const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', `.env.${environmentName}.config`);
100
-
101
- if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
102
- sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
103
- } else {
104
- console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
105
- }
106
- }
107
-
108
- return { ...sharedEnvironmentConfiguration,
109
- ...mergedConfigurationAndSecrests
110
- };
71
+ function _loadConfig() {
72
+ _loadConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
73
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
74
+ while (1) switch (_context.prev = _context.next) {
75
+ case 0:
76
+ _context.prev = 0;
77
+ _context.next = 3;
78
+ return cypressEnvironmentsConfigExplorer.search();
79
+ case 3:
80
+ return _context.abrupt("return", _context.sent);
81
+ case 6:
82
+ _context.prev = 6;
83
+ _context.t0 = _context["catch"](0);
84
+ throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
85
+ case 9:
86
+ case "end":
87
+ return _context.stop();
88
+ }
89
+ }, _callee, null, [[0, 6]]);
90
+ }));
91
+ return _loadConfig.apply(this, arguments);
92
+ }
93
+ function getConfigurationForEnvironment(_x) {
94
+ return _getConfigurationForEnvironment.apply(this, arguments);
95
+ }
96
+ function _getConfigurationForEnvironment() {
97
+ _getConfigurationForEnvironment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(environmentName) {
98
+ var _context2, _context3, _context4, _context5;
99
+ var ignoredGlobs, ignoredCIGlobs, allIgnoredGlobs, configResult, allEnvironmentConfigs, configForEnvironment, secretsFiles, configFiles, mergedConfigurationAndSecrests, rootDir, sharedEnvironmentConfiguration, pathToSharedEnvironmentConfiguration;
100
+ return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context6) {
101
+ while (1) switch (_context6.prev = _context6.next) {
102
+ case 0:
103
+ // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
104
+ // decrypted files are available on a developer's machine.
105
+ ignoredGlobs = ['**/*.enc', '**/*.template'];
106
+ ignoredCIGlobs = ['**/*.ci'];
107
+ allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty__default["default"](ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
108
+ if (isCI) {
109
+ console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
110
+ } else {
111
+ console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
112
+ }
113
+ console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
114
+ _context6.next = 7;
115
+ return loadConfig();
116
+ case 7:
117
+ configResult = _context6.sent;
118
+ allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
119
+ configForEnvironment = _findInstanceProperty__default["default"](_context2 = allEnvironmentConfigs.environments).call(_context2, function (environment) {
120
+ return environment.name === environmentName;
121
+ });
122
+ if (configForEnvironment) {
123
+ _context6.next = 12;
124
+ break;
125
+ }
126
+ throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
127
+ case 12:
128
+ _context6.next = 14;
129
+ return promisifiedGlob(configForEnvironment.secrets.glob, {
130
+ ignore: allIgnoredGlobs
131
+ });
132
+ case 14:
133
+ secretsFiles = _context6.sent;
134
+ _context6.next = 17;
135
+ return promisifiedGlob(configForEnvironment.config.glob, {
136
+ ignore: allIgnoredGlobs
137
+ });
138
+ case 17:
139
+ configFiles = _context6.sent;
140
+ console.log(_concatInstanceProperty__default["default"](_context3 = "\u2139\uFE0F Found ".concat(secretsFiles.length, " secret file(s) and ")).call(_context3, configFiles.length, " config file(s) matching the defined globs."));
141
+ if (secretsFiles.length === 0 || configFiles.length === 0) {
142
+ console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
143
+ console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
144
+ }
145
+ mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = []).call(_context5, _toConsumableArray(configFiles), _toConsumableArray(secretsFiles))).call(_context4, function (previousParsedEnvFileContents, nextEnvFilePath) {
146
+ var parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
147
+ var matchingParsedEnvFileContentsForCIOrLocal = null;
148
+ if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
149
+ matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
150
+ }
151
+ return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
152
+ }, {});
153
+ _context6.next = 23;
154
+ return pkgDir__default["default"](__dirname);
155
+ case 23:
156
+ rootDir = _context6.sent;
157
+ sharedEnvironmentConfiguration = null;
158
+ if (rootDir) {
159
+ pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
160
+ if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
161
+ sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
162
+ } else {
163
+ console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
164
+ }
165
+ }
166
+ return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
167
+ case 27:
168
+ case "end":
169
+ return _context6.stop();
170
+ }
171
+ }, _callee2);
172
+ }));
173
+ return _getConfigurationForEnvironment.apply(this, arguments);
111
174
  }
112
175
 
113
176
  exports.getConfigurationForEnvironment = getConfigurationForEnvironment;
@@ -2,6 +2,22 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
6
+ var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
7
+ var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
8
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
9
+ var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
10
+ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
11
+ var _endsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
12
+ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
13
+ var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
14
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
15
+ var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
16
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
17
+ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
18
+ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
19
+ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
20
+ var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
5
21
  var path = require('path');
6
22
  var fs = require('fs');
7
23
  var util = require('util');
@@ -12,102 +28,149 @@ var cosmiconfig = require('cosmiconfig');
12
28
 
13
29
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
30
 
31
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
32
+ var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
33
+ var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
34
+ var _endsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_endsWithInstanceProperty);
35
+ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
36
+ var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
37
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
38
+ var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
39
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
40
+ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
41
+ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
42
+ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
43
+ var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
15
44
  var path__default = /*#__PURE__*/_interopDefault(path);
16
45
  var fs__default = /*#__PURE__*/_interopDefault(fs);
17
46
  var glob__default = /*#__PURE__*/_interopDefault(glob);
18
47
  var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
19
48
  var pkgDir__default = /*#__PURE__*/_interopDefault(pkgDir);
20
49
 
21
- const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
22
- const isCI = String(process.env.CI) === 'true';
23
- const promisifiedGlob = util.promisify(glob__default["default"]);
24
-
50
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
51
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context7, _context8; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(source), !0)).call(_context7, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(source))).call(_context8, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
52
+ var cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
53
+ var isCI = String(process.env.CI) === 'true';
54
+ var promisifiedGlob = util.promisify(glob__default["default"]);
25
55
  function getParsedEnvFileContents(envPath) {
26
56
  if (fs__default["default"].existsSync(envPath)) {
27
- console.log(`✅ Found and loading environment variables from: '${envPath}'`);
28
- const envFileContents = fs__default["default"].readFileSync(envPath, {
57
+ console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
58
+ var envFileContents = fs__default["default"].readFileSync(envPath, {
29
59
  encoding: 'utf8'
30
60
  });
31
- const configuration = dotenv__default["default"].parse(envFileContents);
61
+ var configuration = dotenv__default["default"].parse(envFileContents);
32
62
  return configuration;
33
63
  } else {
34
- console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
64
+ console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
35
65
  return null;
36
66
  }
37
67
  }
38
-
39
- async function loadConfig() {
40
- try {
41
- return await cypressEnvironmentsConfigExplorer.search();
42
- } catch (e) {
43
- throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
44
- }
68
+ function loadConfig() {
69
+ return _loadConfig.apply(this, arguments);
45
70
  }
46
-
47
- async function getConfigurationForEnvironment(environmentName) {
48
- // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
49
- // decrypted files are available on a developer's machine.
50
- const ignoredGlobs = ['**/*.enc', '**/*.template'];
51
- const ignoredCIGlobs = ['**/*.ci'];
52
- const allIgnoredGlobs = isCI ? ignoredGlobs : ignoredGlobs.concat(ignoredCIGlobs);
53
-
54
- if (isCI) {
55
- console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
56
- } else {
57
- console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
58
- }
59
-
60
- console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
61
- const configResult = await loadConfig();
62
- const allEnvironmentConfigs = configResult?.config;
63
- const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName);
64
-
65
- if (!configForEnvironment) {
66
- throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
67
- }
68
-
69
- const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, {
70
- ignore: allIgnoredGlobs
71
- });
72
- const configFiles = await promisifiedGlob(configForEnvironment.config.glob, {
73
- ignore: allIgnoredGlobs
74
- });
75
- console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
76
-
77
- if (secretsFiles.length === 0 || configFiles.length === 0) {
78
- console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
79
- console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
80
- }
81
-
82
- const mergedConfigurationAndSecrests = [...configFiles, ...secretsFiles].reduce((previousParsedEnvFileContents, nextEnvFilePath) => {
83
- const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
84
- let matchingParsedEnvFileContentsForCIOrLocal = null;
85
-
86
- if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) {
87
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
88
- }
89
-
90
- return { ...previousParsedEnvFileContents,
91
- ...parsedEnvFileContents,
92
- ...matchingParsedEnvFileContentsForCIOrLocal
93
- };
94
- }, {});
95
- const rootDir = await pkgDir__default["default"](__dirname);
96
- let sharedEnvironmentConfiguration = null;
97
-
98
- if (rootDir) {
99
- const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', `.env.${environmentName}.config`);
100
-
101
- if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
102
- sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
103
- } else {
104
- console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
105
- }
106
- }
107
-
108
- return { ...sharedEnvironmentConfiguration,
109
- ...mergedConfigurationAndSecrests
110
- };
71
+ function _loadConfig() {
72
+ _loadConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
73
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
74
+ while (1) switch (_context.prev = _context.next) {
75
+ case 0:
76
+ _context.prev = 0;
77
+ _context.next = 3;
78
+ return cypressEnvironmentsConfigExplorer.search();
79
+ case 3:
80
+ return _context.abrupt("return", _context.sent);
81
+ case 6:
82
+ _context.prev = 6;
83
+ _context.t0 = _context["catch"](0);
84
+ throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
85
+ case 9:
86
+ case "end":
87
+ return _context.stop();
88
+ }
89
+ }, _callee, null, [[0, 6]]);
90
+ }));
91
+ return _loadConfig.apply(this, arguments);
92
+ }
93
+ function getConfigurationForEnvironment(_x) {
94
+ return _getConfigurationForEnvironment.apply(this, arguments);
95
+ }
96
+ function _getConfigurationForEnvironment() {
97
+ _getConfigurationForEnvironment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(environmentName) {
98
+ var _context2, _context3, _context4, _context5;
99
+ var ignoredGlobs, ignoredCIGlobs, allIgnoredGlobs, configResult, allEnvironmentConfigs, configForEnvironment, secretsFiles, configFiles, mergedConfigurationAndSecrests, rootDir, sharedEnvironmentConfiguration, pathToSharedEnvironmentConfiguration;
100
+ return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context6) {
101
+ while (1) switch (_context6.prev = _context6.next) {
102
+ case 0:
103
+ // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
104
+ // decrypted files are available on a developer's machine.
105
+ ignoredGlobs = ['**/*.enc', '**/*.template'];
106
+ ignoredCIGlobs = ['**/*.ci'];
107
+ allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty__default["default"](ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
108
+ if (isCI) {
109
+ console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
110
+ } else {
111
+ console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
112
+ }
113
+ console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
114
+ _context6.next = 7;
115
+ return loadConfig();
116
+ case 7:
117
+ configResult = _context6.sent;
118
+ allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
119
+ configForEnvironment = _findInstanceProperty__default["default"](_context2 = allEnvironmentConfigs.environments).call(_context2, function (environment) {
120
+ return environment.name === environmentName;
121
+ });
122
+ if (configForEnvironment) {
123
+ _context6.next = 12;
124
+ break;
125
+ }
126
+ throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
127
+ case 12:
128
+ _context6.next = 14;
129
+ return promisifiedGlob(configForEnvironment.secrets.glob, {
130
+ ignore: allIgnoredGlobs
131
+ });
132
+ case 14:
133
+ secretsFiles = _context6.sent;
134
+ _context6.next = 17;
135
+ return promisifiedGlob(configForEnvironment.config.glob, {
136
+ ignore: allIgnoredGlobs
137
+ });
138
+ case 17:
139
+ configFiles = _context6.sent;
140
+ console.log(_concatInstanceProperty__default["default"](_context3 = "\u2139\uFE0F Found ".concat(secretsFiles.length, " secret file(s) and ")).call(_context3, configFiles.length, " config file(s) matching the defined globs."));
141
+ if (secretsFiles.length === 0 || configFiles.length === 0) {
142
+ console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
143
+ console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
144
+ }
145
+ mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = []).call(_context5, _toConsumableArray(configFiles), _toConsumableArray(secretsFiles))).call(_context4, function (previousParsedEnvFileContents, nextEnvFilePath) {
146
+ var parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
147
+ var matchingParsedEnvFileContentsForCIOrLocal = null;
148
+ if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
149
+ matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
150
+ }
151
+ return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
152
+ }, {});
153
+ _context6.next = 23;
154
+ return pkgDir__default["default"](__dirname);
155
+ case 23:
156
+ rootDir = _context6.sent;
157
+ sharedEnvironmentConfiguration = null;
158
+ if (rootDir) {
159
+ pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
160
+ if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
161
+ sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
162
+ } else {
163
+ console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
164
+ }
165
+ }
166
+ return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
167
+ case 27:
168
+ case "end":
169
+ return _context6.stop();
170
+ }
171
+ }, _callee2);
172
+ }));
173
+ return _getConfigurationForEnvironment.apply(this, arguments);
111
174
  }
112
175
 
113
176
  exports.getConfigurationForEnvironment = getConfigurationForEnvironment;
@@ -1,3 +1,19 @@
1
+ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
2
+ import _toConsumableArray from '@babel/runtime-corejs3/helpers/esm/toConsumableArray';
3
+ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
4
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
5
+ import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
6
+ import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
7
+ import _endsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/ends-with';
8
+ import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
9
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
10
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
11
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
12
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
13
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
14
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
15
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
16
+ import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
1
17
  import path from 'path';
2
18
  import fs from 'fs';
3
19
  import { promisify } from 'util';
@@ -6,96 +22,130 @@ import dotenv from 'dotenv';
6
22
  import pkgDir from 'pkg-dir';
7
23
  import { cosmiconfig } from 'cosmiconfig';
8
24
 
9
- const cypressEnvironmentsConfigExplorer = cosmiconfig('cypress-environments');
10
- const isCI = String(process.env.CI) === 'true';
11
- const promisifiedGlob = promisify(glob);
12
-
25
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context7, _context8; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context7 = ownKeys(Object(source), !0)).call(_context7, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context8 = ownKeys(Object(source))).call(_context8, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
27
+ var cypressEnvironmentsConfigExplorer = cosmiconfig('cypress-environments');
28
+ var isCI = String(process.env.CI) === 'true';
29
+ var promisifiedGlob = promisify(glob);
13
30
  function getParsedEnvFileContents(envPath) {
14
31
  if (fs.existsSync(envPath)) {
15
- console.log(`✅ Found and loading environment variables from: '${envPath}'`);
16
- const envFileContents = fs.readFileSync(envPath, {
32
+ console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
33
+ var envFileContents = fs.readFileSync(envPath, {
17
34
  encoding: 'utf8'
18
35
  });
19
- const configuration = dotenv.parse(envFileContents);
36
+ var configuration = dotenv.parse(envFileContents);
20
37
  return configuration;
21
38
  } else {
22
- console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
39
+ console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
23
40
  return null;
24
41
  }
25
42
  }
26
-
27
- async function loadConfig() {
28
- try {
29
- return await cypressEnvironmentsConfigExplorer.search();
30
- } catch (e) {
31
- throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
32
- }
43
+ function loadConfig() {
44
+ return _loadConfig.apply(this, arguments);
33
45
  }
34
-
35
- async function getConfigurationForEnvironment(environmentName) {
36
- // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
37
- // decrypted files are available on a developer's machine.
38
- const ignoredGlobs = ['**/*.enc', '**/*.template'];
39
- const ignoredCIGlobs = ['**/*.ci'];
40
- const allIgnoredGlobs = isCI ? ignoredGlobs : ignoredGlobs.concat(ignoredCIGlobs);
41
-
42
- if (isCI) {
43
- console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
44
- } else {
45
- console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
46
- }
47
-
48
- console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
49
- const configResult = await loadConfig();
50
- const allEnvironmentConfigs = configResult?.config;
51
- const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName);
52
-
53
- if (!configForEnvironment) {
54
- throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
55
- }
56
-
57
- const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, {
58
- ignore: allIgnoredGlobs
59
- });
60
- const configFiles = await promisifiedGlob(configForEnvironment.config.glob, {
61
- ignore: allIgnoredGlobs
62
- });
63
- console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
64
-
65
- if (secretsFiles.length === 0 || configFiles.length === 0) {
66
- console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
67
- console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
68
- }
69
-
70
- const mergedConfigurationAndSecrests = [...configFiles, ...secretsFiles].reduce((previousParsedEnvFileContents, nextEnvFilePath) => {
71
- const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
72
- let matchingParsedEnvFileContentsForCIOrLocal = null;
73
-
74
- if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) {
75
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
76
- }
77
-
78
- return { ...previousParsedEnvFileContents,
79
- ...parsedEnvFileContents,
80
- ...matchingParsedEnvFileContentsForCIOrLocal
81
- };
82
- }, {});
83
- const rootDir = await pkgDir(__dirname);
84
- let sharedEnvironmentConfiguration = null;
85
-
86
- if (rootDir) {
87
- const pathToSharedEnvironmentConfiguration = path.join(rootDir, 'config', `.env.${environmentName}.config`);
88
-
89
- if (fs.existsSync(pathToSharedEnvironmentConfiguration)) {
90
- sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
91
- } else {
92
- console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
93
- }
94
- }
95
-
96
- return { ...sharedEnvironmentConfiguration,
97
- ...mergedConfigurationAndSecrests
98
- };
46
+ function _loadConfig() {
47
+ _loadConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
48
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
49
+ while (1) switch (_context.prev = _context.next) {
50
+ case 0:
51
+ _context.prev = 0;
52
+ _context.next = 3;
53
+ return cypressEnvironmentsConfigExplorer.search();
54
+ case 3:
55
+ return _context.abrupt("return", _context.sent);
56
+ case 6:
57
+ _context.prev = 6;
58
+ _context.t0 = _context["catch"](0);
59
+ throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
60
+ case 9:
61
+ case "end":
62
+ return _context.stop();
63
+ }
64
+ }, _callee, null, [[0, 6]]);
65
+ }));
66
+ return _loadConfig.apply(this, arguments);
67
+ }
68
+ function getConfigurationForEnvironment(_x) {
69
+ return _getConfigurationForEnvironment.apply(this, arguments);
70
+ }
71
+ function _getConfigurationForEnvironment() {
72
+ _getConfigurationForEnvironment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(environmentName) {
73
+ var _context2, _context3, _context4, _context5;
74
+ var ignoredGlobs, ignoredCIGlobs, allIgnoredGlobs, configResult, allEnvironmentConfigs, configForEnvironment, secretsFiles, configFiles, mergedConfigurationAndSecrests, rootDir, sharedEnvironmentConfiguration, pathToSharedEnvironmentConfiguration;
75
+ return _regeneratorRuntime.wrap(function _callee2$(_context6) {
76
+ while (1) switch (_context6.prev = _context6.next) {
77
+ case 0:
78
+ // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
79
+ // decrypted files are available on a developer's machine.
80
+ ignoredGlobs = ['**/*.enc', '**/*.template'];
81
+ ignoredCIGlobs = ['**/*.ci'];
82
+ allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty(ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
83
+ if (isCI) {
84
+ console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
85
+ } else {
86
+ console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
87
+ }
88
+ console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
89
+ _context6.next = 7;
90
+ return loadConfig();
91
+ case 7:
92
+ configResult = _context6.sent;
93
+ allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
94
+ configForEnvironment = _findInstanceProperty(_context2 = allEnvironmentConfigs.environments).call(_context2, function (environment) {
95
+ return environment.name === environmentName;
96
+ });
97
+ if (configForEnvironment) {
98
+ _context6.next = 12;
99
+ break;
100
+ }
101
+ throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
102
+ case 12:
103
+ _context6.next = 14;
104
+ return promisifiedGlob(configForEnvironment.secrets.glob, {
105
+ ignore: allIgnoredGlobs
106
+ });
107
+ case 14:
108
+ secretsFiles = _context6.sent;
109
+ _context6.next = 17;
110
+ return promisifiedGlob(configForEnvironment.config.glob, {
111
+ ignore: allIgnoredGlobs
112
+ });
113
+ case 17:
114
+ configFiles = _context6.sent;
115
+ console.log(_concatInstanceProperty(_context3 = "\u2139\uFE0F Found ".concat(secretsFiles.length, " secret file(s) and ")).call(_context3, configFiles.length, " config file(s) matching the defined globs."));
116
+ if (secretsFiles.length === 0 || configFiles.length === 0) {
117
+ console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
118
+ console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
119
+ }
120
+ mergedConfigurationAndSecrests = _reduceInstanceProperty(_context4 = _concatInstanceProperty(_context5 = []).call(_context5, _toConsumableArray(configFiles), _toConsumableArray(secretsFiles))).call(_context4, function (previousParsedEnvFileContents, nextEnvFilePath) {
121
+ var parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
122
+ var matchingParsedEnvFileContentsForCIOrLocal = null;
123
+ if (!_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
124
+ matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
125
+ }
126
+ return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
127
+ }, {});
128
+ _context6.next = 23;
129
+ return pkgDir(__dirname);
130
+ case 23:
131
+ rootDir = _context6.sent;
132
+ sharedEnvironmentConfiguration = null;
133
+ if (rootDir) {
134
+ pathToSharedEnvironmentConfiguration = path.join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
135
+ if (fs.existsSync(pathToSharedEnvironmentConfiguration)) {
136
+ sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
137
+ } else {
138
+ console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
139
+ }
140
+ }
141
+ return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
142
+ case 27:
143
+ case "end":
144
+ return _context6.stop();
145
+ }
146
+ }, _callee2);
147
+ }));
148
+ return _getConfigurationForEnvironment.apply(this, arguments);
99
149
  }
100
150
 
101
151
  export { getConfigurationForEnvironment };
@@ -1,3 +1,3 @@
1
- declare type TEnvironmentConfigurationVariables = Record<string, string>;
1
+ type TEnvironmentConfigurationVariables = Record<string, string>;
2
2
  declare function getConfigurationForEnvironment(environmentName: string): Promise<TEnvironmentConfigurationVariables>;
3
3
  export { getConfigurationForEnvironment };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/cypress-environments",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Cypress package to setup environment configuration using dotenv files",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -19,13 +19,18 @@
19
19
  "README.md"
20
20
  ],
21
21
  "dependencies": {
22
- "cosmiconfig": "7.0.1",
23
- "dotenv": "16.0.2",
24
- "glob": "8.0.3",
22
+ "@babel/runtime": "^7.21.0",
23
+ "@babel/runtime-corejs3": "^7.21.0",
24
+ "cosmiconfig": "8.1.0",
25
+ "dotenv": "16.0.3",
26
+ "glob": "8.1.0",
25
27
  "pkg-dir": "5.0.0"
26
28
  },
27
29
  "devDependencies": {
28
- "typescript": "^4.8.2"
30
+ "@tsconfig/node18": "1.0.1",
31
+ "@types/glob": "8.1.0",
32
+ "@types/node": "18.14.6",
33
+ "typescript": "^4.9.5"
29
34
  },
30
35
  "engines": {
31
36
  "node": ">=14",