@capgo/cli 4.12.14 → 4.13.3

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.
Files changed (68) hide show
  1. package/dist/index.js +183 -92196
  2. package/package.json +20 -22
  3. package/.github/FUNDING.yml +0 -1
  4. package/.github/workflows/autofix.yml +0 -25
  5. package/.github/workflows/build.yml +0 -46
  6. package/.github/workflows/bump_version.yml +0 -56
  7. package/.github/workflows/check_posix_paths.yml +0 -229
  8. package/.github/workflows/test.yml +0 -30
  9. package/.prettierignore +0 -6
  10. package/.vscode/launch.json +0 -23
  11. package/.vscode/settings.json +0 -46
  12. package/.vscode/tasks.json +0 -42
  13. package/CHANGELOG.md +0 -3356
  14. package/build.mjs +0 -23
  15. package/bun.lockb +0 -0
  16. package/bunfig.toml +0 -2
  17. package/capacitor.config.ts +0 -33
  18. package/crypto_explained.png +0 -0
  19. package/eslint.config.js +0 -10
  20. package/renovate.json +0 -23
  21. package/src/api/app.ts +0 -55
  22. package/src/api/channels.ts +0 -163
  23. package/src/api/crypto.ts +0 -116
  24. package/src/api/devices_override.ts +0 -41
  25. package/src/api/update.ts +0 -13
  26. package/src/api/versions.ts +0 -100
  27. package/src/app/add.ts +0 -158
  28. package/src/app/debug.ts +0 -259
  29. package/src/app/delete.ts +0 -110
  30. package/src/app/info.ts +0 -89
  31. package/src/app/list.ts +0 -67
  32. package/src/app/set.ts +0 -96
  33. package/src/bundle/check.ts +0 -42
  34. package/src/bundle/cleanup.ts +0 -123
  35. package/src/bundle/compatibility.ts +0 -70
  36. package/src/bundle/decrypt.ts +0 -54
  37. package/src/bundle/delete.ts +0 -53
  38. package/src/bundle/encrypt.ts +0 -60
  39. package/src/bundle/list.ts +0 -43
  40. package/src/bundle/unlink.ts +0 -86
  41. package/src/bundle/upload.ts +0 -551
  42. package/src/bundle/zip.ts +0 -143
  43. package/src/channel/add.ts +0 -80
  44. package/src/channel/currentBundle.ts +0 -72
  45. package/src/channel/delete.ts +0 -57
  46. package/src/channel/list.ts +0 -49
  47. package/src/channel/set.ts +0 -177
  48. package/src/index.ts +0 -310
  49. package/src/init.ts +0 -495
  50. package/src/key.ts +0 -136
  51. package/src/login.ts +0 -70
  52. package/src/types/capacitor__cli.d.ts +0 -6
  53. package/src/types/supabase.types.ts +0 -2123
  54. package/src/user/account.ts +0 -11
  55. package/src/utils.ts +0 -1107
  56. package/test/VerifyZip.java +0 -83
  57. package/test/check-posix-paths.js +0 -21
  58. package/test/chunk_convert.ts +0 -28
  59. package/test/data.ts +0 -18769
  60. package/test/test_headers_rls.ts +0 -24
  61. package/test/test_semver.ts +0 -13
  62. package/test/test_upload/app.js +0 -3
  63. package/test/test_upload/assets/check-posix-paths.js +0 -21
  64. package/test/test_upload/index.html +0 -0
  65. package/test/test_zip_swift/Package.resolved +0 -24
  66. package/test/test_zip_swift/Package.swift +0 -29
  67. package/test/test_zip_swift/Sources/main.swift +0 -80
  68. package/tsconfig.json +0 -39
