diff --git a/CHANGELOG.md b/CHANGELOG.md index c127155..2c65608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 1.37 + +* Update project from YAML file + ### 0.1.28 * Added the diffy screenshot:create-baseline command * Added the diffy screenshot:set-baseline command diff --git a/README.md b/README.md index d885a90..9ea801f 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ Great for building integrations for your CI/CD tools. Allows scription taking sc Download latest release from [https://github.com/DiffyWebsite/diffy-cli/releases](https://github.com/DiffyWebsite/diffy-cli/releases) page. Download just `diffy.phar` file. No need for all the source code. You can copy file to your executables so it is available everywhere. ```shell script -chmod a+x diffy.phar -cp diffy.phar /usr/local/bin/diffy +wget -O /usr/local/bin/diffy https://github.com/diffywebsite/diffy-cli/releases/latest/download/diffy.phar +chmod a+x /usr/local/bin/diffy ``` ### Installion with Composer @@ -97,7 +97,7 @@ If you want to update your config (For example, from CICD) ```shell script diffy project:update PROJECT_ID ./examples/diffy_update_project.json ``` -See the ./examples/diffy_update_project.json file for a valid config file. +See the ./examples/diffy_update_project.json or ./examples/diffy-project-projectID-demo-test-project.yaml file for a valid config file. For multiple projects ```shell script diff --git a/VERSION b/VERSION index 50140e3..9f42295 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.33 +0.1.37 diff --git a/composer.json b/composer.json index d2cb075..c909c70 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,8 @@ "consolidation/robo": "^4", "diffywebsite/diffy-php": "^1", "guzzlehttp/guzzle": "^7", - "n98/junit-xml": "^1.1" + "n98/junit-xml": "^1.1", + "symfony/yaml": "^6.4" }, "require-dev": { "g1a/composer-test-scenarios": "^2", diff --git a/custom-vs-baseline.sh b/custom-vs-baseline.sh old mode 100644 new mode 100755 index e69de29..22fb2b3 --- a/custom-vs-baseline.sh +++ b/custom-vs-baseline.sh @@ -0,0 +1,3 @@ +CUSTOM_URL="https://diffy.website" +CUSTOM_SCREENSHOT_ID=$(diffy screenshot:create 22119 custom --envUrl=${MULTIDEV_SITE_URL}) +diffy diff:create 22119 ${CUSTOM_SCREENSHOT_ID} 520974 diff --git a/examples/diffy-project-projectID-demo-test-project.yaml b/examples/diffy-project-projectID-demo-test-project.yaml new file mode 100644 index 0000000..3a46e46 --- /dev/null +++ b/examples/diffy-project-projectID-demo-test-project.yaml @@ -0,0 +1,49 @@ +basic: + name: 'Desk' + environments: + production: 'https://wordpress.diffy.website' + staging: 'http://stage.wordpress.diffy.website' + development: '' + breakpoints: + - 640 + - 1024 + - 1200 + pages: + - / + - /2019/01 + - /sample-page + - /2019/03/12/hello-world + - /category/uncategorized + - /2019/03/01/delectus-quia-esse-aut + monitoring: + days: { } + type: '' +advanced: + mask: '' + remove: '' + isolate: '' + delay: 10 + scroll: false + headers: + - { header: user-agent, value: Googlebot-Image/1.0 } + cookies: '' + custom_js: '' + custom_css: '' + mock_content: '' + login: + type: '' + click_element: false + click_element_selector: '' + login_url: '' + username: '' + password: '' + username_selector: '' + password_selector: '' + submit_selector: '' + after_login_selector: '' + performance: + workers_production: 30 + workers_nonproduction: 10 + workers_production_delay: 0 + workers_nonproduction_delay: 0 + stabilize: false diff --git a/src/Commands/ProjectCommand.php b/src/Commands/ProjectCommand.php index d2b9144..a487fd0 100644 --- a/src/Commands/ProjectCommand.php +++ b/src/Commands/ProjectCommand.php @@ -9,10 +9,10 @@ use Diffy\Screenshot; use DiffyCli\Config; use GuzzleHttp\Exception\InvalidArgumentException; +use GuzzleHttp\Utils; use Robo\Tasks; use Symfony\Component\Console\Style\SymfonyStyle; - -use function GuzzleHttp\json_decode; +use Symfony\Component\Yaml\Yaml; class ProjectCommand extends Tasks { @@ -41,7 +41,11 @@ private function isValidJsonConfig(string $configurationPath): array } try { - return json_decode($configuration, true); + if (str_ends_with($configurationPath, '.yaml')) { + return Yaml::parse($configuration, true); + } + + return Utils::jsonDecode($configuration, true); } catch (InvalidArgumentException $exception) { $this->getIO()->writeln('Configuration is not valid JSON'); @@ -171,21 +175,25 @@ public function createCompare( } /** - * Update single project configuration + * Update single project configuration from YAML file * * @command project:update * * @param int $projectId Id of the project. - * @param string $configurationPath Path to the json config file. + * @param string $configurationPath Path to the YAML config file. * - * @usage project:update 342 ./examples/diffy_update_project.json - * Updates given project ID with the diffy config. + * @usage project:update 342 ./examples/diffy_update_project.yaml + * Configuration can be downloaded from Project's settings page. * * @throws InvalidArgumentException */ public function updateProject(int $projectId, string $configurationPath) { - Project::update($projectId, $this->isValidJsonConfig($configurationPath)); + if (str_ends_with($configurationPath, '.yaml')) { + Project::updateYaml($projectId, $this->isValidJsonConfig($configurationPath)); + } else { + Project::update($projectId, $this->isValidJsonConfig($configurationPath)); + } $this->getIO()->writeln('Project ' . $projectId . ' updated.'); }