Skip to content

Commit 8f197c7

Browse files
committed
fix: command to recreate
1 parent adc9568 commit 8f197c7

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/init.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { getRepoStarStatus, isRepoStarredInSession, starAllRepositories, starRep
1818
import { createKeyInternal } from './key'
1919
import { doLoginExists, loginInternal } from './login'
2020
import { showReplicationProgress } from './replicationProgress'
21-
import { createSupabaseClient, findBuildCommandForProjectType, findMainFile, findMainFileForProjectType, findProjectType, findRoot, findSavedKey, formatError, getAllPackagesDependencies, getAppId, getBundleVersion, getConfig, getInstalledVersion, getLocalConfig, getOrganization, getPackageScripts, getPMAndCommand, PACKNAME, projectIsMonorepo, updateConfigbyKey, updateConfigUpdater, validateIosUpdaterSync, verifyUser } from './utils'
21+
import { createSupabaseClient, findBuildCommandForProjectType, findMainFile, findMainFileForProjectType, findProjectType, findRoot, findSavedKey, formatError, getAllPackagesDependencies, getAppId, getBundleVersion, getConfig, getInstalledVersion, getLocalConfig, getNativeProjectResetAdvice, getOrganization, getPackageScripts, getPMAndCommand, PACKNAME, projectIsMonorepo, updateConfigbyKey, updateConfigUpdater, validateIosUpdaterSync, verifyUser } from './utils'
2222

2323
interface SuperOptions extends Options {
2424
local: boolean
@@ -188,13 +188,14 @@ async function saveAppIdToCapacitorConfig(appId: string) {
188188
}
189189

190190
function stopForBrokenIosSync(platformRunner: string, details: string[]): never {
191+
const resetAdvice = getNativeProjectResetAdvice(platformRunner, 'ios')
191192
pLog.error('Capgo iOS dependency sync verification failed.')
192193
for (const detail of details) {
193194
pLog.error(detail)
194195
}
195196
pLog.error('Stop here to avoid testing on a broken native iOS project.')
196-
pLog.warn('Best fix: run this in your terminal to reset iOS and sync again.')
197-
pLog.info(`${platformRunner} cap rm ios && ${platformRunner} cap add ios && ${platformRunner} cap sync ios`)
197+
pLog.warn(resetAdvice.summary)
198+
pLog.info(resetAdvice.command)
198199
pOutro('After reset, run the same `capgo init ...` command to resume onboarding from where you left off (no need to redo previous steps).')
199200
exit(1)
200201
}

src/utils.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,14 @@ export function getPMAndCommand() {
15501550
return { pm, command: pmCommand, installCommand: `${pm} ${pmCommand}`, runner: pmRunner }
15511551
}
15521552

1553+
export function getNativeProjectResetAdvice(platformRunner: string, nativePlatform: 'ios' | 'android') {
1554+
const nativeLabel = nativePlatform === 'ios' ? 'iOS' : 'Android'
1555+
return {
1556+
summary: `Best fix: recreate and sync ${nativeLabel} with this one-line command.`,
1557+
command: `rm -rf ${nativePlatform} && ${platformRunner} cap add ${nativePlatform} && ${platformRunner} cap sync ${nativePlatform}`,
1558+
}
1559+
}
1560+
15531561
function readDirRecursively(dir: string): string[] {
15541562
const entries = readdirSync(dir, { withFileTypes: true })
15551563
const files = entries.flatMap((entry) => {
@@ -2264,15 +2272,16 @@ export async function promptAndSyncCapacitor(
22642272
if (options?.validateIosUpdater) {
22652273
const syncValidation = validateIosUpdaterSync(cwd(), options.packageJsonPath)
22662274
if (syncValidation.shouldCheck && !syncValidation.valid) {
2275+
const resetAdvice = getNativeProjectResetAdvice(pm.runner, 'ios')
22672276
s.stop('iOS sync check failed ❌')
22682277
log.error('Capgo iOS dependency sync verification failed.')
22692278
for (const detail of syncValidation.details) {
22702279
log.error(detail)
22712280
}
22722281
log.error('Stop here to avoid testing on a broken native iOS project.')
2273-
log.warn('Best fix: run this in your terminal to reset iOS and sync again.')
2274-
log.info(`${pm.runner} cap rm ios && ${pm.runner} cap add ios && ${pm.runner} cap sync ios`)
2275-
throw new Error('iOS sync validation failed. Reset your iOS folder with the one-line command above and retry.')
2282+
log.warn(resetAdvice.summary)
2283+
log.info(resetAdvice.command)
2284+
throw new Error('iOS sync validation failed. Delete your iOS folder, then rerun the add and sync commands above and retry.')
22762285
}
22772286
}
22782287

0 commit comments

Comments
 (0)