@capgo/cli 4.10.16 → 4.10.20

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,29 @@
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.10.20](https://github.com/Cap-go/CLI/compare/v4.10.19...v4.10.20) (2024-06-18)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * lint issue ([df7867b](https://github.com/Cap-go/CLI/commit/df7867ba88b1c87a2a123caae68b5b9c4505487e))
11
+
12
+ ### [4.10.19](https://github.com/Cap-go/CLI/compare/v4.10.18...v4.10.19) (2024-06-18)
13
+
14
+ ### [4.10.18](https://github.com/Cap-go/CLI/compare/v4.10.17...v4.10.18) (2024-06-17)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * add log message for the user ([e8b7437](https://github.com/Cap-go/CLI/commit/e8b7437da81bf819d6765fab7659f5d975855693))
20
+
21
+ ### [4.10.17](https://github.com/Cap-go/CLI/compare/v4.10.16...v4.10.17) (2024-06-13)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * remove old userId ([b263deb](https://github.com/Cap-go/CLI/commit/b263debe9b13fd68841c3a176f660863160a3872))
27
+
5
28
  ### [4.10.16](https://github.com/Cap-go/CLI/compare/v4.10.15...v4.10.16) (2024-06-13)
6
29
 
7
30
 
package/dist/index.js CHANGED
@@ -110243,7 +110243,7 @@ async function deletedFailedVersion(supabase, appId, name) {
110243
110243
  try {
110244
110244
  const pathFailed = "private/delete_failed_version";
110245
110245
  const res = await supabase.functions.invoke(pathFailed, { body: JSON.stringify(data), method: "DELETE" });
110246
- return res.data.url;
110246
+ return res.data.status;
110247
110247
  } catch (error) {
110248
110248
  f2.error(`Cannot delete failed version ${formatError(error)}`);
110249
110249
  return Promise.reject(new Error("Cannot delete failed version"));
@@ -110508,7 +110508,7 @@ async function getUserId(options) {
110508
110508
  // package.json
110509
110509
  var package_default = {
110510
110510
  name: "@capgo/cli",
110511
- version: "4.10.16",
110511
+ version: "4.10.20",
110512
110512
  description: "A CLI to upload to capgo servers",
110513
110513
  author: "github.com/riderx",
110514
110514
  license: "Apache 2.0",
@@ -111551,6 +111551,7 @@ The app size is ${mbSize} Mb, this may take a while to download for users
111551
111551
  const startTime = import_node_perf_hooks.performance.now();
111552
111552
  try {
111553
111553
  if (options.multipart !== void 0 && options.multipart) {
111554
+ f2.info(`Uploading bundle as multipart`);
111554
111555
  await uploadMultipart(supabase, appid, bundle2, zipped, orgId);
111555
111556
  } else {
111556
111557
  const url = await uploadUrl(supabase, appid, bundle2);
@@ -112288,7 +112289,7 @@ async function deleteAppVersion(supabase, appid, bundle2) {
112288
112289
  program.error("");
112289
112290
  }
112290
112291
  }
112291
- async function deleteSpecificVersion(supabase, appid, _userId, bundle2) {
112292
+ async function deleteSpecificVersion(supabase, appid, bundle2) {
112292
112293
  const versionData = await getVersionData(supabase, appid, bundle2);
112293
112294
  await checkVersionNotUsedInChannel(supabase, appid, versionData);
112294
112295
  await checkVersionNotUsedInDeviceOverride(supabase, appid, versionData);
@@ -112312,7 +112313,7 @@ function displayBundles(data) {
112312
112313
  });
112313
112314
  f2.success(t.render());
112314
112315
  }
112315
- async function getActiveAppVersions(supabase, appid, _userId) {
112316
+ async function getActiveAppVersions(supabase, appid) {
112316
112317
  const { data, error: vError } = await supabase.from("app_versions").select().eq("app_id", appid).eq("deleted", false).order("created_at", { ascending: false });
112317
112318
  if (vError) {
112318
112319
  f2.error(`App ${appid} not found in database`);
@@ -112353,10 +112354,10 @@ async function listBundle(appId, options) {
112353
112354
  program.error("");
112354
112355
  }
112355
112356
  const supabase = await createSupabaseClient(options.apikey);
112356
- const userId = await verifyUser(supabase, options.apikey, ["write", "all", "read", "upload"]);
112357
+ await verifyUser(supabase, options.apikey, ["write", "all", "read", "upload"]);
112357
112358
  f2.info(`Querying available versions of: ${appId} in Capgo`);
112358
112359
  await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, 1 /* read */);
112359
- const allVersions = await getActiveAppVersions(supabase, appId, userId);
112360
+ const allVersions = await getActiveAppVersions(supabase, appId);
112360
112361
  f2.info(`Active versions in Capgo: ${allVersions?.length}`);
112361
112362
  displayBundles(allVersions);
112362
112363
  $e(`Done \u2705`);
@@ -112529,7 +112530,7 @@ async function deleteBundle(bundleId, appId, options) {
112529
112530
  program.error("");
112530
112531
  }
112531
112532
  const supabase = await createSupabaseClient(options.apikey);
112532
- const userId = await verifyUser(supabase, options.apikey, ["write", "all"]);
112533
+ await verifyUser(supabase, options.apikey, ["write", "all"]);
112533
112534
  await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, 3 /* write */);
112534
112535
  appId = appId || config?.app?.appId;
112535
112536
  if (!options.apikey) {
@@ -112545,7 +112546,7 @@ async function deleteBundle(bundleId, appId, options) {
112545
112546
  program.error("");
112546
112547
  }
112547
112548
  f2.info(`Deleting bundle ${appId}@${bundleId} from Capgo`);
112548
- await deleteSpecificVersion(supabase, appId, userId, bundleId);
112549
+ await deleteSpecificVersion(supabase, appId, bundleId);
112549
112550
  f2.success(`Bundle ${appId}@${bundleId} deleted in Capgo`);
112550
112551
  $e(`Done`);
112551
112552
  import_node_process22.default.exit();
@@ -112754,10 +112755,10 @@ var import_node_process26 = __toESM(require("node:process"));
112754
112755
  var import_preload = __toESM(require_preload());
112755
112756
  var import_prompt_sync = __toESM(require_prompt_sync());
112756
112757
  var prompt = (0, import_prompt_sync.default)();
112757
- async function removeVersions(toRemove, supabase, appid, userId) {
112758
+ async function removeVersions(toRemove, supabase, appid) {
112758
112759
  for await (const row of toRemove) {
112759
112760
  f2.warn(`Removing ${row.name} created on ${getHumanDate(row.created_at)}`);
112760
- await deleteSpecificVersion(supabase, appid, userId, row.name);
112761
+ await deleteSpecificVersion(supabase, appid, row.name);
112761
112762
  }
112762
112763
  }
112763
112764
  function getRemovableVersionsInSemverRange(data, bundle2, nextMajor) {
@@ -112785,10 +112786,10 @@ async function cleanupBundle(appid, options) {
112785
112786
  program.error("");
112786
112787
  }
112787
112788
  const supabase = await createSupabaseClient(options.apikey);
112788
- const userId = await verifyUser(supabase, options.apikey, ["write", "all"]);
112789
+ await verifyUser(supabase, options.apikey, ["write", "all"]);
112789
112790
  await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appid, 3 /* write */);
112790
112791
  f2.info(`Querying all available versions in Capgo`);
112791
- let allVersions = await getActiveAppVersions(supabase, appid, userId);
112792
+ let allVersions = await getActiveAppVersions(supabase, appid);
112792
112793
  const versionInUse = await getChannelsVersion(supabase, appid);
112793
112794
  f2.info(`Total active versions in Capgo: ${allVersions?.length}`);
112794
112795
  if (allVersions?.length === 0) {
@@ -112829,7 +112830,7 @@ async function cleanupBundle(appid, options) {
112829
112830
  }
112830
112831
  }
112831
112832
  f2.success("You have confirmed removal, removing versions now");
112832
- await removeVersions(toRemove, supabase, appid, userId);
112833
+ await removeVersions(toRemove, supabase, appid);
112833
112834
  $e(`Done \u2705`);
112834
112835
  import_node_process26.default.exit();
112835
112836
  }
@@ -112855,7 +112856,11 @@ async function deleteChannel(channelId, appId, options) {
112855
112856
  await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, 4 /* admin */);
112856
112857
  f2.info(`Deleting channel ${appId}#${channelId} from Capgo`);
112857
112858
  try {
112858
- await delChannel(supabase, channelId, appId, userId);
112859
+ const deleteStatus = await delChannel(supabase, channelId, appId, userId);
112860
+ if (deleteStatus.error) {
112861
+ f2.error(`Cannot delete Channel \u{1F640} ${formatError(deleteStatus.error)}`);
112862
+ program.error("");
112863
+ }
112859
112864
  const orgId = await getOrganizationId(supabase, appId);
112860
112865
  f2.success(`Channel deleted`);
112861
112866
  await snag.track({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
- "version": "4.10.16",
3
+ "version": "4.10.20",
4
4
  "description": "A CLI to upload to capgo servers",
5
5
  "author": "github.com/riderx",
6
6
  "license": "Apache 2.0",
@@ -24,7 +24,7 @@ export async function deleteAppVersion(supabase: SupabaseClient<Database>, appid
24
24
  }
25
25
  }
26
26
 
27
- export async function deleteSpecificVersion(supabase: SupabaseClient<Database>, appid: string, _userId: string, bundle: string) {
27
+ export async function deleteSpecificVersion(supabase: SupabaseClient<Database>, appid: string, bundle: string) {
28
28
  const versionData = await getVersionData(supabase, appid, bundle)
29
29
  await checkVersionNotUsedInChannel(supabase, appid, versionData)
30
30
  await checkVersionNotUsedInDeviceOverride(supabase, appid, versionData)
@@ -55,12 +55,11 @@ export function displayBundles(data: (Database['public']['Tables']['app_versions
55
55
  p.log.success(t.render())
56
56
  }
57
57
 
58
- export async function getActiveAppVersions(supabase: SupabaseClient<Database>, appid: string, _userId: string) {
58
+ export async function getActiveAppVersions(supabase: SupabaseClient<Database>, appid: string) {
59
59
  const { data, error: vError } = await supabase
60
60
  .from('app_versions')
61
61
  .select()
62
62
  .eq('app_id', appid)
63
- // .eq('user_id', userId)
64
63
  .eq('deleted', false)
65
64
  .order('created_at', { ascending: false })
66
65
 
@@ -20,11 +20,11 @@ interface Options extends OptionsBase {
20
20
 
21
21
  const prompt = promptSync()
22
22
 
23
- async function removeVersions(toRemove: Database['public']['Tables']['app_versions']['Row'][], supabase: SupabaseClient<Database>, appid: string, userId: string) {
23
+ async function removeVersions(toRemove: Database['public']['Tables']['app_versions']['Row'][], supabase: SupabaseClient<Database>, appid: string) {
24
24
  // call deleteSpecificVersion one by one from toRemove sync
25
25
  for await (const row of toRemove) {
26
26
  p.log.warn(`Removing ${row.name} created on ${(getHumanDate(row.created_at))}`)
27
- await deleteSpecificVersion(supabase, appid, userId, row.name)
27
+ await deleteSpecificVersion(supabase, appid, row.name)
28
28
  }
29
29
  }
30
30
 
@@ -57,14 +57,14 @@ export async function cleanupBundle(appid: string, options: Options) {
57
57
  }
58
58
  const supabase = await createSupabaseClient(options.apikey)
59
59
 
60
- const userId = await verifyUser(supabase, options.apikey, ['write', 'all'])
60
+ await verifyUser(supabase, options.apikey, ['write', 'all'])
61
61
 
62
62
  // Check we have app access to this appId
63
63
  await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appid, OrganizationPerm.write)
64
64
  p.log.info(`Querying all available versions in Capgo`)
65
65
 
66
66
  // Get all active app versions we might possibly be able to cleanup
67
- let allVersions: (Database['public']['Tables']['app_versions']['Row'] & { keep?: string })[] = await getActiveAppVersions(supabase, appid, userId)
67
+ let allVersions: (Database['public']['Tables']['app_versions']['Row'] & { keep?: string })[] = await getActiveAppVersions(supabase, appid)
68
68
 
69
69
  const versionInUse = await getChannelsVersion(supabase, appid)
70
70
 
@@ -121,7 +121,7 @@ export async function cleanupBundle(appid: string, options: Options) {
121
121
 
122
122
  // Yes, lets clean it up
123
123
  p.log.success('You have confirmed removal, removing versions now')
124
- await removeVersions(toRemove, supabase, appid, userId)
124
+ await removeVersions(toRemove, supabase, appid)
125
125
  p.outro(`Done ✅`)
126
126
  process.exit()
127
127
  }
@@ -26,7 +26,7 @@ export async function deleteBundle(bundleId: string, appId: string, options: Opt
26
26
  }
27
27
  const supabase = await createSupabaseClient(options.apikey)
28
28
 
29
- const userId = await verifyUser(supabase, options.apikey, ['write', 'all'])
29
+ await verifyUser(supabase, options.apikey, ['write', 'all'])
30
30
  // Check we have app access to this appId
31
31
  await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, OrganizationPerm.write)
32
32
 
@@ -46,7 +46,7 @@ export async function deleteBundle(bundleId: string, appId: string, options: Opt
46
46
 
47
47
  p.log.info(`Deleting bundle ${appId}@${bundleId} from Capgo`)
48
48
 
49
- await deleteSpecificVersion(supabase, appId, userId, bundleId)
49
+ await deleteSpecificVersion(supabase, appId, bundleId)
50
50
  p.log.success(`Bundle ${appId}@${bundleId} deleted in Capgo`)
51
51
  p.outro(`Done`)
52
52
  process.exit()
@@ -25,7 +25,7 @@ export async function listBundle(appId: string, options: OptionsBase) {
25
25
 
26
26
  const supabase = await createSupabaseClient(options.apikey)
27
27
 
28
- const userId = await verifyUser(supabase, options.apikey, ['write', 'all', 'read', 'upload'])
28
+ await verifyUser(supabase, options.apikey, ['write', 'all', 'read', 'upload'])
29
29
 
30
30
  p.log.info(`Querying available versions of: ${appId} in Capgo`)
31
31
 
@@ -33,7 +33,7 @@ export async function listBundle(appId: string, options: OptionsBase) {
33
33
  await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, OrganizationPerm.read)
34
34
 
35
35
  // Get all active app versions we might possibly be able to cleanup
36
- const allVersions = await getActiveAppVersions(supabase, appId, userId)
36
+ const allVersions = await getActiveAppVersions(supabase, appId)
37
37
 
38
38
  p.log.info(`Active versions in Capgo: ${allVersions?.length}`)
39
39
 
@@ -387,6 +387,7 @@ It will be also visible in your dashboard\n`)
387
387
 
388
388
  try {
389
389
  if (options.multipart !== undefined && options.multipart) {
390
+ p.log.info(`Uploading bundle as multipart`)
390
391
  await uploadMultipart(supabase, appid, bundle, zipped, orgId)
391
392
  }
392
393
  else {
@@ -4,7 +4,7 @@ import * as p from '@clack/prompts'
4
4
  import { checkAppExistsAndHasPermissionOrgErr } from '../api/app'
5
5
  import { delChannel } 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
  export async function deleteChannel(channelId: string, appId: string, options: OptionsBase) {
10
10
  p.intro(`Delete channel`)
@@ -29,7 +29,11 @@ export async function deleteChannel(channelId: string, appId: string, options: O
29
29
 
30
30
  p.log.info(`Deleting channel ${appId}#${channelId} from Capgo`)
31
31
  try {
32
- await delChannel(supabase, channelId, appId, userId)
32
+ const deleteStatus = await delChannel(supabase, channelId, appId, userId)
33
+ if (deleteStatus.error) {
34
+ p.log.error(`Cannot delete Channel 🙀 ${formatError(deleteStatus.error)}`)
35
+ program.error('')
36
+ }
33
37
  const orgId = await getOrganizationId(supabase, appId)
34
38
  p.log.success(`Channel deleted`)
35
39
  await snag.track({
package/src/utils.ts CHANGED
@@ -589,7 +589,7 @@ export async function deletedFailedVersion(supabase: SupabaseClient<Database>, a
589
589
  try {
590
590
  const pathFailed = 'private/delete_failed_version'
591
591
  const res = await supabase.functions.invoke(pathFailed, { body: JSON.stringify(data), method: 'DELETE' })
592
- return res.data.url
592
+ return res.data.status
593
593
  }
594
594
  catch (error) {
595
595
  p.log.error(`Cannot delete failed version ${formatError(error)}`)