@travetto/manifest 7.0.0-rc.1 → 7.0.0-rc.2
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 +1 -1
- package/src/delta.ts +5 -5
- package/src/file.ts +0 -7
- package/src/manifest-index.ts +17 -0
- package/src/package.ts +14 -13
- package/src/types/common.ts +3 -1
package/package.json
CHANGED
package/src/delta.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { ManifestModuleUtil } from './module.ts';
|
|
|
4
4
|
import { path } from './path.ts';
|
|
5
5
|
|
|
6
6
|
import type { ManifestModule, ManifestModuleCore, ManifestModuleFile, ManifestRoot } from './types/manifest.ts';
|
|
7
|
-
import type { ManifestModuleFileType, ManifestModuleFolderType } from './types/common.ts';
|
|
7
|
+
import type { ChangeEventType, ManifestModuleFileType, ManifestModuleFolderType } from './types/common.ts';
|
|
8
8
|
import type { ManifestContext } from './types/context.ts';
|
|
9
9
|
|
|
10
|
-
type DeltaEventType =
|
|
10
|
+
type DeltaEventType = ChangeEventType | 'missing' | 'dirty';
|
|
11
11
|
type DeltaModule = ManifestModuleCore & { files: Record<string, ManifestModuleFile> };
|
|
12
12
|
export type DeltaEvent = { file: string, type: DeltaEventType, module: string, sourceFile: string };
|
|
13
13
|
|
|
@@ -52,17 +52,17 @@ export class ManifestDeltaUtil {
|
|
|
52
52
|
right.delete(ManifestModuleUtil.withoutSourceExtension(file));
|
|
53
53
|
|
|
54
54
|
if (!stat) {
|
|
55
|
-
add(file, '
|
|
55
|
+
add(file, 'create');
|
|
56
56
|
} else {
|
|
57
57
|
const rightTimestamp = this.#getNewest(stat);
|
|
58
58
|
if (leftTimestamp > rightTimestamp) {
|
|
59
|
-
add(file, '
|
|
59
|
+
add(file, 'update');
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
// Deleted
|
|
64
64
|
for (const file of right) {
|
|
65
|
-
add(file, '
|
|
65
|
+
add(file, 'delete');
|
|
66
66
|
}
|
|
67
67
|
return out;
|
|
68
68
|
}
|
package/src/file.ts
CHANGED
|
@@ -16,13 +16,6 @@ export class ManifestFileUtil {
|
|
|
16
16
|
await fs.rm(temp, { force: true });
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Read as json
|
|
21
|
-
*/
|
|
22
|
-
static async readAsJson<T = unknown>(file: string): Promise<T> {
|
|
23
|
-
return JSON.parse(await fs.readFile(file, 'utf8'));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
19
|
/**
|
|
27
20
|
* Read as json, sync
|
|
28
21
|
*/
|
package/src/manifest-index.ts
CHANGED
|
@@ -192,6 +192,14 @@ export class ManifestIndex {
|
|
|
192
192
|
return this.#importToEntry.get(imp);
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Get from import path or source file
|
|
197
|
+
* @param importOrSource
|
|
198
|
+
*/
|
|
199
|
+
getFromImportOrSource(importOrSource: string): IndexedFile | undefined {
|
|
200
|
+
return this.getFromImport(importOrSource) ?? this.getFromSource(path.resolve(importOrSource));
|
|
201
|
+
}
|
|
202
|
+
|
|
195
203
|
/**
|
|
196
204
|
* Get module from source file
|
|
197
205
|
* @param source
|
|
@@ -256,6 +264,15 @@ export class ManifestIndex {
|
|
|
256
264
|
return lookup(file.replace(`${base}/`, '').split('/'));
|
|
257
265
|
}
|
|
258
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Find the module for an arbitrary import
|
|
269
|
+
*/
|
|
270
|
+
findModuleForArbitraryImport(imp: string): IndexedModule | undefined {
|
|
271
|
+
const importParts = imp.split('/');
|
|
272
|
+
const module = imp.startsWith('@') ? importParts.slice(0, 2).join('/') : importParts[0];
|
|
273
|
+
return this.getModule(module);
|
|
274
|
+
}
|
|
275
|
+
|
|
259
276
|
/**
|
|
260
277
|
* Get manifest module by name
|
|
261
278
|
*/
|
package/src/package.ts
CHANGED
|
@@ -99,20 +99,21 @@ export class PackageUtil {
|
|
|
99
99
|
static async resolveWorkspaces(ctx: ManifestContext): Promise<PackageWorkspaceEntry[]> {
|
|
100
100
|
const rootPath = ctx.workspace.path;
|
|
101
101
|
const cache = path.resolve(rootPath, ctx.build.outputFolder, 'workspaces.json');
|
|
102
|
-
|
|
103
|
-
.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
try {
|
|
103
|
+
return this.#workspaces[rootPath] ??= ManifestFileUtil.readAsJsonSync<PackageWorkspaceEntry[]>(cache);
|
|
104
|
+
} catch {
|
|
105
|
+
let out: PackageWorkspaceEntry[];
|
|
106
|
+
switch (ctx.workspace.manager) {
|
|
107
|
+
case 'yarn':
|
|
108
|
+
case 'npm': {
|
|
109
|
+
const workspaces = await this.#exec<{ location: string, name: string }[]>(rootPath, 'npm query .workspace');
|
|
110
|
+
out = workspaces.map(mod => ({ path: path.resolve(ctx.workspace.path, mod.location), name: mod.name }));
|
|
111
|
+
break;
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
}
|
|
114
|
+
await ManifestFileUtil.bufferedFileWrite(cache, JSON.stringify(out));
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
/**
|
package/src/types/common.ts
CHANGED
|
@@ -8,4 +8,6 @@ export type ManifestModuleFolderType =
|
|
|
8
8
|
'test/fixtures' | 'support/fixtures' | 'support/resources' |
|
|
9
9
|
'$transformer';
|
|
10
10
|
|
|
11
|
-
export type ManifestModuleRole = 'std' | 'test' | 'doc' | 'compile' | 'build';
|
|
11
|
+
export type ManifestModuleRole = 'std' | 'test' | 'doc' | 'compile' | 'build';
|
|
12
|
+
|
|
13
|
+
export type ChangeEventType = 'create' | 'update' | 'delete';
|