@commercetools-frontend/cypress 22.16.0 → 22.17.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.
@@ -120,9 +120,12 @@ function loginByForm(commandOptions) {
120
120
  }
121
121
  });
122
122
  }
123
+ const isCustomView = commandOptions => commandOptions.entryPointUriPath === constants$1.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH;
123
124
  function loginByOidc(commandOptions) {
125
+ var _commandOptions$packa;
126
+ const isCustomViewConfigCommand = isCustomView(commandOptions);
124
127
  if (!isLocalhost()) {
125
- throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
128
+ throw new Error("The \"loginByOidc\" command only works when testing a Custom ".concat(isCustomViewConfigCommand ? 'View' : 'Application', " running on localhost."));
126
129
  }
127
130
  const sessionNonce = uuid.v4();
128
131
  let projectKey = undefined;
@@ -130,10 +133,17 @@ function loginByOidc(commandOptions) {
130
133
  var _commandOptions$proje2;
131
134
  projectKey = (_commandOptions$proje2 = commandOptions.projectKey) !== null && _commandOptions$proje2 !== void 0 ? _commandOptions$proje2 : Cypress.env('PROJECT_KEY');
132
135
  }
133
- cy.task('customApplicationConfig', {
136
+ const customEntityConfigCommand = isCustomViewConfigCommand ? 'customViewConfig' : 'customApplicationConfig';
137
+ const packageName = (_commandOptions$packa = commandOptions.packageName) !== null && _commandOptions$packa !== void 0 ? _commandOptions$packa : Cypress.env('PACKAGE_NAME');
138
+ if (isCustomViewConfigCommand && !packageName) {
139
+ throw new Error("Missing required option \"packageName\" when using the \"loginToMerchantCenterForCustomView\" command.");
140
+ }
141
+ cy.task(customEntityConfigCommand, _objectSpread$1({
134
142
  entryPointUriPath: commandOptions.entryPointUriPath,
135
143
  dotfiles: commandOptions.dotfiles
136
- },
144
+ }, isCustomViewConfigCommand ? {
145
+ packageName
146
+ } : {}),
137
147
  // Do not show log, as it may contain sensible information.
138
148
  {
139
149
  log: false
@@ -142,7 +152,7 @@ function loginByOidc(commandOptions) {
142
152
  // Log loaded application config for debugging purposes.
143
153
  Cypress.log({
144
154
  displayName: 'task',
145
- name: 'customApplicationConfig',
155
+ name: customEntityConfigCommand,
146
156
  message: appConfig
147
157
  });
148
158
  const applicationId = appConfig.applicationId;
@@ -120,9 +120,12 @@ function loginByForm(commandOptions) {
120
120
  }
121
121
  });
122
122
  }
123
+ const isCustomView = commandOptions => commandOptions.entryPointUriPath === constants$1.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH;
123
124
  function loginByOidc(commandOptions) {
125
+ var _commandOptions$packa;
126
+ const isCustomViewConfigCommand = isCustomView(commandOptions);
124
127
  if (!isLocalhost()) {
125
- throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
128
+ throw new Error("The \"loginByOidc\" command only works when testing a Custom ".concat(isCustomViewConfigCommand ? 'View' : 'Application', " running on localhost."));
126
129
  }
127
130
  const sessionNonce = uuid.v4();
128
131
  let projectKey = undefined;
@@ -130,10 +133,17 @@ function loginByOidc(commandOptions) {
130
133
  var _commandOptions$proje2;
131
134
  projectKey = (_commandOptions$proje2 = commandOptions.projectKey) !== null && _commandOptions$proje2 !== void 0 ? _commandOptions$proje2 : Cypress.env('PROJECT_KEY');
132
135
  }
133
- cy.task('customApplicationConfig', {
136
+ const customEntityConfigCommand = isCustomViewConfigCommand ? 'customViewConfig' : 'customApplicationConfig';
137
+ const packageName = (_commandOptions$packa = commandOptions.packageName) !== null && _commandOptions$packa !== void 0 ? _commandOptions$packa : Cypress.env('PACKAGE_NAME');
138
+ if (isCustomViewConfigCommand && !packageName) {
139
+ throw new Error("Missing required option \"packageName\" when using the \"loginToMerchantCenterForCustomView\" command.");
140
+ }
141
+ cy.task(customEntityConfigCommand, _objectSpread$1({
134
142
  entryPointUriPath: commandOptions.entryPointUriPath,
135
143
  dotfiles: commandOptions.dotfiles
136
- },
144
+ }, isCustomViewConfigCommand ? {
145
+ packageName
146
+ } : {}),
137
147
  // Do not show log, as it may contain sensible information.
138
148
  {
139
149
  log: false
@@ -142,7 +152,7 @@ function loginByOidc(commandOptions) {
142
152
  // Log loaded application config for debugging purposes.
143
153
  Cypress.log({
144
154
  displayName: 'task',
145
- name: 'customApplicationConfig',
155
+ name: customEntityConfigCommand,
146
156
  message: appConfig
147
157
  });
148
158
  const applicationId = appConfig.applicationId;
@@ -101,9 +101,12 @@ function loginByForm(commandOptions) {
101
101
  }
102
102
  });
103
103
  }
104
+ const isCustomView = commandOptions => commandOptions.entryPointUriPath === CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH;
104
105
  function loginByOidc(commandOptions) {
106
+ var _commandOptions$packa;
107
+ const isCustomViewConfigCommand = isCustomView(commandOptions);
105
108
  if (!isLocalhost()) {
106
- throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
109
+ throw new Error("The \"loginByOidc\" command only works when testing a Custom ".concat(isCustomViewConfigCommand ? 'View' : 'Application', " running on localhost."));
107
110
  }
108
111
  const sessionNonce = v4();
109
112
  let projectKey = undefined;
@@ -111,10 +114,17 @@ function loginByOidc(commandOptions) {
111
114
  var _commandOptions$proje2;
112
115
  projectKey = (_commandOptions$proje2 = commandOptions.projectKey) !== null && _commandOptions$proje2 !== void 0 ? _commandOptions$proje2 : Cypress.env('PROJECT_KEY');
113
116
  }
114
- cy.task('customApplicationConfig', {
117
+ const customEntityConfigCommand = isCustomViewConfigCommand ? 'customViewConfig' : 'customApplicationConfig';
118
+ const packageName = (_commandOptions$packa = commandOptions.packageName) !== null && _commandOptions$packa !== void 0 ? _commandOptions$packa : Cypress.env('PACKAGE_NAME');
119
+ if (isCustomViewConfigCommand && !packageName) {
120
+ throw new Error("Missing required option \"packageName\" when using the \"loginToMerchantCenterForCustomView\" command.");
121
+ }
122
+ cy.task(customEntityConfigCommand, _objectSpread$1({
115
123
  entryPointUriPath: commandOptions.entryPointUriPath,
116
124
  dotfiles: commandOptions.dotfiles
117
- },
125
+ }, isCustomViewConfigCommand ? {
126
+ packageName
127
+ } : {}),
118
128
  // Do not show log, as it may contain sensible information.
119
129
  {
120
130
  log: false
@@ -123,7 +133,7 @@ function loginByOidc(commandOptions) {
123
133
  // Log loaded application config for debugging purposes.
124
134
  Cypress.log({
125
135
  displayName: 'task',
126
- name: 'customApplicationConfig',
136
+ name: customEntityConfigCommand,
127
137
  message: appConfig
128
138
  });
129
139
  const applicationId = appConfig.applicationId;
@@ -21,10 +21,7 @@ declare namespace Cypress {
21
21
  */
22
22
  loginToMerchantCenterForCustomView(
23
23
  // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#import-types
24
- options?: Omit<
25
- import('./dist/commercetools-frontend-cypress-add-commands.cjs').CommandLoginOptions,
26
- 'entryPointUriPath' | 'initialRoute'
27
- >
24
+ options?: import('./dist/commercetools-frontend-cypress-add-commands.cjs').LoginToMerchantCenterForCustomViewCommandLoginOptions
28
25
  ): Chainable<Subject>;
29
26
  /**
30
27
  * Log into the Custom Application using the OIDC workflow.
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
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 = "22.16.0";
8
+ var version = "22.17.0";
9
9
 
10
10
  exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
11
11
  exports.STORAGE_KEYS = constants.STORAGE_KEYS;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
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 = "22.16.0";
8
+ var version = "22.17.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
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 = "22.16.0";
4
+ var version = "22.17.0";
5
5
 
6
6
  export { version };
@@ -1,4 +1,5 @@
1
1
  import { Matcher as TMatcher } from '@testing-library/dom';
2
- import { type CommandLoginOptions as TCommandLoginOptions } from './login';
2
+ import { type CommandLoginOptions as TCommandLoginOptions, type LoginToMerchantCenterForCustomViewCommandLoginOptions as TLoginToMerchantCenterForCustomViewCommandLoginOptions } from './login';
3
3
  export type CommandLoginOptions = TCommandLoginOptions;
4
+ export type LoginToMerchantCenterForCustomViewCommandLoginOptions = TLoginToMerchantCenterForCustomViewCommandLoginOptions;
4
5
  export type Matcher = TMatcher;
@@ -47,8 +47,16 @@ export type CommandLoginOptions = {
47
47
  */
48
48
  disableCacheAcrossSpecs?: boolean;
49
49
  };
50
+ export type LoginToMerchantCenterForCustomViewCommandLoginOptions = Omit<CommandLoginOptions, 'entryPointUriPath' | 'initialRoute'> & {
51
+ /**
52
+ * The package name as specified in the `package.json` to uniquely identify the configuration.
53
+ * This is only required for testing Custom Views.
54
+ * Defaults to `Cypress.env('PACKAGE_NAME')`
55
+ */
56
+ packageName?: string;
57
+ };
50
58
  export type CommandLoginByOidcOptions = CommandLoginOptions;
51
59
  declare function loginByForm(commandOptions: CommandLoginOptions): void;
52
- declare function loginByOidc(commandOptions: CommandLoginOptions): void;
60
+ declare function loginByOidc(commandOptions: CommandLoginOptions & LoginToMerchantCenterForCustomViewCommandLoginOptions): void;
53
61
  declare function isLocalhost(): boolean;
54
62
  export { loginByForm, loginByOidc, isLocalhost };
@@ -1,7 +1,13 @@
1
- import type { ApplicationRuntimeConfig } from '@commercetools-frontend/application-config';
2
- type CustomApplicationConfigTaskOptions = {
1
+ import { type ApplicationRuntimeConfig } from '@commercetools-frontend/application-config';
2
+ type CustomEntityConfigTaskOptions = {
3
3
  entryPointUriPath: string;
4
4
  dotfiles?: string[];
5
+ packageName?: string;
5
6
  };
6
- declare const customApplicationConfig: (options: CustomApplicationConfigTaskOptions) => Promise<ApplicationRuntimeConfig['env']>;
7
- export { customApplicationConfig };
7
+ declare const customApplicationConfig: (options: CustomEntityConfigTaskOptions) => Promise<ApplicationRuntimeConfig['env']>;
8
+ declare const customViewConfig: (options: Omit<CustomEntityConfigTaskOptions, 'entryPointUriPath'>) => Promise<ApplicationRuntimeConfig['env']>;
9
+ export { customApplicationConfig, customViewConfig };
10
+ declare const legacyConfig: {
11
+ customApplicationConfig: (options: CustomEntityConfigTaskOptions) => Promise<ApplicationRuntimeConfig['env']>;
12
+ };
13
+ export default legacyConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/cypress",
3
- "version": "22.16.0",
3
+ "version": "22.17.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": {
@@ -41,9 +41,9 @@
41
41
  "dependencies": {
42
42
  "@babel/runtime": "^7.22.15",
43
43
  "@babel/runtime-corejs3": "^7.22.15",
44
- "@commercetools-frontend/application-config": "22.16.0",
45
- "@commercetools-frontend/application-shell": "22.16.0",
46
- "@commercetools-frontend/constants": "22.16.0",
44
+ "@commercetools-frontend/application-config": "22.17.0",
45
+ "@commercetools-frontend/application-shell": "22.17.0",
46
+ "@commercetools-frontend/constants": "22.17.0",
47
47
  "@manypkg/get-packages": "1.1.3",
48
48
  "@types/semver": "^7.5.1",
49
49
  "semver": "7.5.2",
@@ -1,2 +1,3 @@
1
1
  export * from "../../dist/declarations/src/task/index";
2
+ export { default } from "../../dist/declarations/src/task/index";
2
3
  //# sourceMappingURL=commercetools-frontend-cypress-task.cjs.d.ts.map
@@ -12,10 +12,12 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
12
12
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
13
13
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
14
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
15
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
15
16
  var fs = require('fs');
16
17
  var path = require('path');
17
18
  var getPackages = require('@manypkg/get-packages');
18
19
  var applicationConfig = require('@commercetools-frontend/application-config');
20
+ var constants = require('@commercetools-frontend/constants');
19
21
 
20
22
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
21
23
 
@@ -28,12 +30,13 @@ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_O
28
30
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
29
31
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
30
32
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
33
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
31
34
  var fs__default = /*#__PURE__*/_interopDefault(fs);
32
35
  var path__default = /*#__PURE__*/_interopDefault(path);
33
36
 
34
37
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
35
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
36
- let cachedAllCustomApplicationConfigs;
38
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
39
+ let cachedAllCustomEntityConfigs;
37
40
  const defaultDotfiles = ['.env', '.env.local'];
38
41
  const loadEnvironmentVariables = (packageDirPath, options) => {
39
42
  var _options$dotfiles;
@@ -55,27 +58,30 @@ const loadEnvironmentVariables = (packageDirPath, options) => {
55
58
  // Merge it with the environment variables defined in the current process.
56
59
  }, process.env);
57
60
  };
58
- const loadAllCustomApplicationConfigs = async options => {
59
- if (cachedAllCustomApplicationConfigs) {
60
- return cachedAllCustomApplicationConfigs;
61
+ const loadAllCustomEntityConfigs = async options => {
62
+ if (cachedAllCustomEntityConfigs) {
63
+ return cachedAllCustomEntityConfigs;
61
64
  }
62
65
  const _await$getPackages = await getPackages.getPackages(process.cwd()),
63
66
  packages = _await$getPackages.packages;
64
- cachedAllCustomApplicationConfigs = _reduceInstanceProperty__default["default"](packages).call(packages, (allConfigs, packageInfo) => {
67
+ cachedAllCustomEntityConfigs = _reduceInstanceProperty__default["default"](packages).call(packages, (allConfigs, packageInfo) => {
65
68
  const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
66
69
  try {
70
+ var _context, _context2;
67
71
  const processedConfig = applicationConfig.processConfig({
68
72
  disableCache: true,
69
73
  processEnv,
70
74
  applicationPath: packageInfo.dir
71
75
  });
72
- console.log("Found Custom Application config for ".concat(packageInfo.packageJson.name));
76
+ const isCustomViewConfig = Boolean(processedConfig.env.customViewId);
77
+ console.log(_concatInstanceProperty__default["default"](_context = "Found Custom ".concat(isCustomViewConfig ? 'View' : 'Application', " config for ")).call(_context, packageInfo.packageJson.name));
78
+ const customEntityConfigCacheKey = isCustomViewConfig ? _concatInstanceProperty__default["default"](_context2 = "".concat(processedConfig.env.entryPointUriPath, "-")).call(_context2, packageInfo.packageJson.name) : processedConfig.env.entryPointUriPath;
73
79
  return _objectSpread(_objectSpread({}, allConfigs), {}, {
74
- [processedConfig.env.entryPointUriPath]: processedConfig.env
80
+ [customEntityConfigCacheKey]: processedConfig.env
75
81
  });
76
82
  } catch (error) {
77
83
  // Ignore packages that do not have a valid config file, either because
78
- // the package is not a Custom Application or because the config file
84
+ // the package is not a Custom Entity or because the config file
79
85
  // is invalid.
80
86
  if (error instanceof applicationConfig.MissingOrInvalidConfigError) {
81
87
  return allConfigs;
@@ -83,16 +89,35 @@ const loadAllCustomApplicationConfigs = async options => {
83
89
  throw error;
84
90
  }
85
91
  }, {});
86
- return cachedAllCustomApplicationConfigs;
92
+ return cachedAllCustomEntityConfigs;
87
93
  };
88
94
  const customApplicationConfig = async options => {
89
- const allCustomApplicationConfigs = await loadAllCustomApplicationConfigs(options);
90
- const customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
95
+ const allCustomEntityConfigs = await loadAllCustomEntityConfigs(options);
96
+ const customApplicationConfig = allCustomEntityConfigs[options.entryPointUriPath];
91
97
  if (!customApplicationConfig) {
92
98
  throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
93
99
  }
94
100
  console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
95
101
  return customApplicationConfig;
96
102
  };
103
+ const customViewConfig = async options => {
104
+ var _context3;
105
+ const allCustomEntityConfigs = await loadAllCustomEntityConfigs(_objectSpread(_objectSpread({}, options), {}, {
106
+ entryPointUriPath: constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH
107
+ }));
108
+ const customViewConfig = allCustomEntityConfigs[_concatInstanceProperty__default["default"](_context3 = "".concat(constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, "-")).call(_context3, options.packageName)];
109
+ if (!customViewConfig) {
110
+ throw new Error("Could not find Custom View config");
111
+ }
112
+ console.log("Using Custom View config for \"".concat(options.packageName, "\""));
113
+ return customViewConfig;
114
+ };
115
+
116
+ // for backwards compatibility
117
+ const legacyConfig = {
118
+ customApplicationConfig
119
+ };
97
120
 
98
121
  exports.customApplicationConfig = customApplicationConfig;
122
+ exports.customViewConfig = customViewConfig;
123
+ exports["default"] = legacyConfig;
@@ -12,10 +12,12 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
12
12
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
13
13
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
14
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
15
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
15
16
  var fs = require('fs');
16
17
  var path = require('path');
17
18
  var getPackages = require('@manypkg/get-packages');
18
19
  var applicationConfig = require('@commercetools-frontend/application-config');
20
+ var constants = require('@commercetools-frontend/constants');
19
21
 
20
22
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
21
23
 
@@ -28,12 +30,13 @@ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_O
28
30
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
29
31
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
30
32
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
33
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
31
34
  var fs__default = /*#__PURE__*/_interopDefault(fs);
32
35
  var path__default = /*#__PURE__*/_interopDefault(path);
33
36
 
34
37
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
35
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
36
- let cachedAllCustomApplicationConfigs;
38
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
39
+ let cachedAllCustomEntityConfigs;
37
40
  const defaultDotfiles = ['.env', '.env.local'];
38
41
  const loadEnvironmentVariables = (packageDirPath, options) => {
39
42
  var _options$dotfiles;
@@ -55,27 +58,30 @@ const loadEnvironmentVariables = (packageDirPath, options) => {
55
58
  // Merge it with the environment variables defined in the current process.
56
59
  }, process.env);
57
60
  };
58
- const loadAllCustomApplicationConfigs = async options => {
59
- if (cachedAllCustomApplicationConfigs) {
60
- return cachedAllCustomApplicationConfigs;
61
+ const loadAllCustomEntityConfigs = async options => {
62
+ if (cachedAllCustomEntityConfigs) {
63
+ return cachedAllCustomEntityConfigs;
61
64
  }
62
65
  const _await$getPackages = await getPackages.getPackages(process.cwd()),
63
66
  packages = _await$getPackages.packages;
64
- cachedAllCustomApplicationConfigs = _reduceInstanceProperty__default["default"](packages).call(packages, (allConfigs, packageInfo) => {
67
+ cachedAllCustomEntityConfigs = _reduceInstanceProperty__default["default"](packages).call(packages, (allConfigs, packageInfo) => {
65
68
  const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
66
69
  try {
70
+ var _context, _context2;
67
71
  const processedConfig = applicationConfig.processConfig({
68
72
  disableCache: true,
69
73
  processEnv,
70
74
  applicationPath: packageInfo.dir
71
75
  });
72
- console.log("Found Custom Application config for ".concat(packageInfo.packageJson.name));
76
+ const isCustomViewConfig = Boolean(processedConfig.env.customViewId);
77
+ console.log(_concatInstanceProperty__default["default"](_context = "Found Custom ".concat(isCustomViewConfig ? 'View' : 'Application', " config for ")).call(_context, packageInfo.packageJson.name));
78
+ const customEntityConfigCacheKey = isCustomViewConfig ? _concatInstanceProperty__default["default"](_context2 = "".concat(processedConfig.env.entryPointUriPath, "-")).call(_context2, packageInfo.packageJson.name) : processedConfig.env.entryPointUriPath;
73
79
  return _objectSpread(_objectSpread({}, allConfigs), {}, {
74
- [processedConfig.env.entryPointUriPath]: processedConfig.env
80
+ [customEntityConfigCacheKey]: processedConfig.env
75
81
  });
76
82
  } catch (error) {
77
83
  // Ignore packages that do not have a valid config file, either because
78
- // the package is not a Custom Application or because the config file
84
+ // the package is not a Custom Entity or because the config file
79
85
  // is invalid.
80
86
  if (error instanceof applicationConfig.MissingOrInvalidConfigError) {
81
87
  return allConfigs;
@@ -83,16 +89,35 @@ const loadAllCustomApplicationConfigs = async options => {
83
89
  throw error;
84
90
  }
85
91
  }, {});
86
- return cachedAllCustomApplicationConfigs;
92
+ return cachedAllCustomEntityConfigs;
87
93
  };
88
94
  const customApplicationConfig = async options => {
89
- const allCustomApplicationConfigs = await loadAllCustomApplicationConfigs(options);
90
- const customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
95
+ const allCustomEntityConfigs = await loadAllCustomEntityConfigs(options);
96
+ const customApplicationConfig = allCustomEntityConfigs[options.entryPointUriPath];
91
97
  if (!customApplicationConfig) {
92
98
  throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
93
99
  }
94
100
  console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
95
101
  return customApplicationConfig;
96
102
  };
103
+ const customViewConfig = async options => {
104
+ var _context3;
105
+ const allCustomEntityConfigs = await loadAllCustomEntityConfigs(_objectSpread(_objectSpread({}, options), {}, {
106
+ entryPointUriPath: constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH
107
+ }));
108
+ const customViewConfig = allCustomEntityConfigs[_concatInstanceProperty__default["default"](_context3 = "".concat(constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, "-")).call(_context3, options.packageName)];
109
+ if (!customViewConfig) {
110
+ throw new Error("Could not find Custom View config");
111
+ }
112
+ console.log("Using Custom View config for \"".concat(options.packageName, "\""));
113
+ return customViewConfig;
114
+ };
115
+
116
+ // for backwards compatibility
117
+ const legacyConfig = {
118
+ customApplicationConfig
119
+ };
97
120
 
98
121
  exports.customApplicationConfig = customApplicationConfig;
122
+ exports.customViewConfig = customViewConfig;
123
+ exports["default"] = legacyConfig;
@@ -8,14 +8,16 @@ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/obje
8
8
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
9
9
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
10
10
  import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
11
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
11
12
  import fs from 'fs';
12
13
  import path from 'path';
13
14
  import { getPackages } from '@manypkg/get-packages';
14
15
  import { processConfig, MissingOrInvalidConfigError } from '@commercetools-frontend/application-config';
16
+ import { CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH } from '@commercetools-frontend/constants';
15
17
 
16
18
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
18
- let cachedAllCustomApplicationConfigs;
19
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
20
+ let cachedAllCustomEntityConfigs;
19
21
  const defaultDotfiles = ['.env', '.env.local'];
20
22
  const loadEnvironmentVariables = (packageDirPath, options) => {
21
23
  var _options$dotfiles;
@@ -37,27 +39,30 @@ const loadEnvironmentVariables = (packageDirPath, options) => {
37
39
  // Merge it with the environment variables defined in the current process.
38
40
  }, process.env);
39
41
  };
40
- const loadAllCustomApplicationConfigs = async options => {
41
- if (cachedAllCustomApplicationConfigs) {
42
- return cachedAllCustomApplicationConfigs;
42
+ const loadAllCustomEntityConfigs = async options => {
43
+ if (cachedAllCustomEntityConfigs) {
44
+ return cachedAllCustomEntityConfigs;
43
45
  }
44
46
  const _await$getPackages = await getPackages(process.cwd()),
45
47
  packages = _await$getPackages.packages;
46
- cachedAllCustomApplicationConfigs = _reduceInstanceProperty(packages).call(packages, (allConfigs, packageInfo) => {
48
+ cachedAllCustomEntityConfigs = _reduceInstanceProperty(packages).call(packages, (allConfigs, packageInfo) => {
47
49
  const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
48
50
  try {
51
+ var _context, _context2;
49
52
  const processedConfig = processConfig({
50
53
  disableCache: true,
51
54
  processEnv,
52
55
  applicationPath: packageInfo.dir
53
56
  });
54
- console.log("Found Custom Application config for ".concat(packageInfo.packageJson.name));
57
+ const isCustomViewConfig = Boolean(processedConfig.env.customViewId);
58
+ console.log(_concatInstanceProperty(_context = "Found Custom ".concat(isCustomViewConfig ? 'View' : 'Application', " config for ")).call(_context, packageInfo.packageJson.name));
59
+ const customEntityConfigCacheKey = isCustomViewConfig ? _concatInstanceProperty(_context2 = "".concat(processedConfig.env.entryPointUriPath, "-")).call(_context2, packageInfo.packageJson.name) : processedConfig.env.entryPointUriPath;
55
60
  return _objectSpread(_objectSpread({}, allConfigs), {}, {
56
- [processedConfig.env.entryPointUriPath]: processedConfig.env
61
+ [customEntityConfigCacheKey]: processedConfig.env
57
62
  });
58
63
  } catch (error) {
59
64
  // Ignore packages that do not have a valid config file, either because
60
- // the package is not a Custom Application or because the config file
65
+ // the package is not a Custom Entity or because the config file
61
66
  // is invalid.
62
67
  if (error instanceof MissingOrInvalidConfigError) {
63
68
  return allConfigs;
@@ -65,16 +70,33 @@ const loadAllCustomApplicationConfigs = async options => {
65
70
  throw error;
66
71
  }
67
72
  }, {});
68
- return cachedAllCustomApplicationConfigs;
73
+ return cachedAllCustomEntityConfigs;
69
74
  };
70
75
  const customApplicationConfig = async options => {
71
- const allCustomApplicationConfigs = await loadAllCustomApplicationConfigs(options);
72
- const customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
76
+ const allCustomEntityConfigs = await loadAllCustomEntityConfigs(options);
77
+ const customApplicationConfig = allCustomEntityConfigs[options.entryPointUriPath];
73
78
  if (!customApplicationConfig) {
74
79
  throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
75
80
  }
76
81
  console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
77
82
  return customApplicationConfig;
78
83
  };
84
+ const customViewConfig = async options => {
85
+ var _context3;
86
+ const allCustomEntityConfigs = await loadAllCustomEntityConfigs(_objectSpread(_objectSpread({}, options), {}, {
87
+ entryPointUriPath: CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH
88
+ }));
89
+ const customViewConfig = allCustomEntityConfigs[_concatInstanceProperty(_context3 = "".concat(CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, "-")).call(_context3, options.packageName)];
90
+ if (!customViewConfig) {
91
+ throw new Error("Could not find Custom View config");
92
+ }
93
+ console.log("Using Custom View config for \"".concat(options.packageName, "\""));
94
+ return customViewConfig;
95
+ };
96
+
97
+ // for backwards compatibility
98
+ const legacyConfig = {
99
+ customApplicationConfig
100
+ };
79
101
 
80
- export { customApplicationConfig };
102
+ export { customApplicationConfig, customViewConfig, legacyConfig as default };