Skip to content

Commit fc4382c

Browse files
committed
uprev.py
1 parent dd78c70 commit fc4382c

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

mcp-run-python/deno.json renamed to mcp-run-python/deno.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"src/*.ts",
3333
"src/prepareEnvCode.ts", // required to override gitignore
3434
"README.md",
35-
"deno.json"
35+
"deno.jsonc"
3636
]
3737
}
3838
}

mcp-run-python/uprev.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import re
2+
import sys
3+
4+
from pathlib import Path
5+
6+
if len(sys.argv) != 2:
7+
print("Usage: python uprev.py <new_version>")
8+
sys.exit(1)
9+
10+
new_version = sys.argv[1]
11+
this_dir = Path(__file__).parent
12+
13+
path_regexes = [
14+
(this_dir / 'deno.jsonc', r'^\s+"version": "(.+?)"'),
15+
(this_dir / 'src/main.ts', "^const VERSION = '(.+?)'"),
16+
(this_dir / '../pydantic_ai_slim/pydantic_ai/mcp_run_python.py', "^MCP_RUN_PYTHON_VERSION = '(.+?)'")
17+
]
18+
19+
def replace_version(m: re.Match[str]) -> str:
20+
version = m.group(1)
21+
return m.group(0).replace(version, new_version)
22+
23+
if __name__ == "__main__":
24+
for path, regex in path_regexes:
25+
path = path.resolve()
26+
content = path.read_text()
27+
content, count = re.subn(regex, replace_version, content, count=1, flags=re.M)
28+
if count != 1:
29+
raise ValueError(f"Failed to update version in {path}")
30+
path.write_text(content)
31+
print(f"Updated version to {new_version} in {path}")

0 commit comments

Comments
 (0)