@capgo/cli 4.10.20 → 4.10.22
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/CHANGELOG.md +14 -0
- package/bun.lockb +0 -0
- package/dist/index.js +660 -661
- package/package.json +2 -1
- package/src/bundle/upload.ts +3 -15
- package/src/bundle/zip.ts +2 -4
- package/src/index.ts +1 -1
- package/src/utils.ts +14 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/cli",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.22",
|
|
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",
|
package/src/bundle/upload.ts
CHANGED
|
@@ -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
|
|
|
@@ -100,8 +100,6 @@ export async function uploadBundle(appid: string, options: Options, shouldExit =
|
|
|
100
100
|
channel = channel || 'dev'
|
|
101
101
|
|
|
102
102
|
const config = await getConfig()
|
|
103
|
-
const localS3: boolean = (config?.app?.extConfig?.plugins && config?.app?.extConfig?.plugins?.CapacitorUpdater
|
|
104
|
-
&& config?.app?.extConfig?.plugins?.CapacitorUpdater?.localS3) === true
|
|
105
103
|
|
|
106
104
|
const checkNotifyAppReady = options.codeCheck
|
|
107
105
|
appid = appid || config?.app?.appId
|
|
@@ -258,9 +256,7 @@ export async function uploadBundle(appid: string, options: Options, shouldExit =
|
|
|
258
256
|
let checksum = ''
|
|
259
257
|
let zipped: Buffer | null = null
|
|
260
258
|
if (!external && useS3 === false) {
|
|
261
|
-
|
|
262
|
-
zip.addLocalFolder(path)
|
|
263
|
-
zipped = zip.toBuffer()
|
|
259
|
+
zipped = zipFile(path)
|
|
264
260
|
const s = p.spinner()
|
|
265
261
|
s.start(`Calculating checksum`)
|
|
266
262
|
checksum = await getChecksum(zipped, 'crc32')
|
|
@@ -333,9 +329,7 @@ It will be also visible in your dashboard\n`)
|
|
|
333
329
|
}
|
|
334
330
|
else {
|
|
335
331
|
if (useS3) {
|
|
336
|
-
|
|
337
|
-
zip.addLocalFolder(path)
|
|
338
|
-
zipped = zip.toBuffer()
|
|
332
|
+
zipped = zipFile(path)
|
|
339
333
|
const s = p.spinner()
|
|
340
334
|
s.start(`Calculating checksum`)
|
|
341
335
|
checksum = await getChecksum(zipped, 'crc32')
|
|
@@ -400,12 +394,6 @@ It will be also visible in your dashboard\n`)
|
|
|
400
394
|
timeout: options.timeout || UPLOAD_TIMEOUT,
|
|
401
395
|
retry: 5,
|
|
402
396
|
body: zipped,
|
|
403
|
-
headers: (!localS3
|
|
404
|
-
? {
|
|
405
|
-
'Content-Type': 'application/octet-stream',
|
|
406
|
-
'Cache-Control': 'public, max-age=456789, immutable',
|
|
407
|
-
}
|
|
408
|
-
: undefined),
|
|
409
397
|
})
|
|
410
398
|
}
|
|
411
399
|
}
|
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
|
|
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()
|
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/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',
|