@@ -12,6 +12,7 @@ import { checkVersionStatus } from '../api/update'
1212import { addAppInternal } from '../app/add'
1313import { markSnag , waitLog } from '../app/debug'
1414import { canUseFilePicker , openPackageJsonPicker } from '../build/onboarding/file-picker'
15+ import { getPlatformDirFromCapacitorConfig } from '../build/platform-paths'
1516import { uploadBundleInternal } from '../bundle/upload'
1617import { addChannelInternal } from '../channel/add'
1718import { writeConfigUpdater } from '../config'
@@ -1371,9 +1372,15 @@ async function addUpdaterStep(orgId: string, apikey: string, appId: string) {
13711372 const pm = getPMAndCommand ( )
13721373 let pkgVersion = '1.0.0'
13731374 let delta = false
1374- const doInstall = await pConfirm ( { message : `Automatic Install "@capgo/capacitor-updater" dependency in ${ appId } ?` } )
1375- await cancelCommand ( doInstall , orgId , apikey )
1376- if ( doInstall ) {
1375+ const installChoice = await pSelect ( {
1376+ message : `Install @capgo/capacitor-updater in your project?` ,
1377+ options : [
1378+ { value : 'yes' , label : '✅ Yes, install it' } ,
1379+ { value : 'no' , label : '❌ No, I\'ll do it manually' } ,
1380+ ] ,
1381+ } )
1382+ await cancelCommand ( installChoice , orgId , apikey )
1383+ if ( installChoice === 'yes' ) {
13771384 while ( true ) {
13781385 const s = pSpinner ( )
13791386 let versionToInstall = 'latest'
@@ -1462,10 +1469,16 @@ async function addUpdaterStep(orgId: string, apikey: string, appId: string) {
14621469}
14631470
14641471async function addCodeStep ( orgId : string , apikey : string , appId : string ) {
1465- const doAddCode = await pConfirm ( { message : `Automatic Add "${ codeInject } " code and import in ${ appId } ?` } )
1466- await cancelCommand ( doAddCode , orgId , apikey )
1472+ const addCodeChoice = await pSelect ( {
1473+ message : `Add the Capacitor Updater import to your main file?` ,
1474+ options : [
1475+ { value : 'yes' , label : '✅ Yes, add it' } ,
1476+ { value : 'no' , label : '❌ No, I\'ll do it manually' } ,
1477+ ] ,
1478+ } )
1479+ await cancelCommand ( addCodeChoice , orgId , apikey )
14671480
1468- if ( doAddCode ) {
1481+ if ( addCodeChoice === 'yes' ) {
14691482 const s = pSpinner ( )
14701483 s . start ( `Adding @capacitor-updater to your main file` )
14711484
@@ -2305,6 +2318,46 @@ export async function initApp(apikeyCommand: string, appId: string, options: Sup
23052318 localSupaAnon : options . supaAnon ,
23062319 } )
23072320 }
2321+ // Warn if this doesn't look like a Capacitor project
2322+ const hasCapacitorConfig = capacitorConfigFiles . some ( file => existsSync ( join ( cwd ( ) , file ) ) )
2323+ if ( ! hasCapacitorConfig ) {
2324+ pLog . warn ( '⚠️ No capacitor.config.* found in the current directory.' )
2325+ pLog . info ( ' Capgo requires a Capacitor project. Make sure you run this from your project root.' )
2326+ pLog . info ( ' Learn more: https://capacitorjs.com/docs/getting-started' )
2327+ const continueAnyway = await pSelect ( {
2328+ message : 'Continue anyway?' ,
2329+ options : [
2330+ { value : 'yes' , label : '✅ Yes, continue' } ,
2331+ { value : 'no' , label : '❌ No, exit' } ,
2332+ ] ,
2333+ } )
2334+ if ( pIsCancel ( continueAnyway ) || continueAnyway === 'no' ) {
2335+ pOutro ( 'Bye 👋' )
2336+ exit ( )
2337+ }
2338+ }
2339+ else {
2340+ const iosDir = getPlatformDirFromCapacitorConfig ( extConfig ?. config , 'ios' )
2341+ const androidDir = getPlatformDirFromCapacitorConfig ( extConfig ?. config , 'android' )
2342+ const hasIos = existsSync ( join ( cwd ( ) , iosDir ) )
2343+ const hasAndroid = existsSync ( join ( cwd ( ) , androidDir ) )
2344+ if ( ! hasIos && ! hasAndroid ) {
2345+ pLog . warn ( '⚠️ No native platform directories found (ios/ or android/).' )
2346+ pLog . info ( ' Run "npx cap add ios" or "npx cap add android" to add a platform.' )
2347+ const continueWithout = await pSelect ( {
2348+ message : 'Continue without native platforms? Later steps may not work.' ,
2349+ options : [
2350+ { value : 'yes' , label : '✅ Yes, continue anyway' } ,
2351+ { value : 'no' , label : '❌ No, I\'ll add a platform first' } ,
2352+ ] ,
2353+ } )
2354+ if ( pIsCancel ( continueWithout ) || continueWithout === 'no' ) {
2355+ pOutro ( 'Bye 👋\n💡 Run "npx cap add ios" or "npx cap add android", then try again.' )
2356+ exit ( )
2357+ }
2358+ }
2359+ }
2360+
23082361 const localConfig = await getLocalConfig ( )
23092362 appId = getAppId ( appId , extConfig ?. config )
23102363 options . apikey = apikeyCommand
0 commit comments