Skip to content

Commit

Permalink
Setup WP Env
Browse files Browse the repository at this point in the history
  • Loading branch information
jdamner committed May 29, 2024
1 parent e8171a1 commit 117fa9c
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 18 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ node_modules
/packages/*/build
.turbo
/composer.lock

# Docker WP Image tends to add these plugins...
packages/akismet
packages/hello.php
packages/index.php

# MU-Plugins & Themes are managed via composer
/docker/wordpress/mu-plugins/*
/docker/wordpress/themes/*
!/docker/wordpress/mu-plugins/plugin-loader.php
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ All packages need to have 100% test coverage. During CI they will be tested for

If your package requires javascript, you can also setup a `package.json` file in the root of the package. Much like `composer.json`, this will be merged automatically at the root level.

To run `npm` commands directly in your package run `bin/npm -w pacakges/<package-name>` with your command. For example `bin/npm -w packages/iconography run test` would run tests specifically in the iconography package.
To run `npm` commands directly in your package run `bin/npm -w packages/<package-name>` with your command. For example `bin/npm -w packages/iconography run test` would run tests specifically in the iconography package.

Commands can also be run globally across all packages using `turbo`. This is setup so that if you run `bin/npm run test` it will run test in every package that has a `pacakge.json` file with a `test` script. You should try to keep naming consistent across packages to support this work. All currently supported scripts in `turbo` are listed in the `turbo.json` file at the root.
Commands can also be run globally across all packages using `turbo`. This is setup so that if you run `bin/npm run test` it will run test in every package that has a `package.json` file with a `test` script. You should try to keep naming consistent across packages to support this work. All currently supported scripts in `turbo` are listed in the `turbo.json` file at the root.

During CI, the `lint`, `test` and `build` NPM scripts are run to validate the package quality. You should ensure your package supports these.
31 changes: 29 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
"email": "developers@boxuk.com"
}
],
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org",
"only": [
"wpackagist-plugin/*",
"wpackagist-theme/*"
]
}
],
"require": {
"symfony/validator": "^7.0 || ^6.0"
},
Expand All @@ -24,11 +34,15 @@
"permafrost-dev/coverage-check": "^2.0",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"symplify/monorepo-builder": "^11.2",
"szepeviktor/phpstan-wordpress": "^1.3"
"szepeviktor/phpstan-wordpress": "^1.3",
"wpackagist-plugin/sqlite-database-integration": "^2.0",
"wpackagist-theme/twentytwentyfour": "^1.0"
},
"autoload": {
"psr-4": {
"Boxuk\\BoxWpEditorTools\\": [
"wp-content/plugins/editor-tools/src/",
"plugins/editor-tools/src/",
"packages/editor-tools/src/",
"packages/wp-editor-tools/src/"
]
Expand All @@ -39,8 +53,21 @@
"boxuk/wp-iconography": "self.version"
},
"config": {
"vendor-dir": "packages/vendor",
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"composer/installers": true
}
},
"extra": {
"installer-paths": {
"docker/wordpress/mu-plugins/{$name}": [
"type:wordpress-plugin",
"type:wordpress-muplugin"
],
"docker/wordpress/themes/{$name}": [
"type:wordpress-theme"
]
}
}
}
21 changes: 19 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,28 @@ version: '3.1'
services:
php:
build: ./docker/php
working_dir: /usr/src/app
working_dir: /var/www/html
volumes:
- .:/usr/src/app
- .:/var/www/html
nodejs:
build: ./docker/nodejs
working_dir: /usr/src/app
volumes:
- .:/usr/src/app

wordpress:
build: ./docker/wordpress
ports:
- "8000:80"
volumes:
- ./docker/wordpress/wp-config.php:/var/www/html/wp-config.php
- ./docker/wordpress/db.php:/var/www/html/wp-content/db.php
- ./docker/wordpress/mu-plugins/:/var/www/html/wp-content/mu-plugins/
- ./docker/wordpress/themes:/var/www/html/wp-content/themes
- ./packages:/var/www/html/wp-content/plugins
- database:/var/www/html/wp-content/database
environment:
SQLITE_MAIN_FILE: /var/www/html/wp-content/main.sqlite

volumes:
database:
1 change: 1 addition & 0 deletions docker/wordpress/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM wordpress:6.4.1
43 changes: 43 additions & 0 deletions docker/wordpress/db.php
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' );
}
}
);
13 changes: 13 additions & 0 deletions docker/wordpress/mu-plugins/plugin-loader.php
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.
*/
46 changes: 46 additions & 0 deletions docker/wordpress/wp-config.php
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-settings.php';
require_once ABSPATH . 'wp-content/plugins/vendor/autoload.php';
2 changes: 1 addition & 1 deletion packages/editor-tools/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "wordpress-muplugin",
"autoload": {
"psr-4": {
"Boxuk\\BoxWpEditorTools\\": "src/"
"Boxuk\\BoxWpEditorTools\\": "./src/"
}
},
"authors": [
Expand Down
17 changes: 10 additions & 7 deletions packages/editor-tools/editor-tools.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<?php
/**
* Plugin Name: Boxuk Editor Tools
* Plugin URI: https://boxuk.com
* Description: A collection of tools to enhance the WordPress editor.
* Version: 1.0.0
* Author: BoxUK
* Author URI: https://boxuk.com
*
* @package Boxuk\BoxWpEditorTools
*/

declare( strict_types = 1 );
namespace Boxuk\BoxWpEditorTools;

( new \Boxuk\BoxWpEditorTools\BlockLoader() )->init();
( new \Boxuk\BoxWpEditorTools\Comments() )->init();
( new \Boxuk\BoxWpEditorTools\EditorCleanup() )->init();
( new \Boxuk\BoxWpEditorTools\PostTypes() )->init();
( new \Boxuk\BoxWpEditorTools\TemplatePersistence() )->init();
( new \Boxuk\BoxWpEditorTools\Security\Security() )->init();
( new BlockLoader() )->init();
( new Comments() )->init();
( new EditorCleanup() )->init();
( new PostTypes() )->init();
( new TemplatePersistence() )->init();
( new Security\Security() )->init();
8 changes: 6 additions & 2 deletions packages/iconography/iconography.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?php
/**
* Plugin Name: Iconography
* Description: Provides iconography for the block editor.
* Version: 1.0.0
* Author: BoxUK
* Author URI: https://www.boxuk.com
*
* @package Peake\Client\Mu\Plugins\Iconography
* @package Boxuk\Iconography
*/

declare ( strict_types = 1 );

namespace Peake\Client\Mu\Plugins\Iconography;
namespace Boxuk\Iconography;

/**
* Loads Iconography
Expand Down
4 changes: 2 additions & 2 deletions packages/iconography/tests/TestIcononography.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
/**
* Test Iconography class
*
* @package Peake\Client\Mu\Plugins\Iconography
* @package Boxuk\Iconography
*/

declare( strict_types = 1 );

namespace Peake\Client\Mu\Plugins\Iconography;
namespace Boxuk\Iconography;

use WP_Mock\Tools\TestCase;

Expand Down

0 comments on commit 117fa9c

Please sign in to comment.