ry-cli 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ry_cli-0.3.0 → ry_cli-0.4.0}/CHANGELOG.md +8 -1
- {ry_cli-0.3.0 → ry_cli-0.4.0}/Cargo.lock +8 -1
- {ry_cli-0.3.0 → ry_cli-0.4.0}/Cargo.toml +2 -1
- {ry_cli-0.3.0 → ry_cli-0.4.0}/PKG-INFO +1 -1
- {ry_cli-0.3.0 → ry_cli-0.4.0}/src/config.rs +7 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/src/diagnostics.rs +1 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/src/inline.rs +1 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/src/main.rs +38 -2
- ry_cli-0.4.0/tests/fixtures/basic_async_to_sync/output.txt +2 -0
- ry_cli-0.4.0/tests/fixtures/outdated_generated_code/expected.py +7 -0
- ry_cli-0.4.0/tests/fixtures/outdated_generated_code/input.py +7 -0
- ry_cli-0.4.0/tests/fixtures/outdated_generated_code/output.txt +8 -0
- ry_cli-0.4.0/tests/fixtures/outdated_generated_code/ry.yml +8 -0
- ry_cli-0.4.0/tests/fixtures/tag_rules/output.txt +2 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures.rs +37 -0
- ry_cli-0.4.0/uv.lock +7 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/.github/logo.png +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/.github/workflows/publish-python.yml +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/.github/workflows/release-please.yml +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/.gitignore +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/LICENSE +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/README.md +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/pyproject.toml +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/src/generation.rs +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/src/lib.rs +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/src/module.rs +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/src/packages.rs +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/src/treesitter.rs +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/basic_async_to_sync/expected.py +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/basic_async_to_sync/input.py +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/basic_async_to_sync/ry.yml +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/tag_rules/expected.py +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/tag_rules/input.py +0 -0
- {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/tag_rules/ry.yml +0 -0
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.
|
|
3
|
+
## [0.4.0](https://github.com/karpetrosyan/ry/compare/v0.2.0...v0.4.0) (2026-04-18)
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
### Features
|
|
7
7
|
|
|
8
8
|
* make rule's id optional ([7c2d7a5](https://github.com/karpetrosyan/ry/commit/7c2d7a54cae7dbf810383127c0262e08bc648b0f))
|
|
9
|
+
* make rule's kind optional, default to regex ([920565f](https://github.com/karpetrosyan/ry/commit/920565feef93590c4dc7a9154172ae69d39a4876))
|
|
10
|
+
* show diff with expected sync code in verbose mode ([622e95d](https://github.com/karpetrosyan/ry/commit/622e95d94e4822a9f40cf467bb40e371d8513b3e))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Miscellaneous Chores
|
|
14
|
+
|
|
15
|
+
* release 0.4.0 ([35887e3](https://github.com/karpetrosyan/ry/commit/35887e3442e9040275a9c976e16a5228dacf4482))
|
|
9
16
|
|
|
10
17
|
## [0.2.0](https://github.com/karpetrosyan/ry/compare/v0.1.0...v0.2.0) (2026-04-09)
|
|
11
18
|
|
|
@@ -375,7 +375,7 @@ dependencies = [
|
|
|
375
375
|
|
|
376
376
|
[[package]]
|
|
377
377
|
name = "ry"
|
|
378
|
-
version = "0.
|
|
378
|
+
version = "0.4.0"
|
|
379
379
|
dependencies = [
|
|
380
380
|
"clap",
|
|
381
381
|
"glob",
|
|
@@ -383,6 +383,7 @@ dependencies = [
|
|
|
383
383
|
"regex",
|
|
384
384
|
"serde",
|
|
385
385
|
"serde_yaml",
|
|
386
|
+
"similar",
|
|
386
387
|
"tempfile",
|
|
387
388
|
"tree-sitter",
|
|
388
389
|
"tree-sitter-python",
|
|
@@ -462,6 +463,12 @@ version = "1.3.0"
|
|
|
462
463
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
463
464
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
464
465
|
|
|
466
|
+
[[package]]
|
|
467
|
+
name = "similar"
|
|
468
|
+
version = "2.7.0"
|
|
469
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
470
|
+
checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
|
|
471
|
+
|
|
465
472
|
[[package]]
|
|
466
473
|
name = "streaming-iterator"
|
|
467
474
|
version = "0.1.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "ry"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
|
|
@@ -16,6 +16,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|
|
16
16
|
serde_yaml = "0.9"
|
|
17
17
|
regex = "1.10"
|
|
18
18
|
glob = "0.3"
|
|
19
|
+
similar = "2"
|
|
19
20
|
|
|
20
21
|
[dev-dependencies]
|
|
21
22
|
tempfile = "3.8"
|
|
@@ -36,6 +36,7 @@ pub struct Package {
|
|
|
36
36
|
pub struct Rule {
|
|
37
37
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
38
38
|
pub id: Option<String>,
|
|
39
|
+
#[serde(default)]
|
|
39
40
|
pub kind: RuleKind,
|
|
40
41
|
#[serde(rename = "match")]
|
|
41
42
|
pub match_pattern: String,
|
|
@@ -48,6 +49,12 @@ pub enum RuleKind {
|
|
|
48
49
|
Regex,
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
impl Default for RuleKind {
|
|
53
|
+
fn default() -> Self {
|
|
54
|
+
RuleKind::Regex
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
51
58
|
#[derive(Debug, Serialize, Deserialize)]
|
|
52
59
|
#[serde(untagged)]
|
|
53
60
|
pub enum TargetVariant {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use clap::Parser;
|
|
2
2
|
use glob::glob;
|
|
3
3
|
use ry::config::Config;
|
|
4
|
-
use ry::diagnostics::{Diagnostic, Severity};
|
|
4
|
+
use ry::diagnostics::{Diagnostic, DiagnosticKind, Severity};
|
|
5
5
|
use ry::inline::process_file_inline;
|
|
6
6
|
use ry::module::process_all_file_targets;
|
|
7
7
|
use std::path::{Path, PathBuf};
|
|
@@ -105,13 +105,40 @@ fn main() {
|
|
|
105
105
|
diagnostics.extend(files_diagnostics);
|
|
106
106
|
fixed_diagnostics.extend(files_fixed);
|
|
107
107
|
|
|
108
|
-
print_summary(&paths_to_process, &diagnostics, &fixed_diagnostics);
|
|
108
|
+
print_summary(&paths_to_process, &diagnostics, &fixed_diagnostics, cli.verbose);
|
|
109
|
+
|
|
110
|
+
if diagnostics
|
|
111
|
+
.iter()
|
|
112
|
+
.any(|d| matches!(d.severity, Severity::Error))
|
|
113
|
+
{
|
|
114
|
+
std::process::exit(1)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fn print_diff(actual: &str, expected: &str) {
|
|
119
|
+
use similar::{ChangeTag, TextDiff};
|
|
120
|
+
use std::io::IsTerminal;
|
|
121
|
+
let colors = std::io::stderr().is_terminal();
|
|
122
|
+
let diff = TextDiff::from_lines(actual, expected);
|
|
123
|
+
for change in diff.iter_all_changes() {
|
|
124
|
+
let (sign, color, reset) = match change.tag() {
|
|
125
|
+
ChangeTag::Delete => ("-", "\x1b[31m", "\x1b[0m"),
|
|
126
|
+
ChangeTag::Insert => ("+", "\x1b[32m", "\x1b[0m"),
|
|
127
|
+
ChangeTag::Equal => (" ", "", ""),
|
|
128
|
+
};
|
|
129
|
+
if colors {
|
|
130
|
+
eprint!("{}{}{}{}", color, sign, change, reset);
|
|
131
|
+
} else {
|
|
132
|
+
eprint!("{}{}", sign, change);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
109
135
|
}
|
|
110
136
|
|
|
111
137
|
fn print_summary(
|
|
112
138
|
paths_to_process: &[PathBuf],
|
|
113
139
|
diagnostics: &[Diagnostic],
|
|
114
140
|
fixed_diagnostics: &[Diagnostic],
|
|
141
|
+
verbose: bool,
|
|
115
142
|
) {
|
|
116
143
|
let error_count = diagnostics
|
|
117
144
|
.iter()
|
|
@@ -123,6 +150,15 @@ fn print_summary(
|
|
|
123
150
|
.count();
|
|
124
151
|
let fixed_count = fixed_diagnostics.len();
|
|
125
152
|
|
|
153
|
+
if verbose {
|
|
154
|
+
for diagnostic in diagnostics {
|
|
155
|
+
if let DiagnosticKind::OutDatedGeneratedCode { actual_code, transformed_code, .. } = &diagnostic.kind {
|
|
156
|
+
eprintln!("diff for {}:{}:", diagnostic.location.file, diagnostic.location.line);
|
|
157
|
+
print_diff(actual_code, transformed_code);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
126
162
|
if fixed_count > 0 {
|
|
127
163
|
println!(
|
|
128
164
|
"Processed {} file(s) with {} error(s), {} warning(s), and fixed {} diagnostic(s)",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
input.py:1:0: error: Generated code @sync is out of sync with generate marker
|
|
2
|
+
diff for input.py:1:
|
|
3
|
+
-async def fetch_data(): # unasync: generated @sync
|
|
4
|
+
- result = await get_data()
|
|
5
|
+
+def fetch_data(): # unasync: generated @sync
|
|
6
|
+
+ result = get_data()
|
|
7
|
+
return result
|
|
8
|
+
Processed 1 file(s) with 1 error(s) and 0 warning(s)
|
|
@@ -3,6 +3,7 @@ use ry::config::Config;
|
|
|
3
3
|
use ry::inline::process_file_inline;
|
|
4
4
|
use std::fs;
|
|
5
5
|
use std::path::{Path, PathBuf};
|
|
6
|
+
use std::process::Command;
|
|
6
7
|
use tempfile::TempDir;
|
|
7
8
|
|
|
8
9
|
fn get_fixture_dirs() -> Vec<PathBuf> {
|
|
@@ -77,6 +78,42 @@ fn run_fixture_test(fixture_dir: &Path) {
|
|
|
77
78
|
fixture_name
|
|
78
79
|
);
|
|
79
80
|
}
|
|
81
|
+
|
|
82
|
+
let output_path = fixture_dir.join("output.txt");
|
|
83
|
+
|
|
84
|
+
let temp_check = temp_dir.path().join("check_input.py");
|
|
85
|
+
fs::copy(&input_path, &temp_check).unwrap();
|
|
86
|
+
|
|
87
|
+
let bin = env!("CARGO_BIN_EXE_ry");
|
|
88
|
+
let output = Command::new(bin)
|
|
89
|
+
.args([
|
|
90
|
+
"--config",
|
|
91
|
+
config_path.to_str().unwrap(),
|
|
92
|
+
"--verbose",
|
|
93
|
+
temp_check.to_str().unwrap(),
|
|
94
|
+
])
|
|
95
|
+
.output()
|
|
96
|
+
.expect("failed to run ry binary");
|
|
97
|
+
|
|
98
|
+
let temp_str = temp_check.to_str().unwrap();
|
|
99
|
+
let combined = format!(
|
|
100
|
+
"{}{}",
|
|
101
|
+
String::from_utf8_lossy(&output.stderr),
|
|
102
|
+
String::from_utf8_lossy(&output.stdout),
|
|
103
|
+
)
|
|
104
|
+
.replace(temp_str, "input.py");
|
|
105
|
+
|
|
106
|
+
if update_fixtures || !output_path.exists() {
|
|
107
|
+
fs::write(&output_path, &combined).unwrap();
|
|
108
|
+
println!("Fixture '{}': Generated output.txt", fixture_name);
|
|
109
|
+
} else {
|
|
110
|
+
let expected_output = fs::read_to_string(&output_path).unwrap();
|
|
111
|
+
assert_eq!(
|
|
112
|
+
combined, expected_output,
|
|
113
|
+
"Fixture '{}': Output does not match output.txt",
|
|
114
|
+
fixture_name
|
|
115
|
+
);
|
|
116
|
+
}
|
|
80
117
|
}
|
|
81
118
|
|
|
82
119
|
#[test]
|
ry_cli-0.4.0/uv.lock
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|