Files
triggerdotdev--trigger.dev/packages/cli-v3/e2e/createDeployHash.ts
Émile Ré d4ccdf7105 v3 CLI compiling E2E test suite (#1135)
* Boilerplate server-only use case

* wip: integration suite instrumentation setup

* Working poc testing compileProject

* Add pnpm script to run e2e tests only

* Use vitest globals

* Remove commented line

* Remove useless export

* Add modifier to test only one fixture project

* Handle package manager and log level choice

* Update server-only example

* Setup / teardown + split compile for package manager capabilities

* Ignore yarn files

* Fix issue with corepack, store version in engines field

* Rename test file

* Fix npm updates yarn.lock

* Move typecheking in a dedicated test

* Stop bundling the compile command to allow for more granular testing

* Put config resolving in separate test

* Add no-config test case and add test case expected errors configuration

* Add wantCompilationError option

* Add dependencies handling

* Use packageManager passed as option to resolve required deps

* Remove unused guard clauses

* Add postinstall & hash handling step

* Add worker start test

* Handle yarn.lock copy renaming on sigterm and sigkill

* Update vitest and use concurrent option

* Add a readme file

* Add CI workflow

* Fix handle cli deps

* Run cli v3 e2e tests on publish action

* Increase timeout on deps resolving step

* Add changeset

* Remove .pnp.cjs as we use yarn with nodeLinker node-modules

* Add missing .yarnrc.yml file

* No need to build CLI to run E2E tests

* Remove bun.lockb files

* Update beige-pears-explode.md

---------

Co-authored-by: Eric Allam <eallam@icloud.com>
2024-06-14 11:28:36 +01:00

29 lines
804 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 { 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 };
}