@codigodoleo/wp-kit 5.3.0 → 6.0.1

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 (115) hide show
  1. package/README.md +83 -96
  2. package/lib/commands/init.js +28 -26
  3. package/lib/config/versions.js +27 -1
  4. package/lib/core/cloud-allowlist.js +38 -0
  5. package/lib/core/generator.js +56 -50
  6. package/lib/core/infer-ci-capabilities.js +17 -5
  7. package/lib/prompts/index.js +105 -8
  8. package/lib/utils/auth-template.js +18 -0
  9. package/lib/utils/env-example.js +18 -6
  10. package/lib/utils/git.js +5 -188
  11. package/modules/blank-theme/index.js +1 -1
  12. package/modules/deploy/index.js +15 -0
  13. package/modules/deploy/scripts/check-exposure.sh +63 -0
  14. package/modules/deploy/templates/.github/workflows/ci.yml.hbs +28 -0
  15. package/modules/docs/index.js +18 -18
  16. package/modules/docs/templates/README.md.hbs +1 -1
  17. package/modules/docs/templates/docs/Arquitetura.md.hbs +2 -2
  18. package/modules/docs/templates/docs/Deploy-Pipeline.md.hbs +21 -1
  19. package/modules/docs/templates/docs/Development.md.hbs +236 -0
  20. package/modules/docs/templates/docs/Getting-Started.md.hbs +75 -4
  21. package/modules/docs/templates/docs/Infraestrutura.md.hbs +1 -1
  22. package/modules/docs/templates/docs/Troubleshooting.md.hbs +34 -1
  23. package/modules/git/.husky/kivo-wp/commit-msg +3 -0
  24. package/modules/git/.husky/kivo-wp/pre-commit +25 -0
  25. package/modules/git/.husky/pre-commit +3 -7
  26. package/modules/git/.lintstagedrc.json +5 -2
  27. package/modules/git/index.js +19 -2
  28. package/modules/git/templates/.lando.yml.hbs +5 -0
  29. package/modules/git/templates/package.json.hbs +1 -1
  30. package/modules/kivo-wp/fixtures/menus.json +11 -0
  31. package/modules/kivo-wp/fixtures/options.json +10 -0
  32. package/modules/kivo-wp/fixtures/posts.json +58 -0
  33. package/modules/kivo-wp/fixtures/seed.php +152 -0
  34. package/modules/kivo-wp/fixtures/terms.json +6 -0
  35. package/modules/kivo-wp/fixtures/users.json +26 -0
  36. package/modules/kivo-wp/index.js +193 -0
  37. package/modules/kivo-wp/prompts.js +1 -0
  38. package/modules/kivo-wp/templates/.devcontainer/devcontainer.json.hbs +40 -0
  39. package/modules/kivo-wp/templates/.dockerignore.hbs +15 -0
  40. package/modules/kivo-wp/templates/Dockerfile.hbs +83 -0
  41. package/modules/kivo-wp/templates/bin/_lib.sh.hbs +137 -0
  42. package/modules/kivo-wp/templates/bin/build.hbs +13 -0
  43. package/modules/kivo-wp/templates/bin/composer.hbs +6 -0
  44. package/modules/kivo-wp/templates/bin/db-export.hbs +18 -0
  45. package/modules/kivo-wp/templates/bin/db-import.hbs +26 -0
  46. package/modules/kivo-wp/templates/bin/db.hbs +6 -0
  47. package/modules/kivo-wp/templates/bin/dev.hbs +7 -0
  48. package/modules/kivo-wp/templates/bin/down.hbs +34 -0
  49. package/modules/kivo-wp/templates/bin/e2e.hbs +48 -0
  50. package/modules/kivo-wp/templates/bin/flush.hbs +11 -0
  51. package/modules/kivo-wp/templates/bin/info.hbs +15 -0
  52. package/modules/kivo-wp/templates/bin/logs.hbs +6 -0
  53. package/modules/kivo-wp/templates/bin/mago.hbs +8 -0
  54. package/modules/kivo-wp/templates/bin/node.hbs +6 -0
  55. package/modules/kivo-wp/templates/bin/npm.hbs +6 -0
  56. package/modules/kivo-wp/templates/bin/php.hbs +6 -0
  57. package/modules/kivo-wp/templates/bin/reset-deps.hbs +11 -0
  58. package/modules/kivo-wp/templates/bin/seed.hbs +21 -0
  59. package/modules/kivo-wp/templates/bin/setup.hbs +283 -0
  60. package/modules/kivo-wp/templates/bin/shell.hbs +14 -0
  61. package/modules/kivo-wp/templates/bin/stan.hbs +8 -0
  62. package/modules/kivo-wp/templates/bin/test.hbs +6 -0
  63. package/modules/kivo-wp/templates/bin/trust-cert.hbs +21 -0
  64. package/modules/kivo-wp/templates/bin/up.hbs +6 -0
  65. package/modules/kivo-wp/templates/bin/wp.hbs +6 -0
  66. package/modules/kivo-wp/templates/bin/xdebug.hbs +22 -0
  67. package/modules/kivo-wp/templates/compose.yaml.hbs +117 -0
  68. package/modules/kivo-wp/templates/content/mu-plugins/kivo-wp-local-mail.php.hbs +29 -0
  69. package/modules/kivo-wp/templates/docs/cloud-sessions.md.hbs +34 -0
  70. package/modules/kivo-wp/templates/server/caddy/Caddyfile.hbs +44 -0
  71. package/modules/kivo-wp/templates/server/nginx/deny.conf.hbs +26 -0
  72. package/modules/lint/index.js +22 -14
  73. package/modules/lint/templates/package.json.hbs +6 -0
  74. package/modules/php/index.js +18 -1
  75. package/modules/php/kivo-wp/php-wrapper.sh +3 -0
  76. package/modules/php/kivo-wp/pint-wrapper.sh +3 -0
  77. package/modules/php/templates/phpstan.neon.dist.hbs +27 -0
  78. package/modules/sage/index.js +4 -26
  79. package/modules/sage/templates/bin/theme-lint.hbs +6 -0
  80. package/modules/sage/templates/server/cmd/setup-sage-node.sh.hbs +3 -1
  81. package/modules/sage/templates/server/cmd/setup-sage-php.sh.hbs +3 -1
  82. package/modules/sage/templates/theme/vite.config.js.hbs +20 -2
  83. package/modules/sage/templates/workspace.json.hbs +0 -57
  84. package/modules/skills/index.js +56 -11
  85. package/modules/skills/prompts.js +3 -16
  86. package/modules/test/index.js +13 -11
  87. package/modules/test/phpunit.xml +18 -0
  88. package/modules/test/templates/playwright.config.js.hbs +23 -0
  89. package/modules/test/tests/SmokeTest.php +8 -9
  90. package/modules/test/tests/e2e/smoke.spec.js +28 -0
  91. package/package.json +3 -2
  92. package/templates/.env.hbs +16 -5
  93. package/templates/.gitignore.hbs +8 -1
  94. package/templates/.lando.yml.hbs +3 -9
  95. package/templates/CLAUDE.md.hbs +33 -15
  96. package/templates/README.md.hbs +38 -12
  97. package/templates/composer.json.hbs +1 -1
  98. package/templates/package.json.hbs +8 -1
  99. package/templates/server/cmd/install-wp.sh.hbs +1 -1
  100. package/templates/server/cmd/setup-node.sh.hbs +3 -1
  101. package/templates/server/cmd/setup-php.sh.hbs +63 -9
  102. package/templates/workspace.json.hbs +0 -56
  103. package/{wp-config.php → templates/wp-config.php.hbs} +56 -14
  104. package/modules/docs/templates/docs/Desenvolvimento.md.hbs +0 -127
  105. package/modules/lint/templates/.lando.yml.hbs +0 -5
  106. package/modules/sage/templates/.devcontainer/devcontainer.json.hbs +0 -7
  107. package/modules/sage/templates/.devcontainer/docker-compose.override.yml.hbs +0 -4
  108. package/modules/sage/templates/.devcontainer/post-create.sh.hbs +0 -11
  109. package/templates/.devcontainer/Dockerfile.hbs +0 -24
  110. package/templates/.devcontainer/config/nginx.conf +0 -23
  111. package/templates/.devcontainer/config/nginx.conf.hbs +0 -23
  112. package/templates/.devcontainer/devcontainer.json.hbs +0 -29
  113. package/templates/.devcontainer/docker-compose.yml.hbs +0 -76
  114. package/templates/.devcontainer/setup.sh.hbs +0 -17
  115. package/templates/auth.json.hbs +0 -8
