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(