Skip to content

Commit

Permalink
Upgrade pretty-format to v29 (facebook#45732)
Browse files Browse the repository at this point in the history
Summary:
As described in [this issue](facebook#45726), we had a problem where, at runtime, version v29 instead of v26 was used, so upgrading it is the fastest fix.

## Changelog:

[GENERAL] [CHANGED] - Upgrade pretty-format to 29.7.0

<!--
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: facebook#45732

Test Plan:
I use console log in the RN tester app
![image](https://github.com/user-attachments/assets/3e3ab0d1-e32b-4b73-8f00-cbd8f040c5aa)

Reviewed By: blakef

Differential Revision: D60533197

Pulled By: tdn120

fbshipit-source-id: b83dbfe463971abbf00cfebdcc9e5dd6975de0d8
  • Loading branch information
dprevost-LMI authored and facebook-github-bot committed Aug 28, 2024
1 parent 8618eec commit 7bc9244
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 53 deletions.
49 changes: 0 additions & 49 deletions flow-typed/npm/pretty-format_v26.x.x.js

This file was deleted.

73 changes: 73 additions & 0 deletions flow-typed/npm/pretty-format_v29.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
*
* @flow strict
* @format
* @oncall react_native
*/
declare type Print = (value: mixed) => string;
declare type Indent = (value: string) => string;
declare type PluginOptions = {
edgeSpacing: string,
min: boolean,
spacing: string,
};
declare type Colors = {
comment: {close: string; open: string},
content: {close: string; open: string},
prop: {close: string; open: string},
tag: {close: string; open: string},
value: {close: string; open: string},
};
declare type CompareKeys = ((a: string, b: string) => number) | null | void;

declare type PrettyFormatPlugin =
| {
print: (
value: mixed,
print?: ?Print,
indent?: ?Indent,
options?: ?PluginOptions,
colors?: ?Colors,
) => string,
test: (value: mixed) => boolean,
}
| {
serialize: (value: mixed) => string,
test: (value: mixed) => boolean,
};

declare module 'pretty-format' {
declare export function format(
value: mixed,
options?: ?{
callToJSON?: ?boolean,
compareKeys?: CompareKeys,
escapeRegex?: ?boolean,
escapeString?: ?boolean,
highlight?: ?boolean,
indent?: ?number,
maxDepth?: ?number,
maxWidth?: ?number,
min?: ?boolean,
plugins?: ?Array<PrettyFormatPlugin>,
printBasicPrototype?: ?boolean,
printFunctionName?: ?boolean,
theme?: ?{
comment?: ?string,
content?: ?string,
prop?: ?string,
tag?: ?string,
value: ?string,
},
},
): string;
declare export const plugins: {
AsymmetricMatcher: PrettyFormatPlugin,
DOMCollection: PrettyFormatPlugin,
DOMElement: PrettyFormatPlugin,
Immutable: PrettyFormatPlugin,
ReactElement: PrettyFormatPlugin,
ReactTestComponent: PrettyFormatPlugin,
};
}
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Utilities/HMRClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const HMRClient: HMRClientNativeInterface = {
data: data.map(item =>
typeof item === 'string'
? item
: prettyFormat(item, {
: prettyFormat.format(item, {
escapeString: true,
highlight: true,
maxDepth: 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let rejectionTrackingOptions: $NonMaybeType<Parameters<enable>[0]> = {
stack = error.stack;
} else {
try {
message = require('pretty-format')(rejection);
message = require('pretty-format').format(rejection);
} catch {
message =
typeof rejection === 'string'
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"metro-source-map": "^0.80.3",
"mkdirp": "^0.5.1",
"nullthrows": "^1.1.1",
"pretty-format": "^26.5.2",
"pretty-format": "^29.7.0",
"promise": "^8.3.0",
"react-devtools-core": "^5.3.1",
"react-refresh": "^0.14.0",
Expand Down
11 changes: 10 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7399,7 +7399,7 @@ pretty-format@^24.9.0:
ansi-styles "^3.2.0"
react-is "^16.8.4"

pretty-format@^26.5.2, pretty-format@^26.6.2:
pretty-format@^26.6.2:
version "26.6.2"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93"
integrity sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg==
Expand Down Expand Up @@ -7427,6 +7427,15 @@ pretty-format@^29.6.3:
ansi-styles "^5.0.0"
react-is "^18.0.0"

pretty-format@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812"
integrity sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==
dependencies:
"@jest/schemas" "^29.6.3"
ansi-styles "^5.0.0"
react-is "^18.0.0"

prettyjson@^1.2.1:
version "1.2.5"
resolved "https://registry.yarnpkg.com/prettyjson/-/prettyjson-1.2.5.tgz#ef3cfffcc70505c032abc59785884b4027031835"
Expand Down

0 comments on commit 7bc9244

Please sign in to comment.