mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
0a3ca80af4
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/34694 TL;DR Relax the assumption of having git to build the RN NPM package. We do have two CI Systems: CircleCI for OpenSource and Sandcastle for Internal. It's crucial that the two CIs are aligned. We currently don't have a way to test the new app template on Sandcastle for Android & iOS. This results in scenarios where internal Diffs gets landed and break the public CI externally. This is preparation work to then be able to build the RN NPM package in Sandcastle (which will be done in a follow-up diff). With this we also introduce the restoring of all the changed files after the publishing script is done. ## Changelog [Internal] [Added] - Made it possible to create publishing NPM packages in Sandcastle. Reviewed By: cortinico, cipolleschi Differential Revision: D39467471 fbshipit-source-id: b0de88a768b8a2fb798dd684fa8f97f4d0acb751
119 lines
3.6 KiB
JavaScript
119 lines
3.6 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
const {parseVersion, isReleaseBranch} = require('../version-utils');
|
|
|
|
let execResult = null;
|
|
jest.mock('shelljs', () => ({
|
|
exec: () => {
|
|
return {
|
|
stdout: execResult,
|
|
};
|
|
},
|
|
echo: message => {
|
|
console.log(message);
|
|
},
|
|
exit: exitCode => {
|
|
exit(exitCode);
|
|
},
|
|
}));
|
|
|
|
describe('version-utils', () => {
|
|
describe('isReleaseBranch', () => {
|
|
it('should identify as release branch', () => {
|
|
expect(isReleaseBranch('v0.66-stable')).toBe(true);
|
|
expect(isReleaseBranch('0.66-stable')).toBe(true);
|
|
expect(isReleaseBranch('made-up-stuff-stable')).toBe(true);
|
|
});
|
|
it('should not identify as release branch', () => {
|
|
expect(isReleaseBranch('main')).toBe(false);
|
|
expect(isReleaseBranch('pull/32659')).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('parseVersion', () => {
|
|
it('should throw error if invalid match', () => {
|
|
function testInvalidVersion() {
|
|
parseVersion('<invalid version>');
|
|
}
|
|
expect(testInvalidVersion).toThrowErrorMatchingInlineSnapshot(
|
|
`"You must pass a correctly formatted version; couldn't parse <invalid version>"`,
|
|
);
|
|
});
|
|
|
|
it('should parse pre-release version with .', () => {
|
|
const {version, major, minor, patch, prerelease} =
|
|
parseVersion('0.66.0-rc.4');
|
|
expect(version).toBe('0.66.0-rc.4');
|
|
expect(major).toBe('0');
|
|
expect(minor).toBe('66');
|
|
expect(patch).toBe('0');
|
|
expect(prerelease).toBe('rc.4');
|
|
});
|
|
|
|
it('should parse pre-release version with -', () => {
|
|
const {version, major, minor, patch, prerelease} =
|
|
parseVersion('0.66.0-rc-4');
|
|
expect(version).toBe('0.66.0-rc-4');
|
|
expect(major).toBe('0');
|
|
expect(minor).toBe('66');
|
|
expect(patch).toBe('0');
|
|
expect(prerelease).toBe('rc-4');
|
|
});
|
|
|
|
it('should parse stable version', () => {
|
|
const {version, major, minor, patch, prerelease} = parseVersion('0.66.0');
|
|
expect(version).toBe('0.66.0');
|
|
expect(major).toBe('0');
|
|
expect(minor).toBe('66');
|
|
expect(patch).toBe('0');
|
|
expect(prerelease).toBeUndefined();
|
|
});
|
|
|
|
it('should parse pre-release version from tag', () => {
|
|
const {version, major, minor, patch, prerelease} =
|
|
parseVersion('v0.66.1-rc.4');
|
|
expect(version).toBe('0.66.1-rc.4');
|
|
expect(major).toBe('0');
|
|
expect(minor).toBe('66');
|
|
expect(patch).toBe('1');
|
|
expect(prerelease).toBe('rc.4');
|
|
});
|
|
|
|
it('should parse stable version from tag', () => {
|
|
const {version, major, minor, patch, prerelease} =
|
|
parseVersion('v0.66.0');
|
|
expect(version).toBe('0.66.0');
|
|
expect(major).toBe('0');
|
|
expect(minor).toBe('66');
|
|
expect(patch).toBe('0');
|
|
expect(prerelease).toBeUndefined();
|
|
});
|
|
|
|
it('should parse nightly fake version', () => {
|
|
const {version, major, minor, patch, prerelease} = parseVersion('0.0.0');
|
|
expect(version).toBe('0.0.0');
|
|
expect(major).toBe('0');
|
|
expect(minor).toBe('0');
|
|
expect(patch).toBe('0');
|
|
expect(prerelease).toBeUndefined();
|
|
});
|
|
|
|
it('should parse dryrun fake version', () => {
|
|
const {version, major, minor, patch, prerelease} =
|
|
parseVersion('1000.0.0');
|
|
expect(version).toBe('1000.0.0');
|
|
expect(major).toBe('1000');
|
|
expect(minor).toBe('0');
|
|
expect(patch).toBe('0');
|
|
expect(prerelease).toBeUndefined();
|
|
});
|
|
});
|
|
});
|