Skip to content

Commit

Permalink
fix(em): prevent major updater for pre-releases (#4131)
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 authored Nov 30, 2024
1 parent be27dab commit f26c50f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import MajorUpdater from './MajorUpdater';
import ExtensionItem from './ExtensionItem';
import { Extension } from 'flarum/admin/AdminApplication';
import ItemList from 'flarum/common/utils/ItemList';
import { isProductionReady } from '../utils/versions';

export interface IUpdaterAttrs extends ComponentAttrs {}

Expand All @@ -24,7 +25,7 @@ export default class Updater extends Component<IUpdaterAttrs> {
<div className="ExtensionManager-updaterControls">{this.controlItems().toArray()}</div>
{this.availableUpdatesView()}
</div>,
core && core.package['latest-major'] ? (
core && core.package['latest-major'] && isProductionReady(core.package['latest-major']) ? (
<MajorUpdater coreUpdate={core.package} updateState={app.extensionManager.control.lastUpdateRun.major} />
) : null,
];
Expand Down
32 changes: 32 additions & 0 deletions extensions/package-manager/js/src/admin/utils/versions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export enum VersionStability {
Stable = 'stable',
Alpha = 'alpha',
Beta = 'beta',
RC = 'rc',
Dev = 'dev',
}

export function isProductionReady(version: string): boolean {
return [VersionStability.Stable].includes(stability(version));
}

export function stability(version: string): VersionStability {
const split = version.split('-');

if (split.length === 1) {
return VersionStability.Stable;
}

const stab = split[1].split('.')[0].toLowerCase();

switch (stab) {
case 'alpha':
return VersionStability.Alpha;
case 'beta':
return VersionStability.Beta;
case 'rc':
return VersionStability.RC;
default:
return VersionStability.Dev;
}
}

0 comments on commit f26c50f

Please sign in to comment.