Skip to content

Commit

Permalink
chore: manifest.json should have stable json
Browse files Browse the repository at this point in the history
  • Loading branch information
mutahhir committed Apr 15, 2024
1 parent 81a9593 commit 1330790
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
3 changes: 2 additions & 1 deletion packages/cdktf/lib/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 })
);
}
}
33 changes: 18 additions & 15 deletions packages/cdktf/test/manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}"
`);
});
Expand All @@ -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",
Expand All @@ -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"
}"
`);
});
Expand Down

0 comments on commit 1330790

Please sign in to comment.