@@ -25,7 +25,7 @@ import {
2525 installOption ,
2626 packageManagerPrompt
2727} from '../../utils/package-manager.ts' ;
28- import { getGlobalPreconditions } from './preconditions .ts' ;
28+ import { verifyCleanWorkingDirectory , verifyUnsupportedAddons } from './verifiers .ts' ;
2929import { type AddonMap , applyAddons , setupAddons } from '../../lib/install.ts' ;
3030
3131const aliases = officialAddons . map ( ( c ) => c . alias ) . filter ( ( v ) => v !== undefined ) ;
@@ -36,7 +36,7 @@ const AddonsSchema = v.array(v.string());
3636const OptionsSchema = v . strictObject ( {
3737 cwd : v . string ( ) ,
3838 install : v . union ( [ v . boolean ( ) , v . picklist ( AGENT_NAMES ) ] ) ,
39- preconditions : v . boolean ( ) ,
39+ gitCheck : v . boolean ( ) ,
4040 community : v . optional ( v . union ( [ AddonsSchema , v . boolean ( ) ] ) ) ,
4141 addons : v . record ( v . string ( ) , v . optional ( v . array ( v . string ( ) ) ) )
4242} ) ;
@@ -81,7 +81,7 @@ export const add = new Command('add')
8181 return prev ;
8282 } )
8383 . option ( '-C, --cwd <path>' , 'path to working directory' , defaultCwd )
84- . option ( '--no-preconditions ' , 'skip validating preconditions ' )
84+ . option ( '--no-git-check ' , 'even if some files are dirty, no prompt will be shown ' )
8585 . option ( '--no-install' , 'skip installing dependencies' )
8686 . addOption ( installOption )
8787 //.option('--community [add-on...]', 'community addons to install')
@@ -445,33 +445,33 @@ export async function runAddCommand(
445445 }
446446 }
447447
448- // run precondition checks
449- if ( options . preconditions && selectedAddons . length > 0 ) {
450- // add global checks
451- const addons = selectedAddons . map ( ( { addon } ) => addon ) ;
452- const { preconditions } = getGlobalPreconditions ( options . cwd , addons , addonSetupResults ) ;
453-
454- const fails : Array < { name : string ; message ?: string } > = [ ] ;
455- for ( const condition of preconditions ) {
456- const { message, success } = await condition . run ( ) ;
457- if ( ! success ) fails . push ( { name : condition . name , message } ) ;
458- }
448+ // run verifications
449+ const addons = selectedAddons . map ( ( { addon } ) => addon ) ;
450+ const verifications = [
451+ ...verifyCleanWorkingDirectory ( options . cwd , options . gitCheck ) ,
452+ ...verifyUnsupportedAddons ( addons , addonSetupResults )
453+ ] ;
454+
455+ const fails : Array < { name : string ; message ?: string } > = [ ] ;
456+ for ( const verification of verifications ) {
457+ const { message, success } = await verification . run ( ) ;
458+ if ( ! success ) fails . push ( { name : verification . name , message } ) ;
459+ }
459460
460- if ( fails . length > 0 ) {
461- const message = fails
462- . map ( ( { name, message } ) => pc . yellow ( `${ name } (${ message } )` ) )
463- . join ( '\n- ' ) ;
461+ if ( fails . length > 0 ) {
462+ const message = fails
463+ . map ( ( { name, message } ) => pc . yellow ( `${ name } (${ message } )` ) )
464+ . join ( '\n- ' ) ;
464465
465- p . note ( `- ${ message } ` , 'Preconditions not met' , { format : ( line ) => line } ) ;
466+ p . note ( `- ${ message } ` , 'Verifications not met' , { format : ( line ) => line } ) ;
466467
467- const force = await p . confirm ( {
468- message : 'Preconditions failed. Do you wish to continue?' ,
469- initialValue : false
470- } ) ;
471- if ( p . isCancel ( force ) || ! force ) {
472- p . cancel ( 'Operation cancelled.' ) ;
473- process . exit ( 1 ) ;
474- }
468+ const force = await p . confirm ( {
469+ message : 'Verifications failed. Do you wish to continue?' ,
470+ initialValue : false
471+ } ) ;
472+ if ( p . isCancel ( force ) || ! force ) {
473+ p . cancel ( 'Operation cancelled.' ) ;
474+ process . exit ( 1 ) ;
475475 }
476476 }
477477
0 commit comments