getConstants() as $key => $value) { $key = \strtolower($key); if (in_array($key, $keys)) { $manifest_item[$key] = $value; } } $version = $manifest_item['version']; if (0 < floatval($version)) { echo "+ {$name} {$version}\n"; $manifest_item['type'] = 'plugin'; $manifest_item['id'] = $name; $manifest_item['file'] = "{$dir}-{$version}.tgz"; ksort($manifest_item); $manifest[$name] = $manifest_item; $tar_destination = PLUGINS_DEST_DIR . "/{$name}-{$version}.tar"; $tgz_destination = PLUGINS_DEST_DIR . "/{$name}-{$version}.tgz"; @unlink($tgz_destination); @unlink("{$tar_destination}.gz"); $tar = new PharData($tar_destination); $tar->buildFromDirectory('./plugins/', '/' . \preg_quote("./plugins/{$name}", '/') . '/'); $tar->compress(Phar::GZ); unlink($tar_destination); rename("{$tar_destination}.gz", $tgz_destination); if (Phar::canWrite()) { $phar_destination = PLUGINS_DEST_DIR . "/{$name}.phar"; @unlink($phar_destination); $tar = new Phar($phar_destination); $tar->buildFromDirectory("./plugins/{$name}/"); $tar->compress(Phar::GZ); unlink($phar_destination); rename("{$phar_destination}.gz", $phar_destination); } } else { echo "- {$name} {$version}\n"; } } else { echo "- {$name}\n"; } } ksort($manifest); $manifest = json_encode(array_values($manifest)); $manifest = str_replace('{"', "\n\t{\n\t\t\"", $manifest); $manifest = str_replace('"}', "\"\n\t}", $manifest); $manifest = str_replace('}]', "}\n]", $manifest); $manifest = str_replace('","', "\",\n\t\t\"", $manifest); $manifest = str_replace('\/', '/', $manifest); file_put_contents(PLUGINS_DEST_DIR . "/packages.json", $manifest); exit;