Skip to content

Commit 46b13e7

Browse files
authored
Merge pull request #54 from tdwesten/patch-1
Patch 1
2 parents 501d17b + 29f1994 commit 46b13e7

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
jobs:
7+
release-on-merge:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
steps:
14+
- uses: dexwritescode/release-on-merge-action@v1

src/Console/Export.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,44 @@ public function handle()
2424

2525
$this->exportFieldSets();
2626

27+
$this->exportCollections();
28+
2729
$this->newLine();
2830

2931
$this->info('All done!');
3032
}
3133

34+
private function exportCollections()
35+
{
36+
$namespaces = collect(config('statamic.builder.collections', []));
37+
38+
$namespaces->each(function ($collections): void {
39+
$collections = collect($collections);
40+
41+
$collections->each(function ($collection): void {
42+
$this->exportCollection($collection);
43+
});
44+
});
45+
}
46+
47+
private function exportCollection($collection)
48+
{
49+
$filesystem = Storage::build([
50+
'driver' => 'local',
51+
'root' => base_path('resources/collections'),
52+
]);
53+
54+
$data = (new $collection)->register();
55+
56+
$path = base_path("resources/collections/{$data->handle()}.yaml");
57+
58+
$yaml = YAML::dump($data->toArray());
59+
60+
$this->line("Exporting collection [{$data->handle()}] to [{$path}]");
61+
62+
$filesystem->put("{$data->handle()}.yaml", $yaml);
63+
}
64+
3265
private function exportBlueprints()
3366
{
3467
$namespaces = collect(config('statamic.builder.blueprints', []));

0 commit comments

Comments
 (0)