@codigodoleo/wp-kit 3.5.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/lib/prompts/index.js +99 -0
  2. package/modules/docs/index.js +56 -1
  3. package/modules/docs/templates/README.md.hbs +33 -160
  4. package/modules/docs/templates/docs/Arquitetura.md.hbs +106 -0
  5. package/modules/docs/templates/docs/Deploy-Pipeline.md.hbs +85 -0
  6. package/modules/docs/templates/docs/Desenvolvimento.md.hbs +127 -0
  7. package/modules/docs/templates/docs/Getting-Started.md.hbs +83 -0
  8. package/modules/docs/templates/docs/Infraestrutura.md.hbs +65 -0
  9. package/modules/docs/templates/docs/Monitoramento.md.hbs +57 -0
  10. package/modules/docs/templates/docs/Sync-the-Production-DB-with-the-Staging-DB.md.hbs +68 -0
  11. package/modules/docs/templates/docs/Troubleshooting.md.hbs +65 -0
  12. package/modules/mu-plugin/index.js +143 -17
  13. package/modules/mu-plugin/prompts.js +7 -0
  14. package/modules/mu-plugin/templates/acorn/.gitignore.hbs +10 -0
  15. package/modules/mu-plugin/templates/acorn/README.md.hbs +46 -0
  16. package/modules/mu-plugin/templates/acorn/app/Providers/CoreServiceProvider.php.hbs +26 -0
  17. package/modules/mu-plugin/templates/acorn/composer.json.hbs +31 -0
  18. package/modules/mu-plugin/templates/acorn/config/app.php.hbs +43 -0
  19. package/modules/mu-plugin/templates/acorn/config/logging.php.hbs +59 -0
  20. package/modules/mu-plugin/templates/acorn/plugin.php.hbs +95 -0
  21. package/modules/mu-plugin/templates/acorn/resources/.gitkeep +0 -0
  22. package/modules/mu-plugin/templates/acorn/storage/framework/cache/.gitkeep +0 -0
  23. package/modules/mu-plugin/templates/acorn/storage/framework/sessions/.gitkeep +0 -0
  24. package/modules/mu-plugin/templates/acorn/storage/framework/views/.gitkeep +0 -0
  25. package/modules/mu-plugin/templates/bedrock-autoloader.php +28 -0
  26. package/modules/sage/templates/.lando.yml.hbs +4 -1
  27. package/package.json +1 -1
  28. package/templates/.lando.yml.hbs +0 -9
  29. package/modules/docs/templates/docs/Arquitetura.md +0 -420
  30. package/modules/docs/templates/docs/Deploy-Pipeline.md +0 -127
  31. package/modules/docs/templates/docs/Desenvolvimento.md +0 -1139
  32. package/modules/docs/templates/docs/Getting-Started.md +0 -523
  33. package/modules/docs/templates/docs/Infraestrutura.md +0 -240
  34. package/modules/docs/templates/docs/Monitoramento.md +0 -340
  35. package/modules/docs/templates/docs/Sync-the-Production-DB-with-the-Staging-DB.md +0 -7
  36. package/modules/docs/templates/docs/Troubleshooting.md +0 -3
