Skip to content

Commit 8a48eba

Browse files
committed
add command to export devlinked packages as .txt file
1 parent 4817966 commit 8a48eba

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

packages/devlink/config/devlink.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@
3131
*/
3232
$private_repo_url = env('DEVLINK_PRIVATE_REPO_URL', 'https://pkg.moox.pro/');
3333

34+
/*
35+
|--------------------------------------------------------------------------
36+
| Export Path
37+
|--------------------------------------------------------------------------
38+
|
39+
| The file the package list is exported to (relative to the project root),
40+
| used by CI and the export script. Can be set in the .env file.
41+
|
42+
*/
43+
$export_path = env('DEVLINK_EXPORT_PATH', '.github/moox-packages.txt');
44+
45+
46+
3447
return [
3548

3649
/*
@@ -576,5 +589,6 @@
576589
'packages_path' => $packages_path,
577590
'public_base_path' => $public_base_path,
578591
'private_base_path' => $private_base_path,
592+
'export_path' => $export_path,
579593

580594
];
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Moox\Devlink\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class ExportPackagesCommand extends Command
8+
{
9+
protected $signature = 'moox:devlink-export {--path= : Override the export path from config}';
10+
protected $description = 'Write the active devlink package folders to a file (for CI/deploy)';
11+
12+
public function handle(): int
13+
{
14+
$path = $this->option('path')
15+
?? config('devlink.export_path', '.github/moox-packages.txt');
16+
17+
// In config/devlink.php the array KEY is the folder name (e.g. "address").
18+
// Export only active packages that live in the monorepo: type "public".
19+
// This excludes bundles (meta packages, no folder), "private" (from Satis)
20+
// and "local" (your own committed packages).
21+
$folders = collect(config('devlink.packages', []))
22+
->filter(fn ($cfg) => ($cfg['active'] ?? false) === true
23+
&& ($cfg['type'] ?? null) === 'public')
24+
->keys()
25+
->sort()
26+
->values();
27+
28+
$target = base_path($path);
29+
@mkdir(dirname($target), 0755, true);
30+
file_put_contents($target, $folders->implode(' ') . PHP_EOL);
31+
32+
$this->info($folders->count() . " active packages → {$path}");
33+
$this->line($folders->implode(' '));
34+
35+
return self::SUCCESS;
36+
}
37+
}

packages/devlink/src/DevlinkServiceProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
use Illuminate\Support\ServiceProvider;
88
use Moox\Devlink\Console\Commands\DeployCommand;
9+
use Moox\Devlink\Console\Commands\ExportPackagesCommand;
910
use Moox\Devlink\Console\Commands\LinkCommand;
1011
use Moox\Devlink\Console\Commands\StatusCommand;
1112

13+
1214
class DevlinkServiceProvider extends ServiceProvider
1315
{
1416
public function register(): void
@@ -25,6 +27,7 @@ public function boot(): void
2527

2628
$this->commands([
2729
DeployCommand::class,
30+
ExportPackagesCommand::class,
2831
LinkCommand::class,
2932
StatusCommand::class,
3033
]);

0 commit comments

Comments
 (0)