Skip to content

Commit bf1c132

Browse files
authored
Merge pull request #22 from mbabker/v2-meta
[B/C Break] Use the v2 metadata for package metadata, misc. dependency updates, new API endpoints
2 parents ff7a48f + 77c2afc commit bf1c132

20 files changed

+477
-225
lines changed

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
# Ignore all test and documentation with "export-ignore".
55
/.gitattributes export-ignore
66
/.gitignore export-ignore
7-
/.travis.yml export-ignore
87
/phpunit.xml.dist export-ignore
98
/tests export-ignore
10-
/.php.cs export-ignore
119
/.github export-ignore
10+
/rector.php export-ignore

.github/workflows/php-cs-fixer.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/pint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Fix PHP code style issues
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.php'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
php-code-styling:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
ref: ${{ github.head_ref }}
21+
22+
- name: Fix PHP code style issues
23+
uses: aglipanci/[email protected]
24+
25+
- name: Commit changes
26+
uses: stefanzweifel/git-auto-commit-action@v5
27+
with:
28+
commit_message: Fix styling

.github/workflows/run-tests.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11+
php: [8.2, 8.3, 8.4]
12+
dependency-version: [prefer-stable]
1113
os: [ubuntu-latest, windows-latest]
12-
php: [8.1, 8.0, 7.4, 7.3]
13-
dependency-version: [prefer-lowest, prefer-stable]
14-
14+
include:
15+
- php: 8.2
16+
dependency-version: prefer-lowest
17+
os: ubuntu-latest
18+
1519
name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
1620

1721
steps:
1822
- name: Checkout code
19-
uses: actions/checkout@v2
23+
uses: actions/checkout@v4
2024

2125
- name: Cache dependencies
22-
uses: actions/cache@v2
26+
uses: actions/cache@v4
2327
with:
2428
path: ~/.composer/cache/files
2529
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

.github/workflows/update-changelog.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010

1111
steps:
1212
- name: Checkout code
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
1414
with:
1515
ref: main
1616

@@ -21,7 +21,7 @@ jobs:
2121
release-notes: ${{ github.event.release.body }}
2222

2323
- name: Commit updated CHANGELOG
24-
uses: stefanzweifel/git-auto-commit-action@v4
24+
uses: stefanzweifel/git-auto-commit-action@v5
2525
with:
2626
branch: main
2727
commit_message: Update CHANGELOG

.php-cs-fixer.dist.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ $packagist->getPackagesNamesByType('composer-plugin');
5050
$packagist->getPackagesNamesByVendor('spatie');
5151
```
5252

53+
### List popular packages
54+
```php
55+
// List first page of popular packages
56+
$packagist->getPopularPackages();
57+
```
58+
59+
#### Pagination
60+
Listing popular packages returns a paginated result. You can change the pagination settings by adding more parameters.
61+
62+
```php
63+
// Get the third page, 10 items per page.
64+
$packagist->getPopularPackages(3, 10);
65+
```
66+
5367
### Searching for packages
5468
```php
5569
// Search packages by name.
@@ -79,11 +93,20 @@ $packagist->searchPackagesByName('packagist', 3, 10);
7993
$packagist->getPackageMetadata('spatie/packagist-api');
8094
$packagist->getPackageMetadata('spatie', 'packagist-api');
8195

96+
// Using the Composer metadata for dev branches.
97+
$packagist->getPackageMetadata('spatie', 'packagist-api', true);
98+
8299
// Using the API. (slower, cached for 12 hours by Packagist.
83100
$packagist->getPackage('spatie/packagist-api');
84101
$packagist->getPackage('spatie', 'packagist-api');
85102
```
86103

104+
### Get package download stats
105+
```php
106+
$packagist->getPackageDownloadStats('spatie/packagist-api');
107+
$packagist->getPackageDownloadStats('spatie', 'packagist-api');
108+
```
109+
87110
### Get Statistics
88111
```php
89112
$packagist->getStatistics();

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@
2828
}
2929
],
3030
"require": {
31-
"php": "^7.3|^8.0",
31+
"php": "^8.2",
3232
"ext-json": "*",
3333
"guzzlehttp/guzzle": "^7.0",
34-
"composer/semver": "^1.0|^2.0|^3.0"
34+
"composer/semver": "^3.0"
3535
},
3636
"require-dev": {
37-
"phpunit/phpunit": "^9.4",
38-
"spatie/phpunit-snapshot-assertions": "^4.2"
37+
"laravel/pint": "^1.17.3",
38+
"phpunit/phpunit": "^11.5 || ^12.0",
39+
"spatie/phpunit-snapshot-assertions": "^5.1"
3940
},
4041
"autoload": {
4142
"psr-4": {
@@ -49,6 +50,6 @@
4950
},
5051
"scripts": {
5152
"test": "vendor/bin/phpunit",
52-
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
53+
"lint": "pint"
5354
}
5455
}

phpunit.xml.dist

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
5-
bootstrap="vendor/autoload.php"
6-
backupGlobals="false"
7-
backupStaticAttributes="false"
8-
colors="true"
9-
verbose="true"
10-
convertErrorsToExceptions="true"
11-
convertNoticesToExceptions="true"
12-
convertWarningsToExceptions="true"
13-
processIsolation="false"
14-
stopOnFailure="false">
15-
<coverage>
16-
<include>
17-
<directory suffix=".php">src/</directory>
18-
</include>
19-
<report>
20-
<clover outputFile="build/logs/clover.xml"/>
21-
<html outputDirectory="build/coverage"/>
22-
<text outputFile="build/coverage.txt"/>
23-
</report>
24-
</coverage>
25-
<testsuites>
26-
<testsuite name="Spatie Unit Test Suite">
27-
<directory>tests/Unit</directory>
28-
</testsuite>
29-
<testsuite name="Spatie Integration Test Suite">
30-
<directory>tests/Integration</directory>
31-
</testsuite>
32-
</testsuites>
33-
<logging>
34-
<junit outputFile="build/report.junit.xml"/>
35-
</logging>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
beStrictAboutOutputDuringTests="true"
5+
bootstrap="vendor/autoload.php"
6+
cacheResult="false"
7+
colors="true"
8+
failOnRisky="true"
9+
failOnWarning="true"
10+
cacheDirectory=".phpunit.cache"
11+
displayDetailsOnIncompleteTests="true"
12+
displayDetailsOnSkippedTests="true"
13+
displayDetailsOnTestsThatTriggerDeprecations="true"
14+
displayDetailsOnTestsThatTriggerErrors="true"
15+
displayDetailsOnTestsThatTriggerNotices="true"
16+
displayDetailsOnTestsThatTriggerWarnings="true"
17+
>
18+
<testsuites>
19+
<testsuite name="default">
20+
<directory suffix=".php">./tests</directory>
21+
</testsuite>
22+
</testsuites>
23+
<source>
24+
<include>
25+
<directory suffix=".php">./src</directory>
26+
</include>
27+
</source>
3628
</phpunit>

rector.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__.'/src',
10+
__DIR__.'/tests',
11+
])
12+
->withPreparedSets(codeQuality: true, phpunitCodeQuality: true)
13+
->withPhpSets();

0 commit comments

Comments
 (0)