@lage-run/cache 0.4.3 → 0.5.1
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 +37 -1
- package/CHANGELOG.md +19 -2
- package/lib/TargetHasher.d.ts +1 -0
- package/lib/TargetHasher.js +17 -5
- package/lib/salt.js +14 -6
- package/package.json +4 -3
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,43 @@
|
|
|
2
2
|
"name": "@lage-run/cache",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Wed, 29 Mar 2023 20:02:22 GMT",
|
|
6
|
+
"tag": "@lage-run/cache_v0.5.1",
|
|
7
|
+
"version": "0.5.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "kchau@microsoft.com",
|
|
12
|
+
"package": "@lage-run/cache",
|
|
13
|
+
"commit": "3554c6c3bc2226933a819fd1123ada422848d7d4",
|
|
14
|
+
"comment": "moving back to fast-glob for globbing, as it was more accurate"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@lage-run/cache",
|
|
19
|
+
"comment": "Bump @lage-run/hasher to v0.2.2",
|
|
20
|
+
"commit": "3554c6c3bc2226933a819fd1123ada422848d7d4"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"date": "Mon, 27 Mar 2023 18:00:15 GMT",
|
|
27
|
+
"tag": "@lage-run/cache_v0.5.0",
|
|
28
|
+
"version": "0.5.0",
|
|
29
|
+
"comments": {
|
|
30
|
+
"minor": [
|
|
31
|
+
{
|
|
32
|
+
"author": "kchau@microsoft.com",
|
|
33
|
+
"package": "@lage-run/cache",
|
|
34
|
+
"commit": "6a0593b1ef9f7d16e69eb57ee1bc71b8613fd1d8",
|
|
35
|
+
"comment": "gitignore to be respected again in the envglob - this causes major perf regression otherwise"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"date": "Tue, 14 Mar 2023 00:28:38 GMT",
|
|
6
42
|
"tag": "@lage-run/cache_v0.4.3",
|
|
7
43
|
"version": "0.4.3",
|
|
8
44
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
# Change Log - @lage-run/cache
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 29 Mar 2023 20:02:22 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.5.1
|
|
8
|
+
|
|
9
|
+
Wed, 29 Mar 2023 20:02:22 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- moving back to fast-glob for globbing, as it was more accurate (kchau@microsoft.com)
|
|
14
|
+
- Bump @lage-run/hasher to v0.2.2
|
|
15
|
+
|
|
16
|
+
## 0.5.0
|
|
17
|
+
|
|
18
|
+
Mon, 27 Mar 2023 18:00:15 GMT
|
|
19
|
+
|
|
20
|
+
### Minor changes
|
|
21
|
+
|
|
22
|
+
- gitignore to be respected again in the envglob - this causes major perf regression otherwise (kchau@microsoft.com)
|
|
23
|
+
|
|
7
24
|
## 0.4.3
|
|
8
25
|
|
|
9
|
-
Tue, 14 Mar 2023 00:28:
|
|
26
|
+
Tue, 14 Mar 2023 00:28:38 GMT
|
|
10
27
|
|
|
11
28
|
### Patches
|
|
12
29
|
|
package/lib/TargetHasher.d.ts
CHANGED
package/lib/TargetHasher.js
CHANGED
|
@@ -9,7 +9,13 @@ Object.defineProperty(exports, "TargetHasher", {
|
|
|
9
9
|
const _hasher = require("@lage-run/hasher");
|
|
10
10
|
const _saltJs = require("./salt.js");
|
|
11
11
|
const _globHasher = require("glob-hasher");
|
|
12
|
+
const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
|
|
12
13
|
const _hashStringsJs = require("./hashStrings.js");
|
|
14
|
+
function _interopRequireDefault(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
13
19
|
class TargetHasher {
|
|
14
20
|
async hash(target) {
|
|
15
21
|
const { root } = this.options;
|
|
@@ -20,16 +26,22 @@ class TargetHasher {
|
|
|
20
26
|
if (!target.inputs) {
|
|
21
27
|
throw new Error("Root-level targets must have `inputs` defined if it has cache enabled.");
|
|
22
28
|
}
|
|
23
|
-
const
|
|
24
|
-
cwd: root
|
|
25
|
-
|
|
29
|
+
const files = await (0, _fastGlob.default)(target.inputs, {
|
|
30
|
+
cwd: root
|
|
31
|
+
});
|
|
32
|
+
const fileFashes = (0, _globHasher.hash)(files, {
|
|
33
|
+
cwd: root
|
|
26
34
|
}) ?? {};
|
|
27
35
|
const hashes = Object.values(fileFashes);
|
|
28
36
|
hashes.push(hashKey);
|
|
29
37
|
return (0, _hashStringsJs.hashStrings)(hashes);
|
|
30
38
|
}
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
if (!this.repoInfo) {
|
|
40
|
+
this.repoInfo = await (0, _hasher.getRepoInfo)(root);
|
|
41
|
+
}
|
|
42
|
+
const hasher = new _hasher.Hasher(target.cwd, this.repoInfo);
|
|
43
|
+
const hashString = hasher.createPackageHash(hashKey);
|
|
44
|
+
return hashString;
|
|
33
45
|
}
|
|
34
46
|
constructor(options){
|
|
35
47
|
this.options = options;
|
package/lib/salt.js
CHANGED
|
@@ -14,6 +14,12 @@ _export(exports, {
|
|
|
14
14
|
});
|
|
15
15
|
const _globHasher = require("glob-hasher");
|
|
16
16
|
const _hashStringsJs = require("./hashStrings.js");
|
|
17
|
+
const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
|
|
18
|
+
function _interopRequireDefault(obj) {
|
|
19
|
+
return obj && obj.__esModule ? obj : {
|
|
20
|
+
default: obj
|
|
21
|
+
};
|
|
22
|
+
}
|
|
17
23
|
let envHashes = {};
|
|
18
24
|
// A promise to guarantee the getEnvHashes is done one at a time
|
|
19
25
|
let oneAtATime = Promise.resolve();
|
|
@@ -35,7 +41,7 @@ async function getEnvHash(environmentGlobFiles, repoRoot) {
|
|
|
35
41
|
const key = envHashKey(environmentGlobFiles);
|
|
36
42
|
// We want to make sure that we only call getEnvHashOneAtTime one at a time
|
|
37
43
|
// to avoid having many concurrent calls to read files again and again
|
|
38
|
-
oneAtATime = oneAtATime.then(()=>{
|
|
44
|
+
oneAtATime = oneAtATime.then(async ()=>{
|
|
39
45
|
// we may already have it by time we get to here
|
|
40
46
|
if (envHashes[key]) {
|
|
41
47
|
return envHashes[key];
|
|
@@ -44,16 +50,18 @@ async function getEnvHash(environmentGlobFiles, repoRoot) {
|
|
|
44
50
|
});
|
|
45
51
|
return oneAtATime;
|
|
46
52
|
}
|
|
47
|
-
function getEnvHashOneAtTime(environmentGlobFiles,
|
|
53
|
+
async function getEnvHashOneAtTime(environmentGlobFiles, root) {
|
|
48
54
|
const key = envHashKey(environmentGlobFiles);
|
|
49
55
|
if (environmentGlobFiles.length === 0) {
|
|
50
56
|
envHashes[key] = [];
|
|
51
57
|
return envHashes[key];
|
|
52
58
|
}
|
|
53
|
-
const
|
|
54
|
-
cwd:
|
|
55
|
-
gitignore: false
|
|
59
|
+
const files = await (0, _fastGlob.default)(environmentGlobFiles, {
|
|
60
|
+
cwd: root
|
|
56
61
|
});
|
|
57
|
-
|
|
62
|
+
const fileFashes = (0, _globHasher.hash)(files, {
|
|
63
|
+
cwd: root
|
|
64
|
+
}) ?? {};
|
|
65
|
+
envHashes[key] = Object.values(fileFashes);
|
|
58
66
|
return envHashes[key];
|
|
59
67
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lage-run/cache",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Cache for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/microsoft/lage"
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
"lint": "monorepo-scripts lint"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@lage-run/hasher": "^0.2.
|
|
18
|
+
"@lage-run/hasher": "^0.2.2",
|
|
19
19
|
"@lage-run/target-graph": "^0.8.1",
|
|
20
20
|
"@lage-run/logger": "^1.2.2",
|
|
21
21
|
"backfill-config": "^6.3.0",
|
|
22
22
|
"backfill-cache": "^5.6.1",
|
|
23
23
|
"backfill-logger": "^5.1.3",
|
|
24
|
-
"glob-hasher": "1.
|
|
24
|
+
"glob-hasher": "1.2.1",
|
|
25
|
+
"fast-glob": "3.2.12"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@lage-run/monorepo-fixture": "*",
|