@@ -91,27 +91,30 @@ public function save(): void
91
91
}
92
92
$ data ['includes ' ][] = $ content ;
93
93
}
94
+ unset($ tool , $ content );
94
95
95
96
foreach ($ this ->plugins as $ plugin ) {
96
97
if (null === $ content = $ this ->processPlugin ($ plugin )) {
97
98
continue ;
98
99
}
99
100
$ data ['includes ' ][] = $ content ;
100
101
}
102
+ unset($ plugin , $ content );
101
103
102
104
$ this ->dumpFile ('repository.json ' , $ data );
105
+ unset($ data );
103
106
104
107
$ flipped = array_flip ($ this ->dumpedFileNames );
105
108
foreach (glob ($ this ->baseDir . '/* ' ) as $ filename ) {
106
- if (!array_key_exists ($ filename , $ flipped )) {
109
+ if (!is_dir ( $ filename ) && ! array_key_exists ($ filename , $ flipped )) {
107
110
$ this ->filesystem ->remove ($ filename );
108
111
}
109
112
}
110
113
}
111
114
112
115
private function processTool (ToolInterface $ tool ): ?array
113
116
{
114
- $ fileName = $ tool ->getName () . ' -tool.json ' ;
117
+ $ fileName = sprintf ( ' tool/%1$s/%1$s.json ' , $ tool ->getName ()) ;
115
118
$ fileNameAbsolute = $ this ->baseDir . '/ ' . $ fileName ;
116
119
if ($ tool ->isEmpty ()) {
117
120
return null ;
@@ -175,18 +178,18 @@ private function encodeToolRequirements(ToolRequirements $requirements): stdClas
175
178
176
179
private function processPlugin (PluginInterface $ plugin ): ?array
177
180
{
178
- $ fileName = $ plugin ->getName () . ' -plugin.json ' ;
181
+ $ fileName = sprintf ( ' plugin/%1$s/%1$s.json ' , $ plugin ->getName ()) ;
179
182
$ fileNameAbsolute = $ this ->baseDir . '/ ' . $ fileName ;
180
183
if ($ plugin ->isEmpty ()) {
181
184
return null ;
182
185
}
183
186
$ data = [];
184
187
foreach ($ plugin as $ version ) {
185
188
// if file plugin, copy file - dump it otherwise.
186
- $ pluginFile = $ plugin ->getName () . ' - ' . $ version ->getVersion () . ' .php ' ;
189
+ $ pluginFile = sprintf ( ' %1$s-%2$s.php ' , $ plugin ->getName (), $ version ->getVersion ()) ;
187
190
$ signatureFile = $ pluginFile . '.asc ' ;
188
191
if ($ version instanceof PhpFilePluginVersion) {
189
- $ this ->copyFile ($ version ->getFilePath (), $ pluginFile );
192
+ $ this ->copyFile ($ version ->getFilePath (), sprintf ( ' plugin/%1$s/%2$s ' , $ plugin -> getName (), $ pluginFile) );
190
193
}
191
194
192
195
$ serialized = [
0 commit comments