Skip to content

Commit ce22348

Browse files
committed
Add automatic update script
1 parent 07d2a99 commit ce22348

File tree

6 files changed

+130
-3
lines changed

6 files changed

+130
-3
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ bin/
4040
.vscode/
4141

4242
### Mac OS ###
43-
.DS_Store
43+
.DS_Store
44+
45+
## Custom ##
46+
openvadl-path.txt

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@ a custom (pre-release) version of the openvadl-lsp.
1414

1515
```bash
1616
./gradlew buildPlugin
17+
```
18+
19+
## Updating the LSP
20+
21+
We update the underlying LSP quite frequently, so there is an automated script you can use.
22+
```bash
23+
uv run update_lsp.py
1724
```

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = "vadl"
8-
version = "0.0.1"
8+
version = "0.0.2"
99

1010
repositories {
1111
mavenCentral()

src/main/resources/META-INF/plugin.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
2121
<depends>com.intellij.modules.lsp</depends>
2222

23-
<resource-bundle>messages.MyMessageBundle</resource-bundle>
2423
<!-- Extensions defined by the plugin.
2524
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
2625
<extensions defaultExtensionNs="com.intellij">
158 Bytes
Binary file not shown.

update_lsp.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import shutil
2+
import textwrap
3+
import os
4+
import subprocess
5+
from functools import cache
6+
import re
7+
8+
9+
def run_cmd(args: list[str], working_dir: str = ".") -> str:
10+
print(f"\tRunning command: {' '.join(args)}")
11+
result = subprocess.run(args, cwd=working_dir, capture_output=True, text=True, check=True)
12+
if result.returncode != 0:
13+
print(f"Command failed with exit code {result.returncode}: {result.args}")
14+
os.exit(1)
15+
return result.stdout
16+
17+
@cache
18+
def get_repo_path() -> str:
19+
cache_file = "openvadl-path.txt"
20+
if not os.path.exists(cache_file):
21+
repo_path = input("Enter the path to the OpenVADL repo:")
22+
with open(cache_file, "w") as f:
23+
f.write(repo_path)
24+
25+
with open(cache_file) as f:
26+
return f.read()
27+
28+
29+
def build_lsp():
30+
print("1) Building LSP")
31+
repo_path = get_repo_path()
32+
33+
## Checkout master
34+
current_branch = run_cmd(["git", "rev-parse", "--abbrev-ref", "HEAD"], repo_path).strip()
35+
if current_branch != "master":
36+
print(f"Not on master branch ({current_branch}).")
37+
answer = input("Can we switch to master? (y/n): ")
38+
if answer.lower() not in ["y", "yes"]:
39+
print("Aborting LSP build.")
40+
return
41+
42+
run_cmd(["git", "checkout", "master"], repo_path)
43+
run_cmd(["git", "pull",], repo_path)
44+
45+
## Build LSP
46+
run_cmd(["./gradlew", ":vadl-lsp:installDist"], repo_path)
47+
48+
49+
def copy_lsp():
50+
print("2) Copy LSP results")
51+
repo_path = get_repo_path()
52+
target_dir = "src/main/resources/openvadl-lsp"
53+
54+
if os.path.exists(target_dir):
55+
shutil.rmtree(target_dir)
56+
57+
shutil.copytree(repo_path + "/vadl-lsp/build/install/openvadl-lsp", target_dir)
58+
59+
60+
def update_metadata():
61+
print("3) Update Metadata")
62+
63+
# Read build.gradle.kts
64+
build_file = "build.gradle.kts"
65+
with open(build_file, 'r') as f:
66+
content = f.read()
67+
68+
# Find and increment the version
69+
version_pattern = r'version = "(\d+)\.(\d+)\.(\d+)"'
70+
match = re.search(version_pattern, content)
71+
72+
if match:
73+
major, minor, patch = match.groups()
74+
new_patch = int(patch) + 1
75+
new_version = f"{major}.{minor}.{new_patch}"
76+
77+
# Replace the version
78+
new_content = re.sub(version_pattern, f'version = "{new_version}"', content)
79+
80+
with open(build_file, 'w') as f:
81+
f.write(new_content)
82+
83+
print(f"\tUpdated version from {major}.{minor}.{patch} to {new_version}")
84+
else:
85+
print("\tWarning: Could not find version in build.gradle.kts")
86+
87+
88+
def build_plugin():
89+
print("4) Building plugin")
90+
run_cmd(["./gradlew", "buildPlugin"])
91+
92+
93+
94+
def publish():
95+
print(textwrap.dedent("""
96+
5) Publishing LSP
97+
At the moment we are still awaiting approval from JetBrains. So all updates have to be done manually.
98+
https://plugins.jetbrains.com/plugin/29659-openvadl/edit
99+
100+
Build plugin is at:
101+
build/idea-sandbox/IU-2025.3/plugins/intellij-openvadl/lib/
102+
""").strip())
103+
104+
def main():
105+
build_lsp()
106+
print()
107+
copy_lsp()
108+
print()
109+
update_metadata()
110+
print()
111+
build_plugin()
112+
print()
113+
publish()
114+
print()
115+
print("Done ✨")
116+
117+
if __name__ == "__main__":
118+
main()

0 commit comments

Comments
 (0)