@capgo/cli 4.0.11 → 4.0.13

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.
@@ -1,41 +1,43 @@
1
- import { program } from 'commander';
2
- import * as p from '@clack/prompts';
3
- import { checkAppExistsAndHasPermissionErr } from '../api/app';
4
- import { getActiveAppVersions, displayBundles } from '../api/versions';
5
- import { OptionsBase, createSupabaseClient, findSavedKey, getConfig, verifyUser } from '../utils';
6
- import { checkLatest } from '../api/update';
7
-
8
- export const listBundle = async (appId: string, options: OptionsBase) => {
9
- p.intro(`List bundles`);
10
- await checkLatest();
11
- options.apikey = options.apikey || findSavedKey()
12
- const config = await getConfig();
13
-
14
- appId = appId || config?.app?.appId
15
- if (!options.apikey) {
16
- p.log.error("Missing API key, you need to provide a API key to upload your bundle");
17
- program.error('');
18
- }
19
- if (!appId) {
20
- p.log.error("Missing argument, you need to provide a appid, or be in a capacitor project");
21
- program.error('');
22
- }
23
-
24
- const supabase = await createSupabaseClient(options.apikey)
25
-
26
- const userId = await verifyUser(supabase, options.apikey, ['write', 'all', 'read', 'upload']);
27
-
28
- p.log.info(`Querying available versions of: ${appId} in Capgo`);
29
-
30
- // Check we have app access to this appId
31
- await checkAppExistsAndHasPermissionErr(supabase, options.apikey, appId);
32
-
33
- // Get all active app versions we might possibly be able to cleanup
34
- const allVersions = await getActiveAppVersions(supabase, appId, userId);
35
-
36
- p.log.info(`Active versions in Capgo: ${allVersions?.length}`);
37
-
38
- displayBundles(allVersions);
39
- p.outro(`Done ✅`);
40
- process.exit()
1
+ import process from 'node:process'
2
+ import { program } from 'commander'
3
+ import * as p from '@clack/prompts'
4
+ import { checkAppExistsAndHasPermissionErr } from '../api/app'
5
+ import { displayBundles, getActiveAppVersions } from '../api/versions'
6
+ import type { OptionsBase } from '../utils'
7
+ import { createSupabaseClient, findSavedKey, getConfig, verifyUser } from '../utils'
8
+ import { checkLatest } from '../api/update'
9
+
10
+ export async function listBundle(appId: string, options: OptionsBase) {
11
+ p.intro(`List bundles`)
12
+ await checkLatest()
13
+ options.apikey = options.apikey || findSavedKey()
14
+ const config = await getConfig()
15
+
16
+ appId = appId || config?.app?.appId
17
+ if (!options.apikey) {
18
+ p.log.error('Missing API key, you need to provide a API key to upload your bundle')
19
+ program.error('')
20
+ }
21
+ if (!appId) {
22
+ p.log.error('Missing argument, you need to provide a appid, or be in a capacitor project')
23
+ program.error('')
24
+ }
25
+
26
+ const supabase = await createSupabaseClient(options.apikey)
27
+
28
+ const userId = await verifyUser(supabase, options.apikey, ['write', 'all', 'read', 'upload'])
29
+
30
+ p.log.info(`Querying available versions of: ${appId} in Capgo`)
31
+
32
+ // Check we have app access to this appId
33
+ await checkAppExistsAndHasPermissionErr(supabase, options.apikey, appId)
34
+
35
+ // Get all active app versions we might possibly be able to cleanup
36
+ const allVersions = await getActiveAppVersions(supabase, appId, userId)
37
+
38
+ p.log.info(`Active versions in Capgo: ${allVersions?.length}`)
39
+
40
+ displayBundles(allVersions)
41
+ p.outro(`Done ✅`)
42
+ process.exit()
41
43
  }
@@ -1,71 +1,80 @@
1
- import { program } from 'commander';
2
- import * as p from '@clack/prompts';
3
- import { getVersionData } from '../api/versions';
4
- import { checkVersionNotUsedInDeviceOverride } from '../api/devices_override';
5
- import { checkVersionNotUsedInChannel } from '../api/channels';
6
- import { checkAppExistsAndHasPermissionErr } from "../api/app";
1
+ import process from 'node:process'
2
+ import { program } from 'commander'
3
+ import * as p from '@clack/prompts'
4
+ import { getVersionData } from '../api/versions'
5
+ import { checkVersionNotUsedInDeviceOverride } from '../api/devices_override'
6
+ import { checkVersionNotUsedInChannel } from '../api/channels'
7
+ import { checkAppExistsAndHasPermissionErr } from '../api/app'
8
+ import type {
9
+ OptionsBase,
10
+ } from '../utils'
7
11
  import {
8
- OptionsBase,
9
- getConfig, createSupabaseClient,
10
- formatError, findSavedKey, checkPlanValid, useLogSnag, verifyUser
11
- } from '../utils';
12
+ checkPlanValid,
13
+ createSupabaseClient,
14
+ findSavedKey,
15
+ formatError,
16
+ getConfig,
17
+ useLogSnag,
18
+ verifyUser,
19
+ } from '../utils'
12
20
 
