@commercetools-frontend/cypress-environments 0.1.1 → 0.1.3
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.
|
@@ -42,21 +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
|
|
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
46
|
const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments', {
|
|
47
47
|
searchStrategy: 'project'
|
|
48
48
|
});
|
|
49
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
|
+
}
|
|
50
58
|
function getParsedEnvFileContents(envPath) {
|
|
51
|
-
if (
|
|
52
|
-
console.log(
|
|
59
|
+
if (doesFileExist(envPath)) {
|
|
60
|
+
console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
|
|
53
61
|
const envFileContents = fs__default["default"].readFileSync(envPath, {
|
|
54
62
|
encoding: 'utf8'
|
|
55
63
|
});
|
|
56
64
|
const configuration = dotenv__default["default"].parse(envFileContents);
|
|
57
65
|
return configuration;
|
|
58
66
|
} else {
|
|
59
|
-
console.log(
|
|
67
|
+
console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
|
|
60
68
|
return null;
|
|
61
69
|
}
|
|
62
70
|
}
|
|
@@ -64,27 +72,27 @@ async function loadConfig() {
|
|
|
64
72
|
try {
|
|
65
73
|
return await cypressEnvironmentsConfigExplorer.search();
|
|
66
74
|
} catch (e) {
|
|
67
|
-
throw new Error(
|
|
75
|
+
throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
78
|
async function getConfigurationForEnvironment(environmentName) {
|
|
71
|
-
var _context, _context2;
|
|
79
|
+
var _context, _context2, _context3;
|
|
72
80
|
// NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
|
|
73
81
|
// decrypted files are available on a developer's machine.
|
|
74
82
|
const ignoredGlobs = ['**/*.enc', '**/*.template'];
|
|
75
83
|
const ignoredCIGlobs = ['**/*.ci'];
|
|
76
84
|
const allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty__default["default"](ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
|
|
77
85
|
if (isCI) {
|
|
78
|
-
console.log(
|
|
86
|
+
console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
|
|
79
87
|
} else {
|
|
80
|
-
console.log(
|
|
88
|
+
console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
|
|
81
89
|
}
|
|
82
|
-
console.log(
|
|
90
|
+
console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
|
|
83
91
|
const configResult = await loadConfig();
|
|
84
|
-
const allEnvironmentConfigs = configResult
|
|
92
|
+
const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
|
|
85
93
|
const configForEnvironment = _findInstanceProperty__default["default"](_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
|
|
86
94
|
if (!configForEnvironment) {
|
|
87
|
-
throw new Error(
|
|
95
|
+
throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
|
|
88
96
|
}
|
|
89
97
|
const secretsFiles = await glob.glob(configForEnvironment.secrets.glob, {
|
|
90
98
|
ignore: allIgnoredGlobs
|
|
@@ -92,27 +100,27 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
92
100
|
const configFiles = await glob.glob(configForEnvironment.config.glob, {
|
|
93
101
|
ignore: allIgnoredGlobs
|
|
94
102
|
});
|
|
95
|
-
console.log(
|
|
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."));
|
|
96
104
|
if (secretsFiles.length === 0 || configFiles.length === 0) {
|
|
97
|
-
console.log(
|
|
98
|
-
console.log(
|
|
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));
|
|
99
107
|
}
|
|
100
|
-
const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](
|
|
108
|
+
const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
|
|
101
109
|
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
|
|
102
110
|
let matchingParsedEnvFileContentsForCIOrLocal = null;
|
|
103
111
|
if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
|
|
104
|
-
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(
|
|
112
|
+
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
|
|
105
113
|
}
|
|
106
114
|
return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
|
|
107
115
|
}, {});
|
|
108
116
|
const rootDir = await pkgDir__default["default"](__dirname);
|
|
109
117
|
let sharedEnvironmentConfiguration = null;
|
|
110
118
|
if (rootDir) {
|
|
111
|
-
const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config',
|
|
112
|
-
if (
|
|
119
|
+
const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
|
|
120
|
+
if (doesFileExist(pathToSharedEnvironmentConfiguration)) {
|
|
113
121
|
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
|
|
114
122
|
} else {
|
|
115
|
-
console.log(
|
|
123
|
+
console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
|
|
116
124
|
}
|
|
117
125
|
}
|
|
118
126
|
return _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests);
|
|
@@ -42,21 +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
|
|
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
46
|
const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments', {
|
|
47
47
|
searchStrategy: 'project'
|
|
48
48
|
});
|
|
49
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
|
+
}
|
|
50
58
|
function getParsedEnvFileContents(envPath) {
|
|
51
|
-
if (
|
|
52
|
-
console.log(
|
|
59
|
+
if (doesFileExist(envPath)) {
|
|
60
|
+
console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
|
|
53
61
|
const envFileContents = fs__default["default"].readFileSync(envPath, {
|
|
54
62
|
encoding: 'utf8'
|
|
55
63
|
});
|
|
56
64
|
const configuration = dotenv__default["default"].parse(envFileContents);
|
|
57
65
|
return configuration;
|
|
58
66
|
} else {
|
|
59
|
-
console.log(
|
|
67
|
+
console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
|
|
60
68
|
return null;
|
|
61
69
|
}
|
|
62
70
|
}
|
|
@@ -64,27 +72,27 @@ async function loadConfig() {
|
|
|
64
72
|
try {
|
|
65
73
|
return await cypressEnvironmentsConfigExplorer.search();
|
|
66
74
|
} catch (e) {
|
|
67
|
-
throw new Error(
|
|
75
|
+
throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
78
|
async function getConfigurationForEnvironment(environmentName) {
|
|
71
|
-
var _context, _context2;
|
|
79
|
+
var _context, _context2, _context3;
|
|
72
80
|
// NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
|
|
73
81
|
// decrypted files are available on a developer's machine.
|
|
74
82
|
const ignoredGlobs = ['**/*.enc', '**/*.template'];
|
|
75
83
|
const ignoredCIGlobs = ['**/*.ci'];
|
|
76
84
|
const allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty__default["default"](ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
|
|
77
85
|
if (isCI) {
|
|
78
|
-
console.log(
|
|
86
|
+
console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
|
|
79
87
|
} else {
|
|
80
|
-
console.log(
|
|
88
|
+
console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
|
|
81
89
|
}
|
|
82
|
-
console.log(
|
|
90
|
+
console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
|
|
83
91
|
const configResult = await loadConfig();
|
|
84
|
-
const allEnvironmentConfigs = configResult
|
|
92
|
+
const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
|
|
85
93
|
const configForEnvironment = _findInstanceProperty__default["default"](_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
|
|
86
94
|
if (!configForEnvironment) {
|
|
87
|
-
throw new Error(
|
|
95
|
+
throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
|
|
88
96
|
}
|
|
89
97
|
const secretsFiles = await glob.glob(configForEnvironment.secrets.glob, {
|
|
90
98
|
ignore: allIgnoredGlobs
|
|
@@ -92,27 +100,27 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
92
100
|
const configFiles = await glob.glob(configForEnvironment.config.glob, {
|
|
93
101
|
ignore: allIgnoredGlobs
|
|
94
102
|
});
|
|
95
|
-
console.log(
|
|
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."));
|
|
96
104
|
if (secretsFiles.length === 0 || configFiles.length === 0) {
|
|
97
|
-
console.log(
|
|
98
|
-
console.log(
|
|
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));
|
|
99
107
|
}
|
|
100
|
-
const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](
|
|
108
|
+
const mergedConfigurationAndSecrests = _reduceInstanceProperty__default["default"](_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
|
|
101
109
|
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
|
|
102
110
|
let matchingParsedEnvFileContentsForCIOrLocal = null;
|
|
103
111
|
if (!_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty__default["default"](nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
|
|
104
|
-
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(
|
|
112
|
+
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
|
|
105
113
|
}
|
|
106
114
|
return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
|
|
107
115
|
}, {});
|
|
108
116
|
const rootDir = await pkgDir__default["default"](__dirname);
|
|
109
117
|
let sharedEnvironmentConfiguration = null;
|
|
110
118
|
if (rootDir) {
|
|
111
|
-
const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config',
|
|
112
|
-
if (
|
|
119
|
+
const pathToSharedEnvironmentConfiguration = path__default["default"].join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
|
|
120
|
+
if (doesFileExist(pathToSharedEnvironmentConfiguration)) {
|
|
113
121
|
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
|
|
114
122
|
} else {
|
|
115
|
-
console.log(
|
|
123
|
+
console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
|
|
116
124
|
}
|
|
117
125
|
}
|
|
118
126
|
return _objectSpread(_objectSpread({}, sharedEnvironmentConfiguration), mergedConfigurationAndSecrests);
|
|
@@ -19,21 +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
|
|
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
23
|
const cypressEnvironmentsConfigExplorer = cosmiconfig('cypress-environments', {
|
|
24
24
|
searchStrategy: 'project'
|
|
25
25
|
});
|
|
26
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
|
+
}
|
|
27
35
|
function getParsedEnvFileContents(envPath) {
|
|
28
|
-
if (
|
|
29
|
-
console.log(
|
|
36
|
+
if (doesFileExist(envPath)) {
|
|
37
|
+
console.log("\u2705 Found and loading environment variables from: '".concat(envPath, "'"));
|
|
30
38
|
const envFileContents = fs.readFileSync(envPath, {
|
|
31
39
|
encoding: 'utf8'
|
|
32
40
|
});
|
|
33
41
|
const configuration = dotenv.parse(envFileContents);
|
|
34
42
|
return configuration;
|
|
35
43
|
} else {
|
|
36
|
-
console.log(
|
|
44
|
+
console.log("\u2139\uFE0F No environment variables at: '".concat(envPath, "'. If needed create it or duplicate the template file."));
|
|
37
45
|
return null;
|
|
38
46
|
}
|
|
39
47
|
}
|
|
@@ -41,27 +49,27 @@ async function loadConfig() {
|
|
|
41
49
|
try {
|
|
42
50
|
return await cypressEnvironmentsConfigExplorer.search();
|
|
43
51
|
} catch (e) {
|
|
44
|
-
throw new Error(
|
|
52
|
+
throw new Error("Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.");
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
async function getConfigurationForEnvironment(environmentName) {
|
|
48
|
-
var _context, _context2;
|
|
56
|
+
var _context, _context2, _context3;
|
|
49
57
|
// NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
|
|
50
58
|
// decrypted files are available on a developer's machine.
|
|
51
59
|
const ignoredGlobs = ['**/*.enc', '**/*.template'];
|
|
52
60
|
const ignoredCIGlobs = ['**/*.ci'];
|
|
53
61
|
const allIgnoredGlobs = isCI ? ignoredGlobs : _concatInstanceProperty(ignoredGlobs).call(ignoredGlobs, ignoredCIGlobs);
|
|
54
62
|
if (isCI) {
|
|
55
|
-
console.log(
|
|
63
|
+
console.log("\u2139\uFE0F 'CI' environment variable is defined. Assuming operating from a CI system.");
|
|
56
64
|
} else {
|
|
57
|
-
console.log(
|
|
65
|
+
console.log("\u2139\uFE0F 'CI' environment variable is not defined. Assuming you are running locally.");
|
|
58
66
|
}
|
|
59
|
-
console.log(
|
|
67
|
+
console.log("\u2139\uFE0F The ignored globs are: ".concat(allIgnoredGlobs.join(', '), "."));
|
|
60
68
|
const configResult = await loadConfig();
|
|
61
|
-
const allEnvironmentConfigs = configResult
|
|
69
|
+
const allEnvironmentConfigs = configResult === null || configResult === void 0 ? void 0 : configResult.config;
|
|
62
70
|
const configForEnvironment = _findInstanceProperty(_context = allEnvironmentConfigs.environments).call(_context, environment => environment.name === environmentName);
|
|
63
71
|
if (!configForEnvironment) {
|
|
64
|
-
throw new Error(
|
|
72
|
+
throw new Error("No configuration for ".concat(environmentName, " defined in cosmiconfig for 'cypress-environments'. Please make sure it exists."));
|
|
65
73
|
}
|
|
66
74
|
const secretsFiles = await glob(configForEnvironment.secrets.glob, {
|
|
67
75
|
ignore: allIgnoredGlobs
|
|
@@ -69,27 +77,27 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
69
77
|
const configFiles = await glob(configForEnvironment.config.glob, {
|
|
70
78
|
ignore: allIgnoredGlobs
|
|
71
79
|
});
|
|
72
|
-
console.log(
|
|
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."));
|
|
73
81
|
if (secretsFiles.length === 0 || configFiles.length === 0) {
|
|
74
|
-
console.log(
|
|
75
|
-
console.log(
|
|
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));
|
|
76
84
|
}
|
|
77
|
-
const mergedConfigurationAndSecrests = _reduceInstanceProperty(
|
|
85
|
+
const mergedConfigurationAndSecrests = _reduceInstanceProperty(_context3 = [...configFiles, ...secretsFiles]).call(_context3, (previousParsedEnvFileContents, nextEnvFilePath) => {
|
|
78
86
|
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
|
|
79
87
|
let matchingParsedEnvFileContentsForCIOrLocal = null;
|
|
80
88
|
if (!_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.local') && !_endsWithInstanceProperty(nextEnvFilePath).call(nextEnvFilePath, '.ci')) {
|
|
81
|
-
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(
|
|
89
|
+
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents("".concat(nextEnvFilePath, ".ci")) : getParsedEnvFileContents("".concat(nextEnvFilePath, ".local"));
|
|
82
90
|
}
|
|
83
91
|
return _objectSpread(_objectSpread(_objectSpread({}, previousParsedEnvFileContents), parsedEnvFileContents), matchingParsedEnvFileContentsForCIOrLocal);
|
|
84
92
|
}, {});
|
|
85
93
|
const rootDir = await pkgDir(__dirname);
|
|
86
94
|
let sharedEnvironmentConfiguration = null;
|
|
87
95
|
if (rootDir) {
|
|
88
|
-
const pathToSharedEnvironmentConfiguration = path.join(rootDir, 'config',
|
|
89
|
-
if (
|
|
96
|
+
const pathToSharedEnvironmentConfiguration = path.join(rootDir, 'config', ".env.".concat(environmentName, ".config"));
|
|
97
|
+
if (doesFileExist(pathToSharedEnvironmentConfiguration)) {
|
|
90
98
|
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
|
|
91
99
|
} else {
|
|
92
|
-
console.log(
|
|
100
|
+
console.log("\u2139\uFE0F No shared configuration for ".concat(environmentName, " defined."));
|
|
93
101
|
}
|
|
94
102
|
}
|
|
95
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.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Cypress package to setup environment configuration using dotenv files",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"@babel/runtime": "^7.21.0",
|
|
21
21
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
22
22
|
"cosmiconfig": "9.0.0",
|
|
23
|
-
"dotenv": "16.
|
|
24
|
-
"glob": "10.
|
|
23
|
+
"dotenv": "16.4.5",
|
|
24
|
+
"glob": "10.4.1",
|
|
25
25
|
"pkg-dir": "5.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@tsconfig/node20": "20.1.
|
|
28
|
+
"@tsconfig/node20": "20.1.4",
|
|
29
29
|
"@types/glob": "8.1.0",
|
|
30
|
-
"@types/node": "20.
|
|
30
|
+
"@types/node": "20.12.12",
|
|
31
31
|
"typescript": "5.2.2"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|