From 117fa9cad3618cc4b4efd287818e87649ca9fe76 Mon Sep 17 00:00:00 2001 From: James Amner Date: Wed, 29 May 2024 09:15:13 +0100 Subject: [PATCH] Setup WP Env --- .gitignore | 10 ++++ Readme.md | 4 +- composer.json | 31 ++++++++++++- docker-compose.yml | 21 ++++++++- docker/wordpress/Dockerfile | 1 + docker/wordpress/db.php | 43 +++++++++++++++++ docker/wordpress/mu-plugins/plugin-loader.php | 13 ++++++ docker/wordpress/wp-config.php | 46 +++++++++++++++++++ packages/editor-tools/composer.json | 2 +- packages/editor-tools/editor-tools.php | 17 ++++--- packages/iconography/iconography.php | 8 +++- .../iconography/tests/TestIcononography.php | 4 +- 12 files changed, 182 insertions(+), 18 deletions(-) create mode 100644 docker/wordpress/Dockerfile create mode 100644 docker/wordpress/db.php create mode 100644 docker/wordpress/mu-plugins/plugin-loader.php create mode 100644 docker/wordpress/wp-config.php diff --git a/.gitignore b/.gitignore index 17bdccb..abdb7c4 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Readme.md b/Readme.md index 11fc234..c18d1be 100644 --- a/Readme.md +++ b/Readme.md @@ -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/` 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/` 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. \ No newline at end of file diff --git a/composer.json b/composer.json index 0ff39c9..53ce56b 100644 --- a/composer.json +++ b/composer.json @@ -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" }, @@ -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/" ] @@ -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" + ] } } } diff --git a/docker-compose.yml b/docker-compose.yml index cf8638d..24a75e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: \ No newline at end of file diff --git a/docker/wordpress/Dockerfile b/docker/wordpress/Dockerfile new file mode 100644 index 0000000..b105054 --- /dev/null +++ b/docker/wordpress/Dockerfile @@ -0,0 +1 @@ +FROM wordpress:6.4.1 diff --git a/docker/wordpress/db.php b/docker/wordpress/db.php new file mode 100644 index 0000000..d9d727c --- /dev/null +++ b/docker/wordpress/db.php @@ -0,0 +1,43 @@ +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[)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`#-<}o{}NlqT>4init(); -( 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(); diff --git a/packages/iconography/iconography.php b/packages/iconography/iconography.php index ba277b3..72fd31e 100644 --- a/packages/iconography/iconography.php +++ b/packages/iconography/iconography.php @@ -1,13 +1,17 @@