Skip to content

Add host-path alias symlink startup hook and validation coverage#21

Open
UltraBob wants to merge 8 commits intomainfrom
feature/host-path-alias-parity
Open

Add host-path alias symlink startup hook and validation coverage#21
UltraBob wants to merge 8 commits intomainfrom
feature/host-path-alias-parity

Conversation

@UltraBob
Copy link
Owner

@UltraBob UltraBob commented Mar 4, 2026

Summary

Implements host-path alias parity via a startup symlink strategy instead of a bind-mount alias.

What changed

  • Added .ddev/web-entrypoint.d/90-dcq-host-path-alias.sh.
  • Hook now creates a host-path alias symlink to /var/www/html at container startup.
  • Added opt-out via DCQ_HOST_PATH_ALIAS=0|false|off.
  • Added cleanup behavior for add-on-managed aliases when disabled.
  • Wired new entrypoint hook into install.yaml project_files and removal_actions.
  • Documented behavior and env var in README.md.
  • Added bats coverage for:
    • existing path-map behavior,
    • alias creation behavior,
    • alias-disable behavior.

Important fix included

Entry-point scripts are sourced by DDEV. The initial implementation used exit, which could terminate container startup when aliasing was disabled. This PR fixes that by using safe sourced-script return behavior.

Validation

Targeted bats checks pass:

  • path map prefers DDEV_HOST_PROJECT_ROOT
  • host-path alias symlink is created on restart
  • host-path alias can be disabled via DCQ_HOST_PATH_ALIAS

Notes

This PR establishes the alias architecture and keeps existing path-mapping wrappers in place for safety.
A follow-up phase will investigate removing/simplifying wrapper path-mapping logic to rely on host-path parity directly.

Refs #19

@UltraBob
Copy link
Owner Author

UltraBob commented Mar 4, 2026

Follow-up implementation for TASK-0052 simplification scope is now pushed to feature/host-path-alias-parity (commit 76007df).

What changed:

  • Added shared helper behavior in commands/helpers/path-map.sh:
    • trim quoted compose approot, normalize host-root slash handling,
    • prefer host-path alias pass-through when available,
    • new map_to_project_relative() helper.
  • Refactored wrappers to use shared normalization helper instead of repeated inline /var/www/html stripping:
    • cspell, cspell-suggest, eslint, eslint-fix, stylelint, stylelint-fix, prettier, prettier-fix.
  • Simplified PHPStan JSON host-path rewrite setup to use helper-resolved HOST_ROOT fallback.
  • Added tests:
    • path map keeps host absolute paths when alias exists
    • path map falls back to container path when alias is disabled

Validation run A (5 tests):
bats ./tests/test.bats --filter "path map prefers DDEV_HOST_PROJECT_ROOT|path map keeps host absolute paths when alias exists|path map falls back to container path when alias is disabled|host-path alias symlink is created on restart|host-path alias can be disabled via DCQ_HOST_PATH_ALIAS" --print-output-on-failure

Validation run B (6 tests):
bats ./tests/test.bats --filter "stylelint-fix rewrites explicit web paths with non-web docroot|eslint fixed mode falls back to .eslintrc.json when passing config is missing|stylelint-fix fails with helpful message when project config is missing|stylelint-fix uses nearest config when root config is missing|prettier-fix fails with helpful message when project config is missing|phpstan fails with helpful message when project config is missing" --print-output-on-failure

Both runs passed.

@UltraBob
Copy link
Owner Author

UltraBob commented Mar 4, 2026

Implemented the TASK-0052 follow-up pass to enforce host-path alias parity and remove fallback host->container path rewrites.

What changed in this push (e2af138):

  • Enforced alias setup in web-entrypoint.d/90-dcq-host-path-alias.sh.
    • Removed DCQ_HOST_PATH_ALIAS opt-out behavior.
    • Alias conflicts on existing non-directory paths now fail with an explicit error.
    • Existing directories are treated as valid parity paths.
  • Simplified commands/helpers/path-map.sh:
    • map_path() now keeps host paths host-native (no /var/www/html fallback remap).
    • Retained centralized normalization context + map_to_project_relative().
  • Removed wrapper rewrite loops where alias parity now makes them unnecessary:
    • commands/web/phpcs
    • commands/web/phpcbf
    • commands/web/phpstan (kept output-side canonical->host rewrite behavior)
    • cleaned remaining config arg mapping in cspell, cspell-suggest, prettier.
  • Updated docs:
    • alias now documented as enforced, with restart note after install/upgrade.
    • removed DCQ_HOST_PATH_ALIAS user toggle guidance.
  • Updated tests:
    • replaced disabled-alias fallback test with enforced-alias semantics.
    • added passthrough checks for phpcs/phpcbf host-absolute --stdin-path and --standard args.

Validation rerun after disk cleanup:

  • bats ./tests/test.bats --print-output-on-failure
  • Result: 35/35 passing (expected skips for DCQ_FULL_TESTS-gated tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant