diffy-website/diffy-cli

Diffy CLI tool.

0.1.43 2025-09-24 02:39 UTC

README

Command-Line tool for interacting with Diffy.

Great for building integrations for your CI/CD tools. Allows taking screenshots, diffs, comparing environments.

Travis CI License

Usage

Manual Installation

Download the latest release from 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.

wget -O /usr/local/bin/diffy https://github.com/diffywebsite/diffy-cli/releases/latest/download/diffy.phar
chmod a+x /usr/local/bin/diffy

Installation with Composer

composer require diffy-website/diffy-cli --with-all-dependencies

Authentication

You need to obtain a Key to interact with API. This can be done from Profile.

Once you have a key -- run

diffy auth:login xxxxxxxxxxxx

This will save the key for future usages.

Commands

Take screenshots

diffy screenshot:create PROJECT_ID ENVIRONMENT

PROJECT_ID is an ID of the project. You can get it from URL of your project. ENVIRONMENT is one of "production", "staging", "development" (short options: "prod", "stage", "dev")

You can use --wait key to wait for the screenshot to be completed.

As a result, you will get an ID of the screenshot.

Compare screenshots (creating diff)

If you know your screenshots IDs the easiest would be:

diffy diff:create PROJECT_ID SCREENSHOT_ID1 SCREENSHOT_ID2

Also, you can create diff with custom name:

diffy diff:create PROJECT_ID SCREENSHOT_ID1 SCREENSHOT_ID2 --name="custom"

Shortcut to take screenshots and compare them right away

diffy project:compare PROJECT_ID production staging

or compare with baseline

diffy project:compare PROJECT_ID baseline staging

or in case of custom environments (also set the name for the diff to be "custom")

diffy project:compare PROJECT_ID prod custom --env2Url="https://custom.example.com" --name="custom"

or in case of custom environment with basic auth credentials

diffy project:compare PROJECT_ID prod custom --env2Url="https://custom.example.com" --env2User="user" --env2Pass="password"

Allowed environments are: prod, stage, dev, custom (long options: production, staging, development).

Update project(s)

If you want to update your config (For example, from CICD)

diffy project:update PROJECT_ID ./examples/project-settings.yaml

You can download project config file from Project Settings page. See https://docs.diffy.website/features/configure-project-from-yaml-file

Create project(s)

Similar you can create a project by passing the config file.

diffy project:create ./examples/diffy_create_project.yaml

Get project information

Get the full settings of the project

diffy project:get PROJECT_ID

Get list of diffs

diffy diff:list PROJECT_ID PAGE_NUMBER

PROJECT_ID is an ID of the project. You can get it from URL of your project. PAGE_NUMBER is number of the page results (starts from 0)

Baseline

There are two commands available to work with baseline set

diffy screenshot:create-baseline PROJECT_ID ENVIRONMENT # will create set of screenshots and set them as baseline right away
diffy screenshot:set-baseline PROJECT_ID SCREENSHOT_ID # set screenshots SCREENSHOT_ID as a baseline

Create screenshots from images

diffy screenshot:create-uploaded 342 ./examples/diffy_create_screenshot_upload.json

Github integration

Main documentation page http://diffy.website/documentation/github-integration

The only difference you will need to have is to pass commit sha to compare operation:

diffy project:compare PROJECT_ID prod custom --env2Url="https://custom.example.com" --commit-sha="29b872765b21387b7adfd67fd16b7f11942e1a56"

Examples

Take a look at folder with Examples. This is a collection of shell scripts that aim to give you an idea how CLI tool can be used in your CI pipelines.

Development

Prerequisites

List the things that are needed to install the software and how to install them. For most PHP projects, it should usually be sufficient to run:

composer install

If you wish to build the phar for this project, install the box phar builder via:

composer phar:install-tools

Installing

Provide a step by step series of examples that show how to install this project.

Say what the step will be. If the phar for this project is the primary output, and not a mere development utility, then perhaps the first step will be to build the phar:

composer phar:build

It may then be sufficient to install via:

cp example.phar /usr/local/bin

End with an example of getting some data out of the system or using it for a little demo.

Running the tests

The test suite may be run locally by way of some simple composer scripts:

Test Command
Run all tests composer test
PHPUnit tests composer unit
PHP linter composer lint
Code style composer cs
Fix style errors composer cbf

Deployment

Add additional notes about how to deploy this on a live system.

If your project has been set up to automatically deploy its .phar with every GitHub release, then you will be able to deploy by the following procedure:

  • Edit the VERSION file to contain the version to release, and commit the change.
  • Run composer release

Built With

List significant dependencies that developers of this project will interact with.

Contributing

Please read CONTRIBUTING.md for details on the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the releases page.

Authors

  • Yuri Gerasymov - created project from template.

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details