From dc75965c2d2efd0d6acfe7561ef8c151c33908fa Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Sat, 8 Aug 2026 20:42:51 -0400 Subject: [PATCH] fix(codegen): write prettier-stable generated manifests --- packages/httpapi-codegen/src/index.ts | 10 +++++++++- packages/httpapi-codegen/test/write.test.ts | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/httpapi-codegen/src/index.ts b/packages/httpapi-codegen/src/index.ts index 35a07ae9b7d7..8d4983b817f6 100644 --- a/packages/httpapi-codegen/src/index.ts +++ b/packages/httpapi-codegen/src/index.ts @@ -1316,7 +1316,15 @@ export function write( }).pipe(Effect.flatMap((content) => fs.writeFileString(join(directory, file.path), content))), { concurrency: 8, discard: true }, ) - yield* fs.writeFileString(manifest, JSON.stringify(output.files.map((file) => file.path).sort(), null, 2) + "\n") + // Format the manifest with the same prettier settings as the repo-wide + // format pass, so `check:generated` stays clean after the generate bot + // reformats the tree. + const manifestJson = JSON.stringify(output.files.map((file) => file.path).sort()) + const manifestContent = yield* Effect.tryPromise({ + try: () => format(manifestJson, { filepath: manifest, parser: "json", printWidth: 120 }), + catch: (error) => new GenerationError({ reason: `Failed to format ${manifest}: ${String(error)}` }), + }) + yield* fs.writeFileString(manifest, manifestContent) }) } diff --git a/packages/httpapi-codegen/test/write.test.ts b/packages/httpapi-codegen/test/write.test.ts index f0704abea2b0..018061df699a 100644 --- a/packages/httpapi-codegen/test/write.test.ts +++ b/packages/httpapi-codegen/test/write.test.ts @@ -16,7 +16,7 @@ describe("HttpApiCodegen.write", () => { expect(writes).toEqual([ { path: "/generated/session.ts", content: "export const session = {}\n" }, - { path: "/generated/.httpapi-codegen.json", content: '[\n "session.ts"\n]\n' }, + { path: "/generated/.httpapi-codegen.json", content: '["session.ts"]\n' }, ]) }).pipe( Effect.provideService(