Compare commits

..

7 Commits

Author SHA1 Message Date
Lio Novelli 519c0b074a WIP work on youtrack rest api plugin. 2023-07-16 13:34:51 +02:00
Lio Novelli 4e3477c4a0 Add entity type management system. 2023-01-10 10:42:36 +01:00
Lio Novelli bbb22ab502 Work on code style. 2023-01-02 22:03:59 +01:00
Lio Novelli 99d16c3a72 Fix phpstan errors, improve automated test. 2023-01-02 20:35:41 +01:00
Lio Novelli 624b895fd6 Fix coding standard. 2023-01-02 15:18:52 +01:00
Lio Novelli ff2e35bb93 Add tests, unify input. 2023-01-01 23:51:59 +01:00
Lio Novelli 4dcbcb228a Install code sniffer and run code beautifier. 2022-12-20 23:36:07 +01:00
58 changed files with 2749 additions and 691 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/scratch
.phpcs-cache
*~undo-tree~
/app/tests/data/output

View File

@ -2,7 +2,7 @@
Automate generating invoices from youtrack reports and other time-tracking
related functionality.
** Usage
~./rprt.php invoice -y -p -s~
@ -14,15 +14,14 @@
Asks which report to print from the list of your reports and then prints out
a table with that report.
** Install/Getting started
Get ~.phar~ file from r, run configuration wizzard (planned for version 1.0).
Get ~.phar~ file from r, Run configruration wizzard (planned for version 1.0).
Before version 1.0 is released you have to navigate into ~/app~ directory
and call command through ~.rprt.php~ file.
*** Requirements
1. You have to create a youtrack API token.
@ -45,7 +44,6 @@
- project categories
- hourly wage
- folder for reports
** Components
- report service - provides a csv of a report
@ -61,7 +59,7 @@
*** ValueObjects
*** List my reports
#+begin_example bash
@ -76,21 +74,39 @@ curl 'https://drunomics.myjetbrains.com/youtrack/api/reports?$top=-1&fields=id,n
I'd be using this app. If it get's picked up, by 5 others - it is worth
5 days of development.
- remove errors from reports
* Support the work
If you find this Free Software useful you can consider donating to my
[[https://liberapay.com/tehnoklistir/][@tehno-klistir liberapay account.]]
* Development
** Testing
Main source at symfony [[https://symfony.com/doc/current/console.html#testing-commands][console command page]]. If you read thouroughly:
When using the Console component in a standalone project, use Application and
extend the normal \PHPUnit\Framework\TestCase.
** Plan
*** most current
1. For version 0.6.7
- [X] data value objects
- phar file
- [X] phar file
- [X] additional expenses
2. For version 1.0
- plugin system
- for time tracking services
- for reports
- symfony/config & symfony/di components
3. Time tracking service
- youtrack-api
- jira-api
- kimai (https://www.kimai.org/documentation/timesheet.html)
*** current
*** current
1. For Version 1.0
- Track Command (track time from your cli)
@ -106,7 +122,7 @@ curl 'https://drunomics.myjetbrains.com/youtrack/api/reports?$top=-1&fields=id,n
- Add tests
*** old
*** old
1. Basic structure of the cli-app
1. App preparation
- nice specifications
@ -124,7 +140,6 @@ curl 'https://drunomics.myjetbrains.com/youtrack/api/reports?$top=-1&fields=id,n
3. Second round of enhancements
1. Invoice output
2. configuration wizard
** Learning
@ -134,8 +149,8 @@ curl 'https://drunomics.myjetbrains.com/youtrack/api/reports?$top=-1&fields=id,n
** API calls
*** Get csv file
~curl 'https://drunomics.myjetbrains.com/youtrack/api/reports/83-554/export/csv?&$top=-1' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H "Authorization: Bearer $TKN" > ~/Documents/Drunomics/workhours/2021/21-09.csv~

View File

@ -15,25 +15,37 @@
],
"require": {
"symfony/console": "^5.2",
"guzzlehttp/guzzle": "^7.3",
"guzzlehttp/guzzle": "^6.2",
"php-di/php-di": "^6.3",
"symfony/yaml": "^5.2",
"mpdf/mpdf": "^8.0",
"symfony/mailer": "^5.3",
"symfony/google-mailer": "^5.3"
"symfony/google-mailer": "^5.3",
"cybercog/youtrack-rest-php": "^7.0",
"symfony/finder": "^6.2"
},
"autoload": {
"psr-4": {
"RprtCli\\": "src"
"RprtCli\\": ["src", "tests"]
}
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",
"squizlabs/php_codesniffer": "^3.7",
"phpunit/phpunit": "^9.5",
"opsway/psr12-strict-coding-standard": "^0.5.0"
"opsway/psr12-strict-coding-standard": "^1.0",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^1.9",
"psy/psysh": "^0.11.10"
},
"scripts": {
"cs": "phpcs",
"cbf": "phpcbf"
}
"cs": "vendor/bin/phpcs --colors",
"cbf": "vendor/bin/phpcbf",
"phpstan": "vendor/bin/phpstan analyze -l 5 src"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"minimum-stability": "alpha"
}

747
app/composer.lock generated
View File

@ -4,8 +4,88 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "81050635de2f87c3f7f693ec8cb30645",
"content-hash": "ca5a759d17cf48faeda14bdaab8f4985",
"packages": [
{
"name": "cybercog/youtrack-rest-php",
"version": "7.0.0",
"source": {
"type": "git",
"url": "https://github.com/cybercog/youtrack-rest-php.git",
"reference": "eb0315133d1d3d161da23d26537201afb253dec9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cybercog/youtrack-rest-php/zipball/eb0315133d1d3d161da23d26537201afb253dec9",
"reference": "eb0315133d1d3d161da23d26537201afb253dec9",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/guzzle": "^6.2",
"php": "^7.1|^8.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"phpstan/phpstan": "^0.12.32",
"phpunit/phpunit": "^7.0|^8.0|^9.0"
},
"suggest": {
"cybercog/laravel-youtrack-sdk": "Laravel integration with PHP YouTrack SDK.",
"cybercog/youtrack-php-sdk": "PHP YouTrack SDK."
},
"type": "library",
"autoload": {
"psr-4": {
"Cog\\YouTrack\\Rest\\": "src/",
"Cog\\Contracts\\YouTrack\\Rest\\": "contracts/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anton Komarev",
"email": "anton@komarev.com",
"homepage": "https://komarev.com",
"role": "Developer"
}
],
"description": "YouTrack REST API PHP Client.",
"homepage": "https://komarev.com/sources/php-youtrack-rest",
"keywords": [
"api",
"bugtracker",
"client",
"cog",
"cybercog",
"helpdesk",
"issues",
"jetbrains",
"laravel",
"pm",
"rest",
"tickets",
"youtrack",
"yt"
],
"support": {
"docs": "https://github.com/cybercog/youtrack-rest-php/wiki",
"email": "open@cybercog.su",
"issues": "https://github.com/cybercog/youtrack-rest-php/issues",
"source": "https://github.com/cybercog/youtrack-rest-php",
"wiki": "https://github.com/cybercog/youtrack-rest-php/wiki"
},
"funding": [
{
"url": "https://paypal.me/antonkomarev",
"type": "custom"
}
],
"time": "2022-10-02T18:52:01+00:00"
},
{
"name": "doctrine/lexer",
"version": "1.2.1",
@ -156,68 +236,86 @@
},
{
"name": "guzzlehttp/guzzle",
"version": "7.3.0",
"version": "6.5.7",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "7008573787b430c1c1f650e3722d9bba59967628"
"reference": "724562fa861e21a4071c652c8a159934e4f05592"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628",
"reference": "7008573787b430c1c1f650e3722d9bba59967628",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/724562fa861e21a4071c652c8a159934e4f05592",
"reference": "724562fa861e21a4071c652c8a159934e4f05592",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/promises": "^1.4",
"guzzlehttp/psr7": "^1.7 || ^2.0",
"php": "^7.2.5 || ^8.0",
"psr/http-client": "^1.0"
},
"provide": {
"psr/http-client-implementation": "1.0"
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.6.1",
"php": ">=5.5",
"symfony/polyfill-intl-idn": "^1.17.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4.1",
"ext-curl": "*",
"php-http/client-integration-tests": "^3.0",
"phpunit/phpunit": "^8.5.5 || ^9.3.5",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
"psr/log": "^1.1"
},
"suggest": {
"ext-curl": "Required for CURL handler support",
"ext-intl": "Required for Internationalized Domain Name (IDN) support",
"psr/log": "Required for using the Log middleware"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "7.3-dev"
"dev-master": "6.5-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
},
"files": [
"src/functions_include.php"
]
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Jeremy Lindblom",
"email": "jeremeamia@gmail.com",
"homepage": "https://github.com/jeremeamia"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https://github.com/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://sagikazarmark.hu"
"homepage": "https://github.com/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle is a PHP HTTP client library",
@ -228,12 +326,28 @@
"framework",
"http",
"http client",
"psr-18",
"psr-7",
"rest",
"web service"
],
"time": "2021-03-23T11:33:13+00:00"
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
"source": "https://github.com/guzzle/guzzle/tree/6.5.7"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
"type": "tidelift"
}
],
"time": "2022-06-09T21:36:50+00:00"
},
{
"name": "guzzlehttp/promises",
@ -901,55 +1015,6 @@
},
"time": "2019-01-08T18:20:26+00:00"
},
{
"name": "psr/http-client",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-client.git",
"reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
"reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0",
"psr/http-message": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP clients",
"homepage": "https://github.com/php-fig/http-client",
"keywords": [
"http",
"http-client",
"psr",
"psr-18"
],
"time": "2020-06-29T06:28:15+00:00"
},
{
"name": "psr/http-message",
"version": "1.0.1",
@ -1495,6 +1560,70 @@
],
"time": "2021-03-23T23:28:01+00:00"
},
{
"name": "symfony/finder",
"version": "v6.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "81eefbddfde282ee33b437ba5e13d7753211ae8e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/81eefbddfde282ee33b437ba5e13d7753211ae8e",
"reference": "81eefbddfde282ee33b437ba5e13d7753211ae8e",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"require-dev": {
"symfony/filesystem": "^6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Finder\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v6.2.3"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-12-22T17:55:15+00:00"
},
{
"name": "symfony/google-mailer",
"version": "v5.3.0",
@ -2603,27 +2732,27 @@
"packages-dev": [
{
"name": "dealerdirect/phpcodesniffer-composer-installer",
"version": "v0.7.1",
"version": "v0.7.2",
"source": {
"type": "git",
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
"reference": "fe390591e0241955f22eb9ba327d137e501c771c"
"reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c",
"reference": "fe390591e0241955f22eb9ba327d137e501c771c",
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db",
"reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0 || ^2.0",
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0"
"squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
},
"require-dev": {
"composer/composer": "*",
"phpcompatibility/php-compatibility": "^9.0",
"sensiolabs/security-checker": "^4.1.0"
"php-parallel-lint/php-parallel-lint": "^1.3.1",
"phpcompatibility/php-compatibility": "^9.0"
},
"type": "composer-plugin",
"extra": {
@ -2644,6 +2773,10 @@
"email": "franck.nijhof@dealerdirect.com",
"homepage": "http://www.frenck.nl",
"role": "Developer / IT Manager"
},
{
"name": "Contributors",
"homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors"
}
],
"description": "PHP_CodeSniffer Standards Composer Installer Plugin",
@ -2655,6 +2788,7 @@
"codesniffer",
"composer",
"installer",
"phpcbf",
"phpcs",
"plugin",
"qa",
@ -2665,7 +2799,11 @@
"stylecheck",
"tests"
],
"time": "2020-12-07T18:04:37+00:00"
"support": {
"issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues",
"source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer"
},
"time": "2022-02-04T12:51:07+00:00"
},
{
"name": "doctrine/instantiator",
@ -2795,30 +2933,29 @@
},
{
"name": "opsway/psr12-strict-coding-standard",
"version": "0.5.0",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/opsway/psr12-strict-modern-standart.git",
"reference": "495d5109079f544ec46ec2f0e2161d48f62a6335"
"reference": "2ce8d92f35ed3c229b1da2668c7c02c490af95f4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opsway/psr12-strict-modern-standart/zipball/495d5109079f544ec46ec2f0e2161d48f62a6335",
"reference": "495d5109079f544ec46ec2f0e2161d48f62a6335",
"url": "https://api.github.com/repos/opsway/psr12-strict-modern-standart/zipball/2ce8d92f35ed3c229b1da2668c7c02c490af95f4",
"reference": "2ce8d92f35ed3c229b1da2668c7c02c490af95f4",
"shasum": ""
},
"require": {
"dealerdirect/phpcodesniffer-composer-installer": "~0.6",
"php": "^7.3 || ^8.0",
"slevomat/coding-standard": "^6.1",
"squizlabs/php_codesniffer": "^3.5",
"webimpress/coding-standard": "^1.1"
"dealerdirect/phpcodesniffer-composer-installer": "~0.7",
"php": "^8.0",
"slevomat/coding-standard": "^7.0 || ^8.0",
"squizlabs/php_codesniffer": "^3.6 || ^4.0",
"webimpress/coding-standard": "^1.2"
},
"type": "phpcodesniffer-standard",
"extra": {
"branch-alias": {
"dev-master": "0.0.x-dev",
"dev-develop": "1.0.x-dev"
"dev-develop": "2.0.x-dev"
}
},
"autoload": {
@ -2836,7 +2973,13 @@
"opsway",
"psr12-strict"
],
"time": "2021-01-01T11:19:18+00:00"
"support": {
"docs": "https://github.com/opsway/psr12-strict-modern-standart/tree/master/docs",
"issues": "https://github.com/opsway/psr12-strict-modern-standart/issues",
"rss": "https://github.com/opsway/psr12-strict-modern-standart/releases.atom",
"source": "https://github.com/opsway/psr12-strict-modern-standart"
},
"time": "2022-10-22T12:21:38+00:00"
},
{
"name": "phar-io/manifest",
@ -2949,6 +3092,68 @@
},
"time": "2022-02-21T01:04:05+00:00"
},
{
"name": "phpcompatibility/php-compatibility",
"version": "9.3.5",
"source": {
"type": "git",
"url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
"reference": "9fb324479acf6f39452e0655d2429cc0d3914243"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243",
"reference": "9fb324479acf6f39452e0655d2429cc0d3914243",
"shasum": ""
},
"require": {
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.3 || ^3.0.2"
},
"conflict": {
"squizlabs/php_codesniffer": "2.6.2"
},
"require-dev": {
"phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-or-later"
],
"authors": [
{
"name": "Wim Godden",
"homepage": "https://github.com/wimg",
"role": "lead"
},
{
"name": "Juliette Reinders Folmer",
"homepage": "https://github.com/jrfnl",
"role": "lead"
},
{
"name": "Contributors",
"homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
}
],
"description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
"homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
"keywords": [
"compatibility",
"phpcs",
"standards"
],
"support": {
"issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues",
"source": "https://github.com/PHPCompatibility/PHPCompatibility"
},
"time": "2019-12-27T09:44:58+00:00"
},
{
"name": "phpdocumentor/reflection-common",
"version": "2.2.0",
@ -3178,39 +3383,31 @@
},
{
"name": "phpstan/phpdoc-parser",
"version": "0.4.9",
"version": "1.15.3",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531"
"reference": "61800f71a5526081d1b5633766aa88341f1ade76"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/98a088b17966bdf6ee25c8a4b634df313d8aa531",
"reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/61800f71a5526081d1b5633766aa88341f1ade76",
"reference": "61800f71a5526081d1b5633766aa88341f1ade76",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
"php": "^7.2 || ^8.0"
},
"require-dev": {
"consistence/coding-standard": "^3.5",
"ergebnis/composer-normalize": "^2.0.2",
"jakub-onderka/php-parallel-lint": "^0.9.2",
"phing/phing": "^2.16.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.26",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^6.3",
"slevomat/coding-standard": "^4.7.2",
"symfony/process": "^4.0"
"phpstan/phpstan": "^1.5",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5",
"symfony/process": "^5.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.4-dev"
}
},
"autoload": {
"psr-4": {
"PHPStan\\PhpDocParser\\": [
@ -3223,7 +3420,70 @@
"MIT"
],
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"time": "2020-08-03T20:32:43+00:00"
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.15.3"
},
"time": "2022-12-20T20:56:55+00:00"
},
{
"name": "phpstan/phpstan",
"version": "1.9.4",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "d03bccee595e2146b7c9d174486b84f4dc61b0f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/d03bccee595e2146b7c9d174486b84f4dc61b0f2",
"reference": "d03bccee595e2146b7c9d174486b84f4dc61b0f2",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"keywords": [
"dev",
"static analysis"
],
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.9.4"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://github.com/phpstan",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
"type": "tidelift"
}
],
"time": "2022-12-17T13:33:52+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -3646,6 +3906,82 @@
],
"time": "2022-04-01T12:37:26+00:00"
},
{
"name": "psy/psysh",
"version": "v0.11.10",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/psysh.git",
"reference": "e9eadffbed9c9deb5426fd107faae0452bf20a36"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/e9eadffbed9c9deb5426fd107faae0452bf20a36",
"reference": "e9eadffbed9c9deb5426fd107faae0452bf20a36",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-tokenizer": "*",
"nikic/php-parser": "^4.0 || ^3.1",
"php": "^8.0 || ^7.0.8",
"symfony/console": "^6.0 || ^5.0 || ^4.0 || ^3.4",
"symfony/var-dumper": "^6.0 || ^5.0 || ^4.0 || ^3.4"
},
"conflict": {
"symfony/console": "4.4.37 || 5.3.14 || 5.3.15 || 5.4.3 || 5.4.4 || 6.0.3 || 6.0.4"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.2"
},
"suggest": {
"ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)",
"ext-pdo-sqlite": "The doc command requires SQLite to work.",
"ext-posix": "If you have PCNTL, you'll want the POSIX extension as well.",
"ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history."
},
"bin": [
"bin/psysh"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "0.11.x-dev"
}
},
"autoload": {
"files": [
"src/functions.php"
],
"psr-4": {
"Psy\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Justin Hileman",
"email": "justin@justinhileman.info",
"homepage": "http://justinhileman.com"
}
],
"description": "An interactive shell for modern PHP.",
"homepage": "http://psysh.org",
"keywords": [
"REPL",
"console",
"interactive",
"shell"
],
"support": {
"issues": "https://github.com/bobthecow/psysh/issues",
"source": "https://github.com/bobthecow/psysh/tree/v0.11.10"
},
"time": "2022-12-23T17:47:18+00:00"
},
{
"name": "sebastian/cli-parser",
"version": "1.0.1",
@ -4612,37 +4948,37 @@
},
{
"name": "slevomat/coding-standard",
"version": "6.4.1",
"version": "8.7.1",
"source": {
"type": "git",
"url": "https://github.com/slevomat/coding-standard.git",
"reference": "696dcca217d0c9da2c40d02731526c1e25b65346"
"reference": "c51edb898bebd36aac70a190c6a41a7c056bb5b9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/696dcca217d0c9da2c40d02731526c1e25b65346",
"reference": "696dcca217d0c9da2c40d02731526c1e25b65346",
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/c51edb898bebd36aac70a190c6a41a7c056bb5b9",
"reference": "c51edb898bebd36aac70a190c6a41a7c056bb5b9",
"shasum": ""
},
"require": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7",
"php": "^7.1 || ^8.0",
"phpstan/phpdoc-parser": "0.4.5 - 0.4.9",
"squizlabs/php_codesniffer": "^3.5.6"
"php": "^7.2 || ^8.0",
"phpstan/phpdoc-parser": ">=1.15.0 <1.16.0",
"squizlabs/php_codesniffer": "^3.7.1"
},
"require-dev": {
"phing/phing": "2.16.3",
"php-parallel-lint/php-parallel-lint": "1.2.0",
"phpstan/phpstan": "0.12.48",
"phpstan/phpstan-deprecation-rules": "0.12.5",
"phpstan/phpstan-phpunit": "0.12.16",
"phpstan/phpstan-strict-rules": "0.12.5",
"phpunit/phpunit": "7.5.20|8.5.5|9.4.0"
"phing/phing": "2.17.4",
"php-parallel-lint/php-parallel-lint": "1.3.2",
"phpstan/phpstan": "1.4.10|1.9.3",
"phpstan/phpstan-deprecation-rules": "1.1.0",
"phpstan/phpstan-phpunit": "1.0.0|1.3.1",
"phpstan/phpstan-strict-rules": "1.4.4",
"phpunit/phpunit": "7.5.20|8.5.21|9.5.27"
},
"type": "phpcodesniffer-standard",
"extra": {
"branch-alias": {
"dev-master": "6.x-dev"
"dev-master": "8.x-dev"
}
},
"autoload": {
@ -4655,20 +4991,38 @@
"MIT"
],
"description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.",
"time": "2020-10-05T12:39:37+00:00"
"keywords": [
"dev",
"phpcs"
],
"support": {
"issues": "https://github.com/slevomat/coding-standard/issues",
"source": "https://github.com/slevomat/coding-standard/tree/8.7.1"
},
"funding": [
{
"url": "https://github.com/kukulich",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard",
"type": "tidelift"
}
],
"time": "2022-12-14T08:49:18+00:00"
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.5.8",
"version": "3.7.1",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4"
"reference": "1359e176e9307e906dc3d890bcc9603ff6d90619"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4",
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619",
"reference": "1359e176e9307e906dc3d890bcc9603ff6d90619",
"shasum": ""
},
"require": {
@ -4706,7 +5060,100 @@
"phpcs",
"standards"
],
"time": "2020-10-23T02:01:07+00:00"
"support": {
"issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
},
"time": "2022-06-18T07:21:10+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v6.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "fdbadd4803bc3c96ef89238c9c9e2ebe424ec2e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/fdbadd4803bc3c96ef89238c9c9e2ebe424ec2e0",
"reference": "fdbadd4803bc3c96ef89238c9c9e2ebe424ec2e0",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"phpunit/phpunit": "<5.4.3",
"symfony/console": "<5.4"
},
"require-dev": {
"ext-iconv": "*",
"symfony/console": "^5.4|^6.0",
"symfony/process": "^5.4|^6.0",
"symfony/uid": "^5.4|^6.0",
"twig/twig": "^2.13|^3.0.4"
},
"suggest": {
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
"ext-intl": "To show region name in time zone dump",
"symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script"
},
"bin": [
"Resources/bin/var-dump-server"
],
"type": "library",
"autoload": {
"files": [
"Resources/functions/dump.php"
],
"psr-4": {
"Symfony\\Component\\VarDumper\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides mechanisms for walking through any arbitrary PHP variable",
"homepage": "https://symfony.com",
"keywords": [
"debug",
"dump"
],
"support": {
"source": "https://github.com/symfony/var-dumper/tree/v6.2.3"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-12-22T17:55:15+00:00"
},
{
"name": "theseer/tokenizer",
@ -4760,24 +5207,24 @@
},
{
"name": "webimpress/coding-standard",
"version": "1.2.1",
"version": "1.2.4",
"source": {
"type": "git",
"url": "https://github.com/webimpress/coding-standard.git",
"reference": "fbeb31ee876b3c493779d3aa717ebb57ef258e6a"
"reference": "cd0c4b0b97440c337c1f7da17b524674ca2f9ca9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webimpress/coding-standard/zipball/fbeb31ee876b3c493779d3aa717ebb57ef258e6a",
"reference": "fbeb31ee876b3c493779d3aa717ebb57ef258e6a",
"url": "https://api.github.com/repos/webimpress/coding-standard/zipball/cd0c4b0b97440c337c1f7da17b524674ca2f9ca9",
"reference": "cd0c4b0b97440c337c1f7da17b524674ca2f9ca9",
"shasum": ""
},
"require": {
"php": "^7.3 || ^8.0",
"squizlabs/php_codesniffer": "^3.5.8"
"squizlabs/php_codesniffer": "^3.6.2"
},
"require-dev": {
"phpunit/phpunit": "^9.4.3"
"phpunit/phpunit": "^9.5.13"
},
"type": "phpcodesniffer-standard",
"extra": {
@ -4801,7 +5248,17 @@
"psr-12",
"webimpress"
],
"time": "2021-01-11T18:13:55+00:00"
"support": {
"issues": "https://github.com/webimpress/coding-standard/issues",
"source": "https://github.com/webimpress/coding-standard/tree/1.2.4"
},
"funding": [
{
"url": "https://github.com/michalbundyra",
"type": "github"
}
],
"time": "2022-02-15T19:52:12+00:00"
},
{
"name": "webmozart/assert",
@ -4863,11 +5320,11 @@
}
],
"aliases": [],
"minimum-stability": "stable",
"minimum-stability": "alpha",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.1.0"
"plugin-api-version": "2.3.0"
}

