@@ -3,17 +3,17 @@ import {CommandModule} from "yargs";
33import { Octokit } from "octokit" ;
44import fs from "fs-extra" ;
55import chalk from "chalk" ;
6- import cliProgress from "cli-progress" ;
7- import simpleGit from "simple-git" ;
86import {
9- defaultLlamaCppCudaSupport , defaultLlamaCppGitHubRepo , defaultLlamaCppMetalSupport , defaultLlamaCppRelease , llamaCppDirectory
7+ defaultLlamaCppCudaSupport , defaultLlamaCppGitHubRepo , defaultLlamaCppMetalSupport , defaultLlamaCppRelease , isCI , llamaCppDirectory
108} from "../../config.js" ;
119import { compileLlamaCpp } from "../../utils/compileLLamaCpp.js" ;
1210import withOra from "../../utils/withOra.js" ;
1311import { clearTempFolder } from "../../utils/clearTempFolder.js" ;
1412import { setBinariesGithubRelease } from "../../utils/binariesGithubRelease.js" ;
1513import { downloadCmakeIfNeeded } from "../../utils/cmake.js" ;
1614import withStatusLogs from "../../utils/withStatusLogs.js" ;
15+ import { saveCurrentRepoAsReleaseBundle } from "../../utils/gitReleaseBundles.js" ;
16+ import { cloneLlamaCppRepo } from "../../utils/cloneLlamaCppRepo.js" ;
1717
1818type DownloadCommandArgs = {
1919 repo : string ,
@@ -23,7 +23,7 @@ type DownloadCommandArgs = {
2323 metal : boolean ,
2424 cuda : boolean ,
2525 skipBuild ?: boolean ,
26- updateBinariesReleaseMetadata ?: boolean
26+ updateBinariesReleaseMetadataAndSaveGitBundle ?: boolean
2727} ;
2828
2929export const DownloadCommand : CommandModule < object , DownloadCommandArgs > = {
@@ -68,7 +68,7 @@ export const DownloadCommand: CommandModule<object, DownloadCommandArgs> = {
6868 default : false ,
6969 description : "Skip building llama.cpp after downloading it"
7070 } )
71- . option ( "updateBinariesReleaseMetadata " , {
71+ . option ( "updateBinariesReleaseMetadataAndSaveGitBundle " , {
7272 type : "boolean" ,
7373 hidden : true , // this for the CI to use
7474 default : false ,
@@ -79,7 +79,7 @@ export const DownloadCommand: CommandModule<object, DownloadCommandArgs> = {
7979} ;
8080
8181export async function DownloadLlamaCppCommand ( {
82- repo, release, arch, nodeTarget, metal, cuda, skipBuild, updateBinariesReleaseMetadata
82+ repo, release, arch, nodeTarget, metal, cuda, skipBuild, updateBinariesReleaseMetadataAndSaveGitBundle
8383} : DownloadCommandArgs ) {
8484 const octokit = new Octokit ( ) ;
8585 const [ githubOwner , githubRepo ] = repo . split ( "/" ) ;
@@ -143,7 +143,7 @@ export async function DownloadLlamaCppCommand({
143143 } ) ;
144144
145145 console . log ( chalk . blue ( "Cloning llama.cpp" ) ) ;
146- await cloneTag ( githubOwner , githubRepo , githubRelease ! . data . tag_name , llamaCppDirectory ) ;
146+ await cloneLlamaCppRepo ( githubOwner , githubRepo , githubRelease ! . data . tag_name ) ;
147147
148148 if ( ! skipBuild ) {
149149 await downloadCmakeIfNeeded ( true ) ;
@@ -163,8 +163,9 @@ export async function DownloadLlamaCppCommand({
163163 } ) ;
164164 }
165165
166- if ( updateBinariesReleaseMetadata ) {
166+ if ( isCI && updateBinariesReleaseMetadataAndSaveGitBundle ) {
167167 await setBinariesGithubRelease ( githubRelease ! . data . tag_name ) ;
168+ await saveCurrentRepoAsReleaseBundle ( ) ;
168169 }
169170
170171 console . log ( ) ;
@@ -174,35 +175,3 @@ export async function DownloadLlamaCppCommand({
174175 console . log ( ) ;
175176 console . log ( chalk . green ( "Done" ) ) ;
176177}
177-
178-
179- async function cloneTag ( githubOwner : string , githubRepo : string , tag : string , directory : string ) {
180- const progressBar = new cliProgress . Bar ( {
181- clearOnComplete : false ,
182- hideCursor : true ,
183- autopadding : true ,
184- format : `${ chalk . bold ( "Clone {repo}" ) } ${ chalk . yellow ( "{percentage}%" ) } ${ chalk . cyan ( "{bar}" ) } ${ chalk . grey ( "{eta_formatted}" ) } `
185- } , cliProgress . Presets . shades_classic ) ;
186-
187- progressBar . start ( 100 , 0 , {
188- speed : "" ,
189- repo : `${ githubOwner } /${ githubRepo } `
190- } ) ;
191-
192- try {
193- await simpleGit ( {
194- progress ( { progress, total, processed} ) {
195- const totalProgress = ( processed / 100 ) + ( progress / total ) ;
196-
197- progressBar . update ( Math . floor ( totalProgress * 10000 ) / 100 ) ;
198- }
199- } ) . clone ( `https://github.com/${ githubOwner } /${ githubRepo } .git` , directory , {
200- "--depth" : 1 ,
201- "--branch" : tag ,
202- "--quiet" : null
203- } ) ;
204- } finally {
205- progressBar . update ( 100 ) ;
206- progressBar . stop ( ) ;
207- }
208- }
0 commit comments