@commercetools-frontend/cypress-environments 0.1.0 → 0.1.2

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.
@@ -1,2 +1,2 @@
1
1
  export * from "./declarations/src/index";
2
- //# sourceMappingURL=commercetools-frontend-cypress-environments.cjs.d.ts.map
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy1mcm9udGVuZC1jeXByZXNzLWVudmlyb25tZW50cy5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
@@ -42,19 +42,29 @@ var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
42
42
  var pkgDir__default = /*#__PURE__*/_interopDefault(pkgDir);
43
43
 
44
44
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
45
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
46
- const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
45
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
46
+ const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments', {
47
+ searchStrategy: 'project'
48
+ });
47
49
  const isCI = String(process.env.CI) === 'true';
50
+ function doesFileExist(filePath) {
51
+ try {
52
+ fs__default["default"].accessSync(filePath);
53
+ return true;
54
+ } catch (e) {
55
+ return false;
56
+ }
57
+ }
48
58
  function getParsedEnvFileContents(envPath) {
49
- if (fs__default["default"].existsSync(envPath)) {
50
- console.log(`✅ Found and loading environment variables from: '${envPath}'`);
59
+ if (doesFileExist(envPath)) {
60
+ console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
51
61
  const envFileContents = fs__default["default"].readFileSync(envPath, {
52
62
  encoding: 'utf8'
53
63
  });
54
64
  const configuration = dotenv__default["default"].parse(envFileContents);
55
65
  return configuration;
56
66
  } else {
57
- console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
67
+ console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
58
68
  return null;
59
69
  }
60
70
  }
@@ -62,27 +72,27 @@ async function loadConfig() {
62
72
  try {
63
73
  return await cypressEnvironmentsConfigExplorer.search();
64
74
  } catch (e) {
65
- throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
75
+ throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
66
76
  }
67
77
  }
68
78
  async function getConfigurationForEnvironment(environmentName) {
69
- var _context, _context2;
79
+ var _context, _context2, _context3;
70
80
  // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
71
81
  // decrypted files are available on a developer's machine.
72
82
  const ignoredGlobs = ['**/*.enc', '**/*.template'];
73
83
  const ignoredCIGlobs = ['**/*.ci'];
74
84
  const allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty__default["default"](ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
75
85
  if (isCI) {
76
- console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
86
+ console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
77
87
  } else {
78
- console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
88
+ console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
79
89
  }
80
- console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
90
+ console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
81
91
  const configResult = await loadConfig();
82
- const allEnvironmentConfigs = configResult?.config;
92
+ const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
83
93
  const configForEnvironment = _findInstanceProperty__default["default"](_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
84
94
  if (!configForEnvironment) {
85
- throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
95
+ throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
86
96
  }
87
97
  const secretsFiles = await glob.glob(configForEnvironment.secrets.glob, {
88
98
  ignore: allIgnoredGlobs
@@ -90,27 +100,27 @@ async function getConfigurationForEnvironment(environmentName) {
90
100
  const configFiles = await glob.glob(configForEnvironment.config.glob, {
91
101
  ignore: allIgnoredGlobs
92
102
  });
93
- console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
103
+ console.log(_concatInstanceProperty__default["default"](_context2 = "\u2139\uFE0F Found ".concat(secretsFiles.length, " secret file(s) and ")).call(_context2, configFiles.length, " config file(s) matching the defined globs."));
94
104
  if (secretsFiles.length === 0 || configFiles.length === 0) {
95
- console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
96
- console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
105
+ console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
106
+ console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
97
107
  }
98
- const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context2 = [...configFiles, ...secretsFiles]).call(_context2, (previousParsedEnvFileContents, nextEnvFilePath) => {
108
+ const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
99
109
  const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
100
110
  let matchingParsedEnvFileContentsForCIOrLocal = null;
101
111
  if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
102
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
112
+ matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
103
113
  }
104
114
  return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
105
115
  }, {});
106
116
  const rootDir = await pkgDir__default["default"](__dirname);
107
117
  let sharedEnvironmentConfiguration = null;
108
118
  if (rootDir) {
109
- const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', `.env.${environmentName}.config`);
110
- if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
119
+ const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
120
+ if (doesFileExist(pathToSharedEnvironmentConfiguration)) {
111
121
  sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
112
122
  } else {
113
- console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
123
+ console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
114
124
  }
115
125
  }
116
126
  return _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests);
@@ -42,19 +42,29 @@ var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
42
42
  var pkgDir__default = /*#__PURE__*/_interopDefault(pkgDir);
43
43
 
44
44
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
45
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
46
- const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
45
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
46
+ const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments', {
47
+ searchStrategy: 'project'
48
+ });
47
49
  const isCI = String(process.env.CI) === 'true';
50
+ function doesFileExist(filePath) {
51
+ try {
52
+ fs__default["default"].accessSync(filePath);
53
+ return true;
54
+ } catch (e) {
55
+ return false;
56
+ }
57
+ }
48
58
  function getParsedEnvFileContents(envPath) {
49
- if (fs__default["default"].existsSync(envPath)) {
50
- console.log(`✅ Found and loading environment variables from: '${envPath}'`);
59
+ if (doesFileExist(envPath)) {
60
+ console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
51
61
  const envFileContents = fs__default["default"].readFileSync(envPath, {
52
62
  encoding: 'utf8'
53
63
  });
54
64
  const configuration = dotenv__default["default"].parse(envFileContents);
55
65
  return configuration;
56
66
  } else {
57
- console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
67
+ console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
58
68
  return null;
59
69
  }
60
70
  }
@@ -62,27 +72,27 @@ async function loadConfig() {
62
72
  try {
63
73
  return await cypressEnvironmentsConfigExplorer.search();
64
74
  } catch (e) {
65
- throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
75
+ throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
66
76
  }
67
77
  }
68
78
  async function getConfigurationForEnvironment(environmentName) {
69
- var _context, _context2;
79
+ var _context, _context2, _context3;
70
80
  // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
71
81
  // decrypted files are available on a developer's machine.
72
82
  const ignoredGlobs = ['**/*.enc', '**/*.template'];
73
83
  const ignoredCIGlobs = ['**/*.ci'];
74
84
  const allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty__default["default"](ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
75
85
  if (isCI) {
76
- console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
86
+ console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
77
87
  } else {
78
- console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
88
+ console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
79
89
  }
80
- console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
90
+ console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
81
91
  const configResult = await loadConfig();
82
- const allEnvironmentConfigs = configResult?.config;
92
+ const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
83
93
  const configForEnvironment = _findInstanceProperty__default["default"](_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
84
94
  if (!configForEnvironment) {
85
- throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
95
+ throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
86
96
  }
87
97
  const secretsFiles = await glob.glob(configForEnvironment.secrets.glob, {
88
98
  ignore: allIgnoredGlobs
@@ -90,27 +100,27 @@ async function getConfigurationForEnvironment(environmentName) {
90
100
  const configFiles = await glob.glob(configForEnvironment.config.glob, {
91
101
  ignore: allIgnoredGlobs
92
102
  });
93
- console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
103
+ console.log(_concatInstanceProperty__default["default"](_context2 = "\u2139\uFE0F Found ".concat(secretsFiles.length, " secret file(s) and ")).call(_context2, configFiles.length, " config file(s) matching the defined globs."));
94
104
  if (secretsFiles.length === 0 || configFiles.length === 0) {
95
- console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
96
- console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
105
+ console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
106
+ console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
97
107
  }
98
- const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context2 = [...configFiles, ...secretsFiles]).call(_context2, (previousParsedEnvFileContents, nextEnvFilePath) => {
108
+ const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
99
109
  const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
100
110
  let matchingParsedEnvFileContentsForCIOrLocal = null;
101
111
  if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
102
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
112
+ matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
103
113
  }
104
114
  return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
105
115
  }, {});
106
116
  const rootDir = await pkgDir__default["default"](__dirname);
107
117
  let sharedEnvironmentConfiguration = null;
108
118
  if (rootDir) {
109
- const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', `.env.${environmentName}.config`);
110
- if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
119
+ const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
120
+ if (doesFileExist(pathToSharedEnvironmentConfiguration)) {
111
121
  sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
112
122
  } else {
113
- console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
123
+ console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
114
124
  }
115
125
  }
116
126
  return _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests);
@@ -19,19 +19,29 @@ import pkgDir from 'pkg-dir';
19
19
  import { cosmiconfig } from 'cosmiconfig';
20
20
 
21
21
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
23
- const cypressEnvironmentsConfigExplorer = cosmiconfig('cypress-environments');
22
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
23
+ const cypressEnvironmentsConfigExplorer = cosmiconfig('cypress-environments', {
24
+ searchStrategy: 'project'
25
+ });
24
26
  const isCI = String(process.env.CI) === 'true';
27
+ function doesFileExist(filePath) {
28
+ try {
29
+ fs.accessSync(filePath);
30
+ return true;
31
+ } catch (e) {
32
+ return false;
33
+ }
34
+ }
25
35
  function getParsedEnvFileContents(envPath) {
26
- if (fs.existsSync(envPath)) {
27
- console.log(`✅ Found and loading environment variables from: '${envPath}'`);
36
+ if (doesFileExist(envPath)) {
37
+ console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
28
38
  const envFileContents = fs.readFileSync(envPath, {
29
39
  encoding: 'utf8'
30
40
  });
31
41
  const configuration = dotenv.parse(envFileContents);
32
42
  return configuration;
33
43
  } else {
34
- console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
44
+ console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
35
45
  return null;
36
46
  }
37
47
  }
@@ -39,27 +49,27 @@ async function loadConfig() {
39
49
  try {
40
50
  return await cypressEnvironmentsConfigExplorer.search();
41
51
  } catch (e) {
42
- throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
52
+ throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
43
53
  }
44
54
  }
45
55
  async function getConfigurationForEnvironment(environmentName) {
46
- var _context, _context2;
56
+ var _context, _context2, _context3;
47
57
  // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
48
58
  // decrypted files are available on a developer's machine.
49
59
  const ignoredGlobs = ['**/*.enc', '**/*.template'];
50
60
  const ignoredCIGlobs = ['**/*.ci'];
51
61
  const allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty(ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
52
62
  if (isCI) {
53
- console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
63
+ console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
54
64
  } else {
55
- console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
65
+ console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
56
66
  }
57
- console.log(`ℹ️ The ignored globs are: ${allIgnoredGlobs.join(', ')}.`);
67
+ console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
58
68
  const configResult = await loadConfig();
59
- const allEnvironmentConfigs = configResult?.config;
69
+ const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
60
70
  const configForEnvironment = _findInstanceProperty(_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
61
71
  if (!configForEnvironment) {
62
- throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
72
+ throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
63
73
  }
64
74
  const secretsFiles = await glob(configForEnvironment.secrets.glob, {
65
75
  ignore: allIgnoredGlobs
@@ -67,27 +77,27 @@ async function getConfigurationForEnvironment(environmentName) {
67
77
  const configFiles = await glob(configForEnvironment.config.glob, {
68
78
  ignore: allIgnoredGlobs
69
79
  });
70
- console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
80
+ console.log(_concatInstanceProperty(_context2 = "\u2139\uFE0F Found ".concat(secretsFiles.length, " secret file(s) and ")).call(_context2, configFiles.length, " config file(s) matching the defined globs."));
71
81
  if (secretsFiles.length === 0 || configFiles.length === 0) {
72
- console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
73
- console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
82
+ console.log("\u2139\uFE0F Secrets files glob is: ".concat(configForEnvironment.secrets.glob));
83
+ console.log("\u2139\uFE0F Config files glob is: ".concat(configForEnvironment.config.glob));
74
84
  }
75
- const mergedConfigurationAndSecrests = _reduceInstanceProperty(_context2 = [...configFiles, ...secretsFiles]).call(_context2, (previousParsedEnvFileContents, nextEnvFilePath) => {
85
+ const mergedConfigurationAndSecrests = _reduceInstanceProperty(_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
76
86
  const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
77
87
  let matchingParsedEnvFileContentsForCIOrLocal = null;
78
88
  if (!_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
79
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
89
+ matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
80
90
  }
81
91
  return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
82
92
  }, {});
83
93
  const rootDir = await pkgDir(__dirname);
84
94
  let sharedEnvironmentConfiguration = null;
85
95
  if (rootDir) {
86
- const pathToSharedEnvironmentConfiguration = path.join(rootDir, 'config', `.env.${environmentName}.config`);
87
- if (fs.existsSync(pathToSharedEnvironmentConfiguration)) {
96
+ const pathToSharedEnvironmentConfiguration = path.join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
97
+ if (doesFileExist(pathToSharedEnvironmentConfiguration)) {
88
98
  sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
89
99
  } else {
90
- console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
100
+ console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
91
101
  }
92
102
  }
93
103
  return _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/cypress-environments",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Cypress package to setup environment configuration using dotenv files",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -19,15 +19,15 @@
19
19
  "@babel/core": "^7.22.11",
20
20
  "@babel/runtime": "^7.21.0",
21
21
  "@babel/runtime-corejs3": "^7.21.0",
22
- "cosmiconfig": "8.3.6",
23
- "dotenv": "16.3.1",
24
- "glob": "10.3.10",
22
+ "cosmiconfig": "9.0.0",
23
+ "dotenv": "16.4.5",
24
+ "glob": "10.3.12",
25
25
  "pkg-dir": "5.0.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@tsconfig/node20": "20.1.2",
28
+ "@tsconfig/node20": "20.1.4",
29
29
  "@types/glob": "8.1.0",
30
- "@types/node": "20.8.0",
30
+ "@types/node": "20.12.7",
31
31
  "typescript": "5.2.2"
32
32
  },
33
33
  "engines": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"commercetools-frontend-cypress-environments.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}