Skip to content

Commit dbd8976

Browse files
authored
Merge pull request #105 from context-hub/issue/99
Add wildcard pattern support for configuration imports
2 parents 0c6f167 + 68bb98e commit dbd8976

File tree

72 files changed

+3973
-352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3973
-352
lines changed

.github/workflows/build-phar-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
php-version:
17-
- '8.2'
17+
- '8.3'
1818
dependencies:
1919
- locked
2020
env:

.github/workflows/generate-docs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ jobs:
2323
- name: Setup PHP
2424
uses: shivammathur/setup-php@v2
2525
with:
26-
php-version: '8.2'
26+
php-version: '8.3'
2727
coverage: none
2828

2929
- name: Download context-generator
3030
run: |
31-
wget https://github.com/context-hub/generator/releases/download/1.15.0/ctx
31+
wget https://github.com/context-hub/generator/releases/download/1.19.0/ctx
3232
chmod +x ctx
3333
./ctx version
3434

.github/workflows/refactoring.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
os:
2828
- ubuntu-latest
2929
php-version:
30-
- '8.2'
30+
- '8.3'
3131
dependencies:
3232
- locked
3333
steps:

.github/workflows/security.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
os:
2020
- ubuntu-latest
2121
php-version:
22-
- '8.2'
22+
- '8.3'
2323
dependencies:
2424
- locked
2525
steps:

.github/workflows/static-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
os:
2626
- ubuntu-latest
2727
php-version:
28-
- '8.2'
28+
- '8.3'
2929
dependencies:
3030
- locked
3131
steps:

.github/workflows/testing.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
os:
2424
- ubuntu-latest
2525
php-version:
26-
- '8.2'
26+
- '8.3'
2727
dependencies:
2828
- locked
2929
steps:
@@ -83,8 +83,6 @@ jobs:
8383
os:
8484
- ubuntu-latest
8585
php-version:
86-
- '8.1'
87-
- '8.2'
8886
- '8.3'
8987
dependencies:
9088
- lowest

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^8.2",
19+
"php": "^8.3",
2020
"ext-curl": "*",
2121
"guzzlehttp/guzzle": "^7.0",
2222
"league/html-to-markdown": "^5.1",

context.yaml

