1- import { Args , Command , Flags } from '@oclif/core'
2- import chalk from 'chalk' ;
1+ import { Args , Flags } from '@oclif/core'
32import { ResourceOperation } from 'codify-schemas' ;
43import * as path from 'node:path' ;
54
65import { ApplyOrchestrator } from '../../orchestrators/apply.js' ;
76import { PlanOrchestrator } from '../../orchestrators/plan.js' ;
8- import { DefaultReporter } from '../../ui/reporters/default-reporter .js' ;
7+ import { BaseCommand } from '../../common/base-command .js' ;
98
10- export default class Apply extends Command {
9+ export default class Apply extends BaseCommand {
1110 static args = {
1211 file : Args . string ( { description : 'file to read' } ) ,
1312 }
@@ -23,14 +22,8 @@ export default class Apply extends Command {
2322 path : Flags . string ( { char : 'p' , description : 'path to project' } ) ,
2423 }
2524
26- protected async catch ( err : Error ) : Promise < void > {
27- console . log ( chalk . red ( err . message ) ) ;
28- process . exit ( 1 ) ;
29- }
30-
3125 public async run ( ) : Promise < void > {
3226 const { flags } = await this . parse ( Apply )
33- const reporter = new DefaultReporter ( )
3427
3528 if ( flags . path ) {
3629 this . log ( `Applying Codify from: ${ flags . path } ` ) ;
@@ -39,15 +32,15 @@ export default class Apply extends Command {
3932 const resolvedPath = path . resolve ( flags . path ?? '.' ) ;
4033
4134 const planResult = await PlanOrchestrator . run ( resolvedPath ) ;
42- reporter . displayPlan ( planResult . plan ) ;
35+ this . reporter . displayPlan ( planResult . plan ) ;
4336
4437 // Short circuit and exit if every change is NOOP
4538 if ( planResult . plan . every ( ( p ) => p . operation === ResourceOperation . NOOP ) ) {
4639 console . log ( 'No changes necessary. Exiting' ) ;
4740 return process . exit ( 0 ) ;
4841 }
4942
50- const confirm = await reporter . promptApplyConfirmation ( )
43+ const confirm = await this . reporter . promptApplyConfirmation ( )
5144 if ( ! confirm ) {
5245 return process . exit ( 0 ) ;
5346 }
0 commit comments