@@ -16,6 +16,7 @@ import { usePluginAPI } from '@main/api'
1616import { setupConfig } from '@main/config'
1717import { resolve } from 'node:path'
1818import Squirrel from 'electron-squirrel-startup'
19+ import { fetchLatestRelease } from './main/releases'
1920
2021if ( is . dev ) {
2122 app . setPath ( 'userData' , app . getPath ( 'userData' ) + '-dev' )
@@ -79,9 +80,9 @@ function createWindow(): void {
7980 const position =
8081 externalDisplay && is . dev
8182 ? {
82- x : externalDisplay . bounds . x + 50 ,
83- y : externalDisplay . bounds . y + 50
84- }
83+ x : externalDisplay . bounds . x + 50 ,
84+ y : externalDisplay . bounds . y + 50
85+ }
8586 : { }
8687
8788 // Create the browser window.
@@ -170,13 +171,31 @@ app.whenReady().then(async () => {
170171 await handleProtocolUrl ( url )
171172 } )
172173
173- if ( ! is . dev ) {
174- autoUpdater . setFeedURL ( {
175- url : 'https://github.com/CynToolkit/pipelab/releases/latest/download' ,
176- headers : {
177- 'Cache-Control' : 'no-cache'
174+ if ( ! is . dev || process . env . APP_UPDATE_URL || process . env . PIPELAB_OVERRIDE_RELEASE ) {
175+ try {
176+ const latestRelease = await fetchLatestRelease ( '@pipelab/app' )
177+ if ( latestRelease ) {
178+ logger ( ) . info ( 'Found latest release:' , latestRelease . tag_name )
179+ logger ( ) . info ( 'Release API URL:' , latestRelease . url )
180+ } else {
181+ logger ( ) . info ( 'No specific release found, falling back to generic /latest/download' )
178182 }
179- } )
183+
184+ const feedUrl = latestRelease
185+ ? `https://github.com/CynToolkit/pipelab/releases/download/${ latestRelease . tag_name } `
186+ : 'https://github.com/CynToolkit/pipelab/releases/latest/download'
187+
188+ logger ( ) . info ( 'Setting auto-updater feed URL:' , feedUrl )
189+
190+ autoUpdater . setFeedURL ( {
191+ url : feedUrl ,
192+ headers : {
193+ 'Cache-Control' : 'no-cache'
194+ }
195+ } )
196+ } catch ( error ) {
197+ logger ( ) . error ( 'Failed to setup auto-updater:' , error )
198+ }
180199
181200 autoUpdater . on ( 'update-downloaded' , ( event , releaseNotes , releaseName ) => {
182201 api ?. execute ( 'update:set-status' , {
@@ -378,7 +397,8 @@ app.whenReady().then(async () => {
378397 mainWindow . show ( )
379398 mainWindow . maximize ( )
380399
381- if ( app . isPackaged ) {
400+ if ( app . isPackaged || process . env . APP_UPDATE_URL || process . env . PIPELAB_OVERRIDE_RELEASE ) {
401+ autoUpdater . checkForUpdates ( )
382402 setTimeout ( ( ) => {
383403 autoUpdater . checkForUpdates ( )
384404 console . log ( 'checkForUpdates' )
0 commit comments