@capgo/cli 4.3.5 → 4.4.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/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [4.4.1](https://github.com/Cap-go/CLI/compare/v4.4.0...v4.4.1) (2024-04-21)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * lint issue auto delete ([3d343e2](https://github.com/Cap-go/CLI/commit/3d343e29522b4de725836965c9ec2aabcf469171))
11
+
12
+ ## [4.4.0](https://github.com/Cap-go/CLI/compare/v4.3.6...v4.4.0) (2024-04-21)
13
+
14
+
15
+ ### Features
16
+
17
+ * add auto delete Failed Versions upload ([8ba691c](https://github.com/Cap-go/CLI/commit/8ba691c116b92ababa2870fd5ed9479b9286242d))
18
+
19
+ ### [4.3.6](https://github.com/Cap-go/CLI/compare/v4.3.5...v4.3.6) (2024-04-21)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * add more retry ([a3e4c8e](https://github.com/Cap-go/CLI/commit/a3e4c8e3de66a9dca05fd48a4c480c6b54328c1b))
25
+
5
26
  ### [4.3.5](https://github.com/Cap-go/CLI/compare/v4.3.4...v4.3.5) (2024-04-18)
6
27
 
7
28
  ### [4.3.4](https://github.com/Cap-go/CLI/compare/v4.3.3...v4.3.4) (2024-04-17)
package/dist/index.js CHANGED
@@ -91634,7 +91634,7 @@ var {
91634
91634
  // package.json
91635
91635
  var package_default = {
91636
91636
  name: "@capgo/cli",
91637
- version: "4.3.5",
91637
+ version: "4.4.1",
91638
91638
  description: "A CLI to upload to capgo servers",
91639
91639
  main: "dist/index.js",
91640
91640
  bin: {
@@ -93079,6 +93079,20 @@ async function uploadUrl(supabase, appId, name) {
93079
93079
  }
93080
93080
  return "";
93081
93081
  }
93082
+ async function deletedFailedVersion(supabase, appId, name) {
93083
+ const data = {
93084
+ app_id: appId,
93085
+ name
93086
+ };
93087
+ try {
93088
+ const pathFailed = "private/delete_failed_version";
93089
+ const res = await supabase.functions.invoke(pathFailed, { body: JSON.stringify(data), method: "DELETE" });
93090
+ return res.data.url;
93091
+ } catch (error) {
93092
+ f2.error(`Cannot delete failed version ${formatError(error)}`);
93093
+ return Promise.reject(new Error("Cannot delete failed version"));
93094
+ }
93095
+ }
93082
93096
  async function updateOrCreateChannel(supabase, update) {
93083
93097
  if (!update.app_id || !update.name || !update.created_by) {
93084
93098
  f2.error("missing app_id, name, or created_by");
@@ -94212,15 +94226,22 @@ The app size is ${mbSize} Mb, this may take a while to download for users
94212
94226
  f2.error(`Cannot get upload url`);
94213
94227
  program.error("");
94214
94228
  }
94215
- await distribution_default.put(url, {
94216
- timeout: 6e4,
94217
- body: zipped,
94218
- headers: !localS3 ? {
94219
- "Content-Type": "application/octet-stream",
94220
- "Cache-Control": "public, max-age=456789, immutable",
94221
- "x-amz-meta-crc32": checksum
94222
- } : void 0
94223
- });
94229
+ try {
94230
+ await distribution_default.put(url, {
94231
+ timeout: 2e4,
94232
+ retry: 5,
94233
+ body: zipped,
94234
+ headers: !localS3 ? {
94235
+ "Content-Type": "application/octet-stream",
94236
+ "Cache-Control": "public, max-age=456789, immutable",
94237
+ "x-amz-meta-crc32": checksum
94238
+ } : void 0
94239
+ });
94240
+ } catch (errorUpload) {
94241
+ f2.error(`Cannot upload bundle ${formatError(errorUpload)}`);
94242
+ await deletedFailedVersion(supabase, appid, bundle2);
94243
+ program.error("");
94244
+ }
94224
94245
  versionData.storage_provider = "r2";
94225
94246
  const { error: dbError2 } = await updateOrCreateVersion(supabase, versionData);
94226
94247
  if (dbError2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
- "version": "4.3.5",
3
+ "version": "4.4.1",
4
4
  "description": "A CLI to upload to capgo servers",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -26,6 +26,7 @@ import {
26
26
  checkPlanValid,
27
27
  convertAppName,
28
28
  createSupabaseClient,
29
+ deletedFailedVersion,
29
30
  findSavedKey,
30
31
  formatError,
31
32
  getAppOwner,
@@ -386,17 +387,26 @@ It will be also visible in your dashboard\n`)
386
387
  p.log.error(`Cannot get upload url`)
387
388
  program.error('')
388
389
  }
389
- await ky.put(url, {
390
- timeout: 60000,
391
- body: zipped,
392
- headers: (!localS3
393
- ? {
394
- 'Content-Type': 'application/octet-stream',
395
- 'Cache-Control': 'public, max-age=456789, immutable',
396
- 'x-amz-meta-crc32': checksum,
397
- }
398
- : undefined),
399
- })
390
+ try {
391
+ await ky.put(url, {
392
+ timeout: 20000,
393
+ retry: 5,
394
+ body: zipped,
395
+ headers: (!localS3
396
+ ? {
397
+ 'Content-Type': 'application/octet-stream',
398
+ 'Cache-Control': 'public, max-age=456789, immutable',
399
+ 'x-amz-meta-crc32': checksum,
400
+ }
401
+ : undefined),
402
+ })
403
+ }
404
+ catch (errorUpload) {
405
+ p.log.error(`Cannot upload bundle ${formatError(errorUpload)}`)
406
+ // call delete version on path /delete_failed_version to delete the version
407
+ await deletedFailedVersion(supabase, appid, bundle)
408
+ program.error('')
409
+ }
400
410
  versionData.storage_provider = 'r2'
401
411
  const { error: dbError2 } = await updateOrCreateVersion(supabase, versionData)
402
412
  if (dbError2) {
package/src/utils.ts CHANGED
@@ -426,6 +426,22 @@ export async function uploadUrl(supabase: SupabaseClient<Database>, appId: strin
426
426
  return ''
427
427
  }
428
428
 
429
+ export async function deletedFailedVersion(supabase: SupabaseClient<Database>, appId: string, name: string): Promise<void> {
430
+ const data = {
431
+ app_id: appId,
432
+ name,
433
+ }
434
+ try {
435
+ const pathFailed = 'private/delete_failed_version'
436
+ const res = await supabase.functions.invoke(pathFailed, { body: JSON.stringify(data), method: 'DELETE' })
437
+ return res.data.url
438
+ }
439
+ catch (error) {
440
+ p.log.error(`Cannot delete failed version ${formatError(error)}`)
441
+ return Promise.reject(new Error('Cannot delete failed version'))
442
+ }
443
+ }
444
+
429
445
  export async function updateOrCreateChannel(supabase: SupabaseClient<Database>, update: Database['public']['Tables']['channels']['Insert']) {
430
446
  // console.log('updateOrCreateChannel', update)
431
447
  if (!update.app_id || !update.name || !update.created_by) {