Skip to content

Commit

Permalink
fix: skip major updater if not ready for prod (#4080)
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 authored Oct 19, 2024
1 parent a5a1f6a commit 321020a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default class ExtensionCard<CustomAttrs extends IExtensionAttrs = IExtens
);
}

if (!extension.isStable()) {
if (!extension.isProductionReady()) {
items.add(
'unstable',
<Badge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import MajorUpdater from './MajorUpdater';
import ItemList from 'flarum/common/utils/ItemList';
import InfoTile from 'flarum/common/components/InfoTile';
import ExtensionCard from './ExtensionCard';
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Model from 'flarum/common/Model';
import app from 'flarum/admin/app';
import type { Extension } from 'flarum/admin/AdminApplication';
import { isProductionReady } from '../utils/versions';

export default class ExternalExtension extends Model {
extensionId = Model.attribute<string>('extensionId');
Expand Down Expand Up @@ -36,16 +37,8 @@ export default class ExternalExtension extends Model {
return currentVersion.split('.')[0] === latestCompatibleVersion.split('.')[0];
}

public isStable(): boolean {
const split = this.highestVersion().split('-');

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

const stability = split[1].split('.');

return stability[0] === 'stable';
public isProductionReady(): boolean {
return isProductionReady(this.highestVersion());
}

public toLocalExtension(): Extension {
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, VersionStability.RC].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 321020a

Please sign in to comment.