Skip to content

Commit

Permalink
added - update composer config
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveJonesDev committed Nov 28, 2023
1 parent 0f30eb0 commit a183c10
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Run custom composer script
run: ./run-composer.sh

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- master
- develop
- trunk
- 'feature/**'
- 'release/**'
- 'hotfix/[0-9]+.[0-9]+*'
pull_request:
Expand Down Expand Up @@ -35,6 +36,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Run custom composer script
run: ./run-composer.sh

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
56 changes: 28 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"name": "equalizedigital/accesibility-checker",
"description": "Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.",
"keywords": [
"accessibility",
"accessible",
"wcag"
],
"accessibility",
"accessible",
"wcag"
],
"homepage": "https://equalizedigital.com/accessibility-checker/",
"license": "GPL-3.0-or-later",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Equalize Digital",
"homepage": "https://equalizedigital.com"
"homepage": "https://equalizedigital.com"
}
],
"type": "wordpress-plugin",
Expand All @@ -36,33 +36,33 @@
"require-dev": {
"automattic/vipwpcs": "^3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"equalizedigital/accessibility-checker-wp-env": "1.0.0",
"phpcompatibility/php-compatibility": "*",
"yoast/wp-test-utils": "^1.1.1",
"php-parallel-lint/php-parallel-lint": "^1.3"
"yoast/wp-test-utils": "^1.1.1",
"php-parallel-lint/php-parallel-lint": "^1.3",
"equalizedigital/accessibility-checker-wp-env": "1.0.0"
},
"require": {
"cbschuld/browser.php": "^1.9",
"davechild/textstatistics": "1.0.2",
"php": ">=7.4",
"composer/installers": "^1.12.0"
"composer/installers": "^1.12.0"
},
"scripts": {
"lint": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude node_modules --exclude .git"
],
"config-yoastcs" : [
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run",
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --config-set default_standard Yoast"
],
"check-cs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set testVersion 7.4-"
],
"fix-cs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"
],
"test": [
"@php ./vendor/phpunit/phpunit/phpunit"
]
}
}
"lint": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude node_modules --exclude .git"
],
"config-yoastcs": [
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run",
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --config-set default_standard Yoast"
],
"check-cs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set testVersion 7.4-"
],
"fix-cs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"
],
"test": [
"@php ./vendor/phpunit/phpunit/phpunit"
]
}
}
3 changes: 3 additions & 0 deletions run-composer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
php update-composer-config.php
composer install
25 changes: 25 additions & 0 deletions update-composer-config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Accessibility Checker pluign file.
*
* @package Accessibility_Checker
*/

// Check if running in GitHub Actions environment.
$env = getenv( 'GITHUB_ACTIONS' );

$composer_json_path = 'composer.json';
$composer_config = json_decode( file_get_contents( $composer_json_path ), true );

Check warning on line 12 in update-composer-config.php

View workflow job for this annotation

GitHub Actions / Check code style

Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

Check warning on line 12 in update-composer-config.php

View workflow job for this annotation

GitHub Actions / Check code style

file_get_contents() is uncached. If the function is being used to fetch a remote file (e.g. a URL starting with https://), please use wpcom_vip_file_get_contents() to ensure the results are cached. For more details, please see: https://docs.wpvip.com/technical-references/code-quality-and-best-practices/retrieving-remote-data/

if ( 'true' === $env ) {
// Running in GitHub Actions environment.
// Remove local specific packages for GitHub Actions environment.
unset($composer_config['require-dev']['equalizedigital/accessibility-checker-wp-env']);

Check failure on line 17 in update-composer-config.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 spaces after opening parenthesis; 0 found

Check failure on line 17 in update-composer-config.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 spaces before closing parenthesis; 0 found
} else {
// Not running in GitHub Actions, assuming local environment.
// Add your local specific packages.
$composer_config['require-dev']['equalizedigital/accessibility-checker-wp-env'] = '1.0.0';
}

file_put_contents( $composer_json_path, json_encode( $composer_config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) );

Check warning on line 24 in update-composer-config.php

View workflow job for this annotation

GitHub Actions / Check code style

File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as file_put_contents(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/

Check warning on line 24 in update-composer-config.php

View workflow job for this annotation

GitHub Actions / Check code style

json_encode() is discouraged. Use wp_json_encode() instead.

Check failure on line 24 in update-composer-config.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 blank line at end of file; 2 found

0 comments on commit a183c10

Please sign in to comment.