@capgo/cli 4.10.23 → 4.10.24-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
- "version": "4.10.23",
3
+ "version": "4.10.24-beta.1",
4
4
  "description": "A CLI to upload to capgo servers",
5
5
  "author": "github.com/riderx",
6
6
  "license": "Apache 2.0",
@@ -401,7 +401,7 @@ It will be also visible in your dashboard\n`)
401
401
  const endTime = performance.now()
402
402
  const uploadTime = ((endTime - startTime) / 1000).toFixed(2)
403
403
  spinner.stop(`Failed to upload bundle ( after ${uploadTime} seconds)`)
404
- p.log.error(`Cannot upload bundle ${formatError(errorUpload)}`)
404
+ p.log.error(`Cannot upload bundle ( try again with --multipart option) ${formatError(errorUpload)}`)
405
405
  if (errorUpload instanceof HTTPError) {
406
406
  const body = await errorUpload.response.text()
407
407
  p.log.error(`Response: ${formatError(body)}`)
package/src/utils.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { existsSync, readFileSync, readdirSync } from 'node:fs'
2
- import os, { homedir } from 'node:os'
3
- import { resolve } from 'node:path'
1
+ import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs'
2
+ import { homedir } from 'node:os'
3
+ import { join, relative, resolve, sep } from 'node:path'
4
4
  import process from 'node:process'
5
5
  import type { Buffer } from 'node:buffer'
6
6
  import { loadConfig } from '@capacitor/cli/dist/config'
@@ -16,7 +16,7 @@ import { findRootSync } from '@manypkg/find-root'
16
16
  import type { InstallCommand, PackageManagerRunner, PackageManagerType } from '@capgo/find-package-manager'
17
17
  import { findInstallCommand, findPackageManagerRunner, findPackageManagerType } from '@capgo/find-package-manager'
18
18
  import AdmZip from 'adm-zip'
19
- import isWsl from 'is-wsl'
19
+ // import isWsl from 'is-wsl'
20
20
  import type { Database } from './types/supabase.types'
21
21
 
22
22
  export const baseKey = '.capgo_key'
@@ -519,15 +519,45 @@ async function prepareMultipart(supabase: SupabaseClient<Database>, appId: strin
519
519
  }
520
520
 
521
521
  export function zipFile(filePath: string) {
522
- // if windows and not wsl then do error
523
- if (os.release().toLowerCase().includes('microsoft') && !isWsl) {
524
- p.log.error(`Windows powershell is not supported, please use WSL or a Linux distribution`)
525
- program.error('')
526
- }
527
522
  const zip = new AdmZip()
528
- zip.addLocalFolder(filePath)
523
+
524
+ // Helper function to recursively add files and folders to the ZIP archive
525
+ const addToZip = (folderPath: string, zipPath: string) => {
526
+ const items = readdirSync(folderPath)
527
+
528
+ for (const item of items) {
529
+ const itemPath = join(folderPath, item)
530
+ const stats = statSync(itemPath)
531
+
532
+ if (stats.isFile()) {
533
+ const fileContent = readFileSync(itemPath)
534
+ const relativePath = join(zipPath, item)
535
+ const posixPath = relativePath.split(sep).join('/')
536
+ zip.addFile(posixPath, fileContent)
537
+ }
538
+ else if (stats.isDirectory()) {
539
+ // Recursively add subdirectories and their contents to the ZIP archive
540
+ const subZipPath = join(zipPath, item)
541
+ addToZip(itemPath, subZipPath)
542
+ }
543
+ }
544
+ }
545
+
546
+ // Start adding files and folders to the ZIP archive
547
+ addToZip(filePath, '')
548
+
529
549
  return zip.toBuffer()
530
550
  }
551
+ // export function zipFile(filePath: string) {
552
+ // // if windows and not wsl then do error
553
+ // if (os.release().toLowerCase().includes('microsoft') && !isWsl) {
554
+ // p.log.error(`Windows powershell is not supported, please use WSL or a Linux distribution`)
555
+ // program.error('')
556
+ // }
557
+ // const zip = new AdmZip()
558
+ // zip.addLocalFolder(filePath)
559
+ // return zip.toBuffer()
560
+ // }
531
561
 
532
562
  async function finishMultipartDownload(key: string, uploadId: string, url: string, parts: any[]) {
533
563
  const metadata = {