@commercetools-frontend/cypress 21.23.9 → 21.24.0
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/add-commands/dist/commercetools-frontend-cypress-add-commands.cjs.dev.js +23 -22
- package/add-commands/dist/commercetools-frontend-cypress-add-commands.cjs.prod.js +23 -22
- package/add-commands/dist/commercetools-frontend-cypress-add-commands.esm.js +23 -22
- package/dist/commercetools-frontend-cypress.cjs.dev.js +2 -2
- package/dist/commercetools-frontend-cypress.cjs.prod.js +2 -2
- package/dist/commercetools-frontend-cypress.esm.js +2 -2
- package/dist/{constants-0e882d21.esm.js → constants-18b165fc.esm.js} +2 -2
- package/dist/{constants-42a0ebf5.cjs.dev.js → constants-8ad2a50e.cjs.prod.js} +2 -2
- package/dist/{constants-4d9d4b7b.cjs.prod.js → constants-c657705e.cjs.dev.js} +2 -2
- package/package.json +3 -3
- package/task/dist/commercetools-frontend-cypress-task.cjs.dev.js +52 -105
- package/task/dist/commercetools-frontend-cypress-task.cjs.prod.js +52 -105
- package/task/dist/commercetools-frontend-cypress-task.esm.js +52 -104
|
@@ -12,10 +12,10 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
12
12
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
13
13
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
14
14
|
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
15
|
-
var uuid = require('uuid');
|
|
16
15
|
var semver = require('semver');
|
|
16
|
+
var uuid = require('uuid');
|
|
17
17
|
var ssr = require('@commercetools-frontend/application-shell/ssr');
|
|
18
|
-
var constants = require('../../dist/constants-
|
|
18
|
+
var constants = require('../../dist/constants-c657705e.cjs.dev.js');
|
|
19
19
|
|
|
20
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
21
21
|
|
|
@@ -47,17 +47,17 @@ function loginByForm(commandOptions) {
|
|
|
47
47
|
throw new Error("At the moment, the \"loginByForm\" command only works when testing a Merchant Center production URL. Using form login in an application running on localhost is not supported due to issues with \"cy.origin\".");
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
const projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
|
|
51
51
|
cy.task('customApplicationConfig', {
|
|
52
52
|
entryPointUriPath: commandOptions.entryPointUriPath,
|
|
53
53
|
dotfiles: commandOptions.dotfiles
|
|
54
54
|
}, // Do not show log, as it may contain sensible information.
|
|
55
55
|
{
|
|
56
56
|
log: false
|
|
57
|
-
}).then(
|
|
57
|
+
}).then(appConfig => {
|
|
58
58
|
var _context, _commandOptions$login;
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
let url = _concatInstanceProperty__default["default"](_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
|
|
61
61
|
|
|
62
62
|
if (commandOptions.entryPointUriPath === 'account') {
|
|
63
63
|
url = "/".concat(commandOptions.entryPointUriPath);
|
|
@@ -69,11 +69,11 @@ function loginByForm(commandOptions) {
|
|
|
69
69
|
name: 'customApplicationConfig',
|
|
70
70
|
message: appConfig
|
|
71
71
|
});
|
|
72
|
-
|
|
72
|
+
const userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
|
|
73
73
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
74
74
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
75
75
|
};
|
|
76
|
-
|
|
76
|
+
const sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath]; // const mcUrl = new URL(appConfig.mcApiUrl);
|
|
77
77
|
// const mcFrontendHostname = mcUrl.hostname.replace('mc-api', 'mc');
|
|
78
78
|
|
|
79
79
|
function authCallback() {
|
|
@@ -117,8 +117,8 @@ function loginByOidc(commandOptions) {
|
|
|
117
117
|
throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
const sessionNonce = uuid.v4();
|
|
121
|
+
let projectKey = undefined;
|
|
122
122
|
|
|
123
123
|
if (commandOptions.entryPointUriPath !== 'account') {
|
|
124
124
|
var _commandOptions$proje2;
|
|
@@ -132,7 +132,7 @@ function loginByOidc(commandOptions) {
|
|
|
132
132
|
}, // Do not show log, as it may contain sensible information.
|
|
133
133
|
{
|
|
134
134
|
log: false
|
|
135
|
-
}).then(
|
|
135
|
+
}).then(appConfig => {
|
|
136
136
|
var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _appConfig$__DEVELOPM5, _appConfig$__DEVELOPM6, _commandOptions$login2;
|
|
137
137
|
|
|
138
138
|
// Log loaded application config for debugging purposes.
|
|
@@ -141,20 +141,20 @@ function loginByOidc(commandOptions) {
|
|
|
141
141
|
name: 'customApplicationConfig',
|
|
142
142
|
message: appConfig
|
|
143
143
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
projectKey
|
|
144
|
+
const applicationId = appConfig.applicationId;
|
|
145
|
+
const sessionScope = ssr.buildOidcScope({
|
|
146
|
+
projectKey,
|
|
147
147
|
oAuthScopes: (_appConfig$__DEVELOPM = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM === void 0 ? void 0 : (_appConfig$__DEVELOPM2 = _appConfig$__DEVELOPM.oidc) === null || _appConfig$__DEVELOPM2 === void 0 ? void 0 : _appConfig$__DEVELOPM2.oAuthScopes,
|
|
148
148
|
additionalOAuthScopes: (_appConfig$__DEVELOPM3 = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM3 === void 0 ? void 0 : (_appConfig$__DEVELOPM4 = _appConfig$__DEVELOPM3.oidc) === null || _appConfig$__DEVELOPM4 === void 0 ? void 0 : _appConfig$__DEVELOPM4.additionalOAuthScopes,
|
|
149
149
|
teamId: (_appConfig$__DEVELOPM5 = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM5 === void 0 ? void 0 : (_appConfig$__DEVELOPM6 = _appConfig$__DEVELOPM5.oidc) === null || _appConfig$__DEVELOPM6 === void 0 ? void 0 : _appConfig$__DEVELOPM6.teamId
|
|
150
150
|
});
|
|
151
|
-
|
|
151
|
+
const userCredentials = (_commandOptions$login2 = commandOptions.login) !== null && _commandOptions$login2 !== void 0 ? _commandOptions$login2 : {
|
|
152
152
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
153
153
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
154
154
|
}; // Perform the login using the API, then store some required values into the browser storage
|
|
155
155
|
// and redirect to the auth callback route.
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
const requestOptions = {
|
|
158
158
|
method: 'POST',
|
|
159
159
|
url: "".concat(appConfig.mcApiUrl, "/tokens"),
|
|
160
160
|
body: _objectSpread(_objectSpread({}, userCredentials), {}, {
|
|
@@ -166,12 +166,12 @@ function loginByOidc(commandOptions) {
|
|
|
166
166
|
}),
|
|
167
167
|
followRedirect: false
|
|
168
168
|
};
|
|
169
|
-
cy.request(requestOptions).then(
|
|
170
|
-
|
|
169
|
+
cy.request(requestOptions).then(res => {
|
|
170
|
+
const sessionKey = ['loginByOidc', userCredentials.email, commandOptions.entryPointUriPath];
|
|
171
171
|
|
|
172
172
|
function authCallback() {
|
|
173
173
|
cy.visit(res.body.redirectTo, {
|
|
174
|
-
onBeforeLoad
|
|
174
|
+
onBeforeLoad(win) {
|
|
175
175
|
var _context3;
|
|
176
176
|
|
|
177
177
|
if (projectKey) {
|
|
@@ -179,7 +179,7 @@ function loginByOidc(commandOptions) {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
win.sessionStorage.setItem(_concatInstanceProperty__default["default"](_context3 = "".concat(constants.STORAGE_KEYS.NONCE, "_")).call(_context3, sessionNonce), _JSON$stringify__default["default"]({
|
|
182
|
-
applicationId
|
|
182
|
+
applicationId,
|
|
183
183
|
query: {}
|
|
184
184
|
}));
|
|
185
185
|
win.sessionStorage.setItem(constants.STORAGE_KEYS.SESSION_SCOPE, sessionScope);
|
|
@@ -188,6 +188,7 @@ function loginByOidc(commandOptions) {
|
|
|
188
188
|
commandOptions.onBeforeLoad(win);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
+
|
|
191
192
|
}); // Wait for the application to be loaded so that the session can be saved.
|
|
192
193
|
|
|
193
194
|
cy.get('#app-loader').should('not.exist');
|
|
@@ -225,11 +226,11 @@ function fillLoginForm(userCredentials) {
|
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
function isLocalhost() {
|
|
228
|
-
|
|
229
|
+
const baseUrl = new _URL__default["default"](Cypress.config('baseUrl'));
|
|
229
230
|
return baseUrl.hostname === 'localhost';
|
|
230
231
|
}
|
|
231
232
|
|
|
232
|
-
Cypress.Commands.add('loginToMerchantCenter',
|
|
233
|
+
Cypress.Commands.add('loginToMerchantCenter', commandOptions => {
|
|
233
234
|
Cypress.log({
|
|
234
235
|
name: 'loginToMerchantCenter'
|
|
235
236
|
});
|
|
@@ -240,7 +241,7 @@ Cypress.Commands.add('loginToMerchantCenter', function (commandOptions) {
|
|
|
240
241
|
loginByForm(commandOptions);
|
|
241
242
|
}
|
|
242
243
|
});
|
|
243
|
-
Cypress.Commands.add('loginByOidc',
|
|
244
|
+
Cypress.Commands.add('loginByOidc', commandOptions => {
|
|
244
245
|
Cypress.log({
|
|
245
246
|
name: 'loginByOidc'
|
|
246
247
|
});
|
|
@@ -12,10 +12,10 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
12
12
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
13
13
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
14
14
|
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
15
|
-
var uuid = require('uuid');
|
|
16
15
|
var semver = require('semver');
|
|
16
|
+
var uuid = require('uuid');
|
|
17
17
|
var ssr = require('@commercetools-frontend/application-shell/ssr');
|
|
18
|
-
var constants = require('../../dist/constants-
|
|
18
|
+
var constants = require('../../dist/constants-8ad2a50e.cjs.prod.js');
|
|
19
19
|
|
|
20
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
21
21
|
|
|
@@ -47,17 +47,17 @@ function loginByForm(commandOptions) {
|
|
|
47
47
|
throw new Error("At the moment, the \"loginByForm\" command only works when testing a Merchant Center production URL. Using form login in an application running on localhost is not supported due to issues with \"cy.origin\".");
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
const projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
|
|
51
51
|
cy.task('customApplicationConfig', {
|
|
52
52
|
entryPointUriPath: commandOptions.entryPointUriPath,
|
|
53
53
|
dotfiles: commandOptions.dotfiles
|
|
54
54
|
}, // Do not show log, as it may contain sensible information.
|
|
55
55
|
{
|
|
56
56
|
log: false
|
|
57
|
-
}).then(
|
|
57
|
+
}).then(appConfig => {
|
|
58
58
|
var _context, _commandOptions$login;
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
let url = _concatInstanceProperty__default["default"](_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
|
|
61
61
|
|
|
62
62
|
if (commandOptions.entryPointUriPath === 'account') {
|
|
63
63
|
url = "/".concat(commandOptions.entryPointUriPath);
|
|
@@ -69,11 +69,11 @@ function loginByForm(commandOptions) {
|
|
|
69
69
|
name: 'customApplicationConfig',
|
|
70
70
|
message: appConfig
|
|
71
71
|
});
|
|
72
|
-
|
|
72
|
+
const userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
|
|
73
73
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
74
74
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
75
75
|
};
|
|
76
|
-
|
|
76
|
+
const sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath]; // const mcUrl = new URL(appConfig.mcApiUrl);
|
|
77
77
|
// const mcFrontendHostname = mcUrl.hostname.replace('mc-api', 'mc');
|
|
78
78
|
|
|
79
79
|
function authCallback() {
|
|
@@ -117,8 +117,8 @@ function loginByOidc(commandOptions) {
|
|
|
117
117
|
throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
const sessionNonce = uuid.v4();
|
|
121
|
+
let projectKey = undefined;
|
|
122
122
|
|
|
123
123
|
if (commandOptions.entryPointUriPath !== 'account') {
|
|
124
124
|
var _commandOptions$proje2;
|
|
@@ -132,7 +132,7 @@ function loginByOidc(commandOptions) {
|
|
|
132
132
|
}, // Do not show log, as it may contain sensible information.
|
|
133
133
|
{
|
|
134
134
|
log: false
|
|
135
|
-
}).then(
|
|
135
|
+
}).then(appConfig => {
|
|
136
136
|
var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _appConfig$__DEVELOPM5, _appConfig$__DEVELOPM6, _commandOptions$login2;
|
|
137
137
|
|
|
138
138
|
// Log loaded application config for debugging purposes.
|
|
@@ -141,20 +141,20 @@ function loginByOidc(commandOptions) {
|
|
|
141
141
|
name: 'customApplicationConfig',
|
|
142
142
|
message: appConfig
|
|
143
143
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
projectKey
|
|
144
|
+
const applicationId = appConfig.applicationId;
|
|
145
|
+
const sessionScope = ssr.buildOidcScope({
|
|
146
|
+
projectKey,
|
|
147
147
|
oAuthScopes: (_appConfig$__DEVELOPM = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM === void 0 ? void 0 : (_appConfig$__DEVELOPM2 = _appConfig$__DEVELOPM.oidc) === null || _appConfig$__DEVELOPM2 === void 0 ? void 0 : _appConfig$__DEVELOPM2.oAuthScopes,
|
|
148
148
|
additionalOAuthScopes: (_appConfig$__DEVELOPM3 = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM3 === void 0 ? void 0 : (_appConfig$__DEVELOPM4 = _appConfig$__DEVELOPM3.oidc) === null || _appConfig$__DEVELOPM4 === void 0 ? void 0 : _appConfig$__DEVELOPM4.additionalOAuthScopes,
|
|
149
149
|
teamId: (_appConfig$__DEVELOPM5 = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM5 === void 0 ? void 0 : (_appConfig$__DEVELOPM6 = _appConfig$__DEVELOPM5.oidc) === null || _appConfig$__DEVELOPM6 === void 0 ? void 0 : _appConfig$__DEVELOPM6.teamId
|
|
150
150
|
});
|
|
151
|
-
|
|
151
|
+
const userCredentials = (_commandOptions$login2 = commandOptions.login) !== null && _commandOptions$login2 !== void 0 ? _commandOptions$login2 : {
|
|
152
152
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
153
153
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
154
154
|
}; // Perform the login using the API, then store some required values into the browser storage
|
|
155
155
|
// and redirect to the auth callback route.
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
const requestOptions = {
|
|
158
158
|
method: 'POST',
|
|
159
159
|
url: "".concat(appConfig.mcApiUrl, "/tokens"),
|
|
160
160
|
body: _objectSpread(_objectSpread({}, userCredentials), {}, {
|
|
@@ -166,12 +166,12 @@ function loginByOidc(commandOptions) {
|
|
|
166
166
|
}),
|
|
167
167
|
followRedirect: false
|
|
168
168
|
};
|
|
169
|
-
cy.request(requestOptions).then(
|
|
170
|
-
|
|
169
|
+
cy.request(requestOptions).then(res => {
|
|
170
|
+
const sessionKey = ['loginByOidc', userCredentials.email, commandOptions.entryPointUriPath];
|
|
171
171
|
|
|
172
172
|
function authCallback() {
|
|
173
173
|
cy.visit(res.body.redirectTo, {
|
|
174
|
-
onBeforeLoad
|
|
174
|
+
onBeforeLoad(win) {
|
|
175
175
|
var _context3;
|
|
176
176
|
|
|
177
177
|
if (projectKey) {
|
|
@@ -179,7 +179,7 @@ function loginByOidc(commandOptions) {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
win.sessionStorage.setItem(_concatInstanceProperty__default["default"](_context3 = "".concat(constants.STORAGE_KEYS.NONCE, "_")).call(_context3, sessionNonce), _JSON$stringify__default["default"]({
|
|
182
|
-
applicationId
|
|
182
|
+
applicationId,
|
|
183
183
|
query: {}
|
|
184
184
|
}));
|
|
185
185
|
win.sessionStorage.setItem(constants.STORAGE_KEYS.SESSION_SCOPE, sessionScope);
|
|
@@ -188,6 +188,7 @@ function loginByOidc(commandOptions) {
|
|
|
188
188
|
commandOptions.onBeforeLoad(win);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
+
|
|
191
192
|
}); // Wait for the application to be loaded so that the session can be saved.
|
|
192
193
|
|
|
193
194
|
cy.get('#app-loader').should('not.exist');
|
|
@@ -225,11 +226,11 @@ function fillLoginForm(userCredentials) {
|
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
function isLocalhost() {
|
|
228
|
-
|
|
229
|
+
const baseUrl = new _URL__default["default"](Cypress.config('baseUrl'));
|
|
229
230
|
return baseUrl.hostname === 'localhost';
|
|
230
231
|
}
|
|
231
232
|
|
|
232
|
-
Cypress.Commands.add('loginToMerchantCenter',
|
|
233
|
+
Cypress.Commands.add('loginToMerchantCenter', commandOptions => {
|
|
233
234
|
Cypress.log({
|
|
234
235
|
name: 'loginToMerchantCenter'
|
|
235
236
|
});
|
|
@@ -240,7 +241,7 @@ Cypress.Commands.add('loginToMerchantCenter', function (commandOptions) {
|
|
|
240
241
|
loginByForm(commandOptions);
|
|
241
242
|
}
|
|
242
243
|
});
|
|
243
|
-
Cypress.Commands.add('loginByOidc',
|
|
244
|
+
Cypress.Commands.add('loginByOidc', commandOptions => {
|
|
244
245
|
Cypress.log({
|
|
245
246
|
name: 'loginByOidc'
|
|
246
247
|
});
|
|
@@ -10,10 +10,10 @@ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
|
10
10
|
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
11
11
|
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
12
12
|
import _URL from '@babel/runtime-corejs3/core-js-stable/url';
|
|
13
|
-
import { v4 } from 'uuid';
|
|
14
13
|
import semver from 'semver';
|
|
14
|
+
import { v4 } from 'uuid';
|
|
15
15
|
import { buildOidcScope } from '@commercetools-frontend/application-shell/ssr';
|
|
16
|
-
import { O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS } from '../../dist/constants-
|
|
16
|
+
import { O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS } from '../../dist/constants-18b165fc.esm.js';
|
|
17
17
|
|
|
18
18
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
19
|
|
|
@@ -30,17 +30,17 @@ function loginByForm(commandOptions) {
|
|
|
30
30
|
throw new Error("At the moment, the \"loginByForm\" command only works when testing a Merchant Center production URL. Using form login in an application running on localhost is not supported due to issues with \"cy.origin\".");
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
|
|
34
34
|
cy.task('customApplicationConfig', {
|
|
35
35
|
entryPointUriPath: commandOptions.entryPointUriPath,
|
|
36
36
|
dotfiles: commandOptions.dotfiles
|
|
37
37
|
}, // Do not show log, as it may contain sensible information.
|
|
38
38
|
{
|
|
39
39
|
log: false
|
|
40
|
-
}).then(
|
|
40
|
+
}).then(appConfig => {
|
|
41
41
|
var _context, _commandOptions$login;
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
let url = _concatInstanceProperty(_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
|
|
44
44
|
|
|
45
45
|
if (commandOptions.entryPointUriPath === 'account') {
|
|
46
46
|
url = "/".concat(commandOptions.entryPointUriPath);
|
|
@@ -52,11 +52,11 @@ function loginByForm(commandOptions) {
|
|
|
52
52
|
name: 'customApplicationConfig',
|
|
53
53
|
message: appConfig
|
|
54
54
|
});
|
|
55
|
-
|
|
55
|
+
const userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
|
|
56
56
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
57
57
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
58
58
|
};
|
|
59
|
-
|
|
59
|
+
const sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath]; // const mcUrl = new URL(appConfig.mcApiUrl);
|
|
60
60
|
// const mcFrontendHostname = mcUrl.hostname.replace('mc-api', 'mc');
|
|
61
61
|
|
|
62
62
|
function authCallback() {
|
|
@@ -100,8 +100,8 @@ function loginByOidc(commandOptions) {
|
|
|
100
100
|
throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
const sessionNonce = v4();
|
|
104
|
+
let projectKey = undefined;
|
|
105
105
|
|
|
106
106
|
if (commandOptions.entryPointUriPath !== 'account') {
|
|
107
107
|
var _commandOptions$proje2;
|
|
@@ -115,7 +115,7 @@ function loginByOidc(commandOptions) {
|
|
|
115
115
|
}, // Do not show log, as it may contain sensible information.
|
|
116
116
|
{
|
|
117
117
|
log: false
|
|
118
|
-
}).then(
|
|
118
|
+
}).then(appConfig => {
|
|
119
119
|
var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _appConfig$__DEVELOPM5, _appConfig$__DEVELOPM6, _commandOptions$login2;
|
|
120
120
|
|
|
121
121
|
// Log loaded application config for debugging purposes.
|
|
@@ -124,20 +124,20 @@ function loginByOidc(commandOptions) {
|
|
|
124
124
|
name: 'customApplicationConfig',
|
|
125
125
|
message: appConfig
|
|
126
126
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
projectKey
|
|
127
|
+
const applicationId = appConfig.applicationId;
|
|
128
|
+
const sessionScope = buildOidcScope({
|
|
129
|
+
projectKey,
|
|
130
130
|
oAuthScopes: (_appConfig$__DEVELOPM = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM === void 0 ? void 0 : (_appConfig$__DEVELOPM2 = _appConfig$__DEVELOPM.oidc) === null || _appConfig$__DEVELOPM2 === void 0 ? void 0 : _appConfig$__DEVELOPM2.oAuthScopes,
|
|
131
131
|
additionalOAuthScopes: (_appConfig$__DEVELOPM3 = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM3 === void 0 ? void 0 : (_appConfig$__DEVELOPM4 = _appConfig$__DEVELOPM3.oidc) === null || _appConfig$__DEVELOPM4 === void 0 ? void 0 : _appConfig$__DEVELOPM4.additionalOAuthScopes,
|
|
132
132
|
teamId: (_appConfig$__DEVELOPM5 = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM5 === void 0 ? void 0 : (_appConfig$__DEVELOPM6 = _appConfig$__DEVELOPM5.oidc) === null || _appConfig$__DEVELOPM6 === void 0 ? void 0 : _appConfig$__DEVELOPM6.teamId
|
|
133
133
|
});
|
|
134
|
-
|
|
134
|
+
const userCredentials = (_commandOptions$login2 = commandOptions.login) !== null && _commandOptions$login2 !== void 0 ? _commandOptions$login2 : {
|
|
135
135
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
136
136
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
137
137
|
}; // Perform the login using the API, then store some required values into the browser storage
|
|
138
138
|
// and redirect to the auth callback route.
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
const requestOptions = {
|
|
141
141
|
method: 'POST',
|
|
142
142
|
url: "".concat(appConfig.mcApiUrl, "/tokens"),
|
|
143
143
|
body: _objectSpread(_objectSpread({}, userCredentials), {}, {
|
|
@@ -149,12 +149,12 @@ function loginByOidc(commandOptions) {
|
|
|
149
149
|
}),
|
|
150
150
|
followRedirect: false
|
|
151
151
|
};
|
|
152
|
-
cy.request(requestOptions).then(
|
|
153
|
-
|
|
152
|
+
cy.request(requestOptions).then(res => {
|
|
153
|
+
const sessionKey = ['loginByOidc', userCredentials.email, commandOptions.entryPointUriPath];
|
|
154
154
|
|
|
155
155
|
function authCallback() {
|
|
156
156
|
cy.visit(res.body.redirectTo, {
|
|
157
|
-
onBeforeLoad
|
|
157
|
+
onBeforeLoad(win) {
|
|
158
158
|
var _context3;
|
|
159
159
|
|
|
160
160
|
if (projectKey) {
|
|
@@ -162,7 +162,7 @@ function loginByOidc(commandOptions) {
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
win.sessionStorage.setItem(_concatInstanceProperty(_context3 = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context3, sessionNonce), _JSON$stringify({
|
|
165
|
-
applicationId
|
|
165
|
+
applicationId,
|
|
166
166
|
query: {}
|
|
167
167
|
}));
|
|
168
168
|
win.sessionStorage.setItem(STORAGE_KEYS.SESSION_SCOPE, sessionScope);
|
|
@@ -171,6 +171,7 @@ function loginByOidc(commandOptions) {
|
|
|
171
171
|
commandOptions.onBeforeLoad(win);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
+
|
|
174
175
|
}); // Wait for the application to be loaded so that the session can be saved.
|
|
175
176
|
|
|
176
177
|
cy.get('#app-loader').should('not.exist');
|
|
@@ -208,11 +209,11 @@ function fillLoginForm(userCredentials) {
|
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
function isLocalhost() {
|
|
211
|
-
|
|
212
|
+
const baseUrl = new _URL(Cypress.config('baseUrl'));
|
|
212
213
|
return baseUrl.hostname === 'localhost';
|
|
213
214
|
}
|
|
214
215
|
|
|
215
|
-
Cypress.Commands.add('loginToMerchantCenter',
|
|
216
|
+
Cypress.Commands.add('loginToMerchantCenter', commandOptions => {
|
|
216
217
|
Cypress.log({
|
|
217
218
|
name: 'loginToMerchantCenter'
|
|
218
219
|
});
|
|
@@ -223,7 +224,7 @@ Cypress.Commands.add('loginToMerchantCenter', function (commandOptions) {
|
|
|
223
224
|
loginByForm(commandOptions);
|
|
224
225
|
}
|
|
225
226
|
});
|
|
226
|
-
Cypress.Commands.add('loginByOidc',
|
|
227
|
+
Cypress.Commands.add('loginByOidc', commandOptions => {
|
|
227
228
|
Cypress.log({
|
|
228
229
|
name: 'loginByOidc'
|
|
229
230
|
});
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var constants = require('./constants-
|
|
5
|
+
var constants = require('./constants-c657705e.cjs.dev.js');
|
|
6
6
|
|
|
7
7
|
// NOTE: This string will be replaced on build time with the package version.
|
|
8
|
-
var version = "21.
|
|
8
|
+
var version = "21.24.0";
|
|
9
9
|
|
|
10
10
|
exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
|
|
11
11
|
exports.STORAGE_KEYS = constants.STORAGE_KEYS;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var constants = require('./constants-
|
|
5
|
+
var constants = require('./constants-8ad2a50e.cjs.prod.js');
|
|
6
6
|
|
|
7
7
|
// NOTE: This string will be replaced on build time with the package version.
|
|
8
|
-
var version = "21.
|
|
8
|
+
var version = "21.24.0";
|
|
9
9
|
|
|
10
10
|
exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
|
|
11
11
|
exports.STORAGE_KEYS = constants.STORAGE_KEYS;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS } from './constants-
|
|
1
|
+
export { O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS } from './constants-18b165fc.esm.js';
|
|
2
2
|
|
|
3
3
|
// NOTE: This string will be replaced on build time with the package version.
|
|
4
|
-
var version = "21.
|
|
4
|
+
var version = "21.24.0";
|
|
5
5
|
|
|
6
6
|
export { version };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const STORAGE_KEYS = {
|
|
4
4
|
NONCE: 'nonce',
|
|
5
5
|
SESSION_SCOPE: 'sessionScope',
|
|
6
6
|
ACTIVE_PROJECT_KEY: 'activeProjectKey'
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
const OIDC_RESPONSE_TYPES = {
|
|
9
9
|
ID_TOKEN: 'id_token'
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const STORAGE_KEYS = {
|
|
4
4
|
NONCE: 'nonce',
|
|
5
5
|
SESSION_SCOPE: 'sessionScope',
|
|
6
6
|
ACTIVE_PROJECT_KEY: 'activeProjectKey'
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
const OIDC_RESPONSE_TYPES = {
|
|
9
9
|
ID_TOKEN: 'id_token'
|
|
10
10
|
};
|
|
11
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/cypress",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.24.0",
|
|
4
4
|
"description": "Cypress commands and utilities for Custom Applications",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@babel/runtime": "^7.20.13",
|
|
39
39
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
40
|
-
"@commercetools-frontend/application-config": "21.
|
|
41
|
-
"@commercetools-frontend/application-shell": "21.
|
|
40
|
+
"@commercetools-frontend/application-config": "21.24.0",
|
|
41
|
+
"@commercetools-frontend/application-shell": "21.24.0",
|
|
42
42
|
"@manypkg/get-packages": "1.1.3",
|
|
43
43
|
"semver": "7.3.8",
|
|
44
44
|
"uuid": "8.3.2"
|
|
@@ -10,9 +10,7 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
|
|
|
10
10
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
11
11
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
12
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
|
-
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
14
13
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
15
|
-
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
16
14
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
17
15
|
var fs = require('fs');
|
|
18
16
|
var path = require('path');
|
|
@@ -29,29 +27,28 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
29
27
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
30
28
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
31
29
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
32
|
-
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
33
30
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
34
31
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
35
32
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
36
33
|
|
|
37
34
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
38
35
|
|
|
39
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
37
|
+
let cachedAllCustomApplicationConfigs;
|
|
38
|
+
const defaultDotfiles = ['.env', '.env.local'];
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
const loadEnvironmentVariables = (packageDirPath, options) => {
|
|
44
41
|
var _options$dotfiles;
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
return _reduceInstanceProperty__default["default"](dotfiles).call(dotfiles,
|
|
48
|
-
|
|
43
|
+
const dotfiles = (_options$dotfiles = options.dotfiles) !== null && _options$dotfiles !== void 0 ? _options$dotfiles : defaultDotfiles;
|
|
44
|
+
return _reduceInstanceProperty__default["default"](dotfiles).call(dotfiles, (mergedEnvs, dotfile) => {
|
|
45
|
+
const envPath = path__default["default"].join(packageDirPath, dotfile);
|
|
49
46
|
|
|
50
47
|
if (!fs__default["default"].existsSync(envPath)) {
|
|
51
48
|
return mergedEnvs;
|
|
52
49
|
}
|
|
53
50
|
|
|
54
|
-
|
|
51
|
+
const env = require('dotenv').config({
|
|
55
52
|
path: envPath
|
|
56
53
|
});
|
|
57
54
|
|
|
@@ -65,101 +62,51 @@ var loadEnvironmentVariables = function loadEnvironmentVariables(packageDirPath,
|
|
|
65
62
|
}, process.env);
|
|
66
63
|
};
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
disableCache: true,
|
|
96
|
-
processEnv: processEnv,
|
|
97
|
-
applicationPath: packageInfo.dir
|
|
98
|
-
});
|
|
99
|
-
console.log("Found Custom Application config for ".concat(packageInfo.packageJson.name));
|
|
100
|
-
return _objectSpread(_objectSpread({}, allConfigs), {}, _defineProperty({}, processedConfig.env.entryPointUriPath, processedConfig.env));
|
|
101
|
-
} catch (error) {
|
|
102
|
-
// Ignore packages that do not have a valid config file, either because
|
|
103
|
-
// the package is not a Custom Application or because the config file
|
|
104
|
-
// is invalid.
|
|
105
|
-
if (error instanceof applicationConfig.MissingOrInvalidConfigError) {
|
|
106
|
-
return allConfigs;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
}, {});
|
|
112
|
-
return _context.abrupt("return", cachedAllCustomApplicationConfigs);
|
|
113
|
-
|
|
114
|
-
case 8:
|
|
115
|
-
case "end":
|
|
116
|
-
return _context.stop();
|
|
117
|
-
}
|
|
65
|
+
const loadAllCustomApplicationConfigs = async options => {
|
|
66
|
+
if (cachedAllCustomApplicationConfigs) {
|
|
67
|
+
return cachedAllCustomApplicationConfigs;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const _await$getPackages = await getPackages.getPackages(process.cwd()),
|
|
71
|
+
packages = _await$getPackages.packages;
|
|
72
|
+
|
|
73
|
+
cachedAllCustomApplicationConfigs = _reduceInstanceProperty__default["default"](packages).call(packages, (allConfigs, packageInfo) => {
|
|
74
|
+
const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const processedConfig = applicationConfig.processConfig({
|
|
78
|
+
disableCache: true,
|
|
79
|
+
processEnv,
|
|
80
|
+
applicationPath: packageInfo.dir
|
|
81
|
+
});
|
|
82
|
+
console.log("Found Custom Application config for ".concat(packageInfo.packageJson.name));
|
|
83
|
+
return _objectSpread(_objectSpread({}, allConfigs), {}, {
|
|
84
|
+
[processedConfig.env.entryPointUriPath]: processedConfig.env
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
// Ignore packages that do not have a valid config file, either because
|
|
88
|
+
// the package is not a Custom Application or because the config file
|
|
89
|
+
// is invalid.
|
|
90
|
+
if (error instanceof applicationConfig.MissingOrInvalidConfigError) {
|
|
91
|
+
return allConfigs;
|
|
118
92
|
}
|
|
119
|
-
}, _callee);
|
|
120
|
-
}));
|
|
121
|
-
|
|
122
|
-
return function loadAllCustomApplicationConfigs(_x) {
|
|
123
|
-
return _ref.apply(this, arguments);
|
|
124
|
-
};
|
|
125
|
-
}();
|
|
126
|
-
|
|
127
|
-
var customApplicationConfig = /*#__PURE__*/function () {
|
|
128
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(options) {
|
|
129
|
-
var allCustomApplicationConfigs, customApplicationConfig;
|
|
130
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
131
|
-
while (1) {
|
|
132
|
-
switch (_context2.prev = _context2.next) {
|
|
133
|
-
case 0:
|
|
134
|
-
_context2.next = 2;
|
|
135
|
-
return loadAllCustomApplicationConfigs(options);
|
|
136
|
-
|
|
137
|
-
case 2:
|
|
138
|
-
allCustomApplicationConfigs = _context2.sent;
|
|
139
|
-
customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
|
|
140
|
-
|
|
141
|
-
if (customApplicationConfig) {
|
|
142
|
-
_context2.next = 6;
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
|
|
147
|
-
|
|
148
|
-
case 6:
|
|
149
|
-
console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
|
|
150
|
-
return _context2.abrupt("return", customApplicationConfig);
|
|
151
|
-
|
|
152
|
-
case 8:
|
|
153
|
-
case "end":
|
|
154
|
-
return _context2.stop();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}, _callee2);
|
|
158
|
-
}));
|
|
159
93
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
163
|
-
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}, {});
|
|
97
|
+
return cachedAllCustomApplicationConfigs;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const customApplicationConfig = async options => {
|
|
101
|
+
const allCustomApplicationConfigs = await loadAllCustomApplicationConfigs(options);
|
|
102
|
+
const customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
|
|
103
|
+
|
|
104
|
+
if (!customApplicationConfig) {
|
|
105
|
+
throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
|
|
109
|
+
return customApplicationConfig;
|
|
110
|
+
};
|
|
164
111
|
|
|
165
112
|
exports.customApplicationConfig = customApplicationConfig;
|
|
@@ -10,9 +10,7 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
|
|
|
10
10
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
11
11
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
12
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
|
-
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
14
13
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
15
|
-
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
16
14
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
17
15
|
var fs = require('fs');
|
|
18
16
|
var path = require('path');
|
|
@@ -29,29 +27,28 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
29
27
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
30
28
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
31
29
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
32
|
-
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
33
30
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
34
31
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
35
32
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
36
33
|
|
|
37
34
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
38
35
|
|
|
39
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
37
|
+
let cachedAllCustomApplicationConfigs;
|
|
38
|
+
const defaultDotfiles = ['.env', '.env.local'];
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
const loadEnvironmentVariables = (packageDirPath, options) => {
|
|
44
41
|
var _options$dotfiles;
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
return _reduceInstanceProperty__default["default"](dotfiles).call(dotfiles,
|
|
48
|
-
|
|
43
|
+
const dotfiles = (_options$dotfiles = options.dotfiles) !== null && _options$dotfiles !== void 0 ? _options$dotfiles : defaultDotfiles;
|
|
44
|
+
return _reduceInstanceProperty__default["default"](dotfiles).call(dotfiles, (mergedEnvs, dotfile) => {
|
|
45
|
+
const envPath = path__default["default"].join(packageDirPath, dotfile);
|
|
49
46
|
|
|
50
47
|
if (!fs__default["default"].existsSync(envPath)) {
|
|
51
48
|
return mergedEnvs;
|
|
52
49
|
}
|
|
53
50
|
|
|
54
|
-
|
|
51
|
+
const env = require('dotenv').config({
|
|
55
52
|
path: envPath
|
|
56
53
|
});
|
|
57
54
|
|
|
@@ -65,101 +62,51 @@ var loadEnvironmentVariables = function loadEnvironmentVariables(packageDirPath,
|
|
|
65
62
|
}, process.env);
|
|
66
63
|
};
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
disableCache: true,
|
|
96
|
-
processEnv: processEnv,
|
|
97
|
-
applicationPath: packageInfo.dir
|
|
98
|
-
});
|
|
99
|
-
console.log("Found Custom Application config for ".concat(packageInfo.packageJson.name));
|
|
100
|
-
return _objectSpread(_objectSpread({}, allConfigs), {}, _defineProperty({}, processedConfig.env.entryPointUriPath, processedConfig.env));
|
|
101
|
-
} catch (error) {
|
|
102
|
-
// Ignore packages that do not have a valid config file, either because
|
|
103
|
-
// the package is not a Custom Application or because the config file
|
|
104
|
-
// is invalid.
|
|
105
|
-
if (error instanceof applicationConfig.MissingOrInvalidConfigError) {
|
|
106
|
-
return allConfigs;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
}, {});
|
|
112
|
-
return _context.abrupt("return", cachedAllCustomApplicationConfigs);
|
|
113
|
-
|
|
114
|
-
case 8:
|
|
115
|
-
case "end":
|
|
116
|
-
return _context.stop();
|
|
117
|
-
}
|
|
65
|
+
const loadAllCustomApplicationConfigs = async options => {
|
|
66
|
+
if (cachedAllCustomApplicationConfigs) {
|
|
67
|
+
return cachedAllCustomApplicationConfigs;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const _await$getPackages = await getPackages.getPackages(process.cwd()),
|
|
71
|
+
packages = _await$getPackages.packages;
|
|
72
|
+
|
|
73
|
+
cachedAllCustomApplicationConfigs = _reduceInstanceProperty__default["default"](packages).call(packages, (allConfigs, packageInfo) => {
|
|
74
|
+
const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const processedConfig = applicationConfig.processConfig({
|
|
78
|
+
disableCache: true,
|
|
79
|
+
processEnv,
|
|
80
|
+
applicationPath: packageInfo.dir
|
|
81
|
+
});
|
|
82
|
+
console.log("Found Custom Application config for ".concat(packageInfo.packageJson.name));
|
|
83
|
+
return _objectSpread(_objectSpread({}, allConfigs), {}, {
|
|
84
|
+
[processedConfig.env.entryPointUriPath]: processedConfig.env
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
// Ignore packages that do not have a valid config file, either because
|
|
88
|
+
// the package is not a Custom Application or because the config file
|
|
89
|
+
// is invalid.
|
|
90
|
+
if (error instanceof applicationConfig.MissingOrInvalidConfigError) {
|
|
91
|
+
return allConfigs;
|
|
118
92
|
}
|
|
119
|
-
}, _callee);
|
|
120
|
-
}));
|
|
121
|
-
|
|
122
|
-
return function loadAllCustomApplicationConfigs(_x) {
|
|
123
|
-
return _ref.apply(this, arguments);
|
|
124
|
-
};
|
|
125
|
-
}();
|
|
126
|
-
|
|
127
|
-
var customApplicationConfig = /*#__PURE__*/function () {
|
|
128
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(options) {
|
|
129
|
-
var allCustomApplicationConfigs, customApplicationConfig;
|
|
130
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
131
|
-
while (1) {
|
|
132
|
-
switch (_context2.prev = _context2.next) {
|
|
133
|
-
case 0:
|
|
134
|
-
_context2.next = 2;
|
|
135
|
-
return loadAllCustomApplicationConfigs(options);
|
|
136
|
-
|
|
137
|
-
case 2:
|
|
138
|
-
allCustomApplicationConfigs = _context2.sent;
|
|
139
|
-
customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
|
|
140
|
-
|
|
141
|
-
if (customApplicationConfig) {
|
|
142
|
-
_context2.next = 6;
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
|
|
147
|
-
|
|
148
|
-
case 6:
|
|
149
|
-
console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
|
|
150
|
-
return _context2.abrupt("return", customApplicationConfig);
|
|
151
|
-
|
|
152
|
-
case 8:
|
|
153
|
-
case "end":
|
|
154
|
-
return _context2.stop();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}, _callee2);
|
|
158
|
-
}));
|
|
159
93
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
163
|
-
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}, {});
|
|
97
|
+
return cachedAllCustomApplicationConfigs;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const customApplicationConfig = async options => {
|
|
101
|
+
const allCustomApplicationConfigs = await loadAllCustomApplicationConfigs(options);
|
|
102
|
+
const customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
|
|
103
|
+
|
|
104
|
+
if (!customApplicationConfig) {
|
|
105
|
+
throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
|
|
109
|
+
return customApplicationConfig;
|
|
110
|
+
};
|
|
164
111
|
|
|
165
112
|
exports.customApplicationConfig = customApplicationConfig;
|
|
@@ -6,9 +6,7 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/inst
|
|
|
6
6
|
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
7
7
|
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
8
8
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
|
-
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
|
|
10
9
|
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
11
|
-
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
12
10
|
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
13
11
|
import fs from 'fs';
|
|
14
12
|
import path from 'path';
|
|
@@ -17,22 +15,22 @@ import { processConfig, MissingOrInvalidConfigError } from '@commercetools-front
|
|
|
17
15
|
|
|
18
16
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
17
|
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
let cachedAllCustomApplicationConfigs;
|
|
20
|
+
const defaultDotfiles = ['.env', '.env.local'];
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
const loadEnvironmentVariables = (packageDirPath, options) => {
|
|
25
23
|
var _options$dotfiles;
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
return _reduceInstanceProperty(dotfiles).call(dotfiles,
|
|
29
|
-
|
|
25
|
+
const dotfiles = (_options$dotfiles = options.dotfiles) !== null && _options$dotfiles !== void 0 ? _options$dotfiles : defaultDotfiles;
|
|
26
|
+
return _reduceInstanceProperty(dotfiles).call(dotfiles, (mergedEnvs, dotfile) => {
|
|
27
|
+
const envPath = path.join(packageDirPath, dotfile);
|
|
30
28
|
|
|
31
29
|
if (!fs.existsSync(envPath)) {
|
|
32
30
|
return mergedEnvs;
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
const env = require('dotenv').config({
|
|
36
34
|
path: envPath
|
|
37
35
|
});
|
|
38
36
|
|
|
@@ -46,101 +44,51 @@ var loadEnvironmentVariables = function loadEnvironmentVariables(packageDirPath,
|
|
|
46
44
|
}, process.env);
|
|
47
45
|
};
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
disableCache: true,
|
|
77
|
-
processEnv: processEnv,
|
|
78
|
-
applicationPath: packageInfo.dir
|
|
79
|
-
});
|
|
80
|
-
console.log("Found Custom Application config for ".concat(packageInfo.packageJson.name));
|
|
81
|
-
return _objectSpread(_objectSpread({}, allConfigs), {}, _defineProperty({}, processedConfig.env.entryPointUriPath, processedConfig.env));
|
|
82
|
-
} catch (error) {
|
|
83
|
-
// Ignore packages that do not have a valid config file, either because
|
|
84
|
-
// the package is not a Custom Application or because the config file
|
|
85
|
-
// is invalid.
|
|
86
|
-
if (error instanceof MissingOrInvalidConfigError) {
|
|
87
|
-
return allConfigs;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
}, {});
|
|
93
|
-
return _context.abrupt("return", cachedAllCustomApplicationConfigs);
|
|
94
|
-
|
|
95
|
-
case 8:
|
|
96
|
-
case "end":
|
|
97
|
-
return _context.stop();
|
|
98
|
-
}
|
|
47
|
+
const loadAllCustomApplicationConfigs = async options => {
|
|
48
|
+
if (cachedAllCustomApplicationConfigs) {
|
|
49
|
+
return cachedAllCustomApplicationConfigs;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const _await$getPackages = await getPackages(process.cwd()),
|
|
53
|
+
packages = _await$getPackages.packages;
|
|
54
|
+
|
|
55
|
+
cachedAllCustomApplicationConfigs = _reduceInstanceProperty(packages).call(packages, (allConfigs, packageInfo) => {
|
|
56
|
+
const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const processedConfig = processConfig({
|
|
60
|
+
disableCache: true,
|
|
61
|
+
processEnv,
|
|
62
|
+
applicationPath: packageInfo.dir
|
|
63
|
+
});
|
|
64
|
+
console.log("Found Custom Application config for ".concat(packageInfo.packageJson.name));
|
|
65
|
+
return _objectSpread(_objectSpread({}, allConfigs), {}, {
|
|
66
|
+
[processedConfig.env.entryPointUriPath]: processedConfig.env
|
|
67
|
+
});
|
|
68
|
+
} catch (error) {
|
|
69
|
+
// Ignore packages that do not have a valid config file, either because
|
|
70
|
+
// the package is not a Custom Application or because the config file
|
|
71
|
+
// is invalid.
|
|
72
|
+
if (error instanceof MissingOrInvalidConfigError) {
|
|
73
|
+
return allConfigs;
|
|
99
74
|
}
|
|
100
|
-
}, _callee);
|
|
101
|
-
}));
|
|
102
|
-
|
|
103
|
-
return function loadAllCustomApplicationConfigs(_x) {
|
|
104
|
-
return _ref.apply(this, arguments);
|
|
105
|
-
};
|
|
106
|
-
}();
|
|
107
|
-
|
|
108
|
-
var customApplicationConfig = /*#__PURE__*/function () {
|
|
109
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
110
|
-
var allCustomApplicationConfigs, customApplicationConfig;
|
|
111
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
112
|
-
while (1) {
|
|
113
|
-
switch (_context2.prev = _context2.next) {
|
|
114
|
-
case 0:
|
|
115
|
-
_context2.next = 2;
|
|
116
|
-
return loadAllCustomApplicationConfigs(options);
|
|
117
|
-
|
|
118
|
-
case 2:
|
|
119
|
-
allCustomApplicationConfigs = _context2.sent;
|
|
120
|
-
customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
|
|
121
|
-
|
|
122
|
-
if (customApplicationConfig) {
|
|
123
|
-
_context2.next = 6;
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
|
|
128
|
-
|
|
129
|
-
case 6:
|
|
130
|
-
console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
|
|
131
|
-
return _context2.abrupt("return", customApplicationConfig);
|
|
132
|
-
|
|
133
|
-
case 8:
|
|
134
|
-
case "end":
|
|
135
|
-
return _context2.stop();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}, _callee2);
|
|
139
|
-
}));
|
|
140
75
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
};
|
|
144
|
-
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}, {});
|
|
79
|
+
return cachedAllCustomApplicationConfigs;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const customApplicationConfig = async options => {
|
|
83
|
+
const allCustomApplicationConfigs = await loadAllCustomApplicationConfigs(options);
|
|
84
|
+
const customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
|
|
85
|
+
|
|
86
|
+
if (!customApplicationConfig) {
|
|
87
|
+
throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
|
|
91
|
+
return customApplicationConfig;
|
|
92
|
+
};
|
|
145
93
|
|
|
146
94
|
export { customApplicationConfig };
|