@@ -54,7 +54,6 @@ proto.existPackageHashAndCreateVersions = function (deploymentId, appVersion, pa
5454 return models . DeploymentsVersions . create ( {
5555 deployment_id : deploymentId ,
5656 app_version : appVersion ,
57- is_mandatory : false ,
5857 } ) . then ( function ( ) {
5958 return false ;
6059 } ) ;
@@ -91,7 +90,6 @@ proto.createPackage = function (deploymentId, appVersion, packageHash, manifestH
9190 . then ( function ( deploymentsVersions ) {
9291 if ( ! deploymentsVersions ) {
9392 return models . DeploymentsVersions . create ( {
94- is_mandatory : isMandatory ,
9593 current_package_id : 0 ,
9694 deployment_id : deploymentId ,
9795 app_version : appVersion
@@ -111,11 +109,11 @@ proto.createPackage = function (deploymentId, appVersion, packageHash, manifestH
111109 release_method : releaseMethod ,
112110 label : "v" + labelId ,
113111 released_by : releaseUid ,
112+ is_mandatory : isMandatory ,
114113 original_label : originalLabel ,
115114 original_deployment : originalDeployment
116115 } , { transaction : t } )
117116 . then ( function ( packages ) {
118- deploymentsVersions . set ( 'is_mandatory' , isMandatory ) ;
119117 deploymentsVersions . set ( 'current_package_id' , packages . id ) ;
120118 return Promise . all ( [
121119 deploymentsVersions . save ( { transaction : t } ) ,
@@ -275,7 +273,7 @@ proto.releasePackage = function (deploymentId, packageInfo, fileType, filePath,
275273 var self = this ;
276274 var appVersion = packageInfo . appVersion ;
277275 if ( ! / ^ ( [ 0 - 9 . ] + ) $ / . test ( appVersion ) ) {
278- return Promise . reject ( new Error ( `targetBinaryVersion not support.` ) )
276+ return Promise . reject ( new Error ( `targetBinaryVersion ${ appVersion } not support.` ) )
279277 }
280278 var description = packageInfo . description ;
281279 var isMandatory = packageInfo . isMandatory ;
@@ -352,6 +350,36 @@ proto.releasePackage = function (deploymentId, packageInfo, fileType, filePath,
352350 } ) ;
353351} ;
354352
353+ proto . modifyReleasePackage = function ( deploymentId , deploymentVersionId , packageInfo ) {
354+ var appVersion = _ . get ( packageInfo , 'appVersion' ) ;
355+ var description = _ . get ( packageInfo , 'description' ) ;
356+ var isMandatory = _ . get ( packageInfo , 'isMandatory' ) ;
357+ var isDisabled = _ . get ( packageInfo , 'isDisabled' ) ;
358+ return models . DeploymentsVersions . findById ( deploymentVersionId )
359+ . then ( function ( deploymentsVersions ) {
360+ if ( _ . isBoolean ( isDisabled ) ) {
361+ throw new Error ( `--disabled -x function is not implements` ) ;
362+ }
363+ if ( ! appVersion ) {
364+ if ( ! / ^ ( [ 0 - 9 . ] + ) $ / . test ( appVersion ) ) {
365+ return Promise . reject ( new Error ( `targetBinaryVersion ${ appVersion } not support.` ) )
366+ }
367+ return models . DeploymentsVersions . findOne ( { deployment_id : deploymentId , app_version : appVersion } )
368+ . then ( function ( d ) {
369+ if ( d ) {
370+ throw new Error ( `version ${ appVersion } already exist` ) ;
371+ }
372+ } ) ;
373+ }
374+ if ( ! deploymentsVersions ) {
375+ throw new Error ( `packages were not found in db` ) ;
376+ }
377+ } )
378+ . then ( function ( ) {
379+
380+ } ) ;
381+ } ;
382+
355383proto . promotePackage = function ( sourceDeploymentId , destDeploymentId , promoteUid ) {
356384 var self = this ;
357385 return models . Deployments . findById ( sourceDeploymentId )
@@ -387,7 +415,7 @@ proto.promotePackage = function (sourceDeploymentId, destDeploymentId, promoteUi
387415 var params = {
388416 releaseMethod : 'Promote' ,
389417 releaseUid : promoteUid ,
390- isMandatory : deploymentsVersions . is_mandatory ,
418+ isMandatory : packages . is_mandatory == 1 ? true : false ,
391419 size : packages . size ,
392420 description : packages . description ,
393421 originalLabel : packages . label ,
@@ -432,7 +460,7 @@ proto.rollbackPackage = function (deploymentVersionId, targetLabel, rollbackUid)
432460 var params = {
433461 releaseMethod : 'Rollback' ,
434462 releaseUid : rollbackUid ,
435- isMandatory : deploymentsVersions . is_mandatory ,
463+ isMandatory : rollbackPackage . is_mandatory == 1 ? true : false ,
436464 size : rollbackPackage . size ,
437465 description : rollbackPackage . description ,
438466 originalLabel : rollbackPackage . label ,
0 commit comments