@@ -0,0 +1,46 @@
1
+ # {{mu_plugin_name}}
2
+
3
+ Core must-use plugin for `{{projectName}}`, built on [Roots Acorn](https://roots.io/acorn/).
4
+
5
+ ## Structure
6
+
7
+ ```
8
+ {{mu_plugin_name}}/
9
+ ├── {{mu_plugin_name}}.php # Bootstrap (Acorn boot, WP-CLI guard)
10
+ ├── composer.json # Acorn + ACF Composer deps
11
+ ├── app/
12
+ │ └── Providers/
13
+ │ └── CoreServiceProvider.php # Service registration entry point
14
+ ├── config/
15
+ │ ├── app.php # debug=false, providers list
16
+ │ └── logging.php # Log channels
17
+ ├── resources/ # Blade views, assets (if any)
18
+ └── storage/
19
+ ├── framework/{cache,views,sessions}/
20
+ └── logs/
21
+ ```
22
+
23
+ ## Install
24
+
25
+ The plugin ships its own `vendor/` (gitignored). After cloning:
26
+
27
+ ```bash
28
+ composer install --working-dir=content/mu-plugins/{{mu_plugin_name}}
29
+ ```
30
+
31
+ Or run via Lando: `lando composer install --working-dir=content/mu-plugins/{{mu_plugin_name}}`.
32
+
33
+ ## Adding services
34
+
35
+ 1. Create a new provider under `app/Providers/`.
36
+ 2. Register it in `config/app.php` under `providers`.
37
+ 3. (Optional) Add a config file under `config/`.
38
+
39
+ ## Known traps documented in the bootstrap
40
+
41
+ The plugin entry file (`{{mu_plugin_name}}.php`) contains comments explaining four Acorn integration traps that have already been mitigated:
42
+
43
+ - **WP-CLI Monolog conflict** — Acorn boot is skipped under WP-CLI. Register WP-CLI commands as native, not Acorn Artisan.
44
+ - **`APP_DEBUG=false`** — prevents Acorn's HandleExceptions from converting unrelated plugin notices into fatal errors.
45
+ - **Filesystem provider force-load** — Acorn does not auto-register Illuminate's Filesystem, which ACF Composer requires.
46
+ - **Composer plugin allowance** — `roots/acorn: true` under `allow-plugins` avoids interactive prompts during `composer install`.
@@ -0,0 +1,26 @@
1
+ <?php
2
+
3
+ declare(strict_types=1);
4
+
5
+ namespace {{mu_plugin_namespace}}\Providers;
6
+
7
+ use Roots\Acorn\ServiceProvider;
8
+
9
+ class CoreServiceProvider extends ServiceProvider
10
+ {
11
+ /**
12
+ * Register any application services.
13
+ */
14
+ public function register(): void
15
+ {
16
+ //
17
+ }
18
+
19
+ /**
20
+ * Bootstrap any application services.
21
+ */
22
+ public function boot(): void
23
+ {
24
+ //
25
+ }
26
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "{{projectName}}/{{mu_plugin_name}}",
3
+ "description": "{{projectDescription}} — core must-use plugin, built on Roots Acorn.",
4
+ "type": "wordpress-muplugin",
5
+ "license": "proprietary",
6
+ "require": {
7
+ "php": ">={{phpVersion}}",
8
+ "roots/acorn": "^6.1",
9
+ "log1x/acf-composer": "^3.4"
10
+ },
11
+ "require-dev": {
12
+ "laravel/pint": "^1.21"
13
+ },
14
+ "autoload": {
15
+ "psr-4": {
16
+ "{{mu_plugin_namespace}}\\": "app/"
17
+ }
18
+ },
19
+ "config": {
20
+ "allow-plugins": {
21
+ "roots/acorn": true
22
+ },
23
+ "sort-packages": true
24
+ },
25
+ "scripts": {
26
+ "lint": ["./vendor/bin/pint --test"],
27
+ "lint:fix": ["./vendor/bin/pint"]
28
+ },
29
+ "minimum-stability": "stable",
30
+ "prefer-stable": true
31
+ }
@@ -0,0 +1,43 @@
1
+ <?php
2
+
3
+ return [
4
+
5
+ /*
6
+ |--------------------------------------------------------------------------
7
+ | Application Name
8
+ |--------------------------------------------------------------------------
9
+ */
10
+
11
+ 'name' => '{{mu_plugin_name}}',
12
+
13
+ /*
14
+ |--------------------------------------------------------------------------
15
+ | Application Debug Mode
16
+ |--------------------------------------------------------------------------
17
+ |
18
+ | Hard-coded to false. Acorn's HandleExceptions bootstrapper converts
19
+ | PHP notices/warnings (including from unrelated plugins/themes) into
20
+ | ErrorExceptions when this is truthy, which cascades into a fatal loop
21
+ | because the View provider may not be wired. Defense in depth alongside
22
+ | the APP_DEBUG constant in {{mu_plugin_name}}.php.
23
+ |
24
+ */
25
+
26
+ 'debug' => false,
27
+
28
+ /*
29
+ |--------------------------------------------------------------------------
30
+ | Autoloaded Service Providers
31
+ |--------------------------------------------------------------------------
32
+ |
33
+ | The service providers below are loaded after WordPress' theme is set up.
34
+ | The plugin's bootstrap file also force-loads the Filesystem provider
35
+ | before this list so ACF Composer can resolve its `files` binding.
36
+ |
37
+ */
38
+
39
+ 'providers' => [
40
+ \\{{mu_plugin_namespace}}\Providers\CoreServiceProvider::class,
41
+ ],
42
+
43
+ ];
@@ -0,0 +1,59 @@
1
+ <?php
2
+
3
+ use Monolog\Handler\NullHandler;
4
+ use Monolog\Handler\StreamHandler;
5
+ use Monolog\Processor\PsrLogMessageProcessor;
6
+
7
+ return [
8
+
9
+ /*
10
+ |--------------------------------------------------------------------------
11
+ | Default Log Channel
12
+ |--------------------------------------------------------------------------
13
+ |
14
+ | Routed to WordPress' debug.log when WP_DEBUG_LOG is on, NullHandler
15
+ | otherwise. Override per-environment via env('LOG_CHANNEL').
16
+ |
17
+ */
18
+
19
+ 'default' => env('LOG_CHANNEL', 'wp'),
20
+
21
+ /*
22
+ |--------------------------------------------------------------------------
23
+ | Log Channels
24
+ |--------------------------------------------------------------------------
25
+ */
26
+
27
+ 'channels' => [
28
+
29
+ 'stack' => [
30
+ 'driver' => 'stack',
31
+ 'channels' => ['wp'],
32
+ 'ignore_exceptions' => false,
33
+ ],
34
+
35
+ 'wp' => [
36
+ 'driver' => 'monolog',
37
+ 'level' => env('LOG_LEVEL', 'debug'),
38
+ 'handler' => defined('WP_DEBUG_LOG') && WP_DEBUG_LOG
39
+ ? StreamHandler::class
40
+ : NullHandler::class,
41
+ 'with' => defined('WP_DEBUG_LOG') && WP_DEBUG_LOG && is_string(WP_DEBUG_LOG)
42
+ ? ['stream' => WP_DEBUG_LOG]
43
+ : ['stream' => WP_CONTENT_DIR . '/debug.log'],
44
+ 'processors' => [PsrLogMessageProcessor::class],
45
+ ],
46
+
47
+ 'errorlog' => [
48
+ 'driver' => 'errorlog',
49
+ 'level' => env('LOG_LEVEL', 'debug'),
50
+ ],
51
+
52
+ 'null' => [
53
+ 'driver' => 'monolog',
54
+ 'handler' => NullHandler::class,
55
+ ],
56
+
57
+ ],
58
+
59
+ ];
@@ -0,0 +1,95 @@
1
+ <?php
2
+
3
+ /**
4
+ * Plugin Name: {{mu_plugin_name}}
5
+ * Description: {{projectDescription}} — core must-use plugin (Acorn-flavored).
6
+ * Version: {{projectVersion}}
7
+ * Requires PHP: {{phpVersion}}
8
+ */
9
+
10
+ declare(strict_types=1);
11
+
12
+ if (! defined('ABSPATH')) {
13
+ exit;
14
+ }
15
+
16
+ define('{{mu_plugin_constant_prefix}}_VERSION', '{{projectVersion}}');
17
+ define('{{mu_plugin_constant_prefix}}_PATH', plugin_dir_path(__FILE__));
18
+ define('{{mu_plugin_constant_prefix}}_URL', plugin_dir_url(__FILE__));
19
+
20
+ $autoloadPath = {{mu_plugin_constant_prefix}}_PATH . 'vendor/autoload.php';
21
+
22
+ if (! file_exists($autoloadPath)) {
23
+ add_action('admin_notices', function (): void {
24
+ echo '<div class="notice notice-error"><p><strong>{{mu_plugin_name}}:</strong> dependencies missing. Run <code>composer install</code> in <code>content/mu-plugins/{{mu_plugin_name}}/</code>.</p></div>';
25
+ });
26
+
27
+ return;
28
+ }
29
+
30
+ require_once $autoloadPath;
31
+
32
+ if (! class_exists(\Roots\Acorn\Application::class)) {
33
+ add_action('admin_notices', function (): void {
34
+ echo '<div class="notice notice-error"><p><strong>{{mu_plugin_name}}:</strong> Roots Acorn missing from plugin vendor. Re-run <code>composer install</code> in <code>content/mu-plugins/{{mu_plugin_name}}/</code>.</p></div>';
35
+ });
36
+
37
+ return;
38
+ }
39
+
40
+ /*
41
+ * Acorn's HandleExceptions bootstrapper installs set_error_handler() and
42
+ * converts PHP notices/warnings (including ones emitted by unrelated plugins
43
+ * and themes) into ErrorExceptions when `app.debug` is truthy. That cascades
44
+ * into a fatal loop because the framework tries to render the error via
45
+ * view()/response() before the View provider is wired.
46
+ *
47
+ * Defense in depth: both this constant AND `'debug' => false` in
48
+ * config/app.php must be set. Remove once the project owns the global
49
+ * PHP-warning surface.
50
+ */
51
+ if (! defined('APP_DEBUG')) {
52
+ define('APP_DEBUG', false);
53
+ }
54
+
55
+ add_action('after_setup_theme', function (): void {
56
+ /*
57
+ * Skip Acorn boot under WP-CLI.
58
+ *
59
+ * Acorn (>=6.1) depends on Monolog 3.x (LogRecord-based ProcessorInterface).
60
+ * WP-CLI ships its own PHAR-bundled Monolog 2.x (array-based ProcessorInterface)
61
+ * loaded BEFORE the plugin vendor. When Acorn tries to materialize
62
+ * Illuminate\Log\Context\ContextLogProcessor, PHP fatals with an
63
+ * incompatible-signature error because the parent interface has already
64
+ * been resolved to the Monolog 2.x interface.
65
+ *
66
+ * WordPress hooks (HTTP/upload context) don't load the WP-CLI PHAR, so
67
+ * this guard is invisible in normal operation. WP-CLI commands for this
68
+ * plugin must be registered as native WP_CLI commands (above this hook),
69
+ * NOT as Acorn Artisan commands.
70
+ */
71
+ if (defined('WP_CLI') && WP_CLI) {
72
+ return;
73
+ }
74
+
75
+ \Roots\Acorn\Application::configure({{mu_plugin_constant_prefix}}_PATH)
76
+ ->withProviders([
77
+ /*
78
+ * Acorn doesn't auto-register Illuminate's Filesystem in the
79
+ * default container. ACF Composer needs the `files` binding for
80
+ * File::directories() during its composer discovery; without it,
81
+ * AcfComposer::boot() throws "Target class [files] does not
82
+ * exist" and silently aborts before any Field/Options class is
83
+ * registered. Force-load it before anything else.
84
+ */
85
+ \Illuminate\Filesystem\FilesystemServiceProvider::class,
86
+ \\{{mu_plugin_namespace}}\Providers\CoreServiceProvider::class,
87
+ ])
88
+ ->withPaths(
89
+ app: {{mu_plugin_constant_prefix}}_PATH . 'app',
90
+ config: {{mu_plugin_constant_prefix}}_PATH . 'config',
91
+ storage: {{mu_plugin_constant_prefix}}_PATH . 'storage',
92
+ resources: {{mu_plugin_constant_prefix}}_PATH . 'resources',
93
+ )
94
+ ->boot();
95
+ }, 0);
@@ -0,0 +1,28 @@
1
+ <?php
2
+
3
+ /*
4
+ * Plugin Name: Bedrock Autoloader
5
+ * Plugin URI: https://github.com/roots/bedrock-autoloader
6
+ * Description: An autoloader that enables standard plugins to be required just like must-use plugins. The autoloaded plugins are included during mu-plugin loading. An asterisk (*) next to the name of any plugin designates the plugins that have been autoloaded.
7
+ * Version: 1.0.0
8
+ * Author: Roots
9
+ * Author URI: https://roots.io/
10
+ * License: MIT License
11
+ */
12
+
13
+ if (! is_blog_installed()) {
14
+ return;
15
+ }
16
+
17
+ /*
18
+ * Path math:
19
+ * __DIR__ -> <project>/content/mu-plugins
20
+ * dirname(__DIR__, 1) -> <project>/content
21
+ * dirname(__DIR__, 2) -> <project> (site root, where vendor/ lives)
22
+ *
23
+ * If vendor/autoload.php is missing the site is fundamentally broken;
24
+ * a loud fatal here is preferable to a silent regression in production.
25
+ */
26
+ require_once dirname(__DIR__, 2) . '/vendor/autoload.php';
27
+
28
+ new \Roots\Bedrock\Autoloader();
@@ -12,6 +12,9 @@ events:
12
12
  - appserver: cd /app/content/themes/{{projectName}} && wp acorn optimize:clear
13
13
  - build: bash ./server/cmd/setup-sage-node.sh
14
14
  tooling:
15
+ acorn:
16
+ service: appserver
17
+ cmd: wp acorn
15
18
  dev:
16
19
  service: build
17
20
  description: Run the Sage/Vite development server
@@ -38,11 +41,11 @@ tooling:
38
41
  service: build
39
42
  description: Build the Sage theme
40
43
  cmd: npm run build --prefix /app/content/themes/{{projectName}}
44
+ {{#if enable_lint}}
41
45
  theme-lint:
42
46
  service: build
43
47
  description: Lint the Sage theme (JS/TS/Vue)
44
48
  cmd: npm run lint --prefix /app/content/themes/{{projectName}}
45
- {{#if enable_lint}}
46
49
  pint:
47
50
  service: appserver
48
51
  description: Lint PHP in the Sage theme
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codigodoleo/wp-kit",
3
- "version": "3.5.0",
3
+ "version": "5.0.0",
4
4
  "description": "Kit opinativo para padronizar projetos WordPress com CI/CD dinâmico.",
5
5
  "main": "bin/index.js",
6
6
  "bin": {
@@ -64,15 +64,6 @@ tooling:
64
64
  service: build
65
65
  npm:
66
66
  service: build
67
- dev:
68
- service: build
69
- description: Run the Vite development server
70
- cmd: npm run dev
71
- redis-cli:
72
- service: cache
73
- acorn:
74
- service: appserver
75
- cmd: wp acorn
76
67
  flush:
77
68
  service: appserver
78
69
  description: Flush WordPress and Redis caches