Skip to content

Commit

Permalink
Make sure only kirby-plugin installable
Browse files Browse the repository at this point in the history
  • Loading branch information
afbora committed Feb 28, 2024
1 parent 95872d4 commit 4a179b4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions commands/plugin/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@
]
],
'command' => static function (CLI $cli): void {
$repo = $cli->arg('repo');
$version = $cli->arg('version');
$archive = 'https://github.com/' . $repo . '/archive';
$repo = $cli->arg('repo');
$version = $cli->arg('version');
$archiveUrl = 'https://github.com/' . $repo . '/archive';
$composerUrl = 'https://github.com/' . $repo . '/raw/HEAD/composer.json';

// make sure only `kirby-plugin` installable
$composer = json_decode(file_get_contents($composerUrl));
if (($composer?->type ?? null) !== 'kirby-plugin') {
throw new Exception('The GitHub repository should be a kirby plugin');
}

if ($version === 'latest') {
$url = $archive . '/main.zip';
$url = $archiveUrl . '/main.zip';
} else {
$url = $archive . '/refs/tags/' . $cli->arg('version') . '.zip';
$url = $archiveUrl . '/refs/tags/' . $cli->arg('version') . '.zip';
}

list($vendor, $plugin) = explode('/', $repo);
Expand Down

0 comments on commit 4a179b4

Please sign in to comment.