Skip to content

Commit

Permalink
GL-2039: Added prompt for nodejs and php project selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
akashkska committed Feb 14, 2024
1 parent ebdefcb commit a367e98
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 10 deletions.
109 changes: 108 additions & 1 deletion src/Command/CodeStudio/CodeStudioCiCdVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,114 @@ public static function getList(): array {
/**
* @return array<mixed>
*/
public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL): array {
public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL, ?string $nodeVersion = NULL): array {
return [

Check warning on line 20 in src/Command/CodeStudio/CodeStudioCiCdVariables.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL, ?string $nodeVersion = NULL) : array { - return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; + return [['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; } /** * @return array<mixed>
[

Check warning on line 21 in src/Command/CodeStudio/CodeStudioCiCdVariables.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL, ?string $nodeVersion = NULL) : array { - return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; + return [['masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; } /** * @return array<mixed>
'key' => 'ACQUIA_APPLICATION_UUID',
'masked' => TRUE,

Check warning on line 23 in src/Command/CodeStudio/CodeStudioCiCdVariables.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "TrueValue": --- Original +++ New @@ @@ */ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL, ?string $nodeVersion = NULL) : array { - return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; + return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => false, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; } /** * @return array<mixed>
'protected' => FALSE,

Check warning on line 24 in src/Command/CodeStudio/CodeStudioCiCdVariables.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ */ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL, ?string $nodeVersion = NULL) : array { - return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; + return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => true, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; } /** * @return array<mixed>
'value' => $cloudApplicationUuid,
'variable_type' => 'env_var',
],
[

Check warning on line 28 in src/Command/CodeStudio/CodeStudioCiCdVariables.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL, ?string $nodeVersion = NULL) : array { - return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; + return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; } /** * @return array<mixed>
'key' => 'ACQUIA_CLOUD_API_TOKEN_KEY',
'masked' => TRUE,

Check warning on line 30 in src/Command/CodeStudio/CodeStudioCiCdVariables.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "TrueValue": --- Original +++ New @@ @@ */ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL, ?string $nodeVersion = NULL) : array { - return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; + return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => false, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; } /** * @return array<mixed>
'protected' => FALSE,

Check warning on line 31 in src/Command/CodeStudio/CodeStudioCiCdVariables.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ */ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL, ?string $nodeVersion = NULL) : array { - return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; + return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => true, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; } /** * @return array<mixed>
'value' => $cloudKey,
'variable_type' => 'env_var',
],
[

Check warning on line 35 in src/Command/CodeStudio/CodeStudioCiCdVariables.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL, ?string $nodeVersion = NULL) : array { - return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; + return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; } /** * @return array<mixed>
'key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET',
'masked' => TRUE,

Check warning on line 37 in src/Command/CodeStudio/CodeStudioCiCdVariables.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "TrueValue": --- Original +++ New @@ @@ */ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL, ?string $nodeVersion = NULL) : array { - return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; + return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => false, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; } /** * @return array<mixed>
'protected' => FALSE,

Check warning on line 38 in src/Command/CodeStudio/CodeStudioCiCdVariables.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ */ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL, ?string $nodeVersion = NULL) : array { - return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; + return [['key' => 'ACQUIA_APPLICATION_UUID', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudApplicationUuid, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_KEY', 'masked' => TRUE, 'protected' => FALSE, 'value' => $cloudKey, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET', 'masked' => TRUE, 'protected' => true, 'value' => $cloudSecret, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_NAME', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessTokenName, 'variable_type' => 'env_var'], ['key' => 'ACQUIA_GLAB_TOKEN_SECRET', 'masked' => TRUE, 'protected' => FALSE, 'value' => $projectAccessToken, 'variable_type' => 'env_var'], ['key' => 'PHP_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $phpVersion, 'variable_type' => 'env_var'], ['key' => 'NODE_VERSION', 'masked' => FALSE, 'protected' => FALSE, 'value' => $nodeVersion, 'variable_type' => 'env_var']]; } /** * @return array<mixed>
'value' => $cloudSecret,
'variable_type' => 'env_var',
],
[
'key' => 'ACQUIA_GLAB_TOKEN_NAME',
'masked' => TRUE,
'protected' => FALSE,
'value' => $projectAccessTokenName,
'variable_type' => 'env_var',
],
[
'key' => 'ACQUIA_GLAB_TOKEN_SECRET',
'masked' => TRUE,
'protected' => FALSE,
'value' => $projectAccessToken,
'variable_type' => 'env_var',
],
[
'key' => 'PHP_VERSION',
'masked' => FALSE,
'protected' => FALSE,
'value' => $phpVersion,
'variable_type' => 'env_var',
],
[
'key' => 'NODE_VERSION',
'masked' => FALSE,
'protected' => FALSE,
'value' => $nodeVersion,
'variable_type' => 'env_var',
],
];
}

/**
* @return array<mixed>
*/
public static function getDefaultsForNode(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $nodeVersion = NULL): array {
return [
[
'key' => 'ACQUIA_APPLICATION_UUID',
'masked' => TRUE,
'protected' => FALSE,
'value' => $cloudApplicationUuid,
'variable_type' => 'env_var',
],
[
'key' => 'ACQUIA_CLOUD_API_TOKEN_KEY',
'masked' => TRUE,
'protected' => FALSE,
'value' => $cloudKey,
'variable_type' => 'env_var',
],
[
'key' => 'ACQUIA_CLOUD_API_TOKEN_SECRET',
'masked' => TRUE,
'protected' => FALSE,
'value' => $cloudSecret,
'variable_type' => 'env_var',
],
[
'key' => 'ACQUIA_GLAB_TOKEN_NAME',
'masked' => TRUE,
'protected' => FALSE,
'value' => $projectAccessTokenName,
'variable_type' => 'env_var',
],
[
'key' => 'ACQUIA_GLAB_TOKEN_SECRET',
'masked' => TRUE,
'protected' => FALSE,
'value' => $projectAccessToken,
'variable_type' => 'env_var',
],
[
'key' => 'NODE_VERSION',
'masked' => FALSE,
'protected' => FALSE,
'value' => $nodeVersion,
'variable_type' => 'env_var',
],
];
}

/**
* @return array<mixed>
*/
public static function getDefaultsForPhp(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL): array {
return [
[
'key' => 'ACQUIA_APPLICATION_UUID',
Expand Down
71 changes: 62 additions & 9 deletions src/Command/CodeStudio/CodeStudioWizardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,30 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// So we reauthenticate to be sure we're using the provided credentials.
$this->reAuthenticate($cloudKey, $cloudSecret, $this->cloudCredentials->getBaseUri(), $this->cloudCredentials->getAccountsUri());

$phpVersions = [
'PHP_version_8.1' => "8.1",
'PHP_version_8.2' => "8.2",
$projectType = [
'Drupal_project',
'Node_project',
];
$project = $this->io->choice('Select a PHP version', array_values($phpVersions), $phpVersions['PHP_version_8.1']);
$project = array_search($project, $phpVersions, TRUE);
$phpVersion = $phpVersions[$project];
$projectSelected = $this->io->choice('Select a project type', $projectType, $projectType[0]);
echo "Selected project is, $projectSelected";

if ($projectSelected == 'Drupal_project') {
$phpVersions = [
'PHP_version_8.1' => "8.1",
'PHP_version_8.2' => "8.2",
];
$project = $this->io->choice('Select a PHP version', array_values($phpVersions), $phpVersions['PHP_version_8.1']);
$project = array_search($project, $phpVersions, TRUE);
$phpVersion = $phpVersions[$project];
} elseif ($projectSelected == 'Node_project') {
$nodeVersions = [
'NODE_version_18.17.1' => "18.17.1",
'NODE_version_20.5.1' => "20.5.1",
];
$project = $this->io->choice('Select a NODE version', array_values($nodeVersions), $nodeVersions['NODE_version_20.5.1']);
$project = array_search($project, $nodeVersions, TRUE);
$nodeVersion = $nodeVersions[$project];
}

$appUuid = $this->determineCloudApplication();

Expand Down Expand Up @@ -97,7 +114,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$projectAccessTokenName = 'acquia-codestudio';
$projectAccessToken = $this->createProjectAccessToken($project, $projectAccessTokenName);
$this->updateGitLabProject($project);
$this->setGitLabCiCdVariables($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $phpVersion);
if ($projectSelected == 'Drupal_project') {
$this->setGitLabCiCdVariablesForPhpProject($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $phpVersion);

} elseif ($projectSelected == 'Node_project') {
$this->setGitLabCiCdVariablesForNodeProject($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $nodeVersion);
}
$this->createScheduledPipeline($project);

$this->io->success([
Expand Down Expand Up @@ -163,9 +185,37 @@ private function createProjectAccessToken(array $project, string $projectAccessT
return $projectAccessToken['token'];
}

private function setGitLabCiCdVariables(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken, string $phpVersion): void {
private function setGitLabCiCdVariablesForPhpProject(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken, string $phpVersion ): void {
$this->io->writeln("Setting GitLab CI/CD variables for {$project['path_with_namespace']}..");
$gitlabCicdVariables = CodeStudioCiCdVariables::getDefaultsForPhp($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $phpVersion);
$gitlabCicdExistingVariables = $this->gitLabClient->projects()
->variables($project['id']);
$gitlabCicdExistingVariablesKeyed = [];
foreach ($gitlabCicdExistingVariables as $variable) {
$key = $variable['key'];
$gitlabCicdExistingVariablesKeyed[$key] = $variable;
}

foreach ($gitlabCicdVariables as $variable) {
if ($variable['key'] === 'NODE_VERSION') {
continue;
}
$this->checklist->addItem("Setting CI/CD variable <comment>{$variable['key']}</comment>");
if (!array_key_exists($variable['key'], $gitlabCicdExistingVariablesKeyed)) {
$this->gitLabClient->projects()
->addVariable($project['id'], $variable['key'], $variable['value'], $variable['protected'], NULL, ['masked' => $variable['masked'], 'variable_type' => $variable['variable_type']]);
}
else {
$this->gitLabClient->projects()
->updateVariable($project['id'], $variable['key'], $variable['value'], $variable['protected'], NULL, ['masked' => $variable['masked'], 'variable_type' => $variable['variable_type']]);
}
$this->checklist->completePreviousItem();
}
}

private function setGitLabCiCdVariablesForNodeProject(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken, string $nodeVersion ): void {
$this->io->writeln("Setting GitLab CI/CD variables for {$project['path_with_namespace']}..");
$gitlabCicdVariables = CodeStudioCiCdVariables::getDefaults($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $phpVersion);
$gitlabCicdVariables = CodeStudioCiCdVariables::getDefaultsForNode($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $nodeVersion);
$gitlabCicdExistingVariables = $this->gitLabClient->projects()
->variables($project['id']);
$gitlabCicdExistingVariablesKeyed = [];
Expand All @@ -175,6 +225,9 @@ private function setGitLabCiCdVariables(array $project, string $cloudApplication
}

foreach ($gitlabCicdVariables as $variable) {
if ($variable['key'] === 'PHP_VERSION') {
continue;
}
$this->checklist->addItem("Setting CI/CD variable <comment>{$variable['key']}</comment>");
if (!array_key_exists($variable['key'], $gitlabCicdExistingVariablesKeyed)) {
$this->gitLabClient->projects()
Expand Down

0 comments on commit a367e98

Please sign in to comment.