Make compatible with pnpm (#854)

Switches behavior based on the presence of `yarn.lock`

See https://github.com/discourse/discourse/pull/28671
This commit is contained in:
David Taylor 2024-09-02 20:55:57 +01:00 committed by GitHub
parent fe48fa2c5c
commit 87871bc430
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 8 deletions

View File

@ -10,7 +10,6 @@ RUN cd /var/www/discourse &&\
sudo -u discourse bundle config --local path ./vendor/bundle &&\ sudo -u discourse bundle config --local path ./vendor/bundle &&\
sudo -u discourse bundle config --local without test development &&\ sudo -u discourse bundle config --local without test development &&\
sudo -u discourse bundle install --jobs $(($(nproc) - 1)) &&\ sudo -u discourse bundle install --jobs $(($(nproc) - 1)) &&\
sudo -u discourse yarn install --frozen-lockfile &&\ sudo -u discourse /bin/bash -c 'if [ -f yarn.lock ]; then yarn install --frozen-lockfile && yarn cache clean; else pnpm install --frozen-lockfile; fi' &&\
sudo -u discourse yarn cache clean &&\
find /var/www/discourse/vendor/bundle -name cache -not -path '*/gems/*' -type d -exec rm -rf {} + &&\ find /var/www/discourse/vendor/bundle -name cache -not -path '*/gems/*' -type d -exec rm -rf {} + &&\
find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} + find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +

View File

@ -73,6 +73,6 @@ RUN --mount=type=bind,src=/repo,from=repo-fetcher,target=/tmp/discourse-clone,re
# Warm global yarn cache # Warm global yarn cache
RUN --mount=type=bind,src=/repo,from=repo-fetcher,target=/tmp/discourse-clone,readwrite \ RUN --mount=type=bind,src=/repo,from=repo-fetcher,target=/tmp/discourse-clone,readwrite \
cd /tmp/discourse-clone \ cd /tmp/discourse-clone \
&& yarn install && (if [ -f yarn.lock ]; then yarn install; else pnpm install; fi)
USER root USER root

View File

@ -30,8 +30,7 @@ FROM with_browsers AS release
RUN cd /var/www/discourse &&\ RUN cd /var/www/discourse &&\
sudo -u discourse bundle install --jobs $(($(nproc) - 1)) &&\ sudo -u discourse bundle install --jobs $(($(nproc) - 1)) &&\
sudo -E -u discourse -H yarn install &&\ sudo -E -u discourse -H /bin/bash -c 'if [ -f yarn.lock ]; then (yarn install && yarn cache clean); else pnpm install; fi'
sudo -u discourse yarn cache clean
RUN cd /var/www/discourse && sudo -E -u discourse -H bundle exec rake plugin:install_all_official &&\ RUN cd /var/www/discourse && sudo -E -u discourse -H bundle exec rake plugin:install_all_official &&\
LOAD_PLUGINS=1 sudo -E -u discourse -H bundle exec rake plugin:install_all_gems &&\ LOAD_PLUGINS=1 sudo -E -u discourse -H bundle exec rake plugin:install_all_gems &&\

View File

@ -184,7 +184,12 @@ run:
if [ "$version" != "tests-passed" ]; then if [ "$version" != "tests-passed" ]; then
rm -rf app/assets/javascripts/node_modules rm -rf app/assets/javascripts/node_modules
fi fi
- su discourse -c 'yarn install --frozen-lockfile && yarn cache clean' - |-
if [ -f yarn.lock ]; then
su discourse -c 'yarn install --frozen-lockfile && yarn cache clean'
else
su discourse -c 'pnpm install --frozen-lockfile'
fi
- exec: - exec:
cd: $home cd: $home

View File

@ -185,8 +185,12 @@ run:
if [ "$version" != "tests-passed" ]; then if [ "$version" != "tests-passed" ]; then
rm -rf app/assets/javascripts/node_modules rm -rf app/assets/javascripts/node_modules
fi fi
- su discourse -c 'yarn config set network-timeout 60000 -g' - |-
- su discourse -c 'yarn install --frozen-lockfile && yarn cache clean' if [ -f yarn.lock ]; then
su discourse -c 'yarn install --frozen-lockfile && yarn cache clean'
else
su discourse -c 'pnpm install --frozen-lockfile'
fi
- exec: - exec:
cd: $home cd: $home