Skip to content

Instantly share code, notes, and snippets.

@vardumper
Created August 20, 2022 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vardumper/564e15f89c4776e1718e3600d4c953a4 to your computer and use it in GitHub Desktop.
Save vardumper/564e15f89c4776e1718e3600d4c953a4 to your computer and use it in GitHub Desktop.
Shopware 6 build-administration.sh with pnpm
#!/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