@travetto/manifest 3.4.0-rc.1 → 3.4.0
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/package.json +2 -2
- package/src/package.ts +10 -3
- package/src/root-index.ts +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/manifest",
|
|
3
|
-
"version": "3.4.0
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Support for project indexing, manifesting, along with file watching",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"path",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"main": "__index__.ts",
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
27
|
+
"node": ">=20.0.0"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"url": "https://github.com/travetto/travetto.git",
|
package/src/package.ts
CHANGED
|
@@ -66,10 +66,9 @@ export class PackageUtil {
|
|
|
66
66
|
/**
|
|
67
67
|
* Extract all dependencies from a package
|
|
68
68
|
*/
|
|
69
|
-
static getAllDependencies<T = unknown>(modulePath: string,
|
|
69
|
+
static getAllDependencies<T = unknown>(modulePath: string, local: boolean): PackageVisitReq<T>[] {
|
|
70
70
|
const pkg = this.readPackage(modulePath);
|
|
71
71
|
const children: Record<string, PackageVisitReq<T>> = {};
|
|
72
|
-
const local = modulePath === rootPath && !modulePath.includes('node_modules');
|
|
73
72
|
for (const [deps, prod] of [
|
|
74
73
|
[pkg.dependencies, true],
|
|
75
74
|
...(local ? [[pkg.devDependencies, false] as const] : []),
|
|
@@ -136,7 +135,15 @@ export class PackageUtil {
|
|
|
136
135
|
out.add(dep);
|
|
137
136
|
await visitor.visit?.(req, dep);
|
|
138
137
|
seen.set(key, dep);
|
|
139
|
-
const children = this.getAllDependencies<T>(
|
|
138
|
+
const children = this.getAllDependencies<T>(
|
|
139
|
+
req.sourcePath,
|
|
140
|
+
// We consider a module local if its not in the node_modules
|
|
141
|
+
!req.sourcePath.includes('node_modules') && (
|
|
142
|
+
// And its the root or we are in a monorepo
|
|
143
|
+
root.sourcePath === req.sourcePath ||
|
|
144
|
+
!!root.pkg.workspaces
|
|
145
|
+
)
|
|
146
|
+
);
|
|
140
147
|
queue.push(...children.map(x => ({ ...x, parent: dep })));
|
|
141
148
|
}
|
|
142
149
|
}
|
package/src/root-index.ts
CHANGED
|
@@ -102,6 +102,18 @@ class $RootIndex extends ManifestIndex {
|
|
|
102
102
|
const id = clsId === undefined ? '' : typeof clsId === 'string' ? clsId : clsId.Ⲑid;
|
|
103
103
|
return this.#metadata.get(id);
|
|
104
104
|
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Resolve module path to folder, with support for main module and monorepo support
|
|
108
|
+
*/
|
|
109
|
+
resolveModulePath(modulePath: string): string {
|
|
110
|
+
const main = this.manifest.mainModule;
|
|
111
|
+
const workspace = this.manifest.workspacePath;
|
|
112
|
+
const [base, sub] = modulePath
|
|
113
|
+
.replace(/^(@@?)(#|$)/g, (_, v, r) => `${v === '@' ? main : workspace}${r}`)
|
|
114
|
+
.split('#');
|
|
115
|
+
return path.resolve(this.hasModule(base) ? this.getModule(base)!.sourcePath : base, sub ?? '.');
|
|
116
|
+
}
|
|
105
117
|
}
|
|
106
118
|
|
|
107
119
|
let index: $RootIndex | undefined;
|