Skip to content

Commit aa9cdc4

Browse files
committed
Updates to scaffold repo
1 parent 6c043af commit aa9cdc4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+12227
-363
lines changed

.github/chatmodes/chatmodes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ I'm your WordPress block theme development assistant for **{{theme_name}}**. I c
105105

106106
- `{{theme_slug}}_setup` — Theme setup
107107
- `{{theme_slug}}_enqueue_assets` — Asset loading
108-
- `{{theme_slug}}_customize_register`Customizer options
108+
- `{{theme_slug}}_register_pattern_categories`Block pattern categories
109109

110110
---
111111

.github/instructions/playwright-tests.instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
- Integrate Playwright into CI/CD.
2626

2727
## WordPress Theme Testing
28-
- Cover block registration, rendering, customizer options, frontend/backend appearance, accessibility, device compatibility.
28+
- Cover block registration, rendering, pattern functionality, frontend/backend appearance, accessibility, device compatibility.
2929
- Reference: [Theme Testing](https://developer.wordpress.org/themes/releasing-your-theme/testing/)
3030

3131
## Related Instructions

.github/workflows/ci.yml

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
lint:
1717
name: Code Quality & Linting
1818
runs-on: ubuntu-latest
19-
19+
2020
steps:
2121
- name: Checkout code
2222
uses: actions/checkout@v4
@@ -52,12 +52,12 @@ jobs:
5252
test:
5353
name: Run Tests
5454
runs-on: ubuntu-latest
55-
55+
5656
strategy:
5757
matrix:
5858
php-version: [8.0, 8.1, 8.2]
5959
wp-version: [latest, 6.4, 6.5]
60-
60+
6161
steps:
6262
- name: Checkout code
6363
uses: actions/checkout@v4
@@ -95,7 +95,7 @@ jobs:
9595
runs-on: ubuntu-latest
9696
needs: [lint, test]
9797
if: github.event_name == 'release'
98-
98+
9999
steps:
100100
- name: Checkout code
101101
uses: actions/checkout@v4
@@ -129,11 +129,45 @@ jobs:
129129
asset_name: {{theme_slug}}-${{ github.event.release.tag_name }}.zip
130130
asset_content_type: application/zip
131131

132+
name: build-files
133+
path: build/
134+
135+
security-audit:
136+
name: Security Audit
137+
runs-on: ubuntu-latest
138+
139+
steps:
140+
- name: Checkout code
141+
uses: actions/checkout@v4
142+
143+
- name: Setup Node.js
144+
uses: actions/setup-node@v4
145+
with:
146+
node-version: 18
147+
cache: 'npm'
148+
149+
- name: Install dependencies
150+
run: npm ci
151+
152+
- name: Run npm audit
153+
run: |
154+
echo "🔒 Running security audit..."
155+
npm audit --audit-level=moderate --production || {
156+
echo "❌ Security vulnerabilities detected."
157+
echo "Run 'npm audit' locally for details."
158+
exit 1
159+
}
160+
161+
- name: Check for outdated dependencies
162+
run: |
163+
echo "📦 Checking for outdated dependencies..."
164+
npm outdated || true
165+
132166
e2e:
133167
name: End-to-End Tests
134168
runs-on: ubuntu-latest
135169
needs: [lint]
136-
170+
137171
steps:
138172
- name: Checkout code
139173
uses: actions/checkout@v4
@@ -163,8 +197,8 @@ jobs:
163197
accessibility:
164198
name: Accessibility Tests
165199
runs-on: ubuntu-latest
166-
needs: [lint]
167-
200+
needs: [lint, security-audit]
201+
168202
steps:
169203
- name: Checkout code
170204
uses: actions/checkout@v4

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ public/
88
build/
99
dist/
1010

11+
# Translation files (keep .pot, ignore compiled)
12+
languages/*.mo
13+
!languages/.gitkeep
14+
1115
# Cache and temp files
1216
.cache/
1317
.tmp/

.husky/pre-commit

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env sh
2+
3+
# Pre-commit hook for {{theme_slug}} theme
4+
# This hook runs before each commit to ensure code quality
5+
6+
. "$(dirname -- "$0")/_/husky.sh"
7+
8+
echo "🔍 Running pre-commit checks for {{theme_name}}..."
9+
10+
# Run JavaScript linting
11+
echo "🟡 Linting JavaScript..."
12+
npm run lint:js || {
13+
echo "❌ JavaScript linting failed. Please fix the issues and try again."
14+
exit 1
15+
}
16+
17+
# Run CSS linting
18+
echo "🟡 Linting CSS..."
19+
npm run lint:css || {
20+
echo "❌ CSS linting failed. Please fix the issues and try again."
21+
exit 1
22+
}
23+
24+
# Run PHP linting (if composer is available)
25+
if command -v composer &> /dev/null; then
26+
echo "🟡 Linting PHP..."
27+
composer run lint || {
28+
echo "❌ PHP linting failed. Please fix the issues and try again."
29+
exit 1
30+
}
31+
else
32+
echo "⚠️ Skipping PHP linting (Composer not available)"
33+
fi
34+
35+
# Run security audit
36+
echo "🔒 Running security audit..."
37+
npm audit --audit-level=high --production || {
38+
echo "⚠️ Security vulnerabilities detected (high or critical)."
39+
echo "Run 'npm audit' for details or 'npm audit fix' to attempt automatic fixes."
40+
echo "To bypass this check (not recommended), use: git commit --no-verify"
41+
exit 1
42+
}
43+
44+
echo "✅ All pre-commit checks passed!"

.postcss.config.cjs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,35 @@
1+
/**
2+
* PostCSS Configuration for {{theme_name}}
3+
*
4+
* PostCSS processes CSS files during the build process:
5+
* - Autoprefixer: Adds vendor prefixes based on browserslist config
6+
* - cssnano: Minifies CSS for production builds
7+
*
8+
* This configuration is automatically used by wp-scripts when compiling Sass files.
9+
*
10+
* @package {{theme_name}}
11+
* @since {{version}}
12+
*/
13+
114
module.exports = {
215
plugins: [
16+
// Add vendor prefixes automatically based on .browserslistrc.
317
require( 'autoprefixer' ),
18+
19+
// Minify CSS for production builds only.
20+
// wp-scripts automatically applies this based on NODE_ENV.
421
require( 'cssnano' )( {
5-
preset: 'default',
22+
preset: [
23+
'default',
24+
{
25+
// Preserve important comments (like licenses).
26+
discardComments: {
27+
removeAll: false,
28+
},
29+
// Normalize whitespace but keep readability in development.
30+
normalizeWhitespace: process.env.NODE_ENV === 'production',
31+
},
32+
],
633
} ),
734
],
835
};

.webpack.config.cjs

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* Webpack Configuration for {{theme_name}}
3+
*
4+
* @package {{theme_name}}
5+
* @since {{version}}
6+
*/
7+
18
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
29
const path = require( 'path' );
310

@@ -10,7 +17,7 @@ module.exports = {
1017
'editor-style': './src/css/editor.scss',
1118
},
1219
output: {
13-
path: path.resolve( process.cwd(), 'public' ),
20+
path: path.resolve( process.cwd(), 'build' ),
1421
filename: 'js/[name].js',
1522
clean: true,
1623
},
@@ -19,19 +26,18 @@ module.exports = {
1926
rules: [
2027
...defaultConfig.module.rules,
2128
{
22-
test: /\.scss$/,
23-
use: [
24-
'style-loader',
25-
'css-loader',
26-
{
27-
loader: 'sass-loader',
28-
options: {
29-
sassOptions: {
30-
includePaths: [ 'src/css' ],
31-
},
32-
},
33-
},
34-
],
29+
test: /\.(png|jpe?g|gif|svg)$/i,
30+
type: 'asset/resource',
31+
generator: {
32+
filename: 'images/[name][ext]',
33+
},
34+
},
35+
{
36+
test: /\.(woff|woff2|eot|ttf|otf)$/i,
37+
type: 'asset/resource',
38+
generator: {
39+
filename: 'fonts/[name][ext]',
40+
},
3541
},
3642
],
3743
},
@@ -40,19 +46,32 @@ module.exports = {
4046
alias: {
4147
...defaultConfig.resolve.alias,
4248
'@': path.resolve( __dirname, 'src' ),
49+
'@css': path.resolve( __dirname, 'src/css' ),
50+
'@js': path.resolve( __dirname, 'src/js' ),
4351
},
4452
},
4553
optimization: {
4654
...defaultConfig.optimization,
4755
splitChunks: {
48-
chunks: 'all',
4956
cacheGroups: {
50-
vendor: {
51-
test: /[\\/]node_modules[\\/]/,
52-
name: 'vendors',
57+
style: {
58+
name: 'style',
59+
test: /\.css$/,
60+
chunks: 'all',
61+
enforce: true,
62+
},
63+
editor: {
64+
name: 'editor-style',
65+
test: /editor\.scss$/,
5366
chunks: 'all',
67+
enforce: true,
5468
},
5569
},
5670
},
5771
},
72+
performance: {
73+
...defaultConfig.performance,
74+
maxAssetSize: 512000,
75+
maxEntrypointSize: 512000,
76+
},
5877
};

README.md

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,21 @@ A modern WordPress block theme supporting Full Site Editing (FSE), built with mu
2929
### Development Installation
3030

3131
1. Clone this repository:
32+
3233
```bash
3334
git clone {{theme_repo_url}}
3435
cd {{theme_slug}}
3536
```
3637

3738
2. Install dependencies:
39+
3840
```bash
3941
npm install
4042
composer install
4143
```
4244

4345
3. Build assets:
46+
4447
```bash
4548
npm run build
4649
```
@@ -65,19 +68,55 @@ composer install
6568
npm run start
6669
```
6770

71+
### Build Process
72+
73+
This theme uses `@wordpress/scripts` for a modern build workflow:
74+
75+
- **Compilation**: Modern JavaScript (ESNext/JSX) → Browser-compatible code via Babel
76+
- **Bundling**: Multiple files combined into optimized bundles via webpack
77+
- **Sass Compilation**: `.scss` files compiled to standard CSS
78+
- **Code Minification**: JavaScript (Terser) and CSS (cssnano) optimization
79+
- **Code Linting**: ESLint for JavaScript, Stylelint for CSS
80+
- **Code Formatting**: Prettier for consistent styling
81+
82+
**Documentation**:
83+
84+
- 📖 [Build Process Guide](docs/BUILD-PROCESS.md) - Complete build documentation
85+
- 📖 [wp-scripts Configuration](docs/WP-SCRIPTS-CONFIGURATION.md) - Detailed setup guide
86+
- 📖 [Quick Reference](docs/WP-SCRIPTS-QUICK-REFERENCE.md) - Common tasks and commands
87+
- 📖 [Summary](docs/WP-SCRIPTS-SUMMARY.md) - Configuration summary
88+
6889
### Available Scripts
6990

70-
- `npm run start` - Start development mode with hot reloading
71-
- `npm run build` - Build for production
72-
- `npm run build:production` - Build optimized for production
73-
- `npm run lint` - Run all linters
74-
- `npm run lint:js` - Lint JavaScript
75-
- `npm run lint:css` - Lint CSS
76-
- `npm run lint:php` - Lint PHP
77-
- `npm run test` - Run all tests
78-
- `npm run test:js` - Run JavaScript tests
79-
- `npm run test:php` - Run PHP tests
80-
- `npm run test:e2e` - Run end-to-end tests
91+
#### Build Commands
92+
93+
- `npm run start` - Start development mode with hot reloading and watch mode
94+
- `npm run build` - Build optimized production assets
95+
- `npm run build:production` - Alternative production build
96+
97+
#### Code Quality
98+
99+
- `npm run lint` - Run all linters (JavaScript, CSS, PHP)
100+
- `npm run lint:js` - Lint JavaScript files
101+
- `npm run lint:js:fix` - Auto-fix JavaScript issues
102+
- `npm run lint:css` - Lint CSS/Sass files
103+
- `npm run lint:css:fix` - Auto-fix CSS issues
104+
- `npm run lint:php` - Lint PHP files
105+
- `npm run format` - Format all files with Prettier
106+
107+
#### Testing
108+
109+
- `npm run test` - Run all tests (JavaScript + PHP)
110+
- `npm run test:js` - Run JavaScript unit tests
111+
- `npm run test:js:watch` - Run Jest in watch mode
112+
- `npm run test:php` - Run PHP unit tests
113+
- `npm run test:e2e` - Run end-to-end tests with Playwright
114+
115+
#### Internationalization
116+
117+
- `npm run makepot` - Generate translation POT file
118+
- `npm run makejson` - Generate JSON translation files
119+
- `npm run i18n` - Complete i18n workflow (makepot + makejson)
81120

82121
### Theme Structure
83122

@@ -124,6 +163,7 @@ This theme uses mustache templates for easy customization. Key variables include
124163
### Customizing Colors and Typography
125164

126165
Edit `theme.json` to customize:
166+
127167
- Color palette
128168
- Typography settings
129169
- Spacing scale
@@ -158,6 +198,7 @@ Please read our [Contributing Guidelines](CONTRIBUTING.md) for more details.
158198
## Support
159199

160200
- Documentation: [Full documentation]({{docs_url}})
201+
- Internationalization: [i18n Guide](docs/INTERNATIONALIZATION.md)
161202
- Issues: [GitHub Issues]({{theme_repo_url}}/issues)
162203
- Community: [WordPress.org Support](https://wordpress.org/support/theme/{{theme_slug}})
163204

0 commit comments

Comments
 (0)