View File

@ -1,5 +1,6 @@
<?php
use RprtCli\Utils\TimeTrackingServices\YoutrackRestApi\YoutrackRestApiClient;
use function DI\create;
use function DI\get;
use function DI\factory;
@ -20,6 +21,8 @@ use RprtCli\Utils\PdfExport\PdfExportService;
use RprtCli\Utils\TimeTrackingServices\YoutrackInterface;
use RprtCli\Utils\TimeTrackingServices\YoutrackService;
use Psr\Container\ContainerInterface;
use Symfony\Component\Finder\Finder;
use RprtCli\Utils\TimeTrackingServices\YoutrackRestApi\EntityManager;
# use Symfony\Component\Translation\Translator;
#use Symfony\Component\Translation\Loader\PoFileLoader;
@ -38,9 +41,9 @@ return [
'mpdf' => factory(function (ContainerInterface $c) {
return new Mpdf(['tempDir' => sys_get_temp_dir()]);
}),
// 'mpdf' => function () {
// return new Mpdf(['tempDir' => sys_get_temp_dir()]);
// },
'finder' => factory(function (ContainerInterface $c) {
return new Finder();
}),
ConfigurationInterface::class => get(ConfigurationService::class),
ConfigurationService::class => create()->constructor(
get('config.path'),
@ -58,6 +61,8 @@ return [
get('config.service'),
get('mpdf')
),
YoutrackRestApiClient::class => create()->constructor(get('config.service')),
'youtrack_rest_api.client' => get(YoutrackRestApiClient::class),
'pdf_export.service' => get(PdfExportInterface::class),
// 'locale' => get('config.service')->method('get', 'en'),
// Translator::class => create()->constructor('sl')->method('addLoader', 'po', new PoFileLoader),
@ -73,6 +78,10 @@ return [
get('pdf_export.service')
),
'mailer' => get(MailerInterface::class),
EntityManager::class => create()->constructor(
get('finder')
),
'youtrack.entity_manager' => get(EntityManager::class),
InvoiceCommand::class => create()->constructor(
get('csv.report'),
get('config.service'),

View File

@ -12,9 +12,14 @@
<arg value="p"/>
<!-- Paths to check -->
<file>tests</file>
<file>src</file>
<file>test</file>
<!-- Include all rules from the Zend Coding Standard -->
<rule ref="OpsWayStrictPSR12CodingStandard"/>
<!-- rule ref="OpsWayStrictPSR12CodingStandard"> -->
<rule ref="PSR12">
<exclude name="Generic.NamingConventions.CamelCapsVariableName.Invalid" />
<exclude name="Squiz.NamingConventions.ValidVariableName" />
<!-- <exclude name="WebimpressCodingStandard.NamingConventions.ValidVariableName" /> -->
</rule>
</ruleset>

View File

@ -9,6 +9,7 @@ use DI\ContainerBuilder;
require __DIR__ . '/vendor/autoload.php';
$builder = new ContainerBuilder();
$builder->addDefinitions(__DIR__ . '/dependencies.php');
$container = $builder->build();
@ -19,4 +20,6 @@ $application->add($invoiceCommand);
$reportCommand = $container->get(ReportCommand::class);
$application->add($reportCommand);
// eval(\Psy\sh());
$application->run();

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
// src/Commands/InvoiceCommand.php;
namespace RprtCli\Commands;
use RprtCli\Utils\Configuration\ConfigurationInterface;
use Symfony\Component\Console\Command\Command;
// use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Abstract class that adds some common services and input options.
*/
class AbstractCliCommand extends Command
{
protected $configuration;
// @TODO Add service factory service.
// protected $trackingServiceFactory;
/**
* Dependency inversion.
*/
public function __construct(
ConfigurationInterface $configuration,
?string $name = null
) {
$this->configuration = $configuration;
parent::__construct($name);
}
}

View File

@ -6,6 +6,7 @@ declare(strict_types=1);
namespace RprtCli\Commands;
use Exception;
use RprtCli\Utils\Configuration\ConfigurationInterface;
use RprtCli\Utils\CsvReport\ReportCsvInterface;
use RprtCli\Utils\Mailer\MailerInterface;
@ -15,44 +16,62 @@ use RprtCli\ValueObjects\Expenses;
use RprtCli\ValueObjects\WorkInvoiceElement;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Helper\TableCell;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
// use Symfony\Contracts\Translation\TranslatorInterface;
use function array_merge;
use function explode;
use function is_array;
use function is_null;
use function is_string;
use function readline;
use function strpos;
use function strtolower;
use function sys_get_temp_dir;
use function var_dump;
use function var_export;
// use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Main file - invoice command.
*/
class InvoiceCommand extends Command
{
protected $csv;
use SelectReportTrait;
protected $configuration;
protected ReportCsvInterface $csv;
protected $youtrack;
protected ConfigurationInterface $config;
protected $pdfExport;
protected YoutrackInterface $trackingService;
const TYPE_WORK = 1;
const TYPE_EXPENSE = 2;
protected PdfExportInterface $pdfExport;
/**
* Mailer service.
*/
protected MailerInterface $mailer;
protected const TYPE_WORK = 1;
protected const TYPE_EXPENSE = 2;
public function __construct(
ReportCsvInterface $csv,
ConfigurationInterface $configuration,
YoutrackInterface $youtrack,
YoutrackInterface $trackingService,
PdfExportInterface $pdf_export,
MailerInterface $mailer,
?string $name = null
) {
$this->csv = $csv;
$this->configuration = $configuration;
$this->youtrack = $youtrack;
$this->pdfExport = $pdf_export;
$this->mailer = $mailer;
$this->csv = $csv;
$this->config = $configuration;
$this->trackingService = $trackingService;
$this->pdfExport = $pdf_export;
$this->mailer = $mailer;
parent::__construct($name);
}
@ -71,12 +90,12 @@ class InvoiceCommand extends Command
InputOption::VALUE_REQUIRED,
'Specify the input csv file to generate report from.'
);
$this->addOption(
'youtrack',
'y',
InputOption::VALUE_NONE,
'Use youtrack api to get a report. If this option is used --file does not have any effect..'
);
// $this->addOption(
// 'youtrack',
// 'y',
// InputOption::VALUE_NONE,
// 'Use youtrack api to get a report. If this option is used --file does not have any effect..'
// );
$this->addOption(
'pdf',
'p',
@ -111,15 +130,17 @@ class InvoiceCommand extends Command
'expenses',
'e',
InputOption::VALUE_OPTIONAL,
// phpcs:ignore
'List of additional expenses in format expense1=value1;expenses2=value2... or empty for interactive output.',
FALSE
false
);
$this->addOption(
'custom',
'c',
InputOption::VALUE_OPTIONAL,
// phpcs:ignore
'Additional custom work untracked in format: name1=time1;name2=time2... Project to assign work items to has to be configured in app config. Leave empty for interactive output.',
FALSE
false
);
$this->addOption(
'list-reports',
@ -132,81 +153,52 @@ class InvoiceCommand extends Command
'r',
InputOption::VALUE_OPTIONAL,
'Show time tracked for report.',
FALSE
false
);
}
protected function execute(InputInterface $input, OutputInterface $output) : int
{
if ($input->getOption('test')) {
$test = $this->youtrack->testYoutrackapi();
$test = $this->trackingService->testYoutrackapi();
$output->writeln($test);
}
if ($input->getOption('list-reports')) {
$list = $this->youtrack->listReports();
$output->writeln(var_export($list, TRUE));
$list = $this->trackingService->listReports();
$output->writeln(var_export($list, true));
return Command::SUCCESS;
}
if ($input->hasParameterOption('--report') || $input->hasParameterOption('-r')) {
if ($report = $input->getOption('report')) {
$this->youtrack->setReportId($report);
}
else {
$reports = $this->youtrack->listReports();
$count = 1;
foreach ($reports as $id => $name) {
$output->writeln("[{$count}] {$name} ({$id})");
$count++;
}
$report = readline('Select id of the report: ');
// Asume people are literate.
$this->youtrack->setReportId($report);
}
if ($output->isVerbose()) {
$output->writeln("Setting report: <info>{$report}</info>.");
}
}
if ($youtrack = $input->getOption('youtrack')) {
$report_id = $this->youtrack->getReportId();
$cache_clear_status = $this->youtrack->clearReportCache($report_id);
if ($output->isVerbose()) {
$output->writeln("Report <info>{$report_id}</info> cache cleared, status: {$cache_clear_status}");
}
$file = $this->youtrack->downloadReport($report_id);
}
// Gets report parameter.
$file = $this->getReportCsvFilePath($input, $output, 'tracking_service.youtrack.invoice.report');
$report_name = $this->trackingService->getReportName();
if ($input->hasParameterOption('--expenses') || $input->hasParameterOption('-e')) {
$expenses = $this->getCustomWorkOrExpenses($input->getOption('expenses'), self::TYPE_EXPENSE);
}
if ($input->hasParameterOption('--custom') || $input->hasParameterOption('-c')) {
// @TODO Add option for custom time tracking data.
$custom = $this->getCustomWorkOrExpenses($input->getOption('custom'), self::TYPE_WORK);
}
if ($youtrack || $file = $input->getOption('file')) {
// Youtrack can also provide a file name.
if ($output->isVerbose()) {
$output->writeln("Csv file downloaded to: <info>{$file}</info>");
}
$data = $this->csv->getInvoiceData($file);
if (!empty($expenses)) {
$data = array_merge($data, $expenses);
}
// $table = $this->generateTable($output, $data);
$table = $this->getTable($output, $data);
$table->render();
if ($input->getOption('pdf')) {
$nice_data = $this->csv->arangeDataForDefaultPdfExport($data);
// @TODO method gatherTokens();
if ($out = $input->getOption('output')) {
$this->pdfExport->setOutput($out);
}
$output_path = $this->pdfExport->fromDefaultDataToPdf($nice_data);
// Notify the user where the file was generated to.
$output->writeln("The file was generated at <info>${output_path}</info>.");
}
// return Command::SUCCESS;
$output->writeln("report: <info>{$report_name}</info>");
$data = $this->csv->getInvoiceData($file);
if (!empty($expenses)) {
$data = array_merge($data, $expenses);
}
if ($input->getOption('send') && $output_path) {
if (!empty($custom)) {
$data = array_merge($data, $custom);
}
$table = $this->getTable($output, $data);
$table->render();
if ($input->getOption('pdf')) {
$nice_data = $this->csv->arangeDataForDefaultPdfExport($data);
// @TODO method gatherTokens();
if ($out = $input->getOption('output')) {
$this->pdfExport->setOutput($out);
}
$output_path = $this->pdfExport->fromDefaultDataToPdf($nice_data) ?: sys_get_temp_dir();
// Notify the user where the file was generated to.
$output->writeln("The file was generated at <info>${output_path}</info>.");
}
if ($input->getOption('send') && isset($output_path)) {
// @TODO If no output path print an error.
// Send email to configured address.
if ($recipients = $input->getOption('recipients')) {
@ -219,17 +211,20 @@ class InvoiceCommand extends Command
return Command::SUCCESS;
}
protected function getTable(OutputInterface $output,