Skip to content

Commit 1e1b904

Browse files
committed
feat(cli): print migration guides for deprecated commands
1 parent 89e4538 commit 1e1b904

File tree

8 files changed

+361
-1
lines changed

8 files changed

+361
-1
lines changed

src/cli.rs

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ pub enum Subcommand {
1515
Update,
1616
List,
1717
Json,
18+
ListMismatches,
19+
LintSemverRanges,
20+
FixMismatches,
21+
SetSemverRanges,
22+
Prompt,
1823
}
1924

2025
#[derive(Debug)]
@@ -110,6 +115,106 @@ impl Cli {
110115
Some(("update", matches)) => from_arg_matches(Subcommand::Update, matches),
111116
Some(("list", matches)) => from_arg_matches(Subcommand::List, matches),
112117
Some(("json", matches)) => from_arg_matches(Subcommand::Json, matches),
118+
Some(("list-mismatches", _)) => Cli {
119+
check: false,
120+
config_path: None,
121+
cwd: env::current_dir().unwrap(),
122+
dependencies: vec![],
123+
dependency_types: vec![],
124+
disable_ansi: false,
125+
dry_run: false,
126+
log_levels: vec![],
127+
packages: vec![],
128+
show_hints: false,
129+
show_ignored: false,
130+
show_instances: false,
131+
show_status_codes: false,
132+
sort: SortBy::Name,
133+
source_patterns: vec![],
134+
specifier_types: vec![],
135+
subcommand: Subcommand::ListMismatches,
136+
target: UpdateTarget::Latest,
137+
},
138+
Some(("lint-semver-ranges", _)) => Cli {
139+
check: false,
140+
config_path: None,
141+
cwd: env::current_dir().unwrap(),
142+
dependencies: vec![],
143+
dependency_types: vec![],
144+
disable_ansi: false,
145+
dry_run: false,
146+
log_levels: vec![],
147+
packages: vec![],
148+
show_hints: false,
149+
show_ignored: false,
150+
show_instances: false,
151+
show_status_codes: false,
152+
sort: SortBy::Name,
153+
source_patterns: vec![],
154+
specifier_types: vec![],
155+
subcommand: Subcommand::LintSemverRanges,
156+
target: UpdateTarget::Latest,
157+
},
158+
Some(("fix-mismatches", _)) => Cli {
159+
check: false,
160+
config_path: None,
161+
cwd: env::current_dir().unwrap(),
162+
dependencies: vec![],
163+
dependency_types: vec![],
164+
disable_ansi: false,
165+
dry_run: false,
166+
log_levels: vec![],
167+
packages: vec![],
168+
show_hints: false,
169+
show_ignored: false,
170+
show_instances: false,
171+
show_status_codes: false,
172+
sort: SortBy::Name,
173+
source_patterns: vec![],
174+
specifier_types: vec![],
175+
subcommand: Subcommand::FixMismatches,
176+
target: UpdateTarget::Latest,
177+
},
178+
Some(("set-semver-ranges", _)) => Cli {
179+
check: false,
180+
config_path: None,
181+
cwd: env::current_dir().unwrap(),
182+
dependencies: vec![],
183+
dependency_types: vec![],
184+
disable_ansi: false,
185+
dry_run: false,
186+
log_levels: vec![],
187+
packages: vec![],
188+
show_hints: false,
189+
show_ignored: false,
190+
show_instances: false,
191+
show_status_codes: false,
192+
sort: SortBy::Name,
193+
source_patterns: vec![],
194+
specifier_types: vec![],
195+
subcommand: Subcommand::SetSemverRanges,
196+
target: UpdateTarget::Latest,
197+
},
198+
Some(("prompt", _)) => Cli {
199+
check: false,
200+
config_path: None,
201+
cwd: env::current_dir().unwrap(),
202+
dependencies: vec![],
203+
dependency_types: vec![],
204+
disable_ansi: false,
205+
dry_run: false,
206+
log_levels: vec![],
207+
packages: vec![],
208+
show_hints: false,
209+
show_ignored: false,
210+
show_instances: false,
211+
show_status_codes: false,
212+
sort: SortBy::Name,
213+
source_patterns: vec![],
214+
specifier_types: vec![],
215+
subcommand: Subcommand::Prompt,
216+
target: UpdateTarget::Latest,
217+
},
113218
_ => {
114219
std::process::exit(1);
115220
}
@@ -235,6 +340,41 @@ fn create() -> Command {
235340
.arg(source_option("json"))
236341
.arg(specifier_types_option("json")),
237342
)
343+
.subcommand(
344+
Command::new("list-mismatches")
345+
.about("DEPRECATED: Use 'syncpack lint' instead")
346+
.hide(true)
347+
.disable_help_flag(true)
348+
.disable_version_flag(true),
349+
)
350+
.subcommand(
351+
Command::new("lint-semver-ranges")
352+
.about("DEPRECATED: Use 'syncpack lint' instead")
353+
.hide(true)
354+
.disable_help_flag(true)
355+
.disable_version_flag(true),
356+
)
357+
.subcommand(
358+
Command::new("fix-mismatches")
359+
.about("DEPRECATED: Use 'syncpack fix' instead")
360+
.hide(true)
361+
.disable_help_flag(true)
362+
.disable_version_flag(true),
363+
)
364+
.subcommand(
365+
Command::new("set-semver-ranges")
366+
.about("DEPRECATED: Use 'syncpack fix' instead")
367+
.hide(true)
368+
.disable_help_flag(true)
369+
.disable_version_flag(true),
370+
)
371+
.subcommand(
372+
Command::new("prompt")
373+
.about("MISSING: Not yet implemented in v14")
374+
.hide(true)
375+
.disable_help_flag(true)
376+
.disable_version_flag(true),
377+
)
238378
}
239379

