@stacksjs/actions 0.74.5 → 0.74.6
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/discover-packages.d.ts +43 -1
- package/dist/discover-packages.js +2 -1
- package/package.json +38 -38
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import type { StackDirectory } from '@stacksjs/types';
|
|
2
|
-
export declare function discoverPackages(): Promise<DiscoveredPackagesManifest>;
|
|
2
|
+
export declare function discoverPackages(options?: DiscoverPackagesOptions): Promise<DiscoveredPackagesManifest>;
|
|
3
|
+
/**
|
|
4
|
+
* Find the installed packages that extend this application.
|
|
5
|
+
*
|
|
6
|
+
* Stacks' answer to Laravel's package auto-discovery: a package declares a
|
|
7
|
+
* `stacks` key in its package.json, and the framework registers what it brings
|
|
8
|
+
* without the application wiring anything up.
|
|
9
|
+
*
|
|
10
|
+
* Two roots are searched, in this order:
|
|
11
|
+
*
|
|
12
|
+
* `node_modules/` where a package manager puts what an application asked
|
|
13
|
+
* for, so this is the one that matters for `bun add loghq`.
|
|
14
|
+
* Only DIRECT dependencies are considered, read from the
|
|
15
|
+
* application's own package.json. A transitive dependency
|
|
16
|
+
* has no business injecting models or routes into an app
|
|
17
|
+
* that never named it, and walking the whole tree would
|
|
18
|
+
* mean reading thousands of manifests on every boot.
|
|
19
|
+
*
|
|
20
|
+
* `pantry/` this repository's own package tree, and the root the
|
|
21
|
+
* scan was originally written against. Globbed rather than
|
|
22
|
+
* read from dependencies, because it is a small tree that
|
|
23
|
+
* is not always reflected in a package.json.
|
|
24
|
+
*
|
|
25
|
+
* A package found in both is taken from `node_modules`, and its other location
|
|
26
|
+
* is reported in {@link DiscoveredPackagesManifest.shadowed} rather than
|
|
27
|
+
* silently dropped: the two copies are frequently different versions, and
|
|
28
|
+
* which one won is the first thing worth knowing when a package misbehaves.
|
|
29
|
+
*/
|
|
3
30
|
export declare interface PackageStacksMeta {
|
|
4
31
|
providers?: string[]
|
|
5
32
|
routes?: string[]
|
|
@@ -11,8 +38,23 @@ export declare interface PackageStacksMeta {
|
|
|
11
38
|
name?: string
|
|
12
39
|
description?: string
|
|
13
40
|
directories?: StackDirectory[]
|
|
41
|
+
routePrefix?: string
|
|
42
|
+
routeMiddleware?: string | string[]
|
|
43
|
+
root?: string
|
|
44
|
+
}
|
|
45
|
+
/** A package that was found in more than one root. */
|
|
46
|
+
export declare interface ShadowedPackage {
|
|
47
|
+
name: string
|
|
48
|
+
used: string
|
|
49
|
+
ignored: string
|
|
14
50
|
}
|
|
15
51
|
export declare interface DiscoveredPackagesManifest {
|
|
16
52
|
generated_at: string
|
|
17
53
|
packages: Record<string, PackageStacksMeta>
|
|
54
|
+
shadowed?: ShadowedPackage[]
|
|
55
|
+
}
|
|
56
|
+
export declare interface DiscoverPackagesOptions {
|
|
57
|
+
projectRoot?: string
|
|
58
|
+
manifestPath?: string
|
|
59
|
+
dryRun?: boolean
|
|
18
60
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{projectPath,storagePath}from"@stacksjs/path";
|
|
1
|
+
import{existsSync}from"node:fs";import{isAbsolute,join,relative}from"node:path";import{projectPath,storagePath}from"@stacksjs/path";async function readManifest(file){try{return await Bun.file(file).json()}catch{return null}}async function directDependencies(projectRoot){const pkg=await readManifest(join(projectRoot,"package.json"));if(!pkg)return[];const names=new Set;for(const field of["dependencies","devDependencies","peerDependencies"]){const block=pkg[field];if(block&&typeof block==="object")for(const name of Object.keys(block))names.add(name)}return[...names].sort()}async function fromNodeModules(projectRoot){const root=join(projectRoot,"node_modules");if(!existsSync(root))return[];const out=[];for(const name of await directDependencies(projectRoot)){const dir=join(root,name),pkg=await readManifest(join(dir,"package.json"));if(!pkg?.name||!pkg.stacks||typeof pkg.stacks!=="object")continue;out.push({name:pkg.name,meta:pkg.stacks,dir})}return out}async function fromPantry(projectRoot){const root=join(projectRoot,"pantry");if(!existsSync(root))return[];const out=[];for(const pattern of["*/package.json","@*/*/package.json"]){const glob=new Bun.Glob(pattern);for await(const file of glob.scan({cwd:root,absolute:!0,onlyFiles:!0})){const pkg=await readManifest(file);if(!pkg?.name||!pkg.stacks||typeof pkg.stacks!=="object")continue;out.push({name:pkg.name,meta:pkg.stacks,dir:join(file,"..")})}}return out.sort((a,b)=>a.name.localeCompare(b.name))}async function dontDiscover(projectRoot){const list=(await readManifest(join(projectRoot,"package.json")))?.stacks?.["dont-discover"];return new Set(Array.isArray(list)?list:[])}export async function discoverPackages(options={}){const projectRoot=options.projectRoot??projectPath(),manifestPath=options.manifestPath??storagePath("framework/discovered-packages.json"),excluded=await dontDiscover(projectRoot),found=[...await fromNodeModules(projectRoot),...await fromPantry(projectRoot)],packages={},shadowed=[],chosen=new Map;for(const candidate of found){if(excluded.has(candidate.name))continue;const root=toRelative(projectRoot,candidate.dir),already=chosen.get(candidate.name);if(already!==void 0){shadowed.push({name:candidate.name,used:already,ignored:root});continue}chosen.set(candidate.name,root);packages[candidate.name]={...candidate.meta,root}}const manifest={generated_at:new Date().toISOString(),packages,...shadowed.length>0?{shadowed}:{}};if(options.dryRun)return manifest;try{const current=await Bun.file(manifestPath).json();if(JSON.stringify(current.packages??{})===JSON.stringify(manifest.packages)&&JSON.stringify(current.shadowed??[])===JSON.stringify(shadowed))return current}catch{}await Bun.write(manifestPath,`${JSON.stringify(manifest,null,2)}
|
|
2
|
+
`);return manifest}function toRelative(projectRoot,dir){const rel=relative(projectRoot,dir);return rel&&!rel.startsWith("..")&&!isAbsolute(rel)?rel:dir}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/actions",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.74.
|
|
5
|
+
"version": "0.74.6",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -60,51 +60,51 @@
|
|
|
60
60
|
"prepublishOnly": "bun run build"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@stacksjs/action-runner": "0.74.
|
|
64
|
-
"@stacksjs/ai": "0.74.
|
|
65
|
-
"@stacksjs/analytics": "0.74.
|
|
66
|
-
"@stacksjs/api": "0.74.
|
|
67
|
-
"@stacksjs/auth": "0.74.
|
|
68
|
-
"@stacksjs/build": "0.74.
|
|
63
|
+
"@stacksjs/action-runner": "0.74.6",
|
|
64
|
+
"@stacksjs/ai": "0.74.6",
|
|
65
|
+
"@stacksjs/analytics": "0.74.6",
|
|
66
|
+
"@stacksjs/api": "0.74.6",
|
|
67
|
+
"@stacksjs/auth": "0.74.6",
|
|
68
|
+
"@stacksjs/build": "0.74.6",
|
|
69
69
|
"@stacksjs/bumpx": "^0.2.6",
|
|
70
70
|
"@stacksjs/bunpress": "^0.2.8",
|
|
71
|
-
"@stacksjs/cli": "0.74.
|
|
72
|
-
"@stacksjs/cloud": "0.74.
|
|
73
|
-
"@stacksjs/cms": "0.74.
|
|
74
|
-
"@stacksjs/config": "0.74.
|
|
75
|
-
"@stacksjs/database": "0.74.
|
|
76
|
-
"@stacksjs/desktop-build": "0.74.
|
|
77
|
-
"@stacksjs/dns": "0.74.
|
|
78
|
-
"@stacksjs/enums": "0.74.
|
|
79
|
-
"@stacksjs/env": "0.74.
|
|
80
|
-
"@stacksjs/error-handling": "0.74.
|
|
71
|
+
"@stacksjs/cli": "0.74.6",
|
|
72
|
+
"@stacksjs/cloud": "0.74.6",
|
|
73
|
+
"@stacksjs/cms": "0.74.6",
|
|
74
|
+
"@stacksjs/config": "0.74.6",
|
|
75
|
+
"@stacksjs/database": "0.74.6",
|
|
76
|
+
"@stacksjs/desktop-build": "0.74.6",
|
|
77
|
+
"@stacksjs/dns": "0.74.6",
|
|
78
|
+
"@stacksjs/enums": "0.74.6",
|
|
79
|
+
"@stacksjs/env": "0.74.6",
|
|
80
|
+
"@stacksjs/error-handling": "0.74.6",
|
|
81
81
|
"@stacksjs/gitit": "^0.2.5",
|
|
82
|
-
"@stacksjs/i18n": "0.74.
|
|
83
|
-
"@stacksjs/image": "0.74.
|
|
84
|
-
"@stacksjs/logging": "0.74.
|
|
82
|
+
"@stacksjs/i18n": "0.74.6",
|
|
83
|
+
"@stacksjs/image": "0.74.6",
|
|
84
|
+
"@stacksjs/logging": "0.74.6",
|
|
85
85
|
"@stacksjs/logsmith": "^0.2.3",
|
|
86
|
-
"@stacksjs/orm": "0.74.
|
|
87
|
-
"@stacksjs/path": "0.74.
|
|
88
|
-
"@stacksjs/payments": "0.74.
|
|
89
|
-
"@stacksjs/queue": "0.74.
|
|
90
|
-
"@stacksjs/registry": "0.74.
|
|
91
|
-
"@stacksjs/router": "0.74.
|
|
86
|
+
"@stacksjs/orm": "0.74.6",
|
|
87
|
+
"@stacksjs/path": "0.74.6",
|
|
88
|
+
"@stacksjs/payments": "0.74.6",
|
|
89
|
+
"@stacksjs/queue": "0.74.6",
|
|
90
|
+
"@stacksjs/registry": "0.74.6",
|
|
91
|
+
"@stacksjs/router": "0.74.6",
|
|
92
92
|
"@stacksjs/rpx": "^0.11.42",
|
|
93
|
-
"@stacksjs/scheduler": "0.74.
|
|
94
|
-
"@stacksjs/search-engine": "0.74.
|
|
95
|
-
"@stacksjs/security": "0.74.
|
|
96
|
-
"@stacksjs/server": "0.74.
|
|
97
|
-
"@stacksjs/sites": "0.74.
|
|
98
|
-
"@stacksjs/storage": "0.74.
|
|
99
|
-
"@stacksjs/strings": "0.74.
|
|
93
|
+
"@stacksjs/scheduler": "0.74.6",
|
|
94
|
+
"@stacksjs/search-engine": "0.74.6",
|
|
95
|
+
"@stacksjs/security": "0.74.6",
|
|
96
|
+
"@stacksjs/server": "0.74.6",
|
|
97
|
+
"@stacksjs/sites": "0.74.6",
|
|
98
|
+
"@stacksjs/storage": "0.74.6",
|
|
99
|
+
"@stacksjs/strings": "0.74.6",
|
|
100
100
|
"@stacksjs/stx": "^0.2.253",
|
|
101
101
|
"@stacksjs/tlsx": "^0.13.19",
|
|
102
102
|
"@stacksjs/ts-cloud": "^0.12.10",
|
|
103
103
|
"@stacksjs/ts-md": "^0.1.1",
|
|
104
|
-
"@stacksjs/tunnel": "0.74.
|
|
105
|
-
"@stacksjs/types": "0.74.
|
|
106
|
-
"@stacksjs/utils": "0.74.
|
|
107
|
-
"@stacksjs/whois": "0.74.
|
|
104
|
+
"@stacksjs/tunnel": "0.74.6",
|
|
105
|
+
"@stacksjs/types": "0.74.6",
|
|
106
|
+
"@stacksjs/utils": "0.74.6",
|
|
107
|
+
"@stacksjs/whois": "0.74.6",
|
|
108
108
|
"bun-plugin-stx": "^0.2.246"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
}
|
|
121
121
|
},
|
|
122
122
|
"devDependencies": {
|
|
123
|
-
"@stacksjs/validation": "0.74.
|
|
123
|
+
"@stacksjs/validation": "0.74.6",
|
|
124
124
|
"better-dx": "^0.2.24"
|
|
125
125
|
}
|
|
126
126
|
}
|