Skip to content

Commit 28eb274

Browse files
committed
Changes the addresses.json format and runs prettify on generated JSON
1 parent d357ad9 commit 28eb274

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

scripts/check-deployment-addresses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ async function main(): Promise<void> {
99
? fs.readFileSync(addressesJsonPath, 'utf8')
1010
: '{}';
1111

12-
const generatedAddressesJsonString = getDeploymentAddresses();
12+
const generatedAddressesJsonString = await getDeploymentAddresses();
1313

1414
// Normalize by parsing and re-stringifying to ensure consistent formatting for comparison
1515
const normalizedExisting = `${JSON.stringify(JSON.parse(existingAddressesJsonString), null, 2)}\n`;

scripts/generate-deployment-addresses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { join } from 'node:path';
44
import { getDeploymentAddresses } from './src/deployment-addresses';
55

66
async function main(): Promise<void> {
7-
fs.writeFileSync(join('deployments', 'addresses.json'), getDeploymentAddresses());
7+
fs.writeFileSync(join('deployments', 'addresses.json'), await getDeploymentAddresses());
88
}
99

1010
main()

scripts/src/deployment-addresses.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import * as fs from 'node:fs';
22
import { join, parse as parsePath } from 'node:path';
33

44
import type { AddressLike } from 'ethers';
5+
import { format } from 'prettier';
6+
7+
const PRETTIER_CONFIG = join(__dirname, '..', '..', '.prettierrc');
58

69
export interface Deployment {
710
deploymentName: string; // The full deterministic name from the artifact file
@@ -41,7 +44,7 @@ function extractContractName(deploymentName: string): string {
4144
* with an array of deployment instances.
4245
* @returns A stringified JSON object of deployment addresses.
4346
*/
44-
export function getDeploymentAddresses(): string {
47+
export async function getDeploymentAddresses(): Promise<string> {
4548
const allDeployments: AllDeploymentsByContract = {};
4649
// Assumes this script is in data-feed-proxy-combinators/scripts/src/
4750
// and the deployments directory is at data-feed-proxy-combinators/deployments/
@@ -90,5 +93,8 @@ export function getDeploymentAddresses(): string {
9093
};
9194
}
9295
}
93-
return `${JSON.stringify(allDeployments, null, 2)}\n`;
96+
97+
const rawContent = JSON.stringify(allDeployments);
98+
const prettierConfig = JSON.parse(fs.readFileSync(PRETTIER_CONFIG, 'utf8'));
99+
return format(rawContent, { ...prettierConfig, parser: 'json' });
94100
}

0 commit comments

Comments
 (0)