1- import { printJson } from '../../utils/output.ts' ;
21import { AppError } from '../../utils/errors.ts' ;
3- import {
4- serializeDeployResult ,
5- serializeInstallFromSourceResult ,
6- } from '../../cli-serializers.ts' ;
7- import { readCommandMessage } from '../../utils/success-text.ts' ;
2+ import { serializeDeployResult , serializeInstallFromSourceResult } from '../../cli-serializers.ts' ;
83import type { CliFlags } from '../../utils/command-schema.ts' ;
94import type { AgentDeviceClient , AppDeployResult } from '../../client.ts' ;
10- import { buildSelectionOptions } from './shared.ts' ;
5+ import { buildSelectionOptions , writeCommandMessage } from './shared.ts' ;
116import type { ClientCommandHandler } from './router.ts' ;
127
138export const installCommand : ClientCommandHandler = async ( { positionals, flags, client } ) => {
149 const result = await runDeployCommand ( 'install' , positionals , flags , client ) ;
1510 const data = serializeDeployResult ( result ) ;
16- if ( flags . json ) printJson ( { success : true , data } ) ;
17- else writeHumanMessage ( data ) ;
11+ writeCommandMessage ( flags , data ) ;
1812 return true ;
1913} ;
2014
2115export const reinstallCommand : ClientCommandHandler = async ( { positionals, flags, client } ) => {
2216 const result = await runDeployCommand ( 'reinstall' , positionals , flags , client ) ;
2317 const data = serializeDeployResult ( result ) ;
24- if ( flags . json ) printJson ( { success : true , data } ) ;
25- else writeHumanMessage ( data ) ;
18+ writeCommandMessage ( flags , data ) ;
2619 return true ;
2720} ;
2821
@@ -33,16 +26,10 @@ export const installFromSourceCommand: ClientCommandHandler = async ({
3326} ) => {
3427 const result = await runInstallFromSourceCommand ( positionals , flags , client ) ;
3528 const data = serializeInstallFromSourceResult ( result ) ;
36- if ( flags . json ) printJson ( { success : true , data } ) ;
37- else writeHumanMessage ( data ) ;
29+ writeCommandMessage ( flags , data ) ;
3830 return true ;
3931} ;
4032
41- function writeHumanMessage ( data : Record < string , unknown > ) : void {
42- const message = readCommandMessage ( data ) ;
43- if ( message ) process . stdout . write ( `${ message } \n` ) ;
44- }
45-
4633async function runDeployCommand (
4734 command : 'install' | 'reinstall' ,
4835 positionals : string [ ] ,
0 commit comments