@commercetools-frontend/cypress-environments 0.0.4 → 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.
@@ -71,22 +71,20 @@ function loadConfig() {
71
71
  function _loadConfig() {
72
72
  _loadConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
73
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
- }
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();
90
88
  }
91
89
  }, _callee, null, [[0, 6]]);
92
90
  }));
@@ -100,77 +98,75 @@ function _getConfigurationForEnvironment() {
100
98
  var _context2, _context3, _context4, _context5;
101
99
  var ignoredGlobs, ignoredCIGlobs, allIgnoredGlobs, configResult, allEnvironmentConfigs, configForEnvironment, secretsFiles, configFiles, mergedConfigurationAndSecrests, rootDir, sharedEnvironmentConfiguration, pathToSharedEnvironmentConfiguration;
102
100
  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;
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"));
128
150
  }
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
- }
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."));
168
164
  }
169
- return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
170
- case 27:
171
- case "end":
172
- return _context6.stop();
173
- }
165
+ }
166
+ return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
167
+ case 27:
168
+ case "end":
169
+ return _context6.stop();
174
170
  }
175
171
  }, _callee2);
176
172
  }));
@@ -71,22 +71,20 @@ function loadConfig() {
71
71
  function _loadConfig() {
72
72
  _loadConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
73
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
- }
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();
90
88
  }
91
89
  }, _callee, null, [[0, 6]]);
92
90
  }));
@@ -100,77 +98,75 @@ function _getConfigurationForEnvironment() {
100
98
  var _context2, _context3, _context4, _context5;
101
99
  var ignoredGlobs, ignoredCIGlobs, allIgnoredGlobs, configResult, allEnvironmentConfigs, configForEnvironment, secretsFiles, configFiles, mergedConfigurationAndSecrests, rootDir, sharedEnvironmentConfiguration, pathToSharedEnvironmentConfiguration;
102
100
  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;
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"));
128
150
  }
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
- }
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."));
168
164
  }
169
- return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
170
- case 27:
171
- case "end":
172
- return _context6.stop();
173
- }
165
+ }
166
+ return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
167
+ case 27:
168
+ case "end":
169
+ return _context6.stop();
174
170
  }
175
171
  }, _callee2);
176
172
  }));
@@ -46,22 +46,20 @@ function loadConfig() {
46
46
  function _loadConfig() {
47
47
  _loadConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
48
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
- }
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();
65
63
  }
66
64
  }, _callee, null, [[0, 6]]);
67
65
  }));
@@ -75,77 +73,75 @@ function _getConfigurationForEnvironment() {
75
73
  var _context2, _context3, _context4, _context5;
76
74
  var ignoredGlobs, ignoredCIGlobs, allIgnoredGlobs, configResult, allEnvironmentConfigs, configForEnvironment, secretsFiles, configFiles, mergedConfigurationAndSecrests, rootDir, sharedEnvironmentConfiguration, pathToSharedEnvironmentConfiguration;
77
75
  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;
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"));
103
125
  }
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
- }
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."));
143
139
  }
144
- return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
145
- case 27:
146
- case "end":
147
- return _context6.stop();
148
- }
140
+ }
141
+ return _context6.abrupt("return", _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests));
142
+ case 27:
143
+ case "end":
144
+ return _context6.stop();
149
145
  }
150
146
  }, _callee2);
151
147
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/cypress-environments",
3
- "version": "0.0.4",
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,17 +19,18 @@
19
19
  "README.md"
20
20
  ],
21
21
  "dependencies": {
22
- "@babel/runtime": "^7.19.0",
23
- "@babel/runtime-corejs3": "^7.19.0",
24
- "cosmiconfig": "8.0.0",
22
+ "@babel/runtime": "^7.21.0",
23
+ "@babel/runtime-corejs3": "^7.21.0",
24
+ "cosmiconfig": "8.1.0",
25
25
  "dotenv": "16.0.3",
26
- "glob": "8.0.3",
26
+ "glob": "8.1.0",
27
27
  "pkg-dir": "5.0.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@tsconfig/node18": "1.0.1",
31
- "@types/glob": "8.0.0",
32
- "typescript": "^4.8.4"
31
+ "@types/glob": "8.1.0",
32
+ "@types/node": "18.14.6",
33
+ "typescript": "^4.9.5"
33
34
  },
34
35
  "engines": {
35
36
  "node": ">=14",