@@ -1,80 +0,0 @@
1
- import process from 'node:process'
2
- import { program } from 'commander'
3
- import * as p from '@clack/prompts'
4
- import { checkAppExistsAndHasPermissionOrgErr } from '../api/app'
5
- import { createChannel, findUnknownVersion } from '../api/channels'
6
- import type { OptionsBase } from '../utils'
7
- import { OrganizationPerm, createSupabaseClient, findSavedKey, formatError, getConfig, getOrganizationId, useLogSnag, verifyUser } from '../utils'
8
-
9
- interface Options extends OptionsBase {
10
- default?: boolean
11
- }
12
-
13
- export async function addChannel(channelId: string, appId: string, options: Options, shouldExit = true) {
14
- p.intro(`Create channel`)
15
- options.apikey = options.apikey || findSavedKey()
16
- const config = await getConfig()
17
- appId = appId || config?.app?.appId
18
- const snag = useLogSnag()
19
-
20
- if (!options.apikey) {
21
- p.log.error('Missing API key, you need to provide a API key to upload your bundle')
22
- program.error('')
23
- }
24
- if (!appId) {
25
- p.log.error('Missing argument, you need to provide a appId, or be in a capacitor project')
26
- program.error('')
27
- }
28
- const supabase = await createSupabaseClient(options.apikey)
29
-
30
- await verifyUser(supabase, options.apikey, ['write', 'all'])
31
- // Check we have app access to this appId
32
- await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, OrganizationPerm.admin)
33
-
34
- p.log.info(`Creating channel ${appId}#${channelId} to Capgo`)
35
- try {
36
- const data = await findUnknownVersion(supabase, appId)
37
- const orgId = await getOrganizationId(supabase, appId)
38
- if (!data) {
39
- p.log.error(`Cannot find default version for channel creation, please contact Capgo support 🤨`)
40
- program.error('')
41
- }
42
- const res = await createChannel(supabase, {
43
- name: channelId,
44
- app_id: appId,
45
- version: data.id,
46
- owner_org: orgId,
47
- })
48
-
49
- if (res.error) {
50
- p.log.error(`Cannot create Channel 🙀\n${formatError(res.error)}`)
51
- program.error('')
52
- }
53
-
54
- p.log.success(`Channel created ✅`)
55
- await snag.track({
56
- channel: 'channel',
57
- event: 'Create channel',
58
- icon: '✅',
59
- user_id: orgId,
60
- tags: {
61
- 'app-id': appId,
62
- 'channel': channelId,
63
- },
64
- notify: false,
65
- }).catch()
66
- }
67
- catch (error) {
68
- p.log.error(`Cannot create Channel 🙀`)
69
- return false
70
- }
71
- if (shouldExit) {
72
- p.outro(`Done ✅`)
73
- process.exit()
74
- }
75
- return true
76
- }
77
-
78
- export async function addChannelCommand(apikey: string, appId: string, options: Options) {
79
- addChannel(apikey, appId, options, true)
80
- }
@@ -1,72 +0,0 @@
1
- import process from 'node:process'
2
- import { program } from 'commander'
3
- import * as p from '@clack/prompts'
4
- import { checkAppExistsAndHasPermissionOrgErr } from '../api/app'
5
- import type { OptionsBase } from '../utils'
6
- import { OrganizationPerm, createSupabaseClient, findSavedKey, getConfig, verifyUser } from '../utils'
7
-
8
- interface Options extends OptionsBase {
9
- channel?: string
10
- quiet?: boolean
11
- }
12
-
13
- interface Channel {
14
- version: {
15
- name: string
16
- }
17
- }
18
-
19
- export async function currentBundle(channel: string, appId: string, options: Options) {
20
- const { quiet } = options
21
-
22
- if (!quiet)
23
- p.intro(`List current bundle`)
24
-
25
- options.apikey = options.apikey || findSavedKey(quiet)
26
- const config = await getConfig()
27
- appId = appId || config?.app?.appId
28
-
29
- if (!options.apikey) {
30
- p.log.error('Missing API key, you need to provide a API key to upload your bundle')
31
- program.error('')
32
- }
33
- if (!appId) {
34
- p.log.error('Missing argument, you need to provide a appId, or be in a capacitor project')
35
- program.error('')
36
- }
37
- const supabase = await createSupabaseClient(options.apikey)
38
-
39
- const _userId = await verifyUser(supabase, options.apikey, ['write', 'all', 'read'])
40
- // Check we have app access to this appId
41
- await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, OrganizationPerm.read)
42
-
43
- if (!channel) {
44
- p.log.error(`Please provide a channel to get the bundle from.`)
45
- program.error('')
46
- }
47
-
48
- const { data: supabaseChannel, error } = await supabase
49
- .from('channels')
50
- .select('version ( name )')
51
- .eq('name', channel)
52
- .eq('app_id', appId)
53
- .limit(1)
54
-
55
- if (error || supabaseChannel.length === 0) {
56
- p.log.error(`Error retrieving channel ${channel} for app ${appId}. Perhaps the channel does not exists?`)
57
- program.error('')
58
- }
59
-
60
- const { version } = supabaseChannel[0] as any as Channel
61
- if (!version) {
62
- p.log.error(`Error retrieving channel ${channel} for app ${appId}. Perhaps the channel does not exists?`)
63
- program.error('')
64
- }
65
-
66
- if (!quiet)
67
- p.log.info(`Current bundle for channel ${channel} is ${version.name}`)
68
- else
69
- p.log.info(version.name)
70
-
71
- process.exit()
72
- }
@@ -1,57 +0,0 @@
1
- import process from 'node:process'
2
- import { program } from 'commander'
3
- import * as p from '@clack/prompts'
4
- import { checkAppExistsAndHasPermissionOrgErr } from '../api/app'
5
- import { delChannel } from '../api/channels'
6
- import type { OptionsBase } from '../utils'
7
- import { OrganizationPerm, createSupabaseClient, findSavedKey, formatError, getConfig, getOrganizationId, useLogSnag, verifyUser } from '../utils'
8
-
9
- export async function deleteChannel(channelId: string, appId: string, options: OptionsBase) {
10
- p.intro(`Delete channel`)
11
- options.apikey = options.apikey || findSavedKey()
12
- const config = await getConfig()
13
- appId = appId || config?.app?.appId
14
- const snag = useLogSnag()
15
-
16
- if (!options.apikey) {
17
- p.log.error('Missing API key, you need to provide a API key to upload your bundle')
18
- program.error('')
19
- }
20
- if (!appId) {
21
- p.log.error('Missing argument, you need to provide a appId, or be in a capacitor project')
22
- program.error('')
23
- }
24
- const supabase = await createSupabaseClient(options.apikey)
25
-
26
- const userId = await verifyUser(supabase, options.apikey, ['write', 'all'])
27
- // Check we have app access to this appId
28
- await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, OrganizationPerm.admin)
29
-
30
- p.log.info(`Deleting channel ${appId}#${channelId} from Capgo`)
31
- try {
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
- }
37
- const orgId = await getOrganizationId(supabase, appId)
38
- p.log.success(`Channel deleted`)
39
- await snag.track({
40
- channel: 'channel',
41
- event: 'Delete channel',
42
- icon: '✅',
43
- user_id: orgId,
44
- tags: {
45
- 'user-id': userId,
46
- 'app-id': appId,
47
- 'channel': channelId,
48
- },
49
- notify: false,
50
- }).catch()
51
- }
52
- catch (error) {
53
- p.log.error(`Cannot delete Channel 🙀`)
54
- }
55
- p.outro(`Done ✅`)
56
- process.exit()
57
- }
@@ -1,49 +0,0 @@
1
- import process from 'node:process'
2
- import { program } from 'commander'
3
- import * as p from '@clack/prompts'
4
- import { checkAppExistsAndHasPermissionOrgErr } from '../api/app'
5
- import { displayChannels, getActiveChannels } from '../api/channels'
6
- import type { OptionsBase } from '../utils'
7
- import { OrganizationPerm, createSupabaseClient, findSavedKey, getConfig, useLogSnag, verifyUser } from '../utils'
8
-
9
- export async function listChannels(appId: string, options: OptionsBase) {
10
- p.intro(`List channels`)
11
- options.apikey = options.apikey || findSavedKey()
12
- const config = await getConfig()
13
- appId = appId || config?.app?.appId
14
- const snag = useLogSnag()
15
-
16
- if (!options.apikey)
17
- p.log.error('Missing API key, you need to provide a API key to upload your bundle')
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
- const supabase = await createSupabaseClient(options.apikey)
24
-
25
- const userId = await verifyUser(supabase, options.apikey, ['write', 'all', 'read', 'upload'])
26
- // Check we have app access to this appId
27
- await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, OrganizationPerm.read)
28
-
29
- p.log.info(`Querying available channels in Capgo`)
30
-
31
- // Get all active app versions we might possibly be able to cleanup
32
- const allVersions = await getActiveChannels(supabase, appId)
33
-
34
- p.log.info(`Active channels in Capgo: ${allVersions?.length}`)
35
-
36
- displayChannels(allVersions)
37
- await snag.track({
38
- channel: 'channel',
39
- event: 'List channel',
40
- icon: '✅',
41
- user_id: userId,
42
- tags: {
43
- 'app-id': appId,
44
- },
45
- notify: false,
46
- }).catch()
47
- p.outro(`Done ✅`)
48
- process.exit()
49
- }
@@ -1,177 +0,0 @@
1
- import process from 'node:process'
2
- import { program } from 'commander'
3
- import * as p from '@clack/prompts'
4
- import type { Database } from '../types/supabase.types'
5
- import { checkAppExistsAndHasPermissionOrgErr } from '../api/app'
6
- import type {
7
- OptionsBase,
8
- } from '../utils'
9
- import {
10
- OrganizationPerm,
11
- checkPlanValid,
12
- createSupabaseClient,
13
- findSavedKey,
14
- formatError,
15
- getConfig,
16
- getOrganizationId,
17
- updateOrCreateChannel,
18
- useLogSnag,
19
- verifyUser,
20
- } from '../utils'
21
-
22
- interface Options extends OptionsBase {
23
- bundle: string
24
- state?: string
25
- downgrade?: boolean
26
- latest?: boolean
27
- upgrade?: boolean
28
- ios?: boolean
29
- android?: boolean
30
- selfAssign?: boolean
31
- disableAutoUpdate: string
32
- dev?: boolean
33
- emulator?: boolean
34
- }
35
-
36
- const disableAutoUpdatesPossibleOptions = ['major', 'minor', 'metadata', 'patch', 'none']
37
-
38
- export async function setChannel(channel: string, appId: string, options: Options) {
39
- p.intro(`Set channel`)
40
- options.apikey = options.apikey || findSavedKey()
41
- const config = await getConfig()
42
- appId = appId || config?.app?.appId
43
- const snag = useLogSnag()
44
-
45
- if (!options.apikey) {
46
- p.log.error('Missing API key, you need to provide a API key to upload your bundle')
47
- program.error('')
48
- }
49
- if (!appId) {
50
- p.log.error('Missing argument, you need to provide a appId, or be in a capacitor project')
51
- program.error('')
52
- }
53
- const supabase = await createSupabaseClient(options.apikey)
54
-
55
- const userId = await verifyUser(supabase, options.apikey, ['write', 'all'])
56
- // Check we have app access to this appId
57
- await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, OrganizationPerm.admin)
58
- const orgId = await getOrganizationId(supabase, appId)
59
-
60
- const { bundle, state, downgrade, latest, upgrade, ios, android, selfAssign, disableAutoUpdate, dev, emulator } = options
61
- if (!channel) {
62
- p.log.error('Missing argument, you need to provide a channel')
63
- program.error('')
64
- }
65
- if (latest && bundle) {
66
- p.log.error('Cannot set latest and bundle at the same time')
67
- program.error('')
68
- }
69
- if (bundle == null
70
- && state == null
71
- && latest == null
72
- && downgrade == null
73
- && upgrade == null
74
- && ios == null
75
- && android == null
76
- && selfAssign == null
77
- && dev == null
78
- && emulator == null
79
- && disableAutoUpdate == null) {
80
- p.log.error('Missing argument, you need to provide a option to set')
81
- program.error('')
82
- }
83
- try {
84
- await checkPlanValid(supabase, orgId, options.apikey, appId)
85
- const channelPayload: Database['public']['Tables']['channels']['Insert'] = {
86
- created_by: userId,
87
- app_id: appId,
88
- name: channel,
89
- owner_org: orgId,
90
- version: undefined as any,
91
- }
92
- const bundleVersion = latest ? config?.app?.package?.version : bundle
93
- if (bundleVersion != null) {
94
- const { data, error: vError } = await supabase
95
- .from('app_versions')
96
- .select()
97
- .eq('app_id', appId)
98
- .eq('name', bundleVersion)
99
- .eq('user_id', userId)
100
- .eq('deleted', false)
101
- .single()
102
- if (vError || !data) {
103
- p.log.error(`Cannot find version ${bundleVersion}`)
104
- program.error('')
105
- }
106
- p.log.info(`Set ${appId} channel: ${channel} to @${bundleVersion}`)
107
- channelPayload.version = data.id
108
- }
109
- if (state != null) {
110
- if (state === 'public' || state === 'private')
111
- p.log.info(`Set ${appId} channel: ${channel} to public or private is deprecated, use default or normal instead`)
112
-
113
- p.log.info(`Set ${appId} channel: ${channel} to ${state === 'public' || state === 'default' ? 'default' : 'normal'}`)
114
- channelPayload.public = state === 'public' || state === 'default'
115
- }
116
- if (downgrade != null) {
117
- p.log.info(`Set ${appId} channel: ${channel} to ${downgrade ? 'allow' : 'disallow'} downgrade`)
118
- channelPayload.disableAutoUpdateUnderNative = !downgrade
119
- }
120
- if (ios != null) {
121
- p.log.info(`Set ${appId} channel: ${channel} to ${ios ? 'allow' : 'disallow'} ios update`)
122
- channelPayload.ios = !!ios
123
- }
124
- if (android != null) {
125
- p.log.info(`Set ${appId} channel: ${channel} to ${android ? 'allow' : 'disallow'} android update`)
126
- channelPayload.android = !!android
127
- }
128
- if (selfAssign != null) {
129
- p.log.info(`Set ${appId} channel: ${channel} to ${selfAssign ? 'allow' : 'disallow'} self assign to this channel`)
130
- channelPayload.allow_device_self_set = !!selfAssign
131
- }
132
- if (disableAutoUpdate != null) {
133
- let finalDisableAutoUpdate = disableAutoUpdate.toLocaleLowerCase()
134
-
135
- // The user passed an unimplemented strategy
136
- if (!disableAutoUpdatesPossibleOptions.includes(finalDisableAutoUpdate)) {
137
- p.log.error(`Channel strategy ${finalDisableAutoUpdate} is not known. The possible values are: ${disableAutoUpdatesPossibleOptions.join(', ')}.`)
138
- program.error('')
139
- }
140
-
141
- // This metadata is called differently in the database
142
- if (finalDisableAutoUpdate === 'metadata')
143
- finalDisableAutoUpdate = 'version_number'
144
-
145
- // This cast is safe, look above
146
- channelPayload.disableAutoUpdate = finalDisableAutoUpdate as any
147
- p.log.info(`Set ${appId} channel: ${channel} to ${finalDisableAutoUpdate} disable update strategy to this channel`)
148
- }
149
- try {
150
- const { error: dbError } = await updateOrCreateChannel(supabase, channelPayload)
151
- if (dbError) {
152
- p.log.error(`Cannot set channel the upload key is not allowed to do that, use the "all" for this.`)
153
- program.error('')
154
- }
155
- }
156
- catch (e) {
157
- p.log.error(`Cannot set channel the upload key is not allowed to do that, use the "all" for this.`)
158
- program.error('')
159
- }
160
- await snag.track({
161
- channel: 'channel',
162
- event: 'Set channel',
163
- icon: '✅',
164
- user_id: orgId,
165
- tags: {
166
- 'app-id': appId,
167
- },
168
- notify: false,
169
- }).catch()
170
- }
171
- catch (err) {
172
- p.log.error(`Unknow error ${formatError(err)}`)
173
- program.error('')
174
- }
175
- p.outro(`Done ✅`)
176
- process.exit()
177
- }