Compare commits
2 Commits
e5dad3f2d6
...
9ee4a8c290
Author | SHA1 | Date | |
---|---|---|---|
9ee4a8c290 | |||
2bf9345f69 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,7 @@
|
|||||||
/.idea
|
/.idea
|
||||||
/.vscode
|
/.vscode
|
||||||
/vendor
|
/vendor
|
||||||
|
/nbproject
|
||||||
|
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
.phpunit.cache
|
.phpunit.cache
|
||||||
|
@ -70,7 +70,7 @@ Possible ARGUMENTS:
|
|||||||
-p, --preserve - do not delete OUTPUT_PATH (if exists)
|
-p, --preserve - do not delete OUTPUT_PATH (if exists)
|
||||||
--dump - convert provided arguments into settings file in `pwd`
|
--dump - convert provided arguments into settings file in `pwd`
|
||||||
-h, --help - show this help message and exit
|
-h, --help - show this help message and exit
|
||||||
-v, --version - show version info and exit
|
--version - show version info and exit
|
||||||
|
|
||||||
If no ARGUMENTS passed then --help implied.
|
If no ARGUMENTS passed then --help implied.
|
||||||
If both -f and -d are specified then only unique set of files from both arguments will be converted.
|
If both -f and -d are specified then only unique set of files from both arguments will be converted.
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
],
|
],
|
||||||
"keywords": ["postman", "collection", "converter", "http", "wget", "curl", "api", "convert"],
|
"keywords": ["postman", "collection", "converter", "http", "wget", "curl", "api", "convert"],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1",
|
"php": "^8.2",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"ext-readline": "*"
|
"ext-readline": "*"
|
||||||
|
269
composer.lock
generated
269
composer.lock
generated
@ -4,21 +4,21 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "7d1dfd3f8475dd697f5d4bdab92776a2",
|
"content-hash": "d11deb8a29c512e733d7b130e0943d96",
|
||||||
"packages": [],
|
"packages": [],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
"name": "myclabs/deep-copy",
|
"name": "myclabs/deep-copy",
|
||||||
"version": "1.11.1",
|
"version": "1.12.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/myclabs/DeepCopy.git",
|
"url": "https://github.com/myclabs/DeepCopy.git",
|
||||||
"reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c"
|
"reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
|
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c",
|
||||||
"reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
|
"reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -26,11 +26,12 @@
|
|||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"doctrine/collections": "<1.6.8",
|
"doctrine/collections": "<1.6.8",
|
||||||
"doctrine/common": "<2.13.3 || >=3,<3.2.2"
|
"doctrine/common": "<2.13.3 || >=3 <3.2.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"doctrine/collections": "^1.6.8",
|
"doctrine/collections": "^1.6.8",
|
||||||
"doctrine/common": "^2.13.3 || ^3.2.2",
|
"doctrine/common": "^2.13.3 || ^3.2.2",
|
||||||
|
"phpspec/prophecy": "^1.10",
|
||||||
"phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
|
"phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
@ -56,7 +57,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/myclabs/DeepCopy/issues",
|
"issues": "https://github.com/myclabs/DeepCopy/issues",
|
||||||
"source": "https://github.com/myclabs/DeepCopy/tree/1.11.1"
|
"source": "https://github.com/myclabs/DeepCopy/tree/1.12.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -64,29 +65,31 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-03-08T13:26:56+00:00"
|
"time": "2024-06-12T14:39:25+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "nikic/php-parser",
|
"name": "nikic/php-parser",
|
||||||
"version": "v4.17.1",
|
"version": "v5.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||||
"reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d"
|
"reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d",
|
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/683130c2ff8c2739f4822ff7ac5c873ec529abd1",
|
||||||
"reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d",
|
"reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
"ext-ctype": "*",
|
||||||
|
"ext-json": "*",
|
||||||
"ext-tokenizer": "*",
|
"ext-tokenizer": "*",
|
||||||
"php": ">=7.0"
|
"php": ">=7.4"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ircmaxell/php-yacc": "^0.0.7",
|
"ircmaxell/php-yacc": "^0.0.7",
|
||||||
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
|
"phpunit/phpunit": "^9.0"
|
||||||
},
|
},
|
||||||
"bin": [
|
"bin": [
|
||||||
"bin/php-parse"
|
"bin/php-parse"
|
||||||
@ -94,7 +97,7 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "4.9-dev"
|
"dev-master": "5.0-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -118,26 +121,27 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||||
"source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1"
|
"source": "https://github.com/nikic/PHP-Parser/tree/v5.1.0"
|
||||||
},
|
},
|
||||||
"time": "2023-08-13T19:53:39+00:00"
|
"time": "2024-07-01T20:03:41+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phar-io/manifest",
|
"name": "phar-io/manifest",
|
||||||
"version": "2.0.3",
|
"version": "2.0.4",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phar-io/manifest.git",
|
"url": "https://github.com/phar-io/manifest.git",
|
||||||
"reference": "97803eca37d319dfa7826cc2437fc020857acb53"
|
"reference": "54750ef60c58e43759730615a392c31c80e23176"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53",
|
"url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176",
|
||||||
"reference": "97803eca37d319dfa7826cc2437fc020857acb53",
|
"reference": "54750ef60c58e43759730615a392c31c80e23176",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-dom": "*",
|
"ext-dom": "*",
|
||||||
|
"ext-libxml": "*",
|
||||||
"ext-phar": "*",
|
"ext-phar": "*",
|
||||||
"ext-xmlwriter": "*",
|
"ext-xmlwriter": "*",
|
||||||
"phar-io/version": "^3.0.1",
|
"phar-io/version": "^3.0.1",
|
||||||
@ -178,9 +182,15 @@
|
|||||||
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
|
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/phar-io/manifest/issues",
|
"issues": "https://github.com/phar-io/manifest/issues",
|
||||||
"source": "https://github.com/phar-io/manifest/tree/2.0.3"
|
"source": "https://github.com/phar-io/manifest/tree/2.0.4"
|
||||||
},
|
},
|
||||||
"time": "2021-07-20T11:28:43+00:00"
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/theseer",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-03-03T12:33:53+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phar-io/version",
|
"name": "phar-io/version",
|
||||||
@ -235,23 +245,23 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "10.1.3",
|
"version": "10.1.15",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||||
"reference": "be1fe461fdc917de2a29a452ccf2657d325b443d"
|
"reference": "5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/be1fe461fdc917de2a29a452ccf2657d325b443d",
|
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae",
|
||||||
"reference": "be1fe461fdc917de2a29a452ccf2657d325b443d",
|
"reference": "5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-dom": "*",
|
"ext-dom": "*",
|
||||||
"ext-libxml": "*",
|
"ext-libxml": "*",
|
||||||
"ext-xmlwriter": "*",
|
"ext-xmlwriter": "*",
|
||||||
"nikic/php-parser": "^4.15",
|
"nikic/php-parser": "^4.18 || ^5.0",
|
||||||
"php": ">=8.1",
|
"php": ">=8.1",
|
||||||
"phpunit/php-file-iterator": "^4.0",
|
"phpunit/php-file-iterator": "^4.0",
|
||||||
"phpunit/php-text-template": "^3.0",
|
"phpunit/php-text-template": "^3.0",
|
||||||
@ -301,7 +311,7 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
|
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.3"
|
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.15"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -309,20 +319,20 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-07-26T13:45:28+00:00"
|
"time": "2024-06-29T08:25:15+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-file-iterator",
|
"name": "phpunit/php-file-iterator",
|
||||||
"version": "4.0.2",
|
"version": "4.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
||||||
"reference": "5647d65443818959172645e7ed999217360654b6"
|
"reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/5647d65443818959172645e7ed999217360654b6",
|
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c",
|
||||||
"reference": "5647d65443818959172645e7ed999217360654b6",
|
"reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -362,7 +372,7 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
|
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy",
|
"security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.0.2"
|
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -370,7 +380,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-05-07T09:13:23+00:00"
|
"time": "2023-08-31T06:24:48+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-invoker",
|
"name": "phpunit/php-invoker",
|
||||||
@ -437,16 +447,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-text-template",
|
"name": "phpunit/php-text-template",
|
||||||
"version": "3.0.0",
|
"version": "3.0.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/php-text-template.git",
|
"url": "https://github.com/sebastianbergmann/php-text-template.git",
|
||||||
"reference": "9f3d3709577a527025f55bcf0f7ab8052c8bb37d"
|
"reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/9f3d3709577a527025f55bcf0f7ab8052c8bb37d",
|
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748",
|
||||||
"reference": "9f3d3709577a527025f55bcf0f7ab8052c8bb37d",
|
"reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -484,7 +494,8 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/php-text-template/issues",
|
"issues": "https://github.com/sebastianbergmann/php-text-template/issues",
|
||||||
"source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.0"
|
"security": "https://github.com/sebastianbergmann/php-text-template/security/policy",
|
||||||
|
"source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -492,7 +503,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-02-03T06:56:46+00:00"
|
"time": "2023-08-31T14:07:24+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-timer",
|
"name": "phpunit/php-timer",
|
||||||
@ -555,16 +566,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/phpunit",
|
"name": "phpunit/phpunit",
|
||||||
"version": "10.3.3",
|
"version": "10.5.29",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||||
"reference": "241ed4dd0db1c096984e62d414c4e1ac8d5dbff4"
|
"reference": "8e9e80872b4e8064401788ee8a32d40b4455318f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/241ed4dd0db1c096984e62d414c4e1ac8d5dbff4",
|
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8e9e80872b4e8064401788ee8a32d40b4455318f",
|
||||||
"reference": "241ed4dd0db1c096984e62d414c4e1ac8d5dbff4",
|
"reference": "8e9e80872b4e8064401788ee8a32d40b4455318f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -574,26 +585,26 @@
|
|||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"ext-xml": "*",
|
"ext-xml": "*",
|
||||||
"ext-xmlwriter": "*",
|
"ext-xmlwriter": "*",
|
||||||
"myclabs/deep-copy": "^1.10.1",
|
"myclabs/deep-copy": "^1.12.0",
|
||||||
"phar-io/manifest": "^2.0.3",
|
"phar-io/manifest": "^2.0.4",
|
||||||
"phar-io/version": "^3.0.2",
|
"phar-io/version": "^3.2.1",
|
||||||
"php": ">=8.1",
|
"php": ">=8.1",
|
||||||
"phpunit/php-code-coverage": "^10.1.1",
|
"phpunit/php-code-coverage": "^10.1.15",
|
||||||
"phpunit/php-file-iterator": "^4.0",
|
"phpunit/php-file-iterator": "^4.1.0",
|
||||||
"phpunit/php-invoker": "^4.0",
|
"phpunit/php-invoker": "^4.0.0",
|
||||||
"phpunit/php-text-template": "^3.0",
|
"phpunit/php-text-template": "^3.0.1",
|
||||||
"phpunit/php-timer": "^6.0",
|
"phpunit/php-timer": "^6.0.0",
|
||||||
"sebastian/cli-parser": "^2.0",
|
"sebastian/cli-parser": "^2.0.1",
|
||||||
"sebastian/code-unit": "^2.0",
|
"sebastian/code-unit": "^2.0.0",
|
||||||
"sebastian/comparator": "^5.0",
|
"sebastian/comparator": "^5.0.1",
|
||||||
"sebastian/diff": "^5.0",
|
"sebastian/diff": "^5.1.1",
|
||||||
"sebastian/environment": "^6.0",
|
"sebastian/environment": "^6.1.0",
|
||||||
"sebastian/exporter": "^5.0",
|
"sebastian/exporter": "^5.1.2",
|
||||||
"sebastian/global-state": "^6.0.1",
|
"sebastian/global-state": "^6.0.2",
|
||||||
"sebastian/object-enumerator": "^5.0",
|
"sebastian/object-enumerator": "^5.0.0",
|
||||||
"sebastian/recursion-context": "^5.0",
|
"sebastian/recursion-context": "^5.0.0",
|
||||||
"sebastian/type": "^4.0",
|
"sebastian/type": "^4.0.0",
|
||||||
"sebastian/version": "^4.0"
|
"sebastian/version": "^4.0.1"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-soap": "To be able to generate mocks based on WSDL files"
|
"ext-soap": "To be able to generate mocks based on WSDL files"
|
||||||
@ -604,7 +615,7 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "10.3-dev"
|
"dev-main": "10.5-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -636,7 +647,7 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
|
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.3"
|
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.29"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -652,20 +663,20 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-09-05T04:34:51+00:00"
|
"time": "2024-07-30T11:08:00+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/cli-parser",
|
"name": "sebastian/cli-parser",
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/cli-parser.git",
|
"url": "https://github.com/sebastianbergmann/cli-parser.git",
|
||||||
"reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae"
|
"reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/efdc130dbbbb8ef0b545a994fd811725c5282cae",
|
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c34583b87e7b7a8055bf6c450c2c77ce32a24084",
|
||||||
"reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae",
|
"reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -700,7 +711,8 @@
|
|||||||
"homepage": "https://github.com/sebastianbergmann/cli-parser",
|
"homepage": "https://github.com/sebastianbergmann/cli-parser",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/cli-parser/issues",
|
"issues": "https://github.com/sebastianbergmann/cli-parser/issues",
|
||||||
"source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.0"
|
"security": "https://github.com/sebastianbergmann/cli-parser/security/policy",
|
||||||
|
"source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.1"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -708,7 +720,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-02-03T06:58:15+00:00"
|
"time": "2024-03-02T07:12:49+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/code-unit",
|
"name": "sebastian/code-unit",
|
||||||
@ -900,20 +912,20 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/complexity",
|
"name": "sebastian/complexity",
|
||||||
"version": "3.0.0",
|
"version": "3.2.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/complexity.git",
|
"url": "https://github.com/sebastianbergmann/complexity.git",
|
||||||
"reference": "e67d240970c9dc7ea7b2123a6d520e334dd61dc6"
|
"reference": "68ff824baeae169ec9f2137158ee529584553799"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/e67d240970c9dc7ea7b2123a6d520e334dd61dc6",
|
"url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799",
|
||||||
"reference": "e67d240970c9dc7ea7b2123a6d520e334dd61dc6",
|
"reference": "68ff824baeae169ec9f2137158ee529584553799",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"nikic/php-parser": "^4.10",
|
"nikic/php-parser": "^4.18 || ^5.0",
|
||||||
"php": ">=8.1"
|
"php": ">=8.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
@ -922,7 +934,7 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "3.0-dev"
|
"dev-main": "3.2-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -945,7 +957,8 @@
|
|||||||
"homepage": "https://github.com/sebastianbergmann/complexity",
|
"homepage": "https://github.com/sebastianbergmann/complexity",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/complexity/issues",
|
"issues": "https://github.com/sebastianbergmann/complexity/issues",
|
||||||
"source": "https://github.com/sebastianbergmann/complexity/tree/3.0.0"
|
"security": "https://github.com/sebastianbergmann/complexity/security/policy",
|
||||||
|
"source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -953,20 +966,20 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-02-03T06:59:47+00:00"
|
"time": "2023-12-21T08:37:17+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/diff",
|
"name": "sebastian/diff",
|
||||||
"version": "5.0.3",
|
"version": "5.1.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/diff.git",
|
"url": "https://github.com/sebastianbergmann/diff.git",
|
||||||
"reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b"
|
"reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b",
|
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2e",
|
||||||
"reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b",
|
"reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -974,12 +987,12 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^10.0",
|
"phpunit/phpunit": "^10.0",
|
||||||
"symfony/process": "^4.2 || ^5"
|
"symfony/process": "^6.4"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "5.0-dev"
|
"dev-main": "5.1-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -1012,7 +1025,7 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/diff/issues",
|
"issues": "https://github.com/sebastianbergmann/diff/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/diff/security/policy",
|
"security": "https://github.com/sebastianbergmann/diff/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/diff/tree/5.0.3"
|
"source": "https://github.com/sebastianbergmann/diff/tree/5.1.1"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -1020,20 +1033,20 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-05-01T07:48:21+00:00"
|
"time": "2024-03-02T07:15:17+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/environment",
|
"name": "sebastian/environment",
|
||||||
"version": "6.0.1",
|
"version": "6.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/environment.git",
|
"url": "https://github.com/sebastianbergmann/environment.git",
|
||||||
"reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951"
|
"reference": "8074dbcd93529b357029f5cc5058fd3e43666984"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/43c751b41d74f96cbbd4e07b7aec9675651e2951",
|
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/8074dbcd93529b357029f5cc5058fd3e43666984",
|
||||||
"reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951",
|
"reference": "8074dbcd93529b357029f5cc5058fd3e43666984",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1048,7 +1061,7 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "6.0-dev"
|
"dev-main": "6.1-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -1076,7 +1089,7 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/environment/issues",
|
"issues": "https://github.com/sebastianbergmann/environment/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/environment/security/policy",
|
"security": "https://github.com/sebastianbergmann/environment/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/environment/tree/6.0.1"
|
"source": "https://github.com/sebastianbergmann/environment/tree/6.1.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -1084,20 +1097,20 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-04-11T05:39:26+00:00"
|
"time": "2024-03-23T08:47:14+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/exporter",
|
"name": "sebastian/exporter",
|
||||||
"version": "5.0.0",
|
"version": "5.1.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/exporter.git",
|
"url": "https://github.com/sebastianbergmann/exporter.git",
|
||||||
"reference": "f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0"
|
"reference": "955288482d97c19a372d3f31006ab3f37da47adf"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0",
|
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/955288482d97c19a372d3f31006ab3f37da47adf",
|
||||||
"reference": "f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0",
|
"reference": "955288482d97c19a372d3f31006ab3f37da47adf",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1111,7 +1124,7 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "5.0-dev"
|
"dev-main": "5.1-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -1153,7 +1166,8 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/exporter/issues",
|
"issues": "https://github.com/sebastianbergmann/exporter/issues",
|
||||||
"source": "https://github.com/sebastianbergmann/exporter/tree/5.0.0"
|
"security": "https://github.com/sebastianbergmann/exporter/security/policy",
|
||||||
|
"source": "https://github.com/sebastianbergmann/exporter/tree/5.1.2"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -1161,20 +1175,20 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-02-03T07:06:49+00:00"
|
"time": "2024-03-02T07:17:12+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/global-state",
|
"name": "sebastian/global-state",
|
||||||
"version": "6.0.1",
|
"version": "6.0.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/global-state.git",
|
"url": "https://github.com/sebastianbergmann/global-state.git",
|
||||||
"reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4"
|
"reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/7ea9ead78f6d380d2a667864c132c2f7b83055e4",
|
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/987bafff24ecc4c9ac418cab1145b96dd6e9cbd9",
|
||||||
"reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4",
|
"reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1208,14 +1222,14 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Snapshotting of global state",
|
"description": "Snapshotting of global state",
|
||||||
"homepage": "http://www.github.com/sebastianbergmann/global-state",
|
"homepage": "https://www.github.com/sebastianbergmann/global-state",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"global state"
|
"global state"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/global-state/issues",
|
"issues": "https://github.com/sebastianbergmann/global-state/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/global-state/security/policy",
|
"security": "https://github.com/sebastianbergmann/global-state/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/global-state/tree/6.0.1"
|
"source": "https://github.com/sebastianbergmann/global-state/tree/6.0.2"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -1223,24 +1237,24 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-07-19T07:19:23+00:00"
|
"time": "2024-03-02T07:19:19+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/lines-of-code",
|
"name": "sebastian/lines-of-code",
|
||||||
"version": "2.0.0",
|
"version": "2.0.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/lines-of-code.git",
|
"url": "https://github.com/sebastianbergmann/lines-of-code.git",
|
||||||
"reference": "17c4d940ecafb3d15d2cf916f4108f664e28b130"
|
"reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/17c4d940ecafb3d15d2cf916f4108f664e28b130",
|
"url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0",
|
||||||
"reference": "17c4d940ecafb3d15d2cf916f4108f664e28b130",
|
"reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"nikic/php-parser": "^4.10",
|
"nikic/php-parser": "^4.18 || ^5.0",
|
||||||
"php": ">=8.1"
|
"php": ">=8.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
@ -1272,7 +1286,8 @@
|
|||||||
"homepage": "https://github.com/sebastianbergmann/lines-of-code",
|
"homepage": "https://github.com/sebastianbergmann/lines-of-code",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/lines-of-code/issues",
|
"issues": "https://github.com/sebastianbergmann/lines-of-code/issues",
|
||||||
"source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.0"
|
"security": "https://github.com/sebastianbergmann/lines-of-code/security/policy",
|
||||||
|
"source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -1280,7 +1295,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-02-03T07:08:02+00:00"
|
"time": "2023-12-21T08:38:20+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/object-enumerator",
|
"name": "sebastian/object-enumerator",
|
||||||
@ -1568,16 +1583,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "theseer/tokenizer",
|
"name": "theseer/tokenizer",
|
||||||
"version": "1.2.1",
|
"version": "1.2.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/theseer/tokenizer.git",
|
"url": "https://github.com/theseer/tokenizer.git",
|
||||||
"reference": "34a41e998c2183e22995f158c581e7b5e755ab9e"
|
"reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e",
|
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
|
||||||
"reference": "34a41e998c2183e22995f158c581e7b5e755ab9e",
|
"reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1606,7 +1621,7 @@
|
|||||||
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
|
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/theseer/tokenizer/issues",
|
"issues": "https://github.com/theseer/tokenizer/issues",
|
||||||
"source": "https://github.com/theseer/tokenizer/tree/1.2.1"
|
"source": "https://github.com/theseer/tokenizer/tree/1.2.3"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -1614,7 +1629,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-07-28T10:34:58+00:00"
|
"time": "2024-03-03T12:36:25+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
@ -1623,8 +1638,10 @@
|
|||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "^8.1",
|
"php": "^8.2",
|
||||||
"ext-json": "*"
|
"ext-json": "*",
|
||||||
|
"ext-mbstring": "*",
|
||||||
|
"ext-readline": "*"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.3.0"
|
"plugin-api-version": "2.3.0"
|
||||||
|
15
pm-convert
15
pm-convert
@ -2,10 +2,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use PmConverter\Handler;
|
||||||
const EOL = PHP_EOL;
|
const EOL = PHP_EOL;
|
||||||
const DS = DIRECTORY_SEPARATOR;
|
const DS = DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
use PmConverter\Processor;
|
const PM_VERSION = '1.7';
|
||||||
|
|
||||||
$paths = [
|
$paths = [
|
||||||
__DIR__ . '/../../autoload.php',
|
__DIR__ . '/../../autoload.php',
|
||||||
@ -22,14 +24,15 @@ foreach ($paths as $path) {
|
|||||||
|
|
||||||
is_null($file) && throw new RuntimeException('Unable to locate autoload.php file.');
|
is_null($file) && throw new RuntimeException('Unable to locate autoload.php file.');
|
||||||
|
|
||||||
$processor = new Processor($argv);
|
$handler = new Handler();
|
||||||
try {
|
try {
|
||||||
$processor->handle();
|
$handler->init($argv);
|
||||||
|
$handler->start();
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), EOL));
|
fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), EOL));
|
||||||
print(implode(EOL, Processor::usage()));
|
$handler::printHelp();
|
||||||
die(1);
|
exit(1);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), EOL));
|
fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), EOL));
|
||||||
die(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
178
src/ArgumentParser.php
Normal file
178
src/ArgumentParser.php
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace PmConverter;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use PmConverter\Converters\ConvertFormat;
|
||||||
|
use PmConverter\Enums\ArgumentNames as AN;
|
||||||
|
|
||||||
|
class ArgumentParser
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array Raw arguments passed from cli ($argv)
|
||||||
|
*/
|
||||||
|
protected readonly array $raw;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Parsed and ready to use
|
||||||
|
*/
|
||||||
|
protected array $parsed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param array $argv Raw arguments passed from cli ($argv)
|
||||||
|
*/
|
||||||
|
public function __construct(array $argv)
|
||||||
|
{
|
||||||
|
$this->raw = array_slice($argv, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses raw arguments
|
||||||
|
*
|
||||||
|
* @return array Settings according to settings file format
|
||||||
|
*/
|
||||||
|
public function parse(): array
|
||||||
|
{
|
||||||
|
foreach ($this->raw as $idx => $arg) {
|
||||||
|
switch ($arg) {
|
||||||
|
case '-c':
|
||||||
|
case '--config':
|
||||||
|
if (empty($this->raw[$idx + 1])) {
|
||||||
|
throw new InvalidArgumentException('a configuration file path is expected for -c (--config)');
|
||||||
|
}
|
||||||
|
if (isset($this->parsed[AN::Config])) {
|
||||||
|
printf(
|
||||||
|
"INFO: Config file is already set to '%s' and will be overwritten to '%s'",
|
||||||
|
$this->parsed[AN::Config],
|
||||||
|
$this->raw[$idx + 1],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->parsed[AN::Config] = $this->raw[$idx + 1];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-d':
|
||||||
|
case '--dir':
|
||||||
|
if (empty($this->raw[$idx + 1])) {
|
||||||
|
throw new InvalidArgumentException('a directory path is expected for -d (--dir)');
|
||||||
|
}
|
||||||
|
$this->parsed[AN::Directories][] = $this->raw[$idx + 1];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-f':
|
||||||
|
case '--file':
|
||||||
|
if (empty($this->raw[$idx + 1])) {
|
||||||
|
throw new InvalidArgumentException('a directory path is expected for -f (--file)');
|
||||||
|
}
|
||||||
|
$this->parsed[AN::Files][] = $this->raw[$idx + 1];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-e':
|
||||||
|
case '--env':
|
||||||
|
if (empty($this->raw[$idx + 1])) {
|
||||||
|
throw new InvalidArgumentException('an environment file path is expected for -e (--env)');
|
||||||
|
}
|
||||||
|
$this->parsed[AN::Environment][] = $this->raw[$idx + 1];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-o':
|
||||||
|
case '--output':
|
||||||
|
if (empty($this->raw[$idx + 1])) {
|
||||||
|
throw new InvalidArgumentException('an output path is expected for -o (--output)');
|
||||||
|
}
|
||||||
|
$this->parsed[AN::Output][] = $this->raw[$idx + 1];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-p':
|
||||||
|
case '--preserve':
|
||||||
|
$this->parsed[AN::PreserveOutput] = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '--http':
|
||||||
|
$this->parsed[AN::Formats][] = ConvertFormat::Http;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '--curl':
|
||||||
|
$this->parsed[AN::Formats][] = ConvertFormat::Curl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '--wget':
|
||||||
|
$this->parsed[AN::Formats][] = ConvertFormat::Wget;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '--v2.0':
|
||||||
|
$this->parsed[AN::Formats][] = ConvertFormat::Postman20;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '--v2.1':
|
||||||
|
$this->parsed[AN::Formats][] = ConvertFormat::Postman21;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-a':
|
||||||
|
case '--all':
|
||||||
|
foreach (ConvertFormat::cases() as $format) {
|
||||||
|
$this->parsed[AN::Formats][] = $format;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '--var':
|
||||||
|
$definition = trim($this->raw[$idx + 1]);
|
||||||
|
$name = strtok($definition, '='); // take first part before equal sign as var name
|
||||||
|
$value = strtok(''); // take the rest of argument as var value
|
||||||
|
if (isset($this->parsed[AN::Vars][$name])) {
|
||||||
|
printf(
|
||||||
|
"INFO: Variable '%s' is already set to '%s' and will be overwritten to '%s'",
|
||||||
|
$name,
|
||||||
|
$this->parsed[AN::Vars][$name],
|
||||||
|
$value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->parsed[AN::Vars][$name] = $value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '--dev':
|
||||||
|
$this->parsed[AN::DevMode] = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-v':
|
||||||
|
case '--verbose':
|
||||||
|
$this->parsed[AN::Verbose] = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '--dump':
|
||||||
|
$this->parsed[AN::Dump] = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '--version':
|
||||||
|
$this->parsed[AN::Version] = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-h':
|
||||||
|
case '--help':
|
||||||
|
$this->parsed[AN::Help] = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ([AN::Directories, AN::Files, AN::Formats] as $field) {
|
||||||
|
if (!empty($this->parsed[$field])) {
|
||||||
|
$this->parsed[$field] = array_unique($this->parsed[$field] ?? []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns parsed arguments (if set) or parses raw ones
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function parsed(): array
|
||||||
|
{
|
||||||
|
return $this->parsed ??= $this->parse();
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ namespace PmConverter;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Generator;
|
use Generator;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
|
use PmConverter\Enums\CollectionVersion;
|
||||||
use Stringable;
|
use Stringable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,11 +4,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace PmConverter\Converters\Abstract;
|
namespace PmConverter\Converters\Abstract;
|
||||||
|
|
||||||
use PmConverter\CollectionVersion;
|
|
||||||
use PmConverter\Converters\RequestContract;
|
use PmConverter\Converters\RequestContract;
|
||||||
|
use PmConverter\Enums\CollectionVersion;
|
||||||
|
use PmConverter\Enums\HttpVersion;
|
||||||
use PmConverter\Exceptions\EmptyHttpVerbException;
|
use PmConverter\Exceptions\EmptyHttpVerbException;
|
||||||
use PmConverter\Exceptions\InvalidHttpVersionException;
|
use PmConverter\Exceptions\InvalidHttpVersionException;
|
||||||
use PmConverter\HttpVersion;
|
|
||||||
use Stringable;
|
use Stringable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||||||
namespace PmConverter\Converters\Postman20;
|
namespace PmConverter\Converters\Postman20;
|
||||||
|
|
||||||
use PmConverter\Collection;
|
use PmConverter\Collection;
|
||||||
use PmConverter\CollectionVersion;
|
|
||||||
use PmConverter\Converters\Abstract\AbstractConverter;
|
use PmConverter\Converters\Abstract\AbstractConverter;
|
||||||
|
use PmConverter\Enums\CollectionVersion;
|
||||||
use PmConverter\Exceptions\CannotCreateDirectoryException;
|
use PmConverter\Exceptions\CannotCreateDirectoryException;
|
||||||
use PmConverter\Exceptions\DirectoryIsNotWriteableException;
|
use PmConverter\Exceptions\DirectoryIsNotWriteableException;
|
||||||
use PmConverter\FileSystem;
|
use PmConverter\FileSystem;
|
||||||
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||||||
namespace PmConverter\Converters\Postman21;
|
namespace PmConverter\Converters\Postman21;
|
||||||
|
|
||||||
use PmConverter\Collection;
|
use PmConverter\Collection;
|
||||||
use PmConverter\CollectionVersion;
|
|
||||||
use PmConverter\Converters\Abstract\AbstractConverter;
|
use PmConverter\Converters\Abstract\AbstractConverter;
|
||||||
|
use PmConverter\Enums\CollectionVersion;
|
||||||
use PmConverter\Exceptions\CannotCreateDirectoryException;
|
use PmConverter\Exceptions\CannotCreateDirectoryException;
|
||||||
use PmConverter\Exceptions\DirectoryIsNotWriteableException;
|
use PmConverter\Exceptions\DirectoryIsNotWriteableException;
|
||||||
use PmConverter\FileSystem;
|
use PmConverter\FileSystem;
|
||||||
|
25
src/Enums/ArgumentNames.php
Normal file
25
src/Enums/ArgumentNames.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace PmConverter\Enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Argument names
|
||||||
|
*/
|
||||||
|
class ArgumentNames
|
||||||
|
{
|
||||||
|
public const Config = 'config';
|
||||||
|
public const Directories = 'directories';
|
||||||
|
public const Files = 'files';
|
||||||
|
public const Environment = 'environment';
|
||||||
|
public const Output = 'output';
|
||||||
|
public const PreserveOutput = 'preserveOutput';
|
||||||
|
public const Formats = 'formats';
|
||||||
|
public const Vars = 'vars';
|
||||||
|
public const DevMode = 'devMode';
|
||||||
|
public const Verbose = 'verbose';
|
||||||
|
public const Dump = 'dump';
|
||||||
|
public const Version = 'version';
|
||||||
|
public const Help = 'help';
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace PmConverter;
|
namespace PmConverter\Enums;
|
||||||
|
|
||||||
enum CollectionVersion: string
|
enum CollectionVersion: string
|
||||||
{
|
{
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace PmConverter;
|
namespace PmConverter\Enums;
|
||||||
|
|
||||||
enum HttpVersion: string
|
enum HttpVersion: string
|
||||||
{
|
{
|
@ -6,6 +6,7 @@ namespace PmConverter;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
|
use PmConverter\Enums\CollectionVersion;
|
||||||
use PmConverter\Exceptions\CannotCreateDirectoryException;
|
use PmConverter\Exceptions\CannotCreateDirectoryException;
|
||||||
use PmConverter\Exceptions\DirectoryIsNotReadableException;
|
use PmConverter\Exceptions\DirectoryIsNotReadableException;
|
||||||
use PmConverter\Exceptions\DirectoryIsNotWriteableException;
|
use PmConverter\Exceptions\DirectoryIsNotWriteableException;
|
||||||
|
223
src/Handler.php
Normal file
223
src/Handler.php
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace PmConverter;
|
||||||
|
|
||||||
|
use JsonException;
|
||||||
|
use PmConverter\Enums\ArgumentNames as AN;
|
||||||
|
|
||||||
|
class Handler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array Ready to use arguments
|
||||||
|
*/
|
||||||
|
protected array $arguments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Settings Settings read from file and merged with provided in cli
|
||||||
|
*/
|
||||||
|
protected Settings $settings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Environment Environment laoded from file with custom vars provided
|
||||||
|
*/
|
||||||
|
protected Environment $env;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Processor Object that do convertions according to settings
|
||||||
|
*/
|
||||||
|
protected Processor $processor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes main flow
|
||||||
|
*
|
||||||
|
* @param array $argv Raw arguments passed from cli
|
||||||
|
* @return void
|
||||||
|
* @throws JsonException
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function init(array $argv): void
|
||||||
|
{
|
||||||
|
$this->arguments = (new ArgumentParser($argv))->parsed();
|
||||||
|
|
||||||
|
if (!empty($this->arguments[AN::Help])) {
|
||||||
|
self::printHelp();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($this->arguments[AN::Version])) {
|
||||||
|
self::printVersion();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->settings = new Settings();
|
||||||
|
$this->settings->loadFromFile($this->arguments[AN::Config] ?? null);
|
||||||
|
$this->settings->override($this->arguments);
|
||||||
|
empty($arguments[AN::Dump]) || $this->handleSettingsDump();
|
||||||
|
|
||||||
|
$this->env = Environment::instance()
|
||||||
|
->readFromFile($this->settings->envFilepath())
|
||||||
|
->setCustomVars($this->settings->vars());
|
||||||
|
|
||||||
|
$this->processor = new Processor($this->settings, $this->env);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts convertions
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws Exceptions\CannotCreateDirectoryException
|
||||||
|
* @throws Exceptions\DirectoryIsNotReadableException
|
||||||
|
* @throws Exceptions\DirectoryIsNotWriteableException
|
||||||
|
* @throws Exceptions\DirectoryNotExistsException
|
||||||
|
* @throws Exceptions\IncorrectSettingsFileException
|
||||||
|
* @throws JsonException
|
||||||
|
*/
|
||||||
|
public function start(): void
|
||||||
|
{
|
||||||
|
self::printArray(self::version(), self::copyright());
|
||||||
|
$this->processor->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles settings file saving when requested by --dump
|
||||||
|
*
|
||||||
|
* @return never
|
||||||
|
*/
|
||||||
|
protected function handleSettingsDump(): never
|
||||||
|
{
|
||||||
|
$answer = 'o';
|
||||||
|
|
||||||
|
if ($this->settings->fileExists()) {
|
||||||
|
echo 'Settings file already exists: ' . $this->settings->filePath() . EOL;
|
||||||
|
echo 'Do you want to (o)verwrite it, (b)ackup it and create new one or (c)ancel (default)?' . EOL;
|
||||||
|
$answer = strtolower(trim(readline('> ')));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array($answer, ['o', 'b'])) {
|
||||||
|
die('Current settings file has not been changed' . EOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($answer === 'b') {
|
||||||
|
$filepath = $this->settings->backup();
|
||||||
|
printf("Settings file has been backed up to file:%s\t%s%s", EOL, $filepath, EOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->settings->dump();
|
||||||
|
printf("Arguments has been converted into settings file:%s\t%s%s", EOL, $this->settings->filePath(), EOL);
|
||||||
|
die('Review and edit it if needed.' . EOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns usage help strings
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected static function help(): array
|
||||||
|
{
|
||||||
|
return array_merge(self::version(), [
|
||||||
|
'Usage:',
|
||||||
|
"\t./pm-convert -f|-d PATH -o OUTPUT_PATH [ARGUMENTS] [FORMATS]",
|
||||||
|
"\tphp pm-convert -f|-d PATH -o OUTPUT_PATH [ARGUMENTS] [FORMATS]",
|
||||||
|
"\tcomposer pm-convert -f|-d PATH -o OUTPUT_PATH [ARGUMENTS] [FORMATS]",
|
||||||
|
"\t./vendor/bin/pm-convert -f|-d PATH -o OUTPUT_PATH [ARGUMENTS] [FORMATS]",
|
||||||
|
'',
|
||||||
|
'Possible ARGUMENTS:',
|
||||||
|
"\t-f, --file - a PATH to a single collection file to convert from",
|
||||||
|
"\t-d, --dir - a PATH to a directory with collections to convert from",
|
||||||
|
"\t-o, --output - a directory OUTPUT_PATH to put results in",
|
||||||
|
"\t-e, --env - use environment file with variables to replace in requests",
|
||||||
|
"\t--var \"NAME=VALUE\" - force replace specified env variable called NAME with custom VALUE",
|
||||||
|
"\t-p, --preserve - do not delete OUTPUT_PATH (if exists)",
|
||||||
|
"\t --dump - convert provided arguments into settings file in `pwd",
|
||||||
|
"\t-h, --help - show this help message and exit",
|
||||||
|
"\t-v, --version - show version info and exit",
|
||||||
|
'',
|
||||||
|
'If no ARGUMENTS passed then --help implied.',
|
||||||
|
'If both -f and -d are specified then only unique set of files from both arguments will be converted.',
|
||||||
|
'-f or -d are required to be specified at least once, but each may be specified multiple times.',
|
||||||
|
'PATH must be a valid path to readable json-file or directory.',
|
||||||
|
'OUTPUT_PATH must be a valid path to writeable directory.',
|
||||||
|
'If -o or -e was specified several times then only last one will be used.',
|
||||||
|
'',
|
||||||
|
'Possible FORMATS:',
|
||||||
|
"\t--http - generate raw *.http files (default)",
|
||||||
|
"\t--curl - generate shell scripts with curl command",
|
||||||
|
"\t--wget - generate shell scripts with wget command",
|
||||||
|
"\t--v2.0 - convert from Postman Collection Schema v2.1 into v2.0",
|
||||||
|
"\t--v2.1 - convert from Postman Collection Schema v2.0 into v2.1",
|
||||||
|
"\t-a, --all - convert to all of formats listed above",
|
||||||
|
'',
|
||||||
|
'If no FORMATS specified then --http implied.',
|
||||||
|
'Any of FORMATS can be specified at the same time or replaced by --all.',
|
||||||
|
'',
|
||||||
|
'Example:',
|
||||||
|
" ./pm-convert \ ",
|
||||||
|
" -f ~/dir1/first.postman_collection.json \ ",
|
||||||
|
" --directory ~/team \ ",
|
||||||
|
" --file ~/dir2/second.postman_collection.json \ ",
|
||||||
|
" --env ~/localhost.postman_environment.json \ ",
|
||||||
|
" -d ~/personal \ ",
|
||||||
|
" --var \"myvar=some value\" \ ",
|
||||||
|
" -o ~/postman_export \ ",
|
||||||
|
" --all",
|
||||||
|
"",
|
||||||
|
], self::copyright());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints usage help message in stdout
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function printHelp(): void
|
||||||
|
{
|
||||||
|
self::printArray(self::help());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns version strings
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
protected static function version(): array
|
||||||
|
{
|
||||||
|
return ['Postman collection converter v' . PM_VERSION];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints version message in stdout
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function printVersion(): void
|
||||||
|
{
|
||||||
|
self::printArray(self::version());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns copyright strings
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
protected static function copyright(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Anthony Axenov (c) 2023 - ' . (int)date('Y') . ', MIT license',
|
||||||
|
'https://git.axenov.dev/anthony/pm-convert',
|
||||||
|
// '', //TODO
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints an arrays of string to stdout
|
||||||
|
*
|
||||||
|
* @param ...$strings
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected static function printArray(...$strings): void
|
||||||
|
{
|
||||||
|
fwrite(STDOUT, implode("\n", array_merge(...$strings)));
|
||||||
|
}
|
||||||
|
}
|
@ -6,12 +6,9 @@ namespace PmConverter;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Generator;
|
use Generator;
|
||||||
use InvalidArgumentException;
|
|
||||||
use JetBrains\PhpStorm\NoReturn;
|
|
||||||
use JsonException;
|
use JsonException;
|
||||||
use PmConverter\Converters\Abstract\AbstractConverter;
|
use PmConverter\Converters\Abstract\AbstractConverter;
|
||||||
use PmConverter\Converters\ConverterContract;
|
use PmConverter\Converters\ConverterContract;
|
||||||
use PmConverter\Converters\ConvertFormat;
|
|
||||||
use PmConverter\Exceptions\CannotCreateDirectoryException;
|
use PmConverter\Exceptions\CannotCreateDirectoryException;
|
||||||
use PmConverter\Exceptions\DirectoryIsNotReadableException;
|
use PmConverter\Exceptions\DirectoryIsNotReadableException;
|
||||||
use PmConverter\Exceptions\DirectoryIsNotWriteableException;
|
use PmConverter\Exceptions\DirectoryIsNotWriteableException;
|
||||||
@ -19,15 +16,10 @@ use PmConverter\Exceptions\DirectoryNotExistsException;
|
|||||||
use PmConverter\Exceptions\IncorrectSettingsFileException;
|
use PmConverter\Exceptions\IncorrectSettingsFileException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main class
|
* Processor class
|
||||||
*/
|
*/
|
||||||
class Processor
|
class Processor
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Converter version
|
|
||||||
*/
|
|
||||||
public const VERSION = '1.6.1';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Initial timestamp
|
* @var int Initial timestamp
|
||||||
*/
|
*/
|
||||||
@ -38,150 +30,23 @@ class Processor
|
|||||||
*/
|
*/
|
||||||
protected readonly int $initRam;
|
protected readonly int $initRam;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Settings Settings (lol)
|
|
||||||
*/
|
|
||||||
protected Settings $settings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ConverterContract[] Converters will be used for conversion according to chosen formats
|
* @var ConverterContract[] Converters will be used for conversion according to chosen formats
|
||||||
*/
|
*/
|
||||||
protected array $converters = [];
|
protected array $converters = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool Do we need to save settings file and exit or not?
|
|
||||||
*/
|
|
||||||
protected bool $needDumpSettings = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Environment
|
|
||||||
*/
|
|
||||||
public Environment $env;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param array $argv Arguments came from cli
|
* @param Settings $settings Settings (lol)
|
||||||
* @throws IncorrectSettingsFileException
|
* @param Environment $env Environment
|
||||||
* @throws JsonException
|
|
||||||
*/
|
*/
|
||||||
public function __construct(protected readonly array $argv)
|
public function __construct(
|
||||||
{
|
protected Settings $settings,
|
||||||
|
protected Environment $env,
|
||||||
|
) {
|
||||||
$this->initTime = hrtime(true);
|
$this->initTime = hrtime(true);
|
||||||
$this->initRam = memory_get_usage(true);
|
$this->initRam = memory_get_usage(true);
|
||||||
$this->settings = Settings::init();
|
|
||||||
$this->env = Environment::instance()
|
|
||||||
->readFromFile($this->settings->envFilepath())
|
|
||||||
->setCustomVars($this->settings->vars());
|
|
||||||
$this->parseArgs();
|
|
||||||
$this->needDumpSettings && $this->dumpSettingsFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses an array of arguments came from cli
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @throws JsonException
|
|
||||||
*/
|
|
||||||
protected function parseArgs(): void
|
|
||||||
{
|
|
||||||
$arguments = array_slice($this->argv, 1);
|
|
||||||
$needHelp = count($arguments) === 0 && !$this->settings::fileExists();
|
|
||||||
foreach ($arguments as $idx => $arg) {
|
|
||||||
switch ($arg) {
|
|
||||||
case '-f':
|
|
||||||
case '--file':
|
|
||||||
$this->settings->addFilePath($this->argv[$idx + 1]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '-o':
|
|
||||||
case '--output':
|
|
||||||
if (empty($this->argv[$idx + 1])) {
|
|
||||||
throw new InvalidArgumentException('-o is required');
|
|
||||||
}
|
|
||||||
$this->settings->setOutputPath($this->argv[$idx + 1]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '-d':
|
|
||||||
case '--dir':
|
|
||||||
if (empty($this->argv[$idx + 1])) {
|
|
||||||
throw new InvalidArgumentException('a directory path is expected for -d (--dir)');
|
|
||||||
}
|
|
||||||
$this->settings->addDirPath($this->argv[$idx + 1]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '-e':
|
|
||||||
case '--env':
|
|
||||||
$this->settings->setEnvFilepath($this->argv[$idx + 1]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '-p':
|
|
||||||
case '--preserve':
|
|
||||||
$this->settings->setPreserveOutput(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '--http':
|
|
||||||
$this->settings->addFormat(ConvertFormat::Http);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '--curl':
|
|
||||||
$this->settings->addFormat(ConvertFormat::Curl);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '--wget':
|
|
||||||
$this->settings->addFormat(ConvertFormat::Wget);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '--v2.0':
|
|
||||||
$this->settings->addFormat(ConvertFormat::Postman20);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '--v2.1':
|
|
||||||
$this->settings->addFormat(ConvertFormat::Postman21);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '-a':
|
|
||||||
case '--all':
|
|
||||||
foreach (ConvertFormat::cases() as $format) {
|
|
||||||
$this->settings->addFormat($format);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '--var':
|
|
||||||
//TODO split by first equal sign
|
|
||||||
$this->env->setCustomVar(...explode('=', trim($this->argv[$idx + 1])));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '--dev':
|
|
||||||
$this->settings->setDevMode(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '--dump':
|
|
||||||
$this->needDumpSettings = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '-v':
|
|
||||||
case '--version':
|
|
||||||
die(implode(EOL, $this->version()) . EOL);
|
|
||||||
|
|
||||||
case '-h':
|
|
||||||
case '--help':
|
|
||||||
$needHelp = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($needHelp) {
|
|
||||||
die(implode(EOL, $this->usage()) . EOL);
|
|
||||||
}
|
|
||||||
if (empty($this->settings->collectionPaths())) {
|
|
||||||
throw new InvalidArgumentException('there are no collections to convert');
|
|
||||||
}
|
|
||||||
if (empty($this->settings->outputPath())) {
|
|
||||||
throw new InvalidArgumentException('-o is required');
|
|
||||||
}
|
|
||||||
if (empty($this->settings->formats())) {
|
|
||||||
$this->settings->addFormat(ConvertFormat::Http);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,41 +58,14 @@ class Processor
|
|||||||
* @throws DirectoryIsNotWriteableException
|
* @throws DirectoryIsNotWriteableException
|
||||||
* @throws DirectoryNotExistsException
|
* @throws DirectoryNotExistsException
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
* @throws IncorrectSettingsFileException
|
|
||||||
*/
|
*/
|
||||||
public function handle(): void
|
public function start(): void
|
||||||
{
|
{
|
||||||
$this->prepareOutputDirectory();
|
$this->prepareOutputDirectory();
|
||||||
$this->initConverters();
|
$this->initConverters();
|
||||||
$this->convert();
|
$this->convert();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes all settings into file if --dump provided
|
|
||||||
*
|
|
||||||
* @return never
|
|
||||||
*/
|
|
||||||
#[NoReturn]
|
|
||||||
protected function dumpSettingsFile(): never
|
|
||||||
{
|
|
||||||
$answer = 'o';
|
|
||||||
if ($this->settings::fileExists()) {
|
|
||||||
echo 'Settings file already exists: ' . $this->settings::filepath() . EOL;
|
|
||||||
echo 'Do you want to (o)verwrite it, (b)ackup it and create new one or (c)ancel (default)?' . EOL;
|
|
||||||
$answer = strtolower(trim(readline('> ')));
|
|
||||||
}
|
|
||||||
if (!in_array($answer, ['o', 'b'])) {
|
|
||||||
die('Current settings file has not been changed' . EOL);
|
|
||||||
}
|
|
||||||
if ($answer === 'b') {
|
|
||||||
$filepath = $this->settings->backup();
|
|
||||||
printf("Settings file has been backed up to file:%s\t%s%s", EOL, $filepath, EOL);
|
|
||||||
}
|
|
||||||
$this->settings->dump($this->env->customVars());
|
|
||||||
printf("Arguments has been converted into settings file:%s\t%s%s", EOL, $this->settings::filepath(), EOL);
|
|
||||||
die('Review and edit it if needed.' . EOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes output directory
|
* Initializes output directory
|
||||||
*
|
*
|
||||||
@ -264,7 +102,7 @@ class Processor
|
|||||||
* @return Generator<Collection>
|
* @return Generator<Collection>
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
protected function newCollection(): Generator
|
protected function nextCollection(): Generator
|
||||||
{
|
{
|
||||||
foreach ($this->settings->collectionPaths() as $collectionPath) {
|
foreach ($this->settings->collectionPaths() as $collectionPath) {
|
||||||
yield Collection::fromFile($collectionPath);
|
yield Collection::fromFile($collectionPath);
|
||||||
@ -280,9 +118,7 @@ class Processor
|
|||||||
{
|
{
|
||||||
$count = count($this->settings->collectionPaths());
|
$count = count($this->settings->collectionPaths());
|
||||||
$current = $success = 0;
|
$current = $success = 0;
|
||||||
$collection = null;
|
foreach ($this->nextCollection() as $collection) {
|
||||||
print(implode(EOL, array_merge($this->version(), $this->copyright())) . EOL . EOL);
|
|
||||||
foreach ($this->newCollection() as $collection) {
|
|
||||||
++$current;
|
++$current;
|
||||||
printf("Converting '%s' (%d/%d):%s", $collection->name(), $current, $count, EOL);
|
printf("Converting '%s' (%d/%d):%s", $collection->name(), $current, $count, EOL);
|
||||||
foreach ($this->converters as $type => $converter) {
|
foreach ($this->converters as $type => $converter) {
|
||||||
@ -297,7 +133,7 @@ class Processor
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
printf(' ERROR %s: %s%s', $e->getCode(), $e->getMessage(), EOL);
|
printf(' ERROR %s: %s%s', $e->getCode(), $e->getMessage(), EOL);
|
||||||
if ($this->settings->isDevMode()) {
|
if ($this->settings->isDevMode()) {
|
||||||
array_map(static fn ($line) => printf(' %s%s', $line, EOL), $e->getTrace());
|
array_map(static fn (string $line) => printf(' %s%s', $line, EOL), $e->getTrace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,79 +162,4 @@ class Processor
|
|||||||
$ram = (memory_get_peak_usage(true) - $this->initRam) / 1024 / 1024;
|
$ram = (memory_get_peak_usage(true) - $this->initRam) / 1024 / 1024;
|
||||||
printf("Converted %d/%d in %.2f $timeFmt using up to %.2f MiB RAM%s", $success, $count, $time, $ram, EOL);
|
printf("Converted %d/%d in %.2f $timeFmt using up to %.2f MiB RAM%s", $success, $count, $time, $ram, EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public static function version(): array
|
|
||||||
{
|
|
||||||
return ['Postman collection converter v' . self::VERSION];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public static function copyright(): array
|
|
||||||
{
|
|
||||||
$years = ($year = (int)date('Y')) > 2023 ? "2023 - $year" : $year;
|
|
||||||
return [
|
|
||||||
"Anthony Axenov (c) $years, MIT license",
|
|
||||||
'https://git.axenov.dev/anthony/pm-convert'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function usage(): array
|
|
||||||
{
|
|
||||||
return array_merge(static::version(), [
|
|
||||||
'Usage:',
|
|
||||||
"\t./pm-convert -f|-d PATH -o OUTPUT_PATH [ARGUMENTS] [FORMATS]",
|
|
||||||
"\tphp pm-convert -f|-d PATH -o OUTPUT_PATH [ARGUMENTS] [FORMATS]",
|
|
||||||
"\tcomposer pm-convert -f|-d PATH -o OUTPUT_PATH [ARGUMENTS] [FORMATS]",
|
|
||||||
"\t./vendor/bin/pm-convert -f|-d PATH -o OUTPUT_PATH [ARGUMENTS] [FORMATS]",
|
|
||||||
'',
|
|
||||||
'Possible ARGUMENTS:',
|
|
||||||
"\t-f, --file - a PATH to a single collection file to convert from",
|
|
||||||
"\t-d, --dir - a PATH to a directory with collections to convert from",
|
|
||||||
"\t-o, --output - a directory OUTPUT_PATH to put results in",
|
|
||||||
"\t-e, --env - use environment file with variables to replace in requests",
|
|
||||||
"\t--var \"NAME=VALUE\" - force replace specified env variable called NAME with custom VALUE",
|
|
||||||
"\t-p, --preserve - do not delete OUTPUT_PATH (if exists)",
|
|
||||||
"\t --dump - convert provided arguments into settings file in `pwd",
|
|
||||||
"\t-h, --help - show this help message and exit",
|
|
||||||
"\t-v, --version - show version info and exit",
|
|
||||||
'',
|
|
||||||
'If no ARGUMENTS passed then --help implied.',
|
|
||||||
'If both -f and -d are specified then only unique set of files from both arguments will be converted.',
|
|
||||||
'-f or -d are required to be specified at least once, but each may be specified multiple times.',
|
|
||||||
'PATH must be a valid path to readable json-file or directory.',
|
|
||||||
'OUTPUT_PATH must be a valid path to writeable directory.',
|
|
||||||
'If -o or -e was specified several times then only last one will be used.',
|
|
||||||
'',
|
|
||||||
'Possible FORMATS:',
|
|
||||||
"\t--http - generate raw *.http files (default)",
|
|
||||||
"\t--curl - generate shell scripts with curl command",
|
|
||||||
"\t--wget - generate shell scripts with wget command",
|
|
||||||
"\t--v2.0 - convert from Postman Collection Schema v2.1 into v2.0",
|
|
||||||
"\t--v2.1 - convert from Postman Collection Schema v2.0 into v2.1",
|
|
||||||
"\t-a, --all - convert to all of formats listed above",
|
|
||||||
'',
|
|
||||||
'If no FORMATS specified then --http implied.',
|
|
||||||
'Any of FORMATS can be specified at the same time or replaced by --all.',
|
|
||||||
'',
|
|
||||||
'Example:',
|
|
||||||
" ./pm-convert \ ",
|
|
||||||
" -f ~/dir1/first.postman_collection.json \ ",
|
|
||||||
" --directory ~/team \ ",
|
|
||||||
" --file ~/dir2/second.postman_collection.json \ ",
|
|
||||||
" --env ~/localhost.postman_environment.json \ ",
|
|
||||||
" -d ~/personal \ ",
|
|
||||||
" --var \"myvar=some value\" \ ",
|
|
||||||
" -o ~/postman_export \ ",
|
|
||||||
" --all",
|
|
||||||
"",
|
|
||||||
], static::copyright());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
283
src/Settings.php
283
src/Settings.php
@ -4,10 +4,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace PmConverter;
|
namespace PmConverter;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
use PmConverter\Converters\ConvertFormat;
|
use PmConverter\Converters\ConvertFormat;
|
||||||
use PmConverter\Exceptions\IncorrectSettingsFileException;
|
use PmConverter\Enums\ArgumentNames as AN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class responsible for settings storage and dumping
|
* Class responsible for settings storage and dumping
|
||||||
@ -15,76 +16,201 @@ use PmConverter\Exceptions\IncorrectSettingsFileException;
|
|||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Full path to settings file
|
* @var string|null Full path to settings file
|
||||||
*/
|
*/
|
||||||
protected static string $filepath;
|
protected ?string $filePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool Flag to output some debug-specific messages
|
* @var bool Flag to output some debug-specific messages
|
||||||
*/
|
*/
|
||||||
protected bool $devMode = false;
|
protected bool $devMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[] Paths to collection directories
|
* @var string[] Paths to collection directories
|
||||||
*/
|
*/
|
||||||
protected array $directories = [];
|
protected array $dirPaths;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[] Paths to collection files
|
* @var string[] Paths to collection files
|
||||||
*/
|
*/
|
||||||
protected array $collectionPaths = [];
|
protected array $collectionPaths;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Output path where to put results in
|
* @var string|null Output path where to put results in
|
||||||
*/
|
*/
|
||||||
protected string $outputPath = '';
|
protected ?string $outputPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool Flag to remove output directories or not before conversion started
|
* @var bool Flag to remove output directories or not before conversion started
|
||||||
*/
|
*/
|
||||||
protected bool $preserveOutput = false;
|
protected bool $preserveOutput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[] Additional variables
|
* @var string[] Additional variables
|
||||||
*/
|
*/
|
||||||
protected array $vars = [];
|
protected array $vars;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ConvertFormat[] Formats to convert a collections into
|
* @var ConvertFormat[] Formats to convert a collections into
|
||||||
*/
|
*/
|
||||||
protected array $formats = [];
|
protected array $formats;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Path to environment file
|
* @var string|null Path to environment file
|
||||||
*/
|
*/
|
||||||
protected string $envFilepath = '';
|
protected ?string $envFilePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @param array $settings
|
||||||
*/
|
*/
|
||||||
public static function fileExists(): bool
|
public function __construct()
|
||||||
{
|
{
|
||||||
return file_exists(self::$filepath);
|
$this->loadFromDefaults();
|
||||||
|
// foreach ($settings[AN::Directories] ?? [] as $path) {
|
||||||
|
// $this->addDirPath($path);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// foreach ($settings[AN::Files] ?? [] as $path) {
|
||||||
|
// $this->addFilePath($path);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $this->setDevMode(!empty($settings[AN::DevMode]));
|
||||||
|
//
|
||||||
|
// $this->setPreserveOutput(!empty($settings[AN::PreserveOutput]));
|
||||||
|
//
|
||||||
|
// isset($settings[AN::Environment]) && $this->setEnvFilepath($settings[AN::Environment]);
|
||||||
|
//
|
||||||
|
// isset($settings[AN::Output]) && $this->setOutputPath($settings[AN::Output]);
|
||||||
|
//
|
||||||
|
// foreach ($settings->formats ?? [] as $format) {
|
||||||
|
// $this->addFormat(ConvertFormat::fromArg($format));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// foreach ($settings[AN::Vars] ?? [] as $name => $value) {
|
||||||
|
// $this[AN::Vars][$name] = $value;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return self
|
* Loads settings from file
|
||||||
* @throws IncorrectSettingsFileException
|
*
|
||||||
|
* @param string|null $filePath
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function loadFromFile(?string $filePath = null): void
|
||||||
|
{
|
||||||
|
if (is_null($filePath)) {
|
||||||
|
$filePath = sprintf('%s%spm-convert-settings.json', $_SERVER['PWD'], DS);
|
||||||
|
}
|
||||||
|
|
||||||
|
$filePath = trim($filePath);
|
||||||
|
|
||||||
|
if (!file_exists($filePath)) {
|
||||||
|
throw new Exception("file does not exist: $filePath");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_file($filePath)) {
|
||||||
|
throw new Exception("not a file: $filePath");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_readable($filePath)) {
|
||||||
|
throw new Exception("not a readable file: $filePath");
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = file_get_contents($filePath);
|
||||||
|
$settings = json_decode($content ?: '{}', true, JSON_THROW_ON_ERROR);
|
||||||
|
|
||||||
|
$this->setFromArray($settings);
|
||||||
|
$this->filePath = $filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rewrites some defined settings with new values
|
||||||
|
*
|
||||||
|
* @param array $settings
|
||||||
|
* @return void
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public static function init(): self
|
public function override(array $settings): void
|
||||||
{
|
{
|
||||||
$content = '{}';
|
$settings = array_replace_recursive($this->__serialize(), $settings);
|
||||||
self::$filepath = sprintf('%s%spm-convert-settings.json', $_SERVER['PWD'], DS);
|
$this->setFromArray($settings);
|
||||||
if (self::fileExists()) {
|
}
|
||||||
$content = trim(file_get_contents(self::$filepath));
|
|
||||||
|
/**
|
||||||
|
* Loads settings with default values
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws JsonException
|
||||||
|
*/
|
||||||
|
public function loadFromDefaults(): void
|
||||||
|
{
|
||||||
|
$this->setFromArray(self::defaults());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns default settings values
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function defaults(?string $key = null): mixed
|
||||||
|
{
|
||||||
|
$values = [
|
||||||
|
AN::Config => null,
|
||||||
|
AN::Directories => [],
|
||||||
|
AN::Files => [],
|
||||||
|
AN::Environment => null,
|
||||||
|
AN::Output => null,
|
||||||
|
AN::PreserveOutput => false,
|
||||||
|
AN::Formats => ['http'],
|
||||||
|
AN::Vars => [],
|
||||||
|
AN::DevMode => false,
|
||||||
|
AN::Verbose => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $key ? $values[$key] : $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set settings from array
|
||||||
|
*
|
||||||
|
* @param array $settings
|
||||||
|
* @return void
|
||||||
|
* @throws JsonException
|
||||||
|
*/
|
||||||
|
protected function setFromArray(array $settings): void
|
||||||
|
{
|
||||||
|
foreach ($settings[AN::Directories] ?? self::defaults(AN::Directories) as $path) {
|
||||||
|
$this->addDirPath($path);
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
$settings = json_decode($content ?: '{}', flags: JSON_THROW_ON_ERROR);
|
foreach ($settings[AN::Files] ?? self::defaults(AN::Files) ?? [] as $path) {
|
||||||
} catch (JsonException $e) {
|
$this->addFilePath($path);
|
||||||
throw new IncorrectSettingsFileException('Incorrect settings file: ' . $e->getMessage(), $e->getCode());
|
|
||||||
}
|
}
|
||||||
return new self($settings);
|
|
||||||
|
$this->setEnvFilePath($settings[AN::Environment] ?? self::defaults(AN::Environment));
|
||||||
|
$this->setOutputPath($settings[AN::Output] ?? self::defaults(AN::Output));
|
||||||
|
$this->setPreserveOutput($settings[AN::PreserveOutput] ?? self::defaults(AN::PreserveOutput));
|
||||||
|
|
||||||
|
foreach ($settings[AN::Formats] ?? self::defaults(AN::Formats) as $format) {
|
||||||
|
$this->addFormat(ConvertFormat::fromArg($format));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->vars = $settings[AN::Vars] ?? self::defaults(AN::Vars);
|
||||||
|
$this->setDevMode($settings[AN::DevMode] ?? self::defaults(AN::DevMode));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks wether settings file exists or not
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function fileExists(): bool
|
||||||
|
{
|
||||||
|
return is_file($this->filePath)
|
||||||
|
&& is_readable($this->filePath)
|
||||||
|
&& is_writable($this->filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,77 +218,65 @@ class Settings
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function filepath(): string
|
public function filePath(): string
|
||||||
{
|
{
|
||||||
return self::$filepath;
|
return $this->filePath;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param object $settings
|
|
||||||
* @throws JsonException
|
|
||||||
*/
|
|
||||||
protected function __construct(object $settings)
|
|
||||||
{
|
|
||||||
foreach ($settings->directories ?? [] as $path) {
|
|
||||||
$this->addDirPath($path);
|
|
||||||
}
|
|
||||||
foreach ($settings->files ?? [] as $path) {
|
|
||||||
$this->addFilePath($path);
|
|
||||||
}
|
|
||||||
$this->setDevMode(!empty($settings->devMode));
|
|
||||||
$this->setPreserveOutput(!empty($settings->preserveOutput));
|
|
||||||
isset($settings->environment) && $this->setEnvFilepath($settings->environment);
|
|
||||||
isset($settings->output) && $this->setOutputPath($settings->output);
|
|
||||||
foreach ($settings->formats ?? [] as $format) {
|
|
||||||
$this->addFormat(ConvertFormat::fromArg($format));
|
|
||||||
}
|
|
||||||
foreach ($settings->vars ?? [] as $name => $value) {
|
|
||||||
$this->vars[$name] = $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Adds directory path into current settings array and fills files array with its content
|
||||||
|
*
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return void
|
* @return void
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public function addDirPath(string $path): void
|
public function addDirPath(string $path): void
|
||||||
{
|
{
|
||||||
$this->directories = array_unique(array_merge(
|
$this->dirPaths = array_unique(array_merge(
|
||||||
$this->directories ?? [],
|
$this->dirPaths ?? [],
|
||||||
[FileSystem::normalizePath($path)]
|
[FileSystem::normalizePath($path)]
|
||||||
));
|
));
|
||||||
|
|
||||||
$files = array_filter(
|
$files = array_filter(
|
||||||
FileSystem::dirContents($path),
|
FileSystem::dirContents($path),
|
||||||
static fn ($filename) => FileSystem::isCollectionFile($filename)
|
static fn ($filename) => FileSystem::isCollectionFile($filename)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->collectionPaths = array_unique(array_merge($this->collectionPaths ?? [], $files));
|
$this->collectionPaths = array_unique(array_merge($this->collectionPaths ?? [], $files));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Adds collection file into current settings array
|
||||||
|
*
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return void
|
* @return void
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public function addFilePath(string $path): void
|
public function addFilePath(string $path): void
|
||||||
{
|
{
|
||||||
$normpath = FileSystem::normalizePath($path);
|
$normPath = FileSystem::normalizePath($path);
|
||||||
if (!FileSystem::isCollectionFile($normpath)) {
|
|
||||||
|
if (!FileSystem::isCollectionFile($normPath)) {
|
||||||
throw new InvalidArgumentException("not a valid collection: $path");
|
throw new InvalidArgumentException("not a valid collection: $path");
|
||||||
}
|
}
|
||||||
|
|
||||||
in_array($path, $this->collectionPaths) || $this->collectionPaths[] = $path;
|
in_array($path, $this->collectionPaths) || $this->collectionPaths[] = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $outputPath
|
* Sets output directory path
|
||||||
|
*
|
||||||
|
* @param string|null $outputPath
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setOutputPath(string $outputPath): void
|
public function setOutputPath(?string $outputPath): void
|
||||||
{
|
{
|
||||||
$this->outputPath = $outputPath;
|
$this->outputPath = $outputPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sets developer mode setting
|
||||||
|
*
|
||||||
* @param bool $devMode
|
* @param bool $devMode
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -172,6 +286,8 @@ class Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Adds a format to convert to into current settings array
|
||||||
|
*
|
||||||
* @param ConvertFormat $format
|
* @param ConvertFormat $format
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -191,6 +307,8 @@ class Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sets a setting responsible for saving old convertion results
|
||||||
|
*
|
||||||
* @param bool $preserveOutput
|
* @param bool $preserveOutput
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -200,15 +318,21 @@ class Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filepath
|
* Sets environment filepath setting
|
||||||
|
*
|
||||||
|
* @param string|null $filepath
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setEnvFilepath(string $filepath): void
|
public function setEnvFilePath(?string $filepath): void
|
||||||
{
|
{
|
||||||
$this->envFilepath = FileSystem::normalizePath($filepath);
|
$this->envFilePath = is_string($filepath)
|
||||||
|
? FileSystem::normalizePath($filepath)
|
||||||
|
: $filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns current value of developer mode setting
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isDevMode(): bool
|
public function isDevMode(): bool
|
||||||
@ -217,6 +341,8 @@ class Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns current value of collection files setting
|
||||||
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function collectionPaths(): array
|
public function collectionPaths(): array
|
||||||
@ -225,6 +351,8 @@ class Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns current value of output directory path setting
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function outputPath(): string
|
public function outputPath(): string
|
||||||
@ -233,6 +361,8 @@ class Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns current value of preserve output setting
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isPreserveOutput(): bool
|
public function isPreserveOutput(): bool
|
||||||
@ -241,6 +371,8 @@ class Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns current convert formats
|
||||||
|
*
|
||||||
* @return ConvertFormat[]
|
* @return ConvertFormat[]
|
||||||
*/
|
*/
|
||||||
public function formats(): array
|
public function formats(): array
|
||||||
@ -249,11 +381,13 @@ class Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns current value of environment filepath setting
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function envFilepath(): string
|
public function envFilepath(): string
|
||||||
{
|
{
|
||||||
return $this->envFilepath;
|
return $this->envFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,17 +398,17 @@ class Settings
|
|||||||
public function __serialize(): array
|
public function __serialize(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'dev' => $this->isDevMode(),
|
AN::DevMode => $this->isDevMode(),
|
||||||
'directories' => $this->directories,
|
AN::Directories => $this->dirPaths,
|
||||||
'files' => $this->collectionPaths(),
|
AN::Files => $this->collectionPaths(),
|
||||||
'environment' => $this->envFilepath(),
|
AN::Environment => $this->envFilepath(),
|
||||||
'output' => $this->outputPath(),
|
AN::Output => $this->outputPath(),
|
||||||
'preserve-output' => $this->isPreserveOutput(),
|
AN::PreserveOutput => $this->isPreserveOutput(),
|
||||||
'formats' => array_values(array_map(
|
AN::Formats => array_values(array_map(
|
||||||
static fn (ConvertFormat $format) => $format->toArg(),
|
static fn (ConvertFormat $format) => $format->toArg(),
|
||||||
$this->formats(),
|
$this->formats(),
|
||||||
)),
|
)),
|
||||||
'vars' => $this->vars,
|
AN::Vars => $this->vars,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +441,8 @@ class Settings
|
|||||||
*/
|
*/
|
||||||
public function backup(): string
|
public function backup(): string
|
||||||
{
|
{
|
||||||
copy(self::$filepath, $newfilepath = self::$filepath . '.bak.' . time());
|
$newFilePath = $this->filePath() . '.bak.' . time();
|
||||||
return $newfilepath;
|
copy($this->filePath(), $newFilePath);
|
||||||
|
return $newFilePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ class AbstractRequestTest extends TestCase
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers PmConverter\Converters\Abstract\AbstractRequest
|
* @covers PmConverter\Converters\Abstract\AbstractRequest
|
||||||
* @covers PmConverter\HttpVersion
|
* @covers \PmConverter\Enums\HttpVersion
|
||||||
* @return void
|
* @return void
|
||||||
* @throws InvalidHttpVersionException
|
* @throws InvalidHttpVersionException
|
||||||
*/
|
*/
|
||||||
@ -25,7 +25,7 @@ class AbstractRequestTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @covers PmConverter\Converters\Abstract\AbstractRequest
|
* @covers PmConverter\Converters\Abstract\AbstractRequest
|
||||||
* @covers PmConverter\Converters\Abstract\AbstractRequest::getVerb()
|
* @covers PmConverter\Converters\Abstract\AbstractRequest::getVerb()
|
||||||
* @covers PmConverter\HttpVersion
|
* @covers \PmConverter\Enums\HttpVersion
|
||||||
* @return void
|
* @return void
|
||||||
* @throws InvalidHttpVersionException
|
* @throws InvalidHttpVersionException
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user