@@ -3,17 +3,17 @@ import {CommandModule} from "yargs";
3
3
import { Octokit } from "octokit" ;
4
4
import fs from "fs-extra" ;
5
5
import chalk from "chalk" ;
6
- import cliProgress from "cli-progress" ;
7
- import simpleGit from "simple-git" ;
8
6
import {
9
- defaultLlamaCppCudaSupport , defaultLlamaCppGitHubRepo , defaultLlamaCppMetalSupport , defaultLlamaCppRelease , llamaCppDirectory
7
+ defaultLlamaCppCudaSupport , defaultLlamaCppGitHubRepo , defaultLlamaCppMetalSupport , defaultLlamaCppRelease , isCI , llamaCppDirectory
10
8
} from "../../config.js" ;
11
9
import { compileLlamaCpp } from "../../utils/compileLLamaCpp.js" ;
12
10
import withOra from "../../utils/withOra.js" ;
13
11
import { clearTempFolder } from "../../utils/clearTempFolder.js" ;
14
12
import { setBinariesGithubRelease } from "../../utils/binariesGithubRelease.js" ;
15
13
import { downloadCmakeIfNeeded } from "../../utils/cmake.js" ;
16
14
import withStatusLogs from "../../utils/withStatusLogs.js" ;
15
+ import { saveCurrentRepoAsReleaseBundle } from "../../utils/gitReleaseBundles.js" ;
16
+ import { cloneLlamaCppRepo } from "../../utils/cloneLlamaCppRepo.js" ;
17
17
18
18
type DownloadCommandArgs = {
19
19
repo : string ,
@@ -23,7 +23,7 @@ type DownloadCommandArgs = {
23
23
metal : boolean ,
24
24
cuda : boolean ,
25
25
skipBuild ?: boolean ,
26
- updateBinariesReleaseMetadata ?: boolean
26
+ updateBinariesReleaseMetadataAndSaveGitBundle ?: boolean
27
27
} ;
28
28
29
29
export const DownloadCommand : CommandModule < object , DownloadCommandArgs > = {
@@ -68,7 +68,7 @@ export const DownloadCommand: CommandModule<object, DownloadCommandArgs> = {
68
68
default : false ,
69
69
description : "Skip building llama.cpp after downloading it"
70
70
} )
71
- . option ( "updateBinariesReleaseMetadata " , {
71
+ . option ( "updateBinariesReleaseMetadataAndSaveGitBundle " , {
72
72
type : "boolean" ,
73
73
hidden : true , // this for the CI to use
74
74
default : false ,
@@ -79,7 +79,7 @@ export const DownloadCommand: CommandModule<object, DownloadCommandArgs> = {
79
79
} ;
80
80
81
81
export async function DownloadLlamaCppCommand ( {
82
- repo, release, arch, nodeTarget, metal, cuda, skipBuild, updateBinariesReleaseMetadata
82
+ repo, release, arch, nodeTarget, metal, cuda, skipBuild, updateBinariesReleaseMetadataAndSaveGitBundle
83
83
} : DownloadCommandArgs ) {
84
84
const octokit = new Octokit ( ) ;
85
85
const [ githubOwner , githubRepo ] = repo . split ( "/" ) ;
@@ -143,7 +143,7 @@ export async function DownloadLlamaCppCommand({
143
143
} ) ;
144
144
145
145
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 ) ;
147
147
148
148
if ( ! skipBuild ) {
149
149
await downloadCmakeIfNeeded ( true ) ;
@@ -163,8 +163,9 @@ export async function DownloadLlamaCppCommand({
163
163
} ) ;
164
164
}
165
165
166
- if ( updateBinariesReleaseMetadata ) {
166
+ if ( isCI && updateBinariesReleaseMetadataAndSaveGitBundle ) {
167
167
await setBinariesGithubRelease ( githubRelease ! . data . tag_name ) ;
168
+ await saveCurrentRepoAsReleaseBundle ( ) ;
168
169
}
169
170
170
171
console . log ( ) ;
@@ -174,35 +175,3 @@ export async function DownloadLlamaCppCommand({
174
175
console . log ( ) ;
175
176
console . log ( chalk . green ( "Done" ) ) ;
176
177
}
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