webapp: autocompile script needs to run yarn within webapp dir

we need to change the working directory to the webapp directory such
that corepack installs and uses the expected version of yarn. otherwise,
corepack installs a copy of yarn into the repository root directory.
This commit is contained in:
Bernhard Kirchen 2024-09-21 21:04:10 +02:00
parent a2092e66c4
commit 2f4eef47e9

View File

@ -37,22 +37,25 @@ def check_files(directories, filepaths, hash_file):
# "exectuable" (a shell script) is only performed by cmd.exe, not by
# Python itself. as we are calling yarn with fixed arguments, using
# shell=True is fine.
# we need to change the working directory to the webapp directory such
# that corepack installs and uses the expected version of yarn. otherwise,
# corepack installs a copy of yarn into the repository root directory.
yarn = "yarn"
try:
subprocess.check_output(yarn + " --version", shell=True)
subprocess.check_output(yarn + " --version", cwd="webapp", shell=True)
except FileNotFoundError:
yarn = "yarnpkg"
try:
subprocess.check_output(yarn + " --version", shell=True)
subprocess.check_output(yarn + " --version", cwd="webapp", shell=True)
except FileNotFoundError:
raise Exception("it seems neither 'yarn' nor 'yarnpkg' is available on your system")
# if these commands fail, an exception will prevent us from
# persisting the current hashes => commands will be executed again
subprocess.run(yarn + " --cwd webapp install --frozen-lockfile",
check=True, shell=True)
subprocess.run(yarn + " install --frozen-lockfile",
cwd="webapp", check=True, shell=True)
subprocess.run(yarn + " --cwd webapp build", check=True, shell=True)
subprocess.run(yarn + " build", cwd="webapp", check=True, shell=True)
with open(hash_file, 'wb') as f:
pickle.dump(file_hashes, f)