@@ -25,7 +25,7 @@ import {
25
25
installOption ,
26
26
packageManagerPrompt
27
27
} from '../../utils/package-manager.ts' ;
28
- import { getGlobalPreconditions } from './preconditions .ts' ;
28
+ import { verifyCleanWorkingDirectory , verifyUnsupportedAddons } from './verifiers .ts' ;
29
29
import { type AddonMap , applyAddons , setupAddons } from '../../lib/install.ts' ;
30
30
31
31
const aliases = officialAddons . map ( ( c ) => c . alias ) . filter ( ( v ) => v !== undefined ) ;
@@ -36,7 +36,7 @@ const AddonsSchema = v.array(v.string());
36
36
const OptionsSchema = v . strictObject ( {
37
37
cwd : v . string ( ) ,
38
38
install : v . union ( [ v . boolean ( ) , v . picklist ( AGENT_NAMES ) ] ) ,
39
- preconditions : v . boolean ( ) ,
39
+ gitCheck : v . boolean ( ) ,
40
40
community : v . optional ( v . union ( [ AddonsSchema , v . boolean ( ) ] ) ) ,
41
41
addons : v . record ( v . string ( ) , v . optional ( v . array ( v . string ( ) ) ) )
42
42
} ) ;
@@ -81,7 +81,7 @@ export const add = new Command('add')
81
81
return prev ;
82
82
} )
83
83
. 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 ' )
85
85
. option ( '--no-install' , 'skip installing dependencies' )
86
86
. addOption ( installOption )
87
87
//.option('--community [add-on...]', 'community addons to install')
@@ -445,33 +445,33 @@ export async function runAddCommand(
445
445
}
446
446
}
447
447
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
+ }
459
460
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- ' ) ;
464
465
465
- p . note ( `- ${ message } ` , 'Preconditions not met' , { format : ( line ) => line } ) ;
466
+ p . note ( `- ${ message } ` , 'Verifications not met' , { format : ( line ) => line } ) ;
466
467
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 ) ;
475
475
}
476
476
}
477
477
0 commit comments