diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 00631c22afd54b..a598ee7b69afe8 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -170,7 +170,7 @@ jobs: env: TERM: "dumb" GRADLE_OPTS: "-Dorg.gradle.daemon=false" - # By default we only build ARM64 to save time/resources. For release/nightlies/prealpha, we override this value to build all archs. + # By default we only build ARM64 to save time/resources. For release/nightlies, we override this value to build all archs. ORG_GRADLE_PROJECT_reactNativeArchitectures: "arm64-v8a" env: HERMES_WS_DIR: /tmp/hermes diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 48c243f01223da..d0fc186728b3dd 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -167,7 +167,7 @@ jobs: env: TERM: "dumb" GRADLE_OPTS: "-Dorg.gradle.daemon=false" - # By default we only build ARM64 to save time/resources. For release/nightlies/prealpha, we override this value to build all archs. + # By default we only build ARM64 to save time/resources. For release/nightlies, we override this value to build all archs. ORG_GRADLE_PROJECT_reactNativeArchitectures: "arm64-v8a" env: HERMES_WS_DIR: /tmp/hermes diff --git a/packages/react-native/scripts/hermes/hermes-utils.js b/packages/react-native/scripts/hermes/hermes-utils.js index 3a5aa8dcb3388f..eb831e74044f56 100644 --- a/packages/react-native/scripts/hermes/hermes-utils.js +++ b/packages/react-native/scripts/hermes/hermes-utils.js @@ -16,7 +16,7 @@ const os = require('os'); const path = require('path'); /*:: -type BuildType = 'dry-run' | 'release' | 'nightly' | 'prealpha'; +type BuildType = 'dry-run' | 'release' | 'nightly'; */ const SDKS_DIR = path.normalize(path.join(__dirname, '..', '..', 'sdks')); diff --git a/scripts/__tests__/npm-utils-test.js b/scripts/__tests__/npm-utils-test.js index 955b84eb068198..abf8b4d13ac0ac 100644 --- a/scripts/__tests__/npm-utils-test.js +++ b/scripts/__tests__/npm-utils-test.js @@ -75,18 +75,6 @@ describe('npm-utils', () => { process.env.GITHUB_REF_NAME = ''; }); - it('return the expected format for prealpha', () => { - const isoStringSpy = jest.spyOn(Date.prototype, 'toISOString'); - isoStringSpy.mockReturnValue('2023-10-04T15:43:55.123Z'); - getCurrentCommitMock.mockImplementation(() => 'abcd1234'); - - const returnedValue = getNpmInfo('prealpha'); - expect(returnedValue).toMatchObject({ - version: `0.0.0-prealpha-2023100415`, - tag: 'prealpha', - }); - }); - it('return the expected format for patch-prereleases', () => { const isoStringSpy = jest.spyOn(Date.prototype, 'toISOString'); isoStringSpy.mockReturnValue('2023-10-04T15:43:55.123Z'); diff --git a/scripts/npm-utils.js b/scripts/npm-utils.js index 104721376b29fb..4fa57f00afac41 100644 --- a/scripts/npm-utils.js +++ b/scripts/npm-utils.js @@ -21,7 +21,7 @@ const {exec} = require('shelljs'); /*:: import type { ExecOptsSync, ShellString } from 'shelljs'; -type BuildType = 'dry-run' | 'release' | 'nightly' | 'prealpha'; +type BuildType = 'dry-run' | 'release' | 'nightly'; type NpmInfo = { version: string, tag: ?string, @@ -70,24 +70,6 @@ function getNpmInfo(buildType /*: BuildType */) /*: NpmInfo */ { }; } - if (buildType === 'prealpha') { - const mainVersion = '0.0.0'; - // Date in the format of YYYYMMDDHH. - // This is a progressive int that can track subsequent - // releases and it is smaller of 2^32-1. - // It is unlikely that we can trigger two prealpha in less - // than an hour given that nightlies take ~ 1 hr to complete. - const dateIdentifier = new Date() - .toISOString() - .slice(0, -10) - .replace(/[-T:]/g, ''); - - return { - version: `${mainVersion}-prealpha-${dateIdentifier}`, - tag: 'prealpha', - }; - } - if (buildType === 'release') { let versionTag /*: string*/ = ''; if (process.env.CIRCLE_TAG != null && process.env.CIRCLE_TAG !== '') { diff --git a/scripts/release-testing/utils/testing-utils.js b/scripts/release-testing/utils/testing-utils.js index 9f29fe14cdaf51..5ad69c403802f3 100644 --- a/scripts/release-testing/utils/testing-utils.js +++ b/scripts/release-testing/utils/testing-utils.js @@ -29,7 +29,7 @@ const path = require('path'); const {cp, exec} = require('shelljs'); /*:: -type BuildType = 'dry-run' | 'release' | 'nightly' | 'prealpha'; +type BuildType = 'dry-run' | 'release' | 'nightly'; */ /* diff --git a/scripts/releases-ci/publish-npm.js b/scripts/releases-ci/publish-npm.js index f9eddcc1bd9e8f..950f7b148c63de 100755 --- a/scripts/releases-ci/publish-npm.js +++ b/scripts/releases-ci/publish-npm.js @@ -17,7 +17,6 @@ import type {BuildType} from '../releases/utils/version-utils'; const {REPO_ROOT} = require('../consts'); const {getNpmInfo, publishPackage} = require('../npm-utils'); -const {removeNewArchFlags} = require('../releases/remove-new-arch-flags'); const { updateReactNativeArtifacts, } = require('../releases/set-rn-artifacts-version'); @@ -57,7 +56,7 @@ async function main() { .option('t', { alias: 'builtType', describe: 'The type of build you want to perform.', - choices: ['dry-run', 'nightly', 'release', 'prealpha'], + choices: ['dry-run', 'nightly', 'release'], default: 'dry-run', }) .strict().argv; @@ -96,12 +95,8 @@ async function publishMonorepoPackages(tag /*: ?string */) { async function publishNpm(buildType /*: BuildType */) /*: Promise */ { const {version, tag} = getNpmInfo(buildType); - if (buildType === 'prealpha') { - removeNewArchFlags(); - } - // For stable releases, CircleCI job `prepare_package_for_release` handles this - if (['dry-run', 'nightly', 'prealpha'].includes(buildType)) { + if (['dry-run', 'nightly'].includes(buildType)) { if (buildType === 'nightly') { // Set same version for all monorepo packages await setVersion(version); diff --git a/scripts/releases/__tests__/remove-new-arch-flags-test.js b/scripts/releases/__tests__/remove-new-arch-flags-test.js deleted file mode 100644 index 8497f6faf9ebfa..00000000000000 --- a/scripts/releases/__tests__/remove-new-arch-flags-test.js +++ /dev/null @@ -1,138 +0,0 @@ -/** - * 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 - * @oncall react-native - */ - -const {removeNewArchFlags} = require('../remove-new-arch-flags'); -const { - expectedGradlePropertiesFile, - expectedReactNativePodsFile, - invalidGradlePropertiesFile, - invalidReactNativePodsFile, - validGradlePropertiesFile, - validReactNativePodsFile, -} = require('./__fixtures__/remove-new-arch-flags-fixture'); -const fs = require('fs'); -const path = require('path'); - -describe('removeNewArchFlags', () => { - beforeEach(() => { - jest.resetAllMocks(); - }); - it('throws an exception if not run from react-native-github', async () => { - // Silence logs. - jest.spyOn(console, 'log').mockImplementation(() => {}); - - jest.spyOn(process, 'cwd').mockReturnValue('/path/to/react-native'); - expect(removeNewArchFlags).toThrow(); - }); - - it('it updates the required files', async () => { - const cwd = '/path/to/react-native-github'; - const reactNativePodsPath = - '/packages/react-native/scripts/react_native_pods.rb'; - const templateGradlePropertiesPath = - '/packages/helloworld/android/gradle.properties'; - jest.spyOn(process, 'cwd').mockReturnValue(cwd); - jest.spyOn(fs, 'readFileSync').mockImplementation(filename => { - if (filename === path.join(cwd, reactNativePodsPath)) { - return validReactNativePodsFile; - } else if (filename === path.join(cwd, templateGradlePropertiesPath)) { - return validGradlePropertiesFile; - } else { - throw new Error(`Unexpected call to fs.readFileSync(${filename}).`); - } - }); - let returnedReactNativePodsBackup = ''; - let returnedReactNativePods = ''; - let returnedGradlePropertiesBackup = ''; - let returnedGradleProperties = ''; - jest.spyOn(fs, 'writeFileSync').mockImplementation((filename, content) => { - if (filename === path.join(cwd, `${reactNativePodsPath}.bak`)) { - returnedReactNativePodsBackup = content; - } else if (filename === path.join(cwd, reactNativePodsPath)) { - returnedReactNativePods = content; - } else if ( - filename === path.join(cwd, `${templateGradlePropertiesPath}.bak`) - ) { - returnedGradlePropertiesBackup = content; - } else if (filename === path.join(cwd, templateGradlePropertiesPath)) { - returnedGradleProperties = content; - } else { - throw new Error(`Unexpected call to fs.writeFileSync(${filename}).`); - } - }); - - let deletedFiles = []; - jest.spyOn(fs, 'unlinkSync').mockImplementation(filename => { - deletedFiles.push(filename); - }); - removeNewArchFlags(); - - expect(returnedReactNativePodsBackup).toEqual(validReactNativePodsFile); - expect(returnedReactNativePods).toEqual(expectedReactNativePodsFile); - expect(returnedGradlePropertiesBackup).toEqual(validGradlePropertiesFile); - expect(returnedGradleProperties).toEqual(expectedGradlePropertiesFile); - expect(deletedFiles).toEqual([ - path.join(cwd, `${reactNativePodsPath}.bak`), - path.join(cwd, `${templateGradlePropertiesPath}.bak`), - ]); - }); - - it('does not update the required files if they are not valid', async () => { - const cwd = '/path/to/react-native-github'; - const reactNativePodsPath = - '/packages/react-native/scripts/react_native_pods.rb'; - const templateGradlePropertiesPath = - '/packages/helloworld/android/gradle.properties'; - jest.spyOn(process, 'cwd').mockReturnValue(cwd); - jest.spyOn(fs, 'readFileSync').mockImplementation(filename => { - if (filename === path.join(cwd, reactNativePodsPath)) { - return invalidReactNativePodsFile; - } else if (filename === path.join(cwd, templateGradlePropertiesPath)) { - return invalidGradlePropertiesFile; - } else { - throw new Error(`Unexpected call to fs.readFileSync(${filename}).`); - } - }); - let returnedReactNativePodsBackup = ''; - let returnedReactNativePods = ''; - let returnedGradlePropertiesBackup = ''; - let returnedGradleProperties = ''; - jest.spyOn(fs, 'writeFileSync').mockImplementation((filename, content) => { - if (filename === path.join(cwd, `${reactNativePodsPath}.bak`)) { - returnedReactNativePodsBackup = content; - } else if (filename === path.join(cwd, reactNativePodsPath)) { - returnedReactNativePods = content; - } else if ( - filename === path.join(cwd, `${templateGradlePropertiesPath}.bak`) - ) { - returnedGradlePropertiesBackup = content; - } else if (filename === path.join(cwd, templateGradlePropertiesPath)) { - returnedGradleProperties = content; - } else { - throw new Error(`Unexpected call to fs.writeFileSync(${filename}).`); - } - }); - - let deletedFiles = []; - jest.spyOn(fs, 'unlinkSync').mockImplementation(filename => { - deletedFiles.push(filename); - }); - removeNewArchFlags(); - - expect(returnedReactNativePodsBackup).toEqual(invalidReactNativePodsFile); - expect(returnedReactNativePods).toEqual(invalidReactNativePodsFile); - expect(returnedGradlePropertiesBackup).toEqual(invalidGradlePropertiesFile); - expect(returnedGradleProperties).toEqual(invalidGradlePropertiesFile); - expect(deletedFiles).toEqual([ - path.join(cwd, `${reactNativePodsPath}.bak`), - path.join(cwd, `${templateGradlePropertiesPath}.bak`), - ]); - }); -}); diff --git a/scripts/releases/remove-new-arch-flags.js b/scripts/releases/remove-new-arch-flags.js deleted file mode 100644 index 86a2eb3d62e58f..00000000000000 --- a/scripts/releases/remove-new-arch-flags.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * 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. - * - * @flow strict-local - * @format - * @oncall react-native - */ - -'use strict'; - -const fs = require('fs'); -const path = require('path'); - -function removeNewArchFlags() { - console.log('Removing new arch flags'); - const cwd = getValidCwd(); - - const iosBackups = removeFlagsForiOS(cwd); - - const androidBackups = flipNewArchFlagForAndroid(cwd); - - iosBackups.concat(androidBackups).forEach(file => { - fs.unlinkSync(file); - }); -} - -// === Helpers === -function getValidCwd() /*: string*/ { - const cwd = process.cwd(); - - if (!cwd.endsWith('react-native-github')) { - throw new Error( - `Please call this script from react-native root folder. Current path: ${cwd}`, - ); - } - return cwd; -} - -function replaceContentsOfFile( - contentToBeReplaced /*: string | RegExp*/, - replacement /*: string*/, - filepath /*: string*/, -) /*: string*/ { - const content = fs.readFileSync(filepath, 'utf8'); - - const backupPath = `${filepath}.bak`; - fs.writeFileSync(backupPath, content, 'utf8'); - let newContent = content.replaceAll(contentToBeReplaced, replacement); - fs.writeFileSync(filepath, newContent, 'utf8'); - return backupPath; -} - -function removeContentsFromFile( - contentToBeRemoved /*: string | RegExp*/, - filepath /*: string*/, -) /*: string*/ { - return replaceContentsOfFile(contentToBeRemoved, '', filepath); -} - -function removeFlagsForiOS(cwd /*: string*/) /*: $ReadOnlyArray*/ { - let backupPath /*: Array*/ = []; - const iosPath = path.join( - cwd, - '/packages/react-native/scripts/react_native_pods.rb', - ); - backupPath.push( - removeContentsFromFile( - / {2}fabric_enabled: false,\n {2}new_arch_enabled: NewArchitectureHelper.new_arch_enabled,\n/g, - iosPath, - ), - ); - return backupPath; -} - -function newArchEnabledGradleProps(boolValue /*: boolean*/) /*: string */ { - return `newArchEnabled=${boolValue.toString()}`; -} - -function flipNewArchFlagForAndroid( - cwd /*: string */, -) /*: $ReadOnlyArray*/ { - let backupPath /*: Array */ = []; - - // Gradle.properties - const gradlePropertiesPath = path.join( - cwd, - '/packages/helloworld/android/gradle.properties', - ); - backupPath.push( - replaceContentsOfFile( - new RegExp(newArchEnabledGradleProps(false), 'g'), - newArchEnabledGradleProps(true), - gradlePropertiesPath, - ), - ); - - return backupPath; -} -// =============== - -module.exports = { - removeNewArchFlags, -}; - -if (require.main === module) { - removeNewArchFlags(); -} diff --git a/scripts/releases/set-rn-artifacts-version.js b/scripts/releases/set-rn-artifacts-version.js index 8a551d720b75ea..78b52dc88c6f55 100755 --- a/scripts/releases/set-rn-artifacts-version.js +++ b/scripts/releases/set-rn-artifacts-version.js @@ -56,7 +56,7 @@ async function main() { the given release version. This does not update package.json. Options: - --build-type One of ['dry-run', 'nightly', 'release', 'prealpha']. + --build-type One of ['dry-run', 'nightly', 'release']. --to-version The new version string. `); return; diff --git a/scripts/releases/utils/__tests__/version-utils-test.js b/scripts/releases/utils/__tests__/version-utils-test.js index c20328206a44a7..39ed14681fd5a1 100644 --- a/scripts/releases/utils/__tests__/version-utils-test.js +++ b/scripts/releases/utils/__tests__/version-utils-test.js @@ -42,7 +42,7 @@ describe('version-utils', () => { }); describe('parseVersion', () => { - it('should throw error if buildType is not `release`, `dry-run`, `prealpha`` or `nightly`', () => { + it('should throw error if buildType is not `release`, `dry-run` or `nightly`', () => { function testInvalidVersion() { // $FlowExpectedError[incompatible-call] parseVersion('v0.10.5', 'invalid_build_type'); @@ -305,69 +305,6 @@ describe('version-utils', () => { expect(prerelease).toBeUndefined(); }); - it('should parse prealpha with valid value', () => { - const {version, major, minor, patch, prerelease} = parseVersion( - '0.0.0-prealpha-2023100416', - 'prealpha', - ); - - expect(version).toBe('0.0.0-prealpha-2023100416'); - expect(major).toBe('0'); - expect(minor).toBe('0'); - expect(patch).toBe('0'); - expect(prerelease).toBe('prealpha-2023100416'); - }); - - it('should reject prealpha with 1.0.0 version', () => { - function testInvalidFunction() { - parseVersion('1.0.0-prealpha-2023100416', 'prealpha'); - } - - expect(testInvalidFunction).toThrowErrorMatchingInlineSnapshot( - '"Version 1.0.0-prealpha-2023100416 is not valid for prealphas"', - ); - }); - - it('should reject prealpha with invalid version', () => { - function testInvalidFunction() { - parseVersion('1.2.3-prealpha-2023100416', 'prealpha'); - } - - expect(testInvalidFunction).toThrowErrorMatchingInlineSnapshot( - '"Version 1.2.3-prealpha-2023100416 is not valid for prealphas"', - ); - }); - - it('should reject prealpha with no prerelease', () => { - function testInvalidFunction() { - parseVersion('1.0.0', 'prealpha'); - } - - expect(testInvalidFunction).toThrowErrorMatchingInlineSnapshot( - '"Version 1.0.0 is not valid for prealphas"', - ); - }); - - it('should reject prealpha with invalid prerelease (no timestamp)', () => { - function testInvalidFunction() { - parseVersion('1.0.0-prealpha', 'prealpha'); - } - - expect(testInvalidFunction).toThrowErrorMatchingInlineSnapshot( - '"Version 1.0.0-prealpha is not valid for prealphas"', - ); - }); - - it('should reject prealpha with invalid prerelease (no prealpha)', () => { - function testInvalidFunction() { - parseVersion('1.0.0-2023100416', 'prealpha'); - } - - expect(testInvalidFunction).toThrowErrorMatchingInlineSnapshot( - '"Version 1.0.0-2023100416 is not valid for prealphas"', - ); - }); - it('should reject stable releases with major > 0', () => { expect(() => parseVersion('1.0.1', 'release')).toThrow( 'Version 1.0.1 is not valid for Release', diff --git a/scripts/releases/utils/release-utils.js b/scripts/releases/utils/release-utils.js index 912be2c456c0cb..9a6b5af20fb4eb 100644 --- a/scripts/releases/utils/release-utils.js +++ b/scripts/releases/utils/release-utils.js @@ -17,7 +17,7 @@ const { const {echo, exec, exit, popd, pushd, test} = require('shelljs'); /*:: -type BuildType = 'dry-run' | 'release' | 'nightly' | 'prealpha'; +type BuildType = 'dry-run' | 'release' | 'nightly'; */ function generateAndroidArtifacts(releaseVersion /*: string */) { @@ -105,7 +105,7 @@ function publishExternalArtifactsToMaven( exit(1); } } else { - const isSnapshot = buildType === 'nightly' || buildType === 'prealpha'; + const isSnapshot = buildType === 'nightly'; // -------- For nightly releases, we only need to publish the snapshot to Sonatype snapshot repo. if ( exec( diff --git a/scripts/releases/utils/version-utils.js b/scripts/releases/utils/version-utils.js index 5c0962aad11239..1163fde7fa0085 100644 --- a/scripts/releases/utils/version-utils.js +++ b/scripts/releases/utils/version-utils.js @@ -12,7 +12,7 @@ const VERSION_REGEX = /^v?((\d+)\.(\d+)\.(\d+)(?:-(.+))?)$/; /*:: -export type BuildType = 'dry-run' | 'release' | 'nightly' | 'prealpha'; +export type BuildType = 'dry-run' | 'release' | 'nightly'; export type Version = { version: string, major: string, @@ -33,7 +33,6 @@ export type Version = { * - e2e-test: X.Y.Z-20221116-2018 * - nightly: X.Y.Z-20221116-0bc4547fc * - dryrun: 1000.0.0 - * - prealpha: 0.0.0-prealpha-20221116 */ function parseVersion( versionStr /*: string */, @@ -64,12 +63,7 @@ function validateBuildType( buildType /*: string */, // $FlowFixMe[incompatible-type-guard] ) /*: buildType is BuildType */ { - const validBuildTypes = new Set([ - 'release', - 'dry-run', - 'nightly', - 'prealpha', - ]); + const validBuildTypes = new Set(['release', 'dry-run', 'nightly']); // $FlowFixMe[incompatible-return] return validBuildTypes.has(buildType); @@ -93,7 +87,6 @@ function validateVersion( release: validateRelease, 'dry-run': validateDryRun, nightly: validateNightly, - prealpha: validatePrealpha, }; const validationFunction = map[buildType]; @@ -128,12 +121,6 @@ function validateNightly(version /*: Version */) { } } -function validatePrealpha(version /*: Version */) { - if (!isValidPrealpha(version)) { - throw new Error(`Version ${version.version} is not valid for prealphas`); - } -} - function isStableRelease(version /*: Version */) /*: boolean */ { return ( version.major === '0' && @@ -173,16 +160,6 @@ function isReleaseBranch(branch /*:string */) /*: boolean */ { return branch.endsWith('-stable'); } -function isValidPrealpha(version /*: Version */) /*: boolean */ { - return !!( - version.major === '0' && - version.minor === '0' && - version.patch === '0' && - version.prerelease != null && - version.prerelease.match(/^prealpha-(\d{10})$/) - ); -} - module.exports = { validateBuildType, parseVersion,