@capgo/cli 4.0.12 → 4.0.14

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/src/init.ts CHANGED
@@ -1,299 +1,301 @@
1
- import { writeFileSync, readFileSync } from 'node:fs';
2
- import { execSync, ExecSyncOptions, spawnSync } from 'child_process';
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 , waitLog } from './app/debug';
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
- local: boolean;
22
+ local: boolean
21
23
  }
22
- const importInject = "import { CapacitorUpdater } from '@capgo/capacitor-updater'";
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
- const cancelCommand = async (command: boolean | symbol, userId: string, snag: LogSnag) => {
30
- if (p.isCancel(command)) {
31
- await markSnag('onboarding-v2', userId, snag, 'canceled', '🤷')
32
- process.exit()
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
- const markStep = async (userId: string, snag: LogSnag, step: number | string) =>
37
- markSnag('onboarding-v2', userId, snag, `onboarding-step-${step}`)
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
- const step2 = async (userId: string, snag: LogSnag, appId: string, options: SuperOptions) => {
40
- const doAdd = await p.confirm({ message: `Add ${appId} in Capgo?` });
41
- await cancelCommand(doAdd, userId, snag);
42
- if (doAdd) {
43
- const s = p.spinner();
44
- s.start(`Running: npx @capgo/cli@latest app add ${appId}`);
45
- const addRes = await addApp(appId, options, false);
46
- if (!addRes) {
47
- s.stop(`App already add ✅`);
48
- } else {
49
- s.stop(`App add Done ✅`);
50
- }
51
- } else {
52
- p.log.info(`Run yourself "npx @capgo/cli@latest app add ${appId}"`)
53
- }
54
- await markStep(userId, snag, 2)
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
- const step3 = async (userId: string, snag: LogSnag,
58
- apikey: string, appId: string) => {
59
- const doChannel = await p.confirm({ message: `Create default channel ${defaultChannel} for ${appId} in Capgo?` });
60
- await cancelCommand(doChannel, userId, snag);
61
- if (doChannel) {
62
- const s = p.spinner();
63
- // create production channel public
64
- s.start(`Running: npx @capgo/cli@latest channel add ${defaultChannel} ${appId} --default`);
65
- const addChannelRes = await addChannel(defaultChannel, appId, {
66
- default: true,
67
- apikey,
68
- }, false);
69
- if (!addChannelRes) {
70
- s.stop(`Channel already added ✅`);
71
- } else {
72
- s.stop(`Channel add Done ✅`);
73
- }
74
- }
75
- else {
76
- p.log.info(`Run yourself "npx @capgo/cli@latest channel add ${defaultChannel} ${appId} --default"`)
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
- const step4 = async (userId: string, snag: LogSnag,
83
- apikey: string, appId: string,) => {
84
-
85
- const doInstall = await p.confirm({ message: `Automatic Install "@capgo/capacitor-updater" dependency in ${appId}?` });
86
- await cancelCommand(doInstall, userId, snag);
87
- if (doInstall) {
88
- const s = p.spinner();
89
- s.start(`Checking if @capgo/capacitor-updater is installed`);
90
- const pack = JSON.parse(readFileSync('package.json').toString());
91
- let coreVersion = pack.dependencies['@capacitor/core'] || pack.devDependencies['@capacitor/core']
92
- coreVersion = coreVersion?.replace('^', '').replace('~', '')
93
- if (!coreVersion) {
94
- s.stop(`Cannot find @capacitor/core in package.json, please run \`capgo init\` in a capacitor project`)
95
- process.exit()
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 ✅`)
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
- p.log.info(`Run yourself "npm i @capgo/capacitor-updater@latest"`)
113
+ await execSync(`${pm} ${installCmd} @capgo/capacitor-updater@latest`, execOption as ExecSyncOptions)
114
+ s.stop(`Install Done ✅`)
119
115
  }
120
- await markStep(userId, snag, 4)
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
- const step5 = async (userId: string, snag: LogSnag,
124
- apikey: string, appId: string) => {
125
- const doAddCode = await p.confirm({ message: `Automatic Add "${codeInject}" code and import in ${appId}?` });
126
- await cancelCommand(doAddCode, userId, snag);
127
- if (doAddCode) {
128
- const s = p.spinner();
129
- s.start(`Adding @capacitor-updater to your main file`);
130
- const mainFilePath = await findMainFile();
131
- if (!mainFilePath) {
132
- s.stop('No main.ts, main.js, index.ts or index.js file found, You need to add @capgo/capacitor-updater manually');
133
- process.exit()
134
- }
135
- // open main file and inject codeInject
136
- const mainFile = readFileSync(mainFilePath);
137
- // find the last import line in the file and inject codeInject after it
138
- const mainFileContent = mainFile.toString();
139
- const matches = mainFileContent.match(regexImport);
140
- const last = matches?.pop();
141
- if (!last) {
142
- s.stop(`Cannot find import line in main file, use manual installation: https://capgo.app/docs/plugin/installation/`)
143
- process.exit()
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
- if (mainFileContent.includes(codeInject)) {
147
- s.stop(`Code already added to ${mainFilePath} ✅`)
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
- p.log.info(`Add to your main file the following code:\n\n${importInject};\n\n${codeInject};\n`)
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
- const step6 = async (userId: string, snag: LogSnag,
161
- apikey: string, appId: string) => {
162
- const doEncrypt = await p.confirm({ message: `Automatic configure end-to-end encryption in ${appId} updates?` });
163
- await cancelCommand(doEncrypt, userId, snag);
164
- if (doEncrypt) {
165
- const s = p.spinner();
166
- s.start(`Running: npx @capgo/cli@latest key create`);
167
- const keyRes = await createKey({}, false);
168
- if (!keyRes) {
169
- s.stop(`Cannot create key ❌`);
170
- process.exit(1)
171
- } else {
172
- s.stop(`key created 🔑`);
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
- await markStep(userId, snag, 6)
174
+ markSnag('onboarding-v2', userId, snag, 'Use encryption')
175
+ }
176
+ await markStep(userId, snag, 6)
177
177
  }
178
178
 
179
- const step7 = async (userId: string, snag: LogSnag,
180
- apikey: string, appId: string) => {
181
- const doBuild = await p.confirm({ message: `Automatic build ${appId} with "npm run build" ?` });
182
- await cancelCommand(doBuild, userId, snag);
183
- if (doBuild) {
184
- const s = p.spinner();
185
- s.start(`Running: npm run build && npx cap sync`);
186
- const pack = JSON.parse(readFileSync('package.json').toString());
187
- // check in script build exist
188
- if (!pack.scripts?.build) {
189
- s.stop(`Cannot find build script in package.json, please add it and run \`capgo init\` again`)
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
- await markStep(userId, snag, 7)
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
- const step8 = async (userId: string, snag: LogSnag,
201
- apikey: string, appId: string) => {
202
- const doBundle = await p.confirm({ message: `Automatic upload ${appId} bundle to Capgo?` });
203
- await cancelCommand(doBundle, userId, snag);
204
- if (doBundle) {
205
- const s = p.spinner();
206
- s.start(`Running: npx @capgo/cli@latest bundle upload`);
207
- const uploadRes = await uploadBundle(appId, {
208
- channel: defaultChannel,
209
- apikey,
210
- }, false);
211
- if (!uploadRes) {
212
- s.stop(`Upload failed ❌`);
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
- await markStep(userId, snag, 8)
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
- const step9 = async (userId: string, snag: LogSnag) => {
224
- const doRun = await p.confirm({ message: `Run in device now ?` });
225
- await cancelCommand(doRun, userId, snag);
226
- if (doRun) {
227
- const plaformType = await p.select({
228
- message: 'Pick a platform to run your app',
229
- options: [
230
- { value: 'ios', label: 'IOS' },
231
- { value: 'android', label: 'Android' },
232
- ],
233
- });
234
- if (p.isCancel(plaformType)) {
235
- process.exit()
236
- }
237
- const platform = plaformType as 'ios' | 'android'
238
- const s = p.spinner();
239
- s.start(`Running: npx cap run ${platform}`);
240
- await spawnSync('npx', ['cap', 'run', platform], { stdio: 'inherit' });
241
- s.stop(`Started Done ✅`);
242
- } else {
243
- p.log.info(`Run yourself with command: npx cap run <ios|android>`)
244
- }
245
- await markStep(userId, snag, 9)
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
- const step10 = async (userId: string, snag: LogSnag,
249
- supabase: SupabaseClient<Database>, appId: string) => {
250
- const doRun = await p.confirm({ message: `Automatic check if update working in device ?` });
251
- await cancelCommand(doRun, userId, snag);
252
- if (doRun) {
253
- p.log.info(`Wait logs sent to Capgo from ${appId} device, Put the app in background and open it again.`)
254
- p.log.info('Waiting...');
255
- await waitLog('onboarding-v2', supabase, appId, snag, userId);
256
- } else {
257
- const appIdUrl = convertAppName(appId)
258
- p.log.info(`Check logs in https://web.capgo.app/app/p/${appIdUrl}/logs to see if update works.`)
259
- }
260
- await markStep(userId, snag, 10)
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 const initApp = async (apikey: string, appId: string, options: SuperOptions) => {
264
- p.intro(`Capgo onboarding 🛫`);
265
- await checkLatest();
266
- const snag = useLogSnag()
267
- const config = await getConfig();
268
- appId = appId || config?.app?.appId
269
- apikey = apikey || findSavedKey()
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
- const log = p.spinner();
272
- log.start('Running: npx @capgo/cli@latest login ***');
273
- const loginRes = await login(apikey, options, false);
274
- if (!loginRes) {
275
- log.stop('Login already done ✅');
276
- } else {
277
- log.stop('Login Done ✅');
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
- await step2(userId, snag, appId, options)
284
- await step3(userId, snag, apikey, appId)
285
- await step4(userId, snag, apikey, appId)
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
- await markStep(userId, snag, 0)
294
- p.log.info(`Welcome onboard ✈️!`);
295
- p.log.info(`Your Capgo update system is setup`);
296
- p.log.info(`Next time use \`npx @capgo/cli@latest bundle upload\` to only upload your bundle`);
297
- p.outro(`Bye 👋`);
298
- process.exit()
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
  }