Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .ddev/docker-compose.phpmyadmin.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ddev-generated
services:
phpmyadmin:
container_name: ddev-${DDEV_SITENAME}-phpmyadmin
Expand All @@ -24,7 +23,7 @@ services:
- HTTPS_EXPOSE=8037:80
healthcheck:
test: ["CMD-SHELL", "true"]
interval: 120s
interval: 5s
Comment thread
josbeir marked this conversation as resolved.
timeout: 2s
retries: 1
depends_on:
Expand Down
47 changes: 44 additions & 3 deletions src/Command/SyncPackagesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,24 @@ public function execute(Arguments $args, ConsoleIo $io): void
$packagesTable = $this->fetchTable('Packages');
$touchedIds = [];

$data = $this->client->all(['type' => 'cakephp-plugin']);
foreach ($data as $package) {
$io->out('Fetching package list from Packagist...');
$packages = $this->client->all(['type' => 'cakephp-plugin']);
$total = count($packages);
$io->out(sprintf('Found <info>%d</info> packages. Processing...', $total));

$saved = 0;
$skipped = 0;
$failed = 0;
$i = 0;

$progress = $io->helper('Progress');
Comment thread
josbeir marked this conversation as resolved.
$progress->init(['total' => $total, 'width' => 60]);
$io->out('', 0);

foreach ($packages as $package) {
$i++;
$io->out(sprintf('[%d/%d] %s', $i, $total, $package), 1, ConsoleIo::VERBOSE);

$data = $this->getDataForPackage($package);

if (
Expand All @@ -106,6 +122,8 @@ public function execute(Arguments $args, ConsoleIo $io): void
$data['downloads'] < 10 ||
!$this->hasExplicitCakePhpDependency($data['tag_list'])
) {
$skipped++;
$progress->increment()->draw();
continue;
}

Expand All @@ -116,26 +134,49 @@ public function execute(Arguments $args, ConsoleIo $io): void

$entity = $packagesTable->patchEntity($entity, $data);
if (!$packagesTable->save($entity)) {
$failed++;
Log::warning('Unable to save package', [
'package' => $package->getName(),
'package' => $package,
'errors' => $entity->getErrors(),
]);
} else {
$saved++;
}
$touchedIds[] = $entity->id;
$progress->increment()->draw();
}

$io->out('');
$io->out(sprintf(
'Sync complete. Saved: <info>%d</info>, Skipped: <comment>%d</comment>, Failed: <error>%d</error>',
$saved,
$skipped,
$failed,
));

// Remove packages that were not touched
$io->out('Removing stale packages...');
$deleted = 0;
$deleteFailed = 0;
/** @var \Cake\ORM\ResultSet<array-key, \App\Model\Entity\Package> $toDeletePackages */
$toDeletePackages = $packagesTable->find()->where(['id NOT IN' => $touchedIds])->all();
foreach ($toDeletePackages as $package) {
if (!$packagesTable->delete($package)) {
$deleteFailed++;
Log::warning('Unable to delete package', [
'package' => $package->package,
'id' => $package->id,
'errors' => $package->getErrors(),
]);
} else {
$deleted++;
}
}
$io->out(sprintf(
'Cleanup complete. Deleted: <info>%d</info>, Failed: <error>%d</error>',
$deleted,
$deleteFailed,
));
}

/**
Expand Down
6 changes: 2 additions & 4 deletions templates/element/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
</div>
</div>
</li>
<li role="separator" class="p-0"><hr class="divider my-0" /></li>
<li>
<li class="border-t border-base-300 pt-1">
<?= $this->Html->link('Sign out', [
'controller' => 'Users',
'action' => 'logout',
Expand Down Expand Up @@ -92,8 +91,7 @@
<li><?= $this->Html->link('Docs', 'https://book.cakephp.org/', ['target' => '_blank', 'rel' => 'noopener']) ?></li>
<li><?= $this->Html->link('API', 'https://api.cakephp.org/', ['target' => '_blank', 'rel' => 'noopener']) ?></li>
<?php if (!$this->Identity->isLoggedIn()) : ?>
<li role="separator" class="p-0"><hr class="divider my-0" /></li>
<li>
<li class="border-t border-base-300 pt-1">
<?= $this->Form->postLink(
'Sign in with GitHub',
[
Expand Down
Loading