Skip to content

Commit

Permalink
fix: read apps from apps.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdeali099 committed May 7, 2024
1 parent 1751b2d commit 548deac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
9 changes: 9 additions & 0 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,13 @@ def prune_app_directory(self):
remove_unused_node_modules(app_path)


def add_to_appstxt(installed_apps, app, bench_path="."):
if app not in installed_apps:
installed_apps.append(app)
with open(os.path.join(bench_path, "sites", "apps.txt"), "w") as f:
f.write("\n".join(installed_apps))


def coerce_url_to_name_if_possible(git_url: str, cache_key: str) -> str:
app_name = os.path.basename(git_url)
if can_get_cached(app_name, cache_key):
Expand Down Expand Up @@ -911,6 +918,8 @@ def install_app(
yarn_install += " --verbose"
bench.run(yarn_install, cwd=app_path)

add_to_appstxt(installed_apps=bench.apps.apps, app=app, bench_path=bench_path)

bench.apps.sync(app_name=app, required=resolution, branch=tag, app_dir=app_path)

if not skip_assets:
Expand Down
19 changes: 11 additions & 8 deletions bench/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ def __init__(self, path):
self.cwd = os.path.abspath(path)
self.exists = is_bench_directory(self.name)

self.apps_txt = os.path.join(self.name, "sites", "apps.txt")
self.excluded_apps_txt = os.path.join(self.name, "sites", "excluded_apps.txt")

self.setup = BenchSetup(self)
self.teardown = BenchTearDown(self)
self.apps = BenchApps(self)

self.apps_txt = os.path.join(self.name, "sites", "apps.txt")
self.excluded_apps_txt = os.path.join(self.name, "sites", "excluded_apps.txt")

@property
def python(self) -> str:
return get_env_cmd("python", bench_path=self.name)
Expand Down Expand Up @@ -274,11 +274,14 @@ def sync(

def initialize_apps(self):
try:
self.apps = [
x
for x in os.listdir(os.path.join(self.bench.name, "apps"))
if is_frappe_app(os.path.join(self.bench.name, "apps", x))
]
with open(self.bench.apps_txt) as f:
self.apps = [
app.strip()
for app in f.read().splitlines()
if len(app) > 0 and is_frappe_app(os.path.join(self.bench.name, "apps", app))
]

# FIXME: can be remove
self.apps.remove("frappe")
self.apps.insert(0, "frappe")
except FileNotFoundError:
Expand Down

0 comments on commit 548deac

Please sign in to comment.