@@ -5,19 +5,19 @@
5
5
  * placeholders inside the generated docs for the team to fill in.
6
6
  */
7
7
  function deriveDocContext(context) {
8
- const isGitHub = context.gitProvider === 'github';
9
- const isGitLab = context.gitProvider === 'gitlab';
10
- const isBitbucket = context.gitProvider === 'bitbucket';
8
+ const isGitHub = context.gitProvider === "github";
9
+ const isGitLab = context.gitProvider === "gitlab";
10
+ const isBitbucket = context.gitProvider === "bitbucket";
11
11
 
12
12
  // Pull request terminology varies by provider; the docs reference it
13
13
  // dozens of times so a single derived string keeps the templates clean.
14
- const prTerm = isGitLab ? 'Merge Request (MR)' : 'Pull Request (PR)';
15
- const prTermShort = isGitLab ? 'MR' : 'PR';
14
+ const prTerm = isGitLab ? "Merge Request (MR)" : "Pull Request (PR)";
15
+ const prTermShort = isGitLab ? "MR" : "PR";
16
16
  const ciSystem = isGitLab
17
- ? 'GitLab CI/CD'
17
+ ? "GitLab CI/CD"
18
18
  : isBitbucket
19
- ? 'Bitbucket Pipelines'
20
- : 'GitHub Actions';
19
+ ? "Bitbucket Pipelines"
20
+ : "GitHub Actions";
21
21
 
22
22
  return {
23
23
  ...context,
@@ -35,17 +35,17 @@ export async function setupModule(context, generator) {
35
35
 
36
36
  // README.md lands at the docs/ entry point (not the project root README,
37
37
  // which is generated by the kit core).
38
- await generator.generateFile('README.md', docContext, 'docs', 'docs/README.md');
38
+ await generator.generateFile("README.md", docContext, "docs", "docs/README.md");
39
39
 
40
40
  const docFiles = [
41
- 'Arquitetura.md',
42
- 'Deploy-Pipeline.md',
43
- 'Desenvolvimento.md',
44
- 'Getting-Started.md',
45
- 'Infraestrutura.md',
46
- 'Monitoramento.md',
47
- 'Sync-the-Production-DB-with-the-Staging-DB.md',
48
- 'Troubleshooting.md',
41
+ "Arquitetura.md",
42
+ "Deploy-Pipeline.md",
43
+ "Development.md",
44
+ "Getting-Started.md",
45
+ "Infraestrutura.md",
46
+ "Monitoramento.md",
47
+ "Sync-the-Production-DB-with-the-Staging-DB.md",
48
+ "Troubleshooting.md",
49
49
  ];
50
50
 
51
51
  // Bug fix: the previous implementation passed `file` as the 4th arg
@@ -53,6 +53,6 @@ export async function setupModule(context, generator) {
53
53
  // inside docs/. Removing that arg restores the template path as the
54
54
  // output path (docs/${file}).
55
55
  for (const file of docFiles) {
56
- await generator.generateFile(`docs/${file}`, docContext, 'docs');
56
+ await generator.generateFile(`docs/${file}`, docContext, "docs");
57
57
  }
58
58
  }
@@ -9,7 +9,7 @@ monitoring tools) as your infrastructure decisions get made.
9
9
  | Document | Purpose |
10
10
  | --- | --- |
11
11
  | [Getting-Started](./Getting-Started.md) | Local environment setup |
12
- | [Desenvolvimento](./Desenvolvimento.md) | Workflow, branching, commit hygiene |
12
+ | [Development](./Development.md) | Workflow, branching, commit hygiene |
13
13
  | [Arquitetura](./Arquitetura.md) | High-level technical architecture |
14
14
  | [Infraestrutura](./Infraestrutura.md) | Cloud / network / runtime topology |
15
15
  | [Deploy-Pipeline](./Deploy-Pipeline.md) | CI/CD flow and environments |
@@ -13,7 +13,7 @@ High-level technical architecture of **{{projectTitle}}**.
13
13
  graph TB
14
14
  subgraph "Developer"
15
15
  DEV[Engineers]
16
- LOCAL[{{projectDomain}}<br/>Lando + Docker]
16
+ LOCAL[{{projectDomain}}<br/>{{#if enable_kivo_wp}}kivo-wp Docker Compose{{else}}Lando + Docker{{/if}}]
17
17
  end
18
18
 
19
19
  subgraph "CI / CD"
@@ -54,7 +54,7 @@ graph TB
54
54
 
55
55
  | Component | Technology | Notes |
56
56
  | --- | --- | --- |
57
- | Database | `{{ "{{TODO: MySQL / MariaDB / managed service}}" }}` | Local dev uses MariaDB via Lando |
57
+ | Database | `{{ "{{TODO: MySQL / MariaDB / managed service}}" }}` | Local dev uses {{#if enable_kivo_wp}}MySQL 8.4 in the kivo-wp `db` service{{else}}MariaDB via Lando{{/if}} |
58
58
  | Object storage | `{{ "{{TODO: S3 / GCS / Azure Blob / NFS}}" }}` | For uploads, backups |
59
59
  | Cache | `{{ "{{TODO: Redis / Memcached / none}}" }}` | Object cache, sessions |
60
60
 
@@ -59,7 +59,27 @@ graph LR
59
59
  - *Docker push + remote pull*: build, push to `{{ "{{TODO: registry}}" }}`, SSH to remote, `docker compose pull && docker compose up -d`.
60
60
  - *Kubernetes*: `kubectl apply -f k8s/<env>/` (or `helm upgrade --install`).
61
61
  - *Cloud-managed (ECS / Cloud Run / App Runner)*: trigger service update with new image tag.
62
- - *SSH rsync*: `rsync -av --delete ./ user@host:/var/www/{{projectName}}/`.
62
+ - *SSH rsync*: sync an **allow list** (`index.php`, `wp-config.php`, `wp-cli.yml`, `vendor/`, `wp/`, `content/`), never `./`. See [Keep files out of the web root](#keep-files-out-of-the-web-root).
63
+
64
+ ## Keep files out of the web root
65
+
66
+ On a VPS/CloudPanel layout the deploy path **is** the document root: nginx serves whatever sits in it. Two
67
+ projects leaked this way (`.env` publicly readable on a production host; `CLAUDE.md`, `AGENTS.md`, `composer.lock`
68
+ and `vendor/composer/installed.json` on a staging host). The rules below are built into the generated project:
69
+
70
+ 1. **`.env` lives one level above the web root** (`<remote-root>/../.env`, mode 600). `wp-config.php` reads it
71
+ from there and falls back to the root when there is no file in the parent ({{#if enable_kivo_wp}}the local kivo-wp environment{{else}}Lando{{/if}}). The generated `ci.yml` passes
72
+ `env-location: parent` to `wp-post-deploy`.
73
+ 2. **Sync an allow list, not the repository.** `deploy-rsync` sends only `wp/`, `vendor/`, `content/*`, `index.php`,
74
+ `wp-config.php`. Anything else at the root (`CLAUDE.md`, `.mcp.json`, `.claude/`, `composer.*`, lint configs,
75
+ `docs/`, `tests/`) is development material. An exclude list fails silently on the first new file; an allow list does not.
76
+ 3. **Check from the outside.** `scripts/check-exposure.sh <url> [theme]` (and the `check-exposure` step in `ci.yml`,
77
+ which needs the `STAGING_URL` / `PRODUCTION_URL` environment variable) fails the deploy if a secret or
78
+ development file answers 200. Run it from an IP **outside** any WAF bypass to see what the public sees; from a
79
+ bypassed IP (your own, a CI runner on an allow list) it shows the origin, the stricter reading.
80
+ 4. **Defence in depth** (a file that slips through still cannot leave the server): deny dotfiles and `vendor/`,
81
+ `composer.*`, `package*.json`, `*.blade.php` in the vhost, and block them with a WAF rule. After deleting a file
82
+ from the origin, purge its URL on the CDN: a cached copy keeps being served.
63
83
 
64
84
  ## Secrets
65
85
 
@@ -0,0 +1,236 @@
1
+ # Development
2
+
3
+ Workflow and conventions for working on **{{projectTitle}}**.
4
+
5
+ {{#if enable_kivo_wp}}
6
+ ## Local environment (kivo-wp)
7
+
8
+ The project runs in a Docker Compose stack named `kivo-wp-{{projectName}}` (services `app`, `db`,
9
+ `cache`, `proxy`, `node`, `mail`). Every tool runs inside it through the scripts in `bin/`; nothing
10
+ needs PHP, Composer or Node.js on your machine.
11
+
12
+ ```bash
13
+ bin/setup # first run and any time after: build, start, install, seed (idempotent)
14
+ bin/up # start the stack
15
+ bin/down # stop it (bin/down --volumes also deletes the database; it asks first)
16
+ bin/info # URLs and service state
17
+ bin/logs # follow the logs
18
+ bin/wp <command> # WP-CLI (bin/wp acorn <command> for Acorn)
19
+ bin/composer <args> # Composer
20
+ bin/npm <args> # npm (bin/node for Node.js)
21
+ bin/build # build the theme assets
22
+ bin/dev # Vite dev server with HMR
23
+ bin/flush # flush WordPress, Acorn and object caches
24
+ bin/db # MySQL client in the db service (echo 'select 1;' | bin/db)
25
+ bin/db-export [file] # dump the local database (mysqldump in the db service)
26
+ bin/test # PHP tests (Pest, phpunit.xml)
27
+ bin/stan # PHPStan (phpstan.neon.dist)
28
+ bin/mago [command] # Mago: lint by default, bin/mago format to format
29
+ bin/e2e # Playwright smoke tests (HTTP only, no browser)
30
+ bin/xdebug on|off # toggle Xdebug without a rebuild
31
+ bin/shell [service] # shell in a service
32
+ ```
33
+
34
+ ### Ports and certificates
35
+
36
+ The site is served by Caddy at **https://{{projectName}}.localhost** with a local certificate
37
+ authority. `HTTPS_PORT` (default 443) and `HTTP_PORT` (default 80) in `.env` set the host ports;
38
+ when one is busy, `bin/setup` picks a free port and writes it to `.env` together with
39
+ `WORDPRESS_SITE_URL` (for example `https://{{projectName}}.localhost:8443`), then rewrites stored URLs
40
+ with `bin/wp search-replace`. Run `bin/trust-cert` once to export the CA and print the command that
41
+ trusts it on Linux, macOS or Windows (WSL).
42
+
43
+ ### Licensed packages
44
+
45
+ {{#if enable_acf_pro}}
46
+ ACF Pro is installed from `connect.advancedcustomfields.com`. Credentials never live in the
47
+ repository: `auth.json.tpl` holds 1Password references and `bin/setup` renders `auth.json` (mode 600,
48
+ gitignored) with `op inject -i auth.json.tpl -o auth.json`. Install the 1Password CLI (`op`) and sign
49
+ in before the first `bin/setup`.
50
+ {{else}}
51
+ No licensed Composer packages are configured. If one is added, keep its credentials as 1Password
52
+ references in `auth.json.tpl` and let `bin/setup` render `auth.json` with `op inject`.
53
+ {{/if}}
54
+
55
+ ### Data
56
+
57
+ `bin/setup` seeds an empty database with synthetic fixtures from `fixtures/` (users, posts, pages,
58
+ terms, a menu and options; every email is on `example.test`). `bin/seed` reseeds them and
59
+ `bin/seed --reset` empties the database first. Fixtures are the only data allowed in CI, Codespaces
60
+ and cloud agent sessions.
61
+
62
+ `bin/db-import <dump.sql[.gz]>` loads a sanitized snapshot. It is a **human-only, local** command: it
63
+ refuses to run when `CI`, `CODESPACES` or `CLAUDE_CODE_REMOTE` is set, and agents must never run it.
64
+ Sanitizing the snapshot (for example `wp db export` without sensitive tables, then an anonymizing
65
+ `wp search-replace`) is the responsibility of whoever produces it.
66
+
67
+ The app image has no MySQL client, so the `bin/wp db` commands that shell out to it (`wp db export`,
68
+ `wp db import`, `wp db query`, `wp db reset`) fail there. `bin/db`, `bin/db-export` and
69
+ `bin/db-import` run the client of the `db` service instead; `bin/seed --reset` recreates the
70
+ database the same way.
71
+ {{else}}
72
+ ## Local environment (Lando, deprecated)
73
+
74
+ Lando remains available for the 6.x line of wp-kit and is removed in 7.0.0. Common commands:
75
+ `lando start`, `lando wp <command>`, `lando composer <args>`, `lando npm <args>`, `lando flush`.
76
+ {{#if enable_acf_pro}}
77
+
78
+ ACF Pro credentials come from 1Password: render `auth.json` once with
79
+ `op inject -i auth.json.tpl -o auth.json` and keep it out of version control.
80
+ {{/if}}
81
+ {{/if}}
82
+
83
+ ## Git workflow
84
+
85
+ This project follows a **GitFlow-derived workflow** with three long-lived
86
+ branches and short-lived branches per piece of work. Adjust to your
87
+ team's needs — the structure below is a sensible default.
88
+
89
+ | Branch | Purpose | Auto-deploys to |
90
+ | --- | --- | --- |
91
+ | `main` (or `master`) | Production-ready code | {{projectProductionDomain}} |
92
+ | `staging` | Pre-production validation | {{projectStagingDomain}} |
93
+ | `development` | Integration of in-flight features | {{projectDevDomain}} |
94
+
95
+ ### Branch types
96
+
97
+ | Prefix | From | To | Purpose |
98
+ | --- | --- | --- | --- |
99
+ | `feature/` | `main` | `development` (via {{prTermShort}}) | New functionality |
100
+ | `bugfix/` | `main` | `development` (via {{prTermShort}}) | Non-critical fixes |
101
+ | `hotfix/` | `main` | `main` + `development` (via {{prTermShort}}) | Critical production fixes |
102
+ | `release/` | `main` | `staging` → `main` (via {{prTermShort}}) | Release preparation |
103
+ | `chore/` | `main` | `development` (via {{prTermShort}}) | Maintenance, deps, docs |
104
+
105
+ ### Naming
106
+
107
+ Use kebab-case in English; the prefix carries the intent.
108
+
109
+ ```text
110
+ feature/user-profile-avatar
111
+ bugfix/header-overlap-on-mobile
112
+ hotfix/auth-bypass-cve-2025-1234
113
+ chore/bump-composer-deps
114
+ release/v1.4.0
115
+ ```
116
+
117
+ ## Feature flow
118
+
119
+ ```mermaid
120
+ graph TD
121
+ A[feature/branch off main] --> B[Open {{prTermShort}} -> development]
122
+ B --> C[Code review]
123
+ C --> D{Approved?}
124
+ D -- No --> E[Address feedback]
125
+ E --> C
126
+ D -- Yes --> F[Merge to development]
127
+ F --> G[Auto-deploy to {{projectDevDomain}}]
128
+ G --> H[QA on dev]
129
+ H --> I[{{prTermShort}} development -> staging]
130
+ I --> J[Merge to staging]
131
+ J --> K[Auto-deploy to {{projectStagingDomain}}]
132
+ K --> L[Final validation]
133
+ L --> M[{{prTermShort}} staging -> main]
134
+ M --> N[Merge to main]
135
+ N --> O[Auto-deploy to {{projectProductionDomain}}]
136
+ ```
137
+
138
+ Direct pushes to `main`, `staging`, and `development` should be blocked
139
+ by branch protection — every change goes through a {{prTermShort}}.
140
+
141
+ ## Commits
142
+
143
+ This project uses [Conventional Commits](https://www.conventionalcommits.org/).
144
+ Husky + commitlint enforce the format locally; CI re-checks on every
145
+ {{prTermShort}}.
146
+
147
+ ```text
148
+ <type>(<scope>): <subject>
149
+
150
+ <body>
151
+
152
+ <footer>
153
+ ```
154
+
155
+ Allowed types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`,
156
+ `test`, `chore`, `ci`, `build`, `revert`.
157
+
158
+ Examples:
159
+
160
+ ```text
161
+ feat(checkout): support PIX payment method
162
+ fix(header): align logo on small viewports
163
+ chore(deps): bump roots/acorn to 6.2
164
+ ```
165
+
166
+ ## Code review checklist
167
+
168
+ - [ ] The {{prTermShort}} description explains *why*, not just *what*.
169
+ - [ ] CI is green (lint, tests, build).
170
+ - [ ] No secrets in code or commit history.
171
+ - [ ] Documentation updated when behaviour changes.
172
+ - [ ] Migration / data-fix steps documented for ops.
173
+ - [ ] Screenshots attached for UI changes.
174
+
175
+ ## Lint and formatting
176
+
177
+ {{#if enable_kivo_wp}}
178
+ ```bash
179
+ bin/npm exec -- oxlint . # JavaScript lint
180
+ bin/npm exec -- oxfmt --write . # Format JS, JSON, YAML and Markdown
181
+ bin/mago lint # PHP lint
182
+ bin/mago format # PHP format
183
+ ```
184
+ {{else}}
185
+ ```bash
186
+ npm run lint # ESLint + Stylelint
187
+ npm run lint:fix # Auto-fix where possible
188
+ npm run format # Prettier
189
+ {{#if useSage}}composer lint --working-dir=content/themes/{{projectName}} # Pint
190
+ composer lint:fix --working-dir=content/themes/{{projectName}}{{/if}}
191
+ ```
192
+ {{/if}}
193
+
194
+ Husky runs lint-staged on every commit so only changed files are
195
+ checked; CI re-runs the full sweep.
196
+
197
+ ## Tests
198
+
199
+ {{#if enable_kivo_wp}}
200
+ - **PHP**: Pest tests in `tests/` (every `*Test.php` file, configured by `phpunit.xml`). Run them
201
+ with `bin/test`; arguments pass through (`bin/test --filter=Smoke`).
202
+ - **Static analysis**: `bin/stan` runs PHPStan with `phpstan.neon.dist` (level 5, WordPress
203
+ extension). Add your plugin and MU plugin code to its `paths`.
204
+ - **E2E**: Playwright specs under `tests/e2e/`. `bin/e2e` runs the `smoke` project: HTTP checks of
205
+ the running site that need no browser.
206
+
207
+ ### End-to-end tests in a browser
208
+
209
+ The `chromium` project (`tests/e2e/example.spec.js`) needs Chromium, its system libraries and
210
+ `certutil` in the `node` service, which the `node` image does not ship. Install them once per
211
+ container (they are lost when the container is recreated), then select the project:
212
+
213
+ ```bash
214
+ bin/e2e --install-chromium # system libraries and certutil (as root), then the browser
215
+ bin/e2e --project=chromium
216
+ ```
217
+
218
+ `bin/e2e` adds Caddy's local CA to the browser's certificate store and the Playwright config sends
219
+ the project host names to the `proxy` service, so no TLS error is ignored.
220
+ {{else}}
221
+ - **PHP**: `{{ "{{TODO: Pest suite location and how to invoke it}}" }}`
222
+ - **E2E**: Playwright specs under `tests/e2e/`. Run locally with `npm run test:e2e`.
223
+ {{/if}}
224
+ - **Visual regression**: `{{ "{{TODO: define if/how visual regression is captured}}" }}`
225
+
226
+ ## Releases
227
+
228
+ Releases are tag-driven. The recommended flow:
229
+
230
+ 1. Open a `release/vX.Y.Z` branch off `main`.
231
+ 2. Bump the version in `package.json` and the project changelog.
232
+ 3. {{prTermShort}} `release/vX.Y.Z` → `staging`; validate.
233
+ 4. {{prTermShort}} `staging` → `main`; tag `vX.Y.Z` on the merge commit.
234
+ 5. {{ciSystem}} deploys the tag to {{projectProductionDomain}}.
235
+
236
+ `{{ "{{TODO: replace this section if the project adopts release-please / semantic-release}}" }}`
@@ -2,11 +2,79 @@
2
2
 
3
3
  Local development setup for **{{projectTitle}}**.
4
4
 
5
+ {{#if enable_kivo_wp}}
5
6
  ## Prerequisites
6
7
 
7
8
  | Tool | Version | Purpose |
8
9
  | --- | --- | --- |
9
- | [Lando](https://lando.dev/) | 3.0+ | Local environment orchestration |
10
+ | [Docker](https://docs.docker.com/get-started/get-docker/) | Engine 24+ with Compose v2 | Runs the kivo-wp stack |
11
+ | [Git](https://git-scm.com/) | any | Version control |
12
+ {{#if enable_acf_pro}}
13
+ | [1Password CLI](https://developer.1password.com/docs/cli/get-started/) | 2.x | Renders `auth.json` for ACF Pro |
14
+ {{/if}}
15
+
16
+ PHP, Composer and Node.js run inside the containers; you do not need them on your machine.
17
+
18
+ ## Clone and bootstrap
19
+
20
+ ```bash
21
+ git clone {{repositoryHttpsUrl}}
22
+ cd {{projectName}}
23
+ bin/setup
24
+ ```
25
+
26
+ `bin/setup` is idempotent and is the only command you need: it creates `.env` from `.env.example`
27
+ when missing, picks free ports, {{#if enable_acf_pro}}renders `auth.json` from 1Password with
28
+ `op inject` (sign in with `op signin` first), {{/if}}builds and starts the stack, installs Composer
29
+ and npm dependencies, builds the theme, installs WordPress ({{wpCoreVersion}}), seeds synthetic
30
+ fixtures into an empty database and prints the URLs and the local admin login. Flags: `--ci`,
31
+ `--quick`, `--fresh` (`bin/setup --help`).
32
+
33
+ Once it finishes, the site is at **https://{{projectName}}.localhost** (with the port from
34
+ `HTTPS_PORT` when it is not 443). Run `bin/trust-cert` once and follow the printed command so your
35
+ browser trusts the local certificate.
36
+
37
+ ## Database
38
+
39
+ The database starts with synthetic fixtures (`bin/seed`, `bin/seed --reset`). To work against a
40
+ sanitized snapshot on your own machine:
41
+
42
+ ```bash
43
+ bin/db-import path/to/sanitized-dump.sql.gz
44
+ bin/wp search-replace 'https://{{projectStagingDomain}}' "$(bin/wp option get home)" --all-tables
45
+ ```
46
+
47
+ `bin/db-import` is a human-only, local command: it refuses to run when `CI`, `CODESPACES` or
48
+ `CLAUDE_CODE_REMOTE` is set, and snapshots never go to CI, Codespaces or cloud agent sessions.
49
+
50
+ {{#if useSage}}
51
+ ## Theme build
52
+
53
+ The Sage theme lives under `content/themes/{{projectName}}`. Vite drives the asset pipeline:
54
+
55
+ ```bash
56
+ bin/dev # HMR dev server through https://vite.{{projectName}}.localhost
57
+ bin/build # Production build
58
+ ```
59
+ {{/if}}
60
+
61
+ ## Common commands
62
+
63
+ ```bash
64
+ bin/up # Start the stack
65
+ bin/down # Stop it
66
+ bin/info # URLs and service state
67
+ bin/logs # Follow container logs
68
+ bin/wp <command> # WP-CLI
69
+ bin/shell # Shell in the app service
70
+ bin/down --volumes # Delete the stack's data (asks first)
71
+ ```
72
+ {{else}}
73
+ ## Prerequisites
74
+
75
+ | Tool | Version | Purpose |
76
+ | --- | --- | --- |
77
+ | [Lando](https://lando.dev/) | 3.0+ | Local environment orchestration (deprecated; removed in wp-kit 7.0.0) |
10
78
  | [Docker](https://docker.com/) | 20.0+ | Container runtime backing Lando |
11
79
  | [Git](https://git-scm.com/) | any | Version control |
12
80
  | [Node.js](https://nodejs.org/) | {{nodeVersion}}+ | Build pipeline (Vite, lint) |
@@ -17,6 +85,9 @@ Local development setup for **{{projectTitle}}**.
17
85
  ```bash
18
86
  git clone {{repositoryHttpsUrl}}
19
87
  cd {{projectName}}
88
+ {{#if enable_acf_pro}}
89
+ op inject -i auth.json.tpl -o auth.json # ACF Pro credentials from 1Password
90
+ {{/if}}
20
91
  lando start
21
92
  ```
22
93
 
@@ -63,6 +134,7 @@ lando wp <command> # Run WP-CLI against the Lando WordPress
63
134
  lando ssh # Shell into the appserver
64
135
  lando destroy # Wipe containers (data is preserved on disk)
65
136
  ```
137
+ {{/if}}
66
138
 
67
139
  ## Editor setup
68
140
 
@@ -73,11 +145,10 @@ open.
73
145
 
74
146
  ## What to read next
75
147
 
76
- - [Desenvolvimento](./Desenvolvimento.md) — git workflow and {{prTermShort}} hygiene
148
+ - [Development](./Development.md) — local environment, git workflow and {{prTermShort}} hygiene
77
149
  - [Arquitetura](./Arquitetura.md) — how the pieces fit together
78
150
 
79
151
  ## Troubleshooting
80
152
 
81
153
  If anything goes wrong during the first boot, check
82
- [Troubleshooting](./Troubleshooting.md) — common Lando/Docker issues
83
- are listed there.
154
+ [Troubleshooting](./Troubleshooting.md).
@@ -62,7 +62,7 @@ In production behind edge auth, provision **both** parts:
62
62
  prefix, so this defines `DISABLE_WP_CRON`. It must be `WORDPRESS_DISABLE_WP_CRON` — not
63
63
  `WORDPRESS_DISABLE_CRON`, which would define `DISABLE_CRON` and be ignored by WordPress.
64
64
 
65
- Do not enable this in the local `.env`: under Lando the loopback works and is convenient.
65
+ Do not enable this in the local `.env`: under {{#if enable_kivo_wp}}kivo-wp{{else}}Lando{{/if}} the loopback works and is convenient{{#if enable_kivo_wp}} (bin/setup sets it only in Codespaces){{/if}}.
66
66
  See [Troubleshooting](./Troubleshooting.md) for the symptom and diagnosis.
67
67
 
68
68
  ## Secrets and IAM
@@ -18,6 +18,38 @@ Each entry follows the same shape:
18
18
 
19
19
  ---
20
20
 
21
+ {{#if enable_kivo_wp}}
22
+ ### `bin/setup` reports "ports are not available"
23
+
24
+ **Symptom**: the stack does not start and Docker reports that a host port is not available.
25
+ **Likely cause**: another local stack, a system service or (on WSL) a Windows service holds the port
26
+ set by `HTTPS_PORT` or `HTTP_PORT` in `.env`.
27
+ **Fix**:
28
+
29
+ 1. Run `bin/setup` again: it moves busy ports to free ones and updates `WORDPRESS_SITE_URL`.
30
+ 2. To choose the ports yourself, set `HTTPS_PORT` and `HTTP_PORT` in `.env` and run `bin/setup`.
31
+ 3. `sudo lsof -i :443` identifies a process holding a port on Linux and macOS.
32
+
33
+ **Why this is the fix**: Caddy publishes the host ports from `.env`; `bin/setup` keeps the site URL in
34
+ step with them and rewrites stored URLs.
35
+
36
+ ### WP-CLI prints "PHP Deprecated: Using null as an array offset"
37
+
38
+ **Symptom**: on PHP 8.5, `bin/wp` (and `bin/setup`, which calls it) prints
39
+ `PHP Deprecated: Using null as an array offset is deprecated` from
40
+ `phar:///usr/local/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/Colors.php` before the command output.
41
+ **Likely cause**: WP-CLI 2.12.0, the latest release, bundles a `php-cli-tools` version written
42
+ before PHP 8.5. The notice comes from WP-CLI itself, not from the project code.
43
+ **Fix**:
44
+
45
+ 1. Ignore it: the command still runs and its result is correct.
46
+ 2. When WP-CLI publishes a release with the fix, update `WP_CLI_VERSION` and `WP_CLI_SHA512` in the
47
+ `Dockerfile` and rebuild with `bin/setup`.
48
+
49
+ **Why this is the fix**: the notice is a deprecation, not an error, and only a new WP-CLI phar
50
+ removes it; hiding deprecations would also hide the project's own.
51
+
52
+ {{else}}
21
53
  ### `lando start` fails with "port already in use"
22
54
 
23
55
  **Symptom**: Lando fails to start with `Error starting the network: ports are not available`.
@@ -31,6 +63,7 @@ Each entry follows the same shape:
31
63
 
32
64
  **Why this is the fix**: Lando binds host ports; conflicts surface as start failures, not run failures.
33
65
 
66
+ {{/if}}
34
67
  ---
35
68
 
36
69
  ### Composer install hangs or 404s on a wpackagist plugin
@@ -64,7 +97,7 @@ Each entry follows the same shape:
64
97
 
65
98
  ### Scheduled tasks never run / a plugin screen stays empty (behind edge auth)
66
99
 
67
- **Symptom**: A plugin admin screen that loads data via a background refresh never populates (e.g. an items list spins or returns empty forever). More generally: any `wp_schedule_event` / WP-Cron job silently never fires in production, while the same code works under Lando.
100
+ **Symptom**: A plugin admin screen that loads data via a background refresh never populates (e.g. an items list spins or returns empty forever). More generally: any `wp_schedule_event` / WP-Cron job silently never fires in production, while the same code works under {{#if enable_kivo_wp}}kivo-wp{{else}}Lando{{/if}}.
68
101
  **Likely cause**: The site is behind **Cloudflare Access** (or any edge auth fronting the whole domain). Default WP-Cron fires via a loopback HTTP request to `/wp/wp-cron.php`, which the edge `302`-redirects to its login — so `wp-cron.php` never executes and no scheduled event runs. The browser's `admin-ajax` still works (it carries the auth cookie), so the page loads but the background job never completes.
69
102
  **Fix**:
70
103
 
@@ -0,0 +1,3 @@
1
+ # kivo-wp: commitlint runs in the node service through bin/npm.
2
+ echo "🔍 Validating commit message..."
3
+ bin/npm exec -- commitlint --edit "$1"
@@ -0,0 +1,25 @@
1
+ # kivo-wp: every tool runs in the Compose stack through bin/* (start it with bin/up).
2
+ echo "🔍 Running pre-commit checks..."
3
+
4
+ if [ -z "$(git diff --cached --name-only)" ]; then
5
+ echo "â„šī¸ No staged files, skipping pre-commit checks"
6
+ exit 0
7
+ fi
8
+
9
+ if [ -f ".lintstagedrc.json" ]; then
10
+ echo "📝 Running lint-staged..."
11
+ bin/npm exec -- lint-staged
12
+ fi
13
+
14
+ # PHP formatting: the node service has no PHP, so staged PHP files are formatted with
15
+ # bin/mago in the app service and staged again.
16
+ php_files="$(git diff --cached --name-only --diff-filter=ACMR -- '*.php')"
17
+ if [ -n "$php_files" ] && [ -f vendor/bin/mago ]; then
18
+ echo "🐘 Formatting staged PHP files with Mago..."
19
+ echo "$php_files" | while IFS= read -r file; do
20
+ bin/mago format "$file"
21
+ git add -- "$file"
22
+ done
23
+ fi
24
+
25
+ echo "✅ Pre-commit checks completed!"
@@ -12,13 +12,9 @@ if [ -z "$(git diff --cached --name-only)" ]; then
12
12
  exit 0
13
13
  fi
14
14
 
15
+ # lint-staged runs where git runs (the host); its PHP entries reach the
16
+ # environment through their own commands.
15
17
  echo "📝 Running lint-staged..."
16
- if command -v lando >/dev/null 2>&1 && lando info >/dev/null 2>&1; then
17
- echo "đŸŗ Using Lando environment..."
18
- lando lint-staged
19
- else
20
- echo "🏠 Using local environment..."
21
- npx lint-staged
22
- fi
18
+ npx --no lint-staged
23
19
 
24
20
  echo "✅ Pre-commit checks completed!"
@@ -1,4 +1,7 @@
1
1
  {
2
- "*.{js,mjs,ts,vue,jsx,tsx}": ["oxfmt --write", "oxlint --fix"],
3
- "*.{json,jsonc,html,yml,yaml,md,mdx}": ["oxfmt --write"]
2
+ "*.{js,mjs,ts,vue,jsx,tsx}": [
3
+ "oxfmt --write --no-error-on-unmatched-pattern",
4
+ "oxlint --fix --no-error-on-unmatched-pattern"
5
+ ],
6
+ "*.{json,jsonc,html,yml,yaml,md,mdx}": ["oxfmt --write --no-error-on-unmatched-pattern"]
4
7
  }
@@ -84,13 +84,30 @@ export async function setupModule(context, generator) {
84
84
 
85
85
  await generator.copyFile(".commitlintrc.json", "git");
86
86
  await generator.copyFile(".lintstagedrc.json", "git");
87
- await generator.copyFile(".husky/commit-msg", "git");
88
- await generator.copyFile(".husky/pre-commit", "git");
87
+ // kivo-wp hooks run every tool through bin/*; the Lando hooks stay for the deprecated choice.
88
+ const hooksDir = context.enable_kivo_wp ? ".husky/kivo-wp" : ".husky";
89
+ await generator.copyFile(`${hooksDir}/commit-msg`, "git", ".husky/commit-msg");
90
+ await generator.copyFile(`${hooksDir}/pre-commit`, "git", ".husky/pre-commit");
89
91
 
90
92
  await generator.copyFile(".vscode/conventional-commits.code-snippets", "git");
91
93
  await generator.copyFile(".vscode/copilot.json", "git");
92
94
  await generator.copyFile(".vscode/commit-instructions.md", "git");
93
95
  await generator.copyFile("docs/CONVENTIONAL-COMMITS.md", "git");
96
+ if (context.enable_kivo_wp) {
97
+ // kivo-wp runs the commit tooling in the node service through bin/npm.
98
+ const doc = path.join(generator.cwd, "docs/CONVENTIONAL-COMMITS.md");
99
+ const text = (await fs.readFile(doc, "utf8"))
100
+ .replaceAll("lando git-cz", "bin/npm exec -- git-cz")
101
+ .replaceAll(
102
+ "lando commitlint-check",
103
+ "bin/npm exec -- commitlint --from HEAD~1 --to HEAD --verbose",
104
+ )
105
+ .replaceAll(
106
+ "lando conventional-changelog",
107
+ "bin/npm exec -- conventional-changelog -p angular -i CHANGELOG.md -s",
108
+ );
109
+ await fs.outputFile(doc, text);
110
+ }
94
111
 
95
112
  await fs.chmod(path.join(generator.cwd, ".husky/commit-msg"), 0o755);
96
113
  await fs.chmod(path.join(generator.cwd, ".husky/pre-commit"), 0o755);
@@ -1,4 +1,9 @@
1
1
  tooling:
2
+ # Used by .husky/commit-msg; it lives here because this module installs the hook.
3
+ commitlint:
4
+ service: build
5
+ description: Validate commit message format
6
+ cmd: npx --no commitlint --edit
2
7
  git-cz:
3
8
  service: appserver
4
9
  description: Make commit using Conventional Commits
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "scripts": {
3
3
  "prepare": "husky",
4
- "commit": "lando git-cz"
4
+ "commit": "{{#if enable_kivo_wp}}bin/npm exec -- git-cz{{else}}lando git-cz{{/if}}"
5
5
  },
6
6
  "devDependencies": {
7
7
  "@commitlint/cli": "^19.7.1",
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "name": "Primary",
4
+ "location": "primary_navigation",
5
+ "items": [
6
+ { "page": "home", "title": "Home" },
7
+ { "page": "about", "title": "About" },
8
+ { "page": "contact", "title": "Contact" }
9
+ ]
10
+ }
11
+ ]