chore: even more linting, test fixes (#24)

* chore(lint): funcorder

* chore(lint): yamlfmt, ignored broken test yaml files

* chore(tests): tests do not output garbage, add coverage

* chore(lint): fix editorconfig violations

* chore(lint): move from eclint to editorconfig-checker

* chore(lint): add pre-commit, run and fix

* chore(ci): we use renovate to manage updates
This commit is contained in:
2025-08-06 23:44:32 +03:00
committed by GitHub
parent c5a7ced768
commit b80ecfce92
56 changed files with 809 additions and 601 deletions

View File

@@ -55,6 +55,32 @@ func (e *ConfigExporter) ExportConfig(config *internal.AppConfig, format ExportF
}
}
// GetSupportedFormats returns the list of supported export formats.
func (e *ConfigExporter) GetSupportedFormats() []ExportFormat {
return []ExportFormat{FormatYAML, FormatJSON, FormatTOML}
}
// GetDefaultOutputPath returns the default output path for a given format.
func (e *ConfigExporter) GetDefaultOutputPath(format ExportFormat) (string, error) {
configPath, err := internal.GetConfigPath()
if err != nil {
return "", fmt.Errorf("failed to get config directory: %w", err)
}
dir := filepath.Dir(configPath)
switch format {
case FormatYAML:
return filepath.Join(dir, "config.yaml"), nil
case FormatJSON:
return filepath.Join(dir, "config.json"), nil
case FormatTOML:
return filepath.Join(dir, "config.toml"), nil
default:
return "", fmt.Errorf("unsupported format: %s", format)
}
}
// exportYAML exports configuration as YAML.
func (e *ConfigExporter) exportYAML(config *internal.AppConfig, outputPath string) error {
// Create a clean config without sensitive data for export
@@ -260,29 +286,3 @@ func (e *ConfigExporter) writeVariablesSection(file *os.File, config *internal.A
_, _ = fmt.Fprintf(file, "%s = %q\n", key, value)
}
}
// GetSupportedFormats returns the list of supported export formats.
func (e *ConfigExporter) GetSupportedFormats() []ExportFormat {
return []ExportFormat{FormatYAML, FormatJSON, FormatTOML}
}
// GetDefaultOutputPath returns the default output path for a given format.
func (e *ConfigExporter) GetDefaultOutputPath(format ExportFormat) (string, error) {
configPath, err := internal.GetConfigPath()
if err != nil {
return "", fmt.Errorf("failed to get config directory: %w", err)
}
dir := filepath.Dir(configPath)
switch format {
case FormatYAML:
return filepath.Join(dir, "config.yaml"), nil
case FormatJSON:
return filepath.Join(dir, "config.json"), nil
case FormatTOML:
return filepath.Join(dir, "config.toml"), nil
default:
return "", fmt.Errorf("unsupported format: %s", format)
}
}

View File

@@ -109,6 +109,33 @@ func (v *ConfigValidator) ValidateField(fieldName, value string) *ValidationResu
return result
}
// DisplayValidationResult displays validation results to the user.
func (v *ConfigValidator) DisplayValidationResult(result *ValidationResult) {
if result.Valid {
v.output.Success("✅ Configuration is valid")
} else {
v.output.Error("❌ Configuration has errors")
}
// Display errors
for _, err := range result.Errors {
v.output.Error(" • %s: %s (value: %s)", err.Field, err.Message, err.Value)
}
// Display warnings
for _, warning := range result.Warnings {
v.output.Warning(" ⚠️ %s: %s", warning.Field, warning.Message)
}
// Display suggestions
if len(result.Suggestions) > 0 {
v.output.Info("\nSuggestions:")
for _, suggestion := range result.Suggestions {
v.output.Printf(" 💡 %s", suggestion)
}
}
}
// validateOrganization validates the organization field.
func (v *ConfigValidator) validateOrganization(org string, result *ValidationResult) {
if org == "" {
@@ -478,30 +505,3 @@ func (v *ConfigValidator) isValidVariableName(name string) bool {
return matched
}
// DisplayValidationResult displays validation results to the user.
func (v *ConfigValidator) DisplayValidationResult(result *ValidationResult) {
if result.Valid {
v.output.Success("✅ Configuration is valid")
} else {
v.output.Error("❌ Configuration has errors")
}
// Display errors
for _, err := range result.Errors {
v.output.Error(" • %s: %s (value: %s)", err.Field, err.Message, err.Value)
}
// Display warnings
for _, warning := range result.Warnings {
v.output.Warning(" ⚠️ %s: %s", warning.Field, warning.Message)
}
// Display suggestions
if len(result.Suggestions) > 0 {
v.output.Info("\nSuggestions:")
for _, suggestion := range result.Suggestions {
v.output.Printf(" 💡 %s", suggestion)
}
}
}