Skip to content

Commit

Permalink
Adjust output package.json formatting in scripts (facebook#43133)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#43133

I noticed inconsistent handling of terminating newlines in D54006327@V1, and had also been noticing `yarn build` reformatting unrelated sections of `package.json` files.

For now, this logic isn't moved to a shared util, since there will likely be a higher level abstraction for the release scripts in the next batch of improvements.

Changelog: [Internal]

Reviewed By: lunaleaps, cipolleschi

Differential Revision: D54007565

fbshipit-source-id: 74d58362a85be4fae2f9e058b6c6622a026ff0a0
  • Loading branch information
huntie authored and facebook-github-bot committed Feb 23, 2024
1 parent 52a70d7 commit 30b088d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
5 changes: 1 addition & 4 deletions scripts/build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,7 @@ async function rewritePackageExports(packageName /*: string */) {

pkg.exports = rewriteExportsField(pkg.exports);

await fs.writeFile(
packageJsonPath,
prettier.format(JSON.stringify(pkg), {parser: 'json'}),
);
await fs.writeFile(packageJsonPath, JSON.stringify(pkg, null, 2) + '\n');
}

/*::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ exports[`setReactNativeVersion should set nightly version: packages/react-native
\\"dependencies\\": {
\\"@react-native/package-a\\": \\"0.81.0-nightly-29282302-abcd1234\\"
}
}"
}
"
`;
exports[`setReactNativeVersion should set release version: packages/react-native/Libraries/Core/ReactNativeVersion.js 1`] = `
Expand Down Expand Up @@ -259,5 +260,6 @@ exports[`setReactNativeVersion should set release version: packages/react-native
\\"dependencies\\": {
\\"@react-native/package-a\\": \\"1000.0.0\\"
}
}"
}
"
`;
3 changes: 1 addition & 2 deletions scripts/releases/set-rn-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ async function setReactNativePackageVersion(

await fs.writeFile(
path.join(REPO_ROOT, 'packages/react-native/package.json'),
JSON.stringify(packageJson, null, 2),
'utf-8',
JSON.stringify(packageJson, null, 2) + '\n',
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ exports[`setVersion updates monorepo for nightly: packages/react-native/package.
\\"metro-config\\": \\"^0.80.3\\",
\\"metro-runtime\\": \\"^0.80.3\\"
}
}"
}
"
`;
exports[`setVersion updates monorepo for nightly: packages/react-native/template/package.json 1`] = `
Expand Down Expand Up @@ -374,7 +375,8 @@ exports[`setVersion updates monorepo for release-candidate: packages/react-nativ
\\"metro-config\\": \\"^0.80.3\\",
\\"metro-runtime\\": \\"^0.80.3\\"
}
}"
}
"
`;
exports[`setVersion updates monorepo for release-candidate: packages/react-native/template/package.json 1`] = `
Expand Down Expand Up @@ -572,7 +574,8 @@ exports[`setVersion updates monorepo for stable version: packages/react-native/p
\\"metro-config\\": \\"^0.80.3\\",
\\"metro-runtime\\": \\"^0.80.3\\"
}
}"
}
"
`;
exports[`setVersion updates monorepo for stable version: packages/react-native/template/package.json 1`] = `
Expand Down Expand Up @@ -770,7 +773,8 @@ exports[`setVersion updates monorepo on main after release cut: packages/react-n
\\"metro-config\\": \\"^0.80.3\\",
\\"metro-runtime\\": \\"^0.80.3\\"
}
}"
}
"
`;
exports[`setVersion updates monorepo on main after release cut: packages/react-native/template/package.json 1`] = `
Expand Down
1 change: 0 additions & 1 deletion scripts/releases/set-version/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ async function updatePackageJson(
return fs.writeFile(
path.join(packagePath, 'package.json'),
JSON.stringify(packageJson, null, 2) + '\n',
'utf-8',
);
}

Expand Down

0 comments on commit 30b088d

Please sign in to comment.