@capgo/cli 4.0.12 → 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.
- package/CHANGELOG.md +8 -0
- package/bun.lockb +0 -0
- package/capacitor.config.ts +2 -2
- package/dist/index.js +650 -654
- package/eslint.config.js +3 -0
- package/package.json +3 -2
- package/src/api/app.ts +29 -36
- package/src/api/channels.ts +53 -49
- package/src/api/crypto.ts +83 -80
- package/src/api/devices_override.ts +12 -13
- package/src/api/update.ts +10 -10
- package/src/api/versions.ts +43 -42
- package/src/app/add.ts +61 -53
- package/src/app/debug.ts +153 -151
- package/src/app/delete.ts +61 -59
- package/src/app/info.ts +74 -77
- package/src/app/list.ts +33 -31
- package/src/app/set.ts +85 -82
- package/src/bundle/check.ts +30 -32
- package/src/bundle/cleanup.ts +71 -74
- package/src/bundle/compatibility.ts +52 -55
- package/src/bundle/decrypt.ts +21 -19
- package/src/bundle/delete.ts +27 -25
- package/src/bundle/encrypt.ts +23 -21
- package/src/bundle/list.ts +42 -40
- package/src/bundle/unlink.ts +69 -60
- package/src/bundle/upload.ts +170 -149
- package/src/bundle/zip.ts +122 -118
- package/src/channel/add.ts +62 -60
- package/src/channel/currentBundle.ts +56 -56
- package/src/channel/delete.ts +46 -43
- package/src/channel/list.ts +23 -21
- package/src/channel/set.ts +76 -68
- package/src/index.ts +55 -57
- package/src/init.ts +254 -252
- package/src/key.ts +56 -52
- package/src/login.ts +30 -28
- package/src/types/capacitor__cli.d.ts +2 -3
- package/src/types/supabase.types.ts +505 -505
- package/src/utils.ts +560 -571
- package/.eslintrc +0 -71
package/src/bundle/list.ts
CHANGED
|
@@ -1,41 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
}
|
package/src/bundle/unlink.ts
CHANGED
|
@@ -1,71 +1,80 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
22
|
+
bundle?: string
|
|
15
23
|
}
|
|
16
24
|
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
33
|
+
bundle = bundle || config?.app?.package?.version
|
|
26
34
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
}
|