Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions change/change-af1026b1-217e-47f5-9bf6-56d614cb46c9.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"changes": [
{
"type": "patch",
"comment": "Update backfill-cache to 5.11.3",
"packageName": "@lage-run/cache",
"email": "elcraig@microsoft.com",
"dependentChangeType": "patch"
},
{
"type": "patch",
"comment": "Update config generated by init",
"packageName": "@lage-run/cli",
"email": "elcraig@microsoft.com",
"dependentChangeType": "patch"
},
{
"type": "patch",
"comment": "Reuse utilities from backfill-hasher",
"packageName": "@lage-run/hasher",
"email": "elcraig@microsoft.com",
"dependentChangeType": "patch"
},
{
"type": "none",
"comment": "Update readme",
"packageName": "lage",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
}
]
}
6 changes: 4 additions & 2 deletions docs/docs/guides/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ const config = {
// (relative to package root; folders must end with **/*)
outputGlob: ["lib/**/*"],
// Changes to any of these files/globs will invalidate the cache (relative to repo root;
// folders must end with **/*). This should include your lock file and any other repo-wide
// configs or scripts that are outside a package but could invalidate previous output.
// folders must end with **/*). This should include any repo-wide configs or scripts that
// are outside a package but could invalidate previous output. Including the lock file is
// optional--lage attempts to more granularly check resolved dependency changes, but this
// isn't entirely reliable, especially for peerDependencies.
environmentGlob: ["package.json", "yarn.lock", "lage.config.js"]
}
};
Expand Down
6 changes: 4 additions & 2 deletions docs/docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ const config = {
// (relative to package root; folders must end with **/*)
outputGlob: ["lib/**/*"],
// Changes to any of these files/globs will invalidate the cache (relative to repo root;
// folders must end with **/*). This should include your lock file and any other repo-wide
// configs or scripts that are outside a package but could invalidate previous output.
// folders must end with **/*). This should include any repo-wide configs or scripts that
// are outside a package but could invalidate previous output. Including the lock file is
// optional--lage attempts to more granularly check resolved dependency changes, but this
// isn't entirely reliable, especially for peerDependencies.
environmentGlob: ["package.json", "yarn.lock", "lage.config.js"]
}
};
Expand Down
6 changes: 4 additions & 2 deletions docs/docs/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ const config = {
// (relative to package root; folders must end with **/*)
outputGlob: ["lib/**/*"],
// Changes to any of these files/globs will invalidate the cache (relative to repo root;
// folders must end with **/*). This should include your lock file and any other repo-wide
// configs or scripts that are outside a package but could invalidate previous output.
// folders must end with **/*). This should include any repo-wide configs or scripts that
// are outside a package but could invalidate previous output. Including the lock file is
// optional--lage attempts to more granularly check resolved dependency changes, but this
// isn't entirely reliable, especially for peerDependencies.
environmentGlob: ["package.json", "yarn.lock", "lage.config.js"]
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@lage-run/config": "workspace:^",
"@lage-run/logger": "workspace:^",
"@lage-run/target-graph": "workspace:^",
"backfill-cache": "5.11.2",
"backfill-cache": "5.11.3",
"backfill-config": "6.7.1",
"backfill-logger": "5.4.0",
"glob-hasher": "^1.4.2"
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/commands/init/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ const config = {
// (relative to package root; folders must end with **/*)
outputGlob: ["lib/**/*"],
// Changes to any of these files/globs will invalidate the cache (relative to repo root;
// folders must end with **/*). This should include your lock file and any other repo-wide
// configs or scripts that are outside a package but could invalidate previous output.
// folders must end with **/*). This should include any repo-wide configs or scripts that
// are outside a package but could invalidate previous output. Including the lock file is
// optional--lage attempts to more granularly check resolved dependency changes, but this
// isn't entirely reliable, especially for peerDependencies.
environmentGlob: ${JSON.stringify(["package.json", lockFile, "lage.config.js"].filter(Boolean))},
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/hasher/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# @lage-run/hasher

This package takes code from both backfill-hasher & package-dep-hash and strips out the extraneous dependencies: backfill-logger and @rushstack/node-core-lib. This is done so that `lage` can become a pure ES Module package. It also allows us to control how the hashing works should lage gains the ability to customize the `inputs` in the future.
This package builds on top of some helpers from `backfill-hasher` but adds customization for hashing targets with custom inputs and other logic.
1 change: 1 addition & 0 deletions packages/hasher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@lage-run/globby": "workspace:^",
"@lage-run/logger": "workspace:^",
"@lage-run/target-graph": "workspace:^",
"backfill-hasher": "6.7.0",
"execa": "5.1.1",
"glob-hasher": "^1.4.2",
"graceful-fs": "4.2.11",
Expand Down
12 changes: 6 additions & 6 deletions packages/hasher/src/FileHasher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from "graceful-fs";
import path from "path";
import { getFileHashes } from "backfill-hasher";
import { hash as fastHash, stat } from "glob-hasher";
import fs from "graceful-fs";
import { createInterface } from "node:readline";
import { getPackageDeps } from "./getPackageDeps.js";
import path from "path";

interface FileHashStoreOptions {
root: string;
Expand All @@ -29,12 +29,12 @@ export class FileHasher {

private getHashesFromGit(): void {
const { root } = this.options;
const fileHashes = getPackageDeps(root);
const files = [...fileHashes.keys()];
const fileHashes = getFileHashes(root);
const files = Object.keys(fileHashes);
const fileStats = stat(files, { cwd: root }) ?? {};

for (const [relativePath, fileStat] of Object.entries(fileStats)) {
const hash = fileHashes.get(relativePath);
const hash = fileHashes[relativePath];
if (hash) {
const { size, mtime } = fileStat;

Expand Down
20 changes: 9 additions & 11 deletions packages/hasher/src/TargetHasher.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import type { Target } from "@lage-run/target-graph";
import { hash } from "glob-hasher";
import { globAsync } from "@lage-run/globby";

import type { Logger } from "@lage-run/logger";
import type { Target } from "@lage-run/target-graph";
import { resolveExternalDependencies } from "backfill-hasher";
import fs from "fs";
import { hash } from "glob-hasher";
import path from "path";
import {
type DependencyMap,
type ParsedLock,
type PackageInfos,
parseLockFile,
createDependencyMap,
type DependencyMap,
getPackageInfo,
getPackageInfosAsync,
type PackageInfos,
type ParsedLock,
parseLockFile,
} from "workspace-tools";

import { hashStrings } from "./hashStrings.js";
import { resolveExternalDependencies } from "./resolveExternalDependencies.js";
import { FileHasher } from "./FileHasher.js";
import type { Logger } from "@lage-run/logger";
import { PackageTree } from "./PackageTree.js";
import { getInputFiles } from "./getInputFiles.js";
import { hashStrings } from "./hashStrings.js";

export interface TargetHasherOptions {
root: string;
Expand Down
Loading