@@ -11,8 +11,9 @@ const testProject = 'baseNG';
1111const testProjectOriginalSuffix = '_original' ;
1212
1313export namespace ProjectService {
14-
15- export async function setup ( ) {
14+ export let cloudEnabled = false ;
15+ export async function setup ( cloud : boolean ) {
16+ cloudEnabled = cloud ;
1617 if ( existsSync ( testDirectory ) ) {
1718 await _removeDirectory ( testDirectory ) ;
1819 }
@@ -44,41 +45,56 @@ export namespace ProjectService {
4445 }
4546
4647 export async function testWebpack ( plugin : MarketplaceService . PluginModel ) {
47- return await testPlugin ( plugin , '--bundle' ) ;
48+ return await testPlugin ( plugin , {
49+ android : '--bundle' ,
50+ ios : '--bundle'
51+ } ) ;
4852 }
4953
5054 export async function testSnapshot ( plugin : MarketplaceService . PluginModel ) {
51- return await testPlugin ( plugin , '--bundle --release --env.snapshot --key-store-path ~/.android/debug.keystore --key-store-password android --key-store-alias androiddebugkey --key-store-alias-password android' ) ;
55+ const signKeystore = cloudEnabled ? '../../debug.p12' : '~/.android/debug.keystore' ;
56+ return await testPlugin ( plugin , {
57+ android : `--bundle --release --env.snapshot --key-store-path ${ signKeystore } --key-store-password android --key-store-alias androiddebugkey --key-store-alias-password android`
58+ } ) ;
5259 }
5360
5461 export async function testUglify ( plugin : MarketplaceService . PluginModel ) {
55- return await testPlugin ( plugin , '--bundle --env.uglify' ) ;
62+ return await testPlugin ( plugin , {
63+ android : '--bundle --env.uglify' ,
64+ ios : '--bundle --env.uglify'
65+ } ) ;
5666 }
5767
5868 export async function testAot ( plugin : MarketplaceService . PluginModel ) {
59- return await testPlugin ( plugin , '--bundle --env.aot' ) ;
69+ return await testPlugin ( plugin , {
70+ android : '--bundle --env.aot' ,
71+ ios : '--bundle --env.aot'
72+ } ) ;
6073 }
6174
6275 export async function testBuild ( plugin : MarketplaceService . PluginModel ) {
63- return await testPlugin ( plugin , '' ) ;
76+ return await testPlugin ( plugin , {
77+ android : ' ' ,
78+ ios : ' '
79+ } ) ;
6480 }
6581
66- async function testPlugin ( plugin : MarketplaceService . PluginModel , options : string ) {
82+ async function testPlugin ( plugin : MarketplaceService . PluginModel , options : { android ?: string , ios ?: string } ) {
6783 const result = { android : false , ios : false } ;
6884 let skipBuild = false ;
6985 try {
7086 skipBuild = ! plugin . badges . androidVersion && plugin . badges . iosVersion ;
71- if ( ! skipBuild ) {
72- result . android = ! ! ( await _buildProject ( testProject , 'android' , options ) ) ;
87+ if ( ! skipBuild && options . android ) {
88+ result . android = ! ! ( await _buildProject ( testProject , 'android' , options . android ) ) ;
7389 } else {
74- Logger . error ( 'Skipping android build! Plugin only has ios support.' ) ;
90+ Logger . error ( 'Skipping android build! Plugin only has ios support or no options supplied .' ) ;
7591 }
7692
7793 skipBuild = ! plugin . badges . iosVersion && plugin . badges . androidVersion ;
78- if ( ! skipBuild ) {
79- result . ios = ! ! ( await _buildProject ( testProject , 'ios' , options ) ) ;
94+ if ( ! skipBuild && options . ios ) {
95+ result . ios = ! ! ( await _buildProject ( testProject , 'ios' , options . ios ) ) ;
8096 } else {
81- Logger . error ( 'Skipping ios build! Plugin only has android support.' ) ;
97+ Logger . error ( 'Skipping ios build! Plugin only has android support or no options supplied .' ) ;
8298 }
8399 } catch ( errExec ) {
84100 Logger . error ( JSON . stringify ( errExec ) ) ;
@@ -89,7 +105,11 @@ export namespace ProjectService {
89105 async function _buildProject ( projectName : string , platform : string , options : string ) {
90106 Logger . debug ( `building project for ${ platform } ...` ) ;
91107 const cwd = path . join ( testDirectory , projectName ) ;
92- const result = await execPromise ( cwd , `tns build ${ platform } ${ options } ` ) ;
108+ if ( platform === 'ios' && cloudEnabled ) {
109+ options += ' --provision /tns-official/CodeSign/ios/Icenium_QA_Development.mobileprovision --certificate /tns-official/CodeSign/ios/iPhone\\ Developer\\ Dragon\\ Telerikov\\ \\(GNKAEXW8YQ\\).p12 --certificatePassword 1' ;
110+ }
111+ const command = cloudEnabled ? `tns cloud build ${ platform } --accountId 1 ${ options } ` : `tns build ${ platform } ${ options } ` ;
112+ const result = await execPromise ( cwd , command ) ;
93113 return result ;
94114 }
95115
@@ -162,9 +182,12 @@ export namespace ProjectService {
162182
163183 async function _renameTestProject ( ) {
164184 return new Promise ( ( resolve , reject ) => {
165- rename ( path . join ( testDirectory , testProject ) , path . join ( testDirectory , testProject + testProjectOriginalSuffix ) , err => {
166- return err ? reject ( err ) : resolve ( ) ;
167- } ) ;
185+ setTimeout ( ( ) => {
186+ rename ( path . join ( testDirectory , testProject ) , path . join ( testDirectory , testProject + testProjectOriginalSuffix ) , err => {
187+ return err ? reject ( err ) : resolve ( ) ;
188+ } ) ;
189+ } , 2000 ) ;
190+
168191 } ) ;
169192 }
170193
0 commit comments