list static method
Prints a summary table of all hooks in hooksConfig and their
installation status on disk.
Implementation
static Future<void> list({
required HooksConfigModel hooksConfig,
String? projectDir,
}) async {
if (hooksConfig.isEmpty) {
print('');
print('π¦ No hooks configured.');
print('');
print(' To get started, add a hooks section to your config.yaml:');
print('');
print(' hooks:');
print(' pre-commit:');
print(' enabled: true');
print(' steps:');
print(' - name: "Analyze"');
print(' command: "flutter analyze"');
print('');
print(' Run "frx hooks install" after adding your hooks.');
print('');
return;
}
final gitDir = await _findGitDir(projectDir ?? Directory.current.path);
final hooksDir = gitDir != null
? Directory('${gitDir.path}${Platform.pathSeparator}hooks')
: null;
print('');
print(
'ββββββββββββββββββββββββ¦ββββββββββ¦ββββββββ¦ββββββββββββ¦βββββββββββββββββββββββββββββ');
print(
'β Hook β Enabled β Steps β Installed β Source β');
print(
'β βββββββββββββββββββββββ¬ββββββββββ¬ββββββββ¬ββββββββββββ¬βββββββββββββββββββββββββββββ£');
for (final entry in hooksConfig.hooks.entries) {
final name = entry.key.padRight(20);
final hook = entry.value;
final enabled = hook.enabled ? ' β
' : ' β ';
final steps = hook.steps.length.toString().padRight(5);
// Check disk install status
String installed = ' β ';
if (hooksDir != null) {
final hookFile =
File('${hooksDir.path}${Platform.pathSeparator}${entry.key}');
if (hookFile.existsSync()) {
final content = hookFile.readAsStringSync();
installed =
content.contains(_kFrxHookMarker) ? ' β
' : ' β οΈ custom';
}
}
final source = hook.hasPipeline
? 'β pipeline: ${hook.runPipeline}'.padRight(26)
: (hook.hasSteps
? '${hook.steps.length} inline step(s)'.padRight(26)
: '(none)'.padRight(26));
print('β $name β$enabledβ $steps β$installed β $source β');
}
print(
'ββββββββββββββββββββββββ©ββββββββββ©ββββββββ©ββββββββββββ©βββββββββββββββββββββββββββββ');
print('');
print('π‘ Manage hooks:');
print(' frx hooks install Install all enabled hooks');
print(' frx hooks uninstall Remove all FRX-managed hooks');
print(' frx hooks uninstall --hook pre-commit Remove a specific hook');
print(' frx hooks run pre-commit Manually trigger a hook');
print('');
}