mirror of
https://github.com/facebook/react-native.git
synced 2024-11-21 22:10:14 +00:00
Delete validation in set-rn-version (#37814)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37814 Changelog: [Internal] - deleting file validation, do we need this? Reviewed By: NickGerleman Differential Revision: D46584771 fbshipit-source-id: 69a8853872b2b1582318a2e65d9919e2b50b2475
This commit is contained in:
parent
31eb235a6a
commit
be348528e6
@ -7,7 +7,6 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
const execMock = jest.fn();
|
||||
const echoMock = jest.fn();
|
||||
const catMock = jest.fn();
|
||||
const sedMock = jest.fn();
|
||||
@ -16,23 +15,15 @@ const updateTemplatePackageMock = jest.fn();
|
||||
|
||||
jest
|
||||
.mock('shelljs', () => ({
|
||||
exec: execMock,
|
||||
echo: echoMock,
|
||||
cat: catMock,
|
||||
sed: sedMock,
|
||||
}))
|
||||
.mock('./../update-template-package', () => updateTemplatePackageMock)
|
||||
.mock('./../scm-utils', () => ({
|
||||
saveFiles: jest.fn(),
|
||||
}))
|
||||
.mock('path', () => ({
|
||||
join: () => '../packages/react-native',
|
||||
}))
|
||||
.mock('fs', () => ({
|
||||
writeFileSync: writeFileSyncMock,
|
||||
mkdtempSync: () => './rn-set-version/',
|
||||
}))
|
||||
.mock('os');
|
||||
}));
|
||||
|
||||
const setReactNativeVersion = require('../set-rn-version');
|
||||
|
||||
@ -58,7 +49,6 @@ describe('set-rn-version', () => {
|
||||
}
|
||||
});
|
||||
|
||||
execMock.mockReturnValueOnce({stdout: 'line1\nline2\nline3\n'});
|
||||
sedMock.mockReturnValueOnce({code: 0});
|
||||
|
||||
const version = '0.81.0-nightly-29282302-abcd1234';
|
||||
@ -115,7 +105,6 @@ describe('set-rn-version', () => {
|
||||
return 'exports.version = {major: ${major}, minor: ${minor}, patch: ${patch}, prerelease: ${prerelease}}';
|
||||
});
|
||||
|
||||
execMock.mockReturnValueOnce({stdout: 'line1\nline2\nline3\n'});
|
||||
sedMock.mockReturnValueOnce({code: 0});
|
||||
|
||||
const version = '0.81.0';
|
||||
@ -144,38 +133,5 @@ describe('set-rn-version', () => {
|
||||
expect(updateTemplatePackageMock).toHaveBeenCalledWith({
|
||||
'react-native': version,
|
||||
});
|
||||
expect(execMock.mock.calls[0][0]).toBe(
|
||||
`diff -r ./rn-set-version/ . | grep '^[>]' | grep -c ${version} `,
|
||||
);
|
||||
});
|
||||
|
||||
it('should fail validation', () => {
|
||||
catMock.mockReturnValue('{}');
|
||||
|
||||
execMock.mockReturnValueOnce({stdout: 'line1\nline2\n'});
|
||||
sedMock.mockReturnValueOnce({code: 0});
|
||||
const filesToValidate = [
|
||||
'packages/react-native/package.json',
|
||||
'packages/react-native/template/package.json',
|
||||
];
|
||||
|
||||
const version = '0.81.0';
|
||||
setReactNativeVersion(version, null, 'release');
|
||||
|
||||
expect(echoMock).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'The tmp versioning folder is ./rn-set-version/',
|
||||
);
|
||||
|
||||
expect(echoMock).toHaveBeenNthCalledWith(2, 'WARNING:');
|
||||
|
||||
expect(echoMock.mock.calls[2][0]).toBe(
|
||||
`Failed to update all the files: [${filesToValidate.join(
|
||||
', ',
|
||||
)}] must have versions in them`,
|
||||
);
|
||||
expect(echoMock.mock.calls[3][0]).toBe(
|
||||
`These files already had version ${version} set.`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -10,12 +10,9 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const {cat, echo, exec, exit, sed} = require('shelljs');
|
||||
const {cat, echo, exit, sed} = require('shelljs');
|
||||
const yargs = require('yargs');
|
||||
const {parseVersion, validateBuildType} = require('./version-utils');
|
||||
const {saveFiles} = require('./scm-utils');
|
||||
const updateTemplatePackage = require('./update-template-package');
|
||||
const {applyPackageVersions} = require('./npm-utils');
|
||||
|
||||
@ -152,23 +149,6 @@ function setReactNativeVersion(argVersion, dependencyVersions, buildType) {
|
||||
|
||||
const version = parseVersion(argVersion, buildType);
|
||||
|
||||
// Create tmp folder for copies of files to verify files have changed
|
||||
const filesToValidate = [
|
||||
'packages/react-native/package.json',
|
||||
'packages/react-native/template/package.json',
|
||||
];
|
||||
const tmpVersioningFolder = fs.mkdtempSync(
|
||||
path.join(os.tmpdir(), 'rn-set-version'),
|
||||
);
|
||||
echo(`The tmp versioning folder is ${tmpVersioningFolder}`);
|
||||
saveFiles(
|
||||
[
|
||||
'packages/react-native/package.json',
|
||||
'packages/react-native/template/package.json',
|
||||
],
|
||||
tmpVersioningFolder,
|
||||
);
|
||||
|
||||
setSource(version);
|
||||
setPackage(version, dependencyVersions);
|
||||
|
||||
@ -179,28 +159,6 @@ function setReactNativeVersion(argVersion, dependencyVersions, buildType) {
|
||||
updateTemplatePackage(templateDependencyVersions);
|
||||
|
||||
setGradle(version);
|
||||
|
||||
// Validate changes
|
||||
// We just do a git diff and check how many times version is added across files
|
||||
const numberOfChangedLinesWithNewVersion = exec(
|
||||
`diff -r ${tmpVersioningFolder} . | grep '^[>]' | grep -c ${version.version} `,
|
||||
{silent: true},
|
||||
).stdout.trim();
|
||||
|
||||
if (+numberOfChangedLinesWithNewVersion !== filesToValidate.length) {
|
||||
// TODO: the logic that checks whether all the changes have been applied
|
||||
// is missing several files. For example, it is not checking Ruby version nor that
|
||||
// the Objecive-C files, the codegen and other files are properly updated.
|
||||
// We are going to work on this in another PR.
|
||||
echo('WARNING:');
|
||||
echo(
|
||||
`Failed to update all the files: [${filesToValidate.join(
|
||||
', ',
|
||||
)}] must have versions in them`,
|
||||
);
|
||||
echo(`These files already had version ${version.version} set.`);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user