-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from boxuk/local-wp-environment
Add a local WP environment for developing the packages
- Loading branch information
Showing
22 changed files
with
335 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/usr/bin/env bash | ||
docker-compose run --rm php composer "$@" | ||
./bin/php composer "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
PACKAGE_NAME=$1 | ||
|
||
if [ -z "$PACKAGE_NAME" ]; then | ||
echo "Usage: $0 <package-name>" | ||
exit 1 | ||
fi | ||
|
||
# Validate the package name is in kebab-case | ||
if [[ ! $PACKAGE_NAME =~ ^[a-z0-9-]+$ ]]; then | ||
echo "Package name must be in lowercase with hyphens only" | ||
exit 1 | ||
fi | ||
|
||
if [ -d "./packages/$PACKAGE_NAME" ]; then | ||
echo "Package already exists at ./packages/$PACKAGE_NAME" | ||
exit 1 | ||
fi | ||
|
||
# Convert the package name to PascalCase | ||
# Can't use `sed` as the `\U` flag is not supported on MacOS. | ||
PASCAL_PACKAGE_NAME=$(echo $PACKAGE_NAME | awk -F- '{for(i=1;i<=NF;i++){ $i=toupper(substr($i,1,1)) substr($i,2) }}1' OFS="") | ||
|
||
# Create the necessary directories etc... | ||
mkdir -p ./packages/$PACKAGE_NAME | ||
mkdir -p ./packages/$PACKAGE_NAME/src | ||
mkdir -p ./packages/$PACKAGE_NAME/tests | ||
|
||
cat <<EOT >> ./packages/$PACKAGE_NAME/Readme.md | ||
Please do not submit any Pull Requests here. They will be closed. | ||
--- | ||
Please submit your PR here instead: https://github.com/boxuk/wp-packages | ||
This repository is what we call a "subtree split": a read-only subset of that main repository. | ||
We're looking forward to your PR there! | ||
EOT | ||
|
||
touch ./packages/$PACKAGE_NAME/.deployignore | ||
|
||
cat <<EOT >> ./packages/$PACKAGE_NAME/composer.json | ||
{ | ||
"name": "boxuk/$PACKAGE_NAME", | ||
"type": "wordpress-muplugin", | ||
"autoload": { | ||
"psr-4": { | ||
"Boxuk\\\\${PASCAL_PACKAGE_NAME}\\\\": "src" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "BoxUK", | ||
"email": "developers@boxuk.com" | ||
} | ||
], | ||
"require": {} | ||
} | ||
EOT | ||
|
||
cat <<EOT >> ./packages/$PACKAGE_NAME/$PACKAGE_NAME.php | ||
<?php | ||
/** | ||
* Plugin Name: $PASCAL_PACKAGE_NAME | ||
* Description: A brief description of the plugin. | ||
* Version: 1.0.0 | ||
* Author: BoxUK | ||
* Author URI: https://boxuk.com | ||
* | ||
* @package Boxuk\\${PASCAL_PACKAGE_NAME} | ||
*/ | ||
declare( strict_types=1 ); | ||
namespace Boxuk\\${PASCAL_PACKAGE_NAME}; | ||
// Your code here | ||
EOT | ||
|
||
# Add the package to the mono-repo config. | ||
bin/composer run mono:merge | ||
|
||
# Modify the auto-load paths (the default is /packages/$PACKAGE_NAME/src), but we need it to be /plugins/$PACKAGE_NAME/src | ||
sed -i '' -e "s/packages\/$PACKAGE_NAME\/src/plugins\/$PACKAGE_NAME\/src/g" composer.json | ||
|
||
bin/composer dump-autoload | ||
|
||
echo "" | ||
echo "Package created at ./packages/$PACKAGE_NAME" | ||
echo "Please update the .github/workflows/packages.yml file to include the new package in the build process." | ||
echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env bash | ||
docker-compose run --rm nodejs "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/usr/bin/env bash | ||
docker-compose run --rm nodejs npm "$@" | ||
bin/nodejs npm "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env bash | ||
docker-compose run --rm php "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FROM wordpress:6.5.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Plugin Name: SQLite integration (Drop-in) | ||
* Version: 1.0.0 | ||
* Author: WordPress Performance Team | ||
* Author URI: https://make.wordpress.org/performance/ | ||
* | ||
* This file is auto-generated and copied from the sqlite plugin. | ||
* Please don't edit this file directly. | ||
* | ||
* @package wp-sqlite-integration | ||
*/ | ||
|
||
define( 'SQLITE_DB_DROPIN_VERSION', '1.8.0' ); | ||
|
||
// Bail early if the SQLite implementation was not located in the plugin. | ||
if ( ! file_exists( ABSPATH . 'wp-content/mu-plugins/sqlite-database-integration/wp-includes/sqlite/db.php' ) ) { | ||
return; | ||
} | ||
|
||
// Define SQLite constant. | ||
if ( ! defined( 'DATABASE_TYPE' ) ) { | ||
define( 'DATABASE_TYPE', 'sqlite' ); | ||
} | ||
|
||
// Require the implementation from the plugin. | ||
require_once ABSPATH . 'wp-content/mu-plugins/sqlite-database-integration/wp-includes/sqlite/db.php'; | ||
|
||
// Activate the performance-lab plugin if it is not already activated. | ||
add_action( | ||
'admin_footer', | ||
function () { | ||
if ( defined( 'SQLITE_MAIN_FILE' ) ) { | ||
return; | ||
} | ||
if ( ! function_exists( 'activate_plugin' ) ) { | ||
require_once ABSPATH . 'wp-admin/includes/plugin.php'; | ||
} | ||
if ( is_plugin_inactive( 'sqlite-database-integration' ) ) { | ||
activate_plugin( 'sqlite-database-integration' ); | ||
} | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
/** | ||
* A plugin loader for WordPress. | ||
* | ||
* @package BoxUK/WP | ||
*/ | ||
|
||
// Define the path to the mu-plugins directory. | ||
define( 'MU_PLUGINS_DIR', __DIR__ ); | ||
|
||
/** | ||
* Nothing fancy here. Just `require_once` the necessary plugin files. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* The base configuration for WordPress | ||
* | ||
* The wp-config.php creation script uses this file during the installation. | ||
* You don't have to use the web site, you can copy this file to "wp-config.php" | ||
* and fill in the values. | ||
* | ||
* This file contains the following configurations: | ||
* | ||
* * Database settings | ||
* * Secret keys | ||
* * Database table prefix | ||
* * ABSPATH | ||
* | ||
* @link https://wordpress.org/support/article/editing-wp-config-php/ | ||
* | ||
* @package WordPress | ||
*/ | ||
|
||
define( 'DATABASE_TYPE', 'sqlite' ); | ||
define( 'DB_DIR', '/var/www/html/wp-content/database' ); | ||
define( 'DB_FILE', 'wordpress.db' ); | ||
|
||
define( 'AUTH_KEY', 'uDh8?//l(9c$Qu`NRD4H3k426U3V}x!I#{pbFV7Z!1eT)T$[+6Go)Gpg?K5Z|R{D' ); | ||
define( 'SECURE_AUTH_KEY', 'nGAeRQI%DhdGhMoT.{Ba(&V5D[Z7FDO@NHRX_d3;q~S+jko-tsA; `+~6!<r_X>b' ); | ||
define( 'LOGGED_IN_KEY', 'cqiEHUYDtHxsqW=w|_.g{uCL2cifNJMi_WL2yf?sn)=UF+6nhO>a-qKLH75bZ)n1' ); | ||
define( 'NONCE_KEY', ';H#]ee;nLS~h l~Oy(p|1f<@-;yG1%Y{ h(P8-T<(9X+M(?uUkD)obyL+R[)<Z4z' ); | ||
define( 'AUTH_SALT', 'pjVYn-F]kG%^)##=3^Y@_bH@OW~3#fp:D;B-+#skTM{W+|MtedR|qVn%hQ3Iv2 &' ); | ||
define( 'SECURE_AUTH_SALT', ')C4@PV(d:DU0}i{,P[r.mrjfwyX!>kZvvhRW$|QZQ;S&8&Rep.N$*E938l9bxi`m' ); | ||
define( 'LOGGED_IN_SALT', '%V}O=GU*_{),8)-n-DXKhZXhqeu}lR1U0oA,#f+=7br+&g2TAE_>ZL-,ogsWuedO' ); | ||
define( 'NONCE_SALT', 'dm[=a6+2b1rHuGW=xE`#-<}<w_ -dnmdvM%:ZcxLCCPtq2>o{}NlqT>4<kL6nX-#' ); | ||
|
||
/**#@-*/ | ||
$table_prefix = 'wp_'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited | ||
define( 'WP_DEBUG', true ); | ||
define( 'WP_SCRIPT_DEBUG', true ); | ||
|
||
/** Absolute path to the WordPress directory. */ | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
define( 'ABSPATH', __DIR__ . '/' ); | ||
} | ||
|
||
/** Sets up WordPress vars and included files. */ | ||
require_once ABSPATH . 'wp-content/plugins/vendor/autoload.php'; | ||
require_once ABSPATH . 'wp-settings.php'; |
Oops, something went wrong.