+8-129
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import:
2-
- path: src/Console/context.yaml
3-
- path: src/ConfigLoader/context.yaml
2+
- path: src/*/context.yaml
43

54
documents:
65
- description: "Context Generator Project Structure"
@@ -55,117 +54,11 @@ documents:
5554
- 'FilesInterface.php'
5655
showTreeView: true
5756

58-
- description: Document Compilation System
59-
outputPath: core/document.md
57+
- description: Config parser
58+
outputPath: core/config-parser.md
6059
sources:
6160
- type: file
62-
sourcePaths: src/Document
63-
filePattern: '*.php'
64-
showTreeView: true
65-
66-
- description: Source Implementations - File
67-
outputPath: sources/file-source.md
68-
sources:
69-
- type: file
70-
sourcePaths: src/Source/File
71-
filePattern: '*.php'
72-
showTreeView: true
73-
74-
- description: Source Implementations - GitHub
75-
outputPath: sources/github-source.md
76-
sources:
77-
- type: file
78-
sourcePaths: src/Source/Github
79-
filePattern: '*.php'
80-
showTreeView: true
81-
82-
- description: Source Implementations - URL
83-
outputPath: sources/url-source.md
84-
sources:
85-
- type: file
86-
sourcePaths: src/Source/Url
87-
filePattern: '*.php'
88-
showTreeView: true
89-
90-
- description: Source Implementations - Text
91-
outputPath: sources/text-source.md
92-
sources:
93-
- type: file
94-
sourcePaths: src/Source/Text
95-
filePattern: '*.php'
96-
showTreeView: true
97-
98-
- description: Source Implementations - Git Diff
99-
outputPath: sources/git-diff-source.md
100-
sources:
101-
- type: file
102-
sourcePaths: src/Source/GitDiff
103-
filePattern: '*.php'
104-
showTreeView: true
105-
106-
- description: Source Implementations - Composer
107-
outputPath: sources/composer-source.md
108-
sources:
109-
- type: file
110-
sourcePaths: src/Source/Composer
111-
filePattern: '*.php'
112-
showTreeView: true
113-
114-
- description: Source Implementations - Tree
115-
outputPath: sources/tree-source.md
116-
sources:
117-
- type: file
118-
sourcePaths: src/Source/Tree
119-
filePattern: '*.php'
120-
showTreeView: true
121-
122-
- description: Modifiers System
123-
outputPath: modifiers/modifiers-core.md
124-
sources:
125-
- type: file
126-
sourcePaths: src/Modifier
127-
filePattern:
128-
- '*.php'
129-
- 'Alias/*.php'
130-
notPath:
131-
- 'PhpContentFilter.php'
132-
- 'PhpSignature.php'
133-
- 'ContextSanitizerModifier.php'
134-
showTreeView: true
135-
136-
- description: PHP Content Modifiers
137-
outputPath: modifiers/php-modifiers.md
138-
sources:
139-
- type: file
140-
sourcePaths: src/Modifier
141-
filePattern:
142-
- 'PhpContentFilter.php'
143-
- 'PhpSignature.php'
144-
showTreeView: true
145-
146-
- description: Sanitizer Modifier
147-
outputPath: modifiers/sanitizer.md
148-
sources:
149-
- type: file
150-
sourcePaths:
151-
- src/Modifier/ContextSanitizerModifier.php
152-
- src/Lib/Sanitizer
153-
filePattern: '*.php'
154-
showTreeView: true
155-
156-
- description: Content Building System
157-
outputPath: utilities/content-builder.md
158-
sources:
159-
- type: file
160-
sourcePaths: src/Lib/Content
161-
filePattern: '*.php'
162-
showTreeView: true
163-
164-
- description: Content Block Types
165-
outputPath: utilities/content-blocks.md
166-
sources:
167-
- type: file
168-
sourcePaths: src/Lib/Content/Block
61+
sourcePaths: src/ConfigLoader
16962
filePattern: '*.php'
17063
showTreeView: true
17164

@@ -197,7 +90,9 @@ documents:
19790
outputPath: utilities/github-client.md
19891
sources:
19992
- type: file
200-
sourcePaths: src/Lib/GithubClient
93+
sourcePaths:
94+
- src/Lib/GithubClient
95+
- src/GithubClientFactory.php
20196
filePattern: '*.php'
20297
showTreeView: true
20398

@@ -232,24 +127,8 @@ documents:
232127
sourcePaths:
233128
- tests
234129

235-
- description: "MCP Server Actions"
236-
outputPath: "mcp/actions.md"
237-
sources:
238-
- type: file
239-
sourcePaths:
240-
- src/McpServer/Action
241-
242-
- description: "MCP Server routing"
243-
outputPath: "mcp/routing.md"
244-
sources:
245-
- type: file
246-
sourcePaths:
247-
- src/McpServer/Routing
248-
- src/McpServer/Server.php
249-
- src/McpServer/ServerFactory.php
250-
251130
- description: "Changes in the Project"
252131
outputPath: "changes.md"
253132
sources:
254133
- type: git_diff
255-
commit: unstaged
134+
commit: unstaged

rector.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
// Register rules for PHP 8.4 migration
1616
$rectorConfig->sets([
17-
SetList::PHP_82,
18-
LevelSetList::UP_TO_PHP_82,
17+
SetList::PHP_83,
18+
LevelSetList::UP_TO_PHP_83,
1919
]);
2020

2121
// Skip vendor directories

src/ConfigLoader/ConfigLoaderFactory.php

+1-16
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Butschster\ContextGenerator\ConfigLoader\Import\ImportResolver;
99
use Butschster\ContextGenerator\ConfigLoader\Parser\CompositeConfigParser;
1010
use Butschster\ContextGenerator\ConfigLoader\Parser\ConfigParser;
11-
use Butschster\ContextGenerator\ConfigLoader\Parser\ConfigParserPluginInterface;
1211
use Butschster\ContextGenerator\ConfigLoader\Parser\ImportParserPlugin;
1312
use Butschster\ContextGenerator\ConfigLoader\Reader\JsonReader;
1413
use Butschster\ContextGenerator\ConfigLoader\Reader\PhpReader;
@@ -22,20 +21,14 @@
2221
/**
2322
* Factory for creating config loaders
2423
*/
25-
final readonly class ConfigLoaderFactory
24+
final readonly class ConfigLoaderFactory implements ConfigLoaderFactoryInterface
2625
{
2726
public function __construct(
2827
private FilesInterface $files,
2928
private Directories $dirs,
3029
private ?LoggerInterface $logger = null,
3130
) {}
3231

33-
/**
34-
* Create a loader for a specific config file
35-
*
36-
* @param array<ConfigParserPluginInterface> $parserPlugins Plugins for the config parser
37-
* @return ConfigLoaderInterface The config loader
38-
*/
3932
public function create(Directories $dirs, array $parserPlugins = []): ConfigLoaderInterface
4033
{
4134
\assert($this->logger instanceof HasPrefixLoggerInterface);
@@ -115,7 +108,6 @@ public function create(Directories $dirs, array $parserPlugins = []): ConfigLoad
115108
);
116109
}
117110

118-
// Add a new method to ConfigLoaderFactory to create a loader for a specific file path
119111
public function createForFile(Directories $dirs, array $parserPlugins = []): ConfigLoaderInterface
120112
{
121113
\assert($this->logger instanceof HasPrefixLoggerInterface);
@@ -172,13 +164,6 @@ public function createForFile(Directories $dirs, array $parserPlugins = []): Con
172164
);
173165
}
174166

175-
/**
176-
* Create a loader for an inline JSON configuration string
177-
*
178-
* @param string $jsonConfig The JSON configuration string
179-
* @param array<ConfigParserPluginInterface> $parserPlugins Plugins for the config parser
180-
* @return ConfigLoaderInterface The config loader
181-
*/
182167
public function createFromString(string $jsonConfig, array $parserPlugins = []): ConfigLoaderInterface
183168
{
184169
\assert($this->logger instanceof HasPrefixLoggerInterface);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Butschster\ContextGenerator\ConfigLoader;
6+
7+
use Butschster\ContextGenerator\ConfigLoader\Parser\ConfigParserPluginInterface;
8+
use Butschster\ContextGenerator\Directories;
9+
10+
/**
11+
* Interface for factories that create config loaders
12+
*/
13+
interface ConfigLoaderFactoryInterface
14+
{
15+
/**
16+
* Create a loader for a specific config file
17+
*
18+
* @param array<ConfigParserPluginInterface> $parserPlugins Plugins for the config parser
19+
* @return ConfigLoaderInterface The config loader
20+
*/
21+
public function create(Directories $dirs, array $parserPlugins = []): ConfigLoaderInterface;
22+
23+
/**
24+
* Create a loader for a specific file path
25+
*
26+
* @param array<ConfigParserPluginInterface> $parserPlugins Plugins for the config parser
27+
* @return ConfigLoaderInterface The config loader
28+
*/
29+
public function createForFile(Directories $dirs, array $parserPlugins = []): ConfigLoaderInterface;
30+
31+
/**
32+
* Create a loader for an inline JSON configuration string
33+
*
34+
* @param string $jsonConfig The JSON configuration string
35+
* @param array<ConfigParserPluginInterface> $parserPlugins Plugins for the config parser
36+
* @return ConfigLoaderInterface The config loader
37+
*/
38+
public function createFromString(string $jsonConfig, array $parserPlugins = []): ConfigLoaderInterface;
39+
}

src/ConfigLoader/ConfigurationProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
final readonly class ConfigurationProvider
1616
{
1717
public function __construct(
18-
private ConfigLoaderFactory $loaderFactory,
18+
private ConfigLoaderFactoryInterface $loaderFactory,
1919
private FilesInterface $files,
2020
private Directories $dirs,
2121
private ?LoggerInterface $logger = null,

src/ConfigLoader/Import/CircularImportDetector.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Detects circular dependencies in imports
99
*/
10-
final class CircularImportDetector
10+
final class CircularImportDetector implements CircularImportDetectorInterface
1111
{
1212
/**
1313
* @var array<string> Stack of import paths being processed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Butschster\ContextGenerator\ConfigLoader\Import;
6+
7+
/**
8+
* Interface for detecting circular dependencies in imports
9+
*/
10+
interface CircularImportDetectorInterface
11+
{
12+
/**
13+
* Check if adding this path would create a circular dependency
14+
*/
15+
public function wouldCreateCircularDependency(string $path): bool;
16+
17+
/**
18+
* Begin processing an import path
19+
*/
20+
public function beginProcessing(string $path): void;
21+
22+
/**
23+
* Finish processing an import path
24+
*/
25+
public function endProcessing(string $path): void;
26+
}

0 commit comments

Comments
 (0)