Skip to content

Commit

Permalink
Merge pull request #12 from eclipxe13/maintenance-20221108
Browse files Browse the repository at this point in the history
Maintenance (v2.5.0)
  • Loading branch information
eclipxe13 authored Nov 8, 2022
2 parents 67f8912 + fdec9e7 commit 2f50dde
Show file tree
Hide file tree
Showing 68 changed files with 182 additions and 141 deletions.
7 changes: 6 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@
/.phive/ export-ignore
/build/ export-ignore
/tests/ export-ignore
/.dockerignore export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.dist.php export-ignore
/.scrutinizer.yml export-ignore
/Docker.README.md export-ignore
/Dockerfile export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml.dist export-ignore

# Do not count these files on github code language
/tests/_files/** linguist-detectable=false
24 changes: 12 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.1'
coverage: none
tools: composer:v2, cs2pr, phpcs
tools: cs2pr, phpcs
env:
fail-fast: true
- name: Code style (phpcs)
Expand All @@ -35,13 +35,13 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.1'
coverage: none
tools: composer:v2, cs2pr, php-cs-fixer
tools: cs2pr, php-cs-fixer
env:
fail-fast: true
- name: Code style (php-cs-fixer)
Expand All @@ -52,11 +52,11 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.1'
coverage: none
extensions: sqlite3
tools: composer:v2, cs2pr, phpstan
Expand All @@ -66,7 +66,7 @@ jobs:
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
Expand All @@ -81,10 +81,10 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
php-versions: ['8.0', '8.1']
php-versions: [8.1', '8.2']
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -104,7 +104,7 @@ jobs:
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
Expand Down
9 changes: 5 additions & 4 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.8.0" installed="3.8.0" location="./tools/php-cs-fixer" copy="false"/>
<phar name="phpcs" version="^3.6.2" installed="3.6.2" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.6.2" installed="3.6.2" location="./tools/phpcbf" copy="false"/>
<phar name="phpstan" version="^1.5.3" installed="1.5.3" location="./tools/phpstan" copy="false"/>
<phar name="php-cs-fixer" version="^3.13.0" installed="3.13.0" location="./tools/php-cs-fixer" copy="false"/>
<phar name="phpcs" version="^3.7.1" installed="3.7.1" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.7.1" installed="3.7.1" location="./tools/phpcbf" copy="false"/>
<phar name="phpstan" version="^1.9.1" installed="1.9.1" location="./tools/phpstan" copy="false"/>
<phar name="composer-normalize" version="^2.28.3" installed="2.28.3" location="./tools/composer-normalize" copy="false"/>
</phive>
11 changes: 6 additions & 5 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@
->setRules([
'@PSR12' => true,
'@PSR12:risky' => true,
'@PHP73Migration' => true,
'@PHP74Migration' => true,
'@PHP80Migration' => true,
'@PHP80Migration' => true,
'@PHP80Migration:risky' => true,
// symfony
'class_attributes_separation' => true,
'whitespace_after_comma_in_array' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'function_typehint_space' => true,
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays']],
'no_blank_lines_after_phpdoc' => true,
'object_operator_without_whitespace' => true,
'binary_operator_spaces' => true,
'phpdoc_scalar' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_comma_in_singleline' => true,
'single_quote' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_unused_imports' => true,
Expand All @@ -38,14 +37,16 @@
'concat_space' => ['spacing' => 'one'],
'linebreak_after_opening_tag' => true,
// symfony:risky
'no_alias_functions' => true,
'self_accessor' => true,
// contrib
'not_operator_with_successor_space' => true,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']], // @PSR12 sort_algorithm: none
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
->append([__FILE__])
->exclude(['vendor', 'tools', 'build']),
->exclude(['tools', 'vendor', 'build'])
)
;
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ composer dev:build

The following tests must pass before we will accept a pull request.
If any of these do not pass, it will result in a complete build failure.
Before you can run these, be sure to `composer install` or `composer update`.
Before you can run these, be sure to `composer install` or `composer update` and `phive update`.

```shell script
vendor/bin/php-cs-fixer fix --verbose
vendor/bin/phpcbf --colors -sp
tools/php-cs-fixer fix --verbose
tools/phpcbf --colors -sp
vendor/bin/phpunit --testdox
vendor/bin/phpstan.phar analyse --no-progress --level max
tools/phpstan analyse --no-progress --level max
mkdir -p build/files/
bin/sat-catalogos-update dump-origins > build/files/origins.xml
bin/sat-catalogos-update update-origins build/files/ -w build/files/database.sqlite3
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# phpcfdi/sat-catalogos-populate

[![Source Code][badge-source]][source]
[![PHP Version][badge-php-version]][php-version]
[![Latest Version][badge-release]][release]
[![Software License][badge-license]][license]
[![Build Status][badge-build]][build]
[![Scrutinizer][badge-quality]][quality]
[![Coverage Status][badge-coverage]][coverage]
[![Total Downloads][badge-downloads]][downloads]

> Herramienta para crear y actualizar los catálogos de SAT/CFDI en una base de datos SQLite3
Expand All @@ -21,8 +21,8 @@ the commands provided by this package, for more information check the [`README.D
```shell script
git clone https://github.com/phpcfdi/sat-catalogos-populate.git
docker build -t sat-catalogos-populate sat-catalogos-populate/
docker run -it --rm sat-catalogos-populate /opt/bin/sat-catalogos-update --help
```
docker run -it --rm sat-catalogos-populate --help
```

## Installation on local system

Expand Down Expand Up @@ -83,17 +83,17 @@ and licensed for use under the MIT License (MIT). Please see [LICENSE][] for mor
[todo]: https://github.com/phpcfdi/sat-catalogos-populate/blob/master/docs/TODO.md

[source]: https://github.com/phpcfdi/sat-catalogos-populate
[php-version]: https://github.com/phpcfdi/sat-catalogos-populate/blob/master/composer.json
[release]: https://github.com/phpcfdi/sat-catalogos-populate/releases
[license]: https://github.com/phpcfdi/sat-catalogos-populate/blob/master/LICENSE
[build]: https://github.com/phpcfdi/sat-catalogos-populate/actions/workflows/build.yml?query=branch:master
[quality]: https://scrutinizer-ci.com/g/phpcfdi/sat-catalogos-populate/
[coverage]: https://scrutinizer-ci.com/g/phpcfdi/sat-catalogos-populate/code-structure/master/code-coverage/src
[downloads]: https://github.com/phpcfdi/sat-catalogos-populate

[badge-source]: https://img.shields.io/badge/source-phpcfdi/sat--catalogos--populate-blue?style=flat-square
[badge-php-version]: https://img.shields.io/badge/php-^8.1-blue?style=flat-square
[badge-release]: https://img.shields.io/github/release/phpcfdi/sat-catalogos-populate?style=flat-square
[badge-license]: https://img.shields.io/github/license/phpcfdi/sat-catalogos-populate?style=flat-square
[badge-build]: https://img.shields.io/github/workflow/status/phpcfdi/sat-catalogos-populate/build/master?style=flat-square
[badge-quality]: https://img.shields.io/scrutinizer/g/phpcfdi/sat-catalogos-populate/master?style=flat-square
[badge-coverage]: https://img.shields.io/scrutinizer/coverage/g/phpcfdi/sat-catalogos-populate/master?style=flat-square
[badge-downloads]: https://img.shields.io/github/downloads/phpcfdi/sat-catalogos-populate/total?style=flat-square
47 changes: 28 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
{
"name": "phpcfdi/sat-catalogos-populate",
"description": "Herramienta para crear y actualizar los catálogos de SAT/CFDI en una base de datos SQLite3",
"keywords": ["sat", "cfdi", "catalogos"],
"homepage": "https://github.com/phpcfdi/sat-catalogos-populate",
"license": "MIT",
"keywords": [
"sat",
"cfdi",
"catalogos"
],
"authors": [
{
"name": "Carlos C Soto",
"email": "[email protected]"
}
],
"homepage": "https://github.com/phpcfdi/sat-catalogos-populate",
"support": {
"source": "https://github.com/phpcfdi/sat-catalogos-populate",
"issues": "https://github.com/phpcfdi/sat-catalogos-populate/issues"
"issues": "https://github.com/phpcfdi/sat-catalogos-populate/issues",
"source": "https://github.com/phpcfdi/sat-catalogos-populate"
},
"require": {
"php": ">=8.0",
"ext-pdo": "*",
"ext-sqlite3": "*",
"php": ">=8.1",
"ext-dom": "*",
"ext-json": "*",
"ext-pdo": "*",
"ext-simplexml": "*",
"ext-dom": "*",
"psr/log": "^1.0",
"ext-sqlite3": "*",
"guzzlehttp/guzzle": "^7.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0",
"symfony/dom-crawler": "^5.2"
},
"require-dev": {
"ext-fileinfo": "*",
"phpunit/phpunit": "^9.1.5"
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
Expand All @@ -44,29 +48,34 @@
}
},
"scripts": {
"dev:build": ["@dev:fix-style", "@dev:test"],
"dev:build": [
"@dev:fix-style",
"@dev:test"
],
"dev:check-style": [
"@php tools/composer-normalize normalize --dry-run",
"@php tools/php-cs-fixer fix --dry-run --verbose",
"@php tools/phpcs --colors -sp"
],
"dev:coverage": [
"@php -dzend_extension=xdebug.so -dxdebug.mode=coverage vendor/bin/phpunit --testdox --coverage-html build/coverage/html/"
],
"dev:fix-style": [
"@php tools/composer-normalize normalize",
"@php tools/php-cs-fixer fix --verbose",
"@php tools/phpcbf --colors -sp"
],
"dev:test": [
"@dev:check-style",
"vendor/bin/phpunit --testdox --verbose --stop-on-failure",
"@php vendor/bin/phpunit --testdox --verbose --stop-on-failure",
"@php tools/phpstan analyse --no-progress --no-interaction"
],
"dev:coverage": [
"@php -dzend_extension=xdebug.so vendor/bin/phpunit --coverage-text --coverage-html build/coverage/html/"
]
},
"scripts-descriptions": {
"dev:build": "DEV: run dev:fix-style and dev:tests, run before pull request",
"dev:check-style": "DEV: search for code style errors using php-cs-fixer and phpcs",
"dev:fix-style": "DEV: fix code style errors using php-cs-fixer and phpcbf",
"dev:test": "DEV: run dev:check-style, phpunit and phpstan",
"dev:coverage": "DEV: run phpunit with xdebug and storage coverage in build/coverage/html/"
"dev:check-style": "DEV: search for code style errors using composer-normalize, php-cs-fixer and phpcs",
"dev:coverage": "DEV: run phpunit with xdebug and storage coverage in build/coverage/html/",
"dev:fix-style": "DEV: fix code style errors using composer-normalize, php-cs-fixer and phpcbf",
"dev:test": "DEV: run dev:check-style, phpunit and phpstan"
}
}
17 changes: 17 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# phpcfdi/sat-catalogos-populate Changelog

## Version 2.5.0 2022-11-08

- Fix PHPStan issue: `str_getcsv` can return `array<scalar|null>`.
- Update signature for `SeekableIterator::seek`.
- `UrlResponse` can have a `Stringable|string` body property.
- Move logic to create a UrlResponse from a PSR Response
- Bump to PHP 8.1.
- Add badge for PHP 8.1.
- Remove badge for downloads.
- Upgrade development tools.
- Update GH workflow:
- Add PHP 8.2 to test matrix.
- Update GH actions to 8.1.
- Remove composer requierement when not needed.
- Fix composer script `dev:coverage`.
- Implement development tool `composer-normalize`.

## Version 2.4.2 2022-04-01

- Fix *Carta Porte 2.0* injector *ProductosServicios* headers.
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ruleset name="EngineWorks">
<description>The EngineWorks (PSR-2 based) coding standard.</description>
<description>The EngineWorks (PSR-12 based) coding standard.</description>

<file>bin</file>
<file>src</file>
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractCsvInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract public function checkHeaders(CsvFile $csv): void;

abstract public function dataTable(): DataTable;

public function __construct(private string $sourceFile)
public function __construct(private readonly string $sourceFile)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CliApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function run(string ...$arguments): int
return 0;
}

if (count(array_intersect(['-h', '--help'], $arguments)) > 0) {
if ([] !== array_intersect(['-h', '--help'], $arguments)) {
$this->showHelp($command);
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/UpdateOrigins.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class UpdateOrigins implements CommandInterface

public function __construct(
string $originsFile,
private bool $updateOrigins,
private string $databaseLocation,
private readonly bool $updateOrigins,
private readonly string $databaseLocation,
private LoggerInterface $logger
) {
if ('' === $originsFile) {
Expand Down
8 changes: 4 additions & 4 deletions src/Converters/CsvFolderJoinFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ function ($path): array {
$file = basename($path);
$matches = [];
if (
! (bool) preg_match('/^[ ]*(.+)_Parte_([0-9]+)[ ]*\.csv$/', $file, $matches)
&& ! (bool) preg_match('/^[ ]*(.+) \(Parte ([0-9]+)\)[ ]*\.csv$/', $file, $matches)
&& ! (bool) preg_match('/^[ ]*(.+)_([0-9]+)[ ]*\.csv$/', $file, $matches)
! preg_match('/^ *(.+)_Parte_([0-9]+) *\.csv$/', $file, $matches)
&& ! preg_match('/^ *(.+) \(Parte ([0-9]+)\) *\.csv$/', $file, $matches)
&& ! preg_match('/^ *(.+)_([0-9]+) *\.csv$/', $file, $matches)
) {
return [];
}
Expand All @@ -65,7 +65,7 @@ function ($path): array {
)
);

uasort($files, [$this, 'compareFiles']);
uasort($files, $this->compareFiles(...));

$destinations = [];
foreach ($files as $file) {
Expand Down
Loading

0 comments on commit 2f50dde

Please sign in to comment.