using Umbraco.Cms.Core; using Umbraco.Cms.Core.Services; namespace Umbraco.Extensions; public static class RuntimeStateExtensions { /// /// Returns true if the installer is enabled based on the current runtime state /// /// /// public static bool EnableInstaller(this IRuntimeState state) => state.Level == RuntimeLevel.Install || state.Level == RuntimeLevel.Upgrade; // TODO: If we want to enable the installer for package migrations, but IMO i think we should do migrations in the back office // if they are not unattended. // => state.Level == RuntimeLevel.Install || state.Level == RuntimeLevel.Upgrade || state.Level == RuntimeLevel.PackageMigrations; /// /// Returns true if Umbraco is greater than /// public static bool UmbracoCanBoot(this IRuntimeState state) => state.Level > RuntimeLevel.BootFailed; /// /// Returns true if the runtime state indicates that unattended boot logic should execute /// /// /// public static bool RunUnattendedBootLogic(this IRuntimeState state) => (state.Reason == RuntimeLevelReason.UpgradeMigrations || state.Reason == RuntimeLevelReason.UpgradePackageMigrations) && state.Level == RuntimeLevel.Run; }