Created
August 20, 2022 09:40
-
-
Save vardumper/564e15f89c4776e1718e3600d4c953a4 to your computer and use it in GitHub Desktop.
Shopware 6 build-administration.sh with pnpm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" | |
set -euo pipefail | |
export PROJECT_ROOT="${PROJECT_ROOT:-"$(dirname "$CWD")"}" | |
ADMIN_ROOT="${ADMIN_ROOT:-"${PROJECT_ROOT}/vendor/shopware/administration"}" | |
. /usr/local/opt/nvm/nvm.sh | |
nvm install 16 | |
BIN_TOOL="${CWD}/console" | |
if [[ ${CI-""} ]]; then | |
BIN_TOOL="${CWD}/ci" | |
if [[ ! -x "$BIN_TOOL" ]]; then | |
chmod +x "$BIN_TOOL" | |
fi | |
fi | |
# build admin | |
[[ ${SHOPWARE_SKIP_BUNDLE_DUMP-""} ]] || "${BIN_TOOL}" bundle:dump | |
if [[ $(command -v jq) ]]; then | |
OLDPWD=$(pwd) | |
cd "$PROJECT_ROOT" || exit | |
jq -c '.[]' "var/plugins.json" | while read -r config; do | |
srcPath=$(echo "$config" | jq -r '(.basePath + .administration.path)') | |
# the package.json files are always one upper | |
path=$(dirname "$srcPath") | |
name=$(echo "$config" | jq -r '.technicalName' ) | |
if [[ -f "$path/package.json" && ! -d "$path/node_modules" && $name != "administration" ]]; then | |
echo "=> Installing npm dependencies for ${name}" | |
pnpm install --prefix "$path" | |
fi | |
done | |
cd "$OLDPWD" || exit | |
else | |
echo "Cannot check extensions for required npm installations as jq is not installed" | |
fi | |
(cd "${ADMIN_ROOT}"/Resources/app/administration && pnpm install && pnpm build) | |
[[ ${SHOPWARE_SKIP_ASSET_COPY-""} ]] ||"${BIN_TOOL}" asset:install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@see https://erikpoehler.com/2022/08/20/shopware-6-speed-up-builds-with-pnpm/