diff --git a/bench/app.py b/bench/app.py index f4ea84ec..ab22eea2 100755 --- a/bench/app.py +++ b/bench/app.py @@ -222,7 +222,7 @@ class App(AppMeta): return info_file["required_apps"] if info_file else {} -def make_resolution_plan(app: App, bench): +def make_resolution_plan(app: App, bench: "Bench"): """ decide what apps and versions to install and in what order """ @@ -332,6 +332,7 @@ def get_app( verbose=False, overwrite=False, init_bench=False, + resolve=False, ): """bench get-app clones a Frappe App from remote (GitHub or any other git server), and installs it on the current bench. This also resolves dependencies based on the @@ -343,6 +344,7 @@ def get_app( from bench.bench import Bench import bench as _bench import bench.cli as bench_cli + from bench.utils.app import check_existing_dir bench = Bench(bench_path) app = App(git_url, branch=branch, bench=bench) @@ -375,9 +377,17 @@ def get_app( "color": None, }) + if resolve: + resolve_and_install( + app=app, + bench=bench, + bench_path=bench_path, + skip_assets=skip_assets, + verbose=verbose, + ) + return - cloned_path = os.path.join(bench_path, "apps", repo_name) - dir_already_exists = os.path.isdir(cloned_path) + dir_already_exists, cloned_path = check_existing_dir(bench_path, repo_name) to_clone = not dir_already_exists # application directory already exists @@ -403,35 +413,20 @@ def get_app( app.install(verbose=verbose, skip_assets=skip_assets) def resolve_and_install( - git_url, - branch=None, + app: App, + bench: "Bench", bench_path=".", skip_assets=False, verbose=False, - init_bench=False, ): - from bench.cli import Bench - from bench.utils.system import init from bench.utils.app import check_existing_dir - bench = Bench(bench_path) - app = App(git_url, branch=branch, bench=bench) resolution = make_resolution_plan(app, bench) if "frappe" in resolution: # Terminal dependency del resolution["frappe"] - if init_bench: - bench_path = get_available_folder_name(f"{app.repo}-bench", bench_path) - init( - path=bench_path, - frappe_branch=branch, - skip_assets=skip_assets, - verbose=verbose, - ) - os.chdir(bench_path) - for repo_name, app in reversed(resolution.items()): existing_dir, cloned_path = check_existing_dir(bench_path, repo_name) if existing_dir: @@ -510,7 +505,6 @@ def install_app( if restart_bench: bench.reload() - def pull_apps(apps=None, bench_path=".", reset=False): """Check all apps if there no local changes, pull""" from bench.bench import Bench diff --git a/bench/commands/__init__.py b/bench/commands/__init__.py index 4cdc8882..08a493b9 100755 --- a/bench/commands/__init__.py +++ b/bench/commands/__init__.py @@ -39,7 +39,6 @@ from bench.commands.make import ( new_app, pip, remove_app, - resolve_and_install, ) bench_command.add_command(init) @@ -49,7 +48,6 @@ bench_command.add_command(new_app) bench_command.add_command(remove_app) bench_command.add_command(exclude_app_for_update) bench_command.add_command(include_app_for_update) -bench_command.add_command(resolve_and_install) bench_command.add_command(pip) diff --git a/bench/commands/make.py b/bench/commands/make.py index c6b7748b..c19e71cd 100755 --- a/bench/commands/make.py +++ b/bench/commands/make.py @@ -133,8 +133,20 @@ def drop(path): @click.option( "--init-bench", is_flag=True, default=False, help="Initialize Bench if not in one" ) +@click.option( + "--resolve/--no-resolve", + is_flag=True, + default=False, + help="Resolve dependencies before installing app", +) def get_app( - git_url, branch, name=None, overwrite=False, skip_assets=False, init_bench=False + git_url, + branch, + name=None, + overwrite=False, + skip_assets=False, + init_bench=False, + resolve=False, ): "clone an app from the internet and set it up in your bench" from bench.app import get_app @@ -145,26 +157,7 @@ def get_app( skip_assets=skip_assets, overwrite=overwrite, init_bench=init_bench, - ) - -@click.command("resolve-and-install", help="Resolve dependencies and install apps") -@click.argument("git-url") -@click.option("--branch", default=None) -@click.option("--skip-assets", is_flag=True, default=False, help="Do not build assets") -@click.option( - "--init-bench", is_flag=True, default=False, help="Initialize Bench if not in one" -) -@click.option("--skip-assets", is_flag=True, default=False, help="Do not build assets") -@click.option("--verbose", is_flag=True, default=False, help="Verbosity") -def resolve_and_install(git_url, branch, skip_assets, verbose, init_bench): - from bench.app import resolve_and_install - - resolve_and_install( - git_url=git_url, - branch=branch, - skip_assets=skip_assets, - init_bench=init_bench, - verbose=verbose, + resolve=resolve, ) @click.command("new-app", help="Create a new Frappe application under apps folder") diff --git a/bench/utils/system.py b/bench/utils/system.py index 50c8b1d8..a72ec2ba 100644 --- a/bench/utils/system.py +++ b/bench/utils/system.py @@ -76,7 +76,12 @@ def init( frappe_path = frappe_path or "https://github.com/frappe/frappe.git" get_app( - frappe_path, branch=frappe_branch, bench_path=path, skip_assets=True, verbose=verbose + frappe_path, + branch=frappe_branch, + bench_path=path, + skip_assets=True, + verbose=verbose, + resolve=False, ) # fetch remote apps using config file - deprecate this! @@ -86,7 +91,12 @@ def init( # getting app on bench init using --install-app if install_app: get_app( - install_app, branch=frappe_branch, bench_path=path, skip_assets=True, verbose=verbose + install_app, + branch=frappe_branch, + bench_path=path, + skip_assets=True, + verbose=verbose, + resolve=False, ) if not skip_assets: