2
0
mirror of https://github.com/frappe/bench.git synced 2024-06-26 19:23:30 +00:00

fix: Check yarn files during install (#1533)

We observed that in some cases files are missing when yarn reuses them
from cache. Not sure what's causing it but checking files seems to at
least fix it. This is probably some yarn bug.
This commit is contained in:
Ankush Menat 2024-02-07 13:06:00 +05:30 committed by GitHub
parent f5ab0459ec
commit 1a421758a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 8 deletions

View File

@ -423,7 +423,7 @@ class App(AppMeta):
remove_unused_node_modules(app_path)
def coerce_url_to_name_if_possible(git_url: str, cache_key:str) -> str:
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):
return app_name
@ -908,7 +908,9 @@ def install_app(
install_python_dev_dependencies(apps=app, bench_path=bench_path, verbose=verbose)
if not using_cached and os.path.exists(os.path.join(app_path, "package.json")):
yarn_install = "yarn install --verbose" if verbose else "yarn install"
yarn_install = "yarn install --check-files"
if verbose:
yarn_install += " --verbose"
bench.run(yarn_install, cwd=app_path)
bench.apps.sync(app_name=app, required=resolution, branch=tag, app_dir=app_path)

View File

@ -18,8 +18,14 @@ import click
# imports - module imports
import bench
from bench.exceptions import PatchError, ValidationError
from bench.utils import (exec_cmd, get_bench_cache_path, get_bench_name,
get_cmd_output, log, which)
from bench.utils import (
exec_cmd,
get_bench_cache_path,
get_bench_name,
get_cmd_output,
log,
which,
)
logger = logging.getLogger(bench.PROJECT_NAME)
@ -132,7 +138,9 @@ def update_yarn_packages(bench_path=".", apps=None, verbose=None):
app_path = os.path.join(apps_dir, app)
if os.path.exists(os.path.join(app_path, "package.json")):
click.secho(f"\nInstalling node dependencies for {app}", fg="yellow")
yarn_install = "yarn install --verbose" if verbose else "yarn install"
yarn_install = "yarn install --check-files"
if verbose:
yarn_install += " --verbose"
bench.run(yarn_install, cwd=app_path)
@ -329,7 +337,10 @@ def restart_supervisor_processes(bench_path=".", web_workers=False, _raise=False
for group in groups:
failure = bench.run(f"{sudo}supervisorctl restart {group}", _raise=_raise)
if failure:
log(f"restarting supervisor group `{group}` failed. Use `bench restart` to retry.", level=3)
log(
f"restarting supervisor group `{group}` failed. Use `bench restart` to retry.",
level=3,
)
def restart_systemd_processes(bench_path=".", web_workers=False, _raise=True):