@lage-run/hasher 1.3.0 → 1.3.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 CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "@lage-run/hasher",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 30 Aug 2024 18:39:54 GMT",
5
+ "date": "Wed, 04 Sep 2024 23:24:50 GMT",
6
+ "version": "1.3.1",
7
+ "tag": "@lage-run/hasher_v1.3.1",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "kchau@microsoft.com",
12
+ "package": "@lage-run/hasher",
13
+ "commit": "cbfd60ade539086a6a797c0674e06f26cfc06af3",
14
+ "comment": "Use file hashes instead of just the file names for env glob for targets\\"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Fri, 30 Aug 2024 18:40:09 GMT",
6
21
  "version": "1.3.0",
7
22
  "tag": "@lage-run/hasher_v1.3.0",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - @lage-run/hasher
2
2
 
3
- This log was last generated on Fri, 30 Aug 2024 18:39:54 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 04 Sep 2024 23:24:50 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.3.1
8
+
9
+ Wed, 04 Sep 2024 23:24:50 GMT
10
+
11
+ ### Patches
12
+
13
+ - Use file hashes instead of just the file names for env glob for targets\ (kchau@microsoft.com)
14
+
7
15
  ## 1.3.0
8
16
 
9
- Fri, 30 Aug 2024 18:39:54 GMT
17
+ Fri, 30 Aug 2024 18:40:09 GMT
10
18
 
11
19
  ### Minor changes
12
20
 
@@ -190,7 +190,7 @@ 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 envGlobFiles = target.environmentGlob ? await this.getMemorizedEnvGlobResults(target.environmentGlob) : Object.values(this.globalInputsHash ?? {});
193
+ const envGlobFiles = Object.values(target.environmentGlob ? this.fileHasher.hash(await this.getMemorizedEnvGlobResults(target.environmentGlob)) : this.globalInputsHash ?? {});
194
194
  const combinedHashes = [
195
195
  // Environmental hashes
196
196
  ...envGlobFiles,
@@ -1 +1 @@
1
- export const global: boolean;
1
+ export const global2: boolean;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
6
6
  const _index = require("../index");
7
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
7
8
  const _monorepofixture = require("@lage-run/monorepo-fixture");
8
9
  function _interop_require_default(obj) {
9
10
  return obj && obj.__esModule ? obj : {
@@ -152,4 +153,42 @@ describe("The main Hasher class", ()=>{
152
153
  expect(hash).not.toEqual(hash2);
153
154
  monorepo1.cleanup();
154
155
  });
156
+ it("creates different hashes when the target has a different env glob for different task types", async ()=>{
157
+ const monorepo1 = await setupFixture("monorepo-with-global-files-different-tasks");
158
+ const hasher = new _index.TargetHasher({
159
+ root: monorepo1.root,
160
+ environmentGlob: []
161
+ });
162
+ const target = createTarget(monorepo1.root, "package-a", "test");
163
+ target.environmentGlob = [
164
+ "some-global*"
165
+ ];
166
+ target.inputs = [
167
+ "**/*",
168
+ "^**/*"
169
+ ];
170
+ const hash = await getHash(hasher, target);
171
+ const target2 = createTarget(monorepo1.root, "package-a", "lint");
172
+ target2.environmentGlob = [
173
+ ".eslintrc.js"
174
+ ];
175
+ target2.inputs = [
176
+ "**/*",
177
+ "^**/*"
178
+ ];
179
+ const hash2 = await getHash(hasher, target2);
180
+ const target3 = createTarget(monorepo1.root, "package-a", "lint");
181
+ _fs.default.writeFileSync(_path.default.join(monorepo1.root, ".eslintrc.js"), "module.exports = {/*somethingdifferent*/};");
182
+ target3.environmentGlob = [
183
+ ".eslintrc.js"
184
+ ];
185
+ target3.inputs = [
186
+ "**/*",
187
+ "^**/*"
188
+ ];
189
+ const hash3 = await getHash(hasher, target3);
190
+ expect(hash).not.toEqual(hash2);
191
+ expect(hash2).not.toEqual(hash3);
192
+ monorepo1.cleanup();
193
+ });
155
194
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lage-run/hasher",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Hasher for Lage Targets",
5
5
  "repository": {
6
6
  "url": "https://github.com/microsoft/lage"