diff --git a/deploy/README.md b/deploy/README.md index 81c992372..fda165754 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -1,3 +1,9 @@ ## Deploys -We want to generate @types/xyz \ No newline at end of file +We want to take the `d.ts` files inside `generated` into a set of different `@types` packages. This infra all lives inside these files as multiple steps. For debugging you mostly want to run: + +```sh +node deploy/createTypesPackages.js +``` + +Then look at `deploy/generated` to see the set of NPM packages. \ No newline at end of file diff --git a/deploy/createTypesPackages.js b/deploy/createTypesPackages.js index 027f629dd..3ba88a80b 100644 --- a/deploy/createTypesPackages.js +++ b/deploy/createTypesPackages.js @@ -90,6 +90,7 @@ const go = async () => { }); prependAutoImports(pkg, packagePath); + postProcessDTSFiles(pkg, packagePath); // Setup the files in the repo const newPkgJSON = await updatePackageJSON(pkg, packagePath); @@ -188,6 +189,30 @@ function prependAutoImports(pkg, packagePath) { fs.writeFileSync(index, `${toPrepend}\n\n${indexText}`); } +/** + * Handles any post-processing we do for deployment. + * @param {Package} pkg + * @param {URL} packagePath + */ +function postProcessDTSFiles(pkg, packagePath) { + iterateThroughFiles((content) => { + return content.replace( + "abort(): AbortSignal;", + "// abort(): AbortSignal; - To be re-added in the future" + ); + }); + + /** @param {(str:string) => string} contentReplacer */ + function iterateThroughFiles(contentReplacer) { + pkg.files.forEach((fileRef) => { + const dtsFileURL = new URL(fileRef.to, packagePath); + let dtsContent = fs.readFileSync(dtsFileURL, "utf-8"); + dtsContent = contentReplacer(dtsContent); + fs.writeFileSync(dtsFileURL, dtsContent); + }); + } +} + if (process.argv[1] === fileURLToPath(import.meta.url)) { await go(); }