-
-
Notifications
You must be signed in to change notification settings - Fork 4
Chorale (Replaces Bard) #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
97ae0b7
Chorale initial commit
JoshuaEstes 779bc87
updates
JoshuaEstes ccb7f95
plan command
JoshuaEstes 70fe8a5
bug fix
JoshuaEstes 8bc6210
testing
JoshuaEstes 25f2dd4
meh
JoshuaEstes 7d6526d
testing
JoshuaEstes 9a751db
testing
JoshuaEstes 3bd5f01
Document Chorale tool and fix DependencyMerger
JoshuaEstes 20fbd3e
Merge pull request #1 from JoshuaEstes/codex/review-pr-and-add-agents.md
JoshuaEstes 4f77c1f
feat(chorale): merge root composer dependencies
JoshuaEstes 3f26ecb
Merge pull request #2 from JoshuaEstes/codex/review-and-enhance-chora…
JoshuaEstes 0d7f0d3
Merge branch 'main' into chorale
JoshuaEstes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,3 +16,4 @@ packages.json | |
| results.sarif | ||
| infection.log | ||
| .churn.cache | ||
| tools/chorale/composer.lock | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| version: 1 | ||
| repo_host: git@github.com | ||
| repo_vendor: SonsOfPHP | ||
| repo_name_template: '{name:kebab}.git' | ||
| default_repo_template: '{repo_host}:{repo_vendor}/{repo_name_template}' | ||
| default_branch: main | ||
| splitter: splitsh | ||
| tag_strategy: inherit-monorepo-tag | ||
| rules: | ||
| keep_history: true | ||
| skip_if_unchanged: true | ||
| require_files: | ||
| - composer.json | ||
| - LICENSE | ||
| patterns: | ||
| - | ||
| match: 'src/**' | ||
| include: | ||
| - '**' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| #!/usr/bin/env php | ||
| <?php declare(strict_types=1); | ||
|
|
||
| require __DIR__ . '/../vendor/autoload.php'; | ||
|
|
||
| use Symfony\Component\Console\Application; | ||
| use Chorale\Console\Style\ConsoleStyleFactory; | ||
| use Chorale\Console\SetupCommand; | ||
| use Chorale\Repo\TemplateRenderer; | ||
| use Chorale\Util\PathUtils; | ||
| use Chorale\Util\Sorting; | ||
| use Chorale\Discovery\PackageIdentity; | ||
| use Chorale\Config\ConfigDefaults; | ||
| use Chorale\Config\SchemaValidator; | ||
| use Chorale\IO\BackupManager; | ||
| use Chorale\IO\JsonReporter; | ||
| use Chorale\Telemetry\RunSummary; | ||
| use Chorale\Config\ConfigLoader; | ||
| use Chorale\Config\ConfigWriter; | ||
| use Chorale\Config\ConfigNormalizer; | ||
| use Chorale\Discovery\ComposerMetadata; | ||
| use Chorale\Discovery\PackageScanner; | ||
| use Chorale\Discovery\PatternMatcher; | ||
| use Chorale\Repo\RepoResolver; | ||
| use Chorale\Rules\RequiredFilesChecker; | ||
| use Chorale\Rules\ConflictDetector; | ||
| use Chorale\Composer\ComposerJsonReader; | ||
| use Chorale\Composer\DependencyMerger; | ||
| use Chorale\Composer\RuleEngine; | ||
| use Chorale\Split\ContentHasher; | ||
| use Chorale\Split\SplitDecider; | ||
| use Chorale\State\FilesystemStateStore; | ||
| use Chorale\Util\DiffUtil; | ||
| use Chorale\Plan\PlanBuilder; | ||
| use Chorale\Console\PlanCommand; | ||
|
|
||
| $paths = new PathUtils(); | ||
| $renderer = new TemplateRenderer(); | ||
| $sorting = new Sorting(); | ||
| $identity = new PackageIdentity(); | ||
| $defaults = new ConfigDefaults(); | ||
| $schema = new SchemaValidator(); | ||
| $backup = new BackupManager(); | ||
| $json = new JsonReporter(); | ||
| $summary = new RunSummary(); | ||
| $loader = new ConfigLoader(); | ||
| $composerMeta = new ComposerMetadata(); | ||
| $composerReader = new ComposerJsonReader(); | ||
| $stateStore = new FilesystemStateStore(); | ||
| $hasher = new ContentHasher(); | ||
| $diffs = new DiffUtil(); | ||
|
|
||
| $ruleEngine = new RuleEngine($renderer); | ||
| $writer = new ConfigWriter($backup); | ||
| $normalizer = new ConfigNormalizer($sorting, $defaults); | ||
| $scanner = new PackageScanner($paths); | ||
| $matcher = new PatternMatcher($paths); | ||
| $resolver = new RepoResolver($renderer, $paths); | ||
| $required = new RequiredFilesChecker(); | ||
| $conflicts = new ConflictDetector($matcher); | ||
| $depMerger = new DependencyMerger($composerReader); | ||
| $splitDecider = new SplitDecider($stateStore, $hasher); | ||
|
|
||
| $planner = new PlanBuilder( | ||
| defaults: $defaults, | ||
| scanner: $scanner, | ||
| matcher: $matcher, | ||
| resolver: $resolver, | ||
| paths: $paths, | ||
| composerReader: $composerReader, | ||
| depMerger: $depMerger, | ||
| ruleEngine: $ruleEngine, | ||
| splitDecider: $splitDecider, | ||
| diffs: $diffs, | ||
| ); | ||
|
|
||
| // ----------------------------------------------------------------------------- | ||
| $app = new Application('Chorale', '0.1.0'); | ||
| // ----------------------------------------------------------------------------- | ||
|
|
||
| // ----------------------------------------------------------------------------- | ||
| $app->add(new SetupCommand( | ||
| styleFactory: new ConsoleStyleFactory(), | ||
| configLoader: $loader, | ||
| configWriter: $writer, | ||
| configNormalizer: $normalizer, | ||
| schemaValidator: $schema, | ||
| defaults: $defaults, | ||
| scanner: $scanner, | ||
| matcher: $matcher, | ||
| resolver: $resolver, | ||
| identity: $identity, | ||
| requiredFiles: $required, | ||
| //conflicts: $conflicts, | ||
| jsonReporter: $json, | ||
| summary: $summary, | ||
| composerMeta: $composerMeta, | ||
| )); | ||
| // ----------------------------------------------------------------------------- | ||
|
|
||
| // ----------------------------------------------------------------------------- | ||
| $app->add(new PlanCommand( | ||
| styleFactory: new ConsoleStyleFactory(), | ||
| configLoader: $loader, | ||
| planner: $planner, | ||
| )); | ||
| // ----------------------------------------------------------------------------- | ||
|
|
||
| // ----------------------------------------------------------------------------- | ||
| $app->run(); | ||
| // ----------------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| { | ||
| "name": "sonsofphp/chorale", | ||
| "description": "Chorale: a CLI tool to help manage PHP monorepos.", | ||
| "type": "project", | ||
| "license": "MIT", | ||
| "require": { | ||
| "php": "^8.3", | ||
| "ext-mbstring": "*", | ||
| "symfony/console": "^7.0", | ||
| "symfony/yaml": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^10.0", | ||
| "symfony/var-dumper": "^7.3" | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "Chorale\\": "src/" | ||
| } | ||
| }, | ||
| "autoload-dev": { | ||
| "psr-4": { | ||
| "Chorale\\Tests\\": "src/Tests/" | ||
| } | ||
| }, | ||
| "bin": [ | ||
| "bin/chorale" | ||
| ], | ||
| "config": { | ||
| "sort-packages": true, | ||
| "preferred-install": "dist" | ||
| }, | ||
| "minimum-stability": "stable", | ||
| "prefer-stable": true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" | ||
| bootstrap="vendor/autoload.php" | ||
| cacheDirectory=".phpunit.cache" | ||
| requireCoverageMetadata="true" | ||
| backupGlobals="false" | ||
| colors="true" | ||
| cacheResult="true" | ||
| executionOrder="defects" | ||
| beStrictAboutCoverageMetadata="true" | ||
| stopOnDefect="true" | ||
| stopOnError="true" | ||
| stopOnFailure="true" | ||
| stopOnWarning="true" | ||
| stopOnDeprecation="true" | ||
| stopOnNotice="true" | ||
| displayDetailsOnIncompleteTests="true" | ||
| displayDetailsOnSkippedTests="true" | ||
| displayDetailsOnTestsThatTriggerDeprecations="true" | ||
| displayDetailsOnPhpunitDeprecations="true" | ||
| displayDetailsOnTestsThatTriggerErrors="true" | ||
| displayDetailsOnTestsThatTriggerNotices="true" | ||
| displayDetailsOnTestsThatTriggerWarnings="true" | ||
| > | ||
|
|
||
| <php> | ||
| <ini name="error_reporting" value="-1" /> | ||
| </php> | ||
| <testsuites> | ||
| <testsuite name="Chorale Test Suite"> | ||
| <directory>src/Tests</directory> | ||
| </testsuite> | ||
| </testsuites> | ||
|
|
||
| <coverage includeUncoveredFiles="true" pathCoverage="false" ignoreDeprecatedCodeUnits="true" disableCodeCoverageIgnore="false" /> | ||
|
|
||
| <source> | ||
| <include> | ||
| <directory suffix=".php">src</directory> | ||
| </include> | ||
| <exclude> | ||
| <directory>src/Tests</directory> | ||
| </exclude> | ||
| </source> | ||
| </phpunit> | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Chorale\Composer; | ||
|
|
||
| final class ComposerJsonReader implements ComposerJsonReaderInterface | ||
| { | ||
| public function read(string $absolutePath): array | ||
| { | ||
| if (!is_file($absolutePath)) { | ||
| return []; | ||
| } | ||
|
|
||
| $raw = @file_get_contents($absolutePath); | ||
| if ($raw === false) { | ||
| return []; | ||
| } | ||
|
|
||
| $json = json_decode($raw, true); | ||
|
|
||
| return is_array($json) ? $json : []; | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
tools/chorale/src/Composer/ComposerJsonReaderInterface.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Chorale\Composer; | ||
|
|
||
| interface ComposerJsonReaderInterface | ||
| { | ||
| /** | ||
| * @return array<string, mixed> | ||
| * if missing/invalid, it will return an empty array | ||
| */ | ||
| public function read(string $absolutePath): array; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have the ability to replace variables in the files.