Skip to content

extracting CLI to separate package #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/vendor
/.idea
/json-diff
/json-diff.tar.gz
/composer.lock
/composer.phar
/clover.xml
12 changes: 11 additions & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
checks:
php:
code_rating: true
duplication: true
filter:
paths: [src/*]
excluded_paths: [vendor/*, tests/*]
Expand All @@ -15,4 +19,10 @@ tools:
excluded_dirs: [vendor, tests]
php_cpd:
enabled: true
excluded_dirs: [vendor, tests]
excluded_dirs: [vendor, tests]
build:
nodes:
analysis:
tests:
override:
- php-scrutinizer-run
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ cache:

# execute any number of scripts before the test run, custom env's are available as variables
before_script:
- ls -la $HOME/.composer/cache
- test -f $HOME/.composer/cache/composer.lock.$(phpenv version-name) && cp $HOME/.composer/cache/composer.lock.$(phpenv version-name) ./composer.lock || echo "No composer.lock cached"
- composer install --dev --no-interaction --prefer-dist
- test -f $HOME/.composer/cache/composer.lock.$(phpenv version-name) || cp ./composer.lock $HOME/.composer/cache/composer.lock.$(phpenv version-name)
- if [[ $(phpenv version-name) =~ 7.2 ]] ; then test -f $HOME/.composer/cache/phpstan.phar || wget https://github.com/phpstan/phpstan/releases/download/0.9.1/phpstan.phar -O $HOME/.composer/cache/phpstan.phar; fi
- if [[ $(phpenv version-name) =~ 7.2 ]] ; then test -f $HOME/.composer/cache/ocular.phar || wget https://scrutinizer-ci.com/ocular.phar -O $HOME/.composer/cache/ocular.phar; fi
- if [[ $(phpenv version-name) =~ 7.2 ]] ; then test -f $HOME/.composer/cache/cctr || wget https://codeclimate.com/downloads/test-reporter/test-reporter-0.1.4-linux-amd64 -O $HOME/.composer/cache/cctr && chmod +x $HOME/.composer/cache/cctr; fi
Expand Down
130 changes: 1 addition & 129 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,132 +162,4 @@ $this->assertEquals($diff->getRearranged(), $original);

## CLI tool

### Usage

```
bin/json-diff --help
JSON diff and apply tool for PHP, https://github.com/swaggest/json-diff
Usage:
json-diff <action>
action Action name
Allowed values: diff, apply, rearrange, info
```

```
bin/json-diff diff --help
v2.0.0 json-diff diff
JSON diff and apply tool for PHP, https://github.com/swaggest/json-diff
Make patch from two json documents, output to STDOUT
Usage:
json-diff diff <originalPath> <newPath>
originalPath Path to old (original) json file
newPath Path to new json file

Options:
--pretty Pretty-print result JSON
--rearrange-arrays Rearrange arrays to match original
```

```
bin/json-diff apply --help
v2.0.0 json-diff apply
JSON diff and apply tool for PHP, https://github.com/swaggest/json-diff
Apply patch to base json document, output to STDOUT
Usage:
json-diff apply [patchPath] [basePath]
patchPath Path to JSON patch file
basePath Path to JSON base file

Options:
--pretty Pretty-print result JSON
--rearrange-arrays Rearrange arrays to match original
```

```
bin/json-diff rearrange --help
v2.0.0 json-diff rearrange
JSON diff and apply tool for PHP, https://github.com/swaggest/json-diff
Rearrange json document in the order of another (original) json document
Usage:
json-diff rearrange <originalPath> <newPath>
originalPath Path to old (original) json file
newPath Path to new json file

Options:
--pretty Pretty-print result JSON
--rearrange-arrays Rearrange arrays to match original
```

```
bin/json-diff info --help
v2.0.0 json-diff info
JSON diff and apply tool for PHP, https://github.com/swaggest/json-diff
Show diff info for two JSON documents
Usage:
json-diff info <originalPath> <newPath>
originalPath Path to old (original) json file
newPath Path to new json file

Options:
--pretty Pretty-print result JSON
--rearrange-arrays Rearrange arrays to match original
--with-contents Add content to output
--with-paths Add paths to output
```

### Examples

Using with standard `diff`

```
json-diff rearrange ./composer.json ./composer2.json | diff ./composer.json -
3c3
< "description": "JSON diff and merge tool for PHP",
---
> "description": "JSON diff and merge tool for PHPH",
5,11d4
< "license": "MIT",
< "authors": [
< {
< "name": "Viacheslav Poturaev",
< "email": "[email protected]"
< }
< ],
25,28c18
< },
< "bin": [
< "bin/json-diff"
< ]
---
> }
```

Showing differences in `JSON` mode

```
bin/json-diff info tests/assets/original.json tests/assets/new.json --with-paths --pretty
{
"addedCnt": 4,
"modifiedCnt": 4,
"removedCnt": 3,
"addedPaths": [
"/key3/sub3",
"/key4/0/c",
"/key4/2/c",
"/key5"
],
"modifiedPaths": [
"/key1/0",
"/key3/sub1",
"/key3/sub2",
"/key4/0/a",
"/key4/1/a",
"/key4/1/b"
],
"removedPaths": [
"/key2",
"/key3/sub0",
"/key4/0/b"
]
}
```
Moved to [`swaggest/json-diff-cli`](https://github.com/swaggest/json-diff-cli)
12 changes: 0 additions & 12 deletions bin/json-diff

This file was deleted.

13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swaggest/json-diff",
"description": "JSON diff and rearrange tool for PHP",
"type": "tool",
"description": "JSON diff and rearrange library for PHP",
"type": "library",
"license": "MIT",
"authors": [
{
Expand All @@ -10,7 +10,6 @@
}
],
"require-dev": {
"php-yaoi/php-yaoi": "^1",
"phpunit/phpunit": "^4.8.23",
"phpunit/php-code-coverage": "2.2.4",
"codeclimate/php-test-reporter": "^0.4.0"
Expand All @@ -25,7 +24,9 @@
"Swaggest\\JsonDiff\\Tests\\": "tests/src"
}
},
"bin": [
"bin/json-diff"
]
"config": {
"platform": {
"php": "5.4.45"
}
}
}
Loading