@@ -6,37 +6,16 @@ import { getBackendAmplifyMeta } from '../utils';
6
6
* Runs `amplify delete`
7
7
*/
8
8
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- export const deleteProject = async ( cwd : string , profileConfig ?: any , usingLatestCodebase = false ) : Promise < void > => {
9
+ export const deleteProject = async ( cwd : string , profileConfig ?: any , usingLatestCodebase = false , noOutputTimeout : number = 1000 * 60 * 20 ) : Promise < void > => {
10
10
// Read the meta from backend otherwise it could fail on non-pushed, just initialized projects
11
- try {
12
- const { StackName : stackName , Region : region } = getBackendAmplifyMeta ( cwd ) . providers . awscloudformation ;
13
- await retry (
14
- ( ) => describeCloudFormationStack ( stackName , region , profileConfig ) ,
15
- stack => stack . StackStatus . endsWith ( '_COMPLETE' ) || stack . StackStatus . endsWith ( '_FAILED' ) ,
16
- ) ;
17
-
18
- const noOutputTimeout = 1000 * 60 * 20 ; // 20 minutes;
19
- return spawn ( getCLIPath ( usingLatestCodebase ) , [ 'delete' ] , { cwd, stripColors : true , noOutputTimeout } )
20
- . wait ( 'Are you sure you want to continue?' )
21
- . sendYes ( )
22
- . wait ( 'Project deleted locally.' )
23
- . runAsync ( ) ;
24
- } catch ( e ) {
25
- console . log ( 'Error on deleting project at:' , cwd ) ;
26
- }
27
- } ;
28
-
29
- export const amplifyDeleteWithLongerTimeout = ( cwd : string , usingLatestCodebase = false ) : Promise < void > => new Promise ( ( resolve , reject ) => {
30
- const noOutputTimeout = 1000 * 60 * 30 ; // 30 minutes;
31
- spawn ( getCLIPath ( usingLatestCodebase ) , [ 'delete' ] , { cwd, stripColors : true , noOutputTimeout } )
11
+ const { StackName : stackName , Region : region } = getBackendAmplifyMeta ( cwd ) . providers . awscloudformation ;
12
+ await retry (
13
+ ( ) => describeCloudFormationStack ( stackName , region , profileConfig ) ,
14
+ stack => stack . StackStatus . endsWith ( '_COMPLETE' ) || stack . StackStatus . endsWith ( '_FAILED' ) ,
15
+ ) ;
16
+ return spawn ( getCLIPath ( usingLatestCodebase ) , [ 'delete' ] , { cwd, stripColors : true , noOutputTimeout } )
32
17
. wait ( 'Are you sure you want to continue?' )
33
18
. sendConfirmYes ( )
34
19
. wait ( 'Project deleted locally.' )
35
- . run ( ( err : Error ) => {
36
- if ( ! err ) {
37
- resolve ( ) ;
38
- } else {
39
- reject ( err ) ;
40
- }
41
- } ) ;
42
- } ) ;
20
+ . runAsync ( ) ;
21
+ } ;
0 commit comments