@stacksjs/config 0.75.650 → 0.75.653

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.
@@ -24,8 +24,12 @@ export declare function defaultsForOverrides(): StacksConfig;
24
24
  * Both present is ambiguous rather than wrong, so it warns and takes the
25
25
  * primary instead of guessing silently.
26
26
  */
27
- export declare function resolveUserConfigName(names: [string, ...string[]], cwd?: ReturnType<typeof process.cwd>): string;
28
- export declare function userConfigUrl(name: string, cwd?: ReturnType<typeof process.cwd>): string;
27
+ export declare function resolveUserConfigName(names: [string, ...string[]], root?: unknown): string;
28
+ /*.ts`, and fell back to the framework defaults without a word:
29
+ * `config.database.default` was `sqlite` with DB_CONNECTION=postgres
30
+ * (stacksjs/stacks#3356).
31
+ */
32
+ export declare function userConfigUrl(name: string, root?: unknown): string;
29
33
  export declare const overrides: StacksConfig;
30
34
  export declare const overridesReady: Promise<StacksConfig>;
31
35
  export default overrides;
package/dist/overrides.js CHANGED
@@ -1,4 +1,4 @@
1
- import{existsSync}from"node:fs";import{resolve}from"node:path";import{pathToFileURL}from"node:url";import{defaults}from"./defaults";import{plainEnv}from"./plain-env";import{validateConfig}from"./validators";const skipConfigLoading=process.env.SKIP_CONFIG_LOADING==="true";const skipConfigValidation=process.env.SKIP_CONFIG_VALIDATION==="true";const OVERRIDES_KEY=Symbol.for("@stacksjs/config:overrides");const READY_KEY=Symbol.for("@stacksjs/config:overridesReady");export function defaultsForOverrides(){return{ai:{},analytics:{},app:{...defaults.app,name:plainEnv("APP_NAME")||defaults.app?.name||"Stacks",env:plainEnv("APP_ENV")||"production"},auth:{},cache:{},cli:{},cloud:{},cms:{},commerce:{},dashboard:{},database:{},dns:{},realtime:{},email:{},errors:{},featureFlags:{},git:{},hashing:{},images:{},library:{},logging:{},marketing:{},monitoring:{},notification:{},queue:{},payment:{},ports:{},saas:{},searchEngine:{},security:{},server:{},sites:{},forms:{},services:{},sms:{},socials:{},filesystems:{},team:{},ui:{}}}const globalScope=globalThis;const sharedOverrides=globalScope[OVERRIDES_KEY];export const overrides=sharedOverrides??(()=>{const created=defaultsForOverrides();globalScope[OVERRIDES_KEY]=created;return created})();const userConfigs=[["ai","ai"],["analytics","analytics"],["app","app"],["auth","auth"],["cache","cache"],["cli","cli"],["cloud","cloud"],["cms","cms"],["commerce","commerce"],["cors","cors"],["dashboard","dashboard"],["database","database"],["dns","dns"],["docs","docs"],["email","email"],["errors","errors"],["featureFlags","feature-flags"],["git","git"],["hashing","hashing"],["images","images"],["library","library"],["logging","logging"],["marketing","marketing"],["monitoring","monitoring"],["notification","notification"],["payment","payment"],["ports","ports"],["queue","queue"],["realtime","realtime"],["saas","saas"],["searchEngine","search-engine"],["security","security"],["sites","sites"],["forms","forms"],["server","server"],["services","services"],["sms","sms"],["socials","socials"],["filesystems","filesystems"],["team","team"],["ui","ui","stx"]];export function resolveUserConfigName(names,cwd=process.cwd()){const present=names.filter((candidate)=>existsSync(resolve(cwd,"config",`${candidate}.ts`)));if(present.length>1){console.warn(`[config] config/${present.join(".ts and config/")}.ts both exist and configure the same thing. `+`Using config/${present[0]}.ts; delete the other so every consumer agrees on one.`)}return present[0]??names[0]}export function userConfigUrl(name,cwd=process.cwd()){return pathToFileURL(resolve(cwd,"config",`${name}.ts`)).href}const sharedReady=globalScope[READY_KEY];export const overridesReady=sharedReady??(()=>{const promise=skipConfigLoading?Promise.resolve(overrides):Promise.all(userConfigs.map(async([key,...names])=>{const name=resolveUserConfigName(names);const modulePath=userConfigUrl(name);try{const mod=await import(modulePath);if(mod?.default!==undefined){overrides[key]=mod.default}}catch(err){const code=err?.code;const msg=err?.message??String(err);const isMissing=code==="ERR_MODULE_NOT_FOUND"||code==="MODULE_NOT_FOUND"||/Cannot find module/i.test(msg);if(!isMissing){console.warn(`[config] Failed to load ${String(key)} config from ${modulePath}: ${msg}`)}}})).then(()=>{if(!skipConfigValidation){const issues=validateConfig(overrides);if(issues.length>0){console.error("[config] Configuration issues detected:");for(const issue of issues){console.error(` • ${issue.path}: ${issue.message}`)}const summary=issues.map((i)=>` • ${i.path}: ${i.message}`).join(`
1
+ import{existsSync}from"node:fs";import{resolve}from"node:path";import{pathToFileURL}from"node:url";import{projectPath}from"@stacksjs/path";import{defaults}from"./defaults";import{plainEnv}from"./plain-env";import{validateConfig}from"./validators";const skipConfigLoading=process.env.SKIP_CONFIG_LOADING==="true";const skipConfigValidation=process.env.SKIP_CONFIG_VALIDATION==="true";const OVERRIDES_KEY=Symbol.for("@stacksjs/config:overrides");const READY_KEY=Symbol.for("@stacksjs/config:overridesReady");export function defaultsForOverrides(){return{ai:{},analytics:{},app:{...defaults.app,name:plainEnv("APP_NAME")||defaults.app?.name||"Stacks",env:plainEnv("APP_ENV")||"production"},auth:{},cache:{},cli:{},cloud:{},cms:{},commerce:{},dashboard:{},database:{},dns:{},realtime:{},email:{},errors:{},featureFlags:{},git:{},hashing:{},images:{},library:{},logging:{},marketing:{},monitoring:{},notification:{},queue:{},payment:{},ports:{},saas:{},searchEngine:{},security:{},server:{},sites:{},forms:{},services:{},sms:{},socials:{},filesystems:{},team:{},ui:{}}}const globalScope=globalThis;const sharedOverrides=globalScope[OVERRIDES_KEY];export const overrides=sharedOverrides??(()=>{const created=defaultsForOverrides();globalScope[OVERRIDES_KEY]=created;return created})();const userConfigs=[["ai","ai"],["analytics","analytics"],["app","app"],["auth","auth"],["cache","cache"],["cli","cli"],["cloud","cloud"],["cms","cms"],["commerce","commerce"],["cors","cors"],["dashboard","dashboard"],["database","database"],["dns","dns"],["docs","docs"],["email","email"],["errors","errors"],["featureFlags","feature-flags"],["git","git"],["hashing","hashing"],["images","images"],["library","library"],["logging","logging"],["marketing","marketing"],["monitoring","monitoring"],["notification","notification"],["payment","payment"],["ports","ports"],["queue","queue"],["realtime","realtime"],["saas","saas"],["searchEngine","search-engine"],["security","security"],["sites","sites"],["forms","forms"],["server","server"],["services","services"],["sms","sms"],["socials","socials"],["filesystems","filesystems"],["team","team"],["ui","ui","stx"]];export function resolveUserConfigName(names,root=projectPath()){const present=names.filter((candidate)=>existsSync(resolve(root,"config",`${candidate}.ts`)));if(present.length>1){console.warn(`[config] config/${present.join(".ts and config/")}.ts both exist and configure the same thing. `+`Using config/${present[0]}.ts; delete the other so every consumer agrees on one.`)}return present[0]??names[0]}export function userConfigUrl(name,root=projectPath()){return pathToFileURL(resolve(root,"config",`${name}.ts`)).href}const sharedReady=globalScope[READY_KEY];export const overridesReady=sharedReady??(()=>{const promise=skipConfigLoading?Promise.resolve(overrides):Promise.all(userConfigs.map(async([key,...names])=>{const name=resolveUserConfigName(names);const modulePath=userConfigUrl(name);try{const mod=await import(modulePath);if(mod?.default!==undefined){overrides[key]=mod.default}}catch(err){const code=err?.code;const msg=err?.message??String(err);const isMissing=code==="ERR_MODULE_NOT_FOUND"||code==="MODULE_NOT_FOUND"||/Cannot find module/i.test(msg);if(!isMissing){console.warn(`[config] Failed to load ${String(key)} config from ${modulePath}: ${msg}`)}}})).then(()=>{if(!skipConfigValidation){const issues=validateConfig(overrides);if(issues.length>0){console.error("[config] Configuration issues detected:");for(const issue of issues){console.error(` • ${issue.path}: ${issue.message}`)}const summary=issues.map((i)=>` • ${i.path}: ${i.message}`).join(`
2
2
  `);throw new Error(`[config] ${issues.length} configuration issue(s) detected at boot:
3
3
  ${summary}
4
4
  `+`Set SKIP_CONFIG_VALIDATION=true to bypass (e.g. when running migrations against partial config).`)}}return overrides});globalScope[READY_KEY]=promise;return promise})();export default overrides;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/config",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.650",
5
+ "version": "0.75.653",
6
6
  "description": "The Stacks config helper methods.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -55,16 +55,16 @@
55
55
  "prepublishOnly": "bun run build"
56
56
  },
57
57
  "dependencies": {
58
- "@stacksjs/events": "0.75.650",
59
- "@stacksjs/features": "0.75.650",
60
- "@stacksjs/path": "0.75.650",
61
- "@stacksjs/tunnel": "0.75.650",
58
+ "@stacksjs/events": "0.75.653",
59
+ "@stacksjs/features": "0.75.653",
60
+ "@stacksjs/path": "0.75.653",
61
+ "@stacksjs/tunnel": "0.75.653",
62
62
  "ts-pantry": "^0.11.198"
63
63
  },
64
64
  "devDependencies": {
65
- "@stacksjs/alias": "0.75.650",
66
- "@stacksjs/env": "0.75.650",
67
- "@stacksjs/types": "0.75.650",
65
+ "@stacksjs/alias": "0.75.653",
66
+ "@stacksjs/env": "0.75.653",
67
+ "@stacksjs/types": "0.75.653",
68
68
  "better-dx": "^0.2.39"
69
69
  }
70
70
  }