@commercetools-frontend/application-config 22.36.0 → 22.37.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/dist/commercetools-frontend-application-config.cjs.dev.js +67 -57
- package/dist/commercetools-frontend-application-config.cjs.prod.js +67 -57
- package/dist/commercetools-frontend-application-config.esm.js +64 -56
- package/dist/declarations/src/load-config.d.ts +5 -2
- package/dist/declarations/src/process-config.d.ts +1 -1
- package/package.json +5 -6
- package/scripts/load-js-module.js +0 -34
|
@@ -14,12 +14,16 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
14
14
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
15
15
|
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
16
16
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
17
|
-
var fs = require('node:fs');
|
|
17
|
+
var fs$1 = require('node:fs');
|
|
18
18
|
var path = require('node:path');
|
|
19
19
|
var omitEmpty = require('omit-empty-es');
|
|
20
20
|
var constants = require('@commercetools-frontend/constants');
|
|
21
|
-
var
|
|
21
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
22
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
23
|
+
var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
|
|
24
|
+
var fs = require('node:fs/promises');
|
|
22
25
|
var cosmiconfig = require('cosmiconfig');
|
|
26
|
+
var cosmiconfigTypescriptLoader = require('cosmiconfig-typescript-loader');
|
|
23
27
|
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
24
28
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
25
29
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
@@ -28,12 +32,10 @@ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
|
28
32
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
29
33
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
30
34
|
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
31
|
-
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
32
35
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
33
36
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
34
37
|
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
35
38
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
36
|
-
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
37
39
|
var formatters = require('./formatters-a76b45b9.cjs.dev.js');
|
|
38
40
|
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
39
41
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
@@ -58,15 +60,17 @@ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defin
|
|
|
58
60
|
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
59
61
|
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
60
62
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
61
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
63
|
+
var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
|
|
62
64
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
63
65
|
var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
|
|
66
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
67
|
+
var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
68
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
64
69
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
65
70
|
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
66
71
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
67
72
|
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
68
73
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
69
|
-
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
70
74
|
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
71
75
|
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
72
76
|
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
@@ -126,65 +130,71 @@ let MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
|
|
|
126
130
|
return _createClass(MissingOrInvalidConfigError);
|
|
127
131
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
128
132
|
|
|
129
|
-
|
|
133
|
+
// See the following issues for more context, contributing to failing Jest tests:
|
|
134
|
+
// - Issue: https://github.com/nodejs/node/issues/40058
|
|
135
|
+
// - Resolution: https://github.com/nodejs/node/pull/48510 (Node v20.8.0)
|
|
136
|
+
// Copied from @commitlint/load/src/utils/load-config.ts
|
|
137
|
+
const isDynamicAwaitSupported = () => {
|
|
138
|
+
var _context;
|
|
139
|
+
const _process$version$repl = _mapInstanceProperty__default["default"](_context = process.version.replace('v', '').split('.')).call(_context, val => _parseInt__default["default"](val)),
|
|
140
|
+
_process$version$repl2 = _slicedToArray(_process$version$repl, 2),
|
|
141
|
+
major = _process$version$repl2[0],
|
|
142
|
+
minor = _process$version$repl2[1];
|
|
143
|
+
return major >= 20 && minor >= 8;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Is the given directory set up to use ESM (ECMAScript Modules)?
|
|
147
|
+
// Copied from @commitlint/load/src/utils/load-config.ts
|
|
148
|
+
const isEsmModule = async cwd => {
|
|
149
|
+
const packagePath = path__default["default"].join(cwd, 'package.json');
|
|
130
150
|
try {
|
|
131
|
-
fs__default["default"].
|
|
132
|
-
|
|
151
|
+
const packageJSON = await fs__default["default"].readFile(packagePath, {
|
|
152
|
+
encoding: 'utf-8'
|
|
153
|
+
});
|
|
154
|
+
return JSON.parse(packageJSON)?.type === 'module';
|
|
133
155
|
} catch (error) {
|
|
134
156
|
return false;
|
|
135
157
|
}
|
|
136
|
-
}
|
|
137
|
-
// Helper function to find the package root path from the current location,
|
|
138
|
-
// for instance in respect to both source files and dist files.
|
|
139
|
-
const findPackageRootPath = dir => {
|
|
140
|
-
const packageJsonPath = path__default["default"].join(dir, 'package.json');
|
|
141
|
-
if (doesFileExist(packageJsonPath)) {
|
|
142
|
-
return dir;
|
|
143
|
-
}
|
|
144
|
-
const parentDir = path__default["default"].join(dir, '..');
|
|
145
|
-
return findPackageRootPath(parentDir);
|
|
146
158
|
};
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return cosmiconfig.cosmiconfigSync(configFileName, {
|
|
164
|
-
// Restrict the supported file formats / names
|
|
165
|
-
searchPlaces: [`.${configFileName}rc`, `.${configFileName}.json`, `.${configFileName}.js`, `.${configFileName}.cjs`, `.${configFileName}.mjs`, `.${configFileName}.ts`, `${configFileName}.json`, `${configFileName}.js`, `${configFileName}.cjs`, `${configFileName}.mjs`, `${configFileName}.ts`],
|
|
159
|
+
const createExplorerFor = async configFileName => {
|
|
160
|
+
// Copied from @commitlint/load/src/utils/load-config.ts
|
|
161
|
+
let tsLoaderInstance;
|
|
162
|
+
const tsLoader = function () {
|
|
163
|
+
if (!tsLoaderInstance) {
|
|
164
|
+
tsLoaderInstance = cosmiconfigTypescriptLoader.TypeScriptLoader();
|
|
165
|
+
}
|
|
166
|
+
return tsLoaderInstance(...arguments);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// If dynamic await is supported (Node >= v20.8.0) or directory uses ESM, support
|
|
170
|
+
// async js/cjs loaders (dynamic import). Otherwise, use synchronous js/cjs loaders.
|
|
171
|
+
const loaders = isDynamicAwaitSupported() || (await isEsmModule(process.cwd())) ? cosmiconfig.defaultLoaders : cosmiconfig.defaultLoadersSync;
|
|
172
|
+
return cosmiconfig.cosmiconfig(configFileName, {
|
|
173
|
+
searchStrategy: 'project',
|
|
174
|
+
searchPlaces: [`${configFileName}.js`, `${configFileName}.cjs`, `${configFileName}.mjs`, `${configFileName}.ts`],
|
|
166
175
|
loaders: {
|
|
167
|
-
|
|
168
|
-
'.
|
|
169
|
-
'.
|
|
170
|
-
'.
|
|
171
|
-
'.ts': loadJsModule
|
|
176
|
+
'.js': loaders['.js'],
|
|
177
|
+
'.cjs': loaders['.cjs'],
|
|
178
|
+
'.mjs': tsLoader,
|
|
179
|
+
'.ts': tsLoader
|
|
172
180
|
}
|
|
173
181
|
});
|
|
174
182
|
};
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
const
|
|
178
|
-
const customApplicationConfigFile = customApplicationExplorer.search();
|
|
179
|
-
const customViewConfigFile = customViewExplorer.search();
|
|
183
|
+
const getConfigPath = async () => {
|
|
184
|
+
const customApplicationExplorer = await createExplorerFor('custom-application-config');
|
|
185
|
+
const customViewExplorer = await createExplorerFor('custom-view-config');
|
|
186
|
+
const customApplicationConfigFile = await customApplicationExplorer.search();
|
|
187
|
+
const customViewConfigFile = await customViewExplorer.search();
|
|
180
188
|
if (!customApplicationConfigFile && !customViewConfigFile) {
|
|
181
189
|
throw new Error(`Missing or invalid configuration file.`);
|
|
182
190
|
}
|
|
183
191
|
return customApplicationConfigFile?.filepath || customViewConfigFile?.filepath;
|
|
184
192
|
};
|
|
185
|
-
const loadConfig = applicationPath => {
|
|
186
|
-
const
|
|
187
|
-
const
|
|
193
|
+
const loadConfig = async applicationPath => {
|
|
194
|
+
const customApplicationExplorer = await createExplorerFor('custom-application-config');
|
|
195
|
+
const customViewExplorer = await createExplorerFor('custom-view-config');
|
|
196
|
+
const customApplicationConfigFile = await customApplicationExplorer.search(applicationPath);
|
|
197
|
+
const customViewConfigFile = await customViewExplorer.search(applicationPath);
|
|
188
198
|
if ((!customApplicationConfigFile || !customApplicationConfigFile.config) && (!customViewConfigFile || !customViewConfigFile.config)) {
|
|
189
199
|
throw new MissingOrInvalidConfigError(`Missing or invalid configuration file.`);
|
|
190
200
|
}
|
|
@@ -252,7 +262,7 @@ const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString
|
|
|
252
262
|
const _valueOfPlaceholder$s5 = valueOfPlaceholder.split(':'),
|
|
253
263
|
_valueOfPlaceholder$s6 = _slicedToArray(_valueOfPlaceholder$s5, 2),
|
|
254
264
|
filePathOrModule = _valueOfPlaceholder$s6[1];
|
|
255
|
-
const content = fs__default["default"].readFileSync(require.resolve(filePathOrModule, {
|
|
265
|
+
const content = fs__default$1["default"].readFileSync(require.resolve(filePathOrModule, {
|
|
256
266
|
// Relative paths should be resolved from the application folder.
|
|
257
267
|
paths: [loadingOptions.applicationPath]
|
|
258
268
|
}), {
|
|
@@ -1241,7 +1251,7 @@ const getRuntimeEnvironmentConfig = _ref2 => {
|
|
|
1241
1251
|
// Keep a reference to the config so that requiring the module
|
|
1242
1252
|
// again will result in returning the cached value.
|
|
1243
1253
|
let cachedConfig;
|
|
1244
|
-
const processConfig = function () {
|
|
1254
|
+
const processConfig = async function () {
|
|
1245
1255
|
var _context;
|
|
1246
1256
|
let _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1247
1257
|
_ref3$disableCache = _ref3.disableCache,
|
|
@@ -1249,11 +1259,11 @@ const processConfig = function () {
|
|
|
1249
1259
|
_ref3$processEnv = _ref3.processEnv,
|
|
1250
1260
|
processEnv = _ref3$processEnv === void 0 ? process.env : _ref3$processEnv,
|
|
1251
1261
|
_ref3$applicationPath = _ref3.applicationPath,
|
|
1252
|
-
applicationPath = _ref3$applicationPath === void 0 ? fs__default["default"].realpathSync(process.cwd()) : _ref3$applicationPath;
|
|
1262
|
+
applicationPath = _ref3$applicationPath === void 0 ? fs__default$1["default"].realpathSync(process.cwd()) : _ref3$applicationPath;
|
|
1253
1263
|
if (cachedConfig && !disableCache) return cachedConfig;
|
|
1254
|
-
const
|
|
1255
|
-
filepath =
|
|
1256
|
-
rawConfig =
|
|
1264
|
+
const _await$loadConfig = await loadConfig(applicationPath),
|
|
1265
|
+
filepath = _await$loadConfig.filepath,
|
|
1266
|
+
rawConfig = _await$loadConfig.config;
|
|
1257
1267
|
const configType = getLoadedConfigurationType(path.parse(filepath).name);
|
|
1258
1268
|
validateConfig(configType, rawConfig);
|
|
1259
1269
|
const appConfig = substituteVariablePlaceholders(rawConfig, {
|
|
@@ -14,12 +14,16 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
14
14
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
15
15
|
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
16
16
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
17
|
-
var fs = require('node:fs');
|
|
17
|
+
var fs$1 = require('node:fs');
|
|
18
18
|
var path = require('node:path');
|
|
19
19
|
var omitEmpty = require('omit-empty-es');
|
|
20
20
|
var constants = require('@commercetools-frontend/constants');
|
|
21
|
-
var
|
|
21
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
22
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
23
|
+
var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
|
|
24
|
+
var fs = require('node:fs/promises');
|
|
22
25
|
var cosmiconfig = require('cosmiconfig');
|
|
26
|
+
var cosmiconfigTypescriptLoader = require('cosmiconfig-typescript-loader');
|
|
23
27
|
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
24
28
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
25
29
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
@@ -28,12 +32,10 @@ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
|
28
32
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
29
33
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
30
34
|
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
31
|
-
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
32
35
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
33
36
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
34
37
|
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
35
38
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
36
|
-
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
37
39
|
var formatters = require('./formatters-7f327585.cjs.prod.js');
|
|
38
40
|
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
39
41
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
@@ -58,15 +60,17 @@ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defin
|
|
|
58
60
|
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
59
61
|
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
60
62
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
61
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
63
|
+
var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
|
|
62
64
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
63
65
|
var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
|
|
66
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
67
|
+
var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
68
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
64
69
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
65
70
|
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
66
71
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
67
72
|
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
68
73
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
69
|
-
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
70
74
|
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
71
75
|
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
72
76
|
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
@@ -126,65 +130,71 @@ let MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
|
|
|
126
130
|
return _createClass(MissingOrInvalidConfigError);
|
|
127
131
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
128
132
|
|
|
129
|
-
|
|
133
|
+
// See the following issues for more context, contributing to failing Jest tests:
|
|
134
|
+
// - Issue: https://github.com/nodejs/node/issues/40058
|
|
135
|
+
// - Resolution: https://github.com/nodejs/node/pull/48510 (Node v20.8.0)
|
|
136
|
+
// Copied from @commitlint/load/src/utils/load-config.ts
|
|
137
|
+
const isDynamicAwaitSupported = () => {
|
|
138
|
+
var _context;
|
|
139
|
+
const _process$version$repl = _mapInstanceProperty__default["default"](_context = process.version.replace('v', '').split('.')).call(_context, val => _parseInt__default["default"](val)),
|
|
140
|
+
_process$version$repl2 = _slicedToArray(_process$version$repl, 2),
|
|
141
|
+
major = _process$version$repl2[0],
|
|
142
|
+
minor = _process$version$repl2[1];
|
|
143
|
+
return major >= 20 && minor >= 8;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Is the given directory set up to use ESM (ECMAScript Modules)?
|
|
147
|
+
// Copied from @commitlint/load/src/utils/load-config.ts
|
|
148
|
+
const isEsmModule = async cwd => {
|
|
149
|
+
const packagePath = path__default["default"].join(cwd, 'package.json');
|
|
130
150
|
try {
|
|
131
|
-
fs__default["default"].
|
|
132
|
-
|
|
151
|
+
const packageJSON = await fs__default["default"].readFile(packagePath, {
|
|
152
|
+
encoding: 'utf-8'
|
|
153
|
+
});
|
|
154
|
+
return JSON.parse(packageJSON)?.type === 'module';
|
|
133
155
|
} catch (error) {
|
|
134
156
|
return false;
|
|
135
157
|
}
|
|
136
|
-
}
|
|
137
|
-
// Helper function to find the package root path from the current location,
|
|
138
|
-
// for instance in respect to both source files and dist files.
|
|
139
|
-
const findPackageRootPath = dir => {
|
|
140
|
-
const packageJsonPath = path__default["default"].join(dir, 'package.json');
|
|
141
|
-
if (doesFileExist(packageJsonPath)) {
|
|
142
|
-
return dir;
|
|
143
|
-
}
|
|
144
|
-
const parentDir = path__default["default"].join(dir, '..');
|
|
145
|
-
return findPackageRootPath(parentDir);
|
|
146
158
|
};
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return cosmiconfig.cosmiconfigSync(configFileName, {
|
|
164
|
-
// Restrict the supported file formats / names
|
|
165
|
-
searchPlaces: [`.${configFileName}rc`, `.${configFileName}.json`, `.${configFileName}.js`, `.${configFileName}.cjs`, `.${configFileName}.mjs`, `.${configFileName}.ts`, `${configFileName}.json`, `${configFileName}.js`, `${configFileName}.cjs`, `${configFileName}.mjs`, `${configFileName}.ts`],
|
|
159
|
+
const createExplorerFor = async configFileName => {
|
|
160
|
+
// Copied from @commitlint/load/src/utils/load-config.ts
|
|
161
|
+
let tsLoaderInstance;
|
|
162
|
+
const tsLoader = function () {
|
|
163
|
+
if (!tsLoaderInstance) {
|
|
164
|
+
tsLoaderInstance = cosmiconfigTypescriptLoader.TypeScriptLoader();
|
|
165
|
+
}
|
|
166
|
+
return tsLoaderInstance(...arguments);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// If dynamic await is supported (Node >= v20.8.0) or directory uses ESM, support
|
|
170
|
+
// async js/cjs loaders (dynamic import). Otherwise, use synchronous js/cjs loaders.
|
|
171
|
+
const loaders = isDynamicAwaitSupported() || (await isEsmModule(process.cwd())) ? cosmiconfig.defaultLoaders : cosmiconfig.defaultLoadersSync;
|
|
172
|
+
return cosmiconfig.cosmiconfig(configFileName, {
|
|
173
|
+
searchStrategy: 'project',
|
|
174
|
+
searchPlaces: [`${configFileName}.js`, `${configFileName}.cjs`, `${configFileName}.mjs`, `${configFileName}.ts`],
|
|
166
175
|
loaders: {
|
|
167
|
-
|
|
168
|
-
'.
|
|
169
|
-
'.
|
|
170
|
-
'.
|
|
171
|
-
'.ts': loadJsModule
|
|
176
|
+
'.js': loaders['.js'],
|
|
177
|
+
'.cjs': loaders['.cjs'],
|
|
178
|
+
'.mjs': tsLoader,
|
|
179
|
+
'.ts': tsLoader
|
|
172
180
|
}
|
|
173
181
|
});
|
|
174
182
|
};
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
const
|
|
178
|
-
const customApplicationConfigFile = customApplicationExplorer.search();
|
|
179
|
-
const customViewConfigFile = customViewExplorer.search();
|
|
183
|
+
const getConfigPath = async () => {
|
|
184
|
+
const customApplicationExplorer = await createExplorerFor('custom-application-config');
|
|
185
|
+
const customViewExplorer = await createExplorerFor('custom-view-config');
|
|
186
|
+
const customApplicationConfigFile = await customApplicationExplorer.search();
|
|
187
|
+
const customViewConfigFile = await customViewExplorer.search();
|
|
180
188
|
if (!customApplicationConfigFile && !customViewConfigFile) {
|
|
181
189
|
throw new Error(`Missing or invalid configuration file.`);
|
|
182
190
|
}
|
|
183
191
|
return customApplicationConfigFile?.filepath || customViewConfigFile?.filepath;
|
|
184
192
|
};
|
|
185
|
-
const loadConfig = applicationPath => {
|
|
186
|
-
const
|
|
187
|
-
const
|
|
193
|
+
const loadConfig = async applicationPath => {
|
|
194
|
+
const customApplicationExplorer = await createExplorerFor('custom-application-config');
|
|
195
|
+
const customViewExplorer = await createExplorerFor('custom-view-config');
|
|
196
|
+
const customApplicationConfigFile = await customApplicationExplorer.search(applicationPath);
|
|
197
|
+
const customViewConfigFile = await customViewExplorer.search(applicationPath);
|
|
188
198
|
if ((!customApplicationConfigFile || !customApplicationConfigFile.config) && (!customViewConfigFile || !customViewConfigFile.config)) {
|
|
189
199
|
throw new MissingOrInvalidConfigError(`Missing or invalid configuration file.`);
|
|
190
200
|
}
|
|
@@ -252,7 +262,7 @@ const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString
|
|
|
252
262
|
const _valueOfPlaceholder$s5 = valueOfPlaceholder.split(':'),
|
|
253
263
|
_valueOfPlaceholder$s6 = _slicedToArray(_valueOfPlaceholder$s5, 2),
|
|
254
264
|
filePathOrModule = _valueOfPlaceholder$s6[1];
|
|
255
|
-
const content = fs__default["default"].readFileSync(require.resolve(filePathOrModule, {
|
|
265
|
+
const content = fs__default$1["default"].readFileSync(require.resolve(filePathOrModule, {
|
|
256
266
|
// Relative paths should be resolved from the application folder.
|
|
257
267
|
paths: [loadingOptions.applicationPath]
|
|
258
268
|
}), {
|
|
@@ -1241,7 +1251,7 @@ const getRuntimeEnvironmentConfig = _ref2 => {
|
|
|
1241
1251
|
// Keep a reference to the config so that requiring the module
|
|
1242
1252
|
// again will result in returning the cached value.
|
|
1243
1253
|
let cachedConfig;
|
|
1244
|
-
const processConfig = function () {
|
|
1254
|
+
const processConfig = async function () {
|
|
1245
1255
|
var _context;
|
|
1246
1256
|
let _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1247
1257
|
_ref3$disableCache = _ref3.disableCache,
|
|
@@ -1249,11 +1259,11 @@ const processConfig = function () {
|
|
|
1249
1259
|
_ref3$processEnv = _ref3.processEnv,
|
|
1250
1260
|
processEnv = _ref3$processEnv === void 0 ? process.env : _ref3$processEnv,
|
|
1251
1261
|
_ref3$applicationPath = _ref3.applicationPath,
|
|
1252
|
-
applicationPath = _ref3$applicationPath === void 0 ? fs__default["default"].realpathSync(process.cwd()) : _ref3$applicationPath;
|
|
1262
|
+
applicationPath = _ref3$applicationPath === void 0 ? fs__default$1["default"].realpathSync(process.cwd()) : _ref3$applicationPath;
|
|
1253
1263
|
if (cachedConfig && !disableCache) return cachedConfig;
|
|
1254
|
-
const
|
|
1255
|
-
filepath =
|
|
1256
|
-
rawConfig =
|
|
1264
|
+
const _await$loadConfig = await loadConfig(applicationPath),
|
|
1265
|
+
filepath = _await$loadConfig.filepath,
|
|
1266
|
+
rawConfig = _await$loadConfig.config;
|
|
1257
1267
|
const configType = getLoadedConfigurationType(path.parse(filepath).name);
|
|
1258
1268
|
validateConfig(configType, rawConfig);
|
|
1259
1269
|
const appConfig = substituteVariablePlaceholders(rawConfig, {
|
|
@@ -10,13 +10,17 @@ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
|
10
10
|
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
11
11
|
import _URL from '@babel/runtime-corejs3/core-js-stable/url';
|
|
12
12
|
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
13
|
-
import fs from 'node:fs';
|
|
13
|
+
import fs$1 from 'node:fs';
|
|
14
14
|
import path, { parse } from 'node:path';
|
|
15
15
|
import omitEmpty from 'omit-empty-es';
|
|
16
16
|
import { ENTRY_POINT_URI_PATH_REGEX, PERMISSION_GROUP_NAME_REGEX, CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH } from '@commercetools-frontend/constants';
|
|
17
17
|
export { ENTRY_POINT_URI_PATH_REGEX, PERMISSION_GROUP_NAME_REGEX } from '@commercetools-frontend/constants';
|
|
18
|
-
import
|
|
19
|
-
import
|
|
18
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
19
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
20
|
+
import _parseInt from '@babel/runtime-corejs3/core-js-stable/parse-int';
|
|
21
|
+
import fs from 'node:fs/promises';
|
|
22
|
+
import { defaultLoaders, defaultLoadersSync, cosmiconfig } from 'cosmiconfig';
|
|
23
|
+
import { TypeScriptLoader } from 'cosmiconfig-typescript-loader';
|
|
20
24
|
import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
|
|
21
25
|
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
22
26
|
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
@@ -25,12 +29,10 @@ import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
|
25
29
|
import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
|
|
26
30
|
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
27
31
|
import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
|
|
28
|
-
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
29
32
|
import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
|
|
30
33
|
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
31
34
|
import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
|
|
32
35
|
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
33
|
-
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
34
36
|
import { f as formatEntryPointUriPathToResourceAccessKey, e as entryPointUriPathToResourceAccesses } from './formatters-882eafa8.esm.js';
|
|
35
37
|
import _Set from '@babel/runtime-corejs3/core-js-stable/set';
|
|
36
38
|
import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
|
|
@@ -94,65 +96,71 @@ let MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
|
|
|
94
96
|
return _createClass(MissingOrInvalidConfigError);
|
|
95
97
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
96
98
|
|
|
97
|
-
|
|
99
|
+
// See the following issues for more context, contributing to failing Jest tests:
|
|
100
|
+
// - Issue: https://github.com/nodejs/node/issues/40058
|
|
101
|
+
// - Resolution: https://github.com/nodejs/node/pull/48510 (Node v20.8.0)
|
|
102
|
+
// Copied from @commitlint/load/src/utils/load-config.ts
|
|
103
|
+
const isDynamicAwaitSupported = () => {
|
|
104
|
+
var _context;
|
|
105
|
+
const _process$version$repl = _mapInstanceProperty(_context = process.version.replace('v', '').split('.')).call(_context, val => _parseInt(val)),
|
|
106
|
+
_process$version$repl2 = _slicedToArray(_process$version$repl, 2),
|
|
107
|
+
major = _process$version$repl2[0],
|
|
108
|
+
minor = _process$version$repl2[1];
|
|
109
|
+
return major >= 20 && minor >= 8;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Is the given directory set up to use ESM (ECMAScript Modules)?
|
|
113
|
+
// Copied from @commitlint/load/src/utils/load-config.ts
|
|
114
|
+
const isEsmModule = async cwd => {
|
|
115
|
+
const packagePath = path.join(cwd, 'package.json');
|
|
98
116
|
try {
|
|
99
|
-
fs.
|
|
100
|
-
|
|
117
|
+
const packageJSON = await fs.readFile(packagePath, {
|
|
118
|
+
encoding: 'utf-8'
|
|
119
|
+
});
|
|
120
|
+
return JSON.parse(packageJSON)?.type === 'module';
|
|
101
121
|
} catch (error) {
|
|
102
122
|
return false;
|
|
103
123
|
}
|
|
104
|
-
}
|
|
105
|
-
// Helper function to find the package root path from the current location,
|
|
106
|
-
// for instance in respect to both source files and dist files.
|
|
107
|
-
const findPackageRootPath = dir => {
|
|
108
|
-
const packageJsonPath = path.join(dir, 'package.json');
|
|
109
|
-
if (doesFileExist(packageJsonPath)) {
|
|
110
|
-
return dir;
|
|
111
|
-
}
|
|
112
|
-
const parentDir = path.join(dir, '..');
|
|
113
|
-
return findPackageRootPath(parentDir);
|
|
114
|
-
};
|
|
115
|
-
const loadJsModule = filePath => {
|
|
116
|
-
const packageRootPath = findPackageRootPath(
|
|
117
|
-
// Start from the parent folder
|
|
118
|
-
path.join(__dirname, '..'));
|
|
119
|
-
// Load the JS module using a child process. This is primarly to avoid
|
|
120
|
-
// unwanted behaviors using `@babel/register` in the main process.
|
|
121
|
-
// The loader script does the actual `require` of the given `filePath`
|
|
122
|
-
// and uses `@babel/register` to correctly parse and execute the file.
|
|
123
|
-
// The "required module output" is then written into `stdout` and parsed
|
|
124
|
-
// as JSON.
|
|
125
|
-
const output = execFileSync('node', [path.join(packageRootPath, 'scripts/load-js-module.js'), filePath], {
|
|
126
|
-
encoding: 'utf8'
|
|
127
|
-
});
|
|
128
|
-
return JSON.parse(output);
|
|
129
124
|
};
|
|
130
|
-
const createExplorerFor = configFileName => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
125
|
+
const createExplorerFor = async configFileName => {
|
|
126
|
+
// Copied from @commitlint/load/src/utils/load-config.ts
|
|
127
|
+
let tsLoaderInstance;
|
|
128
|
+
const tsLoader = function () {
|
|
129
|
+
if (!tsLoaderInstance) {
|
|
130
|
+
tsLoaderInstance = TypeScriptLoader();
|
|
131
|
+
}
|
|
132
|
+
return tsLoaderInstance(...arguments);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// If dynamic await is supported (Node >= v20.8.0) or directory uses ESM, support
|
|
136
|
+
// async js/cjs loaders (dynamic import). Otherwise, use synchronous js/cjs loaders.
|
|
137
|
+
const loaders = isDynamicAwaitSupported() || (await isEsmModule(process.cwd())) ? defaultLoaders : defaultLoadersSync;
|
|
138
|
+
return cosmiconfig(configFileName, {
|
|
139
|
+
searchStrategy: 'project',
|
|
140
|
+
searchPlaces: [`${configFileName}.js`, `${configFileName}.cjs`, `${configFileName}.mjs`, `${configFileName}.ts`],
|
|
134
141
|
loaders: {
|
|
135
|
-
|
|
136
|
-
'.
|
|
137
|
-
'.
|
|
138
|
-
'.
|
|
139
|
-
'.ts': loadJsModule
|
|
142
|
+
'.js': loaders['.js'],
|
|
143
|
+
'.cjs': loaders['.cjs'],
|
|
144
|
+
'.mjs': tsLoader,
|
|
145
|
+
'.ts': tsLoader
|
|
140
146
|
}
|
|
141
147
|
});
|
|
142
148
|
};
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
const customApplicationConfigFile = customApplicationExplorer.search();
|
|
147
|
-
const customViewConfigFile = customViewExplorer.search();
|
|
149
|
+
const getConfigPath = async () => {
|
|
150
|
+
const customApplicationExplorer = await createExplorerFor('custom-application-config');
|
|
151
|
+
const customViewExplorer = await createExplorerFor('custom-view-config');
|
|
152
|
+
const customApplicationConfigFile = await customApplicationExplorer.search();
|
|
153
|
+
const customViewConfigFile = await customViewExplorer.search();
|
|
148
154
|
if (!customApplicationConfigFile && !customViewConfigFile) {
|
|
149
155
|
throw new Error(`Missing or invalid configuration file.`);
|
|
150
156
|
}
|
|
151
157
|
return customApplicationConfigFile?.filepath || customViewConfigFile?.filepath;
|
|
152
158
|
};
|
|
153
|
-
const loadConfig = applicationPath => {
|
|
154
|
-
const
|
|
155
|
-
const
|
|
159
|
+
const loadConfig = async applicationPath => {
|
|
160
|
+
const customApplicationExplorer = await createExplorerFor('custom-application-config');
|
|
161
|
+
const customViewExplorer = await createExplorerFor('custom-view-config');
|
|
162
|
+
const customApplicationConfigFile = await customApplicationExplorer.search(applicationPath);
|
|
163
|
+
const customViewConfigFile = await customViewExplorer.search(applicationPath);
|
|
156
164
|
if ((!customApplicationConfigFile || !customApplicationConfigFile.config) && (!customViewConfigFile || !customViewConfigFile.config)) {
|
|
157
165
|
throw new MissingOrInvalidConfigError(`Missing or invalid configuration file.`);
|
|
158
166
|
}
|
|
@@ -220,7 +228,7 @@ const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString
|
|
|
220
228
|
const _valueOfPlaceholder$s5 = valueOfPlaceholder.split(':'),
|
|
221
229
|
_valueOfPlaceholder$s6 = _slicedToArray(_valueOfPlaceholder$s5, 2),
|
|
222
230
|
filePathOrModule = _valueOfPlaceholder$s6[1];
|
|
223
|
-
const content = fs.readFileSync(require.resolve(filePathOrModule, {
|
|
231
|
+
const content = fs$1.readFileSync(require.resolve(filePathOrModule, {
|
|
224
232
|
// Relative paths should be resolved from the application folder.
|
|
225
233
|
paths: [loadingOptions.applicationPath]
|
|
226
234
|
}), {
|
|
@@ -1209,7 +1217,7 @@ const getRuntimeEnvironmentConfig = _ref2 => {
|
|
|
1209
1217
|
// Keep a reference to the config so that requiring the module
|
|
1210
1218
|
// again will result in returning the cached value.
|
|
1211
1219
|
let cachedConfig;
|
|
1212
|
-
const processConfig = function () {
|
|
1220
|
+
const processConfig = async function () {
|
|
1213
1221
|
var _context;
|
|
1214
1222
|
let _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1215
1223
|
_ref3$disableCache = _ref3.disableCache,
|
|
@@ -1217,11 +1225,11 @@ const processConfig = function () {
|
|
|
1217
1225
|
_ref3$processEnv = _ref3.processEnv,
|
|
1218
1226
|
processEnv = _ref3$processEnv === void 0 ? process.env : _ref3$processEnv,
|
|
1219
1227
|
_ref3$applicationPath = _ref3.applicationPath,
|
|
1220
|
-
applicationPath = _ref3$applicationPath === void 0 ? fs.realpathSync(process.cwd()) : _ref3$applicationPath;
|
|
1228
|
+
applicationPath = _ref3$applicationPath === void 0 ? fs$1.realpathSync(process.cwd()) : _ref3$applicationPath;
|
|
1221
1229
|
if (cachedConfig && !disableCache) return cachedConfig;
|
|
1222
|
-
const
|
|
1223
|
-
filepath =
|
|
1224
|
-
rawConfig =
|
|
1230
|
+
const _await$loadConfig = await loadConfig(applicationPath),
|
|
1231
|
+
filepath = _await$loadConfig.filepath,
|
|
1232
|
+
rawConfig = _await$loadConfig.config;
|
|
1225
1233
|
const configType = getLoadedConfigurationType(parse(filepath).name);
|
|
1226
1234
|
validateConfig(configType, rawConfig);
|
|
1227
1235
|
const appConfig = substituteVariablePlaceholders(rawConfig, {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { JSONSchemaForCustomApplicationConfigurationFiles } from './schemas/generated/custom-application.schema';
|
|
2
2
|
import type { JSONSchemaForCustomViewConfigurationFiles } from './schemas/generated/custom-view.schema';
|
|
3
|
-
export declare const
|
|
4
|
-
declare const
|
|
3
|
+
export declare const isDynamicAwaitSupported: () => boolean;
|
|
4
|
+
export declare const isEsmModule: (cwd: string) => Promise<boolean>;
|
|
5
|
+
export declare const getConfigPath: () => Promise<string | undefined>;
|
|
6
|
+
export type TLoadConfigResult = {
|
|
5
7
|
filepath: string;
|
|
6
8
|
config: JSONSchemaForCustomApplicationConfigurationFiles | JSONSchemaForCustomViewConfigurationFiles;
|
|
7
9
|
};
|
|
10
|
+
declare const loadConfig: (applicationPath: string) => Promise<TLoadConfigResult>;
|
|
8
11
|
export default loadConfig;
|
|
@@ -2,5 +2,5 @@ import type { ApplicationRuntimeConfig, LoadingConfigOptions } from './types';
|
|
|
2
2
|
type ProcessConfigOptions = Partial<LoadingConfigOptions> & {
|
|
3
3
|
disableCache?: boolean;
|
|
4
4
|
};
|
|
5
|
-
declare const processConfig: ({ disableCache, processEnv, applicationPath, }?: ProcessConfigOptions) => ApplicationRuntimeConfig
|
|
5
|
+
declare const processConfig: ({ disableCache, processEnv, applicationPath, }?: ProcessConfigOptions) => Promise<ApplicationRuntimeConfig>;
|
|
6
6
|
export default processConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/application-config",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.37.0",
|
|
4
4
|
"description": "Configuration utilities for building Custom Applications",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"@babel/register": "^7.22.15",
|
|
46
46
|
"@babel/runtime": "^7.22.15",
|
|
47
47
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
48
|
-
"@commercetools-frontend/
|
|
49
|
-
"@commercetools-frontend/constants": "22.36.0",
|
|
48
|
+
"@commercetools-frontend/constants": "22.37.0",
|
|
50
49
|
"@types/dompurify": "^2.4.0",
|
|
51
50
|
"@types/lodash": "^4.14.198",
|
|
52
51
|
"@types/react": "^17.0.80",
|
|
53
52
|
"ajv": "8.16.0",
|
|
54
53
|
"core-js": "^3.32.2",
|
|
55
|
-
"cosmiconfig": "
|
|
54
|
+
"cosmiconfig": "9.0.0",
|
|
55
|
+
"cosmiconfig-typescript-loader": "6.1.0",
|
|
56
56
|
"dompurify": "^2.4.7",
|
|
57
57
|
"jsdom": "^21.1.2",
|
|
58
58
|
"lodash": "4.17.21",
|
|
@@ -61,8 +61,7 @@
|
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/jsdom": "^21.1.2",
|
|
63
63
|
"json-schema-to-typescript": "13.1.2",
|
|
64
|
-
"
|
|
65
|
-
"@commercetools-frontend/assets": "22.36.0"
|
|
64
|
+
"@commercetools-frontend/assets": "22.37.0"
|
|
66
65
|
},
|
|
67
66
|
"engines": {
|
|
68
67
|
"node": "16.x || >=18.0.0"
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This script file is used to load and parse a JS module in a child process,
|
|
3
|
-
* to isolate the Babel configuration from the main program and avoid causing
|
|
4
|
-
* unnecessary issues.
|
|
5
|
-
*
|
|
6
|
-
* NOTE: keep this file as a `.js` file, as we want to be able to run this
|
|
7
|
-
* in any Node environment.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
// Ensure there is a babel/node environment variable set, otherwise the
|
|
11
|
-
// babel preset throws an error.
|
|
12
|
-
process.env.BABEL_ENV = 'development';
|
|
13
|
-
|
|
14
|
-
const get = require('lodash/get');
|
|
15
|
-
|
|
16
|
-
// Load JS modules using Babel, as we need to load
|
|
17
|
-
// the config synchronously with `require`, no `await import`.
|
|
18
|
-
require('@babel/register')({
|
|
19
|
-
babelrc: false,
|
|
20
|
-
extensions: ['.js', '.cjs', '.mjs', '.ts'],
|
|
21
|
-
presets: ['@commercetools-frontend/babel-preset-mc-app'],
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// The file to `require` is passed as the main argument to this script file.
|
|
25
|
-
const [filePath] = process.argv.slice(2);
|
|
26
|
-
|
|
27
|
-
// Require the module. It's expected that the module exports the application config
|
|
28
|
-
const moduleExport = require(filePath);
|
|
29
|
-
|
|
30
|
-
// In case we are loading an ES module, we need to pick the `default` export.
|
|
31
|
-
const result = get(moduleExport, 'default', moduleExport);
|
|
32
|
-
|
|
33
|
-
// Write the application config to `stdout`so that the main program can read it.
|
|
34
|
-
process.stdout.write(JSON.stringify(result));
|