mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
fix: skip major updater if not ready for prod (#4080)
This commit is contained in:
parent
a5a1f6a9d2
commit
321020ab83
|
@ -130,7 +130,7 @@ export default class ExtensionCard<CustomAttrs extends IExtensionAttrs = IExtens
|
|||
);
|
||||
}
|
||||
|
||||
if (!extension.isStable()) {
|
||||
if (!extension.isProductionReady()) {
|
||||
items.add(
|
||||
'unstable',
|
||||
<Badge
|
||||
|
|
|
@ -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 {}
|
||||
|
||||
|
@ -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,
|
||||
];
|
||||
|
|
|
@ -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');
|
||||
|
@ -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 {
|
||||
|
|
32
extensions/package-manager/js/src/admin/utils/versions.ts
Normal file
32
extensions/package-manager/js/src/admin/utils/versions.ts
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user