@intlayer/config 7.0.3 → 7.0.4
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/getConfiguration.cjs +15 -16
- package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
- package/dist/cjs/index.cjs +6 -6
- package/dist/cjs/loadExternalFile/parseFileContent.cjs +3 -3
- package/dist/cjs/loadExternalFile/transpileTSToMJS.cjs +1 -1
- package/dist/cjs/package.cjs +1 -1
- package/dist/cjs/package.cjs.map +1 -1
- package/dist/cjs/utils/getPackageJsonPath.cjs +0 -2
- package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -1
- package/dist/esm/configFile/getConfiguration.mjs +15 -16
- package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
- package/dist/esm/index.mjs +6 -6
- package/dist/esm/loadExternalFile/parseFileContent.mjs +2 -2
- package/dist/esm/loadExternalFile/transpileTSToMJS.mjs +1 -1
- package/dist/esm/package.mjs +1 -1
- package/dist/esm/package.mjs.map +1 -1
- package/dist/esm/utils/getPackageJsonPath.mjs +0 -2
- package/dist/esm/utils/getPackageJsonPath.mjs.map +1 -1
- package/dist/types/configFile/getConfiguration.d.ts +1 -0
- package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
- package/dist/types/utils/cache.d.ts.map +1 -1
- package/dist/types/utils/getPackageJsonPath.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_logger = require('../logger.cjs');
|
|
3
3
|
const require_utils_cache = require('../utils/cache.cjs');
|
|
4
|
+
const require_utils_getPackageJsonPath = require('../utils/getPackageJsonPath.cjs');
|
|
4
5
|
const require_configFile_buildConfigurationFields = require('./buildConfigurationFields.cjs');
|
|
5
6
|
const require_configFile_searchConfigurationFile = require('./searchConfigurationFile.cjs');
|
|
6
|
-
const require_utils_getPackageJsonPath = require('../utils/getPackageJsonPath.cjs');
|
|
7
7
|
const require_configFile_loadConfigurationFile = require('./loadConfigurationFile.cjs');
|
|
8
8
|
let node_path = require("node:path");
|
|
9
9
|
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
@@ -15,28 +15,27 @@ deepmerge = require_rolldown_runtime.__toESM(deepmerge);
|
|
|
15
15
|
* Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)
|
|
16
16
|
*/
|
|
17
17
|
const getConfigurationAndFilePath = (options) => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
...options
|
|
21
|
-
};
|
|
22
|
-
const baseDir = mergedOptions.baseDir ?? require_utils_getPackageJsonPath.getPackageJsonPath().baseDir;
|
|
23
|
-
const cachedConfiguration = require_utils_cache.cache.get(mergedOptions);
|
|
18
|
+
const baseDir = options?.baseDir ?? require_utils_getPackageJsonPath.getPackageJsonPath().baseDir;
|
|
19
|
+
const cachedConfiguration = require_utils_cache.cache.get(options);
|
|
24
20
|
if (cachedConfiguration) return cachedConfiguration;
|
|
25
21
|
const { configurationFilePath, numCustomConfiguration } = require_configFile_searchConfigurationFile.searchConfigurationFile(baseDir);
|
|
26
22
|
if (options?.override?.log?.mode === "verbose") logConfigFileResult(baseDir, numCustomConfiguration, configurationFilePath);
|
|
27
23
|
let storedConfiguration;
|
|
28
24
|
if (configurationFilePath) storedConfiguration = require_configFile_buildConfigurationFields.buildConfigurationFields(require_configFile_loadConfigurationFile.loadConfigurationFile(configurationFilePath, {
|
|
29
|
-
projectRequire:
|
|
25
|
+
projectRequire: options?.require,
|
|
30
26
|
envVarOptions: {
|
|
31
|
-
env:
|
|
32
|
-
envFile:
|
|
27
|
+
env: options?.env,
|
|
28
|
+
envFile: options?.envFile
|
|
33
29
|
},
|
|
34
|
-
additionalEnvVars:
|
|
35
|
-
aliases:
|
|
36
|
-
}),
|
|
37
|
-
const projectRequireConfig =
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
additionalEnvVars: options?.additionalEnvVars,
|
|
31
|
+
aliases: options?.aliases
|
|
32
|
+
}), options?.baseDir, options?.logFunctions);
|
|
33
|
+
const projectRequireConfig = options?.require ? { build: {
|
|
34
|
+
require: options?.require,
|
|
35
|
+
cache: options?.cache
|
|
36
|
+
} } : {};
|
|
37
|
+
const configuration = (0, deepmerge.default)((0, deepmerge.default)(storedConfiguration ?? {}, projectRequireConfig), options?.override ?? {});
|
|
38
|
+
require_utils_cache.cache.set(options, {
|
|
40
39
|
configuration,
|
|
41
40
|
configurationFilePath
|
|
42
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfiguration.cjs","names":["getPackageJsonPath","cache","searchConfigurationFile","storedConfiguration: IntlayerConfig | undefined","buildConfigurationFields","loadConfigurationFile","projectRequireConfig: CustomIntlayerConfig"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport merge from 'deepmerge';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { logger } from '../logger';\nimport { cache } from '../utils/cache';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n const
|
|
1
|
+
{"version":3,"file":"getConfiguration.cjs","names":["getPackageJsonPath","cache","searchConfigurationFile","storedConfiguration: IntlayerConfig | undefined","buildConfigurationFields","loadConfigurationFile","projectRequireConfig: CustomIntlayerConfig"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport merge from 'deepmerge';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { logger } from '../logger';\nimport { cache } from '../utils/cache';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n // cache\n cache?: boolean;\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n const baseDir = options?.baseDir ?? getPackageJsonPath().baseDir;\n\n const cachedConfiguration =\n cache.get<GetConfigurationAndFilePathResult>(options);\n\n if (cachedConfiguration) return cachedConfiguration;\n\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n if (options?.override?.log?.mode === 'verbose') {\n logConfigFileResult(baseDir, numCustomConfiguration, configurationFilePath);\n }\n\n let storedConfiguration: IntlayerConfig | undefined;\n\n if (configurationFilePath) {\n // Load the custom configuration\n const customConfiguration: CustomIntlayerConfig | undefined =\n loadConfigurationFile(configurationFilePath, {\n projectRequire: options?.require,\n // Dotenv options\n envVarOptions: {\n env: options?.env,\n envFile: options?.envFile,\n },\n // Sandbox context additional variables\n additionalEnvVars: options?.additionalEnvVars,\n aliases: options?.aliases,\n });\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n customConfiguration,\n options?.baseDir,\n options?.logFunctions\n );\n }\n\n // Log warning if multiple configuration files are found\n\n const projectRequireConfig: CustomIntlayerConfig = options?.require\n ? {\n build: {\n require: options?.require,\n cache: options?.cache,\n },\n }\n : {};\n\n const configWithProjectRequire = merge(\n storedConfiguration ?? {},\n projectRequireConfig\n ) as CustomIntlayerConfig;\n\n const configuration = merge(\n configWithProjectRequire,\n options?.override ?? {}\n ) as IntlayerConfig;\n\n cache.set(options, {\n configuration,\n configurationFilePath,\n });\n\n return {\n configuration,\n configurationFilePath,\n };\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfiguration = (\n options?: GetConfigurationOptions\n): IntlayerConfig => getConfigurationAndFilePath(options).configuration;\n\nconst logConfigFileResult = (\n baseDir: string,\n numCustomConfiguration?: number,\n configurationFilePath?: string\n) => {\n if (numCustomConfiguration === 0) {\n logger('Configuration file not found, using default configuration.', {\n isVerbose: true,\n });\n } else {\n const relativeOutputPath = relative(baseDir, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n logger(`Configuration file found: ${relativeOutputPath}.`, {\n isVerbose: true,\n });\n } else {\n logger(\n `Multiple configuration files found, using ${relativeOutputPath}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAa,+BACX,YACsC;CACtC,MAAM,UAAU,SAAS,WAAWA,qDAAoB,CAAC;CAEzD,MAAM,sBACJC,0BAAM,IAAuC,QAAQ;AAEvD,KAAI,oBAAqB,QAAO;CAGhC,MAAM,EAAE,uBAAuB,2BAC7BC,mEAAwB,QAAQ;AAElC,KAAI,SAAS,UAAU,KAAK,SAAS,UACnC,qBAAoB,SAAS,wBAAwB,sBAAsB;CAG7E,IAAIC;AAEJ,KAAI,sBAgBF,uBAAsBC,qEAbpBC,+DAAsB,uBAAuB;EAC3C,gBAAgB,SAAS;EAEzB,eAAe;GACb,KAAK,SAAS;GACd,SAAS,SAAS;GACnB;EAED,mBAAmB,SAAS;EAC5B,SAAS,SAAS;EACnB,CAAC,EAKF,SAAS,SACT,SAAS,aACV;CAKH,MAAMC,uBAA6C,SAAS,UACxD,EACE,OAAO;EACL,SAAS,SAAS;EAClB,OAAO,SAAS;EACjB,EACF,GACD,EAAE;CAON,MAAM,8DAJJ,uBAAuB,EAAE,EACzB,qBACD,EAIC,SAAS,YAAY,EAAE,CACxB;AAED,2BAAM,IAAI,SAAS;EACjB;EACA;EACD,CAAC;AAEF,QAAO;EACL;EACA;EACD;;;;;AAMH,MAAa,oBACX,YACmB,4BAA4B,QAAQ,CAAC;AAE1D,MAAM,uBACJ,SACA,wBACA,0BACG;AACH,KAAI,2BAA2B,EAC7B,uBAAO,8DAA8D,EACnE,WAAW,MACZ,CAAC;MACG;EACL,MAAM,6CAA8B,SAAS,sBAAuB;AAEpE,MAAI,2BAA2B,EAC7B,uBAAO,6BAA6B,mBAAmB,IAAI,EACzD,WAAW,MACZ,CAAC;MAEF,uBACE,6CAA6C,mBAAmB,IAChE,EACE,WAAW,MACZ,CACF"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,20 +3,20 @@ const require_utils_normalizePath = require('./utils/normalizePath.cjs');
|
|
|
3
3
|
const require_alias = require('./alias.cjs');
|
|
4
4
|
const require_logger = require('./logger.cjs');
|
|
5
5
|
const require_utils_cache = require('./utils/cache.cjs');
|
|
6
|
-
const
|
|
6
|
+
const require_utils_getPackageJsonPath = require('./utils/getPackageJsonPath.cjs');
|
|
7
7
|
const require_configFile_buildConfigurationFields = require('./configFile/buildConfigurationFields.cjs');
|
|
8
|
+
const require_utils_ESMxCJSHelpers = require('./utils/ESMxCJSHelpers.cjs');
|
|
9
|
+
const require_loadEnvFile = require('./loadEnvFile.cjs');
|
|
10
|
+
const require_loadExternalFile_parseFileContent = require('./loadExternalFile/parseFileContent.cjs');
|
|
11
|
+
const require_bundleJSFile = require('./bundleJSFile.cjs');
|
|
8
12
|
const require_configFile_searchConfigurationFile = require('./configFile/searchConfigurationFile.cjs');
|
|
9
13
|
const require_defaultValues_index = require('./defaultValues/index.cjs');
|
|
10
|
-
const require_loadEnvFile = require('./loadEnvFile.cjs');
|
|
11
14
|
const require_loadExternalFile_bundleFile = require('./loadExternalFile/bundleFile.cjs');
|
|
12
|
-
const require_utils_ESMxCJSHelpers = require('./utils/ESMxCJSHelpers.cjs');
|
|
13
|
-
const require_loadExternalFile_parseFileContent = require('./loadExternalFile/parseFileContent.cjs');
|
|
14
|
-
const require_loadExternalFile_loadExternalFile = require('./loadExternalFile/loadExternalFile.cjs');
|
|
15
15
|
const require_utils_extractErrorMessage = require('./utils/extractErrorMessage.cjs');
|
|
16
16
|
const require_retryManager = require('./retryManager.cjs');
|
|
17
17
|
const require_utils_clearModuleCache = require('./utils/clearModuleCache.cjs');
|
|
18
18
|
const require_utils_logStack = require('./utils/logStack.cjs');
|
|
19
|
-
const
|
|
19
|
+
const require_loadExternalFile_loadExternalFile = require('./loadExternalFile/loadExternalFile.cjs');
|
|
20
20
|
const require_configFile_getConfiguration = require('./configFile/getConfiguration.cjs');
|
|
21
21
|
|
|
22
22
|
exports.ANSIColors = require_logger.ANSIColors;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_loadEnvFile = require('../loadEnvFile.cjs');
|
|
3
2
|
const require_utils_ESMxCJSHelpers = require('../utils/ESMxCJSHelpers.cjs');
|
|
4
|
-
|
|
5
|
-
esbuild = require_rolldown_runtime.__toESM(esbuild);
|
|
3
|
+
const require_loadEnvFile = require('../loadEnvFile.cjs');
|
|
6
4
|
let node_vm = require("node:vm");
|
|
7
5
|
node_vm = require_rolldown_runtime.__toESM(node_vm);
|
|
6
|
+
let esbuild = require("esbuild");
|
|
7
|
+
esbuild = require_rolldown_runtime.__toESM(esbuild);
|
|
8
8
|
|
|
9
9
|
//#region src/loadExternalFile/parseFileContent.ts
|
|
10
10
|
const getSandBoxContext = (options) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_loadExternalFile_bundleFile = require('./bundleFile.cjs');
|
|
3
2
|
const require_utils_getPackageJsonPath = require('../utils/getPackageJsonPath.cjs');
|
|
3
|
+
const require_loadExternalFile_bundleFile = require('./bundleFile.cjs');
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
6
6
|
let esbuild = require("esbuild");
|
package/dist/cjs/package.cjs
CHANGED
package/dist/cjs/package.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.cjs","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@intlayer/config\",\n \"version\": \"7.0.
|
|
1
|
+
{"version":3,"file":"package.cjs","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@intlayer/config\",\n \"version\": \"7.0.4\",\n \"private\": false,\n \"description\": \"Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.\",\n \"keywords\": [\n \"intlayer\",\n \"layer\",\n \"abstraction\",\n \"data\",\n \"internationalization\",\n \"i18n\",\n \"typescript\",\n \"javascript\",\n \"json\",\n \"file\"\n ],\n \"homepage\": \"https://intlayer.org\",\n \"bugs\": {\n \"url\": \"https://github.com/aymericzip/intlayer/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/aymericzip/intlayer.git\"\n },\n \"license\": \"Apache-2.0\",\n \"author\": {\n \"name\": \"Aymeric PINEAU\",\n \"url\": \"https://github.com/aymericzip\"\n },\n \"contributors\": [\n {\n \"name\": \"Aymeric Pineau\",\n \"email\": \"ay.pineau@gmail.com\",\n \"url\": \"https://github.com/aymericzip\"\n }\n ],\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"browser\": \"./dist/esm/client.mjs\",\n \"require\": \"./dist/cjs/index.cjs\",\n \"import\": \"./dist/esm/index.mjs\"\n },\n \"./client\": {\n \"types\": \"./dist/types/client.d.ts\",\n \"require\": \"./dist/cjs/client.cjs\",\n \"import\": \"./dist/esm/client.mjs\"\n },\n \"./built\": {\n \"types\": \"./dist/types/built.d.ts\",\n \"require\": \"./dist/cjs/built.cjs\",\n \"import\": \"./dist/esm/built.mjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"dist/cjs/index.cjs\",\n \"module\": \"dist/esm/index.mjs\",\n \"types\": \"dist/types/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \".\": [\n \"./dist/types/index.d.ts\"\n ],\n \"client\": [\n \"./dist/types/client.d.ts\"\n ],\n \"built\": [\n \"./dist/types/built.d.ts\"\n ],\n \"package.json\": [\n \"./package.json\"\n ]\n }\n },\n \"files\": [\n \"./dist\",\n \"./package.json\"\n ],\n \"scripts\": {\n \"build\": \"tsdown --config tsdown.config.ts\",\n \"build:ci\": \"tsdown --config tsdown.config.ts\",\n \"clean\": \"rimraf ./dist .turbo\",\n \"dev\": \"tsdown --config tsdown.config.ts --watch\",\n \"format\": \"biome format . --check\",\n \"format:fix\": \"biome format --write .\",\n \"lint\": \"biome lint .\",\n \"lint:fix\": \"biome lint --write .\",\n \"prepublish\": \"cp -f ../../../README.md ./README.md\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"tsc --noEmit --project tsconfig.types.json\"\n },\n \"dependencies\": {\n \"@intlayer/types\": \"workspace:*\",\n \"deepmerge\": \"4.3.1\",\n \"dotenv\": \"16.6.1\",\n \"esbuild\": \"0.25.2\"\n },\n \"devDependencies\": {\n \"@types/node\": \"24.9.2\",\n \"@utils/ts-config\": \"workspace:*\",\n \"@utils/ts-config-types\": \"workspace:*\",\n \"@utils/tsdown-config\": \"workspace:*\",\n \"rimraf\": \"6.0.1\",\n \"tsdown\": \"0.15.11\",\n \"typescript\": \"5.9.3\",\n \"vitest\": \"4.0.5\"\n },\n \"peerDependencies\": {\n \"intlayer\": \"workspace:*\",\n \"react\": \">=16.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"intlayer\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n }\n },\n \"engines\": {\n \"node\": \">=14.18\"\n },\n \"bug\": {\n \"url\": \"https://github.com/aymericzip/intlayer/issues\"\n }\n}\n"],"mappings":";;cAEa"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_utils_cache = require('./cache.cjs');
|
|
3
|
-
const require_utils_logStack = require('./logStack.cjs');
|
|
4
3
|
let node_path = require("node:path");
|
|
5
4
|
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
6
5
|
let node_fs = require("node:fs");
|
|
@@ -29,7 +28,6 @@ const getPackageJsonPath = (startDir = process.cwd()) => {
|
|
|
29
28
|
if (parentDir === currentDir) break;
|
|
30
29
|
currentDir = parentDir;
|
|
31
30
|
}
|
|
32
|
-
require_utils_logStack.logStack("test");
|
|
33
31
|
throw new Error(`Could not find package.json in current directory or any of the ${MAX_LEVELS} parent directories. Searched from: ${startDir}`);
|
|
34
32
|
};
|
|
35
33
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageJsonPath.cjs","names":["cache"],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport {
|
|
1
|
+
{"version":3,"file":"getPackageJsonPath.cjs","names":["cache"],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { cache } from './cache';\n\nexport const isESModule = typeof import.meta.url === 'string';\n\nconst MAX_LEVELS = 15;\n\ntype PackageJsonPathCache = {\n packageJsonPath: string;\n baseDir: string;\n};\n\nexport const getPackageJsonPath = (\n startDir: string = process.cwd()\n): PackageJsonPathCache => {\n const checkedCache = cache.get<PackageJsonPathCache>(\n 'packageJsonPath',\n startDir\n );\n\n if (checkedCache) return checkedCache;\n\n let currentDir = startDir;\n\n for (let level = 0; level < MAX_LEVELS; level++) {\n const packageJsonPath = join(currentDir, 'package.json');\n\n if (existsSync(packageJsonPath)) {\n cache.set('packageJsonPath', startDir, {\n packageJsonPath,\n baseDir: currentDir,\n });\n\n return { packageJsonPath, baseDir: currentDir };\n }\n\n const parentDir = dirname(currentDir);\n\n // If we've reached the root directory, stop\n if (parentDir === currentDir) {\n break;\n }\n\n currentDir = parentDir;\n }\n\n throw new Error(\n `Could not find package.json in current directory or any of the ${MAX_LEVELS} parent directories. Searched from: ${startDir}`\n );\n};\n"],"mappings":";;;;;;;;AAIA,MAAa,aAAa,yDAA2B;AAErD,MAAM,aAAa;AAOnB,MAAa,sBACX,WAAmB,QAAQ,KAAK,KACP;CACzB,MAAM,eAAeA,0BAAM,IACzB,mBACA,SACD;AAED,KAAI,aAAc,QAAO;CAEzB,IAAI,aAAa;AAEjB,MAAK,IAAI,QAAQ,GAAG,QAAQ,YAAY,SAAS;EAC/C,MAAM,sCAAuB,YAAY,eAAe;AAExD,8BAAe,gBAAgB,EAAE;AAC/B,6BAAM,IAAI,mBAAmB,UAAU;IACrC;IACA,SAAS;IACV,CAAC;AAEF,UAAO;IAAE;IAAiB,SAAS;IAAY;;EAGjD,MAAM,mCAAoB,WAAW;AAGrC,MAAI,cAAc,WAChB;AAGF,eAAa;;AAGf,OAAM,IAAI,MACR,kEAAkE,WAAW,sCAAsC,WACpH"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { logger } from "../logger.mjs";
|
|
2
2
|
import { cache } from "../utils/cache.mjs";
|
|
3
|
+
import { getPackageJsonPath } from "../utils/getPackageJsonPath.mjs";
|
|
3
4
|
import { buildConfigurationFields } from "./buildConfigurationFields.mjs";
|
|
4
5
|
import { searchConfigurationFile } from "./searchConfigurationFile.mjs";
|
|
5
|
-
import { getPackageJsonPath } from "../utils/getPackageJsonPath.mjs";
|
|
6
6
|
import { loadConfigurationFile } from "./loadConfigurationFile.mjs";
|
|
7
7
|
import { relative } from "node:path";
|
|
8
8
|
import merge from "deepmerge";
|
|
@@ -12,28 +12,27 @@ import merge from "deepmerge";
|
|
|
12
12
|
* Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)
|
|
13
13
|
*/
|
|
14
14
|
const getConfigurationAndFilePath = (options) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
...options
|
|
18
|
-
};
|
|
19
|
-
const baseDir = mergedOptions.baseDir ?? getPackageJsonPath().baseDir;
|
|
20
|
-
const cachedConfiguration = cache.get(mergedOptions);
|
|
15
|
+
const baseDir = options?.baseDir ?? getPackageJsonPath().baseDir;
|
|
16
|
+
const cachedConfiguration = cache.get(options);
|
|
21
17
|
if (cachedConfiguration) return cachedConfiguration;
|
|
22
18
|
const { configurationFilePath, numCustomConfiguration } = searchConfigurationFile(baseDir);
|
|
23
19
|
if (options?.override?.log?.mode === "verbose") logConfigFileResult(baseDir, numCustomConfiguration, configurationFilePath);
|
|
24
20
|
let storedConfiguration;
|
|
25
21
|
if (configurationFilePath) storedConfiguration = buildConfigurationFields(loadConfigurationFile(configurationFilePath, {
|
|
26
|
-
projectRequire:
|
|
22
|
+
projectRequire: options?.require,
|
|
27
23
|
envVarOptions: {
|
|
28
|
-
env:
|
|
29
|
-
envFile:
|
|
24
|
+
env: options?.env,
|
|
25
|
+
envFile: options?.envFile
|
|
30
26
|
},
|
|
31
|
-
additionalEnvVars:
|
|
32
|
-
aliases:
|
|
33
|
-
}),
|
|
34
|
-
const projectRequireConfig =
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
additionalEnvVars: options?.additionalEnvVars,
|
|
28
|
+
aliases: options?.aliases
|
|
29
|
+
}), options?.baseDir, options?.logFunctions);
|
|
30
|
+
const projectRequireConfig = options?.require ? { build: {
|
|
31
|
+
require: options?.require,
|
|
32
|
+
cache: options?.cache
|
|
33
|
+
} } : {};
|
|
34
|
+
const configuration = merge(merge(storedConfiguration ?? {}, projectRequireConfig), options?.override ?? {});
|
|
35
|
+
cache.set(options, {
|
|
37
36
|
configuration,
|
|
38
37
|
configurationFilePath
|
|
39
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfiguration.mjs","names":["storedConfiguration: IntlayerConfig | undefined","projectRequireConfig: CustomIntlayerConfig"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport merge from 'deepmerge';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { logger } from '../logger';\nimport { cache } from '../utils/cache';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n const
|
|
1
|
+
{"version":3,"file":"getConfiguration.mjs","names":["storedConfiguration: IntlayerConfig | undefined","projectRequireConfig: CustomIntlayerConfig"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport merge from 'deepmerge';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { logger } from '../logger';\nimport { cache } from '../utils/cache';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n // cache\n cache?: boolean;\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n const baseDir = options?.baseDir ?? getPackageJsonPath().baseDir;\n\n const cachedConfiguration =\n cache.get<GetConfigurationAndFilePathResult>(options);\n\n if (cachedConfiguration) return cachedConfiguration;\n\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n if (options?.override?.log?.mode === 'verbose') {\n logConfigFileResult(baseDir, numCustomConfiguration, configurationFilePath);\n }\n\n let storedConfiguration: IntlayerConfig | undefined;\n\n if (configurationFilePath) {\n // Load the custom configuration\n const customConfiguration: CustomIntlayerConfig | undefined =\n loadConfigurationFile(configurationFilePath, {\n projectRequire: options?.require,\n // Dotenv options\n envVarOptions: {\n env: options?.env,\n envFile: options?.envFile,\n },\n // Sandbox context additional variables\n additionalEnvVars: options?.additionalEnvVars,\n aliases: options?.aliases,\n });\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n customConfiguration,\n options?.baseDir,\n options?.logFunctions\n );\n }\n\n // Log warning if multiple configuration files are found\n\n const projectRequireConfig: CustomIntlayerConfig = options?.require\n ? {\n build: {\n require: options?.require,\n cache: options?.cache,\n },\n }\n : {};\n\n const configWithProjectRequire = merge(\n storedConfiguration ?? {},\n projectRequireConfig\n ) as CustomIntlayerConfig;\n\n const configuration = merge(\n configWithProjectRequire,\n options?.override ?? {}\n ) as IntlayerConfig;\n\n cache.set(options, {\n configuration,\n configurationFilePath,\n });\n\n return {\n configuration,\n configurationFilePath,\n };\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfiguration = (\n options?: GetConfigurationOptions\n): IntlayerConfig => getConfigurationAndFilePath(options).configuration;\n\nconst logConfigFileResult = (\n baseDir: string,\n numCustomConfiguration?: number,\n configurationFilePath?: string\n) => {\n if (numCustomConfiguration === 0) {\n logger('Configuration file not found, using default configuration.', {\n isVerbose: true,\n });\n } else {\n const relativeOutputPath = relative(baseDir, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n logger(`Configuration file found: ${relativeOutputPath}.`, {\n isVerbose: true,\n });\n } else {\n logger(\n `Multiple configuration files found, using ${relativeOutputPath}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAqCA,MAAa,+BACX,YACsC;CACtC,MAAM,UAAU,SAAS,WAAW,oBAAoB,CAAC;CAEzD,MAAM,sBACJ,MAAM,IAAuC,QAAQ;AAEvD,KAAI,oBAAqB,QAAO;CAGhC,MAAM,EAAE,uBAAuB,2BAC7B,wBAAwB,QAAQ;AAElC,KAAI,SAAS,UAAU,KAAK,SAAS,UACnC,qBAAoB,SAAS,wBAAwB,sBAAsB;CAG7E,IAAIA;AAEJ,KAAI,sBAgBF,uBAAsB,yBAbpB,sBAAsB,uBAAuB;EAC3C,gBAAgB,SAAS;EAEzB,eAAe;GACb,KAAK,SAAS;GACd,SAAS,SAAS;GACnB;EAED,mBAAmB,SAAS;EAC5B,SAAS,SAAS;EACnB,CAAC,EAKF,SAAS,SACT,SAAS,aACV;CAKH,MAAMC,uBAA6C,SAAS,UACxD,EACE,OAAO;EACL,SAAS,SAAS;EAClB,OAAO,SAAS;EACjB,EACF,GACD,EAAE;CAON,MAAM,gBAAgB,MALW,MAC/B,uBAAuB,EAAE,EACzB,qBACD,EAIC,SAAS,YAAY,EAAE,CACxB;AAED,OAAM,IAAI,SAAS;EACjB;EACA;EACD,CAAC;AAEF,QAAO;EACL;EACA;EACD;;;;;AAMH,MAAa,oBACX,YACmB,4BAA4B,QAAQ,CAAC;AAE1D,MAAM,uBACJ,SACA,wBACA,0BACG;AACH,KAAI,2BAA2B,EAC7B,QAAO,8DAA8D,EACnE,WAAW,MACZ,CAAC;MACG;EACL,MAAM,qBAAqB,SAAS,SAAS,sBAAuB;AAEpE,MAAI,2BAA2B,EAC7B,QAAO,6BAA6B,mBAAmB,IAAI,EACzD,WAAW,MACZ,CAAC;MAEF,QACE,6CAA6C,mBAAmB,IAChE,EACE,WAAW,MACZ,CACF"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -3,20 +3,20 @@ import { normalizePath } from "./utils/normalizePath.mjs";
|
|
|
3
3
|
import { getAlias } from "./alias.mjs";
|
|
4
4
|
import { ANSIColors, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, logger, removeColor, spinnerFrames, v, x } from "./logger.mjs";
|
|
5
5
|
import { cache, clearCache, getCache, localCache, setCache } from "./utils/cache.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { getPackageJsonPath } from "./utils/getPackageJsonPath.mjs";
|
|
7
7
|
import { buildConfigurationFields } from "./configFile/buildConfigurationFields.mjs";
|
|
8
|
+
import { configESMxCJSRequire, getProjectRequire, isESModule } from "./utils/ESMxCJSHelpers.mjs";
|
|
9
|
+
import { getEnvFilePath, loadEnvFile } from "./loadEnvFile.mjs";
|
|
10
|
+
import { parseFileContent } from "./loadExternalFile/parseFileContent.mjs";
|
|
11
|
+
import { bundleJSFile } from "./bundleJSFile.mjs";
|
|
8
12
|
import { searchConfigurationFile } from "./configFile/searchConfigurationFile.mjs";
|
|
9
13
|
import { defaultValues_exports } from "./defaultValues/index.mjs";
|
|
10
|
-
import { getEnvFilePath, loadEnvFile } from "./loadEnvFile.mjs";
|
|
11
14
|
import { bundleFile, bundleFileSync } from "./loadExternalFile/bundleFile.mjs";
|
|
12
|
-
import { configESMxCJSRequire, getProjectRequire, isESModule } from "./utils/ESMxCJSHelpers.mjs";
|
|
13
|
-
import { parseFileContent } from "./loadExternalFile/parseFileContent.mjs";
|
|
14
|
-
import { loadExternalFile, loadExternalFileSync } from "./loadExternalFile/loadExternalFile.mjs";
|
|
15
15
|
import { extractErrorMessage } from "./utils/extractErrorMessage.mjs";
|
|
16
16
|
import { retryManager } from "./retryManager.mjs";
|
|
17
17
|
import { clearModuleCache } from "./utils/clearModuleCache.mjs";
|
|
18
18
|
import { logStack } from "./utils/logStack.mjs";
|
|
19
|
-
import {
|
|
19
|
+
import { loadExternalFile, loadExternalFileSync } from "./loadExternalFile/loadExternalFile.mjs";
|
|
20
20
|
import { getConfiguration, getConfigurationAndFilePath } from "./configFile/getConfiguration.mjs";
|
|
21
21
|
|
|
22
22
|
export { ANSIColors, defaultValues_exports as DefaultValues, buildConfigurationFields, bundleFile, bundleFileSync, bundleJSFile, cache, clearCache, clearModuleCache, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, configESMxCJSRequire, extractErrorMessage, getAlias, getAppLogger, getCache, getConfiguration, getConfigurationAndFilePath, getEnvFilePath, getExtension, getPackageJsonPath, getProjectRequire, isESModule, loadEnvFile, loadExternalFile, loadExternalFileSync, localCache, logStack, logger, normalizePath, parseFileContent, removeColor, retryManager, searchConfigurationFile, setCache, spinnerFrames, v, x };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { loadEnvFile } from "../loadEnvFile.mjs";
|
|
2
1
|
import { getProjectRequire } from "../utils/ESMxCJSHelpers.mjs";
|
|
3
|
-
import
|
|
2
|
+
import { loadEnvFile } from "../loadEnvFile.mjs";
|
|
4
3
|
import { runInNewContext } from "node:vm";
|
|
4
|
+
import * as esbuild from "esbuild";
|
|
5
5
|
|
|
6
6
|
//#region src/loadExternalFile/parseFileContent.ts
|
|
7
7
|
const getSandBoxContext = (options) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getLoader } from "./bundleFile.mjs";
|
|
2
1
|
import { getPackageJsonPath } from "../utils/getPackageJsonPath.mjs";
|
|
2
|
+
import { getLoader } from "./bundleFile.mjs";
|
|
3
3
|
import { dirname, extname, join } from "node:path";
|
|
4
4
|
import { build, buildSync } from "esbuild";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
package/dist/esm/package.mjs
CHANGED
package/dist/esm/package.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.mjs","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@intlayer/config\",\n \"version\": \"7.0.
|
|
1
|
+
{"version":3,"file":"package.mjs","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@intlayer/config\",\n \"version\": \"7.0.4\",\n \"private\": false,\n \"description\": \"Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.\",\n \"keywords\": [\n \"intlayer\",\n \"layer\",\n \"abstraction\",\n \"data\",\n \"internationalization\",\n \"i18n\",\n \"typescript\",\n \"javascript\",\n \"json\",\n \"file\"\n ],\n \"homepage\": \"https://intlayer.org\",\n \"bugs\": {\n \"url\": \"https://github.com/aymericzip/intlayer/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/aymericzip/intlayer.git\"\n },\n \"license\": \"Apache-2.0\",\n \"author\": {\n \"name\": \"Aymeric PINEAU\",\n \"url\": \"https://github.com/aymericzip\"\n },\n \"contributors\": [\n {\n \"name\": \"Aymeric Pineau\",\n \"email\": \"ay.pineau@gmail.com\",\n \"url\": \"https://github.com/aymericzip\"\n }\n ],\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"browser\": \"./dist/esm/client.mjs\",\n \"require\": \"./dist/cjs/index.cjs\",\n \"import\": \"./dist/esm/index.mjs\"\n },\n \"./client\": {\n \"types\": \"./dist/types/client.d.ts\",\n \"require\": \"./dist/cjs/client.cjs\",\n \"import\": \"./dist/esm/client.mjs\"\n },\n \"./built\": {\n \"types\": \"./dist/types/built.d.ts\",\n \"require\": \"./dist/cjs/built.cjs\",\n \"import\": \"./dist/esm/built.mjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"dist/cjs/index.cjs\",\n \"module\": \"dist/esm/index.mjs\",\n \"types\": \"dist/types/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \".\": [\n \"./dist/types/index.d.ts\"\n ],\n \"client\": [\n \"./dist/types/client.d.ts\"\n ],\n \"built\": [\n \"./dist/types/built.d.ts\"\n ],\n \"package.json\": [\n \"./package.json\"\n ]\n }\n },\n \"files\": [\n \"./dist\",\n \"./package.json\"\n ],\n \"scripts\": {\n \"build\": \"tsdown --config tsdown.config.ts\",\n \"build:ci\": \"tsdown --config tsdown.config.ts\",\n \"clean\": \"rimraf ./dist .turbo\",\n \"dev\": \"tsdown --config tsdown.config.ts --watch\",\n \"format\": \"biome format . --check\",\n \"format:fix\": \"biome format --write .\",\n \"lint\": \"biome lint .\",\n \"lint:fix\": \"biome lint --write .\",\n \"prepublish\": \"cp -f ../../../README.md ./README.md\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"tsc --noEmit --project tsconfig.types.json\"\n },\n \"dependencies\": {\n \"@intlayer/types\": \"workspace:*\",\n \"deepmerge\": \"4.3.1\",\n \"dotenv\": \"16.6.1\",\n \"esbuild\": \"0.25.2\"\n },\n \"devDependencies\": {\n \"@types/node\": \"24.9.2\",\n \"@utils/ts-config\": \"workspace:*\",\n \"@utils/ts-config-types\": \"workspace:*\",\n \"@utils/tsdown-config\": \"workspace:*\",\n \"rimraf\": \"6.0.1\",\n \"tsdown\": \"0.15.11\",\n \"typescript\": \"5.9.3\",\n \"vitest\": \"4.0.5\"\n },\n \"peerDependencies\": {\n \"intlayer\": \"workspace:*\",\n \"react\": \">=16.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"intlayer\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n }\n },\n \"engines\": {\n \"node\": \">=14.18\"\n },\n \"bug\": {\n \"url\": \"https://github.com/aymericzip/intlayer/issues\"\n }\n}\n"],"mappings":";cAEa"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { cache } from "./cache.mjs";
|
|
2
|
-
import { logStack } from "./logStack.mjs";
|
|
3
2
|
import { dirname, join } from "node:path";
|
|
4
3
|
import { existsSync } from "node:fs";
|
|
5
4
|
|
|
@@ -26,7 +25,6 @@ const getPackageJsonPath = (startDir = process.cwd()) => {
|
|
|
26
25
|
if (parentDir === currentDir) break;
|
|
27
26
|
currentDir = parentDir;
|
|
28
27
|
}
|
|
29
|
-
logStack("test");
|
|
30
28
|
throw new Error(`Could not find package.json in current directory or any of the ${MAX_LEVELS} parent directories. Searched from: ${startDir}`);
|
|
31
29
|
};
|
|
32
30
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageJsonPath.mjs","names":[],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport {
|
|
1
|
+
{"version":3,"file":"getPackageJsonPath.mjs","names":[],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { cache } from './cache';\n\nexport const isESModule = typeof import.meta.url === 'string';\n\nconst MAX_LEVELS = 15;\n\ntype PackageJsonPathCache = {\n packageJsonPath: string;\n baseDir: string;\n};\n\nexport const getPackageJsonPath = (\n startDir: string = process.cwd()\n): PackageJsonPathCache => {\n const checkedCache = cache.get<PackageJsonPathCache>(\n 'packageJsonPath',\n startDir\n );\n\n if (checkedCache) return checkedCache;\n\n let currentDir = startDir;\n\n for (let level = 0; level < MAX_LEVELS; level++) {\n const packageJsonPath = join(currentDir, 'package.json');\n\n if (existsSync(packageJsonPath)) {\n cache.set('packageJsonPath', startDir, {\n packageJsonPath,\n baseDir: currentDir,\n });\n\n return { packageJsonPath, baseDir: currentDir };\n }\n\n const parentDir = dirname(currentDir);\n\n // If we've reached the root directory, stop\n if (parentDir === currentDir) {\n break;\n }\n\n currentDir = parentDir;\n }\n\n throw new Error(\n `Could not find package.json in current directory or any of the ${MAX_LEVELS} parent directories. Searched from: ${startDir}`\n );\n};\n"],"mappings":";;;;;AAIA,MAAa,aAAa,OAAO,OAAO,KAAK,QAAQ;AAErD,MAAM,aAAa;AAOnB,MAAa,sBACX,WAAmB,QAAQ,KAAK,KACP;CACzB,MAAM,eAAe,MAAM,IACzB,mBACA,SACD;AAED,KAAI,aAAc,QAAO;CAEzB,IAAI,aAAa;AAEjB,MAAK,IAAI,QAAQ,GAAG,QAAQ,YAAY,SAAS;EAC/C,MAAM,kBAAkB,KAAK,YAAY,eAAe;AAExD,MAAI,WAAW,gBAAgB,EAAE;AAC/B,SAAM,IAAI,mBAAmB,UAAU;IACrC;IACA,SAAS;IACV,CAAC;AAEF,UAAO;IAAE;IAAiB,SAAS;IAAY;;EAGjD,MAAM,YAAY,QAAQ,WAAW;AAGrC,MAAI,cAAc,WAChB;AAGF,eAAa;;AAGf,OAAM,IAAI,MACR,kEAAkE,WAAW,sCAAsC,WACpH"}
|
|
@@ -9,6 +9,7 @@ type GetConfigurationOptions = {
|
|
|
9
9
|
envFile?: string;
|
|
10
10
|
logFunctions?: LogFunctions;
|
|
11
11
|
require?: NodeJS.Require;
|
|
12
|
+
cache?: boolean;
|
|
12
13
|
} & Omit<SandBoxContextOptions, 'projectRequire'>;
|
|
13
14
|
type GetConfigurationAndFilePathResult = {
|
|
14
15
|
configuration: IntlayerConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfiguration.d.ts","names":[],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":[],"mappings":";;;;KAeY,uBAAA;;EAAA,QAAA,CAAA,EAEC,oBAFsB;EAEtB,GAAA,CAAA,EAAA,MAAA;EAKI,OAAA,CAAA,EAAA,MAAA;EAEL,YAAO,CAAA,EAFF,YAEE;
|
|
1
|
+
{"version":3,"file":"getConfiguration.d.ts","names":[],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":[],"mappings":";;;;KAeY,uBAAA;;EAAA,QAAA,CAAA,EAEC,oBAFsB;EAEtB,GAAA,CAAA,EAAA,MAAA;EAKI,OAAA,CAAA,EAAA,MAAA;EAEL,YAAO,CAAA,EAFF,YAEE;EAGV,OAAA,CAAA,EAHG,MAAA,CAAO,OAGV;EAAL,KAAA,CAAA,EAAA,OAAA;CAAI,GAAJ,IAAI,CAAC,qBAAD,EAAA,gBAAA,CAAA;AAEI,KAAA,iCAAA,GAAiC;EAQhC,aAAA,EAPI,cAOJ;EA8EA,qBAE0D,EAAA,MAAA,GAD3D,SAAA;;;;;cA/EC,wCACD,4BACT;;;;cA4EU,6BACD,4BACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","names":[],"sources":["../../../src/utils/cache.ts"],"sourcesContent":[],"mappings":";;;;cAuSa,2CAEX;AAFF;AAOE,KAgBG,QAAA,GAAQ,OAAA;AAGA,cAAA,QAAuB,EAAA,CAAA,CAAA,CAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"cache.d.ts","names":[],"sources":["../../../src/utils/cache.ts"],"sourcesContent":[],"mappings":";;;;cAuSa,2CAEX;AAFF;AAOE,KAgBG,QAAA,GAAQ,OAAA;AAGA,cAAA,QAAuB,EAAA,CAAA,CAAA,CAAA,CAAA,GAAA,GAAc,EAAd,QAAc,EAAA,EAAA,GAAD,CAAC,GAAA,SAAA;AAEhD,KAEG,YAAA,CAAA,CAAY,CAAA,GAAA,CAAA,GAAA,IAAA,EAAgB,QAAA,EAAmB,EAAC,KAAA,EAAD,CAAC,CAAA;AAExC,cAAA,QAAqC,EAAA,CAAb,CAAA,CAAA,CAAA,GAAA,IAAA,EAAA,YAAY,CAAC,CAAD,CAAA,EAAA,GAAA,IAAA;AAMpC,cAAA,UAGZ,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,GAAA,IAAA;AAEY,cAAA,aAEZ,EAAA,GAAA,GAAA,IAAA;AAEY,cAAA,KAIZ,EAAA;EAzBmC,GAAA,EAAA,CAAA,CAAA,CAAA,CAAA,GAAA,GAAA,EAAA,QAAA,EAAA,EAAA,GAAa,CAAb,GAAA,SAAA;EAAa,GAAA,EAAA,CAAA,CAAA,CAAA,CAAA,GAAA,IAAA,EAMZ,YANY,CAMC,CAND,CAAA,EAAA,GAAA,IAAA;EAMC,KAAA,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,GAAA,IAAA;CAAb;;AAmBnC,KAIG,iBAAA,GAAiB;EAoCT;EACK,UAAA,CAAA,EAAA,OAAA;EACV;EACI,KAAA,CAAA,EAAA,MAAA;EAoHkB;EAAR,SAAA,CAAA,EAAA,MAAA;EAWW;EAQZ,SAAA,CAAA,EAAA,MAAA;EAQG;EAgBD,QAAA,CAAA,EAAA,OAAA;CAAO;;cAlKjB,6BACK,sBACV,sBACI;;gBAoHU,QAAQ;;2BAWG;;eAQZ;;kBAQG;;iBAgBD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageJsonPath.d.ts","names":[],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"getPackageJsonPath.d.ts","names":[],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":[],"mappings":";cAIa;AAAb,KAIK,oBAAA,GAJwD;EAIxD,eAAA,EAAA,MAAoB;EAKZ,OAAA,EAAA,MAAA;;cAAA,2CAEV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/config",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.4",
|
|
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": [
|
|
@@ -93,23 +93,23 @@
|
|
|
93
93
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"@intlayer/types": "7.0.
|
|
96
|
+
"@intlayer/types": "7.0.4",
|
|
97
97
|
"deepmerge": "4.3.1",
|
|
98
98
|
"dotenv": "16.6.1",
|
|
99
99
|
"esbuild": "0.25.2"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@types/node": "24.9.2",
|
|
103
|
-
"@utils/ts-config": "7.0.
|
|
104
|
-
"@utils/ts-config-types": "7.0.
|
|
105
|
-
"@utils/tsdown-config": "7.0.
|
|
103
|
+
"@utils/ts-config": "7.0.4",
|
|
104
|
+
"@utils/ts-config-types": "7.0.4",
|
|
105
|
+
"@utils/tsdown-config": "7.0.4",
|
|
106
106
|
"rimraf": "6.0.1",
|
|
107
107
|
"tsdown": "0.15.11",
|
|
108
108
|
"typescript": "5.9.3",
|
|
109
109
|
"vitest": "4.0.5"
|
|
110
110
|
},
|
|
111
111
|
"peerDependencies": {
|
|
112
|
-
"intlayer": "7.0.
|
|
112
|
+
"intlayer": "7.0.4",
|
|
113
113
|
"react": ">=16.0.0"
|
|
114
114
|
},
|
|
115
115
|
"peerDependenciesMeta": {
|