@capgo/cli 3.13.10 → 3.13.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 +16 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/api/app.ts +5 -5
- package/src/app/add.ts +3 -12
- package/src/app/debug.ts +1 -1
- package/src/app/delete.ts +2 -2
- package/src/app/list.ts +1 -1
- package/src/app/set.ts +1 -1
- package/src/bundle/cleanup.ts +1 -1
- package/src/bundle/delete.ts +1 -1
- package/src/bundle/list.ts +1 -1
- package/src/bundle/unlink.ts +2 -2
- package/src/bundle/upload.ts +2 -19
- package/src/channel/add.ts +2 -2
- package/src/channel/delete.ts +2 -2
- package/src/channel/list.ts +2 -2
- package/src/channel/set.ts +4 -4
- package/src/types/supabase.types.ts +448 -41
- package/src/utils.ts +6 -2
package/src/api/app.ts
CHANGED
|
@@ -3,17 +3,17 @@ import { program } from 'commander';
|
|
|
3
3
|
import { Database } from 'types/supabase.types';
|
|
4
4
|
import { OptionsBase } from './utils';
|
|
5
5
|
|
|
6
|
-
export const checkAppExistsAndHasPermission = async (supabase: SupabaseClient<Database>, appid: string,
|
|
6
|
+
export const checkAppExistsAndHasPermission = async (supabase: SupabaseClient<Database>, appid: string,
|
|
7
7
|
shouldExist = true) => {
|
|
8
8
|
const { data: app, error: dbError0 } = await supabase
|
|
9
|
-
.rpc('
|
|
9
|
+
.rpc('exist_app_v2', { appid })
|
|
10
10
|
.single();
|
|
11
11
|
return app !== shouldExist || dbError0;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const checkAppExistsAndHasPermissionErr = async (supabase: SupabaseClient<Database>, appid: string,
|
|
14
|
+
export const checkAppExistsAndHasPermissionErr = async (supabase: SupabaseClient<Database>, appid: string,
|
|
15
15
|
shouldExist = true) => {
|
|
16
|
-
const res = await checkAppExistsAndHasPermission(supabase, appid,
|
|
16
|
+
const res = await checkAppExistsAndHasPermission(supabase, appid, shouldExist);
|
|
17
17
|
if (res) {
|
|
18
18
|
program.error(`App ${appid} does not exist or you don't have permission to access it`);
|
|
19
19
|
}
|
|
@@ -25,4 +25,4 @@ export interface Options extends OptionsBase {
|
|
|
25
25
|
retention?: number;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export const newIconPath = "assets/icon.png"
|
|
28
|
+
export const newIconPath = "assets/icon.png"
|
package/src/app/add.ts
CHANGED
|
@@ -33,9 +33,9 @@ export const addApp = async (appId: string, options: Options, shouldExit = true)
|
|
|
33
33
|
const userId = await verifyUser(supabase, options.apikey, ['write', 'all']);
|
|
34
34
|
// Check we have app access to this appId
|
|
35
35
|
if (shouldExit) {
|
|
36
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId,
|
|
36
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId, false);
|
|
37
37
|
} else {
|
|
38
|
-
const res = await checkAppExistsAndHasPermission(supabase, appId,
|
|
38
|
+
const res = await checkAppExistsAndHasPermission(supabase, appId, false);
|
|
39
39
|
if (res) {
|
|
40
40
|
return false
|
|
41
41
|
}
|
|
@@ -70,15 +70,6 @@ export const addApp = async (appId: string, options: Options, shouldExit = true)
|
|
|
70
70
|
p.log.warn(`Cannot find app icon in any of the following locations: ${icon}, ${newIconPath}`);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
// check if app already exist
|
|
74
|
-
const { data: app, error: dbError0 } = await supabase
|
|
75
|
-
.rpc('exist_app_v2', { appid: appId })
|
|
76
|
-
.single()
|
|
77
|
-
if (app || dbError0) {
|
|
78
|
-
p.log.error(`App ${appId} already exists ${formatError(dbError0)}`);
|
|
79
|
-
program.error('');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
73
|
const fileName = `icon_${randomUUID()}`
|
|
83
74
|
let signedURL = 'https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png'
|
|
84
75
|
|
|
@@ -149,4 +140,4 @@ export const addApp = async (appId: string, options: Options, shouldExit = true)
|
|
|
149
140
|
|
|
150
141
|
export const addCommand = async (apikey: string, options: Options) => {
|
|
151
142
|
addApp(apikey, options, true)
|
|
152
|
-
}
|
|
143
|
+
}
|
package/src/app/debug.ts
CHANGED
|
@@ -165,7 +165,7 @@ export const debugApp = async (appId: string, options: OptionsBaseDebug) => {
|
|
|
165
165
|
p.log.info(`Getting active bundle in Capgo`);
|
|
166
166
|
|
|
167
167
|
// Check we have app access to this appId
|
|
168
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
168
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
169
169
|
|
|
170
170
|
const doRun = await p.confirm({ message: `Automatic check if update working in device ?` });
|
|
171
171
|
await cancelCommand('debug', doRun, userId, snag);
|
package/src/app/delete.ts
CHANGED
|
@@ -21,7 +21,7 @@ export const deleteApp = async (appId: string, options: OptionsBase) => {
|
|
|
21
21
|
|
|
22
22
|
const userId = await verifyUser(supabase, options.apikey, ['write', 'all']);
|
|
23
23
|
// Check we have app access to this appId
|
|
24
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
24
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
25
25
|
|
|
26
26
|
const { error } = await supabase
|
|
27
27
|
.storage
|
|
@@ -60,4 +60,4 @@ export const deleteApp = async (appId: string, options: OptionsBase) => {
|
|
|
60
60
|
p.log.success(`App deleted in Capgo`);
|
|
61
61
|
p.outro('Done ✅');
|
|
62
62
|
process.exit()
|
|
63
|
-
}
|
|
63
|
+
}
|
package/src/app/list.ts
CHANGED
|
@@ -62,7 +62,7 @@ export const listApp = async (appId: string, options: OptionsBase) => {
|
|
|
62
62
|
p.log.info(`Getting active bundle in Capgo`);
|
|
63
63
|
|
|
64
64
|
// Check we have app access to this appId
|
|
65
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
65
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
66
66
|
|
|
67
67
|
// Get all active app versions we might possibly be able to cleanup
|
|
68
68
|
const allApps = await getActiveApps(supabase, userId);
|
package/src/app/set.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const setApp = async (appId: string, options: Options) => {
|
|
|
24
24
|
|
|
25
25
|
const userId = await verifyUser(supabase, options.apikey, ['write', 'all']);
|
|
26
26
|
// Check we have app access to this appId
|
|
27
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
27
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
28
28
|
|
|
29
29
|
const { name, icon, retention } = options;
|
|
30
30
|
|
package/src/bundle/cleanup.ts
CHANGED
|
@@ -62,7 +62,7 @@ export const cleanupBundle = async (appid: string, options: Options) => {
|
|
|
62
62
|
const userId = await verifyUser(supabase, apikey);
|
|
63
63
|
|
|
64
64
|
// Check we have app access to this appId
|
|
65
|
-
await checkAppExistsAndHasPermissionErr(supabase, appid
|
|
65
|
+
await checkAppExistsAndHasPermissionErr(supabase, appid);
|
|
66
66
|
p.log.info(`Querying all available versions in Capgo`);
|
|
67
67
|
|
|
68
68
|
// Get all active app versions we might possibly be able to cleanup
|
package/src/bundle/delete.ts
CHANGED
|
@@ -27,7 +27,7 @@ export const deleteBundle = async (bundleId: string, appId: string, options: Opt
|
|
|
27
27
|
|
|
28
28
|
const userId = await verifyUser(supabase, options.apikey, ['write', 'all']);
|
|
29
29
|
// Check we have app access to this appId
|
|
30
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
30
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
31
31
|
|
|
32
32
|
const apikey = options.apikey || findSavedKey()
|
|
33
33
|
|
package/src/bundle/list.ts
CHANGED
|
@@ -29,7 +29,7 @@ export const listBundle = async (appId: string, options: OptionsBase) => {
|
|
|
29
29
|
p.log.info(`Querying available versions of: ${appId} in Capgo`);
|
|
30
30
|
|
|
31
31
|
// Check we have app access to this appId
|
|
32
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
32
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
33
33
|
|
|
34
34
|
// Get all active app versions we might possibly be able to cleanup
|
|
35
35
|
const allVersions = await getActiveAppVersions(supabase, appId, userId);
|
package/src/bundle/unlink.ts
CHANGED
|
@@ -40,7 +40,7 @@ export const unlinkDevice = async (channel: string, appId: string, options: Opti
|
|
|
40
40
|
|
|
41
41
|
const userId = await verifyUser(supabase, options.apikey, ['write', 'all']);
|
|
42
42
|
// Check we have app access to this appId
|
|
43
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
43
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
44
44
|
|
|
45
45
|
if (!channel) {
|
|
46
46
|
p.log.error("Missing argument, you need to provide a channel");
|
|
@@ -68,4 +68,4 @@ export const unlinkDevice = async (channel: string, appId: string, options: Opti
|
|
|
68
68
|
}
|
|
69
69
|
p.outro('Done ✅');
|
|
70
70
|
process.exit()
|
|
71
|
-
}
|
|
71
|
+
}
|
package/src/bundle/upload.ts
CHANGED
|
@@ -72,17 +72,8 @@ export const uploadBundle = async (appid: string, options: Options, shouldExit =
|
|
|
72
72
|
const userId = await verifyUser(supabase, apikey, ['write', 'all', 'upload']);
|
|
73
73
|
await checkPlanValid(supabase, userId, false)
|
|
74
74
|
// Check we have app access to this appId
|
|
75
|
-
await checkAppExistsAndHasPermissionErr(supabase, appid
|
|
75
|
+
await checkAppExistsAndHasPermissionErr(supabase, appid);
|
|
76
76
|
|
|
77
|
-
// checking if user has access rights before uploading
|
|
78
|
-
const { data: versionExist, error: versionExistError } = await supabase
|
|
79
|
-
.rpc('exist_app_versions', { apikey, name_version: bundle, appid })
|
|
80
|
-
.single()
|
|
81
|
-
|
|
82
|
-
if (versionExist || versionExistError) {
|
|
83
|
-
p.log.error(`This app bundle already exist or was deleted, you cannot re-upload it ${formatError(versionExistError)}`);
|
|
84
|
-
program.error('');
|
|
85
|
-
}
|
|
86
77
|
const { data: isTrial, error: isTrialsError } = await supabase
|
|
87
78
|
.rpc('is_trial', { userid: userId })
|
|
88
79
|
.single()
|
|
@@ -91,14 +82,6 @@ export const uploadBundle = async (appid: string, options: Options, shouldExit =
|
|
|
91
82
|
p.log.warn(`Upgrade here: ${hostWeb}/dashboard/settings/plans`);
|
|
92
83
|
}
|
|
93
84
|
|
|
94
|
-
const { data: app, error: appError } = await supabase
|
|
95
|
-
.rpc('exist_app', { appid, apikey })
|
|
96
|
-
.single()
|
|
97
|
-
|
|
98
|
-
if (!app || appError) {
|
|
99
|
-
p.log.error(`Cannot find app ${appid} in your account ${formatError(appError)}`);
|
|
100
|
-
program.error('');
|
|
101
|
-
}
|
|
102
85
|
// check if app already exist
|
|
103
86
|
const { data: appVersion, error: appVersionError } = await supabase
|
|
104
87
|
.rpc('exist_app_versions', { appid, apikey, name_version: bundle })
|
|
@@ -245,7 +228,7 @@ It will be also visible in your dashboard\n`);
|
|
|
245
228
|
app_id: appid,
|
|
246
229
|
created_by: userId,
|
|
247
230
|
version: versionId,
|
|
248
|
-
}
|
|
231
|
+
})
|
|
249
232
|
if (dbError3) {
|
|
250
233
|
p.log.error(`Cannot set channel, the upload key is not allowed to do that, use the "all" for this.`);
|
|
251
234
|
program.error('');
|
package/src/channel/add.ts
CHANGED
|
@@ -28,7 +28,7 @@ export const addChannel = async (channelId: string, appId: string, options: Opti
|
|
|
28
28
|
|
|
29
29
|
const userId = await verifyUser(supabase, options.apikey, ['write', 'all']);
|
|
30
30
|
// Check we have app access to this appId
|
|
31
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
31
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
32
32
|
|
|
33
33
|
p.log.info(`Creating channel ${appId}#${channelId} to Capgo`);
|
|
34
34
|
try {
|
|
@@ -69,4 +69,4 @@ export const addChannel = async (channelId: string, appId: string, options: Opti
|
|
|
69
69
|
|
|
70
70
|
export const addChannelCommand = async (apikey: string, appId: string, options: Options) => {
|
|
71
71
|
addChannel(apikey, appId, options, true)
|
|
72
|
-
}
|
|
72
|
+
}
|
package/src/channel/delete.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const deleteChannel = async (channelId: string, appId: string, options: O
|
|
|
24
24
|
|
|
25
25
|
const userId = await verifyUser(supabase, options.apikey, ['write', 'all']);
|
|
26
26
|
// Check we have app access to this appId
|
|
27
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
27
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
28
28
|
|
|
29
29
|
p.log.info(`Deleting channel ${appId}#${channelId} from Capgo`);
|
|
30
30
|
try {
|
|
@@ -46,4 +46,4 @@ export const deleteChannel = async (channelId: string, appId: string, options: O
|
|
|
46
46
|
}
|
|
47
47
|
p.outro(`Done ✅`);
|
|
48
48
|
process.exit()
|
|
49
|
-
}
|
|
49
|
+
}
|
package/src/channel/list.ts
CHANGED
|
@@ -23,12 +23,12 @@ export const listChannels = async (appId: string, options: OptionsBase) => {
|
|
|
23
23
|
|
|
24
24
|
const userId = await verifyUser(supabase, options.apikey, ['write', 'all']);
|
|
25
25
|
// Check we have app access to this appId
|
|
26
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
26
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
27
27
|
|
|
28
28
|
p.log.info(`Querying available channels in Capgo`);
|
|
29
29
|
|
|
30
30
|
// Check we have app access to this appId
|
|
31
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
31
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
32
32
|
|
|
33
33
|
// Get all active app versions we might possibly be able to cleanup
|
|
34
34
|
const allVersions = await getActiveChannels(supabase, appId, userId);
|
package/src/channel/set.ts
CHANGED
|
@@ -39,7 +39,7 @@ export const setChannel = async (channel: string, appId: string, options: Option
|
|
|
39
39
|
|
|
40
40
|
const userId = await verifyUser(supabase, options.apikey, ['write', 'all']);
|
|
41
41
|
// Check we have app access to this appId
|
|
42
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
42
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
43
43
|
|
|
44
44
|
const { bundle, latest, downgrade, upgrade, ios, android, selfAssign, state } = options;
|
|
45
45
|
if (!channel) {
|
|
@@ -64,7 +64,7 @@ export const setChannel = async (channel: string, appId: string, options: Option
|
|
|
64
64
|
try {
|
|
65
65
|
await checkPlanValid(supabase, userId)
|
|
66
66
|
// Check we have app access to this appId
|
|
67
|
-
await checkAppExistsAndHasPermissionErr(supabase, appId
|
|
67
|
+
await checkAppExistsAndHasPermissionErr(supabase, appId);
|
|
68
68
|
const channelPayload: Database['public']['Tables']['channels']['Insert'] = {
|
|
69
69
|
created_by: userId,
|
|
70
70
|
app_id: appId,
|
|
@@ -116,7 +116,7 @@ export const setChannel = async (channel: string, appId: string, options: Option
|
|
|
116
116
|
channelPayload.allow_device_self_set = !!selfAssign
|
|
117
117
|
}
|
|
118
118
|
try {
|
|
119
|
-
const { error: dbError } = await updateOrCreateChannel(supabase, channelPayload
|
|
119
|
+
const { error: dbError } = await updateOrCreateChannel(supabase, channelPayload)
|
|
120
120
|
if (dbError) {
|
|
121
121
|
p.log.error(`Cannot set channel the upload key is not allowed to do that, use the "all" for this.`);
|
|
122
122
|
program.error('');
|
|
@@ -142,4 +142,4 @@ export const setChannel = async (channel: string, appId: string, options: Option
|
|
|
142
142
|
}
|
|
143
143
|
p.outro(`Done ✅`);
|
|
144
144
|
process.exit()
|
|
145
|
-
}
|
|
145
|
+
}
|