52b6f48a94
* Run tests * Remove useless comments * Fix readme * Add fixtures for config step * Add fixture for additionalDependencies name parsing scope issue * Add URL to commit fix * Some fixtures will only use 1 package manager * Add resolve-trigger-deps fixture * use rimraf in test setup * Add legacy-peer-deps fixture * Use vitest fixtures * Add nested peer dep locking issue * Add missing peer dep resolving fixture * Get rid of global namespace, fix parallelism * Add console logs to debug log level * Add changeset * Remove comments * Update README.md
29 lines
818 B
TypeScript
29 lines
818 B
TypeScript
import { createHash } from "node:crypto";
|
|
import { OutputFile } from "esbuild";
|
|
|
|
type CreateDeployHashOptions = {
|
|
dependencies: { [k: string]: string };
|
|
entryPointOutputFile: OutputFile;
|
|
workerOutputFile: OutputFile;
|
|
};
|
|
|
|
export async function createDeployHash(options: CreateDeployHashOptions) {
|
|
const { dependencies, entryPointOutputFile, workerOutputFile } = options;
|
|
|
|
// COPIED FROM compileProject()
|
|
const contentHasher = createHash("sha256");
|
|
contentHasher.update(Buffer.from(entryPointOutputFile.text));
|
|
contentHasher.update(Buffer.from(workerOutputFile.text));
|
|
contentHasher.update(Buffer.from(JSON.stringify(dependencies)));
|
|
|
|
const contentHash = contentHasher.digest("hex");
|
|
|
|
// span.setAttributes({
|
|
// contentHash: contentHash,
|
|
// });
|
|
|
|
// span.end();
|
|
|
|
return { contentHash };
|
|
}
|