From c2cd3c1789b27fb44bb736dc0151766df9944d68 Mon Sep 17 00:00:00 2001 From: WcaleNieWolny Date: Fri, 3 Jan 2025 18:35:03 +0100 Subject: [PATCH] feat: --tus-chunk-size --- src/bundle/upload.ts | 3 ++- src/index.ts | 1 + src/utils.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bundle/upload.ts b/src/bundle/upload.ts index 0e9254ae..f3114481 100644 --- a/src/bundle/upload.ts +++ b/src/bundle/upload.ts @@ -53,6 +53,7 @@ interface Options extends OptionsBase { packageJson?: string dryUpload?: boolean nodeModules?: string + tusChunkSize?: number } type SupabaseType = Awaited> @@ -369,7 +370,7 @@ async function uploadBundleToCapgoCloud(apikey: string, supabase: SupabaseType, else { log.info(`Uploading bundle with TUS protocol`) } - await uploadTUS(apikey, zipped, orgId, appid, bundle, spinner, localConfig) + await uploadTUS(apikey, zipped, orgId, appid, bundle, spinner, localConfig, options.tusChunkSize) isTus = true const filePath = `orgs/${orgId}/apps/${appid}/${bundle}.zip` const { error: changeError } = await supabase diff --git a/src/index.ts b/src/index.ts index d4e77d2e..18446e91 100644 --- a/src/index.ts +++ b/src/index.ts @@ -154,6 +154,7 @@ bundle .option('--timeout ', 'Timeout for the upload process in seconds') .option('--multipart', 'Uses multipart protocol to upload data to S3, Deprecated, use tus instead') .option('--tus', 'Upload the bundle using TUS to Capgo cloud') + .option('--tus-chunk-size ', 'Chunk size for the TUS upload') .option('--partial', 'Upload partial files to Capgo cloud') .option('--encrypted-checksum ', 'An encrypted checksum (signature). Used only when uploading an external bundle.') .option('--package-json ', 'A path to package.json. Usefull for monorepos') diff --git a/src/utils.ts b/src/utils.ts index 01f47873..8d98eaf5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -739,7 +739,7 @@ export async function zipFileWindows(filePath: string): Promise { return zip.toBuffer() } -export async function uploadTUS(apikey: string, data: Buffer, orgId: string, appId: string, name: string, spinner: ReturnType, localConfig: CapgoConfig): Promise { +export async function uploadTUS(apikey: string, data: Buffer, orgId: string, appId: string, name: string, spinner: ReturnType, localConfig: CapgoConfig, chunkSize?: number): Promise { return new Promise((resolve, reject) => { sendEvent(apikey, { channel: 'app', @@ -759,6 +759,7 @@ export async function uploadTUS(apikey: string, data: Buffer, orgId: string, app const upload = new tus.Upload(data as any, { endpoint: `${localConfig.hostFilesApi}/files/upload/attachments/`, // parallelUploads: multipart, + chunkSize: chunkSize || Number.POSITIVE_INFINITY, metadataForPartialUploads: { filename: `orgs/${orgId}/apps/${appId}/${name}.zip`, filetype: 'application/gzip',