mirror of
https://github.com/frappe/bench.git
synced 2025-01-08 16:14:12 +00:00
feat: verbose env setup & checking for compatible versions
This commit is contained in:
parent
79765e6b25
commit
d178b08abb
23
bench/app.py
23
bench/app.py
@ -343,7 +343,7 @@ def get_app(
|
||||
|
||||
if resolve_deps:
|
||||
resolution = make_resolution_plan(app, bench)
|
||||
click.secho("Apps to be installed:", fg="yellow")
|
||||
click.secho("Following apps will be installed", fg="yellow")
|
||||
for idx, app in enumerate(reversed(resolution.values()), start=1):
|
||||
print(f"{idx}. {app.name}")
|
||||
|
||||
@ -379,6 +379,7 @@ def get_app(
|
||||
|
||||
if resolve_deps:
|
||||
install_resolved_deps(
|
||||
bench,
|
||||
resolution,
|
||||
bench_path=bench_path,
|
||||
skip_assets=skip_assets,
|
||||
@ -412,6 +413,7 @@ def get_app(
|
||||
app.install(verbose=verbose, skip_assets=skip_assets)
|
||||
|
||||
def install_resolved_deps(
|
||||
bench,
|
||||
resolution,
|
||||
bench_path=".",
|
||||
skip_assets=False,
|
||||
@ -424,16 +426,19 @@ def install_resolved_deps(
|
||||
del resolution["frappe"]
|
||||
|
||||
for repo_name, app in reversed(resolution.items()):
|
||||
existing_dir, cloned_path = check_existing_dir(bench_path, repo_name)
|
||||
existing_dir, _ = check_existing_dir(bench_path, repo_name)
|
||||
if existing_dir:
|
||||
if click.confirm(
|
||||
f"A directory for the application '{repo_name}' already exists. "
|
||||
"Do you want to continue and overwrite it?"
|
||||
):
|
||||
click.secho(f"Removing {repo_name}", fg="yellow")
|
||||
shutil.rmtree(cloned_path)
|
||||
if bench.apps.states[repo_name]["resolution"] != app.tag:
|
||||
click.secho(
|
||||
f"Incompatible version of {repo_name} is already installed",
|
||||
fg="yellow",
|
||||
)
|
||||
app.install_resolved_apps(skip_assets=skip_assets, verbose=verbose)
|
||||
|
||||
else:
|
||||
click.secho(
|
||||
f"Compatible version of {repo_name} is already installed",
|
||||
fg="yellow",
|
||||
)
|
||||
continue
|
||||
app.install_resolved_apps(skip_assets=skip_assets, verbose=verbose)
|
||||
|
||||
|
@ -160,18 +160,16 @@ class BenchApps(MutableSequence):
|
||||
self.bench = bench
|
||||
self.states_path = os.path.join(self.bench.name, "sites", "apps_states.json")
|
||||
self.initialize_apps()
|
||||
self.set_states()
|
||||
|
||||
def set_states(self):
|
||||
try:
|
||||
with open(self.states_path, "r") as f:
|
||||
self.states = json.loads(f.read() or "{}")
|
||||
except FileNotFoundError:
|
||||
with open(self.states_path, "w+") as f:
|
||||
self.states = json.loads(f.read() or "{}")
|
||||
self.states = {}
|
||||
|
||||
def update_apps_states(self, app_name: str = None, resolution: str = None):
|
||||
self.initialize_apps()
|
||||
self.set_states()
|
||||
apps_to_remove = []
|
||||
for app in self.states:
|
||||
if app not in self.apps:
|
||||
@ -281,6 +279,9 @@ class BenchSetup(Base):
|
||||
- install frappe python dependencies
|
||||
"""
|
||||
import bench.cli
|
||||
import click
|
||||
|
||||
click.secho("Setting Up Environment", fg="yellow")
|
||||
|
||||
frappe = os.path.join(self.bench.name, "apps", "frappe")
|
||||
virtualenv = get_venv_path()
|
||||
|
Loading…
Reference in New Issue
Block a user