@commercetools-frontend/cypress-environments 0.0.0 → 0.0.1
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/config → config}/.env.ctp-aws-production-fra.config +2 -2
- package/config/.env.ctp-gcp-production-au.config +5 -0
- package/config/.env.ctp-gcp-production-eu.config +5 -0
- package/config/.env.ctp-gcp-production-us.config +5 -0
- package/{dist/config/.env.ctp-gcp-production-eu.config → config/.env.ctp-gcp-staging.config} +1 -1
- package/dist/commercetools-frontend-cypress-environments.cjs.d.ts +1 -0
- package/dist/commercetools-frontend-cypress-environments.cjs.dev.js +13 -16
- package/dist/commercetools-frontend-cypress-environments.cjs.prod.js +13 -16
- package/dist/commercetools-frontend-cypress-environments.esm.js +13 -15
- package/dist/declarations/src/environments.d.ts +3 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/package.json +8 -7
- package/dist/config/.env.ctp-gcp-production-au.config +0 -5
- package/dist/config/.env.ctp-gcp-production-us.config +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
API_URL=https://api.eu-central-1.aws.commercetools.com
|
|
2
|
-
MC_API_URL=https://mc-api.eu-central-1.aws.commercetools.com
|
|
3
1
|
MC_URL=https://mc-api.eu-central-1.aws.commercetools.com
|
|
2
|
+
MC_API_URL=https://mc-api.eu-central-1.aws.commercetools.com
|
|
3
|
+
API_URL=https://api.eu-central-1.aws.commercetools.com
|
|
4
4
|
AUTH_URL=https://auth.eu-central-1.aws.commercetools.com
|
package/{dist/config/.env.ctp-gcp-production-eu.config → config/.env.ctp-gcp-staging.config}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
API_URL=https://api.europe-west1.gcp.commercetools.com
|
|
2
1
|
MC_API_URL=https://mc-api.europe-west1.gcp.escemo.com
|
|
3
2
|
MC_URL=https://mc.europe-west1.gcp.escemo.com
|
|
3
|
+
API_URL=https://api.europe-west1.gcp.commercetools.com
|
|
4
4
|
AUTH_URL=https://auth.europe-west1.gcp.commercetools.com
|
|
5
5
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./declarations/src/index";
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var fs = require('fs');
|
|
7
|
-
var url = require('url');
|
|
8
7
|
var util = require('util');
|
|
9
8
|
var glob = require('glob');
|
|
10
9
|
var dotenv = require('dotenv');
|
|
@@ -14,16 +13,13 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
|
|
|
14
13
|
|
|
15
14
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
16
15
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
17
|
-
var url__default = /*#__PURE__*/_interopDefault(url);
|
|
18
16
|
var glob__default = /*#__PURE__*/_interopDefault(glob);
|
|
19
17
|
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
20
18
|
|
|
21
19
|
const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
|
|
22
|
-
const isCI = process.env.CI ===
|
|
20
|
+
const isCI = String(process.env.CI) === 'true';
|
|
23
21
|
const promisifiedGlob = util.promisify(glob__default["default"]);
|
|
24
22
|
|
|
25
|
-
const __dirname$1 = path__default["default"].dirname(url__default["default"].fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('dist/commercetools-frontend-cypress-environments.cjs.dev.js', document.baseURI).href))));
|
|
26
|
-
|
|
27
23
|
function getParsedEnvFileContents(envPath) {
|
|
28
24
|
if (fs__default["default"].existsSync(envPath)) {
|
|
29
25
|
console.log(`✅ Found and loading environment variables from: '${envPath}'`);
|
|
@@ -48,17 +44,18 @@ async function loadConfig() {
|
|
|
48
44
|
|
|
49
45
|
async function getConfigurationForEnvironment(environmentName) {
|
|
50
46
|
if (isCI) {
|
|
51
|
-
console.log(`ℹ️ 'CI' environment
|
|
47
|
+
console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
|
|
52
48
|
} else {
|
|
53
|
-
console.log(`ℹ️ 'CI' environment
|
|
49
|
+
console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
|
|
54
50
|
} // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
|
|
55
51
|
// decrypted files are available on a developer's machine.
|
|
56
52
|
|
|
57
53
|
|
|
58
|
-
const ignoredGlobs = ['**/*.enc', '**/*.template'
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
const ignoredGlobs = ['**/*.enc', '**/*.template'];
|
|
55
|
+
const ignoredCIGlobs = ['**/*.ci'];
|
|
56
|
+
const allIgnoredGlobs = isCI ? ignoredGlobs.concat(ignoredCIGlobs) : ignoredGlobs;
|
|
57
|
+
const configResult = await loadConfig();
|
|
58
|
+
const allEnvironmentConfigs = configResult?.config;
|
|
62
59
|
const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName);
|
|
63
60
|
|
|
64
61
|
if (!configForEnvironment) {
|
|
@@ -66,10 +63,10 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
66
63
|
}
|
|
67
64
|
|
|
68
65
|
const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, {
|
|
69
|
-
ignore:
|
|
66
|
+
ignore: allIgnoredGlobs
|
|
70
67
|
});
|
|
71
68
|
const configFiles = await promisifiedGlob(configForEnvironment.config.glob, {
|
|
72
|
-
ignore:
|
|
69
|
+
ignore: allIgnoredGlobs
|
|
73
70
|
});
|
|
74
71
|
console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
|
|
75
72
|
|
|
@@ -80,7 +77,7 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
80
77
|
|
|
81
78
|
const mergedConfigurationAndSecrests = [...configFiles, ...secretsFiles].reduce((previousParsedEnvFileContents, nextEnvFilePath) => {
|
|
82
79
|
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
|
|
83
|
-
let matchingParsedEnvFileContentsForCIOrLocal =
|
|
80
|
+
let matchingParsedEnvFileContentsForCIOrLocal = null;
|
|
84
81
|
|
|
85
82
|
if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) {
|
|
86
83
|
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
|
|
@@ -91,13 +88,13 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
91
88
|
...matchingParsedEnvFileContentsForCIOrLocal
|
|
92
89
|
};
|
|
93
90
|
}, {});
|
|
94
|
-
const pathToSharedEnvironmentConfiguration = path__default["default"].join(__dirname
|
|
91
|
+
const pathToSharedEnvironmentConfiguration = path__default["default"].join(__dirname, '..', 'config', `.env.${environmentName}.config`);
|
|
95
92
|
let sharedEnvironmentConfiguration = null;
|
|
96
93
|
|
|
97
94
|
if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
|
|
98
95
|
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
|
|
99
96
|
} else {
|
|
100
|
-
console.log(`ℹ️
|
|
97
|
+
console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
|
|
101
98
|
}
|
|
102
99
|
|
|
103
100
|
return { ...sharedEnvironmentConfiguration,
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var fs = require('fs');
|
|
7
|
-
var url = require('url');
|
|
8
7
|
var util = require('util');
|
|
9
8
|
var glob = require('glob');
|
|
10
9
|
var dotenv = require('dotenv');
|
|
@@ -14,16 +13,13 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
|
|
|
14
13
|
|
|
15
14
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
16
15
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
17
|
-
var url__default = /*#__PURE__*/_interopDefault(url);
|
|
18
16
|
var glob__default = /*#__PURE__*/_interopDefault(glob);
|
|
19
17
|
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
20
18
|
|
|
21
19
|
const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
|
|
22
|
-
const isCI = process.env.CI ===
|
|
20
|
+
const isCI = String(process.env.CI) === 'true';
|
|
23
21
|
const promisifiedGlob = util.promisify(glob__default["default"]);
|
|
24
22
|
|
|
25
|
-
const __dirname$1 = path__default["default"].dirname(url__default["default"].fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('dist/commercetools-frontend-cypress-environments.cjs.prod.js', document.baseURI).href))));
|
|
26
|
-
|
|
27
23
|
function getParsedEnvFileContents(envPath) {
|
|
28
24
|
if (fs__default["default"].existsSync(envPath)) {
|
|
29
25
|
console.log(`✅ Found and loading environment variables from: '${envPath}'`);
|
|
@@ -48,17 +44,18 @@ async function loadConfig() {
|
|
|
48
44
|
|
|
49
45
|
async function getConfigurationForEnvironment(environmentName) {
|
|
50
46
|
if (isCI) {
|
|
51
|
-
console.log(`ℹ️ 'CI' environment
|
|
47
|
+
console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
|
|
52
48
|
} else {
|
|
53
|
-
console.log(`ℹ️ 'CI' environment
|
|
49
|
+
console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
|
|
54
50
|
} // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
|
|
55
51
|
// decrypted files are available on a developer's machine.
|
|
56
52
|
|
|
57
53
|
|
|
58
|
-
const ignoredGlobs = ['**/*.enc', '**/*.template'
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
const ignoredGlobs = ['**/*.enc', '**/*.template'];
|
|
55
|
+
const ignoredCIGlobs = ['**/*.ci'];
|
|
56
|
+
const allIgnoredGlobs = isCI ? ignoredGlobs.concat(ignoredCIGlobs) : ignoredGlobs;
|
|
57
|
+
const configResult = await loadConfig();
|
|
58
|
+
const allEnvironmentConfigs = configResult?.config;
|
|
62
59
|
const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName);
|
|
63
60
|
|
|
64
61
|
if (!configForEnvironment) {
|
|
@@ -66,10 +63,10 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
66
63
|
}
|
|
67
64
|
|
|
68
65
|
const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, {
|
|
69
|
-
ignore:
|
|
66
|
+
ignore: allIgnoredGlobs
|
|
70
67
|
});
|
|
71
68
|
const configFiles = await promisifiedGlob(configForEnvironment.config.glob, {
|
|
72
|
-
ignore:
|
|
69
|
+
ignore: allIgnoredGlobs
|
|
73
70
|
});
|
|
74
71
|
console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
|
|
75
72
|
|
|
@@ -80,7 +77,7 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
80
77
|
|
|
81
78
|
const mergedConfigurationAndSecrests = [...configFiles, ...secretsFiles].reduce((previousParsedEnvFileContents, nextEnvFilePath) => {
|
|
82
79
|
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
|
|
83
|
-
let matchingParsedEnvFileContentsForCIOrLocal =
|
|
80
|
+
let matchingParsedEnvFileContentsForCIOrLocal = null;
|
|
84
81
|
|
|
85
82
|
if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) {
|
|
86
83
|
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
|
|
@@ -91,13 +88,13 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
91
88
|
...matchingParsedEnvFileContentsForCIOrLocal
|
|
92
89
|
};
|
|
93
90
|
}, {});
|
|
94
|
-
const pathToSharedEnvironmentConfiguration = path__default["default"].join(__dirname
|
|
91
|
+
const pathToSharedEnvironmentConfiguration = path__default["default"].join(__dirname, '..', 'config', `.env.${environmentName}.config`);
|
|
95
92
|
let sharedEnvironmentConfiguration = null;
|
|
96
93
|
|
|
97
94
|
if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
|
|
98
95
|
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
|
|
99
96
|
} else {
|
|
100
|
-
console.log(`ℹ️
|
|
97
|
+
console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
|
|
101
98
|
}
|
|
102
99
|
|
|
103
100
|
return { ...sharedEnvironmentConfiguration,
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import url from 'url';
|
|
4
3
|
import { promisify } from 'util';
|
|
5
4
|
import glob from 'glob';
|
|
6
5
|
import dotenv from 'dotenv';
|
|
7
6
|
import { cosmiconfig } from 'cosmiconfig';
|
|
8
7
|
|
|
9
8
|
const cypressEnvironmentsConfigExplorer = cosmiconfig('cypress-environments');
|
|
10
|
-
const isCI = process.env.CI ===
|
|
9
|
+
const isCI = String(process.env.CI) === 'true';
|
|
11
10
|
const promisifiedGlob = promisify(glob);
|
|
12
11
|
|
|
13
|
-
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
14
|
-
|
|
15
12
|
function getParsedEnvFileContents(envPath) {
|
|
16
13
|
if (fs.existsSync(envPath)) {
|
|
17
14
|
console.log(`✅ Found and loading environment variables from: '${envPath}'`);
|
|
@@ -36,17 +33,18 @@ async function loadConfig() {
|
|
|
36
33
|
|
|
37
34
|
async function getConfigurationForEnvironment(environmentName) {
|
|
38
35
|
if (isCI) {
|
|
39
|
-
console.log(`ℹ️ 'CI' environment
|
|
36
|
+
console.log(`ℹ️ 'CI' environment variable is defined. Assuming operating from a CI system.`);
|
|
40
37
|
} else {
|
|
41
|
-
console.log(`ℹ️ 'CI' environment
|
|
38
|
+
console.log(`ℹ️ 'CI' environment variable is not defined. Assuming you are running locally.`);
|
|
42
39
|
} // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
|
|
43
40
|
// decrypted files are available on a developer's machine.
|
|
44
41
|
|
|
45
42
|
|
|
46
|
-
const ignoredGlobs = ['**/*.enc', '**/*.template'
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
const ignoredGlobs = ['**/*.enc', '**/*.template'];
|
|
44
|
+
const ignoredCIGlobs = ['**/*.ci'];
|
|
45
|
+
const allIgnoredGlobs = isCI ? ignoredGlobs.concat(ignoredCIGlobs) : ignoredGlobs;
|
|
46
|
+
const configResult = await loadConfig();
|
|
47
|
+
const allEnvironmentConfigs = configResult?.config;
|
|
50
48
|
const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName);
|
|
51
49
|
|
|
52
50
|
if (!configForEnvironment) {
|
|
@@ -54,10 +52,10 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, {
|
|
57
|
-
ignore:
|
|
55
|
+
ignore: allIgnoredGlobs
|
|
58
56
|
});
|
|
59
57
|
const configFiles = await promisifiedGlob(configForEnvironment.config.glob, {
|
|
60
|
-
ignore:
|
|
58
|
+
ignore: allIgnoredGlobs
|
|
61
59
|
});
|
|
62
60
|
console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
|
|
63
61
|
|
|
@@ -68,7 +66,7 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
68
66
|
|
|
69
67
|
const mergedConfigurationAndSecrests = [...configFiles, ...secretsFiles].reduce((previousParsedEnvFileContents, nextEnvFilePath) => {
|
|
70
68
|
const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
|
|
71
|
-
let matchingParsedEnvFileContentsForCIOrLocal =
|
|
69
|
+
let matchingParsedEnvFileContentsForCIOrLocal = null;
|
|
72
70
|
|
|
73
71
|
if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) {
|
|
74
72
|
matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
|
|
@@ -79,13 +77,13 @@ async function getConfigurationForEnvironment(environmentName) {
|
|
|
79
77
|
...matchingParsedEnvFileContentsForCIOrLocal
|
|
80
78
|
};
|
|
81
79
|
}, {});
|
|
82
|
-
const pathToSharedEnvironmentConfiguration = path.join(__dirname, 'config', `.env.${environmentName}.config`);
|
|
80
|
+
const pathToSharedEnvironmentConfiguration = path.join(__dirname, '..', 'config', `.env.${environmentName}.config`);
|
|
83
81
|
let sharedEnvironmentConfiguration = null;
|
|
84
82
|
|
|
85
83
|
if (fs.existsSync(pathToSharedEnvironmentConfiguration)) {
|
|
86
84
|
sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
|
|
87
85
|
} else {
|
|
88
|
-
console.log(`ℹ️
|
|
86
|
+
console.log(`ℹ️ No shared configuration for ${environmentName} defined.`);
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
return { ...sharedEnvironmentConfiguration,
|
package/package.json
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/cypress-environments",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "Cypress package to setup environment configuration using dotenv files",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"
|
|
10
|
+
"typecheck": "tsc --noEmit"
|
|
11
11
|
},
|
|
12
12
|
"main": "dist/commercetools-frontend-cypress-environments.cjs.js",
|
|
13
13
|
"module": "dist/commercetools-frontend-cypress-environments.esm.js",
|
|
14
|
-
"preconstruct": {
|
|
15
|
-
"entrypoints": [
|
|
16
|
-
"./index.js"
|
|
17
|
-
]
|
|
18
|
-
},
|
|
19
14
|
"files": [
|
|
15
|
+
"config",
|
|
20
16
|
"dist",
|
|
21
17
|
"package.json",
|
|
22
18
|
"LICENSE",
|
|
@@ -27,6 +23,11 @@
|
|
|
27
23
|
"dotenv": "16.0.2",
|
|
28
24
|
"glob": "8.0.3"
|
|
29
25
|
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@babel/core": "7.19.1",
|
|
28
|
+
"@babel/preset-typescript": "7.18.6",
|
|
29
|
+
"typescript": "^4.8.2"
|
|
30
|
+
},
|
|
30
31
|
"engines": {
|
|
31
32
|
"node": ">=14",
|
|
32
33
|
"npm": ">=5"
|