Add support for release channels (insider release channel) in Updater

This commit is contained in:
Darko Gjorgjijoski
2024-08-04 03:04:10 +02:00
parent bcb89bc9ae
commit 9a46f892ab
5 changed files with 39 additions and 16 deletions

View File

@@ -10,14 +10,21 @@ class AppVersionController extends Controller
/** /**
* Handle the incoming request. * Handle the incoming request.
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function __invoke(Request $request) public function __invoke(Request $request)
{ {
$version = Setting::getSetting('version'); $version = Setting::getSetting('version');
$channel = Setting::getSetting('updater_channel');
if (is_null($channel)) {
$channel = 'stable';
Setting::setSetting('updater_channel', 'stable'); // default.
}
return response()->json([ return response()->json([
'version' => $version, 'version' => $version,
'channel' => $channel,
]); ]);
} }
} }

View File

@@ -25,8 +25,9 @@ class CheckVersionController extends Controller
set_time_limit(600); // 10 minutes set_time_limit(600); // 10 minutes
$json = Updater::checkForUpdate(Setting::getSetting('version')); $channel = $request->get('channel', 'stable');
$response = Updater::checkForUpdate(Setting::getSetting('version'), $channel);
return response()->json($json); return response()->json($response);
} }
} }

View File

@@ -14,19 +14,19 @@ class Updater
{ {
use SiteApi; use SiteApi;
public static function checkForUpdate($installed_version) public static function checkForUpdate($installed_version, $updater_channel = 'stable')
{ {
$data = null; $data = null;
$url = 'releases/update-check/'.$installed_version; $url = sprintf('releases/update-check/%s?channel=%s', $installed_version, $updater_channel);
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]); $response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]);
$data = (object) ['success' => false, 'release' => null];
if ($response && ($response->getStatusCode() == 200)) { if ($response && ($response->getStatusCode() == 200)) {
$data = $response->getBody()->getContents(); $data = $response->getBody()->getContents();
$data = json_decode($data);
} }
$data = json_decode($data);
if ($data->success && $data->release && property_exists($data->release, 'extensions')) { if ($data->success && $data->release && property_exists($data->release, 'extensions')) {
$extensions = []; $extensions = [];
foreach ($data->release->extensions as $extension) { foreach ($data->release->extensions as $extension) {

View File

@@ -1272,6 +1272,7 @@
"title": "Update App", "title": "Update App",
"description": "You can easily update InvoiceShelf by checking for a new update by clicking the button below", "description": "You can easily update InvoiceShelf by checking for a new update by clicking the button below",
"check_update": "Check for updates", "check_update": "Check for updates",
"insider_consent" : "Opt-in for Insider releases. Recommended for testing purposes only.",
"avail_update": "New Update available", "avail_update": "New Update available",
"next_version": "Next version", "next_version": "Next version",
"requirements": "Requirements", "requirements": "Requirements",

View File

@@ -8,11 +8,12 @@
{{ $t('settings.update_app.current_version') }} {{ $t('settings.update_app.current_version') }}
</label> </label>
<div <div class="w-full border-b-2 border-gray-100 border-solid pb-4">
class=" <div
class="
box-border box-border
flex inline-block
w-16 w-auto
p-3 p-3
my-2 my-2
text-sm text-gray-600 text-sm text-gray-600
@@ -21,8 +22,13 @@
rounded-md rounded-md
version version
" "
> >
{{ currentVersion }} {{ currentVersion }}
</div>
</div>
<div class="w-full pt-4">
<BaseCheckbox v-model="insiderChannel" :label="$t('settings.update_app.insider_consent')"/>
</div> </div>
<BaseButton <BaseButton
@@ -71,8 +77,8 @@
<div <div
class=" class="
box-border box-border
flex inline-block
w-16 w-auto
p-3 p-3
my-2 my-2
text-sm text-gray-600 text-sm text-gray-600
@@ -204,6 +210,7 @@ import { handleError } from '@/scripts/helpers/error-handling'
import { useCompanyStore } from '@/scripts/admin/stores/company' import { useCompanyStore } from '@/scripts/admin/stores/company'
import { useExchangeRateStore } from '@/scripts/admin/stores/exchange-rate' import { useExchangeRateStore } from '@/scripts/admin/stores/exchange-rate'
import { useDialogStore } from '@/scripts/stores/dialog' import { useDialogStore } from '@/scripts/stores/dialog'
import BaseCheckbox from "@/scripts/components/base/BaseCheckbox.vue";
const notificationStore = useNotificationStore() const notificationStore = useNotificationStore()
const dialogStore = useDialogStore() const dialogStore = useDialogStore()
@@ -216,6 +223,7 @@ let isCheckingforUpdate = ref(false)
let description = ref('') let description = ref('')
let changelog = ref(''); let changelog = ref('');
let currentVersion = ref('') let currentVersion = ref('')
let insiderChannel = ref('')
let requiredExtentions = ref(null) let requiredExtentions = ref(null)
let deletedFiles = ref(null) let deletedFiles = ref(null)
let isUpdating = ref(false) let isUpdating = ref(false)
@@ -283,6 +291,7 @@ window.addEventListener('beforeunload', (event) => {
axios.get('/api/v1/app/version').then((res) => { axios.get('/api/v1/app/version').then((res) => {
currentVersion.value = res.data.version currentVersion.value = res.data.version
insiderChannel.value = res.data.channel === 'insider'
}) })
// comapnyStore // comapnyStore
@@ -323,7 +332,11 @@ function statusClass(step) {
async function checkUpdate() { async function checkUpdate() {
try { try {
isCheckingforUpdate.value = true isCheckingforUpdate.value = true
let response = await axios.get('/api/v1/check/update') let response = await axios.get('/api/v1/check/update', {
params: {
channel: insiderChannel ? 'insider' : ''
}
});
isCheckingforUpdate.value = false isCheckingforUpdate.value = false
if (!response.data.release) { if (!response.data.release) {
notificationStore.showNotification({ notificationStore.showNotification({
@@ -342,6 +355,7 @@ async function checkUpdate() {
requiredExtentions.value = response.data.release.extensions requiredExtentions.value = response.data.release.extensions
isUpdateAvailable.value = true isUpdateAvailable.value = true
minPhpVesrion.value = response.data.release.min_php_version minPhpVesrion.value = response.data.release.min_php_version
deletedFiles.value = response.data.release.deleted_files
} }
} catch (e) { } catch (e) {
isUpdateAvailable.value = false isUpdateAvailable.value = false