@stacksjs/config 0.74.28 → 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/discovered-resources.d.ts +34 -0
- package/dist/discovered-resources.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/overrides.d.ts +16 -0
- package/dist/overrides.js +1 -1
- package/package.json +6 -6
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration directories each discovered package contributes.
|
|
3
|
+
*
|
|
4
|
+
* These are read, never written. The migration runner deletes and rewrites
|
|
5
|
+
* files in the corpus it runs - SQLite preprocessing drops statements it
|
|
6
|
+
* cannot execute and prunes duplicate CREATEs - so a package's own directory
|
|
7
|
+
* is copied out of before any of that happens. Doing otherwise would have the
|
|
8
|
+
* framework mutating an installed package's files, which a reinstall silently
|
|
9
|
+
* undoes.
|
|
10
|
+
*/
|
|
11
|
+
export declare function packageMigrationRoots(options?: PackageResourceOptions): PackageResourceRoot[];
|
|
12
|
+
/**
|
|
13
|
+
* Job directories each discovered package contributes.
|
|
14
|
+
*
|
|
15
|
+
* Conventional, like models, rather than opt-in like components. A job is
|
|
16
|
+
* reached by its exported name from the barrel and is inert until something
|
|
17
|
+
* dispatches or schedules it, so a package shipping `app/Jobs` it did not mean
|
|
18
|
+
* to publish costs a name in the barrel and nothing else.
|
|
19
|
+
*/
|
|
20
|
+
export declare function packageJobRoots(options?: PackageResourceOptions): PackageResourceRoot[];
|
|
21
|
+
/**
|
|
22
|
+
* Component directories each discovered package contributes.
|
|
23
|
+
*
|
|
24
|
+
* Opt-in, unlike every other surface here: a package contributes components
|
|
25
|
+
* only by declaring `"components"` in its `stacks` key. Components resolve by
|
|
26
|
+
* bare tag name across every template in the process, so a directory picked up
|
|
27
|
+
* by convention would silently enter that namespace.
|
|
28
|
+
*
|
|
29
|
+
* The caller decides precedence. Placing these AFTER the framework's own
|
|
30
|
+
* component directories makes a package purely additive, which is what the
|
|
31
|
+
* shipped stx plugin does - stx searches its component list in order and takes
|
|
32
|
+
* the first match.
|
|
33
|
+
*/
|
|
34
|
+
export declare function packageComponentRoots(options?: PackageResourceOptions): PackageResourceRoot[];
|
|
1
35
|
/** View directories each discovered package contributes. */
|
|
2
36
|
export declare function packageViewRoots(options?: PackageResourceOptions): PackageResourceRoot[];
|
|
3
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync,readFileSync}from"node:fs";import{isAbsolute,join}from"node:path";import{path}from"@stacksjs/path";const IMPLIED_DIRS={views:["resources/views"],models:["app/Models"]};function readManifest(manifestPath){try{return JSON.parse(readFileSync(manifestPath,"utf8"))?.packages??{}}catch{return{}}}function resourceRoots(field,options={}){const manifestPath=options.manifestPath??path.storagePath("framework/discovered-packages.json"),projectRoot=options.projectRoot??path.projectPath(),exists=options.exists??existsSync,roots=[];for(const[name,meta]of Object.entries(readManifest(manifestPath))){const declared=meta?.[field]??IMPLIED_DIRS[field];if(!declared)continue;const root=meta.root;if(!root||typeof root!=="string")continue;const base=isAbsolute(root)?root:join(projectRoot,root);for(const entry of Array.isArray(declared)?declared:[declared]){if(typeof entry!=="string"||!entry)continue;const cleaned=entry.replace(/^[/\\]+/,"");if(!cleaned||cleaned.split(/[/\\]/).includes(".."))continue;const dir=join(base,cleaned);if(exists(dir))roots.push({package:name,dir})}}return roots.sort((a,b)=>a.package.localeCompare(b.package))}export function packageViewRoots(options={}){return resourceRoots("views",options)}export function packageModelRoots(options={}){return resourceRoots("models",options)}
|
|
1
|
+
import{existsSync,readFileSync}from"node:fs";import{isAbsolute,join}from"node:path";import{path}from"@stacksjs/path";const IMPLIED_DIRS={views:["resources/views"],models:["app/Models"],migrations:["database/migrations"],jobs:["app/Jobs"]};function readManifest(manifestPath){try{return JSON.parse(readFileSync(manifestPath,"utf8"))?.packages??{}}catch{return{}}}function resourceRoots(field,options={}){const manifestPath=options.manifestPath??path.storagePath("framework/discovered-packages.json"),projectRoot=options.projectRoot??path.projectPath(),exists=options.exists??existsSync,roots=[];for(const[name,meta]of Object.entries(readManifest(manifestPath))){const declared=meta?.[field]??IMPLIED_DIRS[field];if(!declared)continue;const root=meta.root;if(!root||typeof root!=="string")continue;const base=isAbsolute(root)?root:join(projectRoot,root);for(const entry of Array.isArray(declared)?declared:[declared]){if(typeof entry!=="string"||!entry)continue;const cleaned=entry.replace(/^[/\\]+/,"");if(!cleaned||cleaned.split(/[/\\]/).includes(".."))continue;const dir=join(base,cleaned);if(exists(dir))roots.push({package:name,dir})}}return roots.sort((a,b)=>a.package.localeCompare(b.package))}export function packageMigrationRoots(options={}){return resourceRoots("migrations",options)}export function packageJobRoots(options={}){return resourceRoots("jobs",options)}export function packageComponentRoots(options={}){return resourceRoots("components",options)}export function packageViewRoots(options={}){return resourceRoots("views",options)}export function packageModelRoots(options={}){return resourceRoots("models",options)}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export * from './config';
|
|
|
12
12
|
export { FRAMEWORK_DEFAULTS } from './defaults';
|
|
13
13
|
export { validateConfig, reportConfigIssues, type ConfigValidationIssue } from './validators';
|
|
14
14
|
export { feature, enableFeature, disableFeature, resetFeature, listFeatures } from './features';
|
|
15
|
-
export { packageModelRoots, packageViewRoots, type PackageResourceOptions, type PackageResourceRoot } from './discovered-resources';
|
|
15
|
+
export { packageComponentRoots, packageJobRoots, packageMigrationRoots, packageModelRoots, packageViewRoots, type PackageResourceOptions, type PackageResourceRoot } from './discovered-resources';
|
|
16
16
|
export { resolveViewPatterns, type DefaultViewsSetting, type ViewPatternResolution } from './views';
|
|
17
17
|
export {
|
|
18
18
|
createRequestContext,
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./config";export{FRAMEWORK_DEFAULTS}from"./defaults";export{validateConfig,reportConfigIssues}from"./validators";export{feature,enableFeature,disableFeature,resetFeature,listFeatures}from"./features";export{packageModelRoots,packageViewRoots}from"./discovered-resources";export{resolveViewPatterns}from"./views";export{createRequestContext,installRequestContext,parseCookieHeader,useRequestEvent}from"./request-context";export*from"./capabilities";
|
|
1
|
+
export*from"./config";export{FRAMEWORK_DEFAULTS}from"./defaults";export{validateConfig,reportConfigIssues}from"./validators";export{feature,enableFeature,disableFeature,resetFeature,listFeatures}from"./features";export{packageComponentRoots,packageJobRoots,packageMigrationRoots,packageModelRoots,packageViewRoots}from"./discovered-resources";export{resolveViewPatterns}from"./views";export{createRequestContext,installRequestContext,parseCookieHeader,useRequestEvent}from"./request-context";export*from"./capabilities";
|
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
|
}
|