@@ -86,7 +86,7 @@ const performInstallation = async (args, isUpdate = false) => {
8686 source ,
8787 platformInfo ,
8888 capabilities ,
89- log
89+ log ,
9090 ) ;
9191 selected = smartResult . selected ;
9292 releaseInfo = smartResult . releaseInfo ;
@@ -96,7 +96,7 @@ const performInstallation = async (args, isUpdate = false) => {
9696 source ,
9797 platformInfo ,
9898 capabilities ,
99- log
99+ log ,
100100 ) ;
101101 selected = websiteResult . selected ;
102102 releaseInfo = websiteResult . releaseInfo ;
@@ -106,7 +106,7 @@ const performInstallation = async (args, isUpdate = false) => {
106106 source ,
107107 platformInfo ,
108108 capabilities ,
109- log
109+ log ,
110110 ) ;
111111 selected = result . selected ;
112112 releaseInfo = result . releaseInfo ;
@@ -119,8 +119,8 @@ const performInstallation = async (args, isUpdate = false) => {
119119
120120 const shouldInstall = await confirm (
121121 `Ok to ${ isUpdate ? "update" : "install" } ${ selected . name } (${ fileSize (
122- selected . size
123- ) } )?`
122+ selected . size ,
123+ ) } )?`,
124124 ) ;
125125
126126 if ( ! shouldInstall ) {
@@ -131,7 +131,7 @@ const performInstallation = async (args, isUpdate = false) => {
131131 const installationResult = await installSelected (
132132 selected ,
133133 downloadPath ,
134- log
134+ log ,
135135 ) ;
136136
137137 if ( ! isUpdate ) {
@@ -152,8 +152,9 @@ const performInstallation = async (args, isUpdate = false) => {
152152 }
153153
154154 log . log (
155- `Successfully ${ isUpdate ? "updated" : "installed"
156- } : ${ installationResult . binaries . join ( ", " ) } `
155+ `Successfully ${
156+ isUpdate ? "updated" : "installed"
157+ } : ${ installationResult . binaries . join ( ", " ) } `,
157158 ) ;
158159 } finally {
159160 cleanup ( ) ;
@@ -185,7 +186,7 @@ const handleUrlSource = async (source, log) => {
185186 const { filename, size } = await downloadFromUrl (
186187 source . url ,
187188 tempFilename ,
188- log
189+ log ,
189190 ) ;
190191
191192 log . debug ( `Downloaded ${ filename } to ${ path . resolve ( tempFilename ) } ` ) ;
@@ -203,7 +204,7 @@ const handleSmartUrlSource = async (
203204 source ,
204205 platformInfo ,
205206 capabilities ,
206- log
207+ log ,
207208) => {
208209 log . debug ( `Attempting smart download from: ${ source . url } ` ) ;
209210
@@ -237,8 +238,9 @@ const handleSmartUrlSource = async (
237238 log . debug ( "Assets found:" ) ;
238239 result . assets . forEach ( ( asset , index ) => {
239240 log . debug (
240- ` ${ index + 1 } . ${ asset . name } (ext: ${ asset . extension || "none"
241- } , url: ${ asset . browser_download_url } )`
241+ ` ${ index + 1 } . ${ asset . name } (ext: ${
242+ asset . extension || "none"
243+ } , url: ${ asset . browser_download_url } )`,
242244 ) ;
243245 } ) ;
244246 }
@@ -251,14 +253,15 @@ const handleSmartUrlSource = async (
251253 log . log ( "No compatible assets found. Available downloads:" ) ;
252254 result . assets . forEach ( ( asset , index ) => {
253255 log . log (
254- ` ${ index + 1 } . ${ asset . name } (${ asset . extension || "no extension"
255- } ) - ${ asset . browser_download_url } `
256+ ` ${ index + 1 } . ${ asset . name } (${
257+ asset . extension || "no extension"
258+ } ) - ${ asset . browser_download_url } `,
256259 ) ;
257260 } ) ;
258261
259262 throw new Error (
260263 `Couldn't find a compatible download for ${ platformInfo . platform } /${ platformInfo . arch } . ` +
261- `Check manually: ${ source . url } `
264+ `Check manually: ${ source . url } ` ,
262265 ) ;
263266 }
264267
@@ -284,8 +287,9 @@ const handleWebsiteSource = async (source, platformInfo, capabilities, log) => {
284287 log . debug ( "Assets found:" ) ;
285288 assets . forEach ( ( asset , index ) => {
286289 log . debug (
287- ` ${ index + 1 } . ${ asset . name } (ext: ${ asset . extension || "none"
288- } , url: ${ asset . browser_download_url } )`
290+ ` ${ index + 1 } . ${ asset . name } (ext: ${
291+ asset . extension || "none"
292+ } , url: ${ asset . browser_download_url } )`,
289293 ) ;
290294 } ) ;
291295 }
@@ -298,14 +302,15 @@ const handleWebsiteSource = async (source, platformInfo, capabilities, log) => {
298302 log . log ( "No compatible assets found. Available downloads:" ) ;
299303 assets . forEach ( ( asset , index ) => {
300304 log . log (
301- ` ${ index + 1 } . ${ asset . name } (${ asset . extension || "no extension"
302- } ) - ${ asset . browser_download_url } `
305+ ` ${ index + 1 } . ${ asset . name } (${
306+ asset . extension || "no extension"
307+ } ) - ${ asset . browser_download_url } `,
303308 ) ;
304309 } ) ;
305310
306311 throw new Error (
307312 `Couldn't find a compatible download for ${ platformInfo . platform } /${ platformInfo . arch } . ` +
308- `Check manually: ${ source . url } `
313+ `Check manually: ${ source . url } ` ,
309314 ) ;
310315 }
311316
@@ -321,16 +326,16 @@ const displayScriptPreview = (script, log) => {
321326 const { code, source, score } = script ;
322327 log . log (
323328 `Found installer code in ${ source } (score: ${ score } ):\n\n` +
324- colors . fg . green +
325- code +
326- colors . reset +
327- "\n"
329+ colors . fg . green +
330+ code +
331+ colors . reset +
332+ "\n" ,
328333 ) ;
329334} ;
330335
331336const truncatePreview = (
332337 text ,
333- maxLength = SCRIPT_PREVIEW_CONFIG . MAX_LENGTH
338+ maxLength = SCRIPT_PREVIEW_CONFIG . MAX_LENGTH ,
334339) => {
335340 if ( text . length <= maxLength ) return text ;
336341 return text . substring ( 0 , SCRIPT_PREVIEW_CONFIG . truncateLength ) + "..." ;
@@ -343,7 +348,7 @@ const displayScriptList = (installScripts, log) => {
343348 const firstLine = script . code . split ( "\n" ) [ 0 ] ?. trim ( ) || "" ;
344349 const preview = truncatePreview ( firstLine ) ;
345350 log . log (
346- ` ${ index + 1 } . [Score: ${ script . score } ] ${ script . source } : ${ preview } `
351+ ` ${ index + 1 } . [Score: ${ script . score } ] ${ script . source } : ${ preview } ` ,
347352 ) ;
348353 } ) ;
349354
@@ -358,7 +363,7 @@ const handleSingleScript = async (script, log) => {
358363 displayScriptPreview ( script , log ) ;
359364
360365 const shouldRun = await confirm (
361- "Run install script (y) or continue to regular installation (n)?"
366+ "Run install script (y) or continue to regular installation (n)?" ,
362367 ) ;
363368
364369 return shouldRun ? script : null ;
@@ -373,15 +378,15 @@ const handleMultipleScripts = async (installScripts, log) => {
373378
374379 const choice = await promptChoice (
375380 `Preview install script (1-${ EXIT_OPTION } ): ` ,
376- EXIT_OPTION
381+ EXIT_OPTION ,
377382 ) ;
378383
379384 if ( choice <= installScripts . length ) {
380385 const script = installScripts [ choice - 1 ] ;
381386 displayScriptPreview ( script , log ) ;
382387
383388 const shouldRun = await confirm (
384- "Run this install script (y) or choose a different one (n)?"
389+ "Run this install script (y) or choose a different one (n)?" ,
385390 ) ;
386391
387392 if ( shouldRun ) return script ;
@@ -411,25 +416,43 @@ const executeInstallScript = (script, log) => {
411416} ;
412417
413418const handleGitHubSource = async ( source , platformInfo , capabilities , log ) => {
414- const { assets, body, tag, commit, prerelease } = await getGitHubAssets (
415- source . owner ,
416- source . repo ,
417- source . specificTag
418- ) ;
419+ let assets = [ ] ;
420+ let body = "" ;
421+ let tag = null ;
422+ let commit = null ;
423+ let prerelease = false ;
424+
425+ try {
426+ const releaseData = await getGitHubAssets (
427+ source . owner ,
428+ source . repo ,
429+ source . specificTag ,
430+ ) ;
431+ assets = releaseData . assets ;
432+ body = releaseData . body ;
433+ tag = releaseData . tag ;
434+ commit = releaseData . commit ;
435+ prerelease = releaseData . prerelease ;
436+ } catch ( error ) {
437+ if ( ! error . message . includes ( "No releases found in GitHub repository" ) ) {
438+ throw error ; // Re-throw if it's not a "no releases" error
439+ }
440+ log . debug ( "No releases found, checking for install scripts in README" ) ;
441+ }
419442
420443 log . debug ( `Found ${ assets . length } assets` ) ;
421444
422445 if ( prerelease ) {
423446 log . warn ( `Using prerelease version: ${ tag } ` ) ;
424- } else {
447+ } else if ( tag ) {
425448 log . debug ( `Using stable release: ${ tag } ` ) ;
426449 }
427450
428451 // Check for install scripts first
429452 const installScripts = await findInstallScripts (
430453 source . owner ,
431454 source . repo ,
432- body
455+ body ,
433456 ) ;
434457
435458 // Check for installer.sh in assets
@@ -442,7 +465,7 @@ const handleGitHubSource = async (source, platformInfo, capabilities, log) => {
442465 const { size } = await downloadFromUrl (
443466 installerScript . browser_download_url ,
444467 scriptPath ,
445- log
468+ log ,
446469 ) ;
447470 execSync ( `chmod +x ${ JSON . stringify ( scriptPath ) } ` ) ;
448471 execSync ( scriptPath , { stdio : "inherit" } ) ;
@@ -472,7 +495,7 @@ const handleGitHubSource = async (source, platformInfo, capabilities, log) => {
472495 log . debug ( `No suitable asset found, using install scripts as fallback` ) ;
473496 } else {
474497 log . debug (
475- `Found high priority install script, using it instead of asset`
498+ `Found high priority install script, using it instead of asset` ,
476499 ) ;
477500 }
478501 log . debug ( `Found ${ installScripts . length } install script(s)` ) ;
@@ -492,7 +515,7 @@ const handleGitHubSource = async (source, platformInfo, capabilities, log) => {
492515 version : tag ,
493516 commit : commit ,
494517 prerelease : prerelease ,
495- }
518+ } ,
496519 ) ;
497520 addInstallation ( installRecord ) ;
498521
@@ -502,9 +525,15 @@ const handleGitHubSource = async (source, platformInfo, capabilities, log) => {
502525
503526 // If no install scripts were used and no suitable asset found, throw error
504527 if ( ! selected ) {
528+ // If we have no assets but we have install scripts, that's not an error
529+ if ( assets . length === 0 && installScripts . length > 0 ) {
530+ throw new Error (
531+ `No releases found, but install scripts are available. This shouldn't happen - check the install script logic.` ,
532+ ) ;
533+ }
505534 throw new Error (
506535 `Couldn't find a compatible binary for ${ platformInfo . platform } /${ platformInfo . arch } . ` +
507- `Check manually: https://github.com/${ source . owner } /${ source . repo } /releases`
536+ `Check manually: https://github.com/${ source . owner } /${ source . repo } /releases` ,
508537 ) ;
509538 }
510539
@@ -553,7 +582,7 @@ const installSelected = async (selected, downloadPath, log) => {
553582 mountDMG ( downloadPath , outputDir , log ) ;
554583 const dmgBinaries = getBinaries ( outputDir ) ;
555584 log . debug (
556- `Found ${ dmgBinaries . length } items in DMG: ${ dmgBinaries . join ( ", " ) } `
585+ `Found ${ dmgBinaries . length } items in DMG: ${ dmgBinaries . join ( ", " ) } ` ,
557586 ) ;
558587
559588 const appFile = dmgBinaries . find ( ( f ) => f . endsWith ( ".app" ) ) ;
@@ -575,15 +604,15 @@ const installSelected = async (selected, downloadPath, log) => {
575604 } else if ( dmgBinaries . length > 0 ) {
576605 // Handle DMGs with executables but no .app or .pkg
577606 log . log (
578- "No .app or .pkg found in DMG, trying to install executables"
607+ "No .app or .pkg found in DMG, trying to install executables" ,
579608 ) ;
580609 destinations = await installBinaries (
581610 dmgBinaries ,
582611 outputDir ,
583612 selected . name ,
584613 checkPath ,
585614 log ,
586- true // isMountedVolume = true
615+ true , // isMountedVolume = true
587616 ) ;
588617 binariesList = dmgBinaries . map ( ( bin ) => path . basename ( bin ) ) ;
589618 } else {
@@ -607,7 +636,7 @@ const installSelected = async (selected, downloadPath, log) => {
607636 selected . name ,
608637 path . dirname ( downloadPath ) ,
609638 checkPath ,
610- log
639+ log ,
611640 ) ;
612641 binariesList = [ selected . name ] ;
613642 // Ask to open app
@@ -644,7 +673,7 @@ const installSelected = async (selected, downloadPath, log) => {
644673 outputDir ,
645674 selected . name ,
646675 checkPath ,
647- log
676+ log ,
648677 ) ;
649678
650679 if ( packageResult ) {
@@ -665,7 +694,7 @@ const installSelected = async (selected, downloadPath, log) => {
665694 outputDir ,
666695 selected . name ,
667696 checkPath ,
668- log
697+ log ,
669698 ) ;
670699 binariesList = extractedBinaries . map ( ( bin ) => path . basename ( bin ) ) ;
671700 }
0 commit comments