240380
fn config_option(_command: &str) -> Arg {

src/commands.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
/// Write fixes to disk
22
pub mod fix;
3+
/// DEPRECATED: Use fix instead
4+
pub mod fix_mismatches;
35
/// Lint and fix package.json formatting
46
pub mod format;
57
/// Output all dependencies as flattened JSON objects
68
pub mod json;
79
/// Write lint messages to the UI
810
pub mod lint;
11+
/// DEPRECATED: Use lint instead
12+
pub mod lint_semver_ranges;
913
/// Query and list all instances in the project
1014
pub mod list;
15+
/// DEPRECATED: Use lint instead
16+
pub mod list_mismatches;
17+
/// DEPRECATED: Not yet implemented in v14
18+
pub mod prompt;
19+
/// DEPRECATED: Use fix instead
20+
pub mod set_semver_ranges;
1121
/// A shared module with methods for printing messages to the console
1222
pub mod ui;
1323
/// Find and apply updates from the npm registry

src/commands/fix_mismatches.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use colored::Colorize;
2+
3+
/// Run the fix-mismatches command (deprecated in v14)
4+
pub fn run() -> i32 {
5+
eprintln!("{}", "Deprecated in syncpack v14".red().bold());
6+
eprintln!();
7+
eprintln!("{}", "fix-mismatches → fix".yellow().bold());
8+
eprintln!();
9+
eprintln!(
10+
"{} and {} have been merged into a single {} command which autofixes",
11+
"fix-mismatches".cyan(),
12+
"set-semver-ranges".cyan(),
13+
"fix".green()
14+
);
15+
eprintln!(
16+
"issues found by {}. The {} command no longer fixes formatting, which is now handled",
17+
"syncpack lint".green(),
18+
"fix".green()
19+
);
20+
eprintln!("by {}.", "syncpack format".green());
21+
eprintln!();
22+
eprintln!("{}", "Migration Example:".bold());
23+
eprintln!();
24+
eprintln!(" {}", "# v13".dimmed());
25+
eprintln!(" {}", "syncpack fix-mismatches".dimmed());
26+
eprintln!();
27+
eprintln!(" {}", "# v14".dimmed());
28+
eprintln!(" {}", "syncpack fix".cyan());
29+
eprintln!();
30+
eprintln!(
31+
"{}",
32+
"https://jamiemason.github.io/syncpack/guide/migrate-v14#fix-mismatches-fix"
33+
.blue()
34+
.underline()
35+
);
36+
eprintln!();
37+
1
38+
}

src/commands/lint_semver_ranges.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use colored::Colorize;
2+
3+
/// Run the lint-semver-ranges command (deprecated in v14)
4+
pub fn run() -> i32 {
5+
eprintln!("{}", "Deprecated in syncpack v14".red().bold());
6+
eprintln!();
7+
eprintln!("{}", "lint-semver-ranges → lint".yellow().bold());
8+
eprintln!();
9+
eprintln!(
10+
"{} and {} have been merged into a single {} command which checks",
11+
"list-mismatches".cyan(),
12+
"lint-semver-ranges".cyan(),
13+
"lint".green()
14+
);
15+
eprintln!("whether every specifier matches the semver group and version group they belong to.");
16+
eprintln!(
17+
"The {} command no longer checks formatting, which is now handled by {}.",
18+
"lint".green(),
19+
"syncpack format --check".green()
20+
);
21+
eprintln!();
22+
eprintln!("It's no longer possible to manage semver ranges without also checking version mismatches,");
23+
eprintln!("because the two things are so closely linked. Changes to semver ranges affect which");
24+
eprintln!("versions are considered valid and can indirectly cause version mismatches, so they are");
25+
eprintln!(
26+
"now always checked and changed together via the {} and {} commands.",
27+
"lint".green(),
28+
"fix".green()
29+
);
30+
eprintln!();
31+
eprintln!("{}", "Migration Example:".bold());
32+
eprintln!();
33+
eprintln!(" {}", "# v13".dimmed());
34+
eprintln!(" {}", "syncpack lint-semver-ranges".dimmed());
35+
eprintln!();
36+
eprintln!(" {}", "# v14".dimmed());
37+
eprintln!(" {}", "syncpack lint".cyan());
38+
eprintln!();
39+
eprintln!(
40+
"{}",
41+
"https://jamiemason.github.io/syncpack/guide/migrate-v14#lint-semver-ranges-lint"
42+
.blue()
43+
.underline()
44+
);
45+
eprintln!();
46+
1
47+
}

src/commands/list_mismatches.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use colored::Colorize;
2+
3+
/// Run the list-mismatches command (deprecated in v14)
4+
pub fn run() -> i32 {
5+
eprintln!("{}", "Deprecated in syncpack v14".red().bold());
6+
eprintln!();
7+
eprintln!("{}", "list-mismatches → lint".yellow().bold());
8+
eprintln!();
9+
eprintln!(
10+
"{} and {} have been merged into a single {} command which checks",
11+
"list-mismatches".cyan(),
12+
"lint-semver-ranges".cyan(),
13+
"lint".green()
14+
);
15+
eprintln!("whether every specifier matches the semver group and version group they belong to.");
16+
eprintln!(
17+
"The {} command no longer checks formatting, which is now handled by {}.",
18+
"lint".green(),
19+
"syncpack format --check".green()
20+
);
21+
eprintln!();
22+
eprintln!("{}", "Migration Example:".bold());
23+
eprintln!();
24+
eprintln!(" {}", "# v13".dimmed());
25+
eprintln!(" {}", "syncpack list-mismatches --types prod,dev".dimmed());
26+
eprintln!();
27+
eprintln!(" {}", "# v14".dimmed());
28+
eprintln!(" {}", "syncpack lint --dependency-types prod,dev".cyan());
29+
eprintln!();
30+
eprintln!(
31+
"{}",
32+
"https://jamiemason.github.io/syncpack/guide/migrate-v14#list-mismatches-lint"
33+
.blue()
34+
.underline()
35+
);
36+
eprintln!();
37+
1
38+
}

src/commands/prompt.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use colored::Colorize;
2+
3+
/// Run the prompt command (deprecated in v14)
4+
pub fn run() -> i32 {
5+
eprintln!("{}", "Deprecated in syncpack v14".red().bold());
6+
eprintln!();
7+
eprintln!("{}", "prompt → Removed".yellow().bold());
8+
eprintln!();
9+
eprintln!(
10+
"The {} command is an interactive prompt which lists all current issues which syncpack",
11+
"prompt".cyan()
12+
);
13+
eprintln!("can't fix automatically. It is not yet available in v14 and will be added at a later date.");
14+
eprintln!();
15+
eprintln!("Syncpack can't automatically fix mismatches between specifiers it does not support,");
16+
eprintln!("which are usually specifiers which are not semver, such as pnpm overrides, or complex");
17+
eprintln!("semver specifiers like {}.", "^1.2.3 || ^2.0.0".cyan());
18+
eprintln!();
19+
eprintln!("{}", "Status:".bold());
20+
eprintln!();
21+
eprintln!(" {}", "# v13".dimmed());
22+
eprintln!(" {}", "syncpack prompt".dimmed());
23+
eprintln!();
24+
eprintln!(" {}", "# v14".dimmed());
25+
eprintln!(" {}", "# Not yet implemented".red());
26+
eprintln!();
27+
eprintln!(
28+
"{}",
29+
"https://jamiemason.github.io/syncpack/guide/migrate-v14#prompt-removed"
30+
.blue()
31+
.underline()
32+
);
33+
eprintln!();
34+
1
35+
}

src/commands/set_semver_ranges.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use colored::Colorize;
2+
3+
/// Run the set-semver-ranges command (deprecated in v14)
4+
pub fn run() -> i32 {
5+
eprintln!("{}", "Deprecated in syncpack v14".red().bold());
6+
eprintln!();
7+
eprintln!("{}", "set-semver-ranges → fix".yellow().bold());
8+
eprintln!();
9+
eprintln!(
10+
"{} and {} have been merged into a single {} command which autofixes",
11+
"fix-mismatches".cyan(),
12+
"set-semver-ranges".cyan(),
13+
"fix".green()
14+
);
15+
eprintln!(
16+
"issues found by {}. The {} command no longer fixes formatting, which is now handled",
17+
"syncpack lint".green(),
18+
"fix".green()
19+
);
20+
eprintln!("by {}.", "syncpack format".green());
21+
eprintln!();
22+
eprintln!("It's no longer possible to manage semver ranges without also checking version mismatches,");
23+
eprintln!("because the two things are so closely linked. Changes to semver ranges affect which");
24+
eprintln!("versions are considered valid and can indirectly cause version mismatches, so they are");
25+
eprintln!(
26+
"now always checked and changed together via the {} and {} commands.",
27+
"lint".green(),
28+
"fix".green()
29+
);
30+
eprintln!();
31+
eprintln!("{}", "Migration Example:".bold());
32+
eprintln!();
33+
eprintln!(" {}", "# v13".dimmed());
34+
eprintln!(" {}", "syncpack set-semver-ranges".dimmed());
35+
eprintln!();
36+
eprintln!(" {}", "# v14".dimmed());
37+
eprintln!(" {}", "syncpack fix".cyan());
38+
eprintln!();
39+
eprintln!(
40+
"{}",
41+
"https://jamiemason.github.io/syncpack/guide/migrate-v14#set-semver-ranges-fix"
42+
.blue()
43+
.underline()
44+
);
45+
eprintln!();
46+
1
47+
}

0 commit comments

Comments
 (0)