@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.
- package/CHANGELOG.md +10 -0
- package/bun.lockb +0 -0
- package/capacitor.config.ts +2 -2
- package/dist/index.js +652 -655
- 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 -117
- 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/init.ts
CHANGED
|
@@ -1,299 +1,301 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import type { ExecSyncOptions } from 'node:child_process'
|
|
3
|
+
import { execSync, spawnSync } from 'node:child_process'
|
|
4
|
+
import process from 'node:process'
|
|
3
5
|
import { findPackageManagerType } from '@capgo/find-package-manager'
|
|
4
|
-
import * as p from '@clack/prompts'
|
|
5
|
-
import { SupabaseClient } from '@supabase/supabase-js'
|
|
6
|
-
import LogSnag from 'logsnag'
|
|
6
|
+
import * as p from '@clack/prompts'
|
|
7
|
+
import type { SupabaseClient } from '@supabase/supabase-js'
|
|
8
|
+
import type LogSnag from 'logsnag'
|
|
7
9
|
import semver from 'semver'
|
|
8
|
-
import { Database } from './types/supabase.types'
|
|
9
|
-
import { markSnag
|
|
10
|
-
import { createKey } from './key'
|
|
11
|
-
import { addChannel } from './channel/add'
|
|
12
|
-
import { uploadBundle } from './bundle/upload'
|
|
13
|
-
import { login } from './login'
|
|
14
|
-
import { addApp } from './app/add'
|
|
15
|
-
import { checkLatest } from './api/update'
|
|
16
|
-
import { Options } from './api/app'
|
|
17
|
-
import { convertAppName, createSupabaseClient, findMainFile, findSavedKey, getConfig, useLogSnag, verifyUser } from './utils'
|
|
10
|
+
import type { Database } from './types/supabase.types'
|
|
11
|
+
import { markSnag, waitLog } from './app/debug'
|
|
12
|
+
import { createKey } from './key'
|
|
13
|
+
import { addChannel } from './channel/add'
|
|
14
|
+
import { uploadBundle } from './bundle/upload'
|
|
15
|
+
import { login } from './login'
|
|
16
|
+
import { addApp } from './app/add'
|
|
17
|
+
import { checkLatest } from './api/update'
|
|
18
|
+
import type { Options } from './api/app'
|
|
19
|
+
import { convertAppName, createSupabaseClient, findMainFile, findSavedKey, getConfig, useLogSnag, verifyUser } from './utils'
|
|
18
20
|
|
|
19
21
|
interface SuperOptions extends Options {
|
|
20
|
-
|
|
22
|
+
local: boolean
|
|
21
23
|
}
|
|
22
|
-
const importInject =
|
|
24
|
+
const importInject = 'import { CapacitorUpdater } from \'@capgo/capacitor-updater\''
|
|
23
25
|
const codeInject = 'CapacitorUpdater.notifyAppReady()'
|
|
24
26
|
// create regex to find line who start by 'import ' and end by ' from '
|
|
25
27
|
const regexImport = /import.*from.*/g
|
|
26
28
|
const defaultChannel = 'production'
|
|
27
29
|
const execOption = { stdio: 'pipe' }
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
async function cancelCommand(command: boolean | symbol, userId: string, snag: LogSnag) {
|
|
32
|
+
if (p.isCancel(command)) {
|
|
33
|
+
await markSnag('onboarding-v2', userId, snag, 'canceled', '🤷')
|
|
34
|
+
process.exit()
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
async function markStep(userId: string, snag: LogSnag, step: number | string) {
|
|
39
|
+
return markSnag('onboarding-v2', userId, snag, `onboarding-step-${step}`)
|
|
40
|
+
}
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
async function step2(userId: string, snag: LogSnag, appId: string, options: SuperOptions) {
|
|
43
|
+
const doAdd = await p.confirm({ message: `Add ${appId} in Capgo?` })
|
|
44
|
+
await cancelCommand(doAdd, userId, snag)
|
|
45
|
+
if (doAdd) {
|
|
46
|
+
const s = p.spinner()
|
|
47
|
+
s.start(`Running: npx @capgo/cli@latest app add ${appId}`)
|
|
48
|
+
const addRes = await addApp(appId, options, false)
|
|
49
|
+
if (!addRes)
|
|
50
|
+
s.stop(`App already add ✅`)
|
|
51
|
+
else
|
|
52
|
+
s.stop(`App add Done ✅`)
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
p.log.info(`Run yourself "npx @capgo/cli@latest app add ${appId}"`)
|
|
56
|
+
}
|
|
57
|
+
await markStep(userId, snag, 2)
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
await markStep(userId, snag, 3)
|
|
60
|
+
async function step3(userId: string, snag: LogSnag, apikey: string, appId: string) {
|
|
61
|
+
const doChannel = await p.confirm({ message: `Create default channel ${defaultChannel} for ${appId} in Capgo?` })
|
|
62
|
+
await cancelCommand(doChannel, userId, snag)
|
|
63
|
+
if (doChannel) {
|
|
64
|
+
const s = p.spinner()
|
|
65
|
+
// create production channel public
|
|
66
|
+
s.start(`Running: npx @capgo/cli@latest channel add ${defaultChannel} ${appId} --default`)
|
|
67
|
+
const addChannelRes = await addChannel(defaultChannel, appId, {
|
|
68
|
+
default: true,
|
|
69
|
+
apikey,
|
|
70
|
+
}, false)
|
|
71
|
+
if (!addChannelRes)
|
|
72
|
+
s.stop(`Channel already added ✅`)
|
|
73
|
+
else
|
|
74
|
+
s.stop(`Channel add Done ✅`)
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
p.log.info(`Run yourself "npx @capgo/cli@latest channel add ${defaultChannel} ${appId} --default"`)
|
|
78
|
+
}
|
|
79
|
+
await markStep(userId, snag, 3)
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
const urlMigrateV5 = 'https://capacitorjs.com/docs/updating/5-0'
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
s.stop(`Capgo already installed ✅`)
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
await execSync(`${pm} ${installCmd} @capgo/capacitor-updater@latest`, execOption as ExecSyncOptions)
|
|
114
|
-
s.stop(`Install Done ✅`);
|
|
115
|
-
}
|
|
83
|
+
async function step4(userId: string, snag: LogSnag, apikey: string, appId: string) {
|
|
84
|
+
const doInstall = await p.confirm({ message: `Automatic Install "@capgo/capacitor-updater" dependency in ${appId}?` })
|
|
85
|
+
await cancelCommand(doInstall, userId, snag)
|
|
86
|
+
if (doInstall) {
|
|
87
|
+
const s = p.spinner()
|
|
88
|
+
s.start(`Checking if @capgo/capacitor-updater is installed`)
|
|
89
|
+
const pack = JSON.parse(readFileSync('package.json').toString())
|
|
90
|
+
let coreVersion = pack.dependencies['@capacitor/core'] || pack.devDependencies['@capacitor/core']
|
|
91
|
+
coreVersion = coreVersion?.replace('^', '').replace('~', '')
|
|
92
|
+
if (!coreVersion) {
|
|
93
|
+
s.stop(`Cannot find @capacitor/core in package.json, please run \`capgo init\` in a capacitor project`)
|
|
94
|
+
process.exit()
|
|
95
|
+
}
|
|
96
|
+
else if (semver.lt(coreVersion, '5.0.0')) {
|
|
97
|
+
s.stop(`@capacitor/core version is ${coreVersion}, please update to Capacitor v5 first: ${urlMigrateV5}`)
|
|
98
|
+
process.exit()
|
|
99
|
+
}
|
|
100
|
+
const pm = findPackageManagerType()
|
|
101
|
+
if (pm === 'unknown') {
|
|
102
|
+
s.stop(`Cannot reconize package manager, please run \`capgo init\` in a capacitor project with npm, pnpm or yarn`)
|
|
103
|
+
process.exit()
|
|
104
|
+
}
|
|
105
|
+
// // use pm to install capgo
|
|
106
|
+
// // run command pm install @capgo/capacitor-updater@latest
|
|
107
|
+
const installCmd = pm === 'yarn' ? 'add' : 'install'
|
|
108
|
+
// check if capgo is already installed in package.json
|
|
109
|
+
if (pack.dependencies['@capgo/capacitor-updater']) {
|
|
110
|
+
s.stop(`Capgo already installed ✅`)
|
|
116
111
|
}
|
|
117
112
|
else {
|
|
118
|
-
|
|
113
|
+
await execSync(`${pm} ${installCmd} @capgo/capacitor-updater@latest`, execOption as ExecSyncOptions)
|
|
114
|
+
s.stop(`Install Done ✅`)
|
|
119
115
|
}
|
|
120
|
-
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
p.log.info(`Run yourself "npm i @capgo/capacitor-updater@latest"`)
|
|
119
|
+
}
|
|
120
|
+
await markStep(userId, snag, 4)
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
123
|
+
async function step5(userId: string, snag: LogSnag, apikey: string, appId: string) {
|
|
124
|
+
const doAddCode = await p.confirm({ message: `Automatic Add "${codeInject}" code and import in ${appId}?` })
|
|
125
|
+
await cancelCommand(doAddCode, userId, snag)
|
|
126
|
+
if (doAddCode) {
|
|
127
|
+
const s = p.spinner()
|
|
128
|
+
s.start(`Adding @capacitor-updater to your main file`)
|
|
129
|
+
const mainFilePath = await findMainFile()
|
|
130
|
+
if (!mainFilePath) {
|
|
131
|
+
s.stop('No main.ts, main.js, index.ts or index.js file found, You need to add @capgo/capacitor-updater manually')
|
|
132
|
+
process.exit()
|
|
133
|
+
}
|
|
134
|
+
// open main file and inject codeInject
|
|
135
|
+
const mainFile = readFileSync(mainFilePath)
|
|
136
|
+
// find the last import line in the file and inject codeInject after it
|
|
137
|
+
const mainFileContent = mainFile.toString()
|
|
138
|
+
const matches = mainFileContent.match(regexImport)
|
|
139
|
+
const last = matches?.pop()
|
|
140
|
+
if (!last) {
|
|
141
|
+
s.stop(`Cannot find import line in main file, use manual installation: https://capgo.app/docs/plugin/installation/`)
|
|
142
|
+
process.exit()
|
|
143
|
+
}
|
|
145
144
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
} else {
|
|
149
|
-
const newMainFileContent = mainFileContent.replace(last, `${last}\n${importInject};\n\n${codeInject};\n`)
|
|
150
|
-
writeFileSync(mainFilePath, newMainFileContent);
|
|
151
|
-
s.stop(`Code added to ${mainFilePath} ✅`);
|
|
152
|
-
}
|
|
153
|
-
await markStep(userId, snag, 5)
|
|
145
|
+
if (mainFileContent.includes(codeInject)) {
|
|
146
|
+
s.stop(`Code already added to ${mainFilePath} ✅`)
|
|
154
147
|
}
|
|
155
148
|
else {
|
|
156
|
-
|
|
149
|
+
const newMainFileContent = mainFileContent.replace(last, `${last}\n${importInject};\n\n${codeInject};\n`)
|
|
150
|
+
writeFileSync(mainFilePath, newMainFileContent)
|
|
151
|
+
s.stop(`Code added to ${mainFilePath} ✅`)
|
|
157
152
|
}
|
|
153
|
+
await markStep(userId, snag, 5)
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
p.log.info(`Add to your main file the following code:\n\n${importInject};\n\n${codeInject};\n`)
|
|
157
|
+
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
markSnag('onboarding-v2', userId, snag, 'Use encryption')
|
|
160
|
+
async function step6(userId: string, snag: LogSnag, apikey: string, appId: string) {
|
|
161
|
+
const doEncrypt = await p.confirm({ message: `Automatic configure end-to-end encryption in ${appId} updates?` })
|
|
162
|
+
await cancelCommand(doEncrypt, userId, snag)
|
|
163
|
+
if (doEncrypt) {
|
|
164
|
+
const s = p.spinner()
|
|
165
|
+
s.start(`Running: npx @capgo/cli@latest key create`)
|
|
166
|
+
const keyRes = await createKey({}, false)
|
|
167
|
+
if (!keyRes) {
|
|
168
|
+
s.stop(`Cannot create key ❌`)
|
|
169
|
+
process.exit(1)
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
s.stop(`key created 🔑`)
|
|
175
173
|
}
|
|
176
|
-
|
|
174
|
+
markSnag('onboarding-v2', userId, snag, 'Use encryption')
|
|
175
|
+
}
|
|
176
|
+
await markStep(userId, snag, 6)
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
process.exit()
|
|
191
|
-
}
|
|
192
|
-
execSync(`npm run build && npx cap sync`, execOption as ExecSyncOptions)
|
|
193
|
-
s.stop(`Build & Sync Done ✅`);
|
|
194
|
-
} else {
|
|
195
|
-
p.log.info(`Build yourself with command: npm run build && npx cap sync`)
|
|
179
|
+
async function step7(userId: string, snag: LogSnag, apikey: string, appId: string) {
|
|
180
|
+
const doBuild = await p.confirm({ message: `Automatic build ${appId} with "npm run build" ?` })
|
|
181
|
+
await cancelCommand(doBuild, userId, snag)
|
|
182
|
+
if (doBuild) {
|
|
183
|
+
const s = p.spinner()
|
|
184
|
+
s.start(`Running: npm run build && npx cap sync`)
|
|
185
|
+
const pack = JSON.parse(readFileSync('package.json').toString())
|
|
186
|
+
// check in script build exist
|
|
187
|
+
if (!pack.scripts?.build) {
|
|
188
|
+
s.stop(`Cannot find build script in package.json, please add it and run \`capgo init\` again`)
|
|
189
|
+
process.exit()
|
|
196
190
|
}
|
|
197
|
-
|
|
191
|
+
execSync(`npm run build && npx cap sync`, execOption as ExecSyncOptions)
|
|
192
|
+
s.stop(`Build & Sync Done ✅`)
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
p.log.info(`Build yourself with command: npm run build && npx cap sync`)
|
|
196
|
+
}
|
|
197
|
+
await markStep(userId, snag, 7)
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
process.exit()
|
|
214
|
-
} else {
|
|
215
|
-
s.stop(`Upload Done ✅`);
|
|
216
|
-
}
|
|
217
|
-
} else {
|
|
218
|
-
p.log.info(`Upload yourself with command: npx @capgo/cli@latest bundle upload`)
|
|
200
|
+
async function step8(userId: string, snag: LogSnag, apikey: string, appId: string) {
|
|
201
|
+
const doBundle = await p.confirm({ message: `Automatic upload ${appId} bundle to Capgo?` })
|
|
202
|
+
await cancelCommand(doBundle, userId, snag)
|
|
203
|
+
if (doBundle) {
|
|
204
|
+
const s = p.spinner()
|
|
205
|
+
s.start(`Running: npx @capgo/cli@latest bundle upload`)
|
|
206
|
+
const uploadRes = await uploadBundle(appId, {
|
|
207
|
+
channel: defaultChannel,
|
|
208
|
+
apikey,
|
|
209
|
+
}, false)
|
|
210
|
+
if (!uploadRes) {
|
|
211
|
+
s.stop(`Upload failed ❌`)
|
|
212
|
+
process.exit()
|
|
219
213
|
}
|
|
220
|
-
|
|
214
|
+
else {
|
|
215
|
+
s.stop(`Upload Done ✅`)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
p.log.info(`Upload yourself with command: npx @capgo/cli@latest bundle upload`)
|
|
220
|
+
}
|
|
221
|
+
await markStep(userId, snag, 8)
|
|
221
222
|
}
|
|
222
223
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
224
|
+
async function step9(userId: string, snag: LogSnag) {
|
|
225
|
+
const doRun = await p.confirm({ message: `Run in device now ?` })
|
|
226
|
+
await cancelCommand(doRun, userId, snag)
|
|
227
|
+
if (doRun) {
|
|
228
|
+
const plaformType = await p.select({
|
|
229
|
+
message: 'Pick a platform to run your app',
|
|
230
|
+
options: [
|
|
231
|
+
{ value: 'ios', label: 'IOS' },
|
|
232
|
+
{ value: 'android', label: 'Android' },
|
|
233
|
+
],
|
|
234
|
+
})
|
|
235
|
+
if (p.isCancel(plaformType))
|
|
236
|
+
process.exit()
|
|
237
|
+
|
|
238
|
+
const platform = plaformType as 'ios' | 'android'
|
|
239
|
+
const s = p.spinner()
|
|
240
|
+
s.start(`Running: npx cap run ${platform}`)
|
|
241
|
+
await spawnSync('npx', ['cap', 'run', platform], { stdio: 'inherit' })
|
|
242
|
+
s.stop(`Started Done ✅`)
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
p.log.info(`Run yourself with command: npx cap run <ios|android>`)
|
|
246
|
+
}
|
|
247
|
+
await markStep(userId, snag, 9)
|
|
246
248
|
}
|
|
247
249
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
250
|
+
async function step10(userId: string, snag: LogSnag, supabase: SupabaseClient<Database>, appId: string) {
|
|
251
|
+
const doRun = await p.confirm({ message: `Automatic check if update working in device ?` })
|
|
252
|
+
await cancelCommand(doRun, userId, snag)
|
|
253
|
+
if (doRun) {
|
|
254
|
+
p.log.info(`Wait logs sent to Capgo from ${appId} device, Put the app in background and open it again.`)
|
|
255
|
+
p.log.info('Waiting...')
|
|
256
|
+
await waitLog('onboarding-v2', supabase, appId, snag, userId)
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
const appIdUrl = convertAppName(appId)
|
|
260
|
+
p.log.info(`Check logs in https://web.capgo.app/app/p/${appIdUrl}/logs to see if update works.`)
|
|
261
|
+
}
|
|
262
|
+
await markStep(userId, snag, 10)
|
|
261
263
|
}
|
|
262
264
|
|
|
263
|
-
export
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
265
|
+
export async function initApp(apikey: string, appId: string, options: SuperOptions) {
|
|
266
|
+
p.intro(`Capgo onboarding 🛫`)
|
|
267
|
+
await checkLatest()
|
|
268
|
+
const snag = useLogSnag()
|
|
269
|
+
const config = await getConfig()
|
|
270
|
+
appId = appId || config?.app?.appId
|
|
271
|
+
apikey = apikey || findSavedKey()
|
|
270
272
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
const supabase = await createSupabaseClient(apikey)
|
|
280
|
-
const userId = await verifyUser(supabase, apikey, ['upload', 'all', 'read', 'write']);
|
|
281
|
-
await markStep(userId, snag, 1)
|
|
273
|
+
const log = p.spinner()
|
|
274
|
+
log.start('Running: npx @capgo/cli@latest login ***')
|
|
275
|
+
const loginRes = await login(apikey, options, false)
|
|
276
|
+
if (!loginRes)
|
|
277
|
+
log.stop('Login already done ✅')
|
|
278
|
+
else
|
|
279
|
+
log.stop('Login Done ✅')
|
|
282
280
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
await step5(userId, snag, apikey, appId)
|
|
287
|
-
await step6(userId, snag, apikey, appId)
|
|
288
|
-
await step7(userId, snag, apikey, appId)
|
|
289
|
-
await step8(userId, snag, apikey, appId)
|
|
290
|
-
await step9(userId, snag)
|
|
291
|
-
await step10(userId, snag, supabase, appId)
|
|
281
|
+
const supabase = await createSupabaseClient(apikey)
|
|
282
|
+
const userId = await verifyUser(supabase, apikey, ['upload', 'all', 'read', 'write'])
|
|
283
|
+
await markStep(userId, snag, 1)
|
|
292
284
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
285
|
+
await step2(userId, snag, appId, options)
|
|
286
|
+
await step3(userId, snag, apikey, appId)
|
|
287
|
+
await step4(userId, snag, apikey, appId)
|
|
288
|
+
await step5(userId, snag, apikey, appId)
|
|
289
|
+
await step6(userId, snag, apikey, appId)
|
|
290
|
+
await step7(userId, snag, apikey, appId)
|
|
291
|
+
await step8(userId, snag, apikey, appId)
|
|
292
|
+
await step9(userId, snag)
|
|
293
|
+
await step10(userId, snag, supabase, appId)
|
|
294
|
+
|
|
295
|
+
await markStep(userId, snag, 0)
|
|
296
|
+
p.log.info(`Welcome onboard ✈️!`)
|
|
297
|
+
p.log.info(`Your Capgo update system is setup`)
|
|
298
|
+
p.log.info(`Next time use \`npx @capgo/cli@latest bundle upload\` to only upload your bundle`)
|
|
299
|
+
p.outro(`Bye 👋`)
|
|
300
|
+
process.exit()
|
|
299
301
|
}
|