@intlayer/config 8.1.11 → 8.2.1
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 +1 -1
- package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/loadEnvFile.cjs +1 -1
- package/dist/cjs/loadEnvFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/parseFileContent.cjs +1 -1
- package/dist/esm/configFile/getConfiguration.mjs +1 -1
- package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/loadEnvFile.mjs +1 -1
- package/dist/esm/loadEnvFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/parseFileContent.mjs +1 -1
- package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -5
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../loadEnvFile.cjs`),t=require(`../logger.cjs`),n=require(`../utils/cacheMemory.cjs`),r=require(`../utils/getPackageJsonPath.cjs`),i=require(`./buildConfigurationFields.cjs`),a=require(`./loadConfigurationFile.cjs`),o=require(`./searchConfigurationFile.cjs`);let s=require(`node:path`),c=require(`/Users/aymericpineau/Documents/node_modules/@intlayer/chokidar/dist/esm/utils/index.mjs`),l=require(`defu`);const u=u=>{let d;try{d=u?.baseDir??r.getPackageJsonPath().baseDir}catch{return{configuration:i.buildConfigurationFields({},u?.baseDir,u?.logFunctions),configurationFilePath:void 0}}let f=n.cacheMemory.get(u);if(f)return f;let{configurationFilePath:p,numCustomConfiguration:m}=o.searchConfigurationFile(d),h;h=p?i.buildConfigurationFields(a.loadConfigurationFile(p,{projectRequire:u?.require,envVarOptions:{env:u?.env,envFile:u?.envFile},additionalEnvVars:u?.additionalEnvVars,aliases:u?.aliases}),u?.baseDir,u?.logFunctions):i.buildConfigurationFields({},u?.baseDir,u?.logFunctions);let g=(0,l.defu)(u?.require?{build:{require:u?.require,cache:u?.cache}}:{},h),_=(0,l.defu)(u?.override??{},g);n.cacheMemory.set(u,{configuration:_,configurationFilePath:p});let v=t.getAppLogger(_);if(m===0)v(`Configuration file not found, using default configuration.`,{isVerbose:!0});else{let t=(0,s.relative)(d,p);if(m===1){let n=e.getEnvFilePath(u?.env,u?.envFile);v(`Configuration loaded ${(0,c.formatPath)(t)}${n?` - Env: ${(0,c.formatPath)(n)}`:``}`,{isVerbose:!0})}else v(`Multiple configuration files found, using ${t}.`,{isVerbose:!0})}return{configuration:_,configurationFilePath:p}},d=e=>u(e).configuration;exports.getConfiguration=d,exports.getConfigurationAndFilePath=u;
|
|
2
2
|
//# sourceMappingURL=getConfiguration.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfiguration.cjs","names":["getPackageJsonPath","buildConfigurationFields","cacheMemory","searchConfigurationFile","loadConfigurationFile"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport { defu } from 'defu';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport {
|
|
1
|
+
{"version":3,"file":"getConfiguration.cjs","names":["getPackageJsonPath","buildConfigurationFields","cacheMemory","searchConfigurationFile","loadConfigurationFile","getAppLogger","getEnvFilePath"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { formatPath } from '@intlayer/chokidar/utils';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport { defu } from 'defu';\nimport { getEnvFilePath } from '../loadEnvFile';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { getAppLogger } from '../logger';\nimport { cacheMemory } from '../utils/cacheMemory';\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 let baseDir: string | undefined;\n\n try {\n // Can fail in some environments (e.g. MCP server, VScode extension)\n baseDir = options?.baseDir ?? getPackageJsonPath().baseDir;\n } catch (_err) {\n // Return default config if the package.json is not found\n return {\n configuration: buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions\n ),\n configurationFilePath: undefined,\n };\n }\n\n const cachedConfiguration =\n cacheMemory.get<GetConfigurationAndFilePathResult>(options);\n\n if (cachedConfiguration) return cachedConfiguration;\n\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n let storedConfiguration: IntlayerConfig;\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 } else {\n // No configuration file found, use default configuration\n storedConfiguration = buildConfigurationFields(\n {},\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 = defu(\n projectRequireConfig,\n storedConfiguration\n ) as IntlayerConfig;\n\n const configuration = defu(\n options?.override ?? {},\n configWithProjectRequire\n ) as IntlayerConfig;\n\n cacheMemory.set(options, {\n configuration,\n configurationFilePath,\n });\n\n const appLogger = getAppLogger(configuration);\n\n if (numCustomConfiguration === 0) {\n appLogger('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 const dotEnvFilePath = getEnvFilePath(options?.env, options?.envFile);\n\n appLogger(\n `Configuration loaded ${formatPath(relativeOutputPath)}${dotEnvFilePath ? ` - Env: ${formatPath(dotEnvFilePath)}` : ''}`,\n {\n isVerbose: true,\n }\n );\n } else {\n appLogger(\n `Multiple configuration files found, using ${relativeOutputPath}.`,\n {\n isVerbose: true,\n }\n );\n }\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"],"mappings":"shBAuCA,MAAa,EACX,GACsC,CACtC,IAAI,EAEJ,GAAI,CAEF,EAAU,GAAS,SAAWA,EAAAA,oBAAoB,CAAC,aACtC,CAEb,MAAO,CACL,cAAeC,EAAAA,yBACb,EAAE,CACF,GAAS,QACT,GAAS,aACV,CACD,sBAAuB,IAAA,GACxB,CAGH,IAAM,EACJC,EAAAA,YAAY,IAAuC,EAAQ,CAE7D,GAAI,EAAqB,OAAO,EAGhC,GAAM,CAAE,wBAAuB,0BAC7BC,EAAAA,wBAAwB,EAAQ,CAE9B,EAEJ,AAuBE,EAvBE,EAgBoBF,EAAAA,yBAbpBG,EAAAA,sBAAsB,EAAuB,CAC3C,eAAgB,GAAS,QAEzB,cAAe,CACb,IAAK,GAAS,IACd,QAAS,GAAS,QACnB,CAED,kBAAmB,GAAS,kBAC5B,QAAS,GAAS,QACnB,CAAC,CAKF,GAAS,QACT,GAAS,aACV,CAGqBH,EAAAA,yBACpB,EAAE,CACF,GAAS,QACT,GAAS,aACV,CAcH,IAAM,GAAA,EAAA,EAAA,MAT6C,GAAS,QACxD,CACE,MAAO,CACL,QAAS,GAAS,QAClB,MAAO,GAAS,MACjB,CACF,CACD,EAAE,CAIJ,EACD,CAEK,GAAA,EAAA,EAAA,MACJ,GAAS,UAAY,EAAE,CACvB,EACD,CAED,EAAA,YAAY,IAAI,EAAS,CACvB,gBACA,wBACD,CAAC,CAEF,IAAM,EAAYI,EAAAA,aAAa,EAAc,CAE7C,GAAI,IAA2B,EAC7B,EAAU,6DAA8D,CACtE,UAAW,GACZ,CAAC,KACG,CACL,IAAM,GAAA,EAAA,EAAA,UAA8B,EAAS,EAAuB,CAEpE,GAAI,IAA2B,EAAG,CAChC,IAAM,EAAiBC,EAAAA,eAAe,GAAS,IAAK,GAAS,QAAQ,CAErE,EACE,yBAAA,EAAA,EAAA,YAAmC,EAAmB,GAAG,EAAiB,YAAA,EAAA,EAAA,YAAsB,EAAe,GAAK,KACpH,CACE,UAAW,GACZ,CACF,MAED,EACE,6CAA6C,EAAmB,GAChE,CACE,UAAW,GACZ,CACF,CAIL,MAAO,CACL,gBACA,wBACD,EAMU,EACX,GACmB,EAA4B,EAAQ,CAAC"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./loadEnvFile.cjs`),t=require(`./logger.cjs`),n=require(`./utils/cacheMemory.cjs`),r=require(`./utils/getPackageJsonPath.cjs`),i=require(`./utils/getExtension.cjs`),a=require(`./utils/normalizePath.cjs`),o=require(`./utils/alias.cjs`),s=require(`./utils/cacheDisk.cjs`),c=require(`./utils/ESMxCJSHelpers.cjs`),l=require(`./utils/clearModuleCache.cjs`),u=require(`./utils/compareVersions.cjs`),d=require(`./utils/extractErrorMessage.cjs`),f=require(`./utils/logStack.cjs`),p=require(`./utils/retryManager.cjs`),m=require(`./utils/stringFormatter/camelCaseToKebabCase.cjs`),h=require(`./utils/stringFormatter/camelCaseToSentence.cjs`),g=require(`./utils/stringFormatter/kebabCaseToCamelCase.cjs`),_=require(`./utils/stringFormatter/toLowerCamelCase.cjs`),v=require(`./configFile/buildConfigurationFields.cjs`),y=require(`./loadExternalFile/parseFileContent.cjs`),b=require(`./loadExternalFile/bundleFile.cjs`),x=require(`./loadExternalFile/transpileTSToCJS.cjs`),S=require(`./loadExternalFile/loadExternalFile.cjs`),C=require(`./configFile/searchConfigurationFile.cjs`),w=require(`./configFile/getConfiguration.cjs`),T=require(`./defaultValues/index.cjs`),E=require(`./loadExternalFile/bundleJSFile.cjs`);exports.ANSIColors=t.ANSIColors,Object.defineProperty(exports,`DefaultValues`,{enumerable:!0,get:function(){return T.defaultValues_exports}}),exports.buildConfigurationFields=v.buildConfigurationFields,exports.bundleFile=b.bundleFile,exports.bundleFileSync=b.bundleFileSync,exports.bundleJSFile=E.bundleJSFile,exports.cacheDisk=s.cacheDisk,exports.cacheMemory=n.cacheMemory,exports.camelCaseToKebabCase=m.camelCaseToKebabCase,exports.camelCaseToSentence=h.camelCaseToSentence,exports.clearAllCache=n.clearAllCache,exports.clearCache=n.clearCache,exports.clearModuleCache=l.clearModuleCache,exports.clock=t.clock,exports.colon=t.colon,exports.colorize=t.colorize,exports.colorizeKey=t.colorizeKey,exports.colorizeLocales=t.colorizeLocales,exports.colorizeNumber=t.colorizeNumber,exports.colorizePath=t.colorizePath,exports.compareVersions=u.compareVersions,exports.computeKeyId=n.computeKeyId,exports.configESMxCJSRequire=c.configESMxCJSRequire,exports.configurationFilesCandidates=C.configurationFilesCandidates,exports.extractErrorMessage=d.extractErrorMessage,exports.getAlias=o.getAlias,exports.getAppLogger=t.getAppLogger,exports.getCache=n.getCache,exports.getConfiguration=w.getConfiguration,exports.getConfigurationAndFilePath=w.getConfigurationAndFilePath,exports.getEnvFilePath=e.getEnvFilePath,exports.getExtension=i.getExtension,exports.getLoader=b.getLoader,exports.getPackageJsonPath=r.getPackageJsonPath,exports.getPrefix=t.getPrefix,exports.getProjectRequire=c.getProjectRequire,exports.getSandBoxContext=y.getSandBoxContext,exports.isESModule=c.isESModule,exports.kebabCaseToCamelCase=g.kebabCaseToCamelCase,exports.loadEnvFile=e.loadEnvFile,exports.loadExternalFile=S.loadExternalFile,exports.loadExternalFileSync=S.loadExternalFileSync,exports.logStack=f.logStack,exports.logger=t.logger,exports.normalizePath=a.normalizePath,exports.parseFileContent=y.parseFileContent,exports.removeColor=t.removeColor,exports.retryManager=p.retryManager,exports.searchConfigurationFile=C.searchConfigurationFile,exports.setCache=n.setCache,exports.setPrefix=t.setPrefix,exports.spinnerFrames=t.spinnerFrames,exports.stableStringify=n.stableStringify,exports.toLowerCamelCase=_.toLowerCamelCase,exports.transpileTSToCJS=x.transpileTSToCJS,exports.transpileTSToCJSSync=x.transpileTSToCJSSync,exports.v=t.v,exports.x=t.x;
|
package/dist/cjs/loadEnvFile.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_virtual/_rolldown/runtime.cjs`);let t=require(`node:fs`),n=require(`dotenv`);n=e.__toESM(n);const r=process.env.NODE_ENV??`development`,i=(e=process.env.NODE_ENV??`development`,n)=>(n?[n]:[`.env.${e}.local`,`.env.${e}`,`.env.local`,`.env`]).find(t.existsSync),a=e=>{let t=e?.env??r,
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_virtual/_rolldown/runtime.cjs`);let t=require(`node:fs`),n=require(`dotenv`);n=e.__toESM(n);const r=process.env.NODE_ENV??`development`,i=(e=process.env.NODE_ENV??`development`,n)=>(n?[n]:[`.env.${e}.local`,`.env.${e}`,`.env.local`,`.env`]).find(t.existsSync),a=e=>{let t=i(e?.env??r,e?.envFile);if(!t)return{};let a={};return n.default.config({path:t,processEnv:a,quiet:!0}),a};exports.getEnvFilePath=i,exports.loadEnvFile=a;
|
|
2
2
|
//# sourceMappingURL=loadEnvFile.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadEnvFile.cjs","names":["existsSync"],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions>) => {\n const env = options?.env ?? DEFAULT_ENV;\n\n const envFiles = options?.envFile\n
|
|
1
|
+
{"version":3,"file":"loadEnvFile.cjs","names":["existsSync"],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions>) => {\n const env = options?.env ?? DEFAULT_ENV;\n\n const envFiles = getEnvFilePath(env, options?.envFile);\n\n if (!envFiles) {\n return {};\n }\n\n const result = {};\n\n dotenv.config({\n path: envFiles,\n processEnv: result,\n quiet: true,\n });\n\n return result; // Return the parsed env object\n};\n"],"mappings":"mLAGA,MAAM,EAAc,QAAQ,IAAI,UAAY,cAO/B,GACX,EAAc,QAAQ,IAAI,UAAY,cACtC,KAEiB,EACb,CAAC,EAAQ,CACT,CAAC,QAAQ,EAAI,QAAS,QAAQ,IAAO,aAAc,OAAO,EAE9C,KAAKA,EAAAA,WAAW,CAGrB,EAAe,GAA0C,CAGpE,IAAM,EAAW,EAFL,GAAS,KAAO,EAES,GAAS,QAAQ,CAEtD,GAAI,CAAC,EACH,MAAO,EAAE,CAGX,IAAM,EAAS,EAAE,CAQjB,OANA,EAAA,QAAO,OAAO,CACZ,KAAM,EACN,WAAY,EACZ,MAAO,GACR,CAAC,CAEK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../loadEnvFile.cjs`),n=require(`../utils/ESMxCJSHelpers.cjs`);let r=require(`node:vm`),i=require(`esbuild`);i=e.__toESM(i);const a=e=>{let{envVarOptions:r,projectRequire:a,additionalEnvVars:o,mocks:s,aliases:c}=e??{},l={},u=typeof a==`function`?a:n.getProjectRequire(),d=(()=>{let e=Object.assign({esbuild:i},s),t=Object.assign({},c),n=function(n){let r=t?.[n]?t[n]:n;return e&&Object.hasOwn(e,r)?e[r]:r!==n&&e&&Object.hasOwn(e,n)?e[n]:u(r)};return n.resolve=u.resolve.bind(u),n.main=u.main,n.extensions=u.extensions,n.cache=u.cache,n})();try{l={React:u(`react`)}}catch{l={React:{createElement:(e,t,...n)=>({type:e,props:{...t,children:n.length<=1?n[0]:n}}),Fragment:Symbol.for(`react.fragment`)}}}let f={exports:{default:{}},module:{exports:{}},process:{...process,env:{...process.env,...t.loadEnvFile(r),...o}},console,require:d,...l};return Object.getOwnPropertyNames(globalThis).forEach(e=>{e in f||(f[e]=globalThis[e])}),f},o=(e,t)=>{let n=a(t);(0,r.runInNewContext)(`"use strict";\n${e}`,n);let i=[n.exports?.default,n.module?.exports?.defaults,n.module?.exports?.default,n.module?.exports];for(let e of i)if(e&&typeof e==`object`&&Object.keys(e).length>0)return e};exports.getSandBoxContext=a,exports.parseFileContent=o;
|
|
2
2
|
//# sourceMappingURL=parseFileContent.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getEnvFilePath as e}from"../loadEnvFile.mjs";import{getAppLogger as t}from"../logger.mjs";import{cacheMemory as n}from"../utils/cacheMemory.mjs";import{getPackageJsonPath as r}from"../utils/getPackageJsonPath.mjs";import{buildConfigurationFields as i}from"./buildConfigurationFields.mjs";import{loadConfigurationFile as a}from"./loadConfigurationFile.mjs";import{searchConfigurationFile as o}from"./searchConfigurationFile.mjs";import{relative as s}from"node:path";import{formatPath as c}from"/Users/aymericpineau/Documents/node_modules/@intlayer/chokidar/dist/esm/utils/index.mjs";import{defu as l}from"defu";const u=u=>{let d;try{d=u?.baseDir??r().baseDir}catch{return{configuration:i({},u?.baseDir,u?.logFunctions),configurationFilePath:void 0}}let f=n.get(u);if(f)return f;let{configurationFilePath:p,numCustomConfiguration:m}=o(d),h;h=i(p?a(p,{projectRequire:u?.require,envVarOptions:{env:u?.env,envFile:u?.envFile},additionalEnvVars:u?.additionalEnvVars,aliases:u?.aliases}):{},u?.baseDir,u?.logFunctions);let g=l(u?.require?{build:{require:u?.require,cache:u?.cache}}:{},h),_=l(u?.override??{},g);n.set(u,{configuration:_,configurationFilePath:p});let v=t(_);if(m===0)v(`Configuration file not found, using default configuration.`,{isVerbose:!0});else{let t=s(d,p);if(m===1){let n=e(u?.env,u?.envFile);v(`Configuration loaded ${c(t)}${n?` - Env: ${c(n)}`:``}`,{isVerbose:!0})}else v(`Multiple configuration files found, using ${t}.`,{isVerbose:!0})}return{configuration:_,configurationFilePath:p}},d=e=>u(e).configuration;export{d as getConfiguration,u as getConfigurationAndFilePath};
|
|
2
2
|
//# sourceMappingURL=getConfiguration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfiguration.mjs","names":[],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport { defu } from 'defu';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport {
|
|
1
|
+
{"version":3,"file":"getConfiguration.mjs","names":[],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { formatPath } from '@intlayer/chokidar/utils';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport { defu } from 'defu';\nimport { getEnvFilePath } from '../loadEnvFile';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { getAppLogger } from '../logger';\nimport { cacheMemory } from '../utils/cacheMemory';\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 let baseDir: string | undefined;\n\n try {\n // Can fail in some environments (e.g. MCP server, VScode extension)\n baseDir = options?.baseDir ?? getPackageJsonPath().baseDir;\n } catch (_err) {\n // Return default config if the package.json is not found\n return {\n configuration: buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions\n ),\n configurationFilePath: undefined,\n };\n }\n\n const cachedConfiguration =\n cacheMemory.get<GetConfigurationAndFilePathResult>(options);\n\n if (cachedConfiguration) return cachedConfiguration;\n\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n let storedConfiguration: IntlayerConfig;\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 } else {\n // No configuration file found, use default configuration\n storedConfiguration = buildConfigurationFields(\n {},\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 = defu(\n projectRequireConfig,\n storedConfiguration\n ) as IntlayerConfig;\n\n const configuration = defu(\n options?.override ?? {},\n configWithProjectRequire\n ) as IntlayerConfig;\n\n cacheMemory.set(options, {\n configuration,\n configurationFilePath,\n });\n\n const appLogger = getAppLogger(configuration);\n\n if (numCustomConfiguration === 0) {\n appLogger('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 const dotEnvFilePath = getEnvFilePath(options?.env, options?.envFile);\n\n appLogger(\n `Configuration loaded ${formatPath(relativeOutputPath)}${dotEnvFilePath ? ` - Env: ${formatPath(dotEnvFilePath)}` : ''}`,\n {\n isVerbose: true,\n }\n );\n } else {\n appLogger(\n `Multiple configuration files found, using ${relativeOutputPath}.`,\n {\n isVerbose: true,\n }\n );\n }\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"],"mappings":"ymBAuCA,MAAa,EACX,GACsC,CACtC,IAAI,EAEJ,GAAI,CAEF,EAAU,GAAS,SAAW,GAAoB,CAAC,aACtC,CAEb,MAAO,CACL,cAAe,EACb,EAAE,CACF,GAAS,QACT,GAAS,aACV,CACD,sBAAuB,IAAA,GACxB,CAGH,IAAM,EACJ,EAAY,IAAuC,EAAQ,CAE7D,GAAI,EAAqB,OAAO,EAGhC,GAAM,CAAE,wBAAuB,0BAC7B,EAAwB,EAAQ,CAE9B,EAEJ,AAuBE,EAPsB,EAhBpB,EAGA,EAAsB,EAAuB,CAC3C,eAAgB,GAAS,QAEzB,cAAe,CACb,IAAK,GAAS,IACd,QAAS,GAAS,QACnB,CAED,kBAAmB,GAAS,kBAC5B,QAAS,GAAS,QACnB,CAAC,CAWF,EAAE,CANF,GAAS,QACT,GAAS,aAQV,CAcH,IAAM,EAA2B,EATkB,GAAS,QACxD,CACE,MAAO,CACL,QAAS,GAAS,QAClB,MAAO,GAAS,MACjB,CACF,CACD,EAAE,CAIJ,EACD,CAEK,EAAgB,EACpB,GAAS,UAAY,EAAE,CACvB,EACD,CAED,EAAY,IAAI,EAAS,CACvB,gBACA,wBACD,CAAC,CAEF,IAAM,EAAY,EAAa,EAAc,CAE7C,GAAI,IAA2B,EAC7B,EAAU,6DAA8D,CACtE,UAAW,GACZ,CAAC,KACG,CACL,IAAM,EAAqB,EAAS,EAAS,EAAuB,CAEpE,GAAI,IAA2B,EAAG,CAChC,IAAM,EAAiB,EAAe,GAAS,IAAK,GAAS,QAAQ,CAErE,EACE,wBAAwB,EAAW,EAAmB,GAAG,EAAiB,WAAW,EAAW,EAAe,GAAK,KACpH,CACE,UAAW,GACZ,CACF,MAED,EACE,6CAA6C,EAAmB,GAChE,CACE,UAAW,GACZ,CACF,CAIL,MAAO,CACL,gBACA,wBACD,EAMU,EACX,GACmB,EAA4B,EAAQ,CAAC"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getEnvFilePath as e,loadEnvFile as t}from"./loadEnvFile.mjs";import{ANSIColors as n,clock as r,colon as i,colorize as a,colorizeKey as o,colorizeLocales as s,colorizeNumber as c,colorizePath as l,getAppLogger as u,getPrefix as d,logger as f,removeColor as p,setPrefix as m,spinnerFrames as h,v as g,x as _}from"./logger.mjs";import{cacheMemory as v,clearAllCache as y,clearCache as b,computeKeyId as x,getCache as S,setCache as C,stableStringify as w}from"./utils/cacheMemory.mjs";import{getPackageJsonPath as T}from"./utils/getPackageJsonPath.mjs";import{getExtension as E}from"./utils/getExtension.mjs";import{normalizePath as D}from"./utils/normalizePath.mjs";import{getAlias as O}from"./utils/alias.mjs";import{cacheDisk as k}from"./utils/cacheDisk.mjs";import{configESMxCJSRequire as A,getProjectRequire as j,isESModule as M}from"./utils/ESMxCJSHelpers.mjs";import{clearModuleCache as N}from"./utils/clearModuleCache.mjs";import{compareVersions as P}from"./utils/compareVersions.mjs";import{extractErrorMessage as F}from"./utils/extractErrorMessage.mjs";import{logStack as I}from"./utils/logStack.mjs";import{retryManager as L}from"./utils/retryManager.mjs";import{camelCaseToKebabCase as R}from"./utils/stringFormatter/camelCaseToKebabCase.mjs";import{camelCaseToSentence as z}from"./utils/stringFormatter/camelCaseToSentence.mjs";import{kebabCaseToCamelCase as B}from"./utils/stringFormatter/kebabCaseToCamelCase.mjs";import{toLowerCamelCase as V}from"./utils/stringFormatter/toLowerCamelCase.mjs";import{buildConfigurationFields as H}from"./configFile/buildConfigurationFields.mjs";import{getSandBoxContext as U,parseFileContent as W}from"./loadExternalFile/parseFileContent.mjs";import{bundleFile as G,bundleFileSync as K,getLoader as q}from"./loadExternalFile/bundleFile.mjs";import{transpileTSToCJS as J,transpileTSToCJSSync as Y}from"./loadExternalFile/transpileTSToCJS.mjs";import{loadExternalFile as X,loadExternalFileSync as Z}from"./loadExternalFile/loadExternalFile.mjs";import{configurationFilesCandidates as Q,searchConfigurationFile as $}from"./configFile/searchConfigurationFile.mjs";import{getConfiguration as ee,getConfigurationAndFilePath as te}from"./configFile/getConfiguration.mjs";import{defaultValues_exports as ne}from"./defaultValues/index.mjs";import{bundleJSFile as re}from"./loadExternalFile/bundleJSFile.mjs";export{n as ANSIColors,ne as DefaultValues,H as buildConfigurationFields,G as bundleFile,K as bundleFileSync,re as bundleJSFile,k as cacheDisk,v as cacheMemory,R as camelCaseToKebabCase,z as camelCaseToSentence,y as clearAllCache,b as clearCache,N as clearModuleCache,r as clock,i as colon,a as colorize,o as colorizeKey,s as colorizeLocales,c as colorizeNumber,l as colorizePath,P as compareVersions,x as computeKeyId,A as configESMxCJSRequire,Q as configurationFilesCandidates,F as extractErrorMessage,O as getAlias,u as getAppLogger,S as getCache,ee as getConfiguration,te as getConfigurationAndFilePath,e as getEnvFilePath,E as getExtension,q as getLoader,T as getPackageJsonPath,d as getPrefix,j as getProjectRequire,U as getSandBoxContext,M as isESModule,B as kebabCaseToCamelCase,t as loadEnvFile,X as loadExternalFile,Z as loadExternalFileSync,I as logStack,f as logger,D as normalizePath,W as parseFileContent,p as removeColor,L as retryManager,$ as searchConfigurationFile,C as setCache,m as setPrefix,h as spinnerFrames,w as stableStringify,V as toLowerCamelCase,J as transpileTSToCJS,Y as transpileTSToCJSSync,g as v,_ as x};
|
package/dist/esm/loadEnvFile.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{existsSync as e}from"node:fs";import t from"dotenv";const n=(t=`production`,n)=>(n?[n]:[`.env.${t}.local`,`.env.${t}`,`.env.local`,`.env`]).find(e),r=e=>{let n
|
|
1
|
+
import{existsSync as e}from"node:fs";import t from"dotenv";const n=(t=`production`,n)=>(n?[n]:[`.env.${t}.local`,`.env.${t}`,`.env.local`,`.env`]).find(e),r=e=>{let r=n(e?.env??`production`,e?.envFile);if(!r)return{};let i={};return t.config({path:r,processEnv:i,quiet:!0}),i};export{n as getEnvFilePath,r as loadEnvFile};
|
|
2
2
|
//# sourceMappingURL=loadEnvFile.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadEnvFile.mjs","names":[],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions>) => {\n const env = options?.env ?? DEFAULT_ENV;\n\n const envFiles = options?.envFile\n
|
|
1
|
+
{"version":3,"file":"loadEnvFile.mjs","names":[],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions>) => {\n const env = options?.env ?? DEFAULT_ENV;\n\n const envFiles = getEnvFilePath(env, options?.envFile);\n\n if (!envFiles) {\n return {};\n }\n\n const result = {};\n\n dotenv.config({\n path: envFiles,\n processEnv: result,\n quiet: true,\n });\n\n return result; // Return the parsed env object\n};\n"],"mappings":"2DAGA,MAOa,GACX,EAAA,aACA,KAEiB,EACb,CAAC,EAAQ,CACT,CAAC,QAAQ,EAAI,QAAS,QAAQ,IAAO,aAAc,OAAO,EAE9C,KAAK,EAAW,CAGrB,EAAe,GAA0C,CAGpE,IAAM,EAAW,EAFL,GAAS,KAAO,aAES,GAAS,QAAQ,CAEtD,GAAI,CAAC,EACH,MAAO,EAAE,CAGX,IAAM,EAAS,EAAE,CAQjB,OANA,EAAO,OAAO,CACZ,KAAM,EACN,WAAY,EACZ,MAAO,GACR,CAAC,CAEK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{loadEnvFile as e}from"../loadEnvFile.mjs";import{getProjectRequire as t}from"../utils/ESMxCJSHelpers.mjs";import{runInNewContext as n}from"node:vm";import*as r from"esbuild";const i=n=>{let{envVarOptions:i,projectRequire:a,additionalEnvVars:o,mocks:s,aliases:c}=n??{},l={},u=typeof a==`function`?a:t(),d=(()=>{let e=Object.assign({esbuild:r},s),t=Object.assign({},c),n=function(n){let r=t?.[n]?t[n]:n;return e&&Object.hasOwn(e,r)?e[r]:r!==n&&e&&Object.hasOwn(e,n)?e[n]:u(r)};return n.resolve=u.resolve.bind(u),n.main=u.main,n.extensions=u.extensions,n.cache=u.cache,n})();try{l={React:u(`react`)}}catch{l={React:{createElement:(e,t,...n)=>({type:e,props:{...t,children:n.length<=1?n[0]:n}}),Fragment:Symbol.for(`react.fragment`)}}}let f={exports:{default:{}},module:{exports:{}},process:{...process,env:{...process.env,...e(i),...o}},console,require:d,...l};return Object.getOwnPropertyNames(globalThis).forEach(e=>{e in f||(f[e]=globalThis[e])}),f},a=(e,t)=>{let r=i(t);n(`"use strict";\n${e}`,r);let a=[r.exports?.default,r.module?.exports?.defaults,r.module?.exports?.default,r.module?.exports];for(let e of a)if(e&&typeof e==`object`&&Object.keys(e).length>0)return e};export{i as getSandBoxContext,a as parseFileContent};
|
|
2
2
|
//# sourceMappingURL=parseFileContent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfiguration.d.ts","names":[],"sources":["../../../src/configFile/getConfiguration.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"getConfiguration.d.ts","names":[],"sources":["../../../src/configFile/getConfiguration.ts"],"mappings":";;;;KAiBY,uBAAA;EACV,OAAA;EACA,QAAA,GAAW,oBAAA;EAEX,GAAA;EACA,OAAA;EAEA,YAAA,GAAe,YAAA;EAEf,OAAA,GAAU,MAAA,CAAO,OAAA;EAEjB,KAAA;AAAA,IACE,IAAA,CAAK,qBAAA;AAAA,KAEG,iCAAA;EACV,aAAA,EAAe,cAAA;EACf,qBAAA;AAAA;;;;cAMW,2BAAA,GACX,OAAA,GAAU,uBAAA,KACT,iCAAA;;;;cA0HU,gBAAA,GACX,OAAA,GAAU,uBAAA,KACT,cAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "./built.js";
|
|
2
1
|
import { index_d_exports } from "./defaultValues/index.js";
|
|
3
2
|
import { ANSIColors, Details, Logger, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, getPrefix, logger, removeColor, setPrefix, spinnerFrames, v, x } from "./logger.js";
|
|
4
3
|
import { extractErrorMessage } from "./utils/extractErrorMessage.js";
|
|
@@ -8,7 +7,6 @@ import { camelCaseToKebabCase } from "./utils/stringFormatter/camelCaseToKebabCa
|
|
|
8
7
|
import { camelCaseToSentence } from "./utils/stringFormatter/camelCaseToSentence.js";
|
|
9
8
|
import { kebabCaseToCamelCase } from "./utils/stringFormatter/kebabCaseToCamelCase.js";
|
|
10
9
|
import { toLowerCamelCase } from "./utils/stringFormatter/toLowerCamelCase.js";
|
|
11
|
-
import "./client.js";
|
|
12
10
|
import { buildConfigurationFields } from "./configFile/buildConfigurationFields.js";
|
|
13
11
|
import { LoadEnvFileOptions, getEnvFilePath, loadEnvFile } from "./loadEnvFile.js";
|
|
14
12
|
import { SandBoxContextOptions, getSandBoxContext, parseFileContent } from "./loadExternalFile/parseFileContent.js";
|
|
@@ -18,8 +16,6 @@ import { LoadExternalFileOptions, loadExternalFile, loadExternalFileSync } from
|
|
|
18
16
|
import { ESBuildPlugin, bundleFile, bundleFileSync, getLoader } from "./loadExternalFile/bundleFile.js";
|
|
19
17
|
import { bundleJSFile } from "./loadExternalFile/bundleJSFile.js";
|
|
20
18
|
import { transpileTSToCJS, transpileTSToCJSSync } from "./loadExternalFile/transpileTSToCJS.js";
|
|
21
|
-
import "./loadExternalFile/index.js";
|
|
22
|
-
import "./node.js";
|
|
23
19
|
import { GetAliasOptions, getAlias } from "./utils/alias.js";
|
|
24
20
|
import { CacheKey, cacheMemory, clearAllCache, clearCache, computeKeyId, getCache, setCache, stableStringify } from "./utils/cacheMemory.js";
|
|
25
21
|
import { cacheDisk } from "./utils/cacheDisk.js";
|
|
@@ -29,5 +25,4 @@ import { configESMxCJSRequire, getProjectRequire, isESModule } from "./utils/ESM
|
|
|
29
25
|
import { getExtension } from "./utils/getExtension.js";
|
|
30
26
|
import { getPackageJsonPath } from "./utils/getPackageJsonPath.js";
|
|
31
27
|
import { RetryManagerOptions, retryManager } from "./utils/retryManager.js";
|
|
32
|
-
import "./utils/index.js";
|
|
33
28
|
export { ANSIColors, CacheKey, index_d_exports as DefaultValues, Details, ESBuildPlugin, GetAliasOptions, GetConfigurationAndFilePathResult, GetConfigurationOptions, LoadEnvFileOptions, LoadExternalFileOptions, Logger, RetryManagerOptions, SandBoxContextOptions, buildConfigurationFields, bundleFile, bundleFileSync, bundleJSFile, cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearAllCache, clearCache, clearModuleCache, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, compareVersions, computeKeyId, configESMxCJSRequire, configurationFilesCandidates, extractErrorMessage, getAlias, getAppLogger, getCache, getConfiguration, getConfigurationAndFilePath, getEnvFilePath, getExtension, getLoader, getPackageJsonPath, getPrefix, getProjectRequire, getSandBoxContext, isESModule, kebabCaseToCamelCase, loadEnvFile, loadExternalFile, loadExternalFileSync, logStack, logger, normalizePath, parseFileContent, removeColor, retryManager, searchConfigurationFile, setCache, setPrefix, spinnerFrames, stableStringify, toLowerCamelCase, transpileTSToCJS, transpileTSToCJSSync, v, x };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/config",
|
|
3
|
-
"version": "8.1
|
|
3
|
+
"version": "8.2.1",
|
|
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": [
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
133
133
|
},
|
|
134
134
|
"dependencies": {
|
|
135
|
-
"@intlayer/types": "8.1
|
|
135
|
+
"@intlayer/types": "8.2.1",
|
|
136
136
|
"defu": "6.1.4",
|
|
137
137
|
"dotenv": "17.3.1",
|
|
138
138
|
"esbuild": "0.27.2",
|