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