Skip to content

Commit 9d21ffc

Browse files
[sync] Synchronize funding metadata (#56) (#113)
* [sync] Synchronize funding metadata (#56) * Update wiki submodule pointer for PR #113 * [funding] Normalize composer sync output (#56) * Update wiki submodule pointer for PR #113 --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent c9d0891 commit 9d21ffc

20 files changed

Lines changed: 1513 additions & 16 deletions

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
github: php-fast-forward
22
custom:
3-
- https://www.paypal.com/donate/?business=JLDAF45XZ8D84
3+
- 'https://www.paypal.com/donate/?business=JLDAF45XZ8D84'

.github/wiki

Submodule wiki updated from 3f20b41 to 5246f54

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ composer reports --target=.dev-tools --coverage=.dev-tools/coverage
8484
# Synchronize packaged agent skills into .agents/skills
8585
composer skills
8686

87+
# Synchronize Composer funding metadata with .github/FUNDING.yml
88+
composer funding
89+
composer funding --dry-run
90+
8791
# Merges and synchronizes .gitignore files
8892
composer gitignore
8993

@@ -117,6 +121,11 @@ The `metrics` command ships with `phpmetrics/phpmetrics` as a direct
117121
dependency of `fast-forward/dev-tools`, so consumer repositories can generate
118122
metrics reports without extra setup.
119123

124+
The `funding` command keeps supported `composer.json` funding entries aligned
125+
with `.github/FUNDING.yml`, including GitHub Sponsors handles and `custom`
126+
URLs, while preserving unsupported providers in place and re-running
127+
`composer normalize` after manifest updates.
128+
120129
The `skills` command keeps `.agents/skills` aligned with the packaged Fast
121130
Forward skill set. It creates missing links, repairs broken links, and
122131
preserves existing non-symlink directories. The `dev-tools:sync` command calls
@@ -138,8 +147,9 @@ source of truth.
138147
| `composer metrics` | Runs PhpMetrics for the current project and generates requested report artifacts. |
139148
| `composer docs` | Builds the HTML documentation site from PSR-4 code and `docs/`. |
140149
| `composer skills` | Creates or repairs packaged skill links in `.agents/skills`. |
150+
| `composer funding` | Synchronizes managed funding metadata between `composer.json` and `.github/FUNDING.yml`. |
141151
| `composer gitattributes` | Manages export-ignore rules in `.gitattributes`. |
142-
| `composer dev-tools:sync` | Updates scripts, workflow stubs, `.editorconfig`, `.gitignore`, `.gitattributes`, wiki setup, and packaged skills. |
152+
| `composer dev-tools:sync` | Updates scripts, funding metadata, workflow stubs, `.editorconfig`, `.gitignore`, `.gitattributes`, wiki setup, and packaged skills. |
143153

144154
## 🔌 Integration
145155

composer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
"source": "https://github.com/php-fast-forward/dev-tools",
2727
"docs": "https://php-fast-forward.github.io/dev-tools/"
2828
},
29+
"funding": [
30+
{
31+
"type": "github",
32+
"url": "https://github.com/sponsors/php-fast-forward"
33+
},
34+
{
35+
"type": "custom",
36+
"url": "https://www.paypal.com/donate/?business=JLDAF45XZ8D84"
37+
}
38+
],
2939
"require": {
3040
"php": "^8.3",
3141
"composer-plugin-api": "^2.0",
@@ -65,6 +75,7 @@
6575
"symfony/process": "^7.4 || ^8.0",
6676
"symfony/var-dumper": "^7.4 || ^8.0",
6777
"symfony/var-exporter": "^7.4 || ^8.0",
78+
"symfony/yaml": "^7.4 || ^8.0",
6879
"symplify/easy-coding-standard": "^13.0",
6980
"thecodingmachine/safe": "^3.4",
7081
"twig/twig": "^3.24"

docs/api/commands.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ dependencies through constructor injection. The architecture uses
4444
* - ``FastForward\DevTools\Console\Command\SkillsCommand``
4545
- ``skills``
4646
- Synchronizes packaged agent skills into ``.agents/skills``.
47+
* - ``FastForward\DevTools\Console\Command\FundingCommand``
48+
- ``funding``
49+
- Synchronizes managed funding metadata between Composer and GitHub files.
4750
* - ``FastForward\DevTools\Console\Command\SyncCommand``
4851
- ``dev-tools:sync``
4952
- Synchronizes consumer-facing scripts, automation assets, and packaged

docs/commands/funding.rst

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
funding
2+
=======
3+
4+
Synchronizes funding metadata between ``composer.json`` and
5+
``.github/FUNDING.yml``.
6+
7+
Description
8+
-----------
9+
10+
The ``funding`` command merges supported funding metadata declared in Composer
11+
and GitHub formats so both files stay aligned:
12+
13+
1. Composer ``funding`` entries with ``type=github`` are normalized to GitHub
14+
Sponsors handles in ``.github/FUNDING.yml``.
15+
2. Composer ``funding`` entries with ``type=custom`` are normalized to
16+
``custom`` URLs in ``.github/FUNDING.yml``.
17+
3. Existing ``github`` and ``custom`` entries from ``.github/FUNDING.yml`` are
18+
mirrored back into ``composer.json``.
19+
4. Unsupported providers are preserved in their original format.
20+
21+
Usage
22+
-----
23+
24+
.. code-block:: bash
25+
26+
composer funding
27+
composer funding [options]
28+
composer dev-tools funding -- [options]
29+
vendor/bin/dev-tools funding [options]
30+
31+
Options
32+
-------
33+
34+
``--composer-file`` (optional)
35+
Path to the Composer manifest to synchronize. Default:
36+
``Factory::getComposerFile()``.
37+
38+
``--funding-file`` (optional)
39+
Path to the GitHub funding file to synchronize. Default:
40+
``.github/FUNDING.yml``.
41+
42+
``--dry-run``
43+
Preview funding metadata drift without writing files.
44+
45+
``--check``
46+
Exit with code ``1`` when synchronized funding metadata would change either
47+
file.
48+
49+
``--interactive``
50+
Prompt before writing drifted funding metadata files.
51+
52+
Examples
53+
--------
54+
55+
Synchronize the default files:
56+
57+
.. code-block:: bash
58+
59+
composer funding
60+
61+
Preview funding drift:
62+
63+
.. code-block:: bash
64+
65+
composer funding --dry-run
66+
67+
Validate funding metadata in CI:
68+
69+
.. code-block:: bash
70+
71+
composer funding --check
72+
73+
Use custom paths:
74+
75+
.. code-block:: bash
76+
77+
composer funding --composer-file=packages/example/composer.json --funding-file=packages/example/.github/FUNDING.yml
78+
79+
Exit Codes
80+
----------
81+
82+
.. list-table::
83+
:header-rows: 1
84+
85+
* - Code
86+
- Meaning
87+
* - 0
88+
- Success. Funding metadata was already aligned or was updated
89+
successfully.
90+
* - 1
91+
- Failure. ``--check`` detected drift or a write failed.
92+
93+
Behavior
94+
--------
95+
96+
- Supports GitHub Sponsors handles and ``custom`` URLs as synchronized managed
97+
entries.
98+
- Preserves unsupported Composer funding providers and unsupported GitHub
99+
funding YAML keys.
100+
- Normalizes ``composer.json`` with ``composer normalize`` after applying
101+
funding metadata updates.
102+
- Creates ``.github/FUNDING.yml`` when Composer declares supported funding
103+
metadata and the file is missing.
104+
- Skips writing ``.github/FUNDING.yml`` when neither side declares supported
105+
funding metadata.
106+
- Renders a unified diff during ``--dry-run`` and ``--check`` so local runs and
107+
CI logs show the managed changes clearly.

docs/commands/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Detailed documentation for each dev-tools command.
1818
reports
1919
skills
2020
sync
21+
funding
2122
gitignore
2223
gitattributes
2324
license

docs/commands/sync.rst

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ The ``dev-tools:sync`` command synchronizes consumer-facing automation and defau
1212
2. ``copy-resource`` - copies GitHub Actions workflows
1313
3. ``copy-resource`` - copies .editorconfig
1414
4. ``copy-resource`` - copies dependabot.yml
15-
5. ``wiki --init`` - initializes wiki as submodule
16-
6. ``gitignore`` - merges .gitignore files
17-
7. ``gitattributes`` - manages export-ignore rules
18-
8. ``skills`` - synchronizes packaged skills
19-
9. ``license`` - generates LICENSE file
20-
10. ``git-hooks`` - installs Git hooks
15+
5. ``funding`` - synchronizes ``composer.json`` funding metadata with ``.github/FUNDING.yml``
16+
6. ``wiki --init`` - initializes wiki as submodule
17+
7. ``gitignore`` - merges .gitignore files
18+
8. ``gitattributes`` - manages export-ignore rules
19+
9. ``skills`` - synchronizes packaged skills
20+
10. ``license`` - generates LICENSE file
21+
11. ``git-hooks`` - installs Git hooks
2122

2223
Usage
2324
-----
@@ -89,13 +90,16 @@ Exit Codes
8990
Behavior
9091
---------
9192

92-
- Updates ``composer.json`` scripts and extra configuration.
93+
- Updates ``composer.json`` scripts, extra configuration, and managed funding
94+
metadata.
9395
- Copies missing workflow stubs, ``.editorconfig``, and ``dependabot.yml``.
96+
- Synchronizes supported funding metadata between ``composer.json`` and
97+
``.github/FUNDING.yml``.
9498
- When ``--overwrite`` is enabled, replaced text resources emit a unified diff
9599
so terminal sessions and CI logs show what changed.
96100
- ``--dry-run`` and ``--check`` verify managed-file drift for ``composer.json``,
97-
copied resources, ``.gitignore``, ``.gitattributes``, ``LICENSE``, and Git
98-
hooks.
101+
funding metadata, copied resources, ``.gitignore``, ``.gitattributes``,
102+
``LICENSE``, and Git hooks.
99103
- ``--interactive`` prompts before replacing drifted managed files when the
100104
command is running in an interactive terminal.
101105
- Creates ``.github/wiki`` as a git submodule when missing.

docs/running/specialized-commands.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,28 @@ Important details:
193193
- it creates missing symlinks and repairs broken ones;
194194
- it preserves an existing non-symlink directory instead of overwriting it.
195195

196+
``funding``
197+
-----------
198+
199+
Synchronizes supported funding metadata between Composer and GitHub formats.
200+
201+
.. code-block:: bash
202+
203+
composer funding
204+
composer funding --dry-run
205+
composer funding --check
206+
207+
Important details:
208+
209+
- it keeps ``composer.json`` ``funding`` entries and ``.github/FUNDING.yml`` in
210+
sync for GitHub Sponsors and ``custom`` URLs;
211+
- it preserves unsupported Composer funding providers and unsupported YAML
212+
keys instead of rewriting them;
213+
- it creates ``.github/FUNDING.yml`` when Composer already declares supported
214+
funding metadata;
215+
- it supports ``--dry-run``, ``--check``, and ``--interactive`` so funding
216+
drift can be surfaced in CI and reviewed locally.
217+
196218
``dev-tools:sync``
197219
------------------
198220

@@ -206,6 +228,8 @@ Important details:
206228

207229
- it updates ``composer.json`` scripts and
208230
``extra.grumphp.config-default-path``;
231+
- it calls ``funding`` so supported funding metadata stays aligned between
232+
``composer.json`` and ``.github/FUNDING.yml``;
209233
- it copies missing workflow stubs, ``.editorconfig``, and ``dependabot.yml``;
210234
- it creates ``.github/wiki`` as a git submodule when the directory is
211235
missing.

0 commit comments

Comments
 (0)