diff --git a/packages/cdktf/lib/manifest.ts b/packages/cdktf/lib/manifest.ts index 4cf2a28ebd..1a01f6e93b 100644 --- a/packages/cdktf/lib/manifest.ts +++ b/packages/cdktf/lib/manifest.ts @@ -4,6 +4,7 @@ import * as path from "path"; import * as fs from "fs"; import { TerraformStack } from "./terraform-stack"; import { AnnotationMetadataEntryType } from "./annotations"; +import stringify = require("json-stable-stringify"); export interface StackAnnotation { readonly constructPath: string; @@ -87,7 +88,7 @@ export class Manifest implements IManifest { public writeToFile() { fs.writeFileSync( path.join(this.outdir, Manifest.fileName), - JSON.stringify(this.buildManifest(), undefined, 2) + stringify(this.buildManifest(), { space: 2 }) ); } } diff --git a/packages/cdktf/test/manifest.test.ts b/packages/cdktf/test/manifest.test.ts index 0af27c32ad..74242236da 100644 --- a/packages/cdktf/test/manifest.test.ts +++ b/packages/cdktf/test/manifest.test.ts @@ -53,18 +53,20 @@ test("write manifest", () => { expect(fs.readFileSync(path.join(outdir, Manifest.fileName)).toString()) .toMatchInlineSnapshot(` "{ - "version": "0.0.0", "stacks": { "this-is-a-stack": { - "name": "this-is-a-stack", + "annotations": [ + ], "constructPath": "this-is-a-stack", - "workingDirectory": "stacks/this-is-a-stack", - "synthesizedStackPath": "stacks/this-is-a-stack/cdk.tf.json", + "dependencies": [ + ], + "name": "this-is-a-stack", "stackMetadataPath": "stacks/this-is-a-stack/metadata.json", - "annotations": [], - "dependencies": [] + "synthesizedStackPath": "stacks/this-is-a-stack/cdk.tf.json", + "workingDirectory": "stacks/this-is-a-stack" } - } + }, + "version": "0.0.0" }" `); }); @@ -88,14 +90,8 @@ describe("manifest annotations", () => { expect(fs.readFileSync(path.join(outdir, Manifest.fileName)).toString()) .toMatchInlineSnapshot(` "{ - "version": "stubbed", "stacks": { "this-is-a-stack": { - "name": "this-is-a-stack", - "constructPath": "this-is-a-stack", - "workingDirectory": "stacks/this-is-a-stack", - "synthesizedStackPath": "stacks/this-is-a-stack/cdk.tf.json", - "stackMetadataPath": "stacks/this-is-a-stack/metadata.json", "annotations": [ { "constructPath": "this-is-a-stack", @@ -113,9 +109,16 @@ describe("manifest annotations", () => { "message": "an error" } ], - "dependencies": [] + "constructPath": "this-is-a-stack", + "dependencies": [ + ], + "name": "this-is-a-stack", + "stackMetadataPath": "stacks/this-is-a-stack/metadata.json", + "synthesizedStackPath": "stacks/this-is-a-stack/cdk.tf.json", + "workingDirectory": "stacks/this-is-a-stack" } - } + }, + "version": "stubbed" }" `); });