@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,127 @@
1
+ # Desenvolvimento
2
+
3
+ Workflow and conventions for working on **{{projectTitle}}**.
4
+
5
+ ## Git workflow
6
+
7
+ This project follows a **GitFlow-derived workflow** with three long-lived
8
+ branches and short-lived branches per piece of work. Adjust to your
9
+ team's needs — the structure below is a sensible default.
10
+
11
+ | Branch | Purpose | Auto-deploys to |
12
+ | --- | --- | --- |
13
+ | `main` (or `master`) | Production-ready code | {{projectProductionDomain}} |
14
+ | `staging` | Pre-production validation | {{projectStagingDomain}} |
15
+ | `development` | Integration of in-flight features | {{projectDevDomain}} |
16
+
17
+ ### Branch types
18
+
19
+ | Prefix | From | To | Purpose |
20
+ | --- | --- | --- | --- |
21
+ | `feature/` | `main` | `development` (via {{prTermShort}}) | New functionality |
22
+ | `bugfix/` | `main` | `development` (via {{prTermShort}}) | Non-critical fixes |
23
+ | `hotfix/` | `main` | `main` + `development` (via {{prTermShort}}) | Critical production fixes |
24
+ | `release/` | `main` | `staging` → `main` (via {{prTermShort}}) | Release preparation |
25
+ | `chore/` | `main` | `development` (via {{prTermShort}}) | Maintenance, deps, docs |
26
+
27
+ ### Naming
28
+
29
+ Use kebab-case in English; the prefix carries the intent.
30
+
31
+ ```text
32
+ feature/user-profile-avatar
33
+ bugfix/header-overlap-on-mobile
34
+ hotfix/auth-bypass-cve-2025-1234
35
+ chore/bump-composer-deps
36
+ release/v1.4.0
37
+ ```
38
+
39
+ ## Feature flow
40
+
41
+ ```mermaid
42
+ graph TD
43
+ A[feature/branch off main] --> B[Open {{prTermShort}} -> development]
44
+ B --> C[Code review]
45
+ C --> D{Approved?}
46
+ D -- No --> E[Address feedback]
47
+ E --> C
48
+ D -- Yes --> F[Merge to development]
49
+ F --> G[Auto-deploy to {{projectDevDomain}}]
50
+ G --> H[QA on dev]
51
+ H --> I[{{prTermShort}} development -> staging]
52
+ I --> J[Merge to staging]
53
+ J --> K[Auto-deploy to {{projectStagingDomain}}]
54
+ K --> L[Final validation]
55
+ L --> M[{{prTermShort}} staging -> main]
56
+ M --> N[Merge to main]
57
+ N --> O[Auto-deploy to {{projectProductionDomain}}]
58
+ ```
59
+
60
+ Direct pushes to `main`, `staging`, and `development` should be blocked
61
+ by branch protection — every change goes through a {{prTermShort}}.
62
+
63
+ ## Commits
64
+
65
+ This project uses [Conventional Commits](https://www.conventionalcommits.org/).
66
+ Husky + commitlint enforce the format locally; CI re-checks on every
67
+ {{prTermShort}}.
68
+
69
+ ```text
70
+ <type>(<scope>): <subject>
71
+
72
+ <body>
73
+
74
+ <footer>
75
+ ```
76
+
77
+ Allowed types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`,
78
+ `test`, `chore`, `ci`, `build`, `revert`.
79
+
80
+ Examples:
81
+
82
+ ```text
83
+ feat(checkout): support PIX payment method
84
+ fix(header): align logo on small viewports
85
+ chore(deps): bump roots/acorn to 6.2
86
+ ```
87
+
88
+ ## Code review checklist
89
+
90
+ - [ ] The {{prTermShort}} description explains *why*, not just *what*.
91
+ - [ ] CI is green (lint, tests, build).
92
+ - [ ] No secrets in code or commit history.
93
+ - [ ] Documentation updated when behaviour changes.
94
+ - [ ] Migration / data-fix steps documented for ops.
95
+ - [ ] Screenshots attached for UI changes.
96
+
97
+ ## Lint and formatting
98
+
99
+ ```bash
100
+ npm run lint # ESLint + Stylelint
101
+ npm run lint:fix # Auto-fix where possible
102
+ npm run format # Prettier
103
+ {{#if useSage}}composer lint --working-dir=content/themes/{{projectName}} # Pint
104
+ composer lint:fix --working-dir=content/themes/{{projectName}}{{/if}}
105
+ ```
106
+
107
+ Husky runs lint-staged on every commit so only changed files are
108
+ checked; CI re-runs the full sweep.
109
+
110
+ ## Tests
111
+
112
+ - **PHP**: `{{ "{{TODO: Pest suite location and how to invoke it}}" }}`
113
+ - **E2E**: Playwright specs under `tests/e2e/`. Run locally with
114
+ `npm run test:e2e`.
115
+ - **Visual regression**: `{{ "{{TODO: define if/how visual regression is captured}}" }}`
116
+
117
+ ## Releases
118
+
119
+ Releases are tag-driven. The recommended flow:
120
+
121
+ 1. Open a `release/vX.Y.Z` branch off `main`.
122
+ 2. Bump the version in `package.json` and the project changelog.
123
+ 3. {{prTermShort}} `release/vX.Y.Z` → `staging`; validate.
124
+ 4. {{prTermShort}} `staging` → `main`; tag `vX.Y.Z` on the merge commit.
125
+ 5. {{ciSystem}} deploys the tag to {{projectProductionDomain}}.
126
+
127
+ `{{ "{{TODO: replace this section if the project adopts release-please / semantic-release}}" }}`
@@ -0,0 +1,83 @@
1
+ # Getting Started
2
+
3
+ Local development setup for **{{projectTitle}}**.
4
+
5
+ ## Prerequisites
6
+
7
+ | Tool | Version | Purpose |
8
+ | --- | --- | --- |
9
+ | [Lando](https://lando.dev/) | 3.0+ | Local environment orchestration |
10
+ | [Docker](https://docker.com/) | 20.0+ | Container runtime backing Lando |
11
+ | [Git](https://git-scm.com/) | any | Version control |
12
+ | [Node.js](https://nodejs.org/) | {{nodeVersion}}+ | Build pipeline (Vite, lint) |
13
+ | [Composer](https://getcomposer.org/) | 2.x | PHP dependencies |
14
+
15
+ ## Clone and bootstrap
16
+
17
+ ```bash
18
+ git clone {{repositoryHttpsUrl}}
19
+ cd {{projectName}}
20
+ lando start
21
+ ```
22
+
23
+ The first `lando start` provisions containers, installs WordPress core
24
+ via Composer ({{wpCoreVersion}}), and writes salts into `.env`. Expect
25
+ 3–5 minutes the first time, well under a minute on subsequent boots.
26
+
27
+ Once it finishes, the dev URL is **https://{{projectDomain}}**.
28
+
29
+ ## Database
30
+
31
+ Lando ships an empty MariaDB. To work against a real dataset, refresh
32
+ from staging:
33
+
34
+ ```bash
35
+ # 1. Pull the staging dump (see Sync doc for how the dump gets produced)
36
+ lando db-import path/to/staging-dump.sql.gz
37
+
38
+ # 2. Run search-replace so URLs point at the Lando URL
39
+ lando wp search-replace 'https://{{projectStagingDomain}}' 'https://{{projectDomain}}'
40
+ ```
41
+
42
+ {{#if useSage}}
43
+ ## Theme build
44
+
45
+ The Sage theme lives under `content/themes/{{projectName}}`. Vite drives
46
+ the asset pipeline:
47
+
48
+ ```bash
49
+ lando theme-dev # HMR dev server
50
+ lando theme-build # Production build
51
+ ```
52
+ {{/if}}
53
+
54
+ ## Common commands
55
+
56
+ ```bash
57
+ lando start # Boot containers
58
+ lando stop # Stop containers
59
+ lando restart # Restart (useful after .lando.yml changes)
60
+ lando rebuild # Full rebuild (after Docker config changes)
61
+ lando logs # Tail container logs
62
+ lando wp <command> # Run WP-CLI against the Lando WordPress
63
+ lando ssh # Shell into the appserver
64
+ lando destroy # Wipe containers (data is preserved on disk)
65
+ ```
66
+
67
+ ## Editor setup
68
+
69
+ This project ships a multi-root VS Code workspace at
70
+ `{{projectName}}.code-workspace`. Recommended extensions are pinned in
71
+ `.vscode/extensions.json` — VS Code prompts to install them on first
72
+ open.
73
+
74
+ ## What to read next
75
+
76
+ - [Desenvolvimento](./Desenvolvimento.md) — git workflow and {{prTermShort}} hygiene
77
+ - [Arquitetura](./Arquitetura.md) — how the pieces fit together
78
+
79
+ ## Troubleshooting
80
+
81
+ If anything goes wrong during the first boot, check
82
+ [Troubleshooting](./Troubleshooting.md) — common Lando/Docker issues
83
+ are listed there.
@@ -0,0 +1,65 @@
1
+ # Infraestrutura
2
+
3
+ Production infrastructure for **{{projectTitle}}**. This file is a
4
+ skeleton — fill it in as decisions are made and infrastructure is
5
+ provisioned. Keep it close to the truth; out-of-date infra docs cost
6
+ hours during incidents.
7
+
8
+ ## Cloud provider
9
+
10
+ - **Provider**: `{{ "{{TODO: AWS / GCP / Azure / DigitalOcean / Hetzner / bare metal / ...}}" }}`
11
+ - **Region(s)**: `{{ "{{TODO}}" }}`
12
+ - **Account / project ID**: `{{ "{{TODO}}" }}`
13
+ - **Cost owner**: `{{ "{{TODO: team / cost center}}" }}`
14
+
15
+ ## Network
16
+
17
+ - **VPC / CIDR**: `{{ "{{TODO}}" }}`
18
+ - **Subnets**: `{{ "{{TODO: public, private, database tiers}}" }}`
19
+ - **Egress (NAT)**: `{{ "{{TODO}}" }}`
20
+ - **Peerings / VPN**: `{{ "{{TODO}}" }}`
21
+
22
+ ## Compute
23
+
24
+ - **Runtime platform**: `{{ "{{TODO: Kubernetes / ECS / Fargate / VM / serverless}}" }}`
25
+ - **Sizing**: `{{ "{{TODO: instance class, replica count}}" }}`
26
+ - **Autoscaling**: `{{ "{{TODO: min / max / target metric}}" }}`
27
+ - **Multi-AZ**: `{{ "{{TODO: yes / no, scope}}" }}`
28
+
29
+ ## Persistence
30
+
31
+ | Layer | Service | Sizing | Backup |
32
+ | --- | --- | --- | --- |
33
+ | Database | `{{ "{{TODO}}" }}` | `{{ "{{TODO}}" }}` | `{{ "{{TODO: frequency + retention}}" }}` |
34
+ | Object storage | `{{ "{{TODO}}" }}` | n/a | `{{ "{{TODO: versioning / replication}}" }}` |
35
+ | Cache | `{{ "{{TODO}}" }}` | `{{ "{{TODO}}" }}` | n/a |
36
+
37
+ ## Edge
38
+
39
+ - **DNS**: `{{ "{{TODO}}" }}`
40
+ - **CDN**: `{{ "{{TODO}}" }}`
41
+ - **TLS certificate management**: `{{ "{{TODO: ACM / Let's Encrypt / Cloudflare}}" }}`
42
+ - **WAF**: `{{ "{{TODO}}" }}`
43
+
44
+ ## Secrets and IAM
45
+
46
+ - **Secrets store**: `{{ "{{TODO: cloud secret manager / Vault / env vars}}" }}`
47
+ - **Access model**: `{{ "{{TODO: IAM roles / service accounts / SSH keys}}" }}`
48
+ - **MFA / SSO**: `{{ "{{TODO}}" }}`
49
+
50
+ ## Infrastructure as code
51
+
52
+ - **Tool**: `{{ "{{TODO: Terraform / Pulumi / CloudFormation / Ansible / none}}" }}`
53
+ - **Repository**: `{{ "{{TODO: path or URL of IaC repo}}" }}`
54
+ - **State backend**: `{{ "{{TODO}}" }}`
55
+
56
+ Keep IaC the source of truth. Hand-edits in the cloud console drift
57
+ silently and cause incidents months later.
58
+
59
+ ## Observability
60
+
61
+ See [Monitoramento](./Monitoramento.md).
62
+
63
+ ## Runbooks
64
+
65
+ `{{ "{{TODO: link runbooks for common operations: scaling up, rotating a secret, restoring from backup, swapping the cache, etc.}}" }}`
@@ -0,0 +1,57 @@
1
+ # Monitoramento
2
+
3
+ Observability and alerting for **{{projectTitle}}**.
4
+
5
+ ## Goals
6
+
7
+ - Detect issues before users do.
8
+ - Tie every alert to a documented runbook step.
9
+ - Capture enough telemetry to debug incidents *after* they happen, not just before.
10
+
11
+ ## Stack
12
+
13
+ | Pillar | Tool | Owner |
14
+ | --- | --- | --- |
15
+ | Metrics | `{{ "{{TODO: Prometheus / CloudWatch / Datadog / New Relic / ...}}" }}` | `{{ "{{TODO}}" }}` |
16
+ | Logs | `{{ "{{TODO: CloudWatch Logs / Loki / ELK / Datadog Logs / ...}}" }}` | `{{ "{{TODO}}" }}` |
17
+ | Traces | `{{ "{{TODO: OpenTelemetry / Jaeger / Datadog APM / ...}}" }}` | `{{ "{{TODO}}" }}` |
18
+ | Real user monitoring | `{{ "{{TODO}}" }}` | `{{ "{{TODO}}" }}` |
19
+ | Errors | `{{ "{{TODO: Sentry / Rollbar / Bugsnag / ...}}" }}` | `{{ "{{TODO}}" }}` |
20
+ | Uptime | `{{ "{{TODO: external probe (Pingdom / UptimeRobot / Statuscake / ...)}}" }}` | `{{ "{{TODO}}" }}` |
21
+
22
+ ## Dashboards
23
+
24
+ `{{ "{{TODO: list and link the dashboards the team actually looks at. A dashboard nobody opens is technical debt, not observability.}}" }}`
25
+
26
+ ## Service-level objectives (SLOs)
27
+
28
+ | Metric | Target | Measurement window |
29
+ | --- | --- | --- |
30
+ | Uptime | `{{ "{{TODO}}" }}` | 30d rolling |
31
+ | p95 latency | `{{ "{{TODO}}" }}` | 30d rolling |
32
+ | Error rate | `{{ "{{TODO}}" }}` | 30d rolling |
33
+
34
+ `{{ "{{TODO: define the customer-facing SLI for each SLO. \"Uptime\" without an SLI is not measurable.}}" }}`
35
+
36
+ ## Alerts
37
+
38
+ Every alert needs three things on the alert itself:
39
+
40
+ 1. **What is broken** (one line, plain language).
41
+ 2. **Severity** (page now / handle next business day / informational).
42
+ 3. **First step of the runbook** (URL or paste of the first command to run).
43
+
44
+ `{{ "{{TODO: list the alerts wired up today, link each to a runbook section}}" }}`
45
+
46
+ ## On-call
47
+
48
+ - **Rotation**: `{{ "{{TODO: who is on, where the schedule lives}}" }}`
49
+ - **Escalation policy**: `{{ "{{TODO}}" }}`
50
+ - **Incident channel**: `{{ "{{TODO: Slack channel, Teams channel, etc.}}" }}`
51
+
52
+ ## Post-mortem template
53
+
54
+ After every Sev-1/Sev-2 incident, write a blameless post-mortem under
55
+ `docs/post-mortems/YYYY-MM-DD-short-title.md`. Cover: timeline, impact,
56
+ root cause, what stopped the bleeding, action items (with owners and
57
+ due dates). Action items go into the project tracker the same day.
@@ -0,0 +1,68 @@
1
+ # Sync the Production DB into Staging
2
+
3
+ Refresh the **{{projectTitle}}** staging database with a recent snapshot
4
+ of production, so QA hits realistic data.
5
+
6
+ ## When to do this
7
+
8
+ - Before validating a release branch.
9
+ - After any production data migration that QA needs to test against.
10
+ - Routinely (weekly is a common cadence) so staging never drifts too far.
11
+
12
+ ## Procedure
13
+
14
+ The exact mechanism depends on how production database backups are
15
+ produced and where they live. Pick the option that matches your stack
16
+ and replace this file with the concrete steps.
17
+
18
+ ### Option A — CI-scheduled pipeline
19
+
20
+ If {{ciSystem}} runs a scheduled job that exports production and writes
21
+ it to object storage:
22
+
23
+ 1. Trigger the scheduled job that dumps production:
24
+ - {{#if isGitLab}}[CI/CD → Schedules]({{repositoryWebUrl}}/-/pipeline_schedules){{/if}}
25
+ {{#if isGitHub}}- GitHub Actions → "Run workflow" on the dump pipeline.{{/if}}
26
+ {{#if isBitbucket}}- Bitbucket Pipelines → "Run pipeline" on the schedule defined in `bitbucket-pipelines.yml`.{{/if}}
27
+ 2. Wait for the dump artefact to land in object storage.
28
+ 3. Trigger the import job that loads the artefact into the staging database.
29
+ 4. Verify in {{ciSystem}} that both jobs finished green.
30
+
31
+ `{{ "{{TODO: link the exact job names and the artefact bucket / path}}" }}`
32
+
33
+ ### Option B — Manual via WP-CLI
34
+
35
+ If there is no CI pipeline yet:
36
+
37
+ ```bash
38
+ # On a host with read access to production:
39
+ wp db export prod-dump.sql.gz --add-drop-table
40
+
41
+ # Copy the dump to a host with write access to staging:
42
+ scp prod-dump.sql.gz user@staging-host:/tmp/
43
+
44
+ # On the staging host:
45
+ wp db import /tmp/prod-dump.sql.gz
46
+ wp search-replace 'https://{{projectProductionDomain}}' 'https://{{projectStagingDomain}}'
47
+ wp cache flush
48
+ ```
49
+
50
+ `{{ "{{TODO: replace with the actual commands and hostnames used in this project}}" }}`
51
+
52
+ ## Sanitisation
53
+
54
+ Production data may contain PII the staging environment should not hold
55
+ in clear. Before importing, scrub:
56
+
57
+ - User emails (replace with `user{id}@example.test`).
58
+ - Personal addresses, phone numbers.
59
+ - Order/payment records, depending on regulatory scope.
60
+ - Any third-party tokens stored in `wp_options`.
61
+
62
+ `{{ "{{TODO: define which tables/columns get scrubbed and the SQL or WP-CLI commands that do it}}" }}`
63
+
64
+ ## After the sync
65
+
66
+ - Run a smoke test on staging.
67
+ - Notify the team in `{{ "{{TODO: incident / dev channel}}" }}` so QA knows fresh data is live.
68
+ - If anything looks wrong, restore the previous staging snapshot rather than chasing partial fixes.
@@ -0,0 +1,65 @@
1
+ # Troubleshooting
2
+
3
+ Common issues and recovery steps for **{{projectTitle}}**. Add an entry
4
+ every time you debug something the next person would also stumble on.
5
+
6
+ ## Format
7
+
8
+ Each entry follows the same shape:
9
+
10
+ ```markdown
11
+ ### <Short symptom>
12
+
13
+ **Symptom**: what the user / engineer actually sees.
14
+ **Likely cause**: one or two sentences.
15
+ **Fix**: numbered, copy-pasteable steps.
16
+ **Why this is the fix**: brief, so future-you doesn't relearn it.
17
+ ```
18
+
19
+ ---
20
+
21
+ ### `lando start` fails with "port already in use"
22
+
23
+ **Symptom**: Lando fails to start with `Error starting the network: ports are not available`.
24
+ **Likely cause**: another local stack (Docker container, system service, or a previous Lando project) is bound to ports 80, 443, or 3306.
25
+ **Fix**:
26
+
27
+ 1. List Lando apps: `lando list`.
28
+ 2. Stop unrelated ones: `lando stop --name <other-app>`.
29
+ 3. If a non-Lando process holds the port: `sudo lsof -i :443` to identify it, then stop or reconfigure that service.
30
+ 4. Retry `lando start`.
31
+
32
+ **Why this is the fix**: Lando binds host ports; conflicts surface as start failures, not run failures.
33
+
34
+ ---
35
+
36
+ ### Composer install hangs or 404s on a wpackagist plugin
37
+
38
+ **Symptom**: `composer install` stalls on `wpackagist-plugin/<name>` or errors with "Could not find package".
39
+ **Likely cause**: the wpackagist mirror reflects what is on the WordPress.org plugin directory at scan time. Plugins that were removed (deprecated, taken down) won't be there even if they used to be.
40
+ **Fix**:
41
+
42
+ 1. Check the plugin's current status on https://wordpress.org/plugins/.
43
+ 2. If the plugin is gone: replace it with a maintained alternative, or vendor it via `repositories` + `type: package` in `composer.json`.
44
+ 3. If the plugin still exists upstream: clear Composer cache (`composer clear-cache`) and retry.
45
+
46
+ **Why this is the fix**: wpackagist is a mirror, not the source of truth. A 404 means upstream removed the plugin; clearing cache only helps if it's a transient mirror sync gap.
47
+
48
+ ---
49
+
50
+ ### I can't reach {{repositoryHost}}
51
+
52
+ **Symptom**: Pushes time out, the web UI is unreachable.
53
+ **Likely cause**: VPN is down, DNS is poisoned, or {{repositoryHost}} itself is having an incident.
54
+ **Fix**:
55
+
56
+ 1. Check {{repositoryHost}}'s public status page.
57
+ 2. Try reaching it without VPN if your network allows it.
58
+ 3. Try a different DNS resolver (`dig @1.1.1.1 {{repositoryHost}}`).
59
+ 4. If all else fails: stash work locally and resume when the platform recovers.
60
+
61
+ **Why this is the fix**: most outages here are platform-side or network-side, not client misconfiguration. Burning hours on local fixes when {{repositoryHost}} is down wastes the day.
62
+
63
+ ---
64
+
65
+ `{{ "{{TODO: add project-specific entries as they come up. The list below is intentionally short — generic entries that apply to every wp-kit project.}}" }}`
@@ -4,46 +4,172 @@ import fs from 'fs-extra';
4
4
 
5
5
  import { log, color } from '../../lib/utils/logger.js';
6
6
 
7
+ /**
8
+ * Derive a StudlyCase PSR-4 namespace fragment from a kebab/snake plugin slug.
9
+ *
10
+ * acme-core -> AcmeCore
11
+ * my-site-core -> MySiteCore
12
+ * my_plugin -> MyPlugin
13
+ */
14
+ function toStudlyCase(slug) {
15
+ return slug
16
+ .split(/[-_]/)
17
+ .filter(Boolean)
18
+ .map((segment) => segment[0].toUpperCase() + segment.slice(1).toLowerCase())
19
+ .join('');
20
+ }
21
+
22
+ /**
23
+ * Derive an UPPER_SNAKE constant prefix from a kebab/snake plugin slug.
24
+ *
25
+ * acme-core -> ACME_CORE
26
+ * my-site-core -> MY_SITE_CORE
27
+ */
28
+ function toConstantPrefix(slug) {
29
+ return slug
30
+ .split(/[-_]/)
31
+ .filter(Boolean)
32
+ .map((segment) => segment.toUpperCase())
33
+ .join('_');
34
+ }
35
+
7
36
  export async function setupModule(context, generator) {
8
37
  const pluginName = context.mu_plugin_name || `${context.projectName}-core`;
38
+ const useAcorn = context.mu_plugin_acorn !== false; // default to Acorn-flavored
9
39
  const pluginDir = `content/mu-plugins/${pluginName}`;
10
40
  const absolutePluginDir = path.join(generator.cwd, pluginDir);
11
41
 
12
- log(color.blue, `[mu-plugin] 📂 Scaffolding MU plugin: ${pluginDir}`);
42
+ // Enrich the template context with derived identifiers used by both flavors.
43
+ const pluginContext = {
44
+ ...context,
45
+ mu_plugin_name: pluginName,
46
+ mu_plugin_namespace: toStudlyCase(pluginName),
47
+ mu_plugin_constant_prefix: toConstantPrefix(pluginName),
48
+ };
49
+
50
+ log(
51
+ color.blue,
52
+ `[mu-plugin] 📂 Scaffolding ${useAcorn ? 'Acorn-flavored' : 'minimal'} MU plugin: ${pluginDir}`
53
+ );
13
54
 
14
55
  // 1. Ensure directory exists
15
56
  await fs.ensureDir(absolutePluginDir);
16
57
 
17
- // 2. Generate main plugin entry file
58
+ if (useAcorn) {
59
+ await scaffoldAcorn(pluginContext, generator, pluginDir, absolutePluginDir);
60
+ } else {
61
+ await scaffoldMinimal(pluginContext, generator, pluginDir, absolutePluginDir);
62
+ }
63
+
64
+ // Lint configs co-located in plugin — always installed (IDE/editor support)
65
+ log(color.blue, '[mu-plugin] 🔧 Installing lint configurations...');
66
+ await generator.copyFile('lint/.prettierrc.json', 'mu-plugin', `${pluginDir}/.prettierrc.json`);
67
+ await generator.copyFile('lint/pint.json', 'mu-plugin', `${pluginDir}/pint.json`);
68
+ if (context.mu_plugin_lint_eslint === true) {
69
+ await generator.copyFile(
70
+ 'lint/eslint.config.mjs',
71
+ 'mu-plugin',
72
+ `${pluginDir}/eslint.config.mjs`
73
+ );
74
+ }
75
+
76
+ log(color.green, `[mu-plugin] ✅ MU plugin scaffolded: ${pluginDir}`);
77
+ }
78
+
79
+ /**
80
+ * Acorn-flavored MU plugin: Bedrock Autoloader bootstrap + plugin's own
81
+ * vendor/ with Roots Acorn 6.1, ServiceProvider scaffolding, Laravel-style
82
+ * config/app/storage/resources layout, and four documented gotcha fixes
83
+ * baked into the plugin entry file.
84
+ */
85
+ async function scaffoldAcorn(context, generator, pluginDir, _absolutePluginDir) {
86
+ const { mu_plugin_name: pluginName } = context;
87
+
88
+ // Bedrock Autoloader bootstrap (lives at the mu-plugins root, NOT inside
89
+ // the plugin directory). Required because native WP does not recurse into
90
+ // subdirectory mu-plugins.
91
+ await generator.copyFile(
92
+ 'templates/bedrock-autoloader.php',
93
+ 'mu-plugin',
94
+ 'content/mu-plugins/bedrock-autoloader.php'
95
+ );
96
+
97
+ // Plugin entry file (Acorn boot, WP-CLI guard, APP_DEBUG=false, Filesystem provider)
18
98
  await generator.generateFile(
19
- 'plugin.php',
20
- { ...context, mu_plugin_name: pluginName },
99
+ 'acorn/plugin.php',
100
+ context,
21
101
  'mu-plugin',
22
102
  `${pluginDir}/${pluginName}.php`
23
103
  );
24
104
 
25
- // 3. Generate composer.json
105
+ // composer.json with type=wordpress-muplugin, Acorn + acf-composer, allow-plugins
26
106
  await generator.generateFile(
27
- 'composer.json',
28
- { ...context, mu_plugin_name: pluginName },
107
+ 'acorn/composer.json',
108
+ context,
29
109
  'mu-plugin',
30
110
  `${pluginDir}/composer.json`
31
111
  );
32
112
 
33
- // 4. Create src/ scaffold
34
- await fs.ensureFile(path.join(absolutePluginDir, 'src', '.gitkeep'));
113
+ // .gitignore for vendor/, composer.lock, storage runtime
114
+ await generator.generateFile('acorn/.gitignore', context, 'mu-plugin', `${pluginDir}/.gitignore`);
35
115
 
36
- // 5. Lint configs co-located in plugin — always installed (IDE/editor support)
37
- log(color.blue, '[mu-plugin] 🔧 Installing lint configurations...');
38
- await generator.copyFile('lint/.prettierrc.json', 'mu-plugin', `${pluginDir}/.prettierrc.json`);
39
- await generator.copyFile('lint/pint.json', 'mu-plugin', `${pluginDir}/pint.json`);
40
- if (context.mu_plugin_lint_eslint === true) {
116
+ // README.md (purpose + structure + install + documented traps)
117
+ await generator.generateFile('acorn/README.md', context, 'mu-plugin', `${pluginDir}/README.md`);
118
+
119
+ // config/ files
120
+ await generator.generateFile(
121
+ 'acorn/config/app.php',
122
+ context,
123
+ 'mu-plugin',
124
+ `${pluginDir}/config/app.php`
125
+ );
126
+ await generator.generateFile(
127
+ 'acorn/config/logging.php',
128
+ context,
129
+ 'mu-plugin',
130
+ `${pluginDir}/config/logging.php`
131
+ );
132
+
133
+ // app/Providers/CoreServiceProvider.php stub
134
+ await generator.generateFile(
135
+ 'acorn/app/Providers/CoreServiceProvider.php',
136
+ context,
137
+ 'mu-plugin',
138
+ `${pluginDir}/app/Providers/CoreServiceProvider.php`
139
+ );
140
+
141
+ // Storage and resources scaffolding (.gitkeep markers committed; runtime
142
+ // contents are ignored via .gitignore above).
143
+ for (const subdir of [
144
+ 'storage/framework/cache',
145
+ 'storage/framework/views',
146
+ 'storage/framework/sessions',
147
+ 'storage/logs',
148
+ 'resources',
149
+ ]) {
41
150
  await generator.copyFile(
42
- 'lint/eslint.config.mjs',
151
+ `templates/acorn/${subdir}/.gitkeep`,
43
152
  'mu-plugin',
44
- `${pluginDir}/eslint.config.mjs`
153
+ `${pluginDir}/${subdir}/.gitkeep`
45
154
  );
46
155
  }
156
+ }
47
157
 
48
- log(color.green, `[mu-plugin] ✅ MU plugin scaffolded: ${pluginDir}`);
158
+ /**
159
+ * Minimal MU plugin: legacy single-file scaffold with PSR-4 `App\MuPlugins\\`
160
+ * to `src/`. Retained for projects that explicitly opt out of Acorn.
161
+ */
162
+ async function scaffoldMinimal(context, generator, pluginDir, absolutePluginDir) {
163
+ const { mu_plugin_name: pluginName } = context;
164
+
165
+ await generator.generateFile(
166
+ 'plugin.php',
167
+ context,
168
+ 'mu-plugin',
169
+ `${pluginDir}/${pluginName}.php`
170
+ );
171
+
172
+ await generator.generateFile('composer.json', context, 'mu-plugin', `${pluginDir}/composer.json`);
173
+
174
+ await fs.ensureFile(path.join(absolutePluginDir, 'src', '.gitkeep'));
49
175
  }
@@ -6,6 +6,13 @@ export default [
6
6
  default: (answers) => `${answers.projectName || 'wordpress'}-core`,
7
7
  when: (answers) => answers.selectedContentModules?.includes('mu-plugin'),
8
8
  },
9
+ {
10
+ type: 'confirm',
11
+ name: 'mu_plugin_acorn',
12
+ message: 'MU Plugin: bootstrap with Roots Acorn (recommended for the Roots stack)?',
13
+ default: true,
14
+ when: (answers) => answers.selectedContentModules?.includes('mu-plugin'),
15
+ },
9
16
  {
10
17
  type: 'confirm',
11
18
  name: 'mu_plugin_lint_pint',
@@ -0,0 +1,10 @@
1
+ /vendor/
2
+ /composer.lock
3
+ /storage/framework/cache/*
4
+ /storage/framework/views/*
5
+ /storage/framework/sessions/*
6
+ /storage/logs/*
7
+ !/storage/framework/cache/.gitkeep
8
+ !/storage/framework/views/.gitkeep
9
+ !/storage/framework/sessions/.gitkeep
10
+ !/storage/logs/.gitkeep