diff --git a/private/react-native-bots/dangerfile.js b/private/react-native-bots/dangerfile.js index 77160c71aec..1a2d8131a67 100644 --- a/private/react-native-bots/dangerfile.js +++ b/private/react-native-bots/dangerfile.js @@ -30,20 +30,24 @@ const isFromPhabricator = body_contains('differential revision:'); // Provides advice if a summary section is missing, or body is too short const includesSummary = body_contains('## summary', 'summary:'); -const snapshot_output = JSON.parse( +const diffJsApiChangesOutput = JSON.parse( fs.readFileSync( path.join(process.env.RUNNER_TEMP, 'diff-js-api-changes/output.json'), 'utf8', ), ); -if (snapshot_output && snapshot_output.result !== 'NON_BREAKING') { - const title = ':exclamation: JavaScript API change detected'; - const idea = - 'This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API. ' + - 'Please include a clear changelog message. ' + - 'This change will be subject to extra review.\n\n' + - `This change was flagged as: ${snapshot_output.result}`; - warn(`${title} - ${idea}`); +if (diffJsApiChangesOutput != null) { + const detail = ` +JavaScript API change detected + +This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API. + +- Please include a clear changelog message. +- This change will be subject to additional review. + +This change was flagged as: ${diffJsApiChangesOutput.result} + `; + warn(detail.trim()); } const hasNoUsefulBody = diff --git a/scripts/js-api/diff-api-snapshot/diffApiSnapshot.js b/scripts/js-api/diff-api-snapshot/diffApiSnapshot.js index 684accce7d0..394d128bb7a 100644 --- a/scripts/js-api/diff-api-snapshot/diffApiSnapshot.js +++ b/scripts/js-api/diff-api-snapshot/diffApiSnapshot.js @@ -14,6 +14,7 @@ const t = require('@babel/types'); const Result = { BREAKING: 'BREAKING', + POTENTIALLY_BREAKING: 'POTENTIALLY_BREAKING', POTENTIALLY_NON_BREAKING: 'POTENTIALLY_NON_BREAKING', NON_BREAKING: 'NON_BREAKING', } as const; @@ -62,7 +63,7 @@ function analyzeSpecHashPairs( const newHash = newSpecHashMapping[name]; if (hash !== newHash) { // The hash has changed which means that the statement has changed - output.result = Result.BREAKING; + output.result = Result.POTENTIALLY_BREAKING; output.changedApis.push(name); } delete newSpecHashMapping[name]; diff --git a/scripts/js-api/diff-api-snapshot/index.js b/scripts/js-api/diff-api-snapshot/index.js index 499a33f0fe4..2959b4b13a8 100644 --- a/scripts/js-api/diff-api-snapshot/index.js +++ b/scripts/js-api/diff-api-snapshot/index.js @@ -35,10 +35,9 @@ async function main() { Usage: node ./scripts/js-api/diff-api-snapshot Analyze changes between two versions of React Native's JavaScript API - snapshot (yarn build-types). Returns a JSON object with the following - fields: - - result: 'BREAKING', 'POTENTIALLY_NON_BREAKING' or 'NON_BREAKING'. - - changedApis: List of changed APIs. + snapshot (yarn build-types). Returns a JSON object with the following fields: + - result: 'BREAKING', 'POTENTIALLY_BREAKING', 'POTENTIALLY_NON_BREAKING' or 'NON_BREAKING'. + - changedApis: List of changed APIs. `); process.exitCode = 0; return;