@capgo/cli 4.10.11 → 4.10.12
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 +7 -0
- package/dist/index.js +39 -19
- package/package.json +1 -1
- package/src/app/debug.ts +39 -24
- package/src/init.ts +4 -6
- package/src/types/supabase.types.ts +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.12](https://github.com/Cap-go/CLI/compare/v4.10.11...v4.10.12) (2024-06-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* add back debug command ([bb220a3](https://github.com/Cap-go/CLI/commit/bb220a3c42d30397f67d78233d6b8be460674a23))
|
|
11
|
+
|
|
5
12
|
### [4.10.11](https://github.com/Cap-go/CLI/compare/v4.10.10...v4.10.11) (2024-06-05)
|
|
6
13
|
|
|
7
14
|
|
package/dist/index.js
CHANGED
|
@@ -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.
|
|
110511
|
+
version: "4.10.12",
|
|
110512
110512
|
description: "A CLI to upload to capgo servers",
|
|
110513
110513
|
author: "github.com/riderx",
|
|
110514
110514
|
license: "Apache 2.0",
|
|
@@ -110827,21 +110827,28 @@ async function cancelCommand(channel2, command, orgId, snag) {
|
|
|
110827
110827
|
import_node_process10.default.exit();
|
|
110828
110828
|
}
|
|
110829
110829
|
}
|
|
110830
|
-
async function getStats(
|
|
110830
|
+
async function getStats(apikey, query, after) {
|
|
110831
110831
|
try {
|
|
110832
|
-
const
|
|
110833
|
-
const
|
|
110834
|
-
|
|
110835
|
-
|
|
110836
|
-
|
|
110832
|
+
const defaultApiHostPreprod = "https://api-preprod.capgo.app";
|
|
110833
|
+
const dataD = await distribution_default.post(`${defaultApiHostPreprod}/private/stats`, {
|
|
110834
|
+
headers: {
|
|
110835
|
+
"Content-Type": "application/json",
|
|
110836
|
+
"capgkey": apikey
|
|
110837
|
+
},
|
|
110838
|
+
body: JSON.stringify(query)
|
|
110839
|
+
}).then((res) => res.json()).catch((err) => {
|
|
110840
|
+
console.error("Cannot get devices", err);
|
|
110841
|
+
return [];
|
|
110842
|
+
});
|
|
110843
|
+
if (dataD?.length > 0 && (after === null || after !== dataD[0].created_at))
|
|
110844
|
+
return dataD[0];
|
|
110837
110845
|
} catch (error) {
|
|
110838
110846
|
f2.error(`Cannot get stats ${formatError(error)}`);
|
|
110839
110847
|
}
|
|
110840
110848
|
return null;
|
|
110841
110849
|
}
|
|
110842
|
-
async function waitLog(channel2,
|
|
110850
|
+
async function waitLog(channel2, apikey, appId, snag, orgId, deviceId) {
|
|
110843
110851
|
let loop = true;
|
|
110844
|
-
let now = (/* @__PURE__ */ new Date()).toISOString();
|
|
110845
110852
|
const appIdUrl = convertAppName(appId);
|
|
110846
110853
|
const config = await getLocalConfig();
|
|
110847
110854
|
const baseUrl = `${config.hostWeb}/app/p/${appIdUrl}`;
|
|
@@ -110853,13 +110860,14 @@ async function waitLog(channel2, supabase, appId, snag, orgId, deviceId) {
|
|
|
110853
110860
|
key: "created_at",
|
|
110854
110861
|
sortable: "desc"
|
|
110855
110862
|
}],
|
|
110856
|
-
|
|
110857
|
-
|
|
110858
|
-
after: now
|
|
110863
|
+
limit: 1,
|
|
110864
|
+
rangeStart: (/* @__PURE__ */ new Date()).toISOString()
|
|
110859
110865
|
};
|
|
110866
|
+
let after = null;
|
|
110860
110867
|
while (loop) {
|
|
110861
|
-
const data = await getStats(
|
|
110868
|
+
const data = await getStats(apikey, query, after);
|
|
110862
110869
|
if (data) {
|
|
110870
|
+
after = data.created_at;
|
|
110863
110871
|
f2.info(`Log from Device: ${data.device_id}`);
|
|
110864
110872
|
if (data.action === "get") {
|
|
110865
110873
|
f2.info("Update Sent your your device, wait until event download complete");
|
|
@@ -110887,7 +110895,7 @@ async function waitLog(channel2, supabase, appId, snag, orgId, deviceId) {
|
|
|
110887
110895
|
} else if (data.action === "missingBundle") {
|
|
110888
110896
|
f2.error("Your bundle is missing, please check how you build your app ");
|
|
110889
110897
|
} else if (data.action === "noNew") {
|
|
110890
|
-
f2.error(`Your version in ${data.
|
|
110898
|
+
f2.error(`Your version in ${data.device_id} is the same as your version uploaded, change it to see the update`);
|
|
110891
110899
|
} else if (data.action === "disablePlatformIos") {
|
|
110892
110900
|
f2.error(`iOS is disabled in the default channel and your device is an iOS device ${baseUrl}`);
|
|
110893
110901
|
} else if (data.action === "disablePlatformAndroid") {
|
|
@@ -110919,10 +110927,8 @@ async function waitLog(channel2, supabase, appId, snag, orgId, deviceId) {
|
|
|
110919
110927
|
} else {
|
|
110920
110928
|
f2.error(`Log from Capgo ${data.action}`);
|
|
110921
110929
|
}
|
|
110922
|
-
now = (/* @__PURE__ */ new Date()).toISOString();
|
|
110923
|
-
query.after = now;
|
|
110924
110930
|
}
|
|
110925
|
-
await wait2(
|
|
110931
|
+
await wait2(5e3);
|
|
110926
110932
|
}
|
|
110927
110933
|
return Promise.resolve();
|
|
110928
110934
|
}
|
|
@@ -110951,8 +110957,8 @@ async function debugApp(appId, options) {
|
|
|
110951
110957
|
await cancelCommand("debug", doRun, userId, snag);
|
|
110952
110958
|
if (doRun) {
|
|
110953
110959
|
f2.info(`Wait logs sent to Capgo from ${appId} device, Put the app in background and open it again.`);
|
|
110954
|
-
f2.info("Waiting...");
|
|
110955
|
-
await waitLog("debug",
|
|
110960
|
+
f2.info("Waiting... (there is a usual delay of 15 seconds until the backend process the logs)");
|
|
110961
|
+
await waitLog("debug", options.apikey, appId, snag, orgId, deviceId);
|
|
110956
110962
|
$e(`Done \u2705`);
|
|
110957
110963
|
} else {
|
|
110958
110964
|
$e(`Canceled \u274C`);
|
|
@@ -112185,6 +112191,19 @@ async function step9(orgId, snag) {
|
|
|
112185
112191
|
}
|
|
112186
112192
|
await markStep(orgId, snag, 9);
|
|
112187
112193
|
}
|
|
112194
|
+
async function step10(orgId, snag, apikey, appId) {
|
|
112195
|
+
const doRun = await se({ message: `Automatic check if update working in device ?` });
|
|
112196
|
+
await cancelCommand2(doRun, orgId, snag);
|
|
112197
|
+
if (doRun) {
|
|
112198
|
+
f2.info(`Wait logs sent to Capgo from ${appId} device, Put the app in background and open it again.`);
|
|
112199
|
+
f2.info("Waiting... (there is a usual delay of 15 seconds until the backend process the logs)");
|
|
112200
|
+
await waitLog("onboarding-v2", apikey, appId, snag, orgId);
|
|
112201
|
+
} else {
|
|
112202
|
+
const appIdUrl = convertAppName(appId);
|
|
112203
|
+
f2.info(`Check logs in https://web.capgo.app/app/p/${appIdUrl}/logs to see if update works.`);
|
|
112204
|
+
}
|
|
112205
|
+
await markStep(orgId, snag, 10);
|
|
112206
|
+
}
|
|
112188
112207
|
async function initApp(apikeyCommand, appId, options) {
|
|
112189
112208
|
const pm2 = getPMAndCommand();
|
|
112190
112209
|
oe(`Capgo onboarding \u{1F6EB}`);
|
|
@@ -112212,6 +112231,7 @@ async function initApp(apikeyCommand, appId, options) {
|
|
|
112212
112231
|
await step7(orgId, snag, apikey, appId);
|
|
112213
112232
|
await step8(orgId, snag, apikey, appId);
|
|
112214
112233
|
await step9(orgId, snag);
|
|
112234
|
+
await step10(orgId, snag, apikey, appId);
|
|
112215
112235
|
await markStep(orgId, snag, 0);
|
|
112216
112236
|
f2.info(`Welcome onboard \u2708\uFE0F!`);
|
|
112217
112237
|
f2.info(`Your Capgo update system is setup`);
|
package/package.json
CHANGED
package/src/app/debug.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
+
import ky from 'ky'
|
|
2
3
|
import * as p from '@clack/prompts'
|
|
3
|
-
import type { SupabaseClient } from '@supabase/supabase-js'
|
|
4
4
|
import { program } from 'commander'
|
|
5
5
|
import type LogSnag from 'logsnag'
|
|
6
6
|
import type { Database } from '../types/supabase.types'
|
|
@@ -46,18 +46,36 @@ interface QueryStats {
|
|
|
46
46
|
devicesId?: string[]
|
|
47
47
|
search?: string
|
|
48
48
|
order?: Order[]
|
|
49
|
-
rangeStart?:
|
|
50
|
-
rangeEnd?:
|
|
51
|
-
|
|
49
|
+
rangeStart?: string
|
|
50
|
+
rangeEnd?: string
|
|
51
|
+
limit?: number
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
interface LogData {
|
|
54
|
+
app_id: string
|
|
55
|
+
device_id: string
|
|
56
|
+
action: Database['public']['Enums']['stats_action']
|
|
57
|
+
version_id: number
|
|
58
|
+
version?: number
|
|
59
|
+
created_at: string
|
|
60
|
+
}
|
|
61
|
+
export async function getStats(apikey: string, query: QueryStats, after: string | null): Promise<LogData | null> {
|
|
55
62
|
try {
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
const defaultApiHostPreprod = 'https://api-preprod.capgo.app'
|
|
64
|
+
const dataD = await ky
|
|
65
|
+
.post(`${defaultApiHostPreprod}/private/stats`, {
|
|
66
|
+
headers: {
|
|
67
|
+
'Content-Type': 'application/json',
|
|
68
|
+
'capgkey': apikey,
|
|
69
|
+
},
|
|
70
|
+
body: JSON.stringify(query),
|
|
71
|
+
})
|
|
72
|
+
.then(res => res.json<LogData[]>())
|
|
73
|
+
.catch((err) => {
|
|
74
|
+
console.error('Cannot get devices', err)
|
|
75
|
+
return [] as LogData[]
|
|
76
|
+
})
|
|
77
|
+
if (dataD?.length > 0 && (after === null || after !== dataD[0].created_at))
|
|
78
|
+
return dataD[0]
|
|
61
79
|
}
|
|
62
80
|
catch (error) {
|
|
63
81
|
p.log.error(`Cannot get stats ${formatError(error)}`)
|
|
@@ -65,9 +83,8 @@ export async function getStats(supabase: SupabaseClient<Database>, query: QueryS
|
|
|
65
83
|
return null
|
|
66
84
|
}
|
|
67
85
|
|
|
68
|
-
export async function waitLog(channel: string,
|
|
86
|
+
export async function waitLog(channel: string, apikey: string, appId: string, snag: LogSnag, orgId: string, deviceId?: string) {
|
|
69
87
|
let loop = true
|
|
70
|
-
let now = new Date().toISOString()
|
|
71
88
|
const appIdUrl = convertAppName(appId)
|
|
72
89
|
const config = await getLocalConfig()
|
|
73
90
|
const baseUrl = `${config.hostWeb}/app/p/${appIdUrl}`
|
|
@@ -79,14 +96,14 @@ export async function waitLog(channel: string, supabase: SupabaseClient<Database
|
|
|
79
96
|
key: 'created_at',
|
|
80
97
|
sortable: 'desc',
|
|
81
98
|
}],
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
after: now,
|
|
99
|
+
limit: 1,
|
|
100
|
+
rangeStart: new Date().toISOString(),
|
|
85
101
|
}
|
|
102
|
+
let after: string | null = null
|
|
86
103
|
while (loop) {
|
|
87
|
-
const data = await getStats(
|
|
88
|
-
// console.log('data', data)
|
|
104
|
+
const data = await getStats(apikey, query, after)
|
|
89
105
|
if (data) {
|
|
106
|
+
after = data.created_at
|
|
90
107
|
p.log.info(`Log from Device: ${data.device_id}`)
|
|
91
108
|
if (data.action === 'get') {
|
|
92
109
|
p.log.info('Update Sent your your device, wait until event download complete')
|
|
@@ -122,7 +139,7 @@ export async function waitLog(channel: string, supabase: SupabaseClient<Database
|
|
|
122
139
|
p.log.error('Your bundle is missing, please check how you build your app ')
|
|
123
140
|
}
|
|
124
141
|
else if (data.action === 'noNew') {
|
|
125
|
-
p.log.error(`Your version in ${data.
|
|
142
|
+
p.log.error(`Your version in ${data.device_id} is the same as your version uploaded, change it to see the update`)
|
|
126
143
|
}
|
|
127
144
|
else if (data.action === 'disablePlatformIos') {
|
|
128
145
|
p.log.error(`iOS is disabled in the default channel and your device is an iOS device ${baseUrl}`)
|
|
@@ -166,10 +183,8 @@ export async function waitLog(channel: string, supabase: SupabaseClient<Database
|
|
|
166
183
|
else {
|
|
167
184
|
p.log.error(`Log from Capgo ${data.action}`)
|
|
168
185
|
}
|
|
169
|
-
now = new Date().toISOString()
|
|
170
|
-
query.after = now
|
|
171
186
|
}
|
|
172
|
-
await wait(
|
|
187
|
+
await wait(5000)
|
|
173
188
|
}
|
|
174
189
|
return Promise.resolve()
|
|
175
190
|
}
|
|
@@ -208,8 +223,8 @@ export async function debugApp(appId: string, options: OptionsBaseDebug) {
|
|
|
208
223
|
await cancelCommand('debug', doRun, userId, snag)
|
|
209
224
|
if (doRun) {
|
|
210
225
|
p.log.info(`Wait logs sent to Capgo from ${appId} device, Put the app in background and open it again.`)
|
|
211
|
-
p.log.info('Waiting...')
|
|
212
|
-
await waitLog('debug',
|
|
226
|
+
p.log.info('Waiting... (there is a usual delay of 15 seconds until the backend process the logs)')
|
|
227
|
+
await waitLog('debug', options.apikey, appId, snag, orgId, deviceId)
|
|
213
228
|
p.outro(`Done ✅`)
|
|
214
229
|
}
|
|
215
230
|
else {
|
package/src/init.ts
CHANGED
|
@@ -3,10 +3,8 @@ import type { ExecSyncOptions } from 'node:child_process'
|
|
|
3
3
|
import { execSync, spawnSync } from 'node:child_process'
|
|
4
4
|
import process from 'node:process'
|
|
5
5
|
import * as p from '@clack/prompts'
|
|
6
|
-
import type { SupabaseClient } from '@supabase/supabase-js'
|
|
7
6
|
import type LogSnag from 'logsnag'
|
|
8
7
|
import semver from 'semver'
|
|
9
|
-
import type { Database } from './types/supabase.types'
|
|
10
8
|
import { markSnag, waitLog } from './app/debug'
|
|
11
9
|
import { createKey } from './key'
|
|
12
10
|
import { addChannel } from './channel/add'
|
|
@@ -284,13 +282,13 @@ async function step9(orgId: string, snag: LogSnag) {
|
|
|
284
282
|
await markStep(orgId, snag, 9)
|
|
285
283
|
}
|
|
286
284
|
|
|
287
|
-
async function
|
|
285
|
+
async function step10(orgId: string, snag: LogSnag, apikey: string, appId: string) {
|
|
288
286
|
const doRun = await p.confirm({ message: `Automatic check if update working in device ?` })
|
|
289
287
|
await cancelCommand(doRun, orgId, snag)
|
|
290
288
|
if (doRun) {
|
|
291
289
|
p.log.info(`Wait logs sent to Capgo from ${appId} device, Put the app in background and open it again.`)
|
|
292
|
-
p.log.info('Waiting...')
|
|
293
|
-
await waitLog('onboarding-v2',
|
|
290
|
+
p.log.info('Waiting... (there is a usual delay of 15 seconds until the backend process the logs)')
|
|
291
|
+
await waitLog('onboarding-v2', apikey, appId, snag, orgId)
|
|
294
292
|
}
|
|
295
293
|
else {
|
|
296
294
|
const appIdUrl = convertAppName(appId)
|
|
@@ -331,7 +329,7 @@ export async function initApp(apikeyCommand: string, appId: string, options: Sup
|
|
|
331
329
|
await step7(orgId, snag, apikey, appId)
|
|
332
330
|
await step8(orgId, snag, apikey, appId)
|
|
333
331
|
await step9(orgId, snag)
|
|
334
|
-
|
|
332
|
+
await step10(orgId, snag, apikey, appId)
|
|
335
333
|
|
|
336
334
|
await markStep(orgId, snag, 0)
|
|
337
335
|
p.log.info(`Welcome onboard ✈️!`)
|
|
@@ -15,6 +15,7 @@ export interface Database {
|
|
|
15
15
|
id: number
|
|
16
16
|
key: string
|
|
17
17
|
mode: Database['public']['Enums']['key_mode']
|
|
18
|
+
name: string
|
|
18
19
|
updated_at: string | null
|
|
19
20
|
user_id: string
|
|
20
21
|
}
|
|
@@ -23,6 +24,7 @@ export interface Database {
|
|
|
23
24
|
id?: number
|
|
24
25
|
key: string
|
|
25
26
|
mode: Database['public']['Enums']['key_mode']
|
|
27
|
+
name: string
|
|
26
28
|
updated_at?: string | null
|
|
27
29
|
user_id: string
|
|
28
30
|
}
|
|
@@ -31,6 +33,7 @@ export interface Database {
|
|
|
31
33
|
id?: number
|
|
32
34
|
key?: string
|
|
33
35
|
mode?: Database['public']['Enums']['key_mode']
|
|
36
|
+
name?: string
|
|
34
37
|
updated_at?: string | null
|
|
35
38
|
user_id?: string
|
|
36
39
|
}
|
|
@@ -1638,6 +1641,27 @@ export interface Database {
|
|
|
1638
1641
|
}
|
|
1639
1642
|
Returns: string
|
|
1640
1643
|
}
|
|
1644
|
+
get_versions_with_no_metadata: {
|
|
1645
|
+
Args: Record<PropertyKey, never>
|
|
1646
|
+
Returns: {
|
|
1647
|
+
app_id: string
|
|
1648
|
+
bucket_id: string | null
|
|
1649
|
+
checksum: string | null
|
|
1650
|
+
created_at: string | null
|
|
1651
|
+
deleted: boolean
|
|
1652
|
+
external_url: string | null
|
|
1653
|
+
id: number
|
|
1654
|
+
minUpdateVersion: string | null
|
|
1655
|
+
name: string
|
|
1656
|
+
native_packages: Json[] | null
|
|
1657
|
+
owner_org: string
|
|
1658
|
+
r2_path: string | null
|
|
1659
|
+
session_key: string | null
|
|
1660
|
+
storage_provider: string
|
|
1661
|
+
updated_at: string | null
|
|
1662
|
+
user_id: string | null
|
|
1663
|
+
}[]
|
|
1664
|
+
}
|
|
1641
1665
|
get_weekly_stats: {
|
|
1642
1666
|
Args: {
|
|
1643
1667
|
app_id: string
|
|
@@ -1814,6 +1838,10 @@ export interface Database {
|
|
|
1814
1838
|
Args: Record<PropertyKey, never>
|
|
1815
1839
|
Returns: number[]
|
|
1816
1840
|
}
|
|
1841
|
+
process_failed_uploads: {
|
|
1842
|
+
Args: Record<PropertyKey, never>
|
|
1843
|
+
Returns: undefined
|
|
1844
|
+
}
|
|
1817
1845
|
process_free_trial_expired: {
|
|
1818
1846
|
Args: Record<PropertyKey, never>
|
|
1819
1847
|
Returns: undefined
|
|
@@ -1939,6 +1967,24 @@ export interface Database {
|
|
|
1939
1967
|
| 'decrypt_fail'
|
|
1940
1968
|
| 'app_moved_to_foreground'
|
|
1941
1969
|
| 'app_moved_to_background'
|
|
1970
|
+
| 'uninstall'
|
|
1971
|
+
| 'needPlanUpgrade'
|
|
1972
|
+
| 'missingBundle'
|
|
1973
|
+
| 'noNew'
|
|
1974
|
+
| 'disablePlatformIos'
|
|
1975
|
+
| 'disablePlatformAndroid'
|
|
1976
|
+
| 'disableAutoUpdateToMajor'
|
|
1977
|
+
| 'cannotUpdateViaPrivateChannel'
|
|
1978
|
+
| 'disableAutoUpdateToMinor'
|
|
1979
|
+
| 'disableAutoUpdateToPatch'
|
|
1980
|
+
| 'channelMisconfigured'
|
|
1981
|
+
| 'disableAutoUpdateMetadata'
|
|
1982
|
+
| 'disableAutoUpdateUnderNative'
|
|
1983
|
+
| 'disableDevBuild'
|
|
1984
|
+
| 'disableEmulator'
|
|
1985
|
+
| 'cannotGetBundle'
|
|
1986
|
+
| 'checksum_fail'
|
|
1987
|
+
| 'NoChannelOrOverride'
|
|
1942
1988
|
stripe_status:
|
|
1943
1989
|
| 'created'
|
|
1944
1990
|
| 'succeeded'
|