@@ -145,18 +145,46 @@ export class ProjectService implements IProjectService {
145145
146146 public createPlatformSpecificProject ( platform : string ) : IFuture < void > {
147147 return ( ( ) => {
148+ this . executePlatformSpecificAction ( platform , "createProject" ) . wait ( ) ;
149+ } ) . future < void > ( ) ( ) ;
150+ }
151+
152+ public prepareProject ( platform : string ) : IFuture < void > {
153+ return ( ( ) => {
154+ this . executePlatformSpecificAction ( platform , "prepareProject" ) . wait ( ) ;
155+ } ) . future < void > ( ) ( ) ;
156+ }
157+
158+ public buildProject ( platform : string ) : IFuture < void > {
159+ return ( ( ) => {
160+ this . executePlatformSpecificAction ( platform , "buildProject" ) . wait ( ) ;
161+ } ) . future < void > ( ) ( ) ;
162+ }
163+
164+ private executePlatformSpecificAction ( platform , functionName : string ) : IFuture < void > {
165+ return ( ( ) => {
148166 switch ( platform ) {
149167 case "android" :
150- // TODO: set default values for project name and project id
151- this . $androidProjectService . createProject ( this . projectData ) . wait ( ) ;
168+ this . executeFunctionByName ( functionName , this . $androidProjectService , [ this . projectData ] ) . wait ( ) ;
152169 break ;
153170 case "ios" :
154- this . $iOSProjectService . createProject ( this . projectData ) . wait ( ) ;
171+ this . executeFunctionByName ( functionName , this . $iOSProjectService , [ this . projectData ] ) . wait ( ) ;
155172 break ;
156173 }
157174 } ) . future < void > ( ) ( ) ;
158175 }
159176
177+ private executeFunctionByName ( functionName , context , args : any [ ] ) : IFuture < any > {
178+ return ( ( ) => {
179+ var namespaces = functionName . split ( "." ) ;
180+ var func = namespaces . pop ( ) ;
181+ for ( var i = 0 ; i < namespaces . length ; i ++ ) {
182+ context = context [ namespaces [ i ] ] ;
183+ }
184+ return context [ func ] . apply ( context , args ) . wait ( ) ;
185+ } ) . future < any > ( ) ( ) ;
186+ }
187+
160188 private getCustomAppPath ( ) : string {
161189 var customAppPath = options [ "copy-from" ] || options [ "link-to" ] ;
162190 if ( customAppPath ) {
@@ -221,23 +249,28 @@ class AndroidProjectService implements IAndroidProjectService {
221249 shell . sed ( '-i' , / _ _ N A M E _ _ / , projectData . projectName , path . join ( projectDir , '.project' ) ) ;
222250 shell . sed ( '-i' , / _ _ P A C K A G E _ _ / , packageName , path . join ( projectDir , "AndroidManifest.xml" ) ) ;
223251
224- // Copy app into assets
225- shell . cp ( "-r" , path . join ( projectData . projectDir , ProjectService . APP_FOLDER_NAME ) , path . join ( projectDir , "assets" ) ) ;
226-
227252 this . runAndroidUpdate ( projectDir , targetApi ) . wait ( ) ;
228253
229254 this . $logger . out ( "Project successfully created." ) ;
230255
231256 } ) . future < any > ( ) ( ) ;
232257 }
233258
259+ public prepareProject ( projectData : IProjectData ) : IFuture < void > {
260+ return ( ( ) => {
261+ var projectDir = path . join ( projectData . projectDir , "platforms" , "android" ) ;
262+ // Copy app into assets
263+ shell . cp ( "-r" , path . join ( projectData . projectDir , ProjectService . APP_FOLDER_NAME ) , path . join ( projectDir , "assets" ) ) ;
264+ } ) . future < void > ( ) ( ) ;
265+ }
266+
234267 private runAndroidUpdate ( projectPath : string , targetApi ) : IFuture < void > {
235268 return ( ( ) => {
236269 this . $childProcess . exec ( "android update project --subprojects --path " + projectPath + " --target " + targetApi ) . wait ( ) ;
237270 } ) . future < void > ( ) ( ) ;
238271 }
239272
240- private validatePackageName ( packageName : string ) : boolean {
273+ private validatePackageName ( packageName : string ) : void {
241274 //Make the package conform to Java package types
242275 //Enforce underscore limitation
243276 if ( ! / ^ [ a - z A - Z ] + ( \. [ a - z A - Z 0 - 9 ] [ a - z A - Z 0 - 9 _ ] * ) + $ / . test ( packageName ) ) {
@@ -248,11 +281,9 @@ class AndroidProjectService implements IAndroidProjectService {
248281 if ( / \b [ C c ] l a s s \b / . test ( packageName ) ) {
249282 this . $errors . fail ( "class is a reserved word" ) ;
250283 }
251-
252- return true ;
253284 }
254285
255- private validateProjectName ( projectName : string ) : boolean {
286+ private validateProjectName ( projectName : string ) : void {
256287 if ( projectName === '' ) {
257288 this . $errors . fail ( "Project name cannot be empty" ) ;
258289 }
@@ -261,8 +292,6 @@ class AndroidProjectService implements IAndroidProjectService {
261292 if ( / ^ [ 0 - 9 ] / . test ( projectName ) ) {
262293 this . $errors . fail ( "Project name must not begin with a number" ) ;
263294 }
264-
265- return true ;
266295 }
267296
268297 private get frameworkDir ( ) : string {
0 commit comments