···11-/**
22- * Applies multiple code patches in order to a given piece of code, at each step it validates that the code
33- * has actually been patched/changed, if not an error is thrown
44- *
55- * @param code the code to apply the patches to
66- * @param patches array of tuples, containing a string indicating the target of the patching (for logging) and
77- * a patching function that takes a string (pre-patch code) and returns a string (post-patch code)
88- * @returns the patched code
99- */
1010-export async function patchCodeWithValidations(
1111- code: string,
1212- patches: [string, (code: string) => string | Promise<string>, opts?: { isOptional?: boolean }][]
1313-): Promise<string> {
1414- console.log(`Applying code patches:`);
1515- let patchedCode = code;
1616-1717- for (const [target, patchFunction, opts] of patches) {
1818- console.log(` - patching ${target}`);
1919-2020- const prePatchCode = patchedCode;
2121- patchedCode = await patchFunction(patchedCode);
2222-2323- if (!opts?.isOptional && prePatchCode === patchedCode) {
2424- throw new Error(`Failed to patch ${target}`);
2525- }
2626- }
2727-2828- return patchedCode;
2929-}
+1-1
packages/cloudflare/src/cli/build/utils/index.ts
···11-export * from "./apply-patches.js";
11+export * from "./copy-package-cli-files.js";
22export * from "./create-config-files.js";
33export * from "./ensure-cf-config.js";
44export * from "./extract-project-env-vars.js";