@@ -21,38 +21,63 @@ export namespace ProjectService {
2121 await _createProject ( testProject ) ;
2222 await _renameTestProject ( ) ;
2323 }
24+ export async function prepareProject ( plugin : MarketplaceService . PluginModel ) {
25+ try {
26+ await _copyTestProject ( testProject ) ;
27+ await _installPlugin ( plugin . name , testProject , _isDev ( plugin . name ) ) ;
28+ } catch ( errExec ) {
29+ Logger . error ( JSON . stringify ( errExec ) ) ;
30+ }
31+ }
2432
25- export async function testPlugin ( plugin : MarketplaceService . PluginModel ) {
33+ export async function cleanProject ( ) {
34+ try {
35+ await new Promise ( ( resolve ) => {
36+ setTimeout ( ( ) => {
37+ resolve ( ) ;
38+ } , 2000 ) ;
39+ } ) ;
40+ await _removeDirectory ( path . join ( testDirectory , testProject ) ) ;
41+ } catch ( errExec ) {
42+ Logger . error ( JSON . stringify ( errExec ) ) ;
43+ }
44+ }
45+
46+ export async function testWebpack ( plugin : MarketplaceService . PluginModel ) {
47+ return await testPlugin ( plugin , '--bundle' ) ;
48+ }
49+
50+ export async function testBuild ( plugin : MarketplaceService . PluginModel ) {
51+ return await testPlugin ( plugin , '' ) ;
52+ }
53+
54+ async function testPlugin ( plugin : MarketplaceService . PluginModel , options : string ) {
2655 const result = { android : false , ios : false } ;
2756 let hasPlatform = false ;
2857 try {
29- await _copyTestProject ( testProject ) ;
30- await _installPlugin ( plugin . name , testProject , _isDev ( plugin . name ) ) ;
3158 if ( plugin . badges . androidVersion ) {
32- result . android = ! ! ( await _buildProject ( testProject , 'android' ) ) ;
59+ result . android = ! ! ( await _buildProject ( testProject , 'android' , options ) ) ;
3360 hasPlatform = true ;
3461 }
3562
3663 if ( plugin . badges . iosVersion ) {
37- result . ios = ! ! ( await _buildProject ( testProject , 'ios' ) ) ;
64+ result . ios = ! ! ( await _buildProject ( testProject , 'ios' , options ) ) ;
3865 hasPlatform = true ;
3966 }
4067
4168 if ( ! hasPlatform ) {
4269 Logger . error ( 'plugin has no platform' ) ;
4370 }
44-
45- await _removeDirectory ( path . join ( testDirectory , testProject ) ) ;
4671 } catch ( errExec ) {
4772 Logger . error ( JSON . stringify ( errExec ) ) ;
4873 }
4974 return result ;
5075 }
5176
52- async function _buildProject ( projectName : string , platform : string ) {
77+ async function _buildProject ( projectName : string , platform : string , options : string ) {
5378 Logger . debug ( `building project for ${ platform } ...` ) ;
5479 const cwd = path . join ( testDirectory , projectName ) ;
55- const result = await execPromise ( cwd , `tns build ${ platform } --bundle ` ) ;
80+ const result = await execPromise ( cwd , `tns build ${ platform } ${ options } ` ) ;
5681 return result ;
5782 }
5883
0 commit comments