@lage-run/hasher 1.3.3 → 1.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/CHANGELOG.json +31 -1
- package/CHANGELOG.md +18 -2
- package/lib/TargetHasher.d.ts +6 -0
- package/lib/TargetHasher.js +30 -2
- package/package.json +2 -2
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,37 @@
|
|
|
2
2
|
"name": "@lage-run/hasher",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Wed,
|
|
5
|
+
"date": "Wed, 25 Sep 2024 20:27:33 GMT",
|
|
6
|
+
"version": "1.4.0",
|
|
7
|
+
"tag": "@lage-run/hasher_v1.4.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "kchau@microsoft.com",
|
|
12
|
+
"package": "@lage-run/hasher",
|
|
13
|
+
"commit": "09313be6a4a5667bf8c50b654428f778f6fa4028",
|
|
14
|
+
"comment": "writes out the \"inputs\" as hashes files inside node_modules\\.cache\\lage\\hashes\\**"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Fri, 13 Sep 2024 18:05:04 GMT",
|
|
21
|
+
"version": "1.3.4",
|
|
22
|
+
"tag": "@lage-run/hasher_v1.3.4",
|
|
23
|
+
"comments": {
|
|
24
|
+
"patch": [
|
|
25
|
+
{
|
|
26
|
+
"author": "beachball",
|
|
27
|
+
"package": "@lage-run/hasher",
|
|
28
|
+
"comment": "Bump @lage-run/target-graph to v0.8.10",
|
|
29
|
+
"commit": "not available"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"date": "Wed, 11 Sep 2024 20:52:15 GMT",
|
|
6
36
|
"version": "1.3.3",
|
|
7
37
|
"tag": "@lage-run/hasher_v1.3.3",
|
|
8
38
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
# Change Log - @lage-run/hasher
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on Wed,
|
|
3
|
+
<!-- This log was last generated on Wed, 25 Sep 2024 20:27:33 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.4.0
|
|
8
|
+
|
|
9
|
+
Wed, 25 Sep 2024 20:27:33 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- writes out the "inputs" as hashes files inside node_modules\.cache\lage\hashes\** (kchau@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 1.3.4
|
|
16
|
+
|
|
17
|
+
Fri, 13 Sep 2024 18:05:04 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- Bump @lage-run/target-graph to v0.8.10
|
|
22
|
+
|
|
7
23
|
## 1.3.3
|
|
8
24
|
|
|
9
|
-
Wed, 11 Sep 2024 20:52:
|
|
25
|
+
Wed, 11 Sep 2024 20:52:15 GMT
|
|
10
26
|
|
|
11
27
|
### Patches
|
|
12
28
|
|
package/lib/TargetHasher.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ export interface TargetManifest {
|
|
|
30
30
|
*/
|
|
31
31
|
export declare class TargetHasher {
|
|
32
32
|
private options;
|
|
33
|
+
targetHashesLog: Record<string, {
|
|
34
|
+
fileHashes: Record<string, string>;
|
|
35
|
+
globalFileHashes: Record<string, string>;
|
|
36
|
+
}>;
|
|
37
|
+
targetHashesDirectory: string;
|
|
33
38
|
logger: Logger | undefined;
|
|
34
39
|
fileHasher: FileHasher;
|
|
35
40
|
packageTree: PackageTree | undefined;
|
|
@@ -48,5 +53,6 @@ export declare class TargetHasher {
|
|
|
48
53
|
ensureInitialized(): void;
|
|
49
54
|
initialize(): Promise<void>;
|
|
50
55
|
hash(target: Target): Promise<string>;
|
|
56
|
+
writeTargetHashesManifest(): void;
|
|
51
57
|
cleanup(): Promise<void>;
|
|
52
58
|
}
|
package/lib/TargetHasher.js
CHANGED
|
@@ -190,10 +190,10 @@ class TargetHasher {
|
|
|
190
190
|
const fileHashes = this.fileHasher.hash(files) ?? {}; // this list is sorted by file name
|
|
191
191
|
// get target hashes
|
|
192
192
|
const targetDepHashes = target.dependencies?.sort().map((targetDep)=>this.targetHashes[targetDep]);
|
|
193
|
-
const
|
|
193
|
+
const globalFileHashes = target.environmentGlob ? this.fileHasher.hash(await this.getMemorizedEnvGlobResults(target.environmentGlob)) : this.globalInputsHash ?? {};
|
|
194
194
|
const combinedHashes = [
|
|
195
195
|
// Environmental hashes
|
|
196
|
-
...
|
|
196
|
+
...Object.values(globalFileHashes),
|
|
197
197
|
`${target.id}|${JSON.stringify(this.options.cliArgs)}`,
|
|
198
198
|
this.options.cacheKey || "",
|
|
199
199
|
// File content hashes based on target.inputs
|
|
@@ -204,13 +204,34 @@ class TargetHasher {
|
|
|
204
204
|
].filter(Boolean);
|
|
205
205
|
const hashString = (0, _hashStrings.hashStrings)(combinedHashes);
|
|
206
206
|
this.targetHashes[target.id] = hashString;
|
|
207
|
+
this.targetHashesLog[target.id] = {
|
|
208
|
+
fileHashes,
|
|
209
|
+
globalFileHashes
|
|
210
|
+
};
|
|
207
211
|
return hashString;
|
|
208
212
|
}
|
|
213
|
+
writeTargetHashesManifest() {
|
|
214
|
+
for (const [id, { fileHashes , globalFileHashes }] of Object.entries(this.targetHashesLog)){
|
|
215
|
+
const targetHashesManifestPath = _path.default.join(this.targetHashesDirectory, `${id}.json`);
|
|
216
|
+
if (!_fs.default.existsSync(_path.default.dirname(targetHashesManifestPath))) {
|
|
217
|
+
_fs.default.mkdirSync(_path.default.dirname(targetHashesManifestPath), {
|
|
218
|
+
recursive: true
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
_fs.default.writeFileSync(targetHashesManifestPath, JSON.stringify({
|
|
222
|
+
fileHashes,
|
|
223
|
+
globalFileHashes
|
|
224
|
+
}), "utf-8");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
209
227
|
async cleanup() {
|
|
228
|
+
this.writeTargetHashesManifest();
|
|
210
229
|
await this.fileHasher.writeManifest();
|
|
211
230
|
}
|
|
212
231
|
constructor(options){
|
|
213
232
|
_define_property(this, "options", void 0);
|
|
233
|
+
_define_property(this, "targetHashesLog", void 0);
|
|
234
|
+
_define_property(this, "targetHashesDirectory", void 0);
|
|
214
235
|
_define_property(this, "logger", void 0);
|
|
215
236
|
_define_property(this, "fileHasher", void 0);
|
|
216
237
|
_define_property(this, "packageTree", void 0);
|
|
@@ -223,6 +244,7 @@ class TargetHasher {
|
|
|
223
244
|
_define_property(this, "dependencyMap", void 0);
|
|
224
245
|
_define_property(this, "memoizedEnvGlobResults", void 0);
|
|
225
246
|
this.options = options;
|
|
247
|
+
this.targetHashesLog = {};
|
|
226
248
|
this.packageInfos = {};
|
|
227
249
|
this.targetHashes = {};
|
|
228
250
|
this.dependencyMap = {
|
|
@@ -235,5 +257,11 @@ class TargetHasher {
|
|
|
235
257
|
this.fileHasher = new _FileHasher.FileHasher({
|
|
236
258
|
root
|
|
237
259
|
});
|
|
260
|
+
this.targetHashesDirectory = _path.default.join(root, "node_modules", ".cache", "lage", "hashes");
|
|
261
|
+
if (!_fs.default.existsSync(this.targetHashesDirectory)) {
|
|
262
|
+
_fs.default.mkdirSync(this.targetHashesDirectory, {
|
|
263
|
+
recursive: true
|
|
264
|
+
});
|
|
265
|
+
}
|
|
238
266
|
}
|
|
239
267
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lage-run/hasher",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Hasher for Lage Targets",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/microsoft/lage"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@lage-run/logger": "^1.3.1",
|
|
19
|
-
"@lage-run/target-graph": "^0.8.
|
|
19
|
+
"@lage-run/target-graph": "^0.8.10",
|
|
20
20
|
"execa": "5.1.1",
|
|
21
21
|
"fast-glob": "3.3.2",
|
|
22
22
|
"glob-hasher": "^1.4.2",
|