Skip to content

Commit

Permalink
Manually syncing internal and external repos
Browse files Browse the repository at this point in the history
  • Loading branch information
vahidkay-meta committed Dec 4, 2024
1 parent 464d0f2 commit 4e46096
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Get staged PHP files for PHP CodeSniffer
php_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.php$')
if [ -n "$php_files" ]; then
echo "Running PHP CodeSniffer on the following files:"
echo "$php_files"

echo "$php_files" | xargs vendor/bin/phpcs -d memory_limit=512M --standard=phpcs.xml.dist
if [ $? -ne 0 ]; then
echo "PHP CodeSniffer failed. Please fix the errors."
exit 1
fi
fi

# Get staged CSS and JS files
css_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '^(css/.*\.css)$')
js_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '^(js/.*\.js)$')

# Combine CSS and JS files into a single variable
all_files="$css_files $js_files"

# Run Prettier if there are CSS or JS files
if [ -n "$all_files" ]; then
echo "Running Prettier on the following files:"
echo "$all_files"

echo "$all_files" | xargs npx prettier --write
if [ $? -ne 0 ]; then
echo "Prettier failed. Please fix the formatting errors."
exit 1
fi

# Add formatted files back to the staged changes
echo "$all_files" | xargs git add
fi

echo "All checks passed."
exit 0
25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test

on:
push:
branches:
- main

jobs:
test-and-code-style:
runs-on: ubuntu-latest
strategy:
matrix:
php: [8.1]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: composer install --prefer-dist

- name: Run tests
run: vendor/bin/phpunit --bootstrap __tests__/bootstrap.php __tests__

- name: Run PHPCS
run: vendor/bin/phpcs --standard=WordPress --extensions=php --ignore=vendor/ .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor
/build
/js/lib/node_modules
/node_modules
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"semi": true
}
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "facebook-pixel-for-wordpress",
"version": "1.0.0",
"description": "Grow your business with Facebook for WordPress! This plugin will install a Facebook Pixel for your page so you can capture the actions people take when they interact with your page, such as Lead, ViewContent, AddToCart, InitiateCheckout and Purchase events. Version 2.0.0 also includes support for the Conversions API, which lets you send events directly from your page’s server so you can capture a more of these events when they happen. This can help you better understand your customer’s journey from the moment they show interest in your business to the moment they complete a conversion. You can use this information to create ad campaigns that are relevant to your audience. [Learn More](https://www.facebook.com/business/learn/facebook-ads-pixel)",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "GPL-2.0",
"devDependencies": {
"prettier": "^3.3.3"
}
}
23 changes: 23 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<description>Coding standards for WordPress development.</description>

<!-- Paths to check -->
<file>./</file>

<!-- Exclude these directories from being scanned -->
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>node_modules/*</exclude-pattern>

<!-- Include WordPress coding standards -->
<rule ref="WordPress-Core"/>
<rule ref="WordPress-Extra"/>
<rule ref="WordPress-Docs"/>

<!-- Set severity and error levels -->
<arg name="warning-severity" value="6"/>
<arg name="error-severity" value="5"/>

<!-- Allow parallel processing -->
<arg name="parallel" value="80"/>
</ruleset>

0 comments on commit 4e46096

Please sign in to comment.