@@ -13,7 +13,7 @@ import { loadConfig } from "../config.js";
1313import { createGitMeta } from "../utilities/gitMeta.js" ;
1414import { printStandloneInitialBanner } from "../utilities/initialBanner.js" ;
1515import { logger } from "../utilities/logger.js" ;
16- import { getProjectClient } from "../utilities/session.js" ;
16+ import { getProjectClient , LoginResultOk } from "../utilities/session.js" ;
1717import { spinner } from "../utilities/windows.js" ;
1818import { verifyDirectory } from "./deploy.js" ;
1919import { login } from "./login.js" ;
@@ -119,17 +119,28 @@ async function _previewArchiveCommand(dir: string, options: PreviewCommandOption
119119 ) ;
120120 }
121121
122- const apiClient = new CliApiClient ( authorization . auth . apiUrl , authorization . auth . accessToken ) ;
123-
124122 const $buildSpinner = spinner ( ) ;
125123 $buildSpinner . start ( `Archiving "${ branch } "` ) ;
124+ const result = await archivePreviewBranch ( authorization , branch , resolvedConfig . project ) ;
125+ $buildSpinner . stop (
126+ result ? `Successfully archived "${ branch } "` : `Failed to archive "${ branch } ".`
127+ ) ;
128+ return result ;
129+ }
130+
131+ export async function archivePreviewBranch (
132+ authorization : LoginResultOk ,
133+ branch : string ,
134+ project : string
135+ ) {
136+ const apiClient = new CliApiClient ( authorization . auth . apiUrl , authorization . auth . accessToken ) ;
126137
127- const result = await apiClient . archiveBranch ( resolvedConfig . project , branch ) ;
138+ const result = await apiClient . archiveBranch ( project , branch ) ;
128139
129140 if ( result . success ) {
130- $buildSpinner . stop ( `Successfully archived " ${ branch } "` ) ;
141+ return true ;
131142 } else {
132- $buildSpinner . stop ( `Failed to archive "${ branch } ".` ) ;
133143 logger . error ( result . error ) ;
144+ return false ;
134145 }
135146}
0 commit comments