mirror of
https://github.com/frappe/bench.git
synced 2025-01-09 16:36:25 +00:00
fix: added code removed via erroneous commit
This commit is contained in:
parent
58319a21b7
commit
5b641758cf
29
bench/app.py
29
bench/app.py
@ -107,7 +107,6 @@ class AppMeta:
|
|||||||
self.tag = self.tag or self.branch
|
self.tag = self.tag or self.branch
|
||||||
|
|
||||||
def _setup_details_from_installed_apps(self):
|
def _setup_details_from_installed_apps(self):
|
||||||
self.branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"])
|
|
||||||
self.org, self.repo, self.tag = os.path.split(
|
self.org, self.repo, self.tag = os.path.split(
|
||||||
os.path.join(self.bench.name, "apps", self.name)
|
os.path.join(self.bench.name, "apps", self.name)
|
||||||
)[-2:] + (self.branch,)
|
)[-2:] + (self.branch,)
|
||||||
@ -183,24 +182,25 @@ class App(AppMeta):
|
|||||||
shutil.move(active_app_path, archived_app_path)
|
shutil.move(active_app_path, archived_app_path)
|
||||||
|
|
||||||
@step(title="Installing App {repo}", success="App {repo} Installed")
|
@step(title="Installing App {repo}", success="App {repo} Installed")
|
||||||
def install(self, skip_assets=False, verbose=False, restart_bench=True):
|
def install(self, skip_assets=False, verbose=False, restart_bench=True, resolved=False):
|
||||||
import bench.cli
|
import bench.cli
|
||||||
from bench.utils.app import get_app_name
|
from bench.utils.app import get_app_name
|
||||||
|
|
||||||
verbose = bench.cli.verbose or verbose
|
verbose = bench.cli.verbose or verbose
|
||||||
app_name = get_app_name(self.bench.name, self.repo)
|
app_name = get_app_name(self.bench.name, self.repo)
|
||||||
|
if not resolved:
|
||||||
# TODO: this should go inside install_app only tho - issue: default/resolved branch
|
# TODO: this should go inside install_app only tho - issue: default/resolved branch
|
||||||
setup_app_dependencies(
|
setup_app_dependencies(
|
||||||
repo_name=self.repo,
|
repo_name=self.repo,
|
||||||
bench_path=self.bench.name,
|
bench_path=self.bench.name,
|
||||||
branch=self.tag,
|
branch=self.tag,
|
||||||
verbose=verbose,
|
verbose=verbose,
|
||||||
skip_assets=skip_assets,
|
skip_assets=skip_assets,
|
||||||
)
|
)
|
||||||
|
|
||||||
install_app(
|
install_app(
|
||||||
app=app_name,
|
app=app_name,
|
||||||
|
tag=self.tag,
|
||||||
bench_path=self.bench.name,
|
bench_path=self.bench.name,
|
||||||
verbose=verbose,
|
verbose=verbose,
|
||||||
skip_assets=skip_assets,
|
skip_assets=skip_assets,
|
||||||
@ -211,7 +211,6 @@ class App(AppMeta):
|
|||||||
def install_resolved_apps(self, *args, **kwargs):
|
def install_resolved_apps(self, *args, **kwargs):
|
||||||
self.get()
|
self.get()
|
||||||
self.install(*args, **kwargs, resolved=True)
|
self.install(*args, **kwargs, resolved=True)
|
||||||
self.bench.apps.update_apps_states(self.repo, self.tag)
|
|
||||||
|
|
||||||
@step(title="Uninstalling App {repo}", success="App {repo} Uninstalled")
|
@step(title="Uninstalling App {repo}", success="App {repo} Uninstalled")
|
||||||
def uninstall(self):
|
def uninstall(self):
|
||||||
@ -226,11 +225,9 @@ class App(AppMeta):
|
|||||||
lines = [x for x in f.split("\n") if x.strip().startswith("required_apps")]
|
lines = [x for x in f.split("\n") if x.strip().startswith("required_apps")]
|
||||||
required_apps = eval(lines[0].strip("required_apps").strip().lstrip("=").strip())
|
required_apps = eval(lines[0].strip("required_apps").strip().lstrip("=").strip())
|
||||||
return required_apps
|
return required_apps
|
||||||
except Exception as e:
|
except Exception:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return info_file["required_apps"] if info_file else {}
|
|
||||||
|
|
||||||
def make_resolution_plan(app: App, bench: "Bench"):
|
def make_resolution_plan(app: App, bench: "Bench"):
|
||||||
"""
|
"""
|
||||||
decide what apps and versions to install and in what order
|
decide what apps and versions to install and in what order
|
||||||
@ -482,6 +479,7 @@ def new_app(app, no_git=None, bench_path="."):
|
|||||||
|
|
||||||
def install_app(
|
def install_app(
|
||||||
app,
|
app,
|
||||||
|
tag,
|
||||||
bench_path=".",
|
bench_path=".",
|
||||||
verbose=False,
|
verbose=False,
|
||||||
no_cache=False,
|
no_cache=False,
|
||||||
@ -513,6 +511,7 @@ def install_app(
|
|||||||
bench.run("yarn install", cwd=app_path)
|
bench.run("yarn install", cwd=app_path)
|
||||||
|
|
||||||
bench.apps.sync()
|
bench.apps.sync()
|
||||||
|
bench.apps.update_apps_states(app, tag)
|
||||||
|
|
||||||
if not skip_assets:
|
if not skip_assets:
|
||||||
build_assets(bench_path=bench_path, app=app)
|
build_assets(bench_path=bench_path, app=app)
|
||||||
|
@ -57,7 +57,6 @@ class Bench(Base, Validator):
|
|||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.name = path
|
self.name = path
|
||||||
self.cwd = os.path.abspath(path)
|
self.cwd = os.path.abspath(path)
|
||||||
self.apps_states = os.path.join(self.name, "sites", "apps_states.json")
|
|
||||||
self.exists = is_bench_directory(self.name)
|
self.exists = is_bench_directory(self.name)
|
||||||
|
|
||||||
self.setup = BenchSetup(self)
|
self.setup = BenchSetup(self)
|
||||||
@ -159,19 +158,20 @@ class Bench(Base, Validator):
|
|||||||
class BenchApps(MutableSequence):
|
class BenchApps(MutableSequence):
|
||||||
def __init__(self, bench: Bench):
|
def __init__(self, bench: Bench):
|
||||||
self.bench = bench
|
self.bench = bench
|
||||||
|
self.states_path = os.path.join(self.bench.name, "sites", "apps_states.json")
|
||||||
self.initialize_apps()
|
self.initialize_apps()
|
||||||
|
|
||||||
def initialize_states(self):
|
def set_states(self):
|
||||||
try:
|
try:
|
||||||
with open(self.bench.apps_states, "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.bench.apps_states, "w") as f:
|
with open(self.states_path, "w+") as f:
|
||||||
self.states = json.loads(f.read() or "{}")
|
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_states()
|
|
||||||
self.initialize_apps()
|
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:
|
||||||
@ -180,14 +180,14 @@ class BenchApps(MutableSequence):
|
|||||||
for app in apps_to_remove:
|
for app in apps_to_remove:
|
||||||
del self.states[app]
|
del self.states[app]
|
||||||
|
|
||||||
if app_name and resolution:
|
if app_name:
|
||||||
version = get_current_version(app_name)
|
version = get_current_version(app_name, self.bench.name)
|
||||||
self.states[app_name] = {
|
self.states[app_name] = {
|
||||||
"resolution": resolution,
|
"resolution": resolution,
|
||||||
"version": version,
|
"version": version,
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(self.bench.apps_states, "w") as f:
|
with open(self.states_path, "w") as f:
|
||||||
f.write(json.dumps(self.states, indent=4))
|
f.write(json.dumps(self.states, indent=4))
|
||||||
|
|
||||||
def sync(self):
|
def sync(self):
|
||||||
|
@ -208,6 +208,10 @@ def get_app_name(bench_path, repo_name):
|
|||||||
|
|
||||||
return repo_name
|
return repo_name
|
||||||
|
|
||||||
|
def check_existing_dir(bench_path, repo_name):
|
||||||
|
cloned_path = os.path.join(bench_path, "apps", repo_name)
|
||||||
|
dir_already_exists = os.path.isdir(cloned_path)
|
||||||
|
return dir_already_exists, cloned_path
|
||||||
|
|
||||||
def get_current_version(app, bench_path="."):
|
def get_current_version(app, bench_path="."):
|
||||||
current_version = None
|
current_version = None
|
||||||
|
Loading…
Reference in New Issue
Block a user