Skip to content

Commit f05625e

Browse files
MelvinAchterhuisjankal
authored andcommitted
feat: add packagist downloads
1 parent 20025b7 commit f05625e

File tree

9 files changed

+53
-6
lines changed

9 files changed

+53
-6
lines changed

src/Action/LoadPluginAction.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function execute(string|PackageIndexEntry $packageInformation, \DateTimeI
8383
'license' => $version['license'][0] ?? 'UNKNOWN',
8484
'link' => $repositoryUrl,
8585
'availableVersion' => $version['version'],
86+
'packagistDownloads' => $packagistData['package']['downloads']['total'] ?? 0,
8687
];
8788

8889
if ('' === trim($pluginData['manufacturer'])) {

src/Core/Framework/Plugin/AvailableOpensourcePlugin/AvailableOpensourcePluginDefinition.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
1313
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
1414
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
15+
use Shopware\Core\Framework\DataAbstractionLayer\Field\IntField;
1516
use Shopware\Core\Framework\DataAbstractionLayer\Field\JsonField;
1617
use Shopware\Core\Framework\DataAbstractionLayer\Field\OneToOneAssociationField;
1718
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField;
@@ -53,6 +54,7 @@ protected function defineFields(): FieldCollection
5354
(new StringField('license', 'license'))->addFlags(new Required()),
5455
(new StringField('link', 'link'))->addFlags(new Required()),
5556
(new StringField('available_version', 'availableVersion'))->addFlags(new Required()),
57+
(new IntField('packagist_downloads', 'packagistDownloads'))->addFlags(new Required()),
5658
(new DateField('last_seen_at', 'lastSeenAt'))->addFlags(new Required()),
5759
(new DateField('last_commit_time', 'lastCommitTime'))->addFlags(new Required()),
5860

src/Core/Framework/Plugin/AvailableOpensourcePlugin/AvailableOpensourcePluginEntity.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class AvailableOpensourcePluginEntity extends Entity
3434

3535
protected string $availableVersion;
3636

37+
protected int $packagistDownloads;
38+
3739
protected \DateTimeInterface $lastSeenAt;
3840

3941
protected \DateTimeInterface $lastCommitTime;
@@ -148,6 +150,16 @@ public function setAvailableVersion(string $availableVersion): void
148150
$this->availableVersion = $availableVersion;
149151
}
150152

153+
public function getPackagistDownloads(): int
154+
{
155+
return $this->packagistDownloads;
156+
}
157+
158+
public function setPackagistDownloads(int $packagistDownloads): void
159+
{
160+
$this->packagistDownloads = $packagistDownloads;
161+
}
162+
151163
public function getPluginId(): ?string
152164
{
153165
return $this->pluginId;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace NuonicPluginInstaller\Migration;
4+
5+
use Doctrine\DBAL\Connection;
6+
use Shopware\Core\Framework\Migration\MigrationStep;
7+
8+
/**
9+
* @internal
10+
*/
11+
class Migration1743939491AddPackagistDownloads extends MigrationStep
12+
{
13+
public function getCreationTimestamp(): int
14+
{
15+
return 1743939491;
16+
}
17+
18+
public function update(Connection $connection): void
19+
{
20+
$connection->executeStatement('ALTER TABLE `nuonic_available_opensource_plugin` ADD COLUMN `packagist_downloads` INT(11) NOT NULL AFTER `available_version`');
21+
}
22+
}

src/Resources/app/administration/src/component/nuonic-extension-card/nuonic-extension-card.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
{{ $tc('nuonic-plugin-installer.cards.license') }}
2323
{{ extension.license }}
2424
</span>
25+
<br />
26+
<a :href="'https://packagist.org/packages/' + extension.packageName + '/stats'" target="_blank" class="nuonic-extension-card-base__info-downloads">
27+
{{ $tc('nuonic-plugin-installer.cards.downloads') }} {{ extension.packagistDownloads }}
28+
</a>
2529
</section>
2630
</div>
2731

src/Resources/app/administration/src/component/nuonic-extension-card/nuonic-extension-card.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
.nuonic-extension-card-base__info-inactive {
4040
font-size: $font-size-xs;
4141
}
42+
43+
.nuonic-extension-card-base__info-downloads {
44+
font-size: $font-size-xxs;
45+
}
4246
}
4347

4448
.nuonic-extension-card-base__main-action {

src/Resources/app/administration/src/module/nuonic-plugin-installer/page/nuonic-plugin-installer-list/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Component.register('nuonic-plugin-installer-list', {
1717
limit: 25,
1818
total: 0,
1919
term: null,
20-
sortBy: 'name',
21-
sortDirection: 'ASC',
20+
sortBy: 'packagistDownloads',
21+
sortDirection: 'DESC',
2222
loading: false,
2323
};
2424
},

src/Resources/app/administration/src/snippet/de-DE.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"installedAt": "Installiert am:",
2727
"license": "Lizenz:",
2828
"manufacturer": "Hersteller:",
29-
"update": "Aktualisieren"
29+
"update": "Aktualisieren",
30+
"downloads": "Downloads:"
3031
},
3132
"notification": {
3233
"installFailed": "Installation fehlgeschlagen"
@@ -44,4 +45,4 @@
4445
}
4546
}
4647
}
47-
}
48+
}

src/Resources/app/administration/src/snippet/en-GB.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"installedAt": "Installed on:",
2727
"license": "License:",
2828
"manufacturer": "Manufacturer:",
29-
"update": "Update"
29+
"update": "Update",
30+
"downloads": "Downloads:"
3031
},
3132
"notification": {
3233
"installFailed": "Installation failed"
@@ -44,4 +45,4 @@
4445
}
4546
}
4647
}
47-
}
48+
}

0 commit comments

Comments
 (0)