@@ -293,21 +293,48 @@ function processPackage(done, gitRevision, isReleaseBuild) {
293293 metadata . packageId = pkg . name ;
294294 }
295295
296- const packageJson = new stream . Readable ;
297- packageJson . push ( JSON . stringify ( pkg , undefined , 2 ) ) ;
298- packageJson . push ( null ) ;
299-
300- Object . keys ( pkg )
301- . filter ( key => metadataKeys . includes ( key ) )
302- . forEach ( ( key ) => {
303- metadata [ key ] = pkg [ key ] ;
304- } ) ;
296+ function version_prompt ( ) {
297+ return gulp . src ( '.' )
298+ . pipe ( prompt . prompt ( [ {
299+ type : 'input' ,
300+ name : 'version' ,
301+ message : `Package version (default: ${ pkg . version } ):` ,
302+ } , {
303+ type : 'input' ,
304+ name : 'storeVersion' ,
305+ message : 'Google Play store version (<x.y.z>, default: package version):' ,
306+ } ] , function ( res ) {
307+ if ( res . version ) {
308+ pkg . version = res . version ;
309+ }
310+ if ( res . storeVersion ) {
311+ metadata . storeVersion = res . storeVersion ;
312+ }
313+ } ) ) ;
314+ } ;
305315
306- packageJson
307- . pipe ( source ( 'package.json' ) )
308- . pipe ( gulp . dest ( DIST_DIR ) ) ;
316+ function write_package_file ( ) {
317+ Object . keys ( pkg )
318+ . filter ( key => metadataKeys . includes ( key ) )
319+ . forEach ( ( key ) => {
320+ metadata [ key ] = pkg [ key ] ;
321+ } ) ;
309322
310- done ( ) ;
323+ const packageJson = new stream . Readable ;
324+ packageJson . push ( JSON . stringify ( pkg , undefined , 2 ) ) ;
325+ packageJson . push ( null ) ;
326+
327+ return packageJson
328+ . pipe ( source ( 'package.json' ) )
329+ . pipe ( gulp . dest ( DIST_DIR ) ) ;
330+ } ;
331+
332+ const platforms = getPlatforms ( ) ;
333+ if ( platforms . indexOf ( 'android' ) !== - 1 && isReleaseBuild ) {
334+ gulp . series ( version_prompt , write_package_file ) ( done ) ;
335+ } else {
336+ gulp . series ( write_package_file ) ( done ) ;
337+ }
311338}
312339
313340function dist_src ( ) {
@@ -466,7 +493,7 @@ function debug(done) {
466493 buildNWAppsWrapper ( platforms , 'sdk' , DEBUG_DIR , done ) ;
467494}
468495
469- function injectARMCache ( flavor , callback ) {
496+ function injectARMCache ( flavor , done ) {
470497 const flavorPostfix = `-${ flavor } ` ;
471498 const flavorDownloadPostfix = flavor !== 'normal' ? `-${ flavor } ` : '' ;
472499 clean_cache ( ) . then ( function ( ) {
@@ -529,7 +556,7 @@ function injectARMCache(flavor, callback) {
529556 clean_debug ( ) ;
530557 process . exit ( 1 ) ;
531558 }
532- callback ( ) ;
559+ done ( ) ;
533560 }
534561 ) ;
535562 }
@@ -593,10 +620,10 @@ function buildNWApps(platforms, flavor, dir, done) {
593620
594621function getGitRevision ( done , callback , isReleaseBuild ) {
595622 let gitRevision = 'norevision' ;
596- git . diff ( [ '--shortstat' ] , function ( err , diff ) {
597- if ( ! err && ! diff ) {
598- git . log ( [ '-1' , '--pretty=format:%h' ] , function ( err , rev ) {
599- if ( ! err ) {
623+ git . diff ( [ '--shortstat' ] , function ( err1 , diff ) {
624+ if ( ! err1 && ! diff ) {
625+ git . log ( [ '-1' , '--pretty=format:%h' ] , function ( err2 , rev ) {
626+ if ( ! err2 ) {
600627 gitRevision = rev . latest . hash ;
601628 }
602629
@@ -881,7 +908,7 @@ function listReleaseTasks(isReleaseBuild, appDirectory) {
881908}
882909
883910// Cordova
884- function cordova_dist ( isReleaseBuild ) {
911+ function cordova_dist ( ) {
885912 const distTasks = [ ] ;
886913 const platforms = getPlatforms ( ) ;
887914 if ( platforms . indexOf ( 'android' ) !== - 1 ) {
@@ -995,7 +1022,7 @@ function cordova_manifestjson() {
9951022}
9961023
9971024function cordova_configxml ( ) {
998- let androidName = metadata . packageId . replace ( NAME_REGEX , '_' ) ;
1025+ const androidName = metadata . packageId . replace ( NAME_REGEX , '_' ) ;
9991026
10001027 return gulp . src ( [ `${ CORDOVA_DIST_DIR } config.xml` ] )
10011028 . pipe ( xmlTransformer ( [
@@ -1005,37 +1032,18 @@ function cordova_configxml() {
10051032 ] , 'http://www.w3.org/ns/widgets' ) )
10061033 . pipe ( xmlTransformer ( [
10071034 { path : '.' , attr : { 'id' : `com.betaflight.${ androidName } ` } } ,
1008- { path : '.' , attr : { 'version' : metadata . version } } ,
1035+ { path : '.' , attr : { 'version' : metadata . storeVersion ? metadata . storeVersion : metadata . version } } ,
10091036 ] ) )
10101037 . pipe ( gulp . dest ( CORDOVA_DIST_DIR ) ) ;
10111038}
10121039
1013- function cordova_debug_configxml ( ) {
1014- return cordova_configxml_internal ( ) ;
1015- }
1016-
1017- function cordova_configxml ( callback ) {
1018- return gulp . series ( function version_prompt ( ) {
1019- return gulp . src ( '.' )
1020- . pipe ( prompt . prompt ( {
1021- type : 'input' ,
1022- name : 'version' ,
1023- message : `Bundle version (default: ${ metadata . version } ):` ,
1024- } , function ( res ) {
1025- if ( res . version ) {
1026- metadata . version = res . version ;
1027- }
1028- } ) ) ;
1029- } , cordova_configxml_internal ) ( callback ) ;
1030- }
1031-
10321040function cordova_rename_build_json ( ) {
10331041 return gulp . src ( `${ CORDOVA_DIR } build_template.json` )
10341042 . pipe ( rename ( 'build.json' ) )
10351043 . pipe ( gulp . dest ( CORDOVA_DIST_DIR ) ) ;
10361044}
10371045
1038- function cordova_browserify ( callback ) {
1046+ function cordova_browserify ( done ) {
10391047 const readFile = function ( file ) {
10401048 return new Promise ( function ( resolve ) {
10411049 if ( ! file . includes ( "node_modules" ) ) {
@@ -1053,7 +1061,7 @@ function cordova_browserify(callback) {
10531061 glob ( `${ CORDOVA_DIST_DIR } www/**/*.js` , { } , function ( err , files ) {
10541062 const readLoop = function ( ) {
10551063 if ( files . length === 0 ) {
1056- callback ( ) ;
1064+ done ( ) ;
10571065 } else {
10581066 const file = files . pop ( ) ;
10591067 readFile ( file ) . then ( function ( ) {
@@ -1092,7 +1100,7 @@ function cordova_debug() {
10921100 cordova . run ( ) ;
10931101}
10941102
1095- function cordova_debug_build ( cb ) {
1103+ function cordova_debug_build ( done ) {
10961104 cordova . build ( {
10971105 'platforms' : [ 'android' ] ,
10981106 'options' : {
@@ -1101,13 +1109,14 @@ function cordova_debug_build(cb) {
11011109 } ,
11021110 } ) . then ( function ( ) {
11031111 process . chdir ( '../' ) ;
1104- cb ( ) ;
1105- } ) ;
11061112
1107- console . log ( `APK will be generated at ${ CORDOVA_DIST_DIR } platforms/android/app/build/outputs/apk/release/app-release.apk` ) ;
1113+ console . log ( `APK has been generated at ${ CORDOVA_DIST_DIR } platforms/android/app/build/outputs/apk/release/app-release.apk` ) ;
1114+
1115+ done ( ) ;
1116+ } ) ;
11081117}
11091118
1110- function cordova_build ( callback ) {
1119+ function cordova_build ( done ) {
11111120 let storePassword = '' ;
11121121 return gulp . series ( function password_prompt ( ) {
11131122 return gulp . src ( '.' )
@@ -1124,11 +1133,11 @@ function cordova_build(callback) {
11241133 'android' : {
11251134 'release' : {
11261135 'storePassword' : storePassword ,
1127- }
1128- }
1136+ } ,
1137+ } ,
11291138 } ) )
11301139 . pipe ( gulp . dest ( './' ) ) ;
1131- } , function build ( cb ) {
1140+ } , function build ( done ) {
11321141 return cordova . build ( {
11331142 'platforms' : [ 'android' ] ,
11341143 'options' : {
@@ -1139,24 +1148,28 @@ function cordova_build(callback) {
11391148 // Delete the file containing the store password
11401149 del ( [ 'build.json' ] , { force : true } ) ;
11411150 process . chdir ( '../' ) ;
1142- cb ( ) ;
1143- } ) ;
1144- } ) ( callback ) ;
11451151
1146- console . log ( 'AAB will be generated at dist_cordova/platforms/android/app/build/outputs/bundle/release/app.aab' ) ;
1152+ console . log ( 'AAB has been generated at dist_cordova/platforms/android/app/build/outputs/bundle/release/app.aab' ) ;
1153+ done ( ) ;
1154+ } ) ;
1155+ } ) ( done ) ;
11471156}
11481157
11491158async function cordova_debug_release ( ) {
1150- const filename = await getReleaseFilename ( 'android' , 'apk' ) ;
1159+ const filename = getReleaseFilename ( 'android' , 'apk' ) ;
1160+
11511161 console . log ( `Release APK : release/${ filename } ` ) ;
1162+
11521163 return gulp . src ( `${ CORDOVA_DIST_DIR } platforms/android/app/build/outputs/apk/debug/app-debug.apk` )
11531164 . pipe ( rename ( filename ) )
11541165 . pipe ( gulp . dest ( RELEASE_DIR ) ) ;
11551166}
11561167
11571168async function cordova_release ( ) {
1158- const filename = await getReleaseFilename ( 'android' , 'aab' ) ;
1169+ const filename = getReleaseFilename ( 'android' , 'aab' ) ;
1170+
11591171 console . log ( `Release AAB : release/${ filename } ` ) ;
1172+
11601173 return gulp . src ( `${ CORDOVA_DIST_DIR } platforms/android/app/build/outputs/bundle/release/app.aab` )
11611174 . pipe ( rename ( filename ) )
11621175 . pipe ( gulp . dest ( RELEASE_DIR ) ) ;
0 commit comments