@commercetools-frontend/cypress-environments 0.0.0 → 0.0.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,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
@@ -0,0 +1,5 @@
1
+ MC_URL=https://mc.australia-southeast1.gcp.commercetools.com
2
+ MC_API_URL=https://mc-api.australia-southeast1.gcp.commercetools.com
3
+ API_URL=https://api.australia-southeast1.gcp.commercetools.com
4
+ AUTH_URL=https://auth.australia-southeast1.gcp.commercetools.com
5
+
@@ -0,0 +1,5 @@
1
+ MC_URL=https://mc.europe-west1.gcp.commercetools.com
2
+ MC_API_URL=https://mc-api.europe-west1.gcp.commercetools.com
3
+ API_URL=https://api.europe-west1.gcp.commercetools.com
4
+ AUTH_URL=https://auth.europe-west1.gcp.commercetools.com
5
+
@@ -0,0 +1,5 @@
1
+ MC_URL=https://mc.us-central1.gcp.commercetools.com
2
+ MC_API_URL=https://mc-api.us-central1.gcp.commercetools.com
3
+ API_URL=https://api.us-central1.gcp.commercetools.com
4
+ AUTH_URL=https://auth.us-central1.gcp.commercetools.com
5
+
@@ -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,11 @@
1
+ // are you seeing an error that a default export doesn't exist but your source file has a default export?
2
+ // you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
3
+
4
+ // curious why you need to?
5
+ // this file exists so that you can import from the entrypoint normally
6
+ // except that it points to your source file and you don't need to run build constantly
7
+ // which means we need to re-export all of the modules from your source file
8
+ // and since export * doesn't include default exports, we need to read your source file
9
+ // to check for a default export and re-export it if it exists
10
+ // it's not ideal, but it works pretty well ¯\_(ツ)_/¯
11
+ export * from "../src/index";
@@ -1,7 +1,16 @@
1
- 'use strict';
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./commercetools-frontend-cypress-environments.cjs.prod.js");
5
- } else {
6
- module.exports = require("./commercetools-frontend-cypress-environments.cjs.dev.js");
7
- }
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../..", "..");
12
+
13
+ // this re-exports the source file
14
+ module.exports = require("../src/index.ts");
15
+
16
+ unregister();
package/package.json CHANGED
@@ -1,22 +1,18 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/cypress-environments",
3
- "version": "0.0.0",
3
+ "version": "0.0.2",
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
- "prepublish": "cp -R src/config dist/config"
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",
@@ -25,7 +21,11 @@
25
21
  "dependencies": {
26
22
  "cosmiconfig": "7.0.1",
27
23
  "dotenv": "16.0.2",
28
- "glob": "8.0.3"
24
+ "glob": "8.0.3",
25
+ "pkg-dir": "5.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "typescript": "^4.8.2"
29
29
  },
