Skip to content

Commit

Permalink
WIP: feat(init): add CodeClimate configuration migration support
Browse files Browse the repository at this point in the history
Add functionality to detect and migrate existing .codeclimate.yml
configurations during qlty initialization. The migration:
- Detects existing .codeclimate.yml in project root
- Prompts user for migration confirmation (respects --yes/--no flags)
- Executes migration using 'qlty config migrate'
- Provides success feedback to user

This helps users transition from CodeClimate to qlty while preserving
their existing configurations.
  • Loading branch information
larkinscott committed Jan 29, 2025
1 parent e789264 commit 86e7f30
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions qlty-cli/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use qlty_config::Workspace;
use std::io::Write;
use tabwriter::TabWriter;

const CLASSIC_CONFIG_NAME: &str = ".codeclimate.yml";

#[derive(Args, Debug)]
pub struct Init {
/// Answer yes to all prompts
Expand Down Expand Up @@ -106,9 +108,9 @@ impl Init {
self.print_enabled_plugins(&initializer)?;
}

// if !self.skip_migrate && .codeclimate.yml exists{
// self.maybe_migrate_config
// }
if !self.skip_plugins {
self.maybe_migrate_config()?;
}

if !self.skip_plugins {
self.plugins_post_init(&initializer)?;
Expand Down Expand Up @@ -266,4 +268,26 @@ impl Init {
let current_exe = std::env::current_exe()?;
Ok(current_exe)
}

fn maybe_migrate_config(&self) -> Result<()> {
let workspace = Workspace::new()?;
let classic_config_path = workspace.root.join(CLASSIC_CONFIG_NAME);

if classic_config_path.exists() {
if !self.no
&& (self.yes
|| Confirm::with_theme(&ColorfulTheme::default())
.with_prompt(
"Would you like to migrate your .codeclimate.yml configuration?",
)
.default(true)
.show_default(true)
.interact()?)
{
cmd!(self.current_exe()?, "config", "migrate").run()?;
self.print_check("Migrated .codeclimate.yml configuration");
}
}
Ok(())
}
}

0 comments on commit 86e7f30

Please sign in to comment.