13
21
  interface Options extends OptionsBase {
14
- bundle?: string
22
+ bundle?: string
15
23
  }
16
24
 
17
- export const unlinkDevice = async (channel: string, appId: string, options: Options) => {
18
- p.intro(`Unlink bundle`);
19
- options.apikey = options.apikey || findSavedKey()
20
- const config = await getConfig();
21
- appId = appId || config?.app?.appId
22
- const snag = useLogSnag()
23
- let { bundle } = options;
25
+ export async function unlinkDevice(channel: string, appId: string, options: Options) {
26
+ p.intro(`Unlink bundle`)
27
+ options.apikey = options.apikey || findSavedKey()
28
+ const config = await getConfig()
29
+ appId = appId || config?.app?.appId
30
+ const snag = useLogSnag()
31
+ let { bundle } = options
24
32
 
25
- bundle = bundle || config?.app?.package?.version
33
+ bundle = bundle || config?.app?.package?.version
26
34
 
27
- if (!options.apikey) {
28
- p.log.error("Missing API key, you need to provide a API key to upload your bundle");
29
- program.error('');
30
- }
31
- if (!appId) {
32
- p.log.error("Missing argument, you need to provide a appId, or be in a capacitor project");
33
- program.error('');
34
- }
35
- if (!bundle) {
36
- p.log.error("Missing argument, you need to provide a bundle, or be in a capacitor project");
37
- program.error('');
38
- }
39
- const supabase = await createSupabaseClient(options.apikey)
35
+ if (!options.apikey) {
36
+ p.log.error('Missing API key, you need to provide a API key to upload your bundle')
37
+ program.error('')
38
+ }
39
+ if (!appId) {
40
+ p.log.error('Missing argument, you need to provide a appId, or be in a capacitor project')
41
+ program.error('')
42
+ }
43
+ if (!bundle) {
44
+ p.log.error('Missing argument, you need to provide a bundle, or be in a capacitor project')
45
+ program.error('')
46
+ }
47
+ const supabase = await createSupabaseClient(options.apikey)
40
48
 
41
- const userId = await verifyUser(supabase, options.apikey, ['write', 'all']);
42
- // Check we have app access to this appId
43
- await checkAppExistsAndHasPermissionErr(supabase, options.apikey, appId);
49
+ const userId = await verifyUser(supabase, options.apikey, ['write', 'all'])
50
+ // Check we have app access to this appId
51
+ await checkAppExistsAndHasPermissionErr(supabase, options.apikey, appId)
44
52
 
45
- if (!channel) {
46
- p.log.error("Missing argument, you need to provide a channel");
47
- program.error('');
48
- }
49
- try {
50
- await checkPlanValid(supabase, userId, appId, options.apikey)
53
+ if (!channel) {
54
+ p.log.error('Missing argument, you need to provide a channel')
55
+ program.error('')
56
+ }
57
+ try {
58
+ await checkPlanValid(supabase, userId, appId, options.apikey)
51
59
 
52
- const versionData = await getVersionData(supabase, appId, userId, bundle);
53
- await checkVersionNotUsedInChannel(supabase, appId, userId, versionData);
54
- await checkVersionNotUsedInDeviceOverride(supabase, appId, versionData);
55
- await snag.track({
56
- channel: 'bundle',
57
- event: 'Unlink bundle',
58
- icon: '✅',
59
- user_id: userId,
60
- tags: {
61
- 'app-id': appId,
62
- },
63
- notify: false,
64
- }).catch()
65
- } catch (err) {
66
- p.log.error(`Unknow error ${formatError(err)}`);
67
- program.error('');
68
- }
69
- p.outro('Done ✅');
70
- process.exit()
60
+ const versionData = await getVersionData(supabase, appId, userId, bundle)
61
+ await checkVersionNotUsedInChannel(supabase, appId, userId, versionData)
62
+ await checkVersionNotUsedInDeviceOverride(supabase, appId, versionData)
63
+ await snag.track({
64
+ channel: 'bundle',
65
+ event: 'Unlink bundle',
66
+ icon: '✅',
67
+ user_id: userId,
68
+ tags: {
69
+ 'app-id': appId,
70
+ },
71
+ notify: false,
72
+ }).catch()
73
+ }
74
+ catch (err) {
75
+ p.log.error(`Unknow error ${formatError(err)}`)
76
+ program.error('')
77
+ }
78
+ p.outro('Done ✅')
79
+ process.exit()
71
80
  }