Skip to content

Commit 70643d5

Browse files
committed
feat: auto readme
1 parent 4d94c8e commit 70643d5

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Update README with Artisan Commands
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.2'
24+
extensions: mbstring, intl
25+
coverage: none
26+
27+
- name: Install dependencies
28+
run: composer install --no-interaction --no-progress --prefer-dist
29+
30+
- name: Generate README
31+
env:
32+
APP_ENV: production
33+
run: php scripts/generate-readme.php
34+
35+
- uses: stefanzweifel/git-auto-commit-action@v6

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
11
## OpenAI Test
22

33
* Random stuff to test OpenAI-PHP
4+
* If you migrate - Telescope is installed to get raw HTTP requests and responses.
5+
6+
7+
## Console Commands
8+
9+
<!-- COMMANDS:START -->
10+
11+
| Command | Description |
12+
|---|---|
13+
| `app:assistant-reasoning-create` | Command description |
14+
| `app:audio-stream-transcription-test` | Command description |
15+
| `app:audio-transcribe-dynamic-response-test` | Command description |
16+
| `app:audio-translate-dynamic-response-test` | Command description |
17+
| `app:chat-audio-test` | Command description |
18+
| `app:chat-image-test` | Command description |
19+
| `app:chat-request-file-attachment-test` | Command description |
20+
| `app:chat-stream-include-usage-test` | Command description |
21+
| `app:chatsearch-test` | Command description |
22+
| `app:completion-test` | Command description |
23+
| `app:container-file-object-test` | Command description |
24+
| `app:container-test` | Command description |
25+
| `app:fine-tuning-test` | Command description |
26+
| `app:image-edit-test` | Command description |
27+
| `app:image-test` | Command description |
28+
| `app:moderation-test` | Command description |
29+
| `app:realtime-token-test` | Command description |
30+
| `app:response-conversation-test` | Command description |
31+
| `app:responses-basic-test` | Command description |
32+
| `app:responses-cancel-test` | Command description |
33+
| `app:responses-code-interpreter-background-test` | Command description |
34+
| `app:responses-code-interpreter-test` | Command description |
35+
| `app:responses-image-generation-test` | Command description |
36+
| `app:responses-mcp-connector-test` | Test for Model Context Protocol (MCP) via Connectors |
37+
| `app:responses-mcp-require-approval-test` | Test for Model Context Protocol (MCP) |
38+
| `app:responses-mcp-test` | Test for Model Context Protocol (MCP) |
39+
| `app:responses-nano-model-test` | Command description |
40+
| `app:responses-service-tier-test` | Command description |
41+
| `app:responses-stored-prompt-test` | Command description |
42+
| `app:responses-stream-code-interpreter-test` | Command description |
43+
| `app:responses-stream-mcp-test` | Test for Model Context Protocol (MCP) |
44+
| `app:responses-test` | Command description |
45+
| `app:responses-vector-search-test` | Command description |
46+
47+
<!-- COMMANDS:END -->

scripts/generate-readme.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
3+
chdir(__DIR__.'/..');
4+
5+
require __DIR__.'/../vendor/autoload.php';
6+
$app = require __DIR__.'/../bootstrap/app.php';
7+
$app->make(Illuminate\Contracts\Console\Kernel::class);
8+
9+
// Try to get list via Symfony console JSON if available
10+
$commands = [];
11+
12+
$artisan = $app->make(Illuminate\Contracts\Console\Kernel::class);
13+
$output = new Symfony\Component\Console\Output\BufferedOutput;
14+
$input = new Symfony\Component\Console\Input\ArrayInput(['command' => 'list', '--format' => 'json']);
15+
$artisan->handle($input, $output);
16+
$data = json_decode($output->fetch(), true);
17+
if (is_array($data) && isset($data['commands'])) {
18+
foreach ($data['commands'] as $cmd) {
19+
$commands[] = [
20+
'name' => $cmd['name'] ?? '',
21+
'description' => $cmd['description'] ?? '',
22+
];
23+
}
24+
}
25+
26+
// Keep only custom commands starting with `app:` then filter unique and sort
27+
$seen = [];
28+
$commands = array_values(array_filter($commands, function ($c) use (&$seen) {
29+
$key = $c['name'] ?? '';
30+
if (! $key) {
31+
return false;
32+
}
33+
if (! str_starts_with($key, 'app:')) {
34+
return false;
35+
} // only user-defined commands
36+
if (isset($seen[$key])) {
37+
return false;
38+
}
39+
$seen[$key] = true;
40+
41+
return true;
42+
}));
43+
usort($commands, function ($a, $b) {
44+
return strcmp($a['name'], $b['name']);
45+
});
46+
47+
$readmePath = __DIR__.'/../README.md';
48+
$existing = file_exists($readmePath) ? file_get_contents($readmePath) : '';
49+
50+
$start = '<!-- COMMANDS:START -->';
51+
$end = '<!-- COMMANDS:END -->';
52+
53+
$table = "\n";
54+
$table .= "| Command | Description |\n";
55+
$table .= "|---|---|\n";
56+
if ($commands) {
57+
foreach ($commands as $c) {
58+
$name = $c['name'];
59+
$desc = str_replace(["\n", "\r", '|'], [' ', ' ', '\\|'], $c['description']);
60+
$table .= "| `{$name}` | {$desc} |\n";
61+
}
62+
} else {
63+
$table .= "| _(no commands found)_ | |\n";
64+
}
65+
$table .= "\n";
66+
67+
$section = "\n## Console Commands\n\n".$start."\n".$table.$end."\n";
68+
69+
if (str_contains($existing, $start) && str_contains($existing, $end)) {
70+
$new = preg_replace('/'.preg_quote($start, '/').'.*?'.preg_quote($end, '/').'/s', $start."\n".$table.$end, $existing);
71+
} else {
72+
$new = rtrim($existing)."\n\n".$section;
73+
}
74+
75+
if ($new !== $existing) {
76+
file_put_contents($readmePath, $new);
77+
}
78+
79+
echo "README.md updated.\n";

0 commit comments

Comments
 (0)