Update build system to be compatible with plugin-check branch

This commit is contained in:
2025-04-07 22:43:53 +01:00
parent f643f43481
commit 4594eeb7a1
3 changed files with 99 additions and 8 deletions

View File

@ -55,22 +55,43 @@ jobs:
echo "All version numbers match: ${{ env.VERSION }}"
- name: Generate translation files
- name: Choose build method
id: build_method
run: |
# Check if we have TypeScript files
if ls assets/js/*.ts &> /dev/null; then
echo "USE_MODERN_BUILD=true" >> $GITHUB_ENV
echo "Using modern build process with TypeScript"
else
echo "USE_MODERN_BUILD=false" >> $GITHUB_ENV
echo "Using compatibility build process"
fi
- name: Modern Build - Generate translation files
if: env.USE_MODERN_BUILD == 'true'
run: npm run translations
- name: Process CSS and JS
- name: Modern Build - Process CSS and JS
if: env.USE_MODERN_BUILD == 'true'
run: |
npm run css
npm run js
- name: Create ZIP file
- name: Modern Build - Create ZIP file
if: env.USE_MODERN_BUILD == 'true'
run: npm run zip
- name: Compatibility Build - Run build process
if: env.USE_MODERN_BUILD == 'false'
run: npm run build:compat
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
files: build/wp-multisite-waas-${{ env.VERSION }}.zip
files: |
build/wp-multisite-waas-${{ env.VERSION }}.zip
wp-multisite-waas.zip
name: WP Multisite WaaS ${{ env.VERSION }}
draft: false
prerelease: false

53
BUILD-README.md Normal file
View File

@ -0,0 +1,53 @@
# Build Process Documentation
This document outlines the different build approaches available in the WP Multisite WaaS plugin and how to use them.
## Modern Build Process
The modern build process uses TypeScript, SASS, and modern JavaScript tooling to compile and optimize assets.
### Commands
- `npm run build` - Main build command that runs clean, translations, CSS, and JS processing
- `npm run css` - Compiles SASS to CSS and minifies it
- `npm run js` - Compiles TypeScript to JavaScript and minifies it
- `npm run translations` - Generates translation files
- `npm run lint` - Runs linting for PHP, JS, and CSS
- `npm run test` - Runs Jest tests
- `npm run prepare-release` - Runs build, lint, and test for release preparation
- `npm run zip` - Creates a ZIP file for distribution
### When to use
Use this build process during active development when working with TypeScript files and modern tooling.
## Compatibility Build Process
The compatibility build process is simpler and uses more basic tools like uglify-js and cleancss for direct minification without compilation steps.
### Commands
- `npm run build:compat` - Main compatibility build command
- `npm run build:dev:compat` - Development version of the compatibility build
- `npm run uglify` - Minifies JavaScript files
- `npm run cleancss:compat` - Minifies CSS files
- `npm run makepot` - Generates translation files
- `npm run archive` - Creates a ZIP file using composer
### When to use
Use this build process when working with the plugin-check branch or when you need a simpler build process without TypeScript compilation.
## GitHub Actions Workflow
The GitHub Actions workflow is designed to automatically detect which build process to use based on the presence of TypeScript files. If TypeScript files are detected, it uses the modern build process; otherwise, it falls back to the compatibility build process.
## Merging branches
When merging branches that use different build approaches:
1. Keep both sets of build scripts in package.json
2. The GitHub Actions workflow will automatically detect and use the appropriate build process
3. For local development, choose the build process that matches your current work
This dual approach ensures compatibility with both the modern toolchain and the simpler plugin-check approach.

View File

@ -1,7 +1,9 @@
{
"name": "wp-multisite-waas",
"version": "2.3.4",
"title": "WP Multisite WaaS",
"description": "The Complete Network Solution for transforming your WordPress Multisite into a Website as a Service (WaaS) platform",
"homepage": "https://wpmultisitewaas.org/",
"main": "index.js",
"scripts": {
"start": "wp-scripts start",
@ -13,14 +15,26 @@
"js": "npm run js:compile && npm run js:minify",
"js:compile": "tsc -p tsconfig.json",
"js:minify": "terser assets/js/*.js --compress --mangle --output dist/js/ --source-map \"root='../assets/js',url='[name].min.js.map'\"",
"translations": "wp i18n make-pot . lang/wp-multisite-waas.pot --include=\"**/*.php\" --exclude=\"vendor,node_modules,tests\"",
"translations": "wp i18n make-pot ./ lang/wp-multisite-waas.pot --include=\"**/*.php\" --exclude=\"vendor,node_modules,tests\"",
"lint:php": "composer run-script phpcs",
"lint:js": "eslint assets/js/**/*.js assets/js/**/*.ts",
"lint:css": "stylelint assets/css/**/*.scss",
"lint": "npm run lint:php && npm run lint:js && npm run lint:css",
"test": "jest",
"prepare-release": "npm run build && npm run lint && npm run test",
"zip": "npm run build && bash ./bin/create-zip.sh"
"zip": "npm run build && bash ./bin/create-zip.sh",
"prebuild:compat": "composer install --no-dev",
"prebuild:dev:compat": "composer install",
"build:compat": "npm run uglify && npm run makepot && npm run cleancss:compat && npm run archive",
"build:dev:compat": "npm run uglify && npm run makepot && npm run cleancss:compat",
"archive": "composer archive --file=$npm_package_name --format=zip",
"postarchive": "rm -rf $npm_package_name && unzip $npm_package_name.zip -d $npm_package_name && rm $npm_package_name.zip && zip -r $npm_package_name.zip $npm_package_name && rm -rf $npm_package_name",
"preuglify": "rm -f assets/js/*.min.js",
"uglify": "for f in assets/js/*.js; do file=${f%.js}; node_modules/.bin/uglifyjs $f -c -m > $file.min.js; done",
"precleancss:compat": "rm -f assets/css/*.min.css",
"cleancss:compat": "for f in assets/css/*.css; do file=${f%.css}; node_modules/.bin/cleancss -o $file.min.css $f; done",
"makepot": "wp i18n make-pot ./ lang/$npm_package_name.pot --exclude=node_modules,tests,docs,assets/js/lib"
},
"repository": {
"type": "git",
@ -36,7 +50,9 @@
"bugs": {
"url": "https://github.com/wpallstars/wp-multisite-waas/issues"
},
"homepage": "https://github.com/wpallstars/wp-multisite-waas#readme",
"config": {
"translate": true
},
"devDependencies": {
"@types/jest": "^29.5.3",
"@types/node": "^20.4.5",
@ -52,6 +68,7 @@
"stylelint-config-standard-scss": "^10.0.0",
"terser": "^5.19.2",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
"typescript": "^5.1.6",
"uglify-js": "^3.19.3"
}
}