Skip to content

Commit 4e46096

Browse files
committed
Manually syncing internal and external repos
1 parent 464d0f2 commit 4e46096

7 files changed

Lines changed: 141 additions & 0 deletions

File tree

.githooks/pre-commit

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Get staged PHP files for PHP CodeSniffer
4+
php_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.php$')
5+
if [ -n "$php_files" ]; then
6+
echo "Running PHP CodeSniffer on the following files:"
7+
echo "$php_files"
8+
9+
echo "$php_files" | xargs vendor/bin/phpcs -d memory_limit=512M --standard=phpcs.xml.dist
10+
if [ $? -ne 0 ]; then
11+
echo "PHP CodeSniffer failed. Please fix the errors."
12+
exit 1
13+
fi
14+
fi
15+
16+
# Get staged CSS and JS files
17+
css_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '^(css/.*\.css)$')
18+
js_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '^(js/.*\.js)$')
19+
20+
# Combine CSS and JS files into a single variable
21+
all_files="$css_files $js_files"
22+
23+
# Run Prettier if there are CSS or JS files
24+
if [ -n "$all_files" ]; then
25+
echo "Running Prettier on the following files:"
26+
echo "$all_files"
27+
28+
echo "$all_files" | xargs npx prettier --write
29+
if [ $? -ne 0 ]; then
30+
echo "Prettier failed. Please fix the formatting errors."
31+
exit 1
32+
fi
33+
34+
# Add formatted files back to the staged changes
35+
echo "$all_files" | xargs git add
36+
fi
37+
38+
echo "All checks passed."
39+
exit 0

.github/workflows/main.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test-and-code-style:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
php: [8.1]
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Install dependencies
19+
run: composer install --prefer-dist
20+
21+
- name: Run tests
22+
run: vendor/bin/phpunit --bootstrap __tests__/bootstrap.php __tests__
23+
24+
- name: Run PHPCS
25+
run: vendor/bin/phpcs --standard=WordPress --extensions=php --ignore=vendor/ .

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/vendor
22
/build
33
/js/lib/node_modules
4+
/node_modules

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"tabWidth": 2,
5+
"semi": true
6+
}

package-lock.json

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "facebook-pixel-for-wordpress",
3+
"version": "1.0.0",
4+
"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)",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "GPL-2.0",
12+
"devDependencies": {
13+
"prettier": "^3.3.3"
14+
}
15+
}

phpcs.xml.dist

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="WordPress Coding Standards">
3+
<description>Coding standards for WordPress development.</description>
4+
5+
<!-- Paths to check -->
6+
<file>./</file>
7+
8+
<!-- Exclude these directories from being scanned -->
9+
<exclude-pattern>vendor/*</exclude-pattern>
10+
<exclude-pattern>node_modules/*</exclude-pattern>
11+
12+
<!-- Include WordPress coding standards -->
13+
<rule ref="WordPress-Core"/>
14+
<rule ref="WordPress-Extra"/>
15+
<rule ref="WordPress-Docs"/>
16+
17+
<!-- Set severity and error levels -->
18+
<arg name="warning-severity" value="6"/>
19+
<arg name="error-severity" value="5"/>
20+
21+
<!-- Allow parallel processing -->
22+
<arg name="parallel" value="80"/>
23+
</ruleset>

0 commit comments

Comments
 (0)