@stacksjs/config 0.74.29 → 0.74.31
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/overrides.d.ts +16 -0
- package/dist/overrides.js +1 -1
- package/package.json +6 -6
package/dist/overrides.d.ts
CHANGED
|
@@ -9,6 +9,22 @@ import type { StacksConfig } from '@stacksjs/types';
|
|
|
9
9
|
* APP_NAME / APP_ENV win where set - without depending on any of that.
|
|
10
10
|
*/
|
|
11
11
|
export declare function defaultsForOverrides(): StacksConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Which of a config's accepted filenames this project actually ships.
|
|
14
|
+
*
|
|
15
|
+
* The first one on disk wins, and the primary name is first, so no project
|
|
16
|
+
* that resolves today resolves differently. Falling through the list rather
|
|
17
|
+
* than importing a missing path keeps the loader's ENOENT handling meaning
|
|
18
|
+
* "this project ships no config of this kind" rather than "the primary name
|
|
19
|
+
* was absent" - which is what made the stx/ui split invisible: `config/stx.ts`
|
|
20
|
+
* is a name stx itself accepts, and this loader read straight past it, leaving
|
|
21
|
+
* `config.ui` undefined while stx reported the file loaded fine
|
|
22
|
+
* (stacksjs/stacks#2446).
|
|
23
|
+
*
|
|
24
|
+
* Both present is ambiguous rather than wrong, so it warns and takes the
|
|
25
|
+
* primary instead of guessing silently.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveUserConfigName(names: [string, ...string[]], cwd?: unknown): string;
|
|
12
28
|
export declare function userConfigUrl(name: string, cwd?: unknown): string;
|
|
13
29
|
export declare const overrides: StacksConfig;
|
|
14
30
|
export declare const overridesReady: Promise<StacksConfig>;
|
package/dist/overrides.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{resolve}from"node:path";import{pathToFileURL}from"node:url";import{defaults}from"./defaults";import{validateConfig}from"./validators";const skipConfigLoading=process.env.SKIP_CONFIG_LOADING==="true",skipConfigValidation=process.env.SKIP_CONFIG_VALIDATION==="true",OVERRIDES_KEY=Symbol.for("@stacksjs/config:overrides"),READY_KEY=Symbol.for("@stacksjs/config:overridesReady");export function defaultsForOverrides(){return{ai:{},analytics:{},app:{...defaults.app,name:process.env.APP_NAME||defaults.app?.name||"Stacks",env:process.env.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:{},filesystems:{},team:{},ui:{}}}const globalScope=globalThis,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"],["filesystems","filesystems"],["team","team"],["ui","ui"]];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
|
|
1
|
+
import{existsSync}from"node:fs";import{resolve}from"node:path";import{pathToFileURL}from"node:url";import{defaults}from"./defaults";import{validateConfig}from"./validators";const skipConfigLoading=process.env.SKIP_CONFIG_LOADING==="true",skipConfigValidation=process.env.SKIP_CONFIG_VALIDATION==="true",OVERRIDES_KEY=Symbol.for("@stacksjs/config:overrides"),READY_KEY=Symbol.for("@stacksjs/config:overridesReady");export function defaultsForOverrides(){return{ai:{},analytics:{},app:{...defaults.app,name:process.env.APP_NAME||defaults.app?.name||"Stacks",env:process.env.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:{},filesystems:{},team:{},ui:{}}}const globalScope=globalThis,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"],["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),modulePath=userConfigUrl(name);try{const mod=await import(modulePath);if(mod?.default!==void 0)overrides[key]=mod.default}catch(err){const code=err?.code,msg=err?.message??String(err);if(!(code==="ERR_MODULE_NOT_FOUND"||code==="MODULE_NOT_FOUND"||/Cannot find module/i.test(msg)))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(` \u2022 ${issue.path}: ${issue.message}`);const summary=issues.map((i)=>` \u2022 ${i.path}: ${i.message}`).join(`
|
|
2
2
|
`);throw 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.74.
|
|
5
|
+
"version": "0.74.31",
|
|
6
6
|
"description": "The Stacks config helper methods.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
"prepublishOnly": "bun run build"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@stacksjs/events": "0.74.
|
|
59
|
-
"@stacksjs/path": "0.74.
|
|
60
|
-
"@stacksjs/tunnel": "0.74.
|
|
58
|
+
"@stacksjs/events": "0.74.31",
|
|
59
|
+
"@stacksjs/path": "0.74.31",
|
|
60
|
+
"@stacksjs/tunnel": "0.74.31",
|
|
61
61
|
"ts-pantry": "^0.11.35"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@stacksjs/alias": "0.74.
|
|
65
|
-
"@stacksjs/types": "0.74.
|
|
64
|
+
"@stacksjs/alias": "0.74.31",
|
|
65
|
+
"@stacksjs/types": "0.74.31",
|
|
66
66
|
"better-dx": "^0.2.24"
|
|
67
67
|
}
|
|
68
68
|
}
|