Skip to content
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
14 changes: 1 addition & 13 deletions jest/setupUnitTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@
* @flow
*/

jest.mock('@react-native-community/cli-tools', () => ({
...jest.requireActual('@react-native-community/cli-tools'),
logger: {
success: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
debug: jest.fn(),
log: jest.fn(),
setVerbose: jest.fn(),
isVerbose: jest.fn(),
},
}));
jest.mock('@react-native-community/cli-tools');

jest.setTimeout(20000);
7 changes: 4 additions & 3 deletions packages/cli/src/commands/upgrade/__tests__/upgrade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jest.mock('../../../tools/fetch', () => ({
fetch: jest.fn(() => Promise.resolve('patch')),
}));
jest.mock('@react-native-community/cli-tools', () => ({
...jest.requireActual('@react-native-community/cli-tools'),
logger: {
info: jest.fn((...args) => mockPushLog('info', args)),
error: jest.fn((...args) => mockPushLog('error', args)),
Expand Down Expand Up @@ -187,7 +188,7 @@ test('fetches regular patch, adds remote, applies patch, installs deps, removes
"info Fetching diff between v0.57.8 and v0.58.4...
[fs] write tmp-upgrade-rn.patch
$ execa git rev-parse --show-prefix
$ execa git apply --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory=
$ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory=
info Applying diff...
$ execa git apply tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory=
[fs] unlink tmp-upgrade-rn.patch
Expand Down Expand Up @@ -219,7 +220,7 @@ test('fetches regular patch, adds remote, applies patch, installs deps, removes
"info Fetching diff between v0.57.8 and v0.58.4...
[fs] write tmp-upgrade-rn.patch
$ execa git rev-parse --show-prefix
$ execa git apply --check tmp-upgrade-rn.patch --exclude=NestedApp/package.json -p2 --3way --directory=NestedApp/
$ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=NestedApp/package.json -p2 --3way --directory=NestedApp/
info Applying diff...
$ execa git apply tmp-upgrade-rn.patch --exclude=NestedApp/package.json -p2 --3way --directory=NestedApp/
[fs] unlink tmp-upgrade-rn.patch
Expand Down Expand Up @@ -266,7 +267,7 @@ test('cleans up if patching fails,', async () => {
"info Fetching diff between v0.57.8 and v0.58.4...
[fs] write tmp-upgrade-rn.patch
$ execa git rev-parse --show-prefix
$ execa git apply --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory=
$ execa git apply --binary --check tmp-upgrade-rn.patch --exclude=package.json -p2 --3way --directory=
info Applying diff (excluding: package.json, .flowconfig)...
$ execa git apply tmp-upgrade-rn.patch --exclude=package.json --exclude=.flowconfig -p2 --3way --directory=
error: .flowconfig: does not exist in index
Expand Down
8 changes: 6 additions & 2 deletions packages/cli/src/commands/upgrade/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import chalk from 'chalk';
import semver from 'semver';
import execa from 'execa';
import type {ConfigT} from 'types';
import {logger} from '@react-native-community/cli-tools';
import {logger, CLIError} from '@react-native-community/cli-tools';
import * as PackageManager from '../../tools/packageManager';
import {fetch} from '../../tools/fetch';
import legacyUpgrade from './legacyUpgrade';
Expand Down Expand Up @@ -179,6 +179,10 @@ const applyPatch = async (
);
await execa('git', [
'apply',
// According to git documentation, `--binary` flag is turned on by
// default. However it's necessary when running `git apply --check` to
// actually accept binary files, maybe a bug in git?
'--binary',
'--check',
tmpPatchFile,
...excludes,
Expand Down Expand Up @@ -307,7 +311,7 @@ async function upgrade(argv: Array<string>, ctx: ConfigT, args: FlagsT) {
`${rnDiffPurgeRawDiffsUrl}/${currentVersion}..${newVersion}.diff`,
)}`);

throw new Error(
throw new CLIError(
'Upgrade failed. Please see the messages above for details',
);
}
Expand Down