From 54c125ab68a950fd4276a22f6ce2e332f005341b Mon Sep 17 00:00:00 2001 From: DiegoAndai Date: Tue, 10 Sep 2024 16:28:08 -0300 Subject: [PATCH] Remove preReleaseLabel and preReleaseNumber in favor of prerelease --- babel.config.js | 3 +-- packages/mui-material/src/index.test.js | 11 +++-------- packages/mui-material/src/version/index.ts | 3 +-- packages/mui-system/src/version/index.ts | 3 +-- scripts/utils.mjs | 6 ++---- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/babel.config.js b/babel.config.js index c6910c0afa717e..cbadb0c6a75a97 100644 --- a/babel.config.js +++ b/babel.config.js @@ -110,8 +110,7 @@ module.exports = function getBabelConfig(api) { 'MUI_MAJOR_VERSION', 'MUI_MINOR_VERSION', 'MUI_PATCH_VERSION', - 'MUI_PRERELEASE_LABEL', - 'MUI_PRERELEASE_NUMBER', + 'MUI_PRERELEASE', ], }, ], diff --git a/packages/mui-material/src/index.test.js b/packages/mui-material/src/index.test.js index f015581099d04e..ba50fa794efd6d 100644 --- a/packages/mui-material/src/index.test.js +++ b/packages/mui-material/src/index.test.js @@ -6,14 +6,9 @@ import { expect } from 'chai'; import * as MaterialUI from './index'; -const versionExports = [ - 'version', - 'major', - 'minor', - 'patch', - 'preReleaseLabel', - 'preReleaseNumber', -]; +// To skip them in the undefined exports test +// These are checked in the build process (scripts/build.mjs) +const versionExports = ['version', 'major', 'minor', 'patch', 'prerelease']; describe('material-ui', () => { it('should have exports', () => { diff --git a/packages/mui-material/src/version/index.ts b/packages/mui-material/src/version/index.ts index 8e49930afb8039..b981d5f140d4a3 100644 --- a/packages/mui-material/src/version/index.ts +++ b/packages/mui-material/src/version/index.ts @@ -2,7 +2,6 @@ export const version = process.env.MUI_VERSION; export const major = Number(process.env.MUI_MAJOR_VERSION); export const minor = Number(process.env.MUI_MINOR_VERSION); export const patch = Number(process.env.MUI_PATCH_VERSION); -export const preReleaseLabel = process.env.MUI_PRERELEASE_LABEL || null; -export const preReleaseNumber = Number(process.env.MUI_PRERELEASE_NUMBER) || null; +export const prerelease = process.env.MUI_PRERELEASE; export default version; diff --git a/packages/mui-system/src/version/index.ts b/packages/mui-system/src/version/index.ts index 8e49930afb8039..b981d5f140d4a3 100644 --- a/packages/mui-system/src/version/index.ts +++ b/packages/mui-system/src/version/index.ts @@ -2,7 +2,6 @@ export const version = process.env.MUI_VERSION; export const major = Number(process.env.MUI_MAJOR_VERSION); export const minor = Number(process.env.MUI_MINOR_VERSION); export const patch = Number(process.env.MUI_PATCH_VERSION); -export const preReleaseLabel = process.env.MUI_PRERELEASE_LABEL || null; -export const preReleaseNumber = Number(process.env.MUI_PRERELEASE_NUMBER) || null; +export const prerelease = process.env.MUI_PRERELEASE; export default version; diff --git a/scripts/utils.mjs b/scripts/utils.mjs index 4f0f37d49cf825..d7bbbba3e73d37 100644 --- a/scripts/utils.mjs +++ b/scripts/utils.mjs @@ -23,9 +23,8 @@ export async function getVersionEnvVariables() { throw new Error('Could not find the version in the package.json'); } - const [versionNumber, preReleaseInfo] = version.split('-'); + const [versionNumber, prerelease] = version.split('-'); const [major, minor, patch] = versionNumber.split('.'); - const [preReleaseLabel, preReleaseNumber] = preReleaseInfo ? preReleaseInfo.split('.') : []; if (!major || !minor || !patch) { throw new Error(`Couldn't parse version from package.json`); @@ -36,7 +35,6 @@ export async function getVersionEnvVariables() { MUI_MAJOR_VERSION: major, MUI_MINOR_VERSION: minor, MUI_PATCH_VERSION: patch, - MUI_PRERELEASE_LABEL: preReleaseLabel, - MUI_PRERELEASE_NUMBER: preReleaseNumber, + MUI_PRERELEASE: prerelease, }; }