@stacksjs/server 0.70.362 → 0.70.365
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/imports.d.ts +16 -0
- package/dist/imports.js +1 -1
- package/package.json +5 -5
package/dist/imports.d.ts
CHANGED
|
@@ -26,8 +26,24 @@
|
|
|
26
26
|
* the workspace package, which holds only build files — no `functions/`, no
|
|
27
27
|
* `app/` — so the lookup misses and the vendored branch wins, which is what we
|
|
28
28
|
* want when developing the framework itself.
|
|
29
|
+
*
|
|
30
|
+
* The one exception to vendored-first is a tree the installed package has
|
|
31
|
+
* already moved past. `buddy upgrade` is the only thing that writes
|
|
32
|
+
* `storage/framework/defaults`, so bumping `stacks` in package.json and running
|
|
33
|
+
* `bun install` leaves a copy of an older release sitting in front of the one
|
|
34
|
+
* the app actually declared. That copy is a cache, not source, and preferring
|
|
35
|
+
* it means booting code from a release nobody asked for. Only a recorded
|
|
36
|
+
* version that disagrees with the installed one flips the order: an unstamped
|
|
37
|
+
* tree, a framework checkout, and a linked checkout all keep resolving exactly
|
|
38
|
+
* as before. See `inspectDefaultsProvenance`.
|
|
29
39
|
*/
|
|
30
40
|
export declare function frameworkDefaultsDir(sub: string): string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* The precedence rule on its own, so it can be pinned without a project on
|
|
43
|
+
* disk. Vendored wins unless it is a copy of a release the app has already
|
|
44
|
+
* moved past, and a missing side never beats a present one.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveDefaultsDir(vendored: string | undefined, packaged: string | undefined, vendoredIsStale: boolean): string | undefined;
|
|
31
47
|
/**
|
|
32
48
|
* Every directory the auto-import manifest is generated from.
|
|
33
49
|
*
|
package/dist/imports.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync,statSync}from"node:fs";import{dirname,relative}from"node:path";import{fileURLToPath}from"node:url";import{plugin}from"bun";import{log}from"@stacksjs/logging";import{path}from"@stacksjs/path";import{autoImports,generateRuntimeIndex,generateGlobalsScript}from"bun-plugin-auto-imports";import{globSync}from"@stacksjs/storage";import{primitiveAutoImportEntries,primitiveModules}from"./primitive-imports";const OPTIONAL_MODEL_MODULES={commerce:["config/commerce.ts"],Content:["config/cms.ts","config/blog.ts"],realtime:["config/realtime.ts"]};function configEnabled(configRelPaths){return configRelPaths.some((rel)=>existsSync(path.projectPath(rel)))}export function frameworkDefaultsDir(sub){const vendored=path.storagePath(`framework/defaults/${sub}`);
|
|
1
|
+
import{existsSync,statSync}from"node:fs";import{dirname,relative}from"node:path";import{fileURLToPath}from"node:url";import{plugin}from"bun";import{log}from"@stacksjs/logging";import{path}from"@stacksjs/path";import{autoImports,generateRuntimeIndex,generateGlobalsScript}from"bun-plugin-auto-imports";import{globSync}from"@stacksjs/storage";import{primitiveAutoImportEntries,primitiveModules}from"./primitive-imports";const OPTIONAL_MODEL_MODULES={commerce:["config/commerce.ts"],Content:["config/cms.ts","config/blog.ts"],realtime:["config/realtime.ts"]};function configEnabled(configRelPaths){return configRelPaths.some((rel)=>existsSync(path.projectPath(rel)))}export function frameworkDefaultsDir(sub){const vendored=path.storagePath(`framework/defaults/${sub}`);return resolveDefaultsDir(existsSync(vendored)?vendored:void 0,packagedDefaultsDir(sub),vendoredDefaultsAreStale())}export function resolveDefaultsDir(vendored,packaged,vendoredIsStale){if(packaged&&vendoredIsStale)return packaged;return vendored??packaged}function packagedDefaultsDir(sub){try{const packaged=`${dirname(fileURLToPath(import.meta.resolve("@stacksjs/defaults/package.json")))}/${sub}`;return existsSync(packaged)?packaged:void 0}catch{return}}let defaultsAreStale;function vendoredDefaultsAreStale(){if(defaultsAreStale===void 0)defaultsAreStale=path.inspectDefaultsProvenance().status==="stale";return defaultsAreStale}function existingDirs(dirs){return dirs.filter((dir)=>Boolean(dir)&&existsSync(dir))}function resolveDefaultModelDirs(){const root=frameworkDefaultsDir("app/Models");if(!root)return[];const dirs=[root];for(const[subdir,configPaths]of Object.entries(OPTIONAL_MODEL_MODULES))if(configEnabled(configPaths))dirs.push(`${root}/${subdir}`);return dirs}function scanDirTopLevel(dir){try{return globSync(`${dir}/*.ts`,{ignore:["**/*.d.ts","**/index.ts","**/README*"]})}catch{return[]}}function scanDefineModelExports(dir,opts={}){const{recursive=!0}=opts;let files=[];try{const pattern=recursive?`${dir}/**/*.ts`:`${dir}/*.ts`;files=globSync(pattern,{ignore:["**/*.d.ts","**/index.ts","**/README*"]})}catch{return[]}const exports=[],seen=new Set;for(const file of files){const basename=file.split("/").pop()?.replace(".ts","")||"";if(basename&&!seen.has(basename)){seen.add(basename);exports.push({name:basename,file,isDefault:!0})}}return exports}const GLOBAL_SHADOW_BLOCKLIST=new Set(["Error","Request","Response","URL","Map","Set","Object","Array","Number","String","Date","Promise","Symbol"]);async function generateDefineModelIndex(entries,outputPath){const lines=["// Generated by bun-plugin-auto-imports"],seen=new Set;for(const entry of entries){const dir=typeof entry==="string"?entry:entry.dir,recursive=typeof entry==="string"?!0:entry.recursive;let files=[];try{const pattern=recursive?`${dir}/**/*.ts`:`${dir}/*.ts`;files=globSync(pattern,{ignore:["**/*.d.ts","**/index.ts","**/README*"]})}catch{continue}for(const file of files){const basename=file.split("/").pop()?.replace(".ts","")||"";if(!basename||seen.has(basename))continue;seen.add(basename);const relativePath=relative(dirname(outputPath),file).replace(/\.ts$/,"");if(GLOBAL_SHADOW_BLOCKLIST.has(basename)){lines.push(`// Skipped '${basename}' \u2014 would shadow a built-in global. Import directly if needed.`);lines.push(`// export { default as ${basename} } from '${relativePath}'`);continue}lines.push(`export { default as ${basename} } from '${relativePath}'`)}}await Bun.write(outputPath,lines.join(`
|
|
2
2
|
`)+`
|
|
3
3
|
`)}export function autoImportSourceDirs(){return existingDirs([path.resourcesPath("functions"),frameworkDefaultsDir("functions"),path.userModelsPath(),...resolveDefaultModelDirs(),path.userJobsPath(),path.userControllersPath(),frameworkDefaultsDir("app/Controllers")])}export function autoImportsAreStale(){const manifest=path.storagePath("framework/auto-imports/functions.ts");if(!existsSync(manifest))return!0;let manifestTime;try{manifestTime=statSync(manifest).mtimeMs}catch{return!0}for(const dir of autoImportSourceDirs()){if(!existsSync(dir))continue;try{if(statSync(dir).mtimeMs>manifestTime)return!0;for(const file of globSync(`${dir}/**/*.ts`,{ignore:["**/*.d.ts"]}))if(statSync(file).mtimeMs>manifestTime)return!0}catch{continue}}return!1}export async function generateAutoImportFiles(){await generateServerAutoImportTypes();const userFunctionsPath=path.resourcesPath("functions"),defaultFunctionsPath=frameworkDefaultsDir("functions"),functionsPath=userFunctionsPath,outputDir=path.storagePath("framework/auto-imports"),userModelsPath=path.userModelsPath(),defaultModelDirs=resolveDefaultModelDirs(),[defaultsRoot,...enabledSubdirs]=defaultModelDirs,userJobsPath=path.userJobsPath(),userControllersPath=path.userControllersPath(),defaultControllersPath=frameworkDefaultsDir("app/Controllers");await Bun.write(`${outputDir}/.gitkeep`,"");const functionsIndexPath=`${outputDir}/functions.ts`;await generateRuntimeIndex(existingDirs([userFunctionsPath,defaultFunctionsPath]),functionsIndexPath);const modelsIndexPath=`${outputDir}/models.ts`,modelScan=[userModelsPath,...defaultsRoot?[{dir:defaultsRoot,recursive:!1}]:[],...defaultModelDirs.slice(1).map((d)=>({dir:d,recursive:!0}))];await generateDefineModelIndex(modelScan,modelsIndexPath);const jobsIndexPath=`${outputDir}/jobs.ts`;await generateDefineModelIndex([userJobsPath],jobsIndexPath);const controllersIndexPath=`${outputDir}/controllers.ts`;await generateDefineModelIndex(existingDirs([userControllersPath,defaultControllersPath]),controllersIndexPath);const combinedContent=`// Generated by bun-plugin-auto-imports
|
|
4
4
|
export * from './functions'
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/server",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.70.
|
|
5
|
+
"version": "0.70.365",
|
|
6
6
|
"description": "Local development and production-ready.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"prepublishOnly": "bun run build"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@stacksjs/config": "0.70.
|
|
61
|
+
"@stacksjs/config": "0.70.365",
|
|
62
62
|
"better-dx": "^0.2.17",
|
|
63
|
-
"@stacksjs/path": "0.70.
|
|
64
|
-
"@stacksjs/router": "0.70.
|
|
65
|
-
"@stacksjs/validation": "0.70.
|
|
63
|
+
"@stacksjs/path": "0.70.365",
|
|
64
|
+
"@stacksjs/router": "0.70.365",
|
|
65
|
+
"@stacksjs/validation": "0.70.365"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"bun-plugin-auto-imports": "^0.4.0"
|