Skip to content

Commit 5998cc1

Browse files
committed
#618 project settings yaml
1 parent 0d6bd07 commit 5998cc1

5 files changed

Lines changed: 55 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ If you want to update your config (For example, from CICD)
9797
```shell script
9898
diffy project:update PROJECT_ID ./examples/diffy_update_project.json
9999
```
100-
See the ./examples/diffy_update_project.json file for a valid config file.
100+
See the ./examples/diffy_update_project.json or ./examples/diffy_update_project.yaml file for a valid config file.
101101

102102
For multiple projects
103103
```shell script

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"consolidation/robo": "^4",
2121
"diffywebsite/diffy-php": "^1",
2222
"guzzlehttp/guzzle": "^7",
23-
"n98/junit-xml": "^1.1"
23+
"n98/junit-xml": "^1.1",
24+
"symfony/yaml": "^6.4"
2425
},
2526
"require-dev": {
2627
"g1a/composer-test-scenarios": "^2",

examples/diffy_update_project.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Your project name
2+
breakpoints:
3+
- 320
4+
- 1024
5+
- 1920
6+
- 333
7+
production: https://your-site.com
8+
staging: https://user:password@staging.your-site.com
9+
development: https://user:password@dev.your-site.com
10+
urls:
11+
- https://your-site.com/faq
12+
- https://your-site.com/questions
13+
- https://your-site.com/news
14+
schedule:
15+
type: ''
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'1':
2+
name: Your project1 name
3+
breakpoints:
4+
- 320
5+
- 1024
6+
- 1920
7+
production: https://your-site1.com
8+
staging: https://user1:password1@staging.your-site1.com
9+
development: https://user1:password1@dev.your-site1.com
10+
urls:
11+
- https://your-site1.com/faq
12+
- https://your-site1.com/questions
13+
- https://your-site1.com/news
14+
schedule:
15+
type: ''
16+
'2':
17+
name: Your project2 name
18+
breakpoints:
19+
- 320
20+
- 1024
21+
- 1920
22+
production: https://your-site2.com
23+
staging: https://user2:password2@staging.your-site2.com
24+
development: https://user2:password2@dev.your-site2.com
25+
urls:
26+
- https://your-site2.com/faq
27+
- https://your-site2.com/questions
28+
- https://your-site2.com/news
29+
schedule:
30+
type: ''

src/Commands/ProjectCommand.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
use Diffy\Screenshot;
1010
use DiffyCli\Config;
1111
use GuzzleHttp\Exception\InvalidArgumentException;
12+
use GuzzleHttp\Utils;
1213
use Robo\Tasks;
1314
use Symfony\Component\Console\Style\SymfonyStyle;
14-
15-
use function GuzzleHttp\json_decode;
15+
use Symfony\Component\Yaml\Yaml;
1616

1717
class ProjectCommand extends Tasks
1818
{
@@ -41,7 +41,11 @@ private function isValidJsonConfig(string $configurationPath): array
4141
}
4242

4343
try {
44-
return json_decode($configuration, true);
44+
if (str_ends_with($configurationPath, '.yaml')) {
45+
return Yaml::parse($configuration, true);
46+
}
47+
48+
return Utils::jsonDecode($configuration, true);
4549
} catch (InvalidArgumentException $exception) {
4650
$this->getIO()->writeln('<error>Configuration is not valid JSON<error>');
4751

0 commit comments

Comments
 (0)