Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: manifest.json should have stable json #3584

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe("CdktfProject", () => {
});

return expect(cdktfProject.diff()).rejects.toMatchInlineSnapshot(
`[Error: Usage Error: Found more than one stack, please specify a target stack. Run cdktf diff <stack> with one of these stacks: first, second, third, fourth, fifth ]`
`[Error: Usage Error: Found more than one stack, please specify a target stack. Run cdktf diff <stack> with one of these stacks: fifth, first, fourth, second, third ]`
);
});
});
Expand Down
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");
mutahhir marked this conversation as resolved.
Show resolved Hide resolved

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
Loading
Loading