Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui][mui-system] Simplify version prerelease export #43699

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
},
],
Expand Down
11 changes: 3 additions & 8 deletions packages/mui-material/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-material/src/version/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 1 addition & 2 deletions packages/mui-system/src/version/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
6 changes: 2 additions & 4 deletions scripts/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand All @@ -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,
};
}
Loading