Skip to content

Commit 4531d38

Browse files
committed
Adds development section to readme
1 parent a3f630a commit 4531d38

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,92 @@ Markdown Table
9393
|------------------|--------|---------|---------|
9494
| phpspec/php-diff | v1.0.2 | REMOVED | |
9595

96+
Development
97+
===========
98+
99+
New features are always welcome! Follow these guidelines
100+
101+
- Try to match the style of the code that already exists, even if it isn't _your_ style (sorry!).
102+
- Make sure there is a way to test the feature.
103+
- Test with PHP 5.3 (I'm serious!), >=5.4<7, 7.current. Docker is helpful, particularly for the older versions. Just run the ubuntu:12.04 image and install php for 5.3 and 14.04 for 5.6. I can help if you're having trouble.
104+
105+
To run using the test data simply point the `--to` and `--from` args at the lock files,
106+
107+
```php
108+
php ./composer-lock-diff --from ./test-data/composer.from.lock --to ./test-data/composer.to.lock
109+
```
110+
111+
Docker is very helpful for targeting a specific version of php and/or composer,
112+
113+
```php
114+
docker run --rm -it -v "$PWD":/src -w /src php:7.4.2 \
115+
php ./composer-lock-diff --from ./test-data/composer.from.lock --to ./test-data/composer.to.lock
116+
```
117+
118+
Sometimes you want to test the git related functions. To do that first I make a temporary repo. Then I copy into it `test-data/composer.from.lock` as `composer.lock` to set the previous state and `test-data/composer.to.json` as `composer.json` for the future state. I commit those then run `composer-lock-diff` with the options I want to test and visually inspect the results.
119+
120+
```bash
121+
mkdir tmp && cd tmp
122+
git init
123+
cp ../test-data/composer.to.json composer.json
124+
cp ../test-data/composer.from.lock composer.lock
125+
git add .
126+
git commit -m "initial"
127+
128+
composer update
129+
# or
130+
docker run --rm -it -v "$PWD":/src -w /src composer:latest php composer update
131+
132+
php ../composer-lock-diff
133+
134+
# or, if you want to use docker, you'll need git
135+
cd ..
136+
docker run --rm -it -v "$PWD":/src -w /src php:7.4.2 bash
137+
apt-get update && apt-get install -y git
138+
# You may want composer as well,
139+
curl -OL https://getcomposer.org/download/1.9.3/composer.phar
140+
cd tmp
141+
php ../composer.phar update
142+
php ../composer-lock-diff
143+
```
144+
145+
Add a test case to test-data/
146+
-----------------------------
147+
148+
- Make a new, temporary git repo in `./tmp`
149+
- Copy `../test-data/composer.from.json` as `composer.json` and `../test-data/composer.from.lock` as `composer.lock`.
150+
- Commit them.
151+
- Run `composer install`
152+
- The generated `composer.lock` should look similar to `../test-data/composer.from.lock` but there will be differences due to transient dependencies. No real way around that. Use `composer-lock-diff` to make sure none of the named packages change versions.
153+
- Add your _pre_ case to `composer.json`. Use an exact version.
154+
- Generate a new lock file. Commit it.
155+
- Copy `composer.json` to `../test-data/composer.from.json` and `composer.lock` to `composer.from.lock`.
156+
- Copy `../test-data/composer.to.json` as `composer.json`.
157+
- Add your _post_ case to `composer.json`. Again, exact versions are best.
158+
- Generate a new lock file.
159+
- Use composer-lock-diff to test your feature.
160+
- When you're happy with it, copy `composer.json` to `../test-data/composer.to.json` and `composer.lock` to `../test-data/composer.to.lock`.
161+
162+
Test Cases
163+
----------
164+
165+
- `comopser-lock-diff` # no args
166+
- `composer-lock-diff --from ./test-data/composer.from.lock --to ./test-data/composer.to.lock`
167+
- `composer-lock-diff --path ./test-data/`
168+
- `composer-lock-diff --from <git ref>` # this gets tested with 'no args'
169+
- `composer-lock-diff --from <git ref with filename>`
170+
- `composer-lock-diff --to <git ref>`
171+
- `composer-lock-diff --to <git ref with filename>`
172+
- `composer-lock-diff --only-dev`
173+
- `composer-lock-diff --only-prod`
174+
- `composer-lock-diff --no-links`
175+
- `composer-lock-diff --json`
176+
- `composer-lock-diff --json --pretty`
177+
- `composer-lock-diff --md`
178+
- `composer-lock-diff --md --no-links`
179+
180+
If anyone can help test with Windows that would be very much appreciated!
181+
96182
Contributors
97183
============
98184

0 commit comments

Comments
 (0)