Skip to content

Conversation

butschster
Copy link
Collaborator

This PR enhances CTX's variable system by enabling variable resolution in source paths and adding new predefined path variables. This makes configurations more flexible, reusable, and suitable for multi-environment setups.

Changes

1. Variable Resolution in Source Paths

Source paths now support variable substitution, allowing dynamic path construction:

Before:

documents:
  - description: "API Documentation"
    sources:
      - type: file
        sourcePaths:
          - "src/Controllers"  # Static path only

After:

variables:
  env: production
  src_dir: src/{{env}}

documents:
  - description: "API Documentation"
    sources:
      - type: file
        sourcePaths:
          - "{{src_dir}}/Controllers"  # Dynamic path based on environment
          - "${ROOT_PATH}/config" # Using predefined variables

2. New Predefined Path Variables

Added four new predefined variables for project paths:

Variable Description Example
${ROOT_PATH} Project root directory /home/user/my-project
${CONFIG_PATH} Configuration file path /home/user/my-project/context.yaml
${ENV_PATH} Environment file path /home/user/my-project/.env.local
${BINARY_PATH} CTX binary path /usr/local/bin/ctx

@butschster butschster added this to the 1.32 milestone Oct 4, 2025
@butschster butschster self-assigned this Oct 4, 2025
@butschster butschster added enhancement New feature or request config:loader ConfigLoader component for parsing and validating config files labels Oct 4, 2025
@butschster butschster moved this to In review in Context Generator Oct 4, 2025
@butschster butschster linked an issue Oct 4, 2025 that may be closed by this pull request
Copy link

codecov bot commented Oct 4, 2025

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../Config/Import/PathPrefixer/SourcePathPrefixer.php 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@butschster butschster moved this from In review to Done in Context Generator Oct 4, 2025
@butschster butschster merged commit 1580f62 into main Oct 4, 2025
8 checks passed
@butschster butschster deleted the issue/271 branch October 4, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config:loader ConfigLoader component for parsing and validating config files enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Project root placeholder in path
1 participant