@capgo/cli 4.10.22 โ†’ 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.22",
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",
@@ -51,7 +51,13 @@ export function findUnknownVersion(supabase: SupabaseClient<Database>, appId: st
51
51
  .eq('app_id', appId)
52
52
  .eq('name', 'unknown')
53
53
  .throwOnError()
54
- .single().then(({ data }) => data)
54
+ .single().then(({ data, error }) => {
55
+ if (error) {
56
+ p.log.error(`Cannot call findUnknownVersion as it returned an error.\n${formatError(error)}`)
57
+ program.error('')
58
+ }
59
+ return data
60
+ })
55
61
  }
56
62
 
57
63
  export function createChannel(supabase: SupabaseClient<Database>, update: Database['public']['Tables']['channels']['Insert']) {
@@ -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)}`)
@@ -4,7 +4,7 @@ import * as p from '@clack/prompts'
4
4
  import { checkAppExistsAndHasPermissionOrgErr } from '../api/app'
5
5
  import { createChannel, findUnknownVersion } from '../api/channels'
6
6
  import type { OptionsBase } from '../utils'
7
- import { OrganizationPerm, createSupabaseClient, findSavedKey, getConfig, getOrganizationId, useLogSnag, verifyUser } from '../utils'
7
+ import { OrganizationPerm, createSupabaseClient, findSavedKey, formatError, getConfig, getOrganizationId, useLogSnag, verifyUser } from '../utils'
8
8
 
9
9
  interface Options extends OptionsBase {
10
10
  default?: boolean
@@ -39,12 +39,18 @@ export async function addChannel(channelId: string, appId: string, options: Opti
39
39
  p.log.error(`Cannot find default version for channel creation, please contact Capgo support ๐Ÿคจ`)
40
40
  program.error('')
41
41
  }
42
- await createChannel(supabase, {
42
+ const res = await createChannel(supabase, {
43
43
  name: channelId,
44
44
  app_id: appId,
45
45
  version: data.id,
46
46
  owner_org: orgId,
47
47
  })
48
+
49
+ if (res.error) {
50
+ p.log.error(`Cannot create Channel ๐Ÿ™€\n${formatError(res.error)}`)
51
+ program.error('')
52
+ }
53
+
48
54
  p.log.success(`Channel created โœ…`)
49
55
  await snag.track({
50
56
  channel: 'channel',
package/src/init.ts CHANGED
@@ -51,7 +51,7 @@ async function step2(organization: Organization, snag: LogSnag, appId: string, o
51
51
  s.stop(`App add Done โœ…`)
52
52
  }
53
53
  else {
54
- p.log.info(`Run yourself "${pm.runner} @capgo/cli@latest app add ${appId}"`)
54
+ p.log.info(`If you change your mind, run it for yourself with: "${pm.runner} @capgo/cli@latest app add ${appId}"`)
55
55
  }
56
56
  await markStep(organization.gid, snag, 2)
57
57
  }
@@ -74,7 +74,7 @@ async function step3(orgId: string, snag: LogSnag, apikey: string, appId: string
74
74
  s.stop(`Channel add Done โœ…`)
75
75
  }
76
76
  else {
77
- p.log.info(`Run yourself "${pm.runner} @capgo/cli@latest channel add ${defaultChannel} ${appId} --default"`)
77
+ p.log.info(`If you change your mind, run it for yourself with: "${pm.runner} @capgo/cli@latest channel add ${defaultChannel} ${appId} --default"`)
78
78
  }
79
79
  await markStep(orgId, snag, 3)
80
80
  }
@@ -126,7 +126,7 @@ async function step4(orgId: string, snag: LogSnag, apikey: string, appId: string
126
126
  }
127
127
  }
128
128
  else {
129
- p.log.info(`Run yourself "${pm.installCommand} @capgo/capacitor-updater@latest"`)
129
+ p.log.info(`If you change your mind, run it for yourself with: "${pm.installCommand} @capgo/capacitor-updater@latest"`)
130
130
  }
131
131
  await markStep(orgId, snag, 4)
132
132
  }
@@ -277,7 +277,7 @@ async function step9(orgId: string, snag: LogSnag) {
277
277
  s.stop(`Started Done โœ…`)
278
278
  }
279
279
  else {
280
- p.log.info(`Run yourself with command: ${pm.runner} cap run <ios|android>`)
280
+ p.log.info(`If you change your mind, run it for yourself with: ${pm.runner} cap run <ios|android>`)
281
281
  }
282
282
  await markStep(orgId, snag, 9)
283
283
  }
package/src/key.ts CHANGED
@@ -76,8 +76,8 @@ export async function createKey(options: Options, log = true) {
76
76
 
77
77
  // check if baseName already exist
78
78
  if (existsSync(baseKeyPub) && !options.force) {
79
+ p.log.error('Public Key already exists, use --force to overwrite')
79
80
  if (log) {
80
- p.log.error('Public Key already exists, use --force to overwrite')
81
81
  program.error('')
82
82
  }
83
83
  else {
@@ -86,8 +86,8 @@ export async function createKey(options: Options, log = true) {
86
86
  }
87
87
  writeFileSync(baseKeyPub, publicKey)
88
88
  if (existsSync(baseKey) && !options.force) {
89
+ p.log.error('Private Key already exists, use --force to overwrite')
89
90
  if (log) {
90
- p.log.error('Private Key already exists, use --force to overwrite')
91
91
  program.error('')
92
92
  }
93
93
  else {
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 = {