Skip to content

Commit 05db245

Browse files
authored
Web, Releases moox.json (#752)
* Web, Docs, JSON
1 parent d2705e4 commit 05db245

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+3888
-272
lines changed

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ APP_URL=https://moox.test
77

88
CUSTOM_VIEWS=example
99

10+
GITHUB_ORG=mooxphp
11+
GITHUB_TOKEN=your_github_token_here
12+
PACKAGIST_VENDOR=moox
13+
VSCODE_EXTENSION_ID=adrolli.tallui-laravel-livewire-tailwind
14+
1015
VERBOSE_LEVEL=3
1116
LOG_IN_PRODUCTION=true
1217

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
class ChangelogParser
4+
{
5+
private string $version;
6+
private array $globalChanges = [];
7+
private array $packageChanges = [];
8+
private array $monorepoNotes = [];
9+
10+
public function parseLatestVersion(string $content): void
11+
{
12+
$sections = [];
13+
$currentSection = null;
14+
$currentLevel = 0;
15+
16+
foreach (explode("\n", $content) as $line) {
17+
// Get first version number
18+
if (str_starts_with($line, '## ') && !$this->version) {
19+
$this->version = trim(str_replace('## ', '', $line));
20+
continue;
21+
}
22+
23+
// Parse sections
24+
if (str_starts_with($line, '### ')) {
25+
$currentSection = trim(str_replace('### ', '', $line));
26+
$currentLevel = 3;
27+
continue;
28+
}
29+
30+
// Store content based on section
31+
$trimmedLine = trim($line);
32+
if ($trimmedLine && $currentSection) {
33+
if ($currentSection === 'All') {
34+
$this->globalChanges[] = $trimmedLine;
35+
} elseif ($currentLevel === 3) {
36+
$this->packageChanges[$currentSection][] = $trimmedLine;
37+
}
38+
}
39+
}
40+
}
41+
42+
public function isPackageAffected(string $package): bool
43+
{
44+
return isset($this->packageChanges[$package]) || $this->isMajorVersion();
45+
}
46+
47+
public function isMajorVersion(): bool
48+
{
49+
$parts = explode('.', $this->version);
50+
return isset($parts[1]) && $parts[1] === '0' && $parts[2] === '0';
51+
}
52+
53+
// Getters
54+
public function getVersion(): string
55+
{
56+
return $this->version;
57+
}
58+
59+
public function getGlobalChanges(): array
60+
{
61+
return $this->globalChanges;
62+
}
63+
64+
public function getPackageChanges(string $package): array
65+
{
66+
return $this->packageChanges[$package] ?? [];
67+
}
68+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
class PackageChangelogUpdater
4+
{
5+
private ChangelogParser $parser;
6+
private string $packagesDir;
7+
8+
public function __construct(string $changelogContent, string $packagesDir)
9+
{
10+
$this->parser = new ChangelogParser();
11+
$this->parser->parseLatestVersion($changelogContent);
12+
$this->packagesDir = $packagesDir;
13+
}
14+
15+
public function updatePackage(string $package): void
16+
{
17+
$changelogPath = "{$this->packagesDir}/{$package}/CHANGELOG.md";
18+
19+
$changes = [];
20+
21+
// Add version header
22+
$changes[] = "## {$this->parser->getVersion()}";
23+
$changes[] = "";
24+
25+
// Add global changes if any
26+
if ($globalChanges = $this->parser->getGlobalChanges()) {
27+
foreach ($globalChanges as $change) {
28+
$changes[] = $change;
29+
}
30+
$changes[] = "";
31+
}
32+
33+
// Add package-specific changes
34+
if ($packageChanges = $this->parser->getPackageChanges($package)) {
35+
foreach ($packageChanges as $change) {
36+
$changes[] = $change;
37+
}
38+
} elseif ($this->parser->isMajorVersion()) {
39+
$changes[] = "Compatibility release";
40+
}
41+
42+
// Prepend to existing changelog
43+
$this->prependToChangelog($changelogPath, $changes);
44+
}
45+
46+
private function prependToChangelog(string $path, array $changes): void
47+
{
48+
$content = file_exists($path) ? file_get_contents($path) : "# Changelog\n\n";
49+
$newContent = implode("\n", $changes) . "\n\n" . $content;
50+
file_put_contents($path, $newContent);
51+
}
52+
}

.github/workflows/monorepo-split-packages.yml

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,71 +7,57 @@ on:
77

88
env:
99
GITHUB_TOKEN: ${{ secrets.BOT }}
10-
CORE_VERSION: "^3.0.3"
1110

1211
jobs:
13-
packages_split:
12+
matrix_prep:
1413
runs-on: ubuntu-latest
14+
outputs:
15+
matrix: ${{ steps.set-matrix.outputs.matrix }}
16+
core_version: ${{ steps.get-core-version.outputs.version }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
- id: set-matrix
20+
run: |
21+
PACKAGES=$(jq -c '{package: [.packages[].name]}' .github/workflows/moox.json)
22+
echo "matrix=$PACKAGES" >> $GITHUB_OUTPUT
23+
- id: get-core-version
24+
run: |
25+
VERSION=$(jq -r '.packages[] | select(.name == "core") | .latest' .github/workflows/moox.json)
26+
echo "version=^${VERSION}" >> $GITHUB_OUTPUT
1527
28+
packages_split:
29+
needs: matrix_prep
30+
runs-on: ubuntu-latest
1631
strategy:
1732
fail-fast: false
18-
matrix:
19-
package:
20-
- audit
21-
- builder
22-
- category
23-
- core
24-
- devlink
25-
- expiry
26-
- flags
27-
- jobs
28-
- locate
29-
- login-link
30-
- notifications
31-
- passkey
32-
- permission
33-
- press
34-
- security
35-
- skeleton
36-
- sync
37-
- tag
38-
- trainings
39-
- user
40-
- user-device
41-
- user-session
33+
matrix: ${{ fromJson(needs.matrix_prep.outputs.matrix) }}
4234

4335
steps:
4436
- uses: actions/checkout@v4
4537

46-
# Search and replace "moox/core": "*" with "moox/core": "^3.0.3" in composer.json
4738
- name: Replace core version in composer.json
4839
working-directory: packages/${{ matrix.package }}
4940
run: |
5041
if [ -f composer.json ]; then
5142
echo "Updating moox/core version in ${{ matrix.package }}"
52-
sed -i 's/"moox\/core": "\*"/"moox\/core": "^3.0.3"/g' composer.json
43+
sed -i 's/"moox\/core": "\*"/"moox\/core": "${{ needs.matrix_prep.outputs.core_version }}"/g' composer.json
5344
fi
5445
55-
# Commit the updated composer.json (if there was a change)
5646
- name: Commit changes
5747
working-directory: packages/${{ matrix.package }}
5848
run: |
5949
if [ -f composer.json ]; then
6050
git config --global user.name "mooxbot"
6151
git config --global user.email "[email protected]"
6252
git add composer.json
63-
git commit -m "Update moox/core dependency to ^^3.0.3" || echo "No changes to commit"
53+
git commit -m "Update moox/core dependency to ${{ needs.matrix_prep.outputs.core_version }}" || echo "No changes to commit"
6454
fi
6555
6656
- if: "!startsWith(github.ref, 'refs/tags/')"
6757
uses: "symplify/[email protected]"
6858
with:
69-
tag: ${GITHUB_REF#refs/tags/}
70-
7159
package_directory: "packages/${{ matrix.package }}"
72-
7360
repository_organization: "mooxphp"
7461
repository_name: "${{ matrix.package }}"
75-
7662
user_name: "mooxbot"
7763
user_email: "[email protected]"

.github/workflows/update-changelog.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

CHANGELOG-implementation.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Changelog
2+
3+
This is the changelog of the Moox monorepo. All changes noted here are used to update the changelogs of the individual packages and will invoke a new release for all packages that have changes or all packages if a mayor version is released.
4+
5+
## Next
6+
7+
This is the next version that will be released. We need to just skip this part of the changelog to get to the current version.
8+
9+
### All
10+
11+
Skip this too.
12+
13+
### Core
14+
15+
And this too.
16+
17+
## 4.0.0
18+
19+
This is the current version. If this is newer than the already released version, the changelog should be updated and a new release should be created.
20+
21+
This comment stays only here in the monorepo changelog.
22+
23+
### All
24+
25+
This should be written to all Moox packages.
26+
27+
- Added support for Filament 4
28+
- Removed support for Filament 3
29+
- Aligned all Moox packages to Version 4.0
30+
- Added automatic changelog generation
31+
32+
### Core
33+
34+
This would be written to the core package instead of the all-packages changelog.
35+
36+
### Press
37+
38+
This would be written to the Press package instead of the all-packages changelog.
39+
40+
And so on.
41+
42+
If All is empty, and the package is not mentioned in the changelog but has updates, there should be a "Compatibility release" note written the changelog of the package.

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
# Changelog
22

3-
This is the changelog of the monorepo. It is currently not used. If you want to know more about what fixes and improvements we made, take a look at the Changelogs of the Moox packages.
3+
This is the changelog of the Moox monorepo. All changes noted here are used to update the changelogs of the individual packages and will invoke a new release for all packages that have changes or all packages if a mayor version is released.
4+
5+
## Next
6+
7+
We work on the next version and compatibility with Filament 4.
8+
9+
### All
10+
11+
- Added support for Filament 4
12+
- Removed support for Filament 3
13+
14+
### Core
15+
16+
- Added support for Filament 4
17+
- Removed support for Filament 3
18+
- I guess we need some more changes here...
19+
20+
## 3.5.0
21+
22+
Added automatic changelog generation to the monorepo. This aligns all packages to version 3.5.0.
23+
24+
### All
25+
26+
Compatibility release for all Moox packages. We aligned all packages to version 3.5.0 in preparation for Filament 4. Contains no new features or changes.

app/View/Components/Logo.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace App\View\Components;
4+
5+
use Illuminate\View\Component;
6+
7+
class Logo extends Component
8+
{
9+
public function __construct() {}
10+
11+
public function render()
12+
{
13+
return view('components.logo');
14+
}
15+
}

config/app.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,17 @@
240240
// 'ExampleClass' => App\Example\ExampleClass::class,
241241
])->toArray(),
242242

243+
/*
244+
|--------------------------------------------------------------------------
245+
| Moox Stats
246+
|--------------------------------------------------------------------------
247+
|
248+
| Used for getting the stats of Moox.
249+
|
250+
*/
251+
'github_token' => env('GITHUB_TOKEN'),
252+
'github_org' => env('GITHUB_ORG', 'mooxphp'),
253+
'packagist_vendor' => env('PACKAGIST_VENDOR', 'moox'),
254+
'vscode_extension_id' => env('VSCODE_EXTENSION_ID', 'adrolli.tallui-laravel-livewire-tailwind'),
255+
243256
];

0 commit comments

Comments
 (0)