@@ -129,15 +129,9 @@ export default class Apigw {
129129 apiList,
130130 customDomains,
131131 usagePlan,
132- isInputServiceId = false ,
132+ isRemoveTrigger = false ,
133133 } = inputs ;
134134
135- // 如果用户 yaml 的 inputs 配置了 serviceId,走特殊流程
136- if ( isInputServiceId ) {
137- await this . removeWithInputServiceId ( inputs ) ;
138- return ;
139- }
140-
141135 // check service exist
142136 const detail = await this . request ( {
143137 Action : 'DescribeService' ,
@@ -148,6 +142,20 @@ export default class Apigw {
148142 return ;
149143 }
150144
145+ // 1. remove all apis
146+ await this . api . bulkRemove ( {
147+ apiList,
148+ serviceId,
149+ environment,
150+ } ) ;
151+
152+ // 定制化需求:如果用户在yaml中配置了 serviceId,则只执行删除 api 逻辑
153+ // 删除后需要重新发布
154+ if ( isRemoveTrigger ) {
155+ await this . service . release ( { serviceId, environment } ) ;
156+ return ;
157+ }
158+
151159 // remove usage plan
152160 if ( usagePlan ) {
153161 await this . usagePlan . remove ( {
@@ -157,13 +165,6 @@ export default class Apigw {
157165 } ) ;
158166 }
159167
160- // 1. remove all apis
161- await this . api . bulkRemove ( {
162- apiList,
163- serviceId,
164- environment,
165- } ) ;
166-
167168 // 2. unbind all custom domains
168169 if ( customDomains ) {
169170 for ( let i = 0 ; i < customDomains . length ; i ++ ) {
@@ -231,29 +232,6 @@ export default class Apigw {
231232
232233 return outputs ;
233234 }
234-
235- // 定制化需求:如果用户在yaml中配置了 serviceId,则只执行删除 api 逻辑
236- async removeWithInputServiceId ( inputs : ApigwRemoveInputs ) {
237- const { environment, serviceId, apiList } = inputs ;
238-
239- // check service exist
240- const detail = await this . request ( {
241- Action : 'DescribeService' ,
242- ServiceId : serviceId ,
243- } ) ;
244-
245- if ( ! detail ) {
246- console . log ( `Service ${ serviceId } not exist` ) ;
247- return ;
248- }
249-
250- // 1. remove all apis
251- await this . api . bulkRemove ( {
252- apiList,
253- serviceId,
254- environment,
255- } ) ;
256- }
257235}
258236
259237module . exports = Apigw ;
0 commit comments