Skip to content

Commit

Permalink
#278 cli env names
Browse files Browse the repository at this point in the history
  • Loading branch information
gregurcom committed May 28, 2023
1 parent 8424132 commit 23359dd
Show file tree
Hide file tree
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
Expand Up @@ -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.

Expand Down Expand Up @@ -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)

Expand Down
16 changes: 16 additions & 0 deletions src/Commands/ProjectCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
11 changes: 10 additions & 1 deletion src/Commands/ScreenshotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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) {
Expand Down

0 comments on commit 23359dd

Please sign in to comment.