55use App \Models \User ;
66use Illuminate \Console \Command ;
77use Moox \Monorepo \Services \GitHubService ;
8- use Moox \Monorepo \Services \ReleaseService ;
98use Moox \Monorepo \Services \PackageComparisonService ;
9+ use Moox \Monorepo \Services \ReleaseService ;
1010
1111class CreateRelease extends Command
1212{
@@ -15,40 +15,43 @@ class CreateRelease extends Command
1515 protected $ description = 'Create a release for the monorepo ' ;
1616
1717 protected PackageComparisonService $ packageComparisonService ;
18+
1819 protected GitHubService $ githubService ;
1920
20- //TODO
21- // 1. Check the current version of this monorepo from GitHub API ✓
22- // 2. Ask the user for the new version, e.g. 4.2.11 ✓
23- // 3. Read directory of all packages (also private) ✓
24- // 4. If repos do not exist, create them (2nd iteration)
25- // 5. For each new repo, add it to devlink.php (2nd iteration)
26- // 6. Read the DEVLOG.md file ✓
27- // 7. Suggest contents from the DEVLOG.md file ✓
28- // 8. New packages without DEVLOG-entry are "Initial release"
29- // 9. Otherwise, "Compatibility release" for all other packages
30- // 10. Split all packages
31- // Core version in composer schreiben!
32- // 11. Create a new tag and release in all repos
33- // 12. Create a new Packagist.org package or Satis (3rd iteration)
34- // 13. Update the packages in the packages table (3rd iteration)
35- // 14. Webplate für translation release! And look at the translation commit from webplate (3rd iteration)
21+ // TODO
22+ // 1. Check the current version of this monorepo from GitHub API ✓
23+ // 2. Ask the user for the new version, e.g. 4.2.11 ✓
24+ // 3. Read directory of all packages (also private) ✓
25+ // 4. If repos do not exist, create them (2nd iteration)
26+ // 5. For each new repo, add it to devlink.php (2nd iteration)
27+ // 6. Read the DEVLOG.md file ✓
28+ // 7. Suggest contents from the DEVLOG.md file ✓
29+ // 8. New packages without DEVLOG-entry are "Initial release"
30+ // 9. Otherwise, "Compatibility release" for all other packages
31+ // 10. Split all packages
32+ // Core version in composer schreiben!
33+ // 11. Create a new tag and release in all repos
34+ // 12. Create a new Packagist.org package or Satis (3rd iteration)
35+ // 13. Update the packages in the packages table (3rd iteration)
36+ // 14. Webplate für translation release! And look at the translation commit from webplate (3rd iteration)
3637
3738 protected $ devlog ;
38- public function __construct (){
39+
40+ public function __construct ()
41+ {
3942 parent ::__construct ();
4043 $ this ->githubService = new GitHubService (User::first ()?->github_token);
4144 $ this ->packageComparisonService = new PackageComparisonService ($ this ->githubService , config ('monorepo.organization ' , 'mooxphp ' ));
4245 }
46+
4347 public function handle (): int
4448 {
45-
4649 $ token = User::first ()?->github_token;
47- if (! $ token ) {
48- $ this ->error ('No GitHub token found. Please link your GitHub account. ' );
49- return 1 ;
50- }
51-
50+ if (! $ token ) {
51+ $ this ->error ('No GitHub token found. Please link your GitHub account. ' );
52+
53+ return 1 ;
54+ }
5255
5356 switch (true ) {
5457 case $ this ->option ('versions ' ):
@@ -63,7 +66,7 @@ public function handle(): int
6366
6467 $ devlog = $ this ->parseDevlog ($ newVersion );
6568
66- //TODO es soll nur erkennen, dass es neu ist
69+ // TODO es soll nur erkennen, dass es neu ist
6770 foreach ($ devlog as $ package => $ messages ) {
6871 if ($ this ->packageComparisonService ->isNewPackage ($ package )) {
6972 $ this ->info ("New package: {$ package }" );
@@ -75,7 +78,6 @@ public function handle(): int
7578
7679 protected function showVersions (GitHubService $ github ): int
7780 {
78-
7981 $ mainRepo = config ('monorepo.public_repo ' , 'mooxphp/moox ' );
8082 $ org = 'mooxphp ' ;
8183
@@ -106,27 +108,27 @@ protected function comparePackages(GitHubService $github): int
106108 $ localPackages = collect (array_merge (
107109 \Illuminate \Support \Facades \File::directories (base_path ($ publicBasePath )),
108110 $ privateBasePath !== 'disabled ' ? \Illuminate \Support \Facades \File::directories (base_path ($ privateBasePath )) : []
109- ))->map (fn ($ dir ) => basename ($ dir ))
110- ->toArray ();
111+ ))->map (fn ($ dir ) => basename ($ dir ))
112+ ->toArray ();
111113
112114 $ devlogCommits = $ this ->parseDevlog ();
113115
114116 $ commitMessages = collect ($ localPackages )->mapWithKeys (function ($ package ) use ($ devlogCommits ) {
115117 if (isset ($ devlogCommits [$ package ])) {
116118 return [$ package => $ devlogCommits [$ package ]];
117119 }
120+
118121 return [$ package => ['Compatibility release ' ]];
119122 });
120123
121-
122-
123124 $ this ->packageComparisonService = new PackageComparisonService ($ github , config ('monorepo.organization ' , 'mooxphp ' ));
124125 $ devlinkPackages = $ this ->packageComparisonService ->extractDevlinkPackages ();
125126 $ comparison = $ this ->packageComparisonService ->comparePackagesWithRepositories ($ localPackages , $ devlinkPackages );
126127 $ this ->table (
127- ['Org. Package ' , 'Has single Repo ' , 'Is in Devlink Config ' , 'Commit Messages ' ],
128- $ comparison ->map (function ($ exists , $ package ) use ($ devlinkPackages , $ commitMessages ) {
128+ ['Org. Package ' , 'Has single Repo ' , 'Is in Devlink Config ' , 'Commit Messages ' ],
129+ $ comparison ->map (function ($ exists , $ package ) use ($ devlinkPackages , $ commitMessages ) {
129130 $ messages = $ commitMessages [strtolower ($ package )] ?? ['Not in Monorepo ' ];
131+
130132 return [
131133 $ package ,
132134 $ exists ? '✅ ' : '❌ ' ,
@@ -145,31 +147,30 @@ public function askForNewVersion(string $currentVersion): string
145147 $ this ->info ('No existing release found. Starting with version 0.0.1. ' );
146148 $ currentVersion = '0.0.1 ' ;
147149 $ suggestedVersion = $ currentVersion ;
148-
149150 } else {
150151 $ this ->info ("Current version: {$ currentVersion }" );
151152 [$ major , $ minor , $ patch ] = explode ('. ' , $ currentVersion );
152- $ suggestedVersion = "$ major. $ minor. " . ((int )$ patch + 1 );
153+ $ suggestedVersion = "$ major. $ minor. " . ((int ) $ patch + 1 );
153154 }
154155
155-
156- $ version = $ this ->ask ("Enter the new version: " , $ suggestedVersion );
157-
156+ $ version = $ this ->ask ('Enter the new version: ' , $ suggestedVersion );
157+
158158 if (! $ this ->validateVersionFormat ($ version )) {
159159 $ this ->error ('Invalid version format. Please use X.X.X format. ' );
160+
160161 return $ this ->askForNewVersion ($ currentVersion );
161162 }
162-
163+
163164 if (! $ this ->validateVersionOrder ($ version , $ currentVersion )) {
164165 $ this ->error ('New version cannot be smaller than the current version. ' );
166+
165167 return $ this ->askForNewVersion ($ currentVersion );
166168 }
167-
169+
168170 return $ version ;
169-
170171 }
171-
172- //Helper methods
172+
173+ // Helper methods
173174 private function validateVersionFormat (string $ version ): bool
174175 {
175176 return preg_match ('/^ \\d+ \\. \\d+ \\. \\d+$/ ' , $ version );
@@ -192,7 +193,7 @@ protected function parseDevlog(): array
192193 foreach ($ lines as $ line ) {
193194 if (preg_match ('/^##\s+(.*)$/ ' , $ line , $ matches )) {
194195 $ currentPackage = trim ($ matches [1 ]);
195- if (!isset ($ commits [strtolower ($ currentPackage )])) {
196+ if (! isset ($ commits [strtolower ($ currentPackage )])) {
196197 $ commits [strtolower ($ currentPackage )] = [];
197198 }
198199 } elseif ($ currentPackage && preg_match ('/^-\s+(.*)$/ ' , $ line , $ matches )) {
0 commit comments