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

[1.x] fix(em): prevent major updater for pre-releases #4131

Merged
merged 1 commit into from
Nov 30, 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
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;
}
}
Loading