2025-06-18 18:50:46 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								"use strict" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Object . defineProperty ( exports ,  "__esModule" ,  {  value :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exports . initCommand  =  void  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  tslib _1  =  require ( "tslib" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  open _1  =  tslib _1 . _ _importDefault ( require ( "open" ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  path _1  =  require ( "path" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  colors _1  =  tslib _1 . _ _importDefault ( require ( "../colors" ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  common _1  =  require ( "../common" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  config _1  =  require ( "../config" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  cordova _1  =  require ( "../cordova" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  errors _1  =  require ( "../errors" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  framework _configs _1  =  require ( "../framework-configs" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  log _1  =  require ( "../log" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  sysconfig _1  =  require ( "../sysconfig" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  node _1  =  require ( "../util/node" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  term _1  =  require ( "../util/term" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-06 20:20:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								async  function  initCommand ( config ,  name ,  id ,  webDirFromCLI ,  skipAppIDValidation )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 18:50:46 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    var  _a ,  _b ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( ! ( 0 ,  term _1 . checkInteractive ) ( name ,  id ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( config . app . extConfigType  !==  'json' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ( 0 ,  errors _1 . fatal ) ( ` Cannot run  ${ colors _1 . default . input ( 'init' ) }  for a project using a non-JSON configuration file. \n `  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ` Delete  ${ colors _1 . default . strong ( config . app . extConfigName ) }  and try again. ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  isNewConfig  =  Object . keys ( config . app . extConfig ) . length  ===  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  tsInstalled  =  ! ! ( 0 ,  node _1 . resolveNode ) ( config . app . rootDir ,  'typescript' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  appName  =  await  getName ( config ,  name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  appId  =  await  getAppId ( config ,  id ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  webDir  =  ( 0 ,  term _1 . isInteractive ) ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ?  await  getWebDir ( config ,  webDirFromCLI ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-06 20:20:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            :  ( ( _a  =  webDirFromCLI  !==  null  &&  webDirFromCLI  !==  void  0  ?  webDirFromCLI  :  config . app . extConfig . webDir )  !==  null  &&  _a  !==  void  0  ?  _a  :  'www' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( skipAppIDValidation  ===  true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            await  ( 0 ,  common _1 . check ) ( [ ( )  =>  ( 0 ,  common _1 . checkAppName ) ( config ,  appName ) ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            await  ( 0 ,  common _1 . check ) ( [ ( )  =>  ( 0 ,  common _1 . checkAppName ) ( config ,  appName ) ,  ( )  =>  ( 0 ,  common _1 . checkAppId ) ( config ,  appId ) ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 18:50:46 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        const  cordova  =  await  ( 0 ,  cordova _1 . getCordovaPreferences ) ( config ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        await  runMergeConfig ( config ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            appId , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            appName , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            webDir , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            cordova , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } ,  isNewConfig  &&  tsInstalled  ?  'ts'  :  'json' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    catch  ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( ! ( 0 ,  errors _1 . isFatal ) ( e ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-06 20:20:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            log _1 . output . write ( 'Usage: npx cap init appName appId\n'  +  'Example: npx cap init "My App" "com.example.myapp"\n\n' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 18:50:46 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								            ( 0 ,  errors _1 . fatal ) ( ( _b  =  e . stack )  !==  null  &&  _b  !==  void  0  ?  _b  :  e ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        throw  e ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exports . initCommand  =  initCommand ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								async  function  getName ( config ,  name )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    var  _a ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ! name )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  answers  =  await  ( 0 ,  log _1 . logPrompt ) ( ` ${ colors _1 . default . strong ( ` What is the name of your app? ` ) } \n `  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ` This should be a human-friendly app name, like what you'd see in the App Store. ` ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            type :  'text' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            name :  'name' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            message :  ` Name ` , 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-06 20:20:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            initial :  config . app . appName  ?  config . app . appName  :  ( ( _a  =  config . app . package . name )  !==  null  &&  _a  !==  void  0  ?  _a  :  'App' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 18:50:46 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  answers . name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								async  function  getAppId ( config ,  id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ! id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  answers  =  await  ( 0 ,  log _1 . logPrompt ) ( ` ${ colors _1 . default . strong ( ` What should be the Package ID for your app? ` ) } \n `  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ` Package IDs (aka Bundle ID in iOS and Application ID in Android) are unique identifiers for apps. They must be in reverse domain name notation, generally representing a domain name that you or your company owns. ` ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            type :  'text' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            name :  'id' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            message :  ` Package ID ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            initial :  config . app . appId  ?  config . app . appId  :  'com.example.app' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  answers . id ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  id ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								async  function  getWebDir ( config ,  webDir )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ! webDir )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  framework  =  ( 0 ,  framework _configs _1 . detectFramework ) ( config ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( framework  ===  null  ||  framework  ===  void  0  ?  void  0  :  framework . webDir )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  framework . webDir ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  answers  =  await  ( 0 ,  log _1 . logPrompt ) ( ` ${ colors _1 . default . strong ( ` What is the web asset directory for your app? ` ) } \n `  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ` This directory should contain the final  ${ colors _1 . default . strong ( 'index.html' ) }  of your app. ` ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            type :  'text' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            name :  'webDir' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            message :  ` Web asset directory ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            initial :  config . app . webDir  ?  config . app . webDir  :  'www' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  answers . webDir ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  webDir ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								async  function  runMergeConfig ( config ,  extConfig ,  type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  configDirectory  =  ( 0 ,  path _1 . dirname ) ( config . app . extConfigFilePath ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  newConfigPath  =  ( 0 ,  path _1 . resolve ) ( configDirectory ,  type  ===  'ts'  ?  config _1 . CONFIG _FILE _NAME _TS  :  config _1 . CONFIG _FILE _NAME _JSON ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    await  ( 0 ,  common _1 . runTask ) ( ` Creating  ${ colors _1 . default . strong ( ( 0 ,  path _1 . basename ) ( newConfigPath ) ) }  in  ${ colors _1 . default . input ( config . app . rootDir ) } ` ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        await  mergeConfig ( config ,  extConfig ,  newConfigPath ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    printNextSteps ( ( 0 ,  path _1 . basename ) ( newConfigPath ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ( 0 ,  term _1 . isInteractive ) ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        let  sysconfig  =  await  ( 0 ,  sysconfig _1 . readConfig ) ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( typeof  sysconfig . signup  ===  'undefined' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  signup  =  await  promptToSignup ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            sysconfig  =  {  ... sysconfig ,  signup  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            await  ( 0 ,  sysconfig _1 . writeConfig ) ( sysconfig ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								async  function  mergeConfig ( config ,  extConfig ,  newConfigPath )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  oldConfig  =  {  ... config . app . extConfig  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  newConfig  =  {  ... oldConfig ,  ... extConfig  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    await  ( 0 ,  config _1 . writeConfig ) ( newConfig ,  newConfigPath ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function  printNextSteps ( newConfigName )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ( 0 ,  log _1 . logSuccess ) ( ` ${ colors _1 . default . strong ( newConfigName ) }  created! ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    log _1 . output . write ( ` \n Next steps:  \n ${ colors _1 . default . strong ( ` https://capacitorjs.com/docs/getting-started#where-to-go-next ` ) } \n ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								async  function  promptToSignup ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  answers  =  await  ( 0 ,  log _1 . logPrompt ) ( ` Join the Ionic Community! 💙 \n `  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ` Connect with millions of developers on the Ionic Forum and get access to live events, news updates, and more. ` ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        type :  'confirm' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        name :  'create' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        message :  ` Create free Ionic account? ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        initial :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( answers . create )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ( 0 ,  open _1 . default ) ( ` http://ionicframework.com/signup?source=capacitor ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  answers . create ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}