From de5bccf0806f347bd31457f19c9b9c47de749649 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Thu, 16 Jan 2025 11:36:42 -0800 Subject: [PATCH] Cleanup prealpha logic from the JS Publishing Scripts (#48691) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48691 We don't intent to use the prealpha logic in the near future so it makes sense to remove it for to simplify our already complicated release process. We can always revive it if we wish. Changelog: [Internal] [Changed] - Reviewed By: cipolleschi Differential Revision: D68206014 fbshipit-source-id: f05eeae3997d52df1127852e03437a387a01f5ad --- .github/workflows/nightly.yml | 2 +- .github/workflows/publish-release.yml | 2 +- .../scripts/hermes/hermes-utils.js | 2 +- scripts/__tests__/npm-utils-test.js | 12 -- scripts/npm-utils.js | 20 +-- .../release-testing/utils/testing-utils.js | 2 +- .../releases-ci/__tests__/publish-npm-test.js | 22 --- scripts/releases-ci/publish-npm.js | 9 +- scripts/releases/README.md | 4 - .../__tests__/remove-new-arch-flags-test.js | 138 ------------------ scripts/releases/remove-new-arch-flags.js | 110 -------------- scripts/releases/set-rn-artifacts-version.js | 2 +- .../utils/__tests__/version-utils-test.js | 65 +-------- scripts/releases/utils/release-utils.js | 4 +- scripts/releases/utils/version-utils.js | 27 +--- 15 files changed, 13 insertions(+), 408 deletions(-) delete mode 100644 scripts/releases/__tests__/remove-new-arch-flags-test.js delete mode 100644 scripts/releases/remove-new-arch-flags.js diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 00631c22afd..a598ee7b69a 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 48c243f0122..d0fc186728b 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 3a5aa8dcb33..eb831e74044 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 955b84eb068..abf8b4d13ac 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 104721376b2..4fa57f00afa 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 9f29fe14cda..5ad69c40380 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/__tests__/publish-npm-test.js b/scripts/releases-ci/__tests__/publish-npm-test.js index 742547e844e..775d90e2872 100644 --- a/scripts/releases-ci/__tests__/publish-npm-test.js +++ b/scripts/releases-ci/__tests__/publish-npm-test.js @@ -16,7 +16,6 @@ const setVersionMock = jest.fn(); const updateReactNativeArtifactsMock = jest.fn(); const publishAndroidArtifactsToMavenMock = jest.fn(); const publishExternalArtifactsToMavenMock = jest.fn(); -const removeNewArchFlags = jest.fn(); const env = process.env; const publishPackageMock = jest.fn(); const getNpmInfoMock = jest.fn(); @@ -51,9 +50,6 @@ describe('publish-npm', () => { .mock('../../releases/set-rn-artifacts-version', () => ({ updateReactNativeArtifacts: updateReactNativeArtifactsMock, })) - .mock('../../releases/remove-new-arch-flags', () => ({ - removeNewArchFlags, - })) .mock('../../npm-utils', () => ({ ...jest.requireActual('../../npm-utils'), publishPackage: publishPackageMock, @@ -103,8 +99,6 @@ describe('publish-npm', () => { await publishNpm('dry-run'); - expect(removeNewArchFlags).not.toHaveBeenCalled(); - expect(setVersionMock).not.toBeCalled(); expect(updateReactNativeArtifactsMock).toBeCalledWith(version, 'dry-run'); @@ -159,9 +153,6 @@ describe('publish-npm', () => { await publishNpm('nightly'); - expect(removeNewArchFlags).not.toHaveBeenCalled(); - expect(setVersionMock).toBeCalledWith(expectedVersion); - // Generate Android artifacts is now delegate to build_android entirely expect(generateAndroidArtifactsMock).not.toHaveBeenCalled(); @@ -213,8 +204,6 @@ describe('publish-npm', () => { await publishNpm('nightly'); }).rejects.toThrow('something went wrong with setVersion'); - expect(removeNewArchFlags).not.toHaveBeenCalled(); - expect(publishPackageMock).not.toBeCalled(); expect(generateAndroidArtifactsMock).not.toHaveBeenCalled(); expect(publishAndroidArtifactsToMavenMock).not.toBeCalled(); expect(publishExternalArtifactsToMavenMock).not.toHaveBeenCalled(); @@ -259,9 +248,6 @@ describe('publish-npm', () => { `Failed to publish monorepo/pkg-b@${expectedVersion} to npm. Stopping all nightly publishes`, ); - expect(removeNewArchFlags).not.toHaveBeenCalled(); - expect(setVersionMock).toBeCalledWith(expectedVersion); - expect(generateAndroidArtifactsMock).not.toHaveBeenCalled(); // Note that we don't call `publishPackage` for react-native, or monorepo/pkg-c @@ -301,8 +287,6 @@ describe('publish-npm', () => { await publishNpm('release'); - expect(removeNewArchFlags).not.toHaveBeenCalled(); - expect(updateReactNativeArtifactsMock).not.toHaveBeenCalled(); expect(setVersionMock).not.toBeCalled(); // Generate Android artifacts is now delegate to build_android entirely @@ -343,8 +327,6 @@ describe('publish-npm', () => { await publishNpm('release'); - expect(removeNewArchFlags).not.toHaveBeenCalled(); - expect(setVersionMock).not.toBeCalled(); expect(updateReactNativeArtifactsMock).not.toBeCalled(); // Generate Android artifacts is now delegate to build_android entirely @@ -392,8 +374,6 @@ describe('publish-npm', () => { `Failed to publish react-native@${expectedVersion} to npm.`, ); - expect(removeNewArchFlags).not.toHaveBeenCalled(); - expect(setVersionMock).not.toBeCalled(); expect(updateReactNativeArtifactsMock).not.toHaveBeenCalled(); // Generate Android artifacts is now delegate to build_android entirely @@ -431,8 +411,6 @@ describe('publish-npm', () => { await publishNpm('release'); - expect(removeNewArchFlags).not.toHaveBeenCalled(); - expect(updateReactNativeArtifactsMock).not.toHaveBeenCalled(); expect(setVersionMock).not.toBeCalled(); // Generate Android artifacts is now delegate to build_android entirely diff --git a/scripts/releases-ci/publish-npm.js b/scripts/releases-ci/publish-npm.js index f9eddcc1bd9..950f7b148c6 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/README.md b/scripts/releases/README.md index 5a775727877..ef6c20658b1 100644 --- a/scripts/releases/README.md +++ b/scripts/releases/README.md @@ -10,10 +10,6 @@ For information on command arguments, run `node --help`. Creates a release commit to trigger a new release. -### `remove-new-arch-flags` - -Updates native build files to disable the New Architecture. - ### `set-version` Bump the version of all packages. 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 8497f6faf9e..00000000000 --- 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 86a2eb3d62e..00000000000 --- 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 8a551d720b7..78b52dc88c6 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 c20328206a4..39ed14681fd 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 912be2c456c..9a6b5af20fb 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 5c0962aad11..1163fde7fa0 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,