@commercetools-frontend/cypress-environments 0.0.3 → 0.0.4
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/dist/commercetools-frontend-cypress-environments.cjs.dev.js +147 -80
- package/dist/commercetools-frontend-cypress-environments.cjs.prod.js +147 -80
- package/dist/commercetools-frontend-cypress-environments.esm.js +134 -80
- package/dist/declarations/src/environments.d.ts +1 -1
- package/package.json +8 -4
|
@@ -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,153 @@ 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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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(
|
|
28
|
-
|
|
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
|
-
|
|
61
|
+
var configuration = dotenv__default["default"].parse(envFileContents);
|
|
32
62
|
return configuration;
|
|
33
63
|
} else {
|
|
34
|
-
console.log(
|
|
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
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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) {
|
|
75
|
+
switch (_context.prev = _context.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
_context.prev = 0;
|
|
78
|
+
_context.next = 3;
|
|
79
|
+
return cypressEnvironmentsConfigExplorer.search();
|
|
80
|
+
case 3:
|
|
81
|
+
return _context.abrupt("return", _context.sent);
|
|
82
|
+
case 6:
|
|
83
|
+
_context.prev = 6;
|
|
84
|
+
_context.t0 = _context["catch"](0);
|
|
85
|
+
throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
|
|
86
|
+
case 9:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context.stop();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, _callee, null, [[0, 6]]);
|
|
92
|
+
}));
|
|
93
|
+
return _loadConfig.apply(this, arguments);
|
|
94
|
+
}
|
|
95
|
+
function getConfigurationForEnvironment(_x) {
|
|
96
|
+
return _getConfigurationForEnvironment.apply(this, arguments);
|
|
97
|
+
}
|
|
98
|
+
function _getConfigurationForEnvironment() {
|
|
99
|
+
_getConfigurationForEnvironment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(environmentName) {
|
|
100
|
+
var _context2, _context3, _context4, _context5;
|
|
101
|
+
var ignoredGlobs, ignoredCIGlobs, allIgnoredGlobs, configResult, allEnvironmentConfigs, configForEnvironment, secretsFiles, configFiles, mergedConfigurationAndSecrests, rootDir, sharedEnvironmentConfiguration, pathToSharedEnvironmentConfiguration;
|
|
102
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context6) {
|
|
103
|
+
while (1) {
|
|
104
|
+
switch (_context6.prev = _context6.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
// NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
|
|
107
|
+
// decrypted files are available on a developer's machine.
|
|
108
|
+
ignoredGlobs = ['**/*.enc', '**/*.template'];
|
|
109
|
+
ignoredCIGlobs = ['**/*.ci'];
|
|
110
|
+
allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty__default["default"](ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
|
|
111
|
+
if (isCI) {
|
|
112
|
+
console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
|
|
113
|
+
} else {
|
|
114
|
+
console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
|
|
115
|
+
}
|
|
116
|
+
console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
|
|
117
|
+
_context6.next = 7;
|
|
118
|
+
return loadConfig();
|
|
119
|
+
case 7:
|
|
120
|
+
configResult = _context6.sent;
|
|
121
|
+
allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
|
|
122
|
+
configForEnvironment = _findInstanceProperty__default["default"](_context2 = allEnvironmentConfigs.environments).call(_context2, function (environment) {
|
|
123
|
+
return environment.name === environmentName;
|
|
124
|
+
});
|
|
125
|
+
if (configForEnvironment) {
|
|
126
|
+
_context6.next = 12;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
|
|
130
|
+
case 12:
|
|
131
|
+
_context6.next = 14;
|
|
132
|
+
return promisifiedGlob(configForEnvironment.secrets.glob, {
|
|
133
|
+
ignore: allIgnoredGlobs
|
|
134
|
+
});
|
|
135
|
+
case 14:
|
|
136
|
+
secretsFiles = _context6.sent;
|
|
137
|
+
_context6.next = 17;
|
|
138
|
+
return promisifiedGlob(configForEnvironment.config.glob, {
|
|
139
|
+
ignore: allIgnoredGlobs
|
|
140
|
+
});
|
|
141
|
+
case 17:
|
|
142
|
+
configFiles = _context6.sent;
|
|
143
|
+
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."));
|
|
144
|
+
if (secretsFiles.length === 0 || configFiles.length === 0) {
|
|
145
|
+
console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
|
|
146
|
+
console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
|
|
147
|
+
}
|
|
148
|
+
mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = []).call(_context5, _toConsumableArray(configFiles), _toConsumableArray(secretsFiles))).call(_context4, function (previousParsedEnvFileContents, nextEnvFilePath) {
|
|
149
|
+
var parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
|
|
150
|
+
var matchingParsedEnvFileContentsForCIOrLocal = null;
|
|
151
|
+
if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
|
|
152
|
+
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
|
|
153
|
+
}
|
|
154
|
+
return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
|
|
155
|
+
}, {});
|
|
156
|
+
_context6.next = 23;
|
|
157
|
+
return pkgDir__default["default"](__dirname);
|
|
158
|
+
case 23:
|
|
159
|
+
rootDir = _context6.sent;
|
|
160
|
+
sharedEnvironmentConfiguration = null;
|
|
161
|
+
if (rootDir) {
|
|
162
|
+
pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
|
|
163
|
+
if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
|
|
164
|
+
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
|
|
165
|
+
} else {
|
|
166
|
+
console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
|
|
170
|
+
case 27:
|
|
171
|
+
case "end":
|
|
172
|
+
return _context6.stop();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}, _callee2);
|
|
176
|
+
}));
|
|
177
|
+
return _getConfigurationForEnvironment.apply(this, arguments);
|
|
111
178
|
}
|
|
112
179
|
|
|
113
180
|
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,153 @@ 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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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(
|
|
28
|
-
|
|
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
|
-
|
|
61
|
+
var configuration = dotenv__default["default"].parse(envFileContents);
|
|
32
62
|
return configuration;
|
|
33
63
|
} else {
|
|
34
|
-
console.log(
|
|
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
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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) {
|
|
75
|
+
switch (_context.prev = _context.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
_context.prev = 0;
|
|
78
|
+
_context.next = 3;
|
|
79
|
+
return cypressEnvironmentsConfigExplorer.search();
|
|
80
|
+
case 3:
|
|
81
|
+
return _context.abrupt("return", _context.sent);
|
|
82
|
+
case 6:
|
|
83
|
+
_context.prev = 6;
|
|
84
|
+
_context.t0 = _context["catch"](0);
|
|
85
|
+
throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
|
|
86
|
+
case 9:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context.stop();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, _callee, null, [[0, 6]]);
|
|
92
|
+
}));
|
|
93
|
+
return _loadConfig.apply(this, arguments);
|
|
94
|
+
}
|
|
95
|
+
function getConfigurationForEnvironment(_x) {
|
|
96
|
+
return _getConfigurationForEnvironment.apply(this, arguments);
|
|
97
|
+
}
|
|
98
|
+
function _getConfigurationForEnvironment() {
|
|
99
|
+
_getConfigurationForEnvironment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(environmentName) {
|
|
100
|
+
var _context2, _context3, _context4, _context5;
|
|
101
|
+
var ignoredGlobs, ignoredCIGlobs, allIgnoredGlobs, configResult, allEnvironmentConfigs, configForEnvironment, secretsFiles, configFiles, mergedConfigurationAndSecrests, rootDir, sharedEnvironmentConfiguration, pathToSharedEnvironmentConfiguration;
|
|
102
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context6) {
|
|
103
|
+
while (1) {
|
|
104
|
+
switch (_context6.prev = _context6.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
// NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
|
|
107
|
+
// decrypted files are available on a developer's machine.
|
|
108
|
+
ignoredGlobs = ['**/*.enc', '**/*.template'];
|
|
109
|
+
ignoredCIGlobs = ['**/*.ci'];
|
|
110
|
+
allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty__default["default"](ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
|
|
111
|
+
if (isCI) {
|
|
112
|
+
console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
|
|
113
|
+
} else {
|
|
114
|
+
console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
|
|
115
|
+
}
|
|
116
|
+
console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
|
|
117
|
+
_context6.next = 7;
|
|
118
|
+
return loadConfig();
|
|
119
|
+
case 7:
|
|
120
|
+
configResult = _context6.sent;
|
|
121
|
+
allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
|
|
122
|
+
configForEnvironment = _findInstanceProperty__default["default"](_context2 = allEnvironmentConfigs.environments).call(_context2, function (environment) {
|
|
123
|
+
return environment.name === environmentName;
|
|
124
|
+
});
|
|
125
|
+
if (configForEnvironment) {
|
|
126
|
+
_context6.next = 12;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
|
|
130
|
+
case 12:
|
|
131
|
+
_context6.next = 14;
|
|
132
|
+
return promisifiedGlob(configForEnvironment.secrets.glob, {
|
|
133
|
+
ignore: allIgnoredGlobs
|
|
134
|
+
});
|
|
135
|
+
case 14:
|
|
136
|
+
secretsFiles = _context6.sent;
|
|
137
|
+
_context6.next = 17;
|
|
138
|
+
return promisifiedGlob(configForEnvironment.config.glob, {
|
|
139
|
+
ignore: allIgnoredGlobs
|
|
140
|
+
});
|
|
141
|
+
case 17:
|
|
142
|
+
configFiles = _context6.sent;
|
|
143
|
+
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."));
|
|
144
|
+
if (secretsFiles.length === 0 || configFiles.length === 0) {
|
|
145
|
+
console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
|
|
146
|
+
console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
|
|
147
|
+
}
|
|
148
|
+
mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = []).call(_context5, _toConsumableArray(configFiles), _toConsumableArray(secretsFiles))).call(_context4, function (previousParsedEnvFileContents, nextEnvFilePath) {
|
|
149
|
+
var parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
|
|
150
|
+
var matchingParsedEnvFileContentsForCIOrLocal = null;
|
|
151
|
+
if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
|
|
152
|
+
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
|
|
153
|
+
}
|
|
154
|
+
return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
|
|
155
|
+
}, {});
|
|
156
|
+
_context6.next = 23;
|
|
157
|
+
return pkgDir__default["default"](__dirname);
|
|
158
|
+
case 23:
|
|
159
|
+
rootDir = _context6.sent;
|
|
160
|
+
sharedEnvironmentConfiguration = null;
|
|
161
|
+
if (rootDir) {
|
|
162
|
+
pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
|
|
163
|
+
if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
|
|
164
|
+
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
|
|
165
|
+
} else {
|
|
166
|
+
console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
|
|
170
|
+
case 27:
|
|
171
|
+
case "end":
|
|
172
|
+
return _context6.stop();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}, _callee2);
|
|
176
|
+
}));
|
|
177
|
+
return _getConfigurationForEnvironment.apply(this, arguments);
|
|
111
178
|
}
|
|
112
179
|
|
|
113
180
|
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,134 @@ import dotenv from 'dotenv';
|
|
|
6
22
|
import pkgDir from 'pkg-dir';
|
|
7
23
|
import { cosmiconfig } from 'cosmiconfig';
|
|
8
24
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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(
|
|
16
|
-
|
|
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
|
-
|
|
36
|
+
var configuration = dotenv.parse(envFileContents);
|
|
20
37
|
return configuration;
|
|
21
38
|
} else {
|
|
22
|
-
console.log(
|
|
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
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
46
|
+
function _loadConfig() {
|
|
47
|
+
_loadConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
48
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
49
|
+
while (1) {
|
|
50
|
+
switch (_context.prev = _context.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
_context.prev = 0;
|
|
53
|
+
_context.next = 3;
|
|
54
|
+
return cypressEnvironmentsConfigExplorer.search();
|
|
55
|
+
case 3:
|
|
56
|
+
return _context.abrupt("return", _context.sent);
|
|
57
|
+
case 6:
|
|
58
|
+
_context.prev = 6;
|
|
59
|
+
_context.t0 = _context["catch"](0);
|
|
60
|
+
throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
|
|
61
|
+
case 9:
|
|
62
|
+
case "end":
|
|
63
|
+
return _context.stop();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}, _callee, null, [[0, 6]]);
|
|
67
|
+
}));
|
|
68
|
+
return _loadConfig.apply(this, arguments);
|
|
69
|
+
}
|
|
70
|
+
function getConfigurationForEnvironment(_x) {
|
|
71
|
+
return _getConfigurationForEnvironment.apply(this, arguments);
|
|
72
|
+
}
|
|
73
|
+
function _getConfigurationForEnvironment() {
|
|
74
|
+
_getConfigurationForEnvironment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(environmentName) {
|
|
75
|
+
var _context2, _context3, _context4, _context5;
|
|
76
|
+
var ignoredGlobs, ignoredCIGlobs, allIgnoredGlobs, configResult, allEnvironmentConfigs, configForEnvironment, secretsFiles, configFiles, mergedConfigurationAndSecrests, rootDir, sharedEnvironmentConfiguration, pathToSharedEnvironmentConfiguration;
|
|
77
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context6) {
|
|
78
|
+
while (1) {
|
|
79
|
+
switch (_context6.prev = _context6.next) {
|
|
80
|
+
case 0:
|
|
81
|
+
// NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
|
|
82
|
+
// decrypted files are available on a developer's machine.
|
|
83
|
+
ignoredGlobs = ['**/*.enc', '**/*.template'];
|
|
84
|
+
ignoredCIGlobs = ['**/*.ci'];
|
|
85
|
+
allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty(ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
|
|
86
|
+
if (isCI) {
|
|
87
|
+
console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
|
|
88
|
+
} else {
|
|
89
|
+
console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
|
|
90
|
+
}
|
|
91
|
+
console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
|
|
92
|
+
_context6.next = 7;
|
|
93
|
+
return loadConfig();
|
|
94
|
+
case 7:
|
|
95
|
+
configResult = _context6.sent;
|
|
96
|
+
allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
|
|
97
|
+
configForEnvironment = _findInstanceProperty(_context2 = allEnvironmentConfigs.environments).call(_context2, function (environment) {
|
|
98
|
+
return environment.name === environmentName;
|
|
99
|
+
});
|
|
100
|
+
if (configForEnvironment) {
|
|
101
|
+
_context6.next = 12;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
|
|
105
|
+
case 12:
|
|
106
|
+
_context6.next = 14;
|
|
107
|
+
return promisifiedGlob(configForEnvironment.secrets.glob, {
|
|
108
|
+
ignore: allIgnoredGlobs
|
|
109
|
+
});
|
|
110
|
+
case 14:
|
|
111
|
+
secretsFiles = _context6.sent;
|
|
112
|
+
_context6.next = 17;
|
|
113
|
+
return promisifiedGlob(configForEnvironment.config.glob, {
|
|
114
|
+
ignore: allIgnoredGlobs
|
|
115
|
+
});
|
|
116
|
+
case 17:
|
|
117
|
+
configFiles = _context6.sent;
|
|
118
|
+
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."));
|
|
119
|
+
if (secretsFiles.length === 0 || configFiles.length === 0) {
|
|
120
|
+
console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
|
|
121
|
+
console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
|
|
122
|
+
}
|
|
123
|
+
mergedConfigurationAndSecrests = _reduceInstanceProperty(_context4 = _concatInstanceProperty(_context5 = []).call(_context5, _toConsumableArray(configFiles), _toConsumableArray(secretsFiles))).call(_context4, function (previousParsedEnvFileContents, nextEnvFilePath) {
|
|
124
|
+
var parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
|
|
125
|
+
var matchingParsedEnvFileContentsForCIOrLocal = null;
|
|
126
|
+
if (!_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
|
|
127
|
+
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
|
|
128
|
+
}
|
|
129
|
+
return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
|
|
130
|
+
}, {});
|
|
131
|
+
_context6.next = 23;
|
|
132
|
+
return pkgDir(__dirname);
|
|
133
|
+
case 23:
|
|
134
|
+
rootDir = _context6.sent;
|
|
135
|
+
sharedEnvironmentConfiguration = null;
|
|
136
|
+
if (rootDir) {
|
|
137
|
+
pathToSharedEnvironmentConfiguration = path.join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
|
|
138
|
+
if (fs.existsSync(pathToSharedEnvironmentConfiguration)) {
|
|
139
|
+
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
|
|
140
|
+
} else {
|
|
141
|
+
console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
|
|
145
|
+
case 27:
|
|
146
|
+
case "end":
|
|
147
|
+
return _context6.stop();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}, _callee2);
|
|
151
|
+
}));
|
|
152
|
+
return _getConfigurationForEnvironment.apply(this, arguments);
|
|
99
153
|
}
|
|
100
154
|
|
|
101
155
|
export { getConfigurationForEnvironment };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
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
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Cypress package to setup environment configuration using dotenv files",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,13 +19,17 @@
|
|
|
19
19
|
"README.md"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
22
|
+
"@babel/runtime": "^7.19.0",
|
|
23
|
+
"@babel/runtime-corejs3": "^7.19.0",
|
|
24
|
+
"cosmiconfig": "8.0.0",
|
|
25
|
+
"dotenv": "16.0.3",
|
|
24
26
|
"glob": "8.0.3",
|
|
25
27
|
"pkg-dir": "5.0.0"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
|
-
"
|
|
30
|
+
"@tsconfig/node18": "1.0.1",
|
|
31
|
+
"@types/glob": "8.0.0",
|
|
32
|
+
"typescript": "^4.8.4"
|
|
29
33
|
},
|
|
30
34
|
"engines": {
|
|
31
35
|
"node": ">=14",
|