diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..27fed85 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{bats,sh,yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 46d64c3..c79650b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,4 @@ tests/ export-ignore .github/ export-ignore .gitattributes export-ignore +.editorconfig export-ignore diff --git a/commands/web/pnpm b/commands/web/pnpm old mode 100644 new mode 100755 index e33f50c..885a2cc --- a/commands/web/pnpm +++ b/commands/web/pnpm @@ -14,7 +14,11 @@ fi # If a $PNPM_DIRECTORY is set, run our PNPM commands in that directory if [ -n "$PNPM_DIRECTORY" ]; then - pnpm --dir "$PNPM_DIRECTORY" "$@" -else - pnpm "$@" + mkdir -p "$DDEV_APPROOT/$PNPM_DIRECTORY" + cd "$DDEV_APPROOT/$PNPM_DIRECTORY" || { + echo "Error: Failed to change directory to '$DDEV_APPROOT/$PNPM_DIRECTORY'." >&2 + exit 1 + } fi + +pnpm "$@" diff --git a/tests/test.bats b/tests/test.bats index efae66c..1221eab 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -58,7 +58,7 @@ health_checks() { assert_file_exist package.json fi - run ddev pnpm link + run ddev pnpm link . assert_success } @@ -126,7 +126,7 @@ teardown() { # Verify is-odd@3.0.1 is stored in the global cache after installing run ddev pnpm install assert_success - run ddev exec bash -c "grep -r 'is-odd' /mnt/ddev-global-cache/pnpm 2>/dev/null | grep '3.0.1'" + run ddev exec bash -c "grep -R 'is-odd' /mnt/ddev-global-cache/pnpm 2>/dev/null | grep '3.0.1'" assert_success # Install the same package version from a second directory and verify it is reused from cache @@ -141,7 +141,7 @@ teardown() { run ddev exec bash -c "cd /var/www/html/third && pnpm install" assert_success - run ddev exec bash -c "grep -r 'is-odd' /mnt/ddev-global-cache/pnpm 2>/dev/null | grep '2.0.0'" + run ddev exec bash -c "grep -R 'is-odd' /mnt/ddev-global-cache/pnpm 2>/dev/null | grep '2.0.0'" assert_success run ddev exec bash -c "node -e \"console.log(require('/var/www/html/third/node_modules/is-odd/package.json').version)\"" diff --git a/tests/testdata/frontend/package.json b/tests/testdata/frontend/package.json index 657834b..e1a211a 100644 --- a/tests/testdata/frontend/package.json +++ b/tests/testdata/frontend/package.json @@ -9,7 +9,6 @@ "keywords": [], "author": "", "license": "ISC", - "packageManager": "pnpm@10.5.2", "dependencies": { "is-odd": "3.0.1" } diff --git a/web-build/Dockerfile.pnpm b/web-build/Dockerfile.pnpm index 6a71eff..0e336de 100644 --- a/web-build/Dockerfile.pnpm +++ b/web-build/Dockerfile.pnpm @@ -4,8 +4,8 @@ RUN (command -v pnpm >/dev/null 2>&1 || npm install --global pnpm) && \ PNPM_SCRIPT=$(printf '%s\n' \ 'export PNPM_HOME="/mnt/ddev-global-cache/pnpm"' \ 'case ":$PATH:" in' \ - ' *":$PNPM_HOME:"*) ;;' \ - ' *) PATH="$PNPM_HOME:$PATH" ;;' \ + ' *":$PNPM_HOME/bin:"*) ;;' \ + ' *) PATH="$PNPM_HOME/bin:$PATH" ;;' \ 'esac' \ 'export PATH') && \ echo "$PNPM_SCRIPT" >> /etc/bash.bashrc && \