@travetto/manifest 7.1.3 → 8.0.0-alpha.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 +3 -3
- package/src/file.ts +7 -4
- package/src/manifest-index.ts +1 -4
- package/src/package.ts +1 -1
- package/src/util.ts +14 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/manifest",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Support for project indexing, manifesting, along with file watching",
|
|
6
6
|
"keywords": [
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
],
|
|
23
23
|
"main": "__index__.ts",
|
|
24
24
|
"engines": {
|
|
25
|
-
"node": ">=
|
|
25
|
+
"node": ">=25.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@types/node": "^
|
|
28
|
+
"@types/node": "^25.3.2"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"url": "git+https://github.com/travetto/travetto.git",
|
package/src/file.ts
CHANGED
|
@@ -10,10 +10,13 @@ export class ManifestFileUtil {
|
|
|
10
10
|
*/
|
|
11
11
|
static async bufferedFileWrite(file: string, content: string): Promise<void> {
|
|
12
12
|
const temp = path.resolve(os.tmpdir(), `${process.hrtime()[1]}.${path.basename(file)}`);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
try {
|
|
14
|
+
await fs.writeFile(temp, content, 'utf8');
|
|
15
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
16
|
+
await fs.copyFile(temp, file);
|
|
17
|
+
} finally {
|
|
18
|
+
await fs.rm(temp, { force: true });
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
/**
|
package/src/manifest-index.ts
CHANGED
|
@@ -312,10 +312,7 @@ export class ManifestIndex {
|
|
|
312
312
|
const moduleSet = new Set(this.getDependentModules(event.module, 'parents').map(module => module.name));
|
|
313
313
|
moduleSet.add(this.manifest.workspace.name);
|
|
314
314
|
for (const moduleName of moduleSet) {
|
|
315
|
-
|
|
316
|
-
itemsByModule.set(moduleName, []);
|
|
317
|
-
}
|
|
318
|
-
itemsByModule.get(moduleName)!.push(event.item);
|
|
315
|
+
itemsByModule.getOrInsert(moduleName, []).push(event.item);
|
|
319
316
|
}
|
|
320
317
|
}
|
|
321
318
|
return itemsByModule;
|
package/src/package.ts
CHANGED
|
@@ -93,7 +93,7 @@ export class PackageUtil {
|
|
|
93
93
|
const rootPath = ctx.workspace.path;
|
|
94
94
|
const cache = path.resolve(rootPath, ctx.build.outputFolder, 'workspaces.json');
|
|
95
95
|
try {
|
|
96
|
-
return this.#workspaces[rootPath] ??= ManifestFileUtil.readAsJsonSync
|
|
96
|
+
return this.#workspaces[rootPath] ??= ManifestFileUtil.readAsJsonSync(cache);
|
|
97
97
|
} catch {
|
|
98
98
|
let args: string[];
|
|
99
99
|
switch (ctx.workspace.manager) {
|
package/src/util.ts
CHANGED
|
@@ -151,32 +151,32 @@ export class ManifestUtil {
|
|
|
151
151
|
* Efficient lookup for path-based graphs
|
|
152
152
|
*/
|
|
153
153
|
static lookupTrie<T>(
|
|
154
|
-
inputs: T[], getPath: (value: T) => string[], validateUnknown?: (
|
|
155
|
-
): (
|
|
156
|
-
type TrieNode = { value?: T,
|
|
157
|
-
const root: TrieNode = {
|
|
154
|
+
inputs: T[], getPath: (value: T) => string[], validateUnknown?: (inputPath: string[]) => boolean
|
|
155
|
+
): (inputPath: string[]) => T | undefined {
|
|
156
|
+
type TrieNode = { value?: T, subPaths: Record<string, TrieNode> };
|
|
157
|
+
const root: TrieNode = { subPaths: {} };
|
|
158
158
|
for (const item of inputs) {
|
|
159
|
-
const
|
|
159
|
+
const inputPath = getPath(item);
|
|
160
160
|
let node = root;
|
|
161
|
-
for (const
|
|
162
|
-
if (
|
|
163
|
-
node = node.
|
|
161
|
+
for (const subPath of inputPath) {
|
|
162
|
+
if (subPath) {
|
|
163
|
+
node = node.subPaths[subPath] ??= { subPaths: {} };
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
node.value = item;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
return
|
|
169
|
+
return inputPath => {
|
|
170
170
|
let node = root;
|
|
171
171
|
let value = node.value;
|
|
172
|
-
let
|
|
172
|
+
let index = 0;
|
|
173
173
|
|
|
174
|
-
for (const
|
|
175
|
-
|
|
174
|
+
for (const subPath of inputPath) {
|
|
175
|
+
index += 1;
|
|
176
176
|
if (node) {
|
|
177
|
-
node = node.
|
|
177
|
+
node = node.subPaths[subPath];
|
|
178
178
|
value = node?.value ?? value;
|
|
179
|
-
} else if (validateUnknown && !node && !validateUnknown(
|
|
179
|
+
} else if (validateUnknown && !node && !validateUnknown(inputPath.slice(0, index))) {
|
|
180
180
|
value = undefined;
|
|
181
181
|
break;
|
|
182
182
|
}
|