@capgo/cli 4.10.21 โ†’ 4.10.23

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.21",
3
+ "version": "4.10.23",
4
4
  "description": "A CLI to upload to capgo servers",
5
5
  "author": "github.com/riderx",
6
6
  "license": "Apache 2.0",
@@ -56,6 +56,7 @@
56
56
  "commander": "12.1.0",
57
57
  "console-table-printer": "^2.12.0",
58
58
  "get-latest-version": "^5.1.0",
59
+ "is-wsl": "^3.1.0",
59
60
  "ky": "^1.3.0",
60
61
  "logsnag": "1.0.0",
61
62
  "mime": "^4.0.3",
@@ -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']) {
@@ -3,7 +3,6 @@ import { existsSync, readFileSync } from 'node:fs'
3
3
  import process from 'node:process'
4
4
  import type { Buffer } from 'node:buffer'
5
5
  import { performance } from 'node:perf_hooks'
6
- import AdmZip from 'adm-zip'
7
6
  import { program } from 'commander'
8
7
  import * as p from '@clack/prompts'
9
8
  import { checksum as getChecksum } from '@tomasklaen/checksum'
@@ -43,6 +42,7 @@ import {
43
42
  uploadUrl,
44
43
  useLogSnag,
45
44
  verifyUser,
45
+ zipFile,
46
46
  } from '../utils'
47
47
  import { checkIndexPosition, searchInDirectory } from './check'
48
48
 
@@ -256,9 +256,7 @@ export async function uploadBundle(appid: string, options: Options, shouldExit =
256
256
  let checksum = ''
257
257
  let zipped: Buffer | null = null
258
258
  if (!external && useS3 === false) {
259
- const zip = new AdmZip()
260
- zip.addLocalFolder(path)
261
- zipped = zip.toBuffer()
259
+ zipped = zipFile(path)
262
260
  const s = p.spinner()
263
261
  s.start(`Calculating checksum`)
264
262
  checksum = await getChecksum(zipped, 'crc32')
@@ -331,9 +329,7 @@ It will be also visible in your dashboard\n`)
331
329
  }
332
330
  else {
333
331
  if (useS3) {
334
- const zip = new AdmZip()
335
- zip.addLocalFolder(path)
336
- zipped = zip.toBuffer()
332
+ zipped = zipFile(path)
337
333
  const s = p.spinner()
338
334
  s.start(`Calculating checksum`)
339
335
  checksum = await getChecksum(zipped, 'crc32')
package/src/bundle/zip.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { randomUUID } from 'node:crypto'
2
2
  import { writeFileSync } from 'node:fs'
3
3
  import process from 'node:process'
4
- import AdmZip from 'adm-zip'
5
4
  import { program } from 'commander'
6
5
  import * as p from '@clack/prompts'
7
6
  import { checksum as getChecksum } from '@tomasklaen/checksum'
@@ -14,6 +13,7 @@ import {
14
13
  getConfig,
15
14
  regexSemver,
16
15
  useLogSnag,
16
+ zipFile,
17
17
  } from '../utils'
18
18
  import { checkIndexPosition, searchInDirectory } from './check'
19
19
 
@@ -78,9 +78,7 @@ export async function zipBundle(appId: string, options: Options) {
78
78
  program.error('')
79
79
  }
80
80
  }
81
- const zip = new AdmZip()
82
- zip.addLocalFolder(path)
83
- const zipped = zip.toBuffer()
81
+ const zipped = zipFile(path)
84
82
  if (!json)
85
83
  p.log.info(`Zipped ${zipped.byteLength} bytes`)
86
84
  const s = p.spinner()
@@ -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/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { program } from 'commander'
2
- import { getUserId } from 'user/account'
3
2
  import pack from '../package.json'
3
+ import { getUserId } from './user/account'
4
4
  import { zipBundle } from './bundle/zip'
5
5
  import { initApp } from './init'
6
6
  import { listBundle } from './bundle/list'
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,5 +1,5 @@
1
1
  import { existsSync, readFileSync, readdirSync } from 'node:fs'
2
- import { homedir } from 'node:os'
2
+ import os, { homedir } from 'node:os'
3
3
  import { resolve } from 'node:path'
4
4
  import process from 'node:process'
5
5
  import type { Buffer } from 'node:buffer'
@@ -15,6 +15,8 @@ import { promiseFiles } from 'node-dir'
15
15
  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
+ import AdmZip from 'adm-zip'
19
+ import isWsl from 'is-wsl'
18
20
  import type { Database } from './types/supabase.types'
19
21
 
20
22
  export const baseKey = '.capgo_key'
@@ -516,6 +518,17 @@ async function prepareMultipart(supabase: SupabaseClient<Database>, appId: strin
516
518
  }
517
519
  }
518
520
 
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
+ const zip = new AdmZip()
528
+ zip.addLocalFolder(filePath)
529
+ return zip.toBuffer()
530
+ }
531
+
519
532
  async function finishMultipartDownload(key: string, uploadId: string, url: string, parts: any[]) {
520
533
  const metadata = {
521
534
  action: 'mpu-complete',