Skip to content

Commit

Permalink
Merge pull request #20 from gregurcom/278-cli-env-names
Browse files Browse the repository at this point in the history
#278 cli env names
gregurco authored May 28, 2023
2 parents 8424132 + 23359dd commit 48f34b7
Showing 3 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ 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"
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.

@@ -77,7 +77,7 @@ 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.
Allowed environments are: prod, stage, dev, custom (long options: production, staging, development).

#### Update project(s)

16 changes: 16 additions & 0 deletions src/Commands/ProjectCommand.php
Original file line number Diff line number Diff line change
@@ -102,6 +102,22 @@ public function createCompare(
$params['commitSha'] = $options['commit-sha'];
}

if ($params['env1'] === 'production') {
$params['env1'] = 'prod';
} elseif ($params['env1'] === 'development') {
$params['env1'] = 'dev';
} elseif ($params['env1'] === 'staging') {
$params['env1'] = 'stage';
}

if ($params['env2'] === 'production') {
$params['env2'] = 'prod';
} elseif ($params['env2'] === 'development') {
$params['env2'] = 'dev';
} elseif ($params['env2'] === 'staging') {
$params['env2'] = 'stage';
}

$diffId = Project::compare($projectId, $params);

if (!empty($options['name'])) {
11 changes: 10 additions & 1 deletion src/Commands/ScreenshotCommand.php
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ class ScreenshotCommand extends Tasks
* @command screenshot:create
*
* @param int $projectId ID of the project
* @param string $environment Environment of the project. Can be one of "production", "staging", "development", "custom"
* @param string $environment Environment of the project. Can be one of "production", "staging", "development", "custom" (short options: "prod", "stage", "dev")
*
* @param array $options
*
@@ -35,6 +35,15 @@ public function createScreenshot($projectId, $environment, array $options = ['wa
$apiKey = Config::getConfig()['key'];

Diffy::setApiKey($apiKey);

if ($environment === 'prod') {
$environment = 'production';
} elseif ($environment === 'dev') {
$environment = 'development';
} elseif ($environment === 'stage') {
$environment = 'staging';
}

$screenshotId = Screenshot::create($projectId, $environment);

if (!empty($options['wait']) && $options['wait'] == true) {

0 comments on commit 48f34b7

Please sign in to comment.