@stacksjs/config 0.74.27 → 0.74.29
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/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/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.29",
|
|
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.29",
|
|
59
|
+
"@stacksjs/path": "0.74.29",
|
|
60
|
+
"@stacksjs/tunnel": "0.74.29",
|
|
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.29",
|
|
65
|
+
"@stacksjs/types": "0.74.29",
|
|
66
66
|
"better-dx": "^0.2.24"
|
|
67
67
|
}
|
|
68
68
|
}
|