30
30
  "engines": {
31
31
  "node": ">=14",
@@ -1,108 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var path = require('path');
6
- var fs = require('fs');
7
- var url = require('url');
8
- var util = require('util');
9
- var glob = require('glob');
10
- var dotenv = require('dotenv');
11
- var cosmiconfig = require('cosmiconfig');
12
-
13
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
-
15
- var path__default = /*#__PURE__*/_interopDefault(path);
16
- var fs__default = /*#__PURE__*/_interopDefault(fs);
17
- var url__default = /*#__PURE__*/_interopDefault(url);
18
- var glob__default = /*#__PURE__*/_interopDefault(glob);
19
- var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
20
-
21
- const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
22
- const isCI = process.env.CI === true || process.env.CI === 'true';
23
- const promisifiedGlob = util.promisify(glob__default["default"]);
24
-
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
- function getParsedEnvFileContents(envPath) {
28
- if (fs__default["default"].existsSync(envPath)) {
29
- console.log(`✅ Found and loading environment variables from: '${envPath}'`);
30
- const envFileContents = fs__default["default"].readFileSync(envPath, {
31
- encoding: 'utf8'
32
- });
33
- const configuration = dotenv__default["default"].parse(envFileContents);
34
- return configuration;
35
- } else {
36
- console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
37
- return null;
38
- }
39
- }
40
-
41
- async function loadConfig() {
42
- try {
43
- return await cypressEnvironmentsConfigExplorer.search();
44
- } catch (e) {
45
- throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
46
- }
47
- }
48
-
49
- async function getConfigurationForEnvironment(environmentName) {
50
- if (isCI) {
51
- console.log(`ℹ️ 'CI' environment variables are defined. Assuming operating from a CI system.`);
52
- } else {
53
- console.log(`ℹ️ 'CI' environment variables are not defined. Assuming you are running locally.`);
54
- } // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
55
- // decrypted files are available on a developer's machine.
56
-
57
-
58
- const ignoredGlobs = ['**/*.enc', '**/*.template', !isCI && '**/*.ci'].filter(Boolean);
59
- const {
60
- config: allEnvironmentConfigs
61
- } = await loadConfig();
62
- const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName);
63
-
64
- if (!configForEnvironment) {
65
- throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
66
- }
67
-
68
- const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, {
69
- ignore: ignoredGlobs
70
- });
71
- const configFiles = await promisifiedGlob(configForEnvironment.config.glob, {
72
- ignore: ignoredGlobs
73
- });
74
- console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
75
-
76
- if (secretsFiles.length === 0 || configFiles.length === 0) {
77
- console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
78
- console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
79
- }
80
-
81
- const mergedConfigurationAndSecrests = [...configFiles, ...secretsFiles].reduce((previousParsedEnvFileContents, nextEnvFilePath) => {
82
- const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
83
- let matchingParsedEnvFileContentsForCIOrLocal = {};
84
-
85
- if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) {
86
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
87
- }
88
-
89
- return { ...previousParsedEnvFileContents,
90
- ...parsedEnvFileContents,
91
- ...matchingParsedEnvFileContentsForCIOrLocal
92
- };
93
- }, {});
94
- const pathToSharedEnvironmentConfiguration = path__default["default"].join(__dirname$1, 'config', `.env.${environmentName}.config`);
95
- let sharedEnvironmentConfiguration = null;
96
-
97
- if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
98
- sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
99
- } else {
100
- console.log(`ℹ️ Not shared configuration for ${environmentName} defined.`);
101
- }
102
-
103
- return { ...sharedEnvironmentConfiguration,
104
- ...mergedConfigurationAndSecrests
105
- };
106
- }
107
-
108
- exports.getConfigurationForEnvironment = getConfigurationForEnvironment;
@@ -1,108 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var path = require('path');
6
- var fs = require('fs');
7
- var url = require('url');
8
- var util = require('util');
9
- var glob = require('glob');
10
- var dotenv = require('dotenv');
11
- var cosmiconfig = require('cosmiconfig');
12
-
13
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
-
15
- var path__default = /*#__PURE__*/_interopDefault(path);
16
- var fs__default = /*#__PURE__*/_interopDefault(fs);
17
- var url__default = /*#__PURE__*/_interopDefault(url);
18
- var glob__default = /*#__PURE__*/_interopDefault(glob);
19
- var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
20
-
21
- const cypressEnvironmentsConfigExplorer = cosmiconfig.cosmiconfig('cypress-environments');
22
- const isCI = process.env.CI === true || process.env.CI === 'true';
23
- const promisifiedGlob = util.promisify(glob__default["default"]);
24
-
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
- function getParsedEnvFileContents(envPath) {
28
- if (fs__default["default"].existsSync(envPath)) {
29
- console.log(`✅ Found and loading environment variables from: '${envPath}'`);
30
- const envFileContents = fs__default["default"].readFileSync(envPath, {
31
- encoding: 'utf8'
32
- });
33
- const configuration = dotenv__default["default"].parse(envFileContents);
34
- return configuration;
35
- } else {
36
- console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
37
- return null;
38
- }
39
- }
40
-
41
- async function loadConfig() {
42
- try {
43
- return await cypressEnvironmentsConfigExplorer.search();
44
- } catch (e) {
45
- throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
46
- }
47
- }
48
-
49
- async function getConfigurationForEnvironment(environmentName) {
50
- if (isCI) {
51
- console.log(`ℹ️ 'CI' environment variables are defined. Assuming operating from a CI system.`);
52
- } else {
53
- console.log(`ℹ️ 'CI' environment variables are not defined. Assuming you are running locally.`);
54
- } // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
55
- // decrypted files are available on a developer's machine.
56
-
57
-
58
- const ignoredGlobs = ['**/*.enc', '**/*.template', !isCI && '**/*.ci'].filter(Boolean);
59
- const {
60
- config: allEnvironmentConfigs
61
- } = await loadConfig();
62
- const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName);
63
-
64
- if (!configForEnvironment) {
65
- throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
66
- }
67
-
68
- const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, {
69
- ignore: ignoredGlobs
70
- });
71
- const configFiles = await promisifiedGlob(configForEnvironment.config.glob, {
72
- ignore: ignoredGlobs
73
- });
74
- console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
75
-
76
- if (secretsFiles.length === 0 || configFiles.length === 0) {
77
- console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
78
- console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
79
- }
80
-
81
- const mergedConfigurationAndSecrests = [...configFiles, ...secretsFiles].reduce((previousParsedEnvFileContents, nextEnvFilePath) => {
82
- const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
83
- let matchingParsedEnvFileContentsForCIOrLocal = {};
84
-
85
- if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) {
86
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
87
- }
88
-
89
- return { ...previousParsedEnvFileContents,
90
- ...parsedEnvFileContents,
91
- ...matchingParsedEnvFileContentsForCIOrLocal
92
- };
93
- }, {});
94
- const pathToSharedEnvironmentConfiguration = path__default["default"].join(__dirname$1, 'config', `.env.${environmentName}.config`);
95
- let sharedEnvironmentConfiguration = null;
96
-
97
- if (fs__default["default"].existsSync(pathToSharedEnvironmentConfiguration)) {
98
- sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
99
- } else {
100
- console.log(`ℹ️ Not shared configuration for ${environmentName} defined.`);
101
- }
102
-
103
- return { ...sharedEnvironmentConfiguration,
104
- ...mergedConfigurationAndSecrests
105
- };
106
- }
107
-
108
- exports.getConfigurationForEnvironment = getConfigurationForEnvironment;
@@ -1,96 +0,0 @@
1
- import path from 'path';
2
- import fs from 'fs';
3
- import url from 'url';
4
- import { promisify } from 'util';
5
- import glob from 'glob';
6
- import dotenv from 'dotenv';
7
- import { cosmiconfig } from 'cosmiconfig';
8
-
9
- const cypressEnvironmentsConfigExplorer = cosmiconfig('cypress-environments');
10
- const isCI = process.env.CI === true || process.env.CI === 'true';
11
- const promisifiedGlob = promisify(glob);
12
-
13
- const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
14
-
15
- function getParsedEnvFileContents(envPath) {
16
- if (fs.existsSync(envPath)) {
17
- console.log(`✅ Found and loading environment variables from: '${envPath}'`);
18
- const envFileContents = fs.readFileSync(envPath, {
19
- encoding: 'utf8'
20
- });
21
- const configuration = dotenv.parse(envFileContents);
22
- return configuration;
23
- } else {
24
- console.log(`ℹ️ No environment variables at: '${envPath}'. If needed create it or duplicate the template file.`);
25
- return null;
26
- }
27
- }
28
-
29
- async function loadConfig() {
30
- try {
31
- return await cypressEnvironmentsConfigExplorer.search();
32
- } catch (e) {
33
- throw new Error(`Failed loading a Cypress environments configuration. Create a cosmiconfig for 'cypress-environments' for example 'cypress-environments.config.cjs'.`);
34
- }
35
- }
36
-
37
- async function getConfigurationForEnvironment(environmentName) {
38
- if (isCI) {
39
- console.log(`ℹ️ 'CI' environment variables are defined. Assuming operating from a CI system.`);
40
- } else {
41
- console.log(`ℹ️ 'CI' environment variables are not defined. Assuming you are running locally.`);
42
- } // NOTE: On CI the *.ci secrests are not excluded. Locally the are in case
43
- // decrypted files are available on a developer's machine.
44
-
45
-
46
- const ignoredGlobs = ['**/*.enc', '**/*.template', !isCI && '**/*.ci'].filter(Boolean);
47
- const {
48
- config: allEnvironmentConfigs
49
- } = await loadConfig();
50
- const configForEnvironment = allEnvironmentConfigs.environments.find(environment => environment.name === environmentName);
51
-
52
- if (!configForEnvironment) {
53
- throw new Error(`No configuration for ${environmentName} defined in cosmiconfig for 'cypress-environments'. Please make sure it exists.`);
54
- }
55
-
56
- const secretsFiles = await promisifiedGlob(configForEnvironment.secrets.glob, {
57
- ignore: ignoredGlobs
58
- });
59
- const configFiles = await promisifiedGlob(configForEnvironment.config.glob, {
60
- ignore: ignoredGlobs
61
- });
62
- console.log(`ℹ️ Found ${secretsFiles.length} secret file(s) and ${configFiles.length} config file(s) matching the defined globs.`);
63
-
64
- if (secretsFiles.length === 0 || configFiles.length === 0) {
65
- console.log(`ℹ️ Secrets files glob is: ${configForEnvironment.secrets.glob}`);
66
- console.log(`ℹ️ Config files glob is: ${configForEnvironment.config.glob}`);
67
- }
68
-
69
- const mergedConfigurationAndSecrests = [...configFiles, ...secretsFiles].reduce((previousParsedEnvFileContents, nextEnvFilePath) => {
70
- const parsedEnvFileContents = getParsedEnvFileContents(nextEnvFilePath);
71
- let matchingParsedEnvFileContentsForCIOrLocal = {};
72
-
73
- if (!nextEnvFilePath.endsWith('.local') && !nextEnvFilePath.endsWith('.ci')) {
74
- matchingParsedEnvFileContentsForCIOrLocal = isCI ? getParsedEnvFileContents(`${nextEnvFilePath}.ci`) : getParsedEnvFileContents(`${nextEnvFilePath}.local`);
75
- }
76
-
77
- return { ...previousParsedEnvFileContents,
78
- ...parsedEnvFileContents,
79
- ...matchingParsedEnvFileContentsForCIOrLocal
80
- };
81
- }, {});
82
- const pathToSharedEnvironmentConfiguration = path.join(__dirname, 'config', `.env.${environmentName}.config`);
83
- let sharedEnvironmentConfiguration = null;
84
-
85
- if (fs.existsSync(pathToSharedEnvironmentConfiguration)) {
86
- sharedEnvironmentConfiguration = getParsedEnvFileContents(pathToSharedEnvironmentConfiguration);
87
- } else {
88
- console.log(`ℹ️ Not shared configuration for ${environmentName} defined.`);
89
- }
90
-
91
- return { ...sharedEnvironmentConfiguration,
92
- ...mergedConfigurationAndSecrests
93
- };
94
- }
95
-
96
- export { getConfigurationForEnvironment };
@@ -1,5 +0,0 @@
1
- API_URL=https://api.australia-southeast1.gcp.commercetools.com
2
- MC_API_URL=https://mc-api.australia-southeast1.gcp.escemo.com
3
- MC_URL=https://mc.australia-southeast1.gcp.escemo.com
4
- AUTH_URL=https://auth.australia-southeast1.gcp.commercetools.com
5
-
@@ -1,5 +0,0 @@
1
- API_URL=https://api.us-central1.gcp.commercetools.com
2
- MC_API_URL=https://mc-api.us-central1.gcp.escemo.com
3
- MC_URL=https://mc.us-central1.gcp.escemo.com
4
- AUTH_URL=https://auth.us-central1.gcp.commercetools.com
5
-