@intlayer/config 5.2.9 → 5.3.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/cjs/configFile/loadConfigurationFile.cjs +3 -59
- package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
- package/dist/cjs/index.cjs +3 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/loadExternalFile.cjs +101 -0
- package/dist/cjs/loadExternalFile.cjs.map +1 -0
- package/dist/esm/configFile/loadConfigurationFile.mjs +3 -59
- package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/loadExternalFile.mjs +77 -0
- package/dist/esm/loadExternalFile.mjs.map +1 -0
- package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/loadExternalFile.d.ts +8 -0
- package/dist/types/loadExternalFile.d.ts.map +1 -0
- package/package.json +5 -4
|
@@ -21,71 +21,15 @@ __export(loadConfigurationFile_exports, {
|
|
|
21
21
|
loadConfigurationFile: () => loadConfigurationFile
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(loadConfigurationFile_exports);
|
|
24
|
-
var import_vm = require("vm");
|
|
25
|
-
var import_esbuild = require("esbuild");
|
|
26
|
-
var import_getSandboxContext = require('../getSandboxContext.cjs');
|
|
27
24
|
var import_logger = require('../logger.cjs');
|
|
28
|
-
var
|
|
29
|
-
const getTransformationOptions = () => {
|
|
30
|
-
const define = {};
|
|
31
|
-
for (const k in process.env) {
|
|
32
|
-
define[`process.env.${k}`] = JSON.stringify(process.env[k]);
|
|
33
|
-
}
|
|
34
|
-
const transformationOption = {
|
|
35
|
-
loader: {
|
|
36
|
-
".js": "js",
|
|
37
|
-
".jsx": "jsx",
|
|
38
|
-
".mjs": "js",
|
|
39
|
-
".ts": "ts",
|
|
40
|
-
".tsx": "tsx",
|
|
41
|
-
".cjs": "js",
|
|
42
|
-
".json": "json"
|
|
43
|
-
},
|
|
44
|
-
format: "cjs",
|
|
45
|
-
// Output format as commonjs
|
|
46
|
-
target: "es2017",
|
|
47
|
-
packages: "external",
|
|
48
|
-
write: false,
|
|
49
|
-
bundle: true,
|
|
50
|
-
define
|
|
51
|
-
};
|
|
52
|
-
return transformationOption;
|
|
53
|
-
};
|
|
25
|
+
var import_loadExternalFile = require('../loadExternalFile.cjs');
|
|
54
26
|
const filterValidConfiguration = (configuration) => {
|
|
55
27
|
return configuration;
|
|
56
28
|
};
|
|
57
29
|
const loadConfigurationFile = (configFilePath, envVarOptions) => {
|
|
58
|
-
let customConfiguration = void 0;
|
|
59
|
-
const configFileExtension = configFilePath.split(".").pop() ?? "";
|
|
60
30
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
const sandboxContext = (0, import_getSandboxContext.getSandBoxContext)(envVarOptions);
|
|
65
|
-
const moduleResult = (0, import_esbuild.buildSync)({
|
|
66
|
-
entryPoints: [configFilePath],
|
|
67
|
-
...getTransformationOptions()
|
|
68
|
-
});
|
|
69
|
-
const moduleResultString = moduleResult.outputFiles?.[0].text;
|
|
70
|
-
if (!moduleResultString) {
|
|
71
|
-
(0, import_logger.logger)("Configuration file could not be loaded.", { level: "error" });
|
|
72
|
-
return void 0;
|
|
73
|
-
}
|
|
74
|
-
(0, import_vm.runInNewContext)(moduleResultString, sandboxContext);
|
|
75
|
-
if (sandboxContext.exports.default && Object.keys(sandboxContext.exports.default).length > 0) {
|
|
76
|
-
customConfiguration = sandboxContext.exports.default;
|
|
77
|
-
} else if (sandboxContext.module.exports.defaults && Object.keys(sandboxContext.module.exports.defaults).length > 0) {
|
|
78
|
-
customConfiguration = sandboxContext.module.exports.default;
|
|
79
|
-
} else if (sandboxContext.module.exports.default && Object.keys(sandboxContext.module.exports.default).length > 0) {
|
|
80
|
-
customConfiguration = sandboxContext.module.exports.default;
|
|
81
|
-
} else if (sandboxContext.module.exports && Object.keys(sandboxContext.module.exports).length > 0) {
|
|
82
|
-
customConfiguration = sandboxContext.module.exports;
|
|
83
|
-
}
|
|
84
|
-
if (typeof customConfiguration === "undefined") {
|
|
85
|
-
(0, import_logger.logger)("Configuration file could not be loaded.");
|
|
86
|
-
return void 0;
|
|
87
|
-
}
|
|
88
|
-
return filterValidConfiguration(customConfiguration);
|
|
31
|
+
const fileContent = (0, import_loadExternalFile.loadExternalFile)(configFilePath, envVarOptions);
|
|
32
|
+
return filterValidConfiguration(fileContent);
|
|
89
33
|
} catch (error) {
|
|
90
34
|
(0, import_logger.logger)(
|
|
91
35
|
`Error: ${error} ${JSON.stringify(error.stack, null, 2)}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import { type LoadEnvFileOptions } from '../envVariables/loadEnvFile';\nimport { logger } from '../logger';\nimport type { CustomIntlayerConfig } from '../types/config';\nimport { loadExternalFile } from '../loadExternalFile';\n\nconst filterValidConfiguration = (\n configuration: CustomIntlayerConfig\n): CustomIntlayerConfig => {\n // @TODO Implement filtering of valid configuration\n return configuration;\n};\n\n/**\n * Load the configuration file from the given path\n * Example of configuration file: intlayer.config.js\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadConfigurationFile = (\n configFilePath: string,\n envVarOptions?: LoadEnvFileOptions\n): CustomIntlayerConfig | undefined => {\n try {\n const fileContent = loadExternalFile(configFilePath, envVarOptions);\n\n return filterValidConfiguration(fileContent);\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AAEvB,8BAAiC;AAEjC,MAAM,2BAA2B,CAC/B,kBACyB;AAEzB,SAAO;AACT;AAQO,MAAM,wBAAwB,CACnC,gBACA,kBACqC;AACrC,MAAI;AACF,UAAM,kBAAc,0CAAiB,gBAAgB,aAAa;AAElE,WAAO,yBAAyB,WAAW;AAAA,EAC7C,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ __export(index_exports, {
|
|
|
27
27
|
getPlatform: () => import_envVariables.getPlatform,
|
|
28
28
|
getSandBoxContext: () => import_getSandboxContext.getSandBoxContext,
|
|
29
29
|
loadEnvFile: () => import_envVariables.loadEnvFile,
|
|
30
|
+
loadExternalFile: () => import_loadExternalFile.loadExternalFile,
|
|
30
31
|
logger: () => import_logger.logger
|
|
31
32
|
});
|
|
32
33
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -37,6 +38,7 @@ var import_ESMxCJSRequire = require('./utils/ESMxCJSRequire.cjs');
|
|
|
37
38
|
var import_logger = require('./logger.cjs');
|
|
38
39
|
var import_appLoggerServer = require('./appLoggerServer.cjs');
|
|
39
40
|
var import_getSandboxContext = require('./getSandboxContext.cjs');
|
|
41
|
+
var import_loadExternalFile = require('./loadExternalFile.cjs');
|
|
40
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
43
|
0 && (module.exports = {
|
|
42
44
|
ESMxCJSRequire,
|
|
@@ -48,6 +50,7 @@ var import_getSandboxContext = require('./getSandboxContext.cjs');
|
|
|
48
50
|
getPlatform,
|
|
49
51
|
getSandBoxContext,
|
|
50
52
|
loadEnvFile,
|
|
53
|
+
loadExternalFile,
|
|
51
54
|
logger
|
|
52
55
|
});
|
|
53
56
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n getConfiguration,\n type GetConfigurationOptions,\n} from './configFile/getConfiguration';\n\nexport type {\n InternationalizationConfig,\n ServerSetCookieRule,\n MiddlewareConfig,\n CustomIntlayerConfig,\n BaseContentConfig,\n BaseDerivedConfig,\n ResultDirDerivedConfig,\n PatternsContentConfig,\n ContentConfig,\n LogConfig,\n StrictMode,\n IntlayerConfig,\n} from './types/config';\nexport type { LocalesValues } from './types/locales';\nexport { Locales } from './types/locales';\nexport {\n formatEnvVariable,\n getConfiguration as getClientConfiguration,\n loadEnvFile,\n getPlatform,\n} from './envVariables/index';\nexport { ESMxCJSRequire } from './utils/ESMxCJSRequire';\nexport { logger } from './logger';\nexport { appLogger } from './appLoggerServer';\nexport { getSandBoxContext } from './getSandboxContext';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAGO;AAiBP,qBAAwB;AACxB,0BAKO;AACP,4BAA+B;AAC/B,oBAAuB;AACvB,6BAA0B;AAC1B,+BAAkC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n getConfiguration,\n type GetConfigurationOptions,\n} from './configFile/getConfiguration';\n\nexport type {\n InternationalizationConfig,\n ServerSetCookieRule,\n MiddlewareConfig,\n CustomIntlayerConfig,\n BaseContentConfig,\n BaseDerivedConfig,\n ResultDirDerivedConfig,\n PatternsContentConfig,\n ContentConfig,\n LogConfig,\n StrictMode,\n IntlayerConfig,\n} from './types/config';\nexport type { LocalesValues } from './types/locales';\nexport { Locales } from './types/locales';\nexport {\n formatEnvVariable,\n getConfiguration as getClientConfiguration,\n loadEnvFile,\n getPlatform,\n} from './envVariables/index';\nexport { ESMxCJSRequire } from './utils/ESMxCJSRequire';\nexport { logger } from './logger';\nexport { appLogger } from './appLoggerServer';\nexport { getSandBoxContext } from './getSandboxContext';\nexport { loadExternalFile } from './loadExternalFile';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAGO;AAiBP,qBAAwB;AACxB,0BAKO;AACP,4BAA+B;AAC/B,oBAAuB;AACvB,6BAA0B;AAC1B,+BAAkC;AAClC,8BAAiC;","names":[]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var loadExternalFile_exports = {};
|
|
20
|
+
__export(loadExternalFile_exports, {
|
|
21
|
+
loadExternalFile: () => loadExternalFile
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(loadExternalFile_exports);
|
|
24
|
+
var import_vm = require("vm");
|
|
25
|
+
var import_esbuild = require("esbuild");
|
|
26
|
+
var import_getSandboxContext = require('./getSandboxContext.cjs');
|
|
27
|
+
var import_ESMxCJSRequire = require('./utils/ESMxCJSRequire.cjs');
|
|
28
|
+
var import_logger = require('./logger.cjs');
|
|
29
|
+
const getTransformationOptions = () => {
|
|
30
|
+
const define = {};
|
|
31
|
+
for (const k in process.env) {
|
|
32
|
+
define[`process.env.${k}`] = JSON.stringify(process.env[k]);
|
|
33
|
+
}
|
|
34
|
+
const transformationOption = {
|
|
35
|
+
loader: {
|
|
36
|
+
".js": "js",
|
|
37
|
+
".jsx": "jsx",
|
|
38
|
+
".mjs": "js",
|
|
39
|
+
".ts": "ts",
|
|
40
|
+
".tsx": "tsx",
|
|
41
|
+
".cjs": "js",
|
|
42
|
+
".json": "json",
|
|
43
|
+
".md": "text",
|
|
44
|
+
".mdx": "text"
|
|
45
|
+
},
|
|
46
|
+
format: "cjs",
|
|
47
|
+
// Output format as commonjs
|
|
48
|
+
target: "es2017",
|
|
49
|
+
packages: "external",
|
|
50
|
+
write: false,
|
|
51
|
+
bundle: true,
|
|
52
|
+
define
|
|
53
|
+
};
|
|
54
|
+
return transformationOption;
|
|
55
|
+
};
|
|
56
|
+
const loadExternalFile = (filePath, envVarOptions) => {
|
|
57
|
+
let fileContent = void 0;
|
|
58
|
+
const fileExtension = filePath.split(".").pop() ?? "";
|
|
59
|
+
try {
|
|
60
|
+
if (fileExtension === "json") {
|
|
61
|
+
return (0, import_ESMxCJSRequire.ESMxCJSRequire)(filePath);
|
|
62
|
+
}
|
|
63
|
+
const moduleResult = (0, import_esbuild.buildSync)({
|
|
64
|
+
entryPoints: [filePath],
|
|
65
|
+
...getTransformationOptions()
|
|
66
|
+
});
|
|
67
|
+
const moduleResultString = moduleResult.outputFiles?.[0].text;
|
|
68
|
+
if (!moduleResultString) {
|
|
69
|
+
(0, import_logger.logger)("File could not be loaded.", { level: "error" });
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
72
|
+
const sandboxContext = (0, import_getSandboxContext.getSandBoxContext)(envVarOptions);
|
|
73
|
+
(0, import_vm.runInNewContext)(moduleResultString, sandboxContext);
|
|
74
|
+
if (sandboxContext.exports.default && Object.keys(sandboxContext.exports.default).length > 0) {
|
|
75
|
+
fileContent = sandboxContext.exports.default;
|
|
76
|
+
} else if (sandboxContext.module.exports.defaults && Object.keys(sandboxContext.module.exports.defaults).length > 0) {
|
|
77
|
+
fileContent = sandboxContext.module.exports.default;
|
|
78
|
+
} else if (sandboxContext.module.exports.default && Object.keys(sandboxContext.module.exports.default).length > 0) {
|
|
79
|
+
fileContent = sandboxContext.module.exports.default;
|
|
80
|
+
} else if (sandboxContext.module.exports && Object.keys(sandboxContext.module.exports).length > 0) {
|
|
81
|
+
fileContent = sandboxContext.module.exports;
|
|
82
|
+
}
|
|
83
|
+
if (typeof fileContent === "undefined") {
|
|
84
|
+
(0, import_logger.logger)(`File file could not be loaded. Path : ${filePath}`);
|
|
85
|
+
return void 0;
|
|
86
|
+
}
|
|
87
|
+
return fileContent;
|
|
88
|
+
} catch (error) {
|
|
89
|
+
(0, import_logger.logger)(
|
|
90
|
+
`Error: ${error} ${JSON.stringify(error.stack, null, 2)}`,
|
|
91
|
+
{
|
|
92
|
+
level: "error"
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
+
0 && (module.exports = {
|
|
99
|
+
loadExternalFile
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=loadExternalFile.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/loadExternalFile.ts"],"sourcesContent":["import { runInNewContext } from 'vm';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport { getSandBoxContext } from './getSandboxContext';\nimport { ESMxCJSRequire } from './utils/ESMxCJSRequire';\nimport { logger } from './logger';\nimport { LoadEnvFileOptions } from './envVariables/loadEnvFile';\n\nconst getTransformationOptions = (): BuildOptions => {\n const define: Record<string, string> = {};\n\n for (const k in process.env) {\n define[`process.env.${k}`] = JSON.stringify(process.env[k]);\n }\n\n const transformationOption: BuildOptions = {\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n define,\n };\n\n return transformationOption;\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = (\n filePath: string,\n envVarOptions?: LoadEnvFileOptions\n): any | undefined => {\n let fileContent: any | undefined = undefined;\n\n const fileExtension = filePath.split('.').pop() ?? '';\n\n try {\n if (fileExtension === 'json') {\n // Assume JSON\n return ESMxCJSRequire(filePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [filePath],\n ...getTransformationOptions(),\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const sandboxContext = getSandBoxContext(envVarOptions);\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n fileContent = sandboxContext.module.exports;\n }\n\n if (typeof fileContent === 'undefined') {\n logger(`File file could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAgC;AAChC,qBAA+D;AAC/D,+BAAkC;AAClC,4BAA+B;AAC/B,oBAAuB;AAGvB,MAAM,2BAA2B,MAAoB;AACnD,QAAM,SAAiC,CAAC;AAExC,aAAW,KAAK,QAAQ,KAAK;AAC3B,WAAO,eAAe,CAAC,EAAE,IAAI,KAAK,UAAU,QAAQ,IAAI,CAAC,CAAC;AAAA,EAC5D;AAEA,QAAM,uBAAqC;AAAA,IACzC,QAAQ;AAAA,MACN,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,OAAO;AAAA,MACP,QAAQ;AAAA,IACV;AAAA,IACA,QAAQ;AAAA;AAAA,IACR,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR;AAAA,EACF;AAEA,SAAO;AACT;AAOO,MAAM,mBAAmB,CAC9B,UACA,kBACoB;AACpB,MAAI,cAA+B;AAEnC,QAAM,gBAAgB,SAAS,MAAM,GAAG,EAAE,IAAI,KAAK;AAEnD,MAAI;AACF,QAAI,kBAAkB,QAAQ;AAE5B,iBAAO,sCAAe,QAAQ;AAAA,IAChC;AAIA,UAAM,mBAA4B,0BAAU;AAAA,MAC1C,aAAa,CAAC,QAAQ;AAAA,MACtB,GAAG,yBAAyB;AAAA,IAC9B,CAAC;AAED,UAAM,qBAAqB,aAAa,cAAc,CAAC,EAAE;AAEzD,QAAI,CAAC,oBAAoB;AACvB,gCAAO,6BAA6B,EAAE,OAAO,QAAQ,CAAC;AACtD,aAAO;AAAA,IACT;AAEA,UAAM,qBAAiB,4CAAkB,aAAa;AAEtD,mCAAgB,oBAAoB,cAAc;AAElD,QACE,eAAe,QAAQ,WACvB,OAAO,KAAK,eAAe,QAAQ,OAAO,EAAE,SAAS,GACrD;AAEA,oBAAc,eAAe,QAAQ;AAAA,IACvC,WACE,eAAe,OAAO,QAAQ,YAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,QAAQ,EAAE,SAAS,GAC7D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,QAAQ,WAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,OAAO,EAAE,SAAS,GAC5D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,WACtB,OAAO,KAAK,eAAe,OAAO,OAAO,EAAE,SAAS,GACpD;AAEA,oBAAc,eAAe,OAAO;AAAA,IACtC;AAEA,QAAI,OAAO,gBAAgB,aAAa;AACtC,gCAAO,yCAAyC,QAAQ,EAAE;AAC1D,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,68 +1,12 @@
|
|
|
1
|
-
import { runInNewContext } from "vm";
|
|
2
|
-
import { buildSync } from "esbuild";
|
|
3
|
-
import { getSandBoxContext } from "../getSandboxContext.mjs";
|
|
4
1
|
import { logger } from "../logger.mjs";
|
|
5
|
-
import {
|
|
6
|
-
const getTransformationOptions = () => {
|
|
7
|
-
const define = {};
|
|
8
|
-
for (const k in process.env) {
|
|
9
|
-
define[`process.env.${k}`] = JSON.stringify(process.env[k]);
|
|
10
|
-
}
|
|
11
|
-
const transformationOption = {
|
|
12
|
-
loader: {
|
|
13
|
-
".js": "js",
|
|
14
|
-
".jsx": "jsx",
|
|
15
|
-
".mjs": "js",
|
|
16
|
-
".ts": "ts",
|
|
17
|
-
".tsx": "tsx",
|
|
18
|
-
".cjs": "js",
|
|
19
|
-
".json": "json"
|
|
20
|
-
},
|
|
21
|
-
format: "cjs",
|
|
22
|
-
// Output format as commonjs
|
|
23
|
-
target: "es2017",
|
|
24
|
-
packages: "external",
|
|
25
|
-
write: false,
|
|
26
|
-
bundle: true,
|
|
27
|
-
define
|
|
28
|
-
};
|
|
29
|
-
return transformationOption;
|
|
30
|
-
};
|
|
2
|
+
import { loadExternalFile } from "../loadExternalFile.mjs";
|
|
31
3
|
const filterValidConfiguration = (configuration) => {
|
|
32
4
|
return configuration;
|
|
33
5
|
};
|
|
34
6
|
const loadConfigurationFile = (configFilePath, envVarOptions) => {
|
|
35
|
-
let customConfiguration = void 0;
|
|
36
|
-
const configFileExtension = configFilePath.split(".").pop() ?? "";
|
|
37
7
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
const sandboxContext = getSandBoxContext(envVarOptions);
|
|
42
|
-
const moduleResult = buildSync({
|
|
43
|
-
entryPoints: [configFilePath],
|
|
44
|
-
...getTransformationOptions()
|
|
45
|
-
});
|
|
46
|
-
const moduleResultString = moduleResult.outputFiles?.[0].text;
|
|
47
|
-
if (!moduleResultString) {
|
|
48
|
-
logger("Configuration file could not be loaded.", { level: "error" });
|
|
49
|
-
return void 0;
|
|
50
|
-
}
|
|
51
|
-
runInNewContext(moduleResultString, sandboxContext);
|
|
52
|
-
if (sandboxContext.exports.default && Object.keys(sandboxContext.exports.default).length > 0) {
|
|
53
|
-
customConfiguration = sandboxContext.exports.default;
|
|
54
|
-
} else if (sandboxContext.module.exports.defaults && Object.keys(sandboxContext.module.exports.defaults).length > 0) {
|
|
55
|
-
customConfiguration = sandboxContext.module.exports.default;
|
|
56
|
-
} else if (sandboxContext.module.exports.default && Object.keys(sandboxContext.module.exports.default).length > 0) {
|
|
57
|
-
customConfiguration = sandboxContext.module.exports.default;
|
|
58
|
-
} else if (sandboxContext.module.exports && Object.keys(sandboxContext.module.exports).length > 0) {
|
|
59
|
-
customConfiguration = sandboxContext.module.exports;
|
|
60
|
-
}
|
|
61
|
-
if (typeof customConfiguration === "undefined") {
|
|
62
|
-
logger("Configuration file could not be loaded.");
|
|
63
|
-
return void 0;
|
|
64
|
-
}
|
|
65
|
-
return filterValidConfiguration(customConfiguration);
|
|
8
|
+
const fileContent = loadExternalFile(configFilePath, envVarOptions);
|
|
9
|
+
return filterValidConfiguration(fileContent);
|
|
66
10
|
} catch (error) {
|
|
67
11
|
logger(
|
|
68
12
|
`Error: ${error} ${JSON.stringify(error.stack, null, 2)}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import { type LoadEnvFileOptions } from '../envVariables/loadEnvFile';\nimport { logger } from '../logger';\nimport type { CustomIntlayerConfig } from '../types/config';\nimport { loadExternalFile } from '../loadExternalFile';\n\nconst filterValidConfiguration = (\n configuration: CustomIntlayerConfig\n): CustomIntlayerConfig => {\n // @TODO Implement filtering of valid configuration\n return configuration;\n};\n\n/**\n * Load the configuration file from the given path\n * Example of configuration file: intlayer.config.js\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadConfigurationFile = (\n configFilePath: string,\n envVarOptions?: LoadEnvFileOptions\n): CustomIntlayerConfig | undefined => {\n try {\n const fileContent = loadExternalFile(configFilePath, envVarOptions);\n\n return filterValidConfiguration(fileContent);\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":"AACA,SAAS,cAAc;AAEvB,SAAS,wBAAwB;AAEjC,MAAM,2BAA2B,CAC/B,kBACyB;AAEzB,SAAO;AACT;AAQO,MAAM,wBAAwB,CACnC,gBACA,kBACqC;AACrC,MAAI;AACF,UAAM,cAAc,iBAAiB,gBAAgB,aAAa;AAElE,WAAO,yBAAyB,WAAW;AAAA,EAC7C,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { ESMxCJSRequire } from "./utils/ESMxCJSRequire.mjs";
|
|
|
12
12
|
import { logger } from "./logger.mjs";
|
|
13
13
|
import { appLogger } from "./appLoggerServer.mjs";
|
|
14
14
|
import { getSandBoxContext } from "./getSandboxContext.mjs";
|
|
15
|
+
import { loadExternalFile } from "./loadExternalFile.mjs";
|
|
15
16
|
export {
|
|
16
17
|
ESMxCJSRequire,
|
|
17
18
|
Locales,
|
|
@@ -22,6 +23,7 @@ export {
|
|
|
22
23
|
getPlatform,
|
|
23
24
|
getSandBoxContext,
|
|
24
25
|
loadEnvFile,
|
|
26
|
+
loadExternalFile,
|
|
25
27
|
logger
|
|
26
28
|
};
|
|
27
29
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n getConfiguration,\n type GetConfigurationOptions,\n} from './configFile/getConfiguration';\n\nexport type {\n InternationalizationConfig,\n ServerSetCookieRule,\n MiddlewareConfig,\n CustomIntlayerConfig,\n BaseContentConfig,\n BaseDerivedConfig,\n ResultDirDerivedConfig,\n PatternsContentConfig,\n ContentConfig,\n LogConfig,\n StrictMode,\n IntlayerConfig,\n} from './types/config';\nexport type { LocalesValues } from './types/locales';\nexport { Locales } from './types/locales';\nexport {\n formatEnvVariable,\n getConfiguration as getClientConfiguration,\n loadEnvFile,\n getPlatform,\n} from './envVariables/index';\nexport { ESMxCJSRequire } from './utils/ESMxCJSRequire';\nexport { logger } from './logger';\nexport { appLogger } from './appLoggerServer';\nexport { getSandBoxContext } from './getSandboxContext';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OAEK;AAiBP,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACoB,oBAApBA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;","names":["getConfiguration"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n getConfiguration,\n type GetConfigurationOptions,\n} from './configFile/getConfiguration';\n\nexport type {\n InternationalizationConfig,\n ServerSetCookieRule,\n MiddlewareConfig,\n CustomIntlayerConfig,\n BaseContentConfig,\n BaseDerivedConfig,\n ResultDirDerivedConfig,\n PatternsContentConfig,\n ContentConfig,\n LogConfig,\n StrictMode,\n IntlayerConfig,\n} from './types/config';\nexport type { LocalesValues } from './types/locales';\nexport { Locales } from './types/locales';\nexport {\n formatEnvVariable,\n getConfiguration as getClientConfiguration,\n loadEnvFile,\n getPlatform,\n} from './envVariables/index';\nexport { ESMxCJSRequire } from './utils/ESMxCJSRequire';\nexport { logger } from './logger';\nexport { appLogger } from './appLoggerServer';\nexport { getSandBoxContext } from './getSandboxContext';\nexport { loadExternalFile } from './loadExternalFile';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OAEK;AAiBP,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACoB,oBAApBA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;","names":["getConfiguration"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { runInNewContext } from "vm";
|
|
2
|
+
import { buildSync } from "esbuild";
|
|
3
|
+
import { getSandBoxContext } from "./getSandboxContext.mjs";
|
|
4
|
+
import { ESMxCJSRequire } from "./utils/ESMxCJSRequire.mjs";
|
|
5
|
+
import { logger } from "./logger.mjs";
|
|
6
|
+
const getTransformationOptions = () => {
|
|
7
|
+
const define = {};
|
|
8
|
+
for (const k in process.env) {
|
|
9
|
+
define[`process.env.${k}`] = JSON.stringify(process.env[k]);
|
|
10
|
+
}
|
|
11
|
+
const transformationOption = {
|
|
12
|
+
loader: {
|
|
13
|
+
".js": "js",
|
|
14
|
+
".jsx": "jsx",
|
|
15
|
+
".mjs": "js",
|
|
16
|
+
".ts": "ts",
|
|
17
|
+
".tsx": "tsx",
|
|
18
|
+
".cjs": "js",
|
|
19
|
+
".json": "json",
|
|
20
|
+
".md": "text",
|
|
21
|
+
".mdx": "text"
|
|
22
|
+
},
|
|
23
|
+
format: "cjs",
|
|
24
|
+
// Output format as commonjs
|
|
25
|
+
target: "es2017",
|
|
26
|
+
packages: "external",
|
|
27
|
+
write: false,
|
|
28
|
+
bundle: true,
|
|
29
|
+
define
|
|
30
|
+
};
|
|
31
|
+
return transformationOption;
|
|
32
|
+
};
|
|
33
|
+
const loadExternalFile = (filePath, envVarOptions) => {
|
|
34
|
+
let fileContent = void 0;
|
|
35
|
+
const fileExtension = filePath.split(".").pop() ?? "";
|
|
36
|
+
try {
|
|
37
|
+
if (fileExtension === "json") {
|
|
38
|
+
return ESMxCJSRequire(filePath);
|
|
39
|
+
}
|
|
40
|
+
const moduleResult = buildSync({
|
|
41
|
+
entryPoints: [filePath],
|
|
42
|
+
...getTransformationOptions()
|
|
43
|
+
});
|
|
44
|
+
const moduleResultString = moduleResult.outputFiles?.[0].text;
|
|
45
|
+
if (!moduleResultString) {
|
|
46
|
+
logger("File could not be loaded.", { level: "error" });
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
const sandboxContext = getSandBoxContext(envVarOptions);
|
|
50
|
+
runInNewContext(moduleResultString, sandboxContext);
|
|
51
|
+
if (sandboxContext.exports.default && Object.keys(sandboxContext.exports.default).length > 0) {
|
|
52
|
+
fileContent = sandboxContext.exports.default;
|
|
53
|
+
} else if (sandboxContext.module.exports.defaults && Object.keys(sandboxContext.module.exports.defaults).length > 0) {
|
|
54
|
+
fileContent = sandboxContext.module.exports.default;
|
|
55
|
+
} else if (sandboxContext.module.exports.default && Object.keys(sandboxContext.module.exports.default).length > 0) {
|
|
56
|
+
fileContent = sandboxContext.module.exports.default;
|
|
57
|
+
} else if (sandboxContext.module.exports && Object.keys(sandboxContext.module.exports).length > 0) {
|
|
58
|
+
fileContent = sandboxContext.module.exports;
|
|
59
|
+
}
|
|
60
|
+
if (typeof fileContent === "undefined") {
|
|
61
|
+
logger(`File file could not be loaded. Path : ${filePath}`);
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
return fileContent;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
logger(
|
|
67
|
+
`Error: ${error} ${JSON.stringify(error.stack, null, 2)}`,
|
|
68
|
+
{
|
|
69
|
+
level: "error"
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
loadExternalFile
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=loadExternalFile.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/loadExternalFile.ts"],"sourcesContent":["import { runInNewContext } from 'vm';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport { getSandBoxContext } from './getSandboxContext';\nimport { ESMxCJSRequire } from './utils/ESMxCJSRequire';\nimport { logger } from './logger';\nimport { LoadEnvFileOptions } from './envVariables/loadEnvFile';\n\nconst getTransformationOptions = (): BuildOptions => {\n const define: Record<string, string> = {};\n\n for (const k in process.env) {\n define[`process.env.${k}`] = JSON.stringify(process.env[k]);\n }\n\n const transformationOption: BuildOptions = {\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n define,\n };\n\n return transformationOption;\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = (\n filePath: string,\n envVarOptions?: LoadEnvFileOptions\n): any | undefined => {\n let fileContent: any | undefined = undefined;\n\n const fileExtension = filePath.split('.').pop() ?? '';\n\n try {\n if (fileExtension === 'json') {\n // Assume JSON\n return ESMxCJSRequire(filePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [filePath],\n ...getTransformationOptions(),\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const sandboxContext = getSandBoxContext(envVarOptions);\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n fileContent = sandboxContext.module.exports;\n }\n\n if (typeof fileContent === 'undefined') {\n logger(`File file could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":"AAAA,SAAS,uBAAuB;AAChC,SAA4B,iBAAmC;AAC/D,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AAGvB,MAAM,2BAA2B,MAAoB;AACnD,QAAM,SAAiC,CAAC;AAExC,aAAW,KAAK,QAAQ,KAAK;AAC3B,WAAO,eAAe,CAAC,EAAE,IAAI,KAAK,UAAU,QAAQ,IAAI,CAAC,CAAC;AAAA,EAC5D;AAEA,QAAM,uBAAqC;AAAA,IACzC,QAAQ;AAAA,MACN,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,OAAO;AAAA,MACP,QAAQ;AAAA,IACV;AAAA,IACA,QAAQ;AAAA;AAAA,IACR,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR;AAAA,EACF;AAEA,SAAO;AACT;AAOO,MAAM,mBAAmB,CAC9B,UACA,kBACoB;AACpB,MAAI,cAA+B;AAEnC,QAAM,gBAAgB,SAAS,MAAM,GAAG,EAAE,IAAI,KAAK;AAEnD,MAAI;AACF,QAAI,kBAAkB,QAAQ;AAE5B,aAAO,eAAe,QAAQ;AAAA,IAChC;AAIA,UAAM,eAA4B,UAAU;AAAA,MAC1C,aAAa,CAAC,QAAQ;AAAA,MACtB,GAAG,yBAAyB;AAAA,IAC9B,CAAC;AAED,UAAM,qBAAqB,aAAa,cAAc,CAAC,EAAE;AAEzD,QAAI,CAAC,oBAAoB;AACvB,aAAO,6BAA6B,EAAE,OAAO,QAAQ,CAAC;AACtD,aAAO;AAAA,IACT;AAEA,UAAM,iBAAiB,kBAAkB,aAAa;AAEtD,oBAAgB,oBAAoB,cAAc;AAElD,QACE,eAAe,QAAQ,WACvB,OAAO,KAAK,eAAe,QAAQ,OAAO,EAAE,SAAS,GACrD;AAEA,oBAAc,eAAe,QAAQ;AAAA,IACvC,WACE,eAAe,OAAO,QAAQ,YAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,QAAQ,EAAE,SAAS,GAC7D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,QAAQ,WAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,OAAO,EAAE,SAAS,GAC5D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,WACtB,OAAO,KAAK,eAAe,OAAO,OAAO,EAAE,SAAS,GACpD;AAEA,oBAAc,eAAe,OAAO;AAAA,IACtC;AAEA,QAAI,OAAO,gBAAgB,aAAa;AACtC,aAAO,yCAAyC,QAAQ,EAAE;AAC1D,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfigurationFile.d.ts","sourceRoot":"","sources":["../../../src/configFile/loadConfigurationFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadConfigurationFile.d.ts","sourceRoot":"","sources":["../../../src/configFile/loadConfigurationFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAU5D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,gBAAgB,MAAM,EACtB,gBAAgB,kBAAkB,KACjC,oBAAoB,GAAG,SAazB,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export { ESMxCJSRequire } from './utils/ESMxCJSRequire';
|
|
|
7
7
|
export { logger } from './logger';
|
|
8
8
|
export { appLogger } from './appLoggerServer';
|
|
9
9
|
export { getSandBoxContext } from './getSandboxContext';
|
|
10
|
+
export { loadExternalFile } from './loadExternalFile';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,GAC7B,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EACV,0BAA0B,EAC1B,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,gBAAgB,IAAI,sBAAsB,EAC1C,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,GAC7B,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EACV,0BAA0B,EAC1B,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,gBAAgB,IAAI,sBAAsB,EAC1C,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LoadEnvFileOptions } from './envVariables/loadEnvFile';
|
|
2
|
+
/**
|
|
3
|
+
* Load the content declaration from the given path
|
|
4
|
+
*
|
|
5
|
+
* Accepts JSON, JS, MJS and TS files as configuration
|
|
6
|
+
*/
|
|
7
|
+
export declare const loadExternalFile: (filePath: string, envVarOptions?: LoadEnvFileOptions) => any | undefined;
|
|
8
|
+
//# sourceMappingURL=loadExternalFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadExternalFile.d.ts","sourceRoot":"","sources":["../../src/loadExternalFile.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAgChE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,gBAAgB,kBAAkB,KACjC,GAAG,GAAG,SAqER,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/config",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.",
|
|
6
6
|
"keywords": [
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"url": "https://github.com/aymericzip"
|
|
36
36
|
}
|
|
37
37
|
],
|
|
38
|
+
"sideEffects": false,
|
|
38
39
|
"exports": {
|
|
39
40
|
".": {
|
|
40
41
|
"types": "./dist/types/index.d.ts",
|
|
@@ -83,11 +84,11 @@
|
|
|
83
84
|
"typescript": "^5.7.3",
|
|
84
85
|
"@utils/eslint-config": "1.0.4",
|
|
85
86
|
"@utils/ts-config": "1.0.4",
|
|
86
|
-
"@utils/
|
|
87
|
-
"@utils/
|
|
87
|
+
"@utils/tsup-config": "1.0.4",
|
|
88
|
+
"@utils/ts-config-types": "1.0.4"
|
|
88
89
|
},
|
|
89
90
|
"peerDependencies": {
|
|
90
|
-
"intlayer": "5.
|
|
91
|
+
"intlayer": "5.3.0"
|
|
91
92
|
},
|
|
92
93
|
"engines": {
|
|
93
94
|
"node": ">=14.18"
|