cave-cli 3.5.4__tar.gz → 3.6.0b1__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.
- {cave_cli-3.5.4/cave_cli.egg-info → cave_cli-3.6.0b1}/PKG-INFO +29 -16
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/README.md +19 -15
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/cli.py +28 -1
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/doctor.py +16 -12
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/list_cmd.py +7 -2
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/list_versions.py +3 -6
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/prettify.py +1 -1
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/reset.py +1 -1
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/run.py +55 -4
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/sync_cmd.py +8 -7
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/test.py +1 -1
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/uninstall.py +7 -10
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/update.py +15 -17
- cave_cli-3.6.0b1/cave_cli/commands/upgrade.py +246 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/version.py +21 -15
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/display.py +30 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/docker.py +73 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/logger.py +2 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/subprocess.py +1 -21
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/validate.py +45 -6
- cave_cli-3.6.0b1/cave_cli/utils/version.py +133 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1/cave_cli.egg-info}/PKG-INFO +29 -16
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli.egg-info/SOURCES.txt +8 -2
- cave_cli-3.6.0b1/cave_cli.egg-info/requires.txt +10 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/pyproject.toml +16 -1
- cave_cli-3.6.0b1/setup.cfg +4 -0
- cave_cli-3.6.0b1/test/test_env.py +113 -0
- cave_cli-3.6.0b1/test/test_net.py +33 -0
- cave_cli-3.6.0b1/test/test_sync.py +42 -0
- cave_cli-3.6.0b1/test/test_validate.py +49 -0
- cave_cli-3.6.0b1/utils/prettify.py +25 -0
- cave_cli-3.5.4/cave_cli/commands/upgrade.py +0 -75
- cave_cli-3.5.4/setup.cfg +0 -10
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/LICENSE +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/NOTICE.md +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/__init__.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/__init__.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/create.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/kill.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/purge.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/commands/theme.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/__init__.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/cache.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/constants.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/env.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/git.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/net.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli/utils/sync.py +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli.egg-info/dependency_links.txt +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli.egg-info/entry_points.txt +0 -0
- {cave_cli-3.5.4 → cave_cli-3.6.0b1}/cave_cli.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cave_cli
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.6.0b1
|
|
4
4
|
Summary: CLI for creating and managing Docker-based CAVE web applications.
|
|
5
5
|
Author-email: MIT-CAVE <cave-contact@mit.edu>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -13,6 +13,15 @@ Requires-Python: >=3.11
|
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
License-File: NOTICE.md
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest>=9.0.3; extra == "dev"
|
|
18
|
+
Requires-Dist: autoflake>=2.3.1; extra == "dev"
|
|
19
|
+
Requires-Dist: black>=25.1.0; extra == "dev"
|
|
20
|
+
Requires-Dist: build>=1.4.0; extra == "dev"
|
|
21
|
+
Requires-Dist: nox>=2026.4.10; extra == "dev"
|
|
22
|
+
Requires-Dist: nox-uv>=0.8.0; extra == "dev"
|
|
23
|
+
Requires-Dist: pdoc>=15.0.1; extra == "dev"
|
|
24
|
+
Requires-Dist: twine>=6.2.0; extra == "dev"
|
|
16
25
|
Dynamic: license-file
|
|
17
26
|
|
|
18
27
|
# CAVE CLI
|
|
@@ -56,38 +65,42 @@ docker run hello-world
|
|
|
56
65
|
|
|
57
66
|
## Installation
|
|
58
67
|
|
|
59
|
-
Install with [
|
|
68
|
+
Install with [uv](https://docs.astral.sh/uv/) (required to run cave update and cave uninstall):
|
|
60
69
|
|
|
61
70
|
```sh
|
|
62
|
-
|
|
71
|
+
uv tool install cave_cli
|
|
63
72
|
```
|
|
64
73
|
|
|
65
|
-
If you don't have
|
|
74
|
+
If you don't have uv, install it first:
|
|
66
75
|
|
|
67
76
|
<details>
|
|
68
77
|
<summary>macOS</summary>
|
|
69
78
|
|
|
70
79
|
```sh
|
|
71
80
|
# With Homebrew (recommended)
|
|
72
|
-
brew install
|
|
73
|
-
pipx ensurepath
|
|
81
|
+
brew install uv
|
|
74
82
|
|
|
75
|
-
# Or with
|
|
76
|
-
|
|
77
|
-
pipx ensurepath
|
|
83
|
+
# Or with the official installer
|
|
84
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
78
85
|
```
|
|
79
86
|
|
|
80
87
|
</details>
|
|
81
88
|
<details>
|
|
82
|
-
<summary>
|
|
89
|
+
<summary>Linux</summary>
|
|
83
90
|
|
|
84
91
|
```sh
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
93
|
+
```
|
|
94
|
+
</details>
|
|
95
|
+
<details>
|
|
96
|
+
<summary>Windows</summary>
|
|
97
|
+
|
|
98
|
+
```powershell
|
|
99
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
87
100
|
```
|
|
88
101
|
</details>
|
|
89
102
|
|
|
90
|
-
For more options see the [
|
|
103
|
+
For more options see the [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/).
|
|
91
104
|
|
|
92
105
|
Verify the installation and check your environment health:
|
|
93
106
|
|
|
@@ -116,7 +129,7 @@ cave --help
|
|
|
116
129
|
|---|---|
|
|
117
130
|
| `cave create <name>` | Create a new CAVE app from the template repository |
|
|
118
131
|
| `cave run` | Build Docker image and run the app with a live TUI dashboard |
|
|
119
|
-
| `cave doctor` | Check the health of your Docker, Git, and
|
|
132
|
+
| `cave doctor` | Check the health of your Docker, Git, and uv environment |
|
|
120
133
|
|
|
121
134
|
### Peripheral Commands
|
|
122
135
|
|
|
@@ -163,10 +176,10 @@ cave --help
|
|
|
163
176
|
cave update
|
|
164
177
|
```
|
|
165
178
|
|
|
166
|
-
Or directly via
|
|
179
|
+
Or directly via uv:
|
|
167
180
|
|
|
168
181
|
```sh
|
|
169
|
-
|
|
182
|
+
uv tool upgrade cave_cli
|
|
170
183
|
```
|
|
171
184
|
|
|
172
185
|
## License Notice
|
|
@@ -39,38 +39,42 @@ docker run hello-world
|
|
|
39
39
|
|
|
40
40
|
## Installation
|
|
41
41
|
|
|
42
|
-
Install with [
|
|
42
|
+
Install with [uv](https://docs.astral.sh/uv/) (required to run cave update and cave uninstall):
|
|
43
43
|
|
|
44
44
|
```sh
|
|
45
|
-
|
|
45
|
+
uv tool install cave_cli
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
If you don't have
|
|
48
|
+
If you don't have uv, install it first:
|
|
49
49
|
|
|
50
50
|
<details>
|
|
51
51
|
<summary>macOS</summary>
|
|
52
52
|
|
|
53
53
|
```sh
|
|
54
54
|
# With Homebrew (recommended)
|
|
55
|
-
brew install
|
|
56
|
-
pipx ensurepath
|
|
55
|
+
brew install uv
|
|
57
56
|
|
|
58
|
-
# Or with
|
|
59
|
-
|
|
60
|
-
pipx ensurepath
|
|
57
|
+
# Or with the official installer
|
|
58
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
61
59
|
```
|
|
62
60
|
|
|
63
61
|
</details>
|
|
64
62
|
<details>
|
|
65
|
-
<summary>
|
|
63
|
+
<summary>Linux</summary>
|
|
66
64
|
|
|
67
65
|
```sh
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
67
|
+
```
|
|
68
|
+
</details>
|
|
69
|
+
<details>
|
|
70
|
+
<summary>Windows</summary>
|
|
71
|
+
|
|
72
|
+
```powershell
|
|
73
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
70
74
|
```
|
|
71
75
|
</details>
|
|
72
76
|
|
|
73
|
-
For more options see the [
|
|
77
|
+
For more options see the [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/).
|
|
74
78
|
|
|
75
79
|
Verify the installation and check your environment health:
|
|
76
80
|
|
|
@@ -99,7 +103,7 @@ cave --help
|
|
|
99
103
|
|---|---|
|
|
100
104
|
| `cave create <name>` | Create a new CAVE app from the template repository |
|
|
101
105
|
| `cave run` | Build Docker image and run the app with a live TUI dashboard |
|
|
102
|
-
| `cave doctor` | Check the health of your Docker, Git, and
|
|
106
|
+
| `cave doctor` | Check the health of your Docker, Git, and uv environment |
|
|
103
107
|
|
|
104
108
|
### Peripheral Commands
|
|
105
109
|
|
|
@@ -146,10 +150,10 @@ cave --help
|
|
|
146
150
|
cave update
|
|
147
151
|
```
|
|
148
152
|
|
|
149
|
-
Or directly via
|
|
153
|
+
Or directly via uv:
|
|
150
154
|
|
|
151
155
|
```sh
|
|
152
|
-
|
|
156
|
+
uv tool upgrade cave_cli
|
|
153
157
|
```
|
|
154
158
|
|
|
155
159
|
## License Notice
|
|
@@ -38,6 +38,13 @@ def add_global_args(parser: argparse.ArgumentParser) -> None:
|
|
|
38
38
|
default=False,
|
|
39
39
|
help="Enable verbose logging output (shorthand for --loglevel DEBUG)",
|
|
40
40
|
)
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"-q",
|
|
43
|
+
"--quiet",
|
|
44
|
+
action="store_true",
|
|
45
|
+
default=False,
|
|
46
|
+
help="Enable quiet mode (suppress most output, shorthand for --loglevel SILENT)",
|
|
47
|
+
)
|
|
41
48
|
parser.add_argument(
|
|
42
49
|
"--loglevel",
|
|
43
50
|
"--ll",
|
|
@@ -162,6 +169,12 @@ def main():
|
|
|
162
169
|
),
|
|
163
170
|
)
|
|
164
171
|
add_global_args(p_reset)
|
|
172
|
+
p_reset.add_argument(
|
|
173
|
+
"--docker-args",
|
|
174
|
+
default="",
|
|
175
|
+
metavar="ARGS",
|
|
176
|
+
help="Additional arguments to pass to docker run",
|
|
177
|
+
)
|
|
165
178
|
|
|
166
179
|
# ------------------------------------------------------------------ #
|
|
167
180
|
# upgrade #
|
|
@@ -233,6 +246,12 @@ def main():
|
|
|
233
246
|
help="Run tests in cave_api/tests/",
|
|
234
247
|
)
|
|
235
248
|
add_global_args(p_test)
|
|
249
|
+
p_test.add_argument(
|
|
250
|
+
"--docker-args",
|
|
251
|
+
default="",
|
|
252
|
+
metavar="ARGS",
|
|
253
|
+
help="Additional arguments to pass to docker run",
|
|
254
|
+
)
|
|
236
255
|
p_test.add_argument(
|
|
237
256
|
"remaining",
|
|
238
257
|
nargs="*",
|
|
@@ -247,6 +266,12 @@ def main():
|
|
|
247
266
|
help="Format code with autoflake and black",
|
|
248
267
|
)
|
|
249
268
|
add_global_args(p_prettify)
|
|
269
|
+
p_prettify.add_argument(
|
|
270
|
+
"--docker-args",
|
|
271
|
+
default="",
|
|
272
|
+
metavar="ARGS",
|
|
273
|
+
help="Additional arguments to pass to docker run",
|
|
274
|
+
)
|
|
250
275
|
|
|
251
276
|
# ------------------------------------------------------------------ #
|
|
252
277
|
# list #
|
|
@@ -401,7 +426,9 @@ def main():
|
|
|
401
426
|
# Configure logging
|
|
402
427
|
from cave_cli.utils.logger import logger
|
|
403
428
|
|
|
404
|
-
if args
|
|
429
|
+
if getattr(args, "quiet", False):
|
|
430
|
+
logger.set_level("SILENT")
|
|
431
|
+
elif args.verbose:
|
|
405
432
|
logger.set_level("DEBUG")
|
|
406
433
|
else:
|
|
407
434
|
logger.set_level(args.loglevel)
|
|
@@ -34,31 +34,35 @@ def check_git() -> tuple[bool, str]:
|
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def
|
|
37
|
+
def check_uv(return_path: bool = True) -> tuple[bool, str, str | None]:
|
|
38
38
|
"""
|
|
39
39
|
Usage:
|
|
40
40
|
|
|
41
|
-
- Validates that
|
|
41
|
+
- Validates that uv is installed
|
|
42
42
|
|
|
43
43
|
Returns:
|
|
44
44
|
|
|
45
45
|
- ``success``: bool
|
|
46
46
|
- ``message``: str remediation or version
|
|
47
|
+
- ``path``: str|None path to uv executable if found
|
|
47
48
|
"""
|
|
48
49
|
import shutil
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
if
|
|
51
|
+
uv_path = shutil.which("uv")
|
|
52
|
+
if uv_path:
|
|
52
53
|
try:
|
|
53
|
-
result = run([
|
|
54
|
+
result = run([uv_path, "--version"])
|
|
54
55
|
if result.returncode == 0:
|
|
55
|
-
|
|
56
|
+
output = True, f"uv version {result.stdout.strip()}"
|
|
57
|
+
if return_path:
|
|
58
|
+
return output + (uv_path,)
|
|
59
|
+
return output
|
|
56
60
|
except Exception:
|
|
57
61
|
pass
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
output = False, "uv is not installed. Please install uv: https://github.com/astral-sh/uv"
|
|
63
|
+
if return_path:
|
|
64
|
+
return output + (None,)
|
|
65
|
+
return output
|
|
62
66
|
|
|
63
67
|
|
|
64
68
|
def check_docker() -> tuple[bool, str]:
|
|
@@ -126,7 +130,7 @@ def check_all(exit_on_fail: bool = True) -> dict[str, tuple[bool, str]]:
|
|
|
126
130
|
results = {
|
|
127
131
|
"Docker": check_docker(),
|
|
128
132
|
"Git": check_git(),
|
|
129
|
-
"
|
|
133
|
+
"uv": check_uv(return_path=False),
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
if exit_on_fail:
|
|
@@ -145,7 +149,7 @@ def doctor(args: argparse.Namespace) -> None:
|
|
|
145
149
|
"""
|
|
146
150
|
Usage:
|
|
147
151
|
|
|
148
|
-
- Checks the health of the CAVE environment (Docker, Git,
|
|
152
|
+
- Checks the health of the CAVE environment (Docker, Git, uv)
|
|
149
153
|
"""
|
|
150
154
|
print_section("CAVE Doctor")
|
|
151
155
|
|
|
@@ -20,9 +20,11 @@ def list_cmd(args: argparse.Namespace) -> None:
|
|
|
20
20
|
|
|
21
21
|
if show_all:
|
|
22
22
|
print_section("CAVE App Containers (All)")
|
|
23
|
+
from cave_cli.utils.display import _QUIET
|
|
23
24
|
for suffix in ("_django", "_db_host", "_redis_host", "_nginx_host"):
|
|
24
25
|
for name in get_all_containers(suffix):
|
|
25
|
-
|
|
26
|
+
if not _QUIET:
|
|
27
|
+
print(f" ● {name}")
|
|
26
28
|
else:
|
|
27
29
|
apps = get_running_apps()
|
|
28
30
|
if not apps:
|
|
@@ -40,4 +42,7 @@ def list_cmd(args: argparse.Namespace) -> None:
|
|
|
40
42
|
else:
|
|
41
43
|
port = get_container_host_port(f"{app_name}_django")
|
|
42
44
|
print_key_value(app_name, f"http://localhost:{port}")
|
|
43
|
-
|
|
45
|
+
|
|
46
|
+
from cave_cli.utils.display import _QUIET
|
|
47
|
+
if not _QUIET:
|
|
48
|
+
print("")
|
|
@@ -14,14 +14,11 @@ from cave_cli.utils.display import (
|
|
|
14
14
|
)
|
|
15
15
|
from cave_cli.utils.git import ls_remote_tags
|
|
16
16
|
from cave_cli.utils.logger import logger
|
|
17
|
+
from cave_cli.utils.version import version_tuple
|
|
17
18
|
|
|
18
19
|
RECENT_LIMIT = 5
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
def _version_sort_key(v: str) -> list[int]:
|
|
22
|
-
return [int(x) for x in re.findall(r"\d+", v)]
|
|
23
|
-
|
|
24
|
-
|
|
25
22
|
def list_versions(args: argparse.Namespace) -> None:
|
|
26
23
|
"""
|
|
27
24
|
Usage:
|
|
@@ -54,7 +51,7 @@ def list_versions(args: argparse.Namespace) -> None:
|
|
|
54
51
|
v for v in set().union(*repo_tags.values())
|
|
55
52
|
if not pattern or fnmatch.fnmatch(v, pattern)
|
|
56
53
|
),
|
|
57
|
-
key=
|
|
54
|
+
key=version_tuple,
|
|
58
55
|
reverse=True,
|
|
59
56
|
)
|
|
60
57
|
|
|
@@ -64,7 +61,7 @@ def list_versions(args: argparse.Namespace) -> None:
|
|
|
64
61
|
|
|
65
62
|
by_major: dict[int, list[str]] = defaultdict(list)
|
|
66
63
|
for v in all_versions:
|
|
67
|
-
major =
|
|
64
|
+
major = version_tuple(v)[0]
|
|
68
65
|
by_major[major].append(v)
|
|
69
66
|
|
|
70
67
|
repos = list(VALID_REPOS)
|
|
@@ -18,7 +18,7 @@ def prettify(args: argparse.Namespace) -> None:
|
|
|
18
18
|
entrypoint="./utils/prettify.sh",
|
|
19
19
|
interactive=False,
|
|
20
20
|
it=False,
|
|
21
|
-
docker_args="",
|
|
21
|
+
docker_args=getattr(args, "docker_args", "") or "",
|
|
22
22
|
ip_port=None,
|
|
23
23
|
yes=True,
|
|
24
24
|
verbose=getattr(args, "verbose", False),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import argparse
|
|
2
|
+
import shlex
|
|
2
3
|
import signal
|
|
3
4
|
import sys
|
|
4
5
|
import threading
|
|
@@ -8,12 +9,14 @@ from cave_cli.utils.display import (
|
|
|
8
9
|
RunDashboard,
|
|
9
10
|
print_section,
|
|
10
11
|
step_done,
|
|
12
|
+
step_fail,
|
|
11
13
|
step_start,
|
|
12
14
|
)
|
|
13
15
|
from cave_cli.utils.docker import (
|
|
14
16
|
build_image,
|
|
15
17
|
create_network,
|
|
16
18
|
remove_containers,
|
|
19
|
+
run_and_log,
|
|
17
20
|
run_detached,
|
|
18
21
|
run_detached_logged,
|
|
19
22
|
run_interactive,
|
|
@@ -49,10 +52,11 @@ def run_cave(
|
|
|
49
52
|
show_all = getattr(args, "show_all", False) or getattr(args, "verbose", False) or getattr(args, "loglevel", "INFO").upper() == "DEBUG"
|
|
50
53
|
entrypoint = getattr(args, "entrypoint", None) or "./utils/run_server.sh"
|
|
51
54
|
docker_args_str = getattr(args, "docker_args", "") or ""
|
|
52
|
-
extra_docker_args =
|
|
55
|
+
extra_docker_args = shlex.split(docker_args_str) if docker_args_str else []
|
|
53
56
|
ip_port_arg = getattr(args, "ip_port", None)
|
|
54
57
|
command_args = getattr(args, "command_args", []) or []
|
|
55
58
|
extra_env = getattr(args, "extra_env", {}) or {}
|
|
59
|
+
quiet = getattr(args, "quiet", False) or getattr(args, "loglevel", "INFO").upper() == "SILENT"
|
|
56
60
|
|
|
57
61
|
is_server_run = entrypoint == "./utils/run_server.sh" and not interactive
|
|
58
62
|
use_tui = is_server_run and not show_all
|
|
@@ -136,6 +140,50 @@ def run_cave(
|
|
|
136
140
|
|
|
137
141
|
django_volumes = [f"{app_dir}:/app"]
|
|
138
142
|
|
|
143
|
+
# Check if database needs initialization
|
|
144
|
+
if is_server_run and "postgres" in db_image.lower():
|
|
145
|
+
from cave_cli.utils.docker import is_container_ready, is_db_initialized
|
|
146
|
+
from cave_cli.utils.validate import confirm_action
|
|
147
|
+
|
|
148
|
+
db_container = f"{app_name}_db_host"
|
|
149
|
+
db_user = f"{app_name}_user"
|
|
150
|
+
db_name = f"{app_name}_name"
|
|
151
|
+
|
|
152
|
+
step_start("Checking database")
|
|
153
|
+
import time
|
|
154
|
+
|
|
155
|
+
ready = False
|
|
156
|
+
for _ in range(30):
|
|
157
|
+
if is_container_ready(db_container, db_user):
|
|
158
|
+
ready = True
|
|
159
|
+
break
|
|
160
|
+
time.sleep(1)
|
|
161
|
+
|
|
162
|
+
if ready:
|
|
163
|
+
if not is_db_initialized(db_container, db_user, db_name):
|
|
164
|
+
step_done("Checking database")
|
|
165
|
+
confirm_action(
|
|
166
|
+
"The database for this app is not set up. "
|
|
167
|
+
"Would you like to set it up now?"
|
|
168
|
+
)
|
|
169
|
+
step_start("Initializing database")
|
|
170
|
+
run_interactive(
|
|
171
|
+
name=f"{app_name}_django_setup",
|
|
172
|
+
image=f"cave-app:{app_name}",
|
|
173
|
+
network=network,
|
|
174
|
+
volumes=django_volumes,
|
|
175
|
+
env_vars=django_env,
|
|
176
|
+
command=["./utils/reset_db.sh"],
|
|
177
|
+
)
|
|
178
|
+
run_and_log(["docker", "rm", f"{app_name}_django_setup"])
|
|
179
|
+
step_done("Initializing database")
|
|
180
|
+
else:
|
|
181
|
+
step_done("Checking database")
|
|
182
|
+
else:
|
|
183
|
+
step_fail("Checking database", "Database container failed to become ready.")
|
|
184
|
+
remove_containers(app_name)
|
|
185
|
+
sys.exit(1)
|
|
186
|
+
|
|
139
187
|
parsed = parse_ip_port(ip_port_arg) if ip_port_arg else None
|
|
140
188
|
django_container = f"{app_name}_django"
|
|
141
189
|
|
|
@@ -177,7 +225,7 @@ def run_cave(
|
|
|
177
225
|
url = f"https://{ip}:{port}"
|
|
178
226
|
|
|
179
227
|
if interactive:
|
|
180
|
-
logger.header("CAVE App
|
|
228
|
+
logger.header("CAVE App (Interactive)")
|
|
181
229
|
run_interactive(
|
|
182
230
|
name=django_container,
|
|
183
231
|
image=f"cave-app:{app_name}",
|
|
@@ -189,8 +237,8 @@ def run_cave(
|
|
|
189
237
|
command=server_command,
|
|
190
238
|
)
|
|
191
239
|
remove_containers(app_name)
|
|
192
|
-
|
|
193
240
|
elif use_tui:
|
|
241
|
+
logger.header("CAVE App (TUI)")
|
|
194
242
|
_run_tui(
|
|
195
243
|
app_name=app_name,
|
|
196
244
|
django_container=django_container,
|
|
@@ -205,6 +253,7 @@ def run_cave(
|
|
|
205
253
|
)
|
|
206
254
|
|
|
207
255
|
else:
|
|
256
|
+
logger.header("CAVE App (CLI)")
|
|
208
257
|
if is_server_run:
|
|
209
258
|
logger.info(
|
|
210
259
|
f"Your Cave App can be accessed from Chrome at:\n{url}"
|
|
@@ -226,7 +275,7 @@ def run_cave(
|
|
|
226
275
|
url = f"http://localhost:{port}"
|
|
227
276
|
|
|
228
277
|
if interactive:
|
|
229
|
-
logger.header("CAVE App
|
|
278
|
+
logger.header("CAVE App (Interactive)")
|
|
230
279
|
run_interactive(
|
|
231
280
|
name=django_container,
|
|
232
281
|
image=f"cave-app:{app_name}",
|
|
@@ -240,6 +289,7 @@ def run_cave(
|
|
|
240
289
|
remove_containers(app_name)
|
|
241
290
|
|
|
242
291
|
elif use_tui:
|
|
292
|
+
logger.header("CAVE App (TUI)")
|
|
243
293
|
_run_tui(
|
|
244
294
|
app_name=app_name,
|
|
245
295
|
django_container=django_container,
|
|
@@ -254,6 +304,7 @@ def run_cave(
|
|
|
254
304
|
)
|
|
255
305
|
|
|
256
306
|
else:
|
|
307
|
+
logger.header("CAVE App (CLI)")
|
|
257
308
|
if is_server_run:
|
|
258
309
|
logger.info(
|
|
259
310
|
f"Your Cave App can be accessed from Chrome at:\n{url}"
|
|
@@ -12,7 +12,7 @@ from cave_cli.utils.sync import sync_files
|
|
|
12
12
|
from cave_cli.utils.validate import confirm_action, find_app_dir
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
def sync_cmd(args: argparse.Namespace) -> None:
|
|
15
|
+
def sync_cmd(args: argparse.Namespace, do_reset: bool=True) -> None:
|
|
16
16
|
"""
|
|
17
17
|
Usage:
|
|
18
18
|
|
|
@@ -69,11 +69,12 @@ def sync_cmd(args: argparse.Namespace) -> None:
|
|
|
69
69
|
|
|
70
70
|
shutil.rmtree(temp_dir, ignore_errors=True)
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
if do_reset:
|
|
73
|
+
reset_args = argparse.Namespace(
|
|
74
|
+
yes=True,
|
|
75
|
+
verbose=getattr(args, "verbose", False),
|
|
76
|
+
loglevel=getattr(args, "loglevel", "INFO"),
|
|
77
|
+
)
|
|
78
|
+
reset(reset_args)
|
|
78
79
|
|
|
79
80
|
logger.success("Sync complete.")
|
|
@@ -5,15 +5,14 @@ import sys
|
|
|
5
5
|
|
|
6
6
|
from cave_cli.utils.display import RED, RESET, step_done, step_start
|
|
7
7
|
from cave_cli.utils.logger import logger
|
|
8
|
-
|
|
9
|
-
PIPX_DOCS_URL = "https://pipx.pypa.io/stable/installation/"
|
|
8
|
+
from cave_cli.commands.doctor import check_uv
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
def uninstall(args: argparse.Namespace) -> None:
|
|
13
12
|
"""
|
|
14
13
|
Usage:
|
|
15
14
|
|
|
16
|
-
- Removes the CAVE CLI package via
|
|
15
|
+
- Removes the CAVE CLI package via uv.
|
|
17
16
|
"""
|
|
18
17
|
try:
|
|
19
18
|
response = input(
|
|
@@ -28,17 +27,15 @@ def uninstall(args: argparse.Namespace) -> None:
|
|
|
28
27
|
logger.error("Uninstall canceled")
|
|
29
28
|
return
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
if not
|
|
33
|
-
logger.error(
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
logger.error(f"See: {PIPX_DOCS_URL}")
|
|
30
|
+
has_uv, uv_message, uv_path = check_uv()
|
|
31
|
+
if not has_uv:
|
|
32
|
+
logger.error(uv_message)
|
|
33
|
+
logger.error(f"You may need to uninstall CAVE CLI manually based on how it was installed.")
|
|
37
34
|
sys.exit(1)
|
|
38
35
|
|
|
39
36
|
step_start("Removing installation")
|
|
40
37
|
result = subprocess.run(
|
|
41
|
-
[
|
|
38
|
+
[uv_path, "tool", "uninstall", "cave_cli"],
|
|
42
39
|
stdout=subprocess.PIPE,
|
|
43
40
|
stderr=subprocess.PIPE,
|
|
44
41
|
text=True,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import argparse
|
|
2
|
-
import shutil
|
|
3
2
|
import subprocess
|
|
4
3
|
import sys
|
|
5
4
|
import tempfile
|
|
6
5
|
|
|
7
6
|
from cave_cli.utils.display import step_done, step_start
|
|
8
7
|
from cave_cli.utils.logger import logger
|
|
8
|
+
from cave_cli.commands.doctor import check_uv
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
UV_DOCS_URL = "https://docs.astral.sh/uv/"
|
|
11
11
|
CLI_REPO_URL = "https://github.com/MIT-CAVE/cave_cli.git"
|
|
12
12
|
|
|
13
13
|
|
|
@@ -15,32 +15,30 @@ def update(args: argparse.Namespace) -> None:
|
|
|
15
15
|
"""
|
|
16
16
|
Usage:
|
|
17
17
|
|
|
18
|
-
- Updates the CAVE CLI via
|
|
18
|
+
- Updates the CAVE CLI via uv.
|
|
19
19
|
|
|
20
20
|
Notes:
|
|
21
21
|
|
|
22
|
-
- Without ``--version``,
|
|
23
|
-
``
|
|
24
|
-
- With ``--version``, reinstalls via ``
|
|
25
|
-
specified git tag or branch.
|
|
22
|
+
- Without ``--version``, upgrades to the latest version from PyPI via
|
|
23
|
+
``uv tool upgrade cave_cli``.
|
|
24
|
+
- With ``--version``, reinstalls via ``uv tool install --reinstall`` from
|
|
25
|
+
the specified git tag or branch.
|
|
26
26
|
- On Windows, the update runs in a new console window because Windows
|
|
27
27
|
locks running executables and cave.exe cannot replace itself.
|
|
28
28
|
"""
|
|
29
|
-
|
|
30
|
-
if not
|
|
31
|
-
logger.error(
|
|
32
|
-
|
|
33
|
-
)
|
|
34
|
-
logger.error(f"See: {PIPX_DOCS_URL}")
|
|
29
|
+
has_uv, uv_message, uv_path= check_uv()
|
|
30
|
+
if not has_uv:
|
|
31
|
+
logger.error(uv_message)
|
|
32
|
+
logger.error(f"The cave_cli package may need to be updated manually based on how it was installed.")
|
|
35
33
|
sys.exit(1)
|
|
36
34
|
|
|
37
35
|
version = getattr(args, "version", None)
|
|
38
36
|
if version:
|
|
39
37
|
label = f"Reinstalling CAVE CLI ({version})"
|
|
40
|
-
|
|
38
|
+
cmd = [uv_path, "tool", "install", "--reinstall", f"cave_cli @ git+{CLI_REPO_URL}@{version}"]
|
|
41
39
|
else:
|
|
42
40
|
label = "Updating CAVE CLI"
|
|
43
|
-
|
|
41
|
+
cmd = [uv_path, "tool", "upgrade", "cave_cli"]
|
|
44
42
|
|
|
45
43
|
step_start(label)
|
|
46
44
|
|
|
@@ -54,7 +52,7 @@ def update(args: argparse.Namespace) -> None:
|
|
|
54
52
|
) as f:
|
|
55
53
|
f.write("@echo off\r\n")
|
|
56
54
|
f.write("timeout /t 1 /nobreak >nul\r\n")
|
|
57
|
-
f.write(f'"{
|
|
55
|
+
f.write(" ".join(f'"{c}"' for c in cmd) + "\r\n")
|
|
58
56
|
f.write('del "%~f0"\r\n')
|
|
59
57
|
bat_path = f.name
|
|
60
58
|
subprocess.Popen(
|
|
@@ -66,7 +64,7 @@ def update(args: argparse.Namespace) -> None:
|
|
|
66
64
|
return
|
|
67
65
|
|
|
68
66
|
result = subprocess.run(
|
|
69
|
-
|
|
67
|
+
cmd,
|
|
70
68
|
stdout=subprocess.PIPE,
|
|
71
69
|
stderr=subprocess.PIPE,
|
|
72
70
|
text=True,
|