@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
@@ -10,12 +10,23 @@ WP_CORE_VERSION="{{wpCoreVersion}}"
10
10
  SAGE_VERSION="{{sageVersion}}"
11
11
  {{/if}}
12
12
  GIT_REPOSITORY="{{gitRepository}}"
13
+ {{#if enable_kivo_wp}}
14
+
15
+ ### kivo-wp ###
16
+ # Host ports of the Caddy proxy; bin/setup picks free ones when these are busy.
17
+ HTTPS_PORT=443
18
+ HTTP_PORT=80
19
+ {{/if}}
13
20
 
14
21
  WORDPRESS_SITE_URL="https://{{projectDomain}}"
15
22
  WORDPRESS_DB_NAME="wordpress"
16
23
  WORDPRESS_DB_USER="wordpress"
17
24
  WORDPRESS_DB_PASSWORD="wordpress"
25
+ {{#if enable_kivo_wp}}
26
+ WORDPRESS_DB_HOST="db"
27
+ {{else}}
18
28
  WORDPRESS_DB_HOST="database"
29
+ {{/if}}
19
30
  WORDPRESS_DB_CHARSET="utf8"
20
31
  WORDPRESS_DB_COLLATE=""
21
32
  WORDPRESS_TABLE_PREFIX="wp_"
@@ -35,7 +46,7 @@ WORDPRESS_WP_AUTO_UPDATE_CORE=false
35
46
 
36
47
  ### Redis ###
37
48
  {{#if enable_redis}}
38
- WORDPRESS_REDIS_HOST=redis
49
+ WORDPRESS_REDIS_HOST=cache
39
50
  WORDPRESS_REDIS_PORT=6379
40
51
  {{/if}}
41
52
 
@@ -49,7 +60,7 @@ WORDPRESS_SECURE_AUTH_SALT={{{salts.SECURE_AUTH_SALT}}}
49
60
  WORDPRESS_LOGGED_IN_SALT={{{salts.LOGGED_IN_SALT}}}
50
61
  WORDPRESS_NONCE_SALT={{{salts.NONCE_SALT}}}
51
62
 
52
- # Observability (hekivo-audit-log, fatia #5) — preencher via deploy (op://) ou
53
- # scripts/push-obs-creds-to-site.sh do hekivo-mgmt:
54
- # HEKIVO_AUDIT_CW_ACCESS_KEY_ID="op://Client-<Nome>/cloudwatch-observability-push/username"
55
- # HEKIVO_AUDIT_CW_SECRET_ACCESS_KEY="op://Client-<Nome>/cloudwatch-observability-push/password"
63
+ # Observability (hekivo-audit-log): filled by the deploy (op://) or by
64
+ # hekivo-mgmt's scripts/push-obs-creds-to-site.sh:
65
+ # HEKIVO_AUDIT_CW_ACCESS_KEY_ID="op://Client-<Name>/cloudwatch-observability-push/username"
66
+ # HEKIVO_AUDIT_CW_SECRET_ACCESS_KEY="op://Client-<Name>/cloudwatch-observability-push/password"
@@ -16,7 +16,8 @@ content/languages/*
16
16
  !content/languages/.gitkeep
17
17
  content/mu-plugins/*
18
18
  !content/mu-plugins/.gitkeep
19
- {{#if enable_mu_plugin}}!content/mu-plugins/{{mu_plugin_name}}
19
+ {{#if enable_kivo_wp}}!content/mu-plugins/kivo-wp-local-mail.php
20
+ {{/if}}{{#if enable_mu_plugin}}!content/mu-plugins/{{mu_plugin_name}}
20
21
  {{#if mu_plugin_acorn}}!content/mu-plugins/bedrock-autoloader.php
21
22
  {{/if}}{{/if}}
22
23
 
@@ -77,8 +78,13 @@ public/build/
77
78
  *.backup
78
79
  *.old
79
80
 
81
+ {{#unless enable_kivo_wp}}
80
82
  # Lando
81
83
  .lando.local.yml
84
+ {{/unless}}
85
+ # Local environment overrides and agent caches
86
+ compose.override.yaml
87
+ .kivo-wise/
82
88
 
83
89
  # PHP
84
90
  *.php~
@@ -88,6 +94,7 @@ php_errors.log
88
94
  # Testing
89
95
  coverage/
90
96
  .phpunit.result.cache
97
+ .phpunit.cache/
91
98
 
92
99
  # Environment (local secrets: WP salts, DB credentials)
93
100
  /.env
@@ -10,21 +10,15 @@ config:
10
10
  via: nginx
11
11
  php: "{{phpVersion}}"
12
12
  database: mariadb
13
- cache: redis
14
13
  xdebug: true
15
- extra_php_extensions:
16
- - bcmath
17
- - exif
18
- - gd
19
- - mysqli
20
- - zip
21
- - imagick
22
- - redis
23
14
  config:
24
15
  php: ./server/php/php.ini
25
16
  vhosts: ./server/www/vhosts.conf
26
17
  services:
27
18
  appserver:
19
+ # The wordpress recipe ignores config.extra_php_extensions; extensions are installed here.
20
+ build_as_root:
21
+ - bash /app/server/cmd/setup-php.sh --extensions
28
22
  build:
29
23
  - bash /app/server/cmd/setup-php.sh
30
24
  overrides:
@@ -1,7 +1,7 @@
1
1
  # {{projectName}}
2
2
 
3
3
  > WordPress project scaffolded by [wp-kit](https://github.com/codigodoleo/wp-kit), using the
4
- > [Roots](https://roots.io/) ecosystem: Bedrock, Sage, Acorn, and Lando.
4
+ > [Roots](https://roots.io/) ecosystem: Bedrock, Sage and Acorn, {{#if enable_kivo_wp}}on the kivo-wp Docker Compose environment{{else}}with Lando{{/if}}.
5
5
 
6
6
  ## Stack
7
7
 
@@ -9,7 +9,17 @@
9
9
  - Node.js {{nodeVersion}}
10
10
  - WordPress {{wpCoreVersion}}
11
11
  {{#if useSage}}- Sage {{sageVersion}} + Acorn
12
- {{/if}}- Lando (local development)
12
+ {{/if}}{{#if enable_kivo_wp}}- kivo-wp Docker Compose environment (local development; tools only through `bin/*`)
13
+
14
+ ## Local Development
15
+
16
+ ```bash
17
+ bin/setup # Build, start, install and seed (idempotent)
18
+ bin/dev # HMR dev server (Vite)
19
+ bin/build # Production build
20
+ bin/wp <command> # WP-CLI (bin/wp acorn <command> for Acorn)
21
+ ```
22
+ {{else}}- Lando (local development)
13
23
 
14
24
  ## Local Development
15
25
 
@@ -18,25 +28,27 @@ lando start
18
28
  lando dev # HMR dev server (Vite)
19
29
  lando theme-build # Production build
20
30
  ```
31
+ {{/if}}
21
32
 
22
33
  ## AI Co-Pilot
23
34
 
24
- This project includes [superpowers](https://github.com/obra/superpowers) and [superpowers-sage](https://github.com/codigodoleo/superpowers-sage) in `.claude/`.
25
- Start a session with:
35
+ {{#if enable_skills}}
36
+ `.claude/settings.json` enables [kivo-wise](https://github.com/hekivo/kivo-wise), the agent plugin
37
+ for WordPress on the Roots stack (marketplace `hekivo/kivo-wise`, plugin `kivo-wise@kivo-wise`).
38
+ Claude Code offers to install it the first time you trust this folder; to install it by hand:
26
39
 
40
+ ```bash
41
+ claude plugin marketplace add hekivo/kivo-wise
42
+ claude plugin install kivo-wise@kivo-wise
27
43
  ```
28
- /sage-onboard
29
- ```
30
-
31
- Available commands:
32
44
 
33
- | Command | Purpose |
34
- |---|---|
35
- | `/sage-onboard` | Project analysis and overview |
36
- | `/sage-plan` | Architecture decision for a new feature |
37
- | `/sage-scaffold` | Run generators and create stubs |
38
- | `/sage-review` | Review code against conventions |
39
- | `/sage-debug` | Guided troubleshooting |
45
+ At session start it detects the project and its runner; `/roots-status` prints what it found and the
46
+ `roots-onboarding` skill maps the project. Other assistants (Cursor, Codex, Copilot) are covered in
47
+ the kivo-wise README.
48
+ {{else}}
49
+ No agent plugin is enabled. To add kivo-wise, the plugin for WordPress on the Roots stack, see
50
+ https://github.com/hekivo/kivo-wise.
51
+ {{/if}}
40
52
 
41
53
  ## Theme
42
54
 
@@ -44,9 +56,15 @@ Available commands:
44
56
  Theme located at `content/themes/{{themeName}}/`.
45
57
 
46
58
  ```bash
59
+ {{#if enable_kivo_wp}}
60
+ bin/reset-deps # Reinstall theme dependencies
61
+ bin/wp acorn make:component ComponentName
62
+ bin/wp acorn acf:block BlockName
63
+ {{else}}
47
64
  lando theme-bootstrap # Install theme dependencies
48
65
  lando acorn make:component ComponentName
49
66
  lando acorn acf:block BlockName
67
+ {{/if}}
50
68
  ```
51
69
  {{else}}
52
70
  No Sage theme configured.
@@ -2,26 +2,52 @@
2
2
 
3
3
  Scaffolded by [wp-kit](https://github.com/hekivo/wp-kit).
4
4
 
5
- ## 🧱 Stack
5
+ ## Getting started
6
+
7
+ {{#if enable_kivo_wp}}
8
+ You need Docker with Compose v2 and Git; PHP, Composer and Node.js run inside the containers.
9
+
10
+ ```bash
11
+ bin/setup # build, start, install and seed (idempotent; run it again any time)
12
+ bin/trust-cert # once: trust the local certificate in your browser
13
+ ```
14
+
15
+ The site answers at `https://{{projectName}}.localhost` (with the port from `HTTPS_PORT` in `.env`
16
+ when it is not 443). `bin/info` prints the URLs; `bin/up` and `bin/down` start and stop the stack.
17
+ {{else}}
18
+ ```bash
19
+ lando start
20
+ ```
21
+ {{/if}}
22
+ {{#if enable_docs}}
23
+
24
+ Full setup, commands and troubleshooting: [docs/Getting-Started.md](docs/Getting-Started.md),
25
+ [docs/Development.md](docs/Development.md) and [docs/Troubleshooting.md](docs/Troubleshooting.md).
26
+ {{/if}}
27
+
28
+ ## Stack
6
29
 
7
30
  - PHP {{phpVersion}}
8
31
  - Node.js {{nodeVersion}}
32
+ {{#if useSage}}
33
+
34
+ ## Blocks with ACF Composer
9
35
 
10
- ## 🧩 Blocos com ACF Composer
36
+ The Sage theme builds blocks with ACF Composer:
11
37
 
12
- Quando Sage estiver habilitado, o projeto usa o fluxo de blocos via ACF Composer.
38
+ - Block classes: `content/themes/{{projectName}}/app/Blocks`
39
+ - ACF fields: `content/themes/{{projectName}}/app/Fields`
40
+ - Block Blade views: `content/themes/{{projectName}}/resources/views/blocks`
13
41
 
14
- - Classes de blocos: `content/themes/{{projectName}}/app/Blocks`
15
- - Fields do ACF: `content/themes/{{projectName}}/app/Fields`
16
- - Views Blade dos blocos: `content/themes/{{projectName}}/resources/views/blocks`
42
+ Quick flow:
17
43
 
18
- Fluxo rapido:
19
- 1. Criar classe do bloco com `wp acorn make:component NomeDoBloco`.
20
- 2. Definir fields em `app/Fields` com ACF Composer.
21
- 3. Renderizar o bloco em `resources/views/blocks`.
44
+ 1. Create the block class with {{#if enable_kivo_wp}}`bin/wp acorn acf:block BlockName`{{else}}`lando acorn acf:block BlockName`{{/if}}.
45
+ 2. Define its fields in `app/Fields` with ACF Composer.
46
+ 3. Render the block in `resources/views/blocks`.
22
47
 
23
- Requisito: plugin Advanced Custom Fields (ACF) ativo no WordPress.
48
+ Requirement: the Advanced Custom Fields (ACF) plugin active in WordPress.
49
+ {{/if}}
24
50
 
25
- ## 👤 Author
51
+ ## Author
26
52
 
27
53
  {{author}}
@@ -24,7 +24,7 @@
24
24
  "roots/wordpress": "{{wpCoreVersion}}",
25
25
  "roots/bedrock-autoloader": "1.0",
26
26
  "inpsyde/wp-translation-downloader": "2.5",
27
- "vlucas/phpdotenv": "5.5"{{#if enable_acf_pro}},
27
+ "vlucas/phpdotenv": "^5.6.2"{{#if enable_acf_pro}},
28
28
  "wordpress/mcp-adapter": "0.5.0",
29
29
  "wpengine/advanced-custom-fields-pro": "^6.4"{{/if}}
30
30
  },
@@ -15,10 +15,17 @@
15
15
  "homepage": "{{gitRepository}}#readme",
16
16
  "scripts": {
17
17
  "test": "echo \"No tests specified\" && exit 0",
18
+ {{#if enable_kivo_wp}}
19
+ "composer:install": "bin/composer install",
20
+ "composer:update": "bin/composer update",
21
+ "wp:info": "bin/wp --info",
22
+ "wp:help": "bin/wp help"
23
+ {{else}}
18
24
  "composer:install": "lando composer install",
19
25
  "composer:update": "lando composer update",
20
26
  "wp:info": "lando wp --info",
21
27
  "wp:help": "lando wp help"
28
+ {{/if}}
22
29
  },
23
30
  "devDependencies": {
24
31
  "@cspell/dict-php": "^4.0.14",
@@ -34,7 +41,7 @@
34
41
  },
35
42
  "keywords": [
36
43
  "wordpress",
37
- "lando",
44
+ "{{#if enable_kivo_wp}}kivo-wp{{else}}lando{{/if}}",
38
45
  "devops",
39
46
  "ci-cd",
40
47
  "gitflow",
@@ -45,7 +45,7 @@ wp core install \
45
45
  --title="${PROJECT_NAME:-WordPress Development}" \
46
46
  --admin_user="${WORDPRESS_ADMIN_USER:-admin}" \
47
47
  --admin_password="${WORDPRESS_ADMIN_PASSWORD:-admin}" \
48
- --admin_email="${WORDPRESS_ADMIN_EMAIL:-admin@example.com}" \
48
+ --admin_email="${WORDPRESS_ADMIN_EMAIL:-admin@example.test}" \
49
49
  --skip-email \
50
50
  --path="${WP_PATH}"
51
51
 
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  # Installs root Node.js dependencies via npm.
3
- # Invoked from: Lando (build service build step), Devcontainer (setup.sh), CI/CD.
3
+ {{#if enable_kivo_wp}}# Invoked from: kivo-wp bin/setup and bin/reset-deps (inside the containers), CI/CD.
4
+ {{else}}# Invoked from: Lando (build service build step), CI/CD.
5
+ {{/if}}
4
6
  set -euo pipefail
5
7
 
6
8
  PROJECT_ROOT="${PROJECT_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
@@ -1,14 +1,68 @@
1
1
  #!/usr/bin/env bash
2
- # Installs root PHP dependencies via Composer.
3
- # Invoked from: Lando (appserver build step), Devcontainer (setup.sh), CI/CD.
2
+ # Installs root PHP dependencies via Composer, or the PHP extensions WordPress needs.
3
+ {{#if enable_kivo_wp}}# Invoked from: kivo-wp bin/setup and bin/reset-deps (inside the containers), CI/CD.
4
+ {{else}}# Invoked from: Lando (appserver build steps), CI/CD.
5
+ {{/if}}
6
+ #
7
+ # Usage:
8
+ # setup-php.sh composer install (non-root build step)
9
+ # setup-php.sh --extensions install missing PHP extensions (root build step); a no-op when
10
+ # php -m already lists every required extension
4
11
  set -euo pipefail
5
12
 
6
13
  PROJECT_ROOT="${PROJECT_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
7
14
 
8
- echo "Installing PHP dependencies..."
9
- composer install \
10
- --working-dir="${PROJECT_ROOT}" \
11
- --no-interaction \
12
- --no-progress \
13
- --optimize-autoloader
14
- echo "PHP dependencies installed."
15
+ REQUIRED_EXTENSIONS=(bcmath exif gd mysqli zip imagick redis)
16
+
17
+ install_extensions() {
18
+ local loaded missing=()
19
+ loaded="$(php -m | tr '[:upper:]' '[:lower:]')"
20
+ for ext in "${REQUIRED_EXTENSIONS[@]}"; do
21
+ if ! grep -qx "${ext}" <<<"${loaded}"; then
22
+ missing+=("${ext}")
23
+ fi
24
+ done
25
+
26
+ if [ "${#missing[@]}" -eq 0 ]; then
27
+ echo "PHP extensions already present: ${REQUIRED_EXTENSIONS[*]}"
28
+ return 0
29
+ fi
30
+
31
+ if [ "$(id -u)" -ne 0 ]; then
32
+ echo "Missing PHP extensions (${missing[*]}) need a root build step." >&2
33
+ return 1
34
+ fi
35
+
36
+ echo "Installing missing PHP extensions: ${missing[*]}"
37
+ for ext in "${missing[@]}"; do
38
+ case "${ext}" in
39
+ imagick | redis)
40
+ pecl install "${ext}" </dev/null
41
+ docker-php-ext-enable "${ext}"
42
+ ;;
43
+ *)
44
+ docker-php-ext-install -j"$(nproc)" "${ext}"
45
+ ;;
46
+ esac
47
+ done
48
+ echo "PHP extensions installed."
49
+ }
50
+
51
+ install_dependencies() {
52
+ echo "Installing PHP dependencies..."
53
+ composer install \
54
+ --working-dir="${PROJECT_ROOT}" \
55
+ --no-interaction \
56
+ --no-progress \
57
+ --optimize-autoloader
58
+ echo "PHP dependencies installed."
59
+ }
60
+
61
+ case "${1:-}" in
62
+ --extensions) install_extensions ;;
63
+ "") install_dependencies ;;
64
+ *)
65
+ echo "Unknown option: $1" >&2
66
+ exit 2
67
+ ;;
68
+ esac
@@ -170,62 +170,6 @@
170
170
  "panel": "shared"
171
171
  },
172
172
  "problemMatcher": []
173
- },
174
- {
175
- "label": "🐳 Devcontainer: Up",
176
- "type": "shell",
177
- "command": "docker",
178
- "args": ["compose", "-f", ".devcontainer/docker-compose.yml", "up", "-d", "--build"],
179
- "group": "build",
180
- "presentation": {
181
- "echo": true,
182
- "reveal": "always",
183
- "focus": false,
184
- "panel": "shared"
185
- },
186
- "problemMatcher": []
187
- },
188
- {
189
- "label": "🐳 Devcontainer: Down",
190
- "type": "shell",
191
- "command": "docker",
192
- "args": ["compose", "-f", ".devcontainer/docker-compose.yml", "down"],
193
- "group": "build",
194
- "presentation": {
195
- "echo": true,
196
- "reveal": "always",
197
- "focus": false,
198
- "panel": "shared"
199
- },
200
- "problemMatcher": []
201
- },
202
- {
203
- "label": "🐳 Devcontainer: Rebuild",
204
- "type": "shell",
205
- "command": "docker",
206
- "args": ["compose", "-f", ".devcontainer/docker-compose.yml", "up", "-d", "--build", "--force-recreate"],
207
- "group": "build",
208
- "presentation": {
209
- "echo": true,
210
- "reveal": "always",
211
- "focus": false,
212
- "panel": "shared"
213
- },
214
- "problemMatcher": []
215
- },
216
- {
217
- "label": "🐳 Devcontainer: Bootstrap",
218
- "type": "shell",
219
- "command": "docker",
220
- "args": ["compose", "-f", ".devcontainer/docker-compose.yml", "exec", "wordpress", "bash", ".devcontainer/setup.sh"],
221
- "group": "build",
222
- "presentation": {
223
- "echo": true,
224
- "reveal": "always",
225
- "focus": false,
226
- "panel": "shared"
227
- },
228
- "problemMatcher": []
229
173
  }
230
174
  ]
231
175
  }
@@ -29,8 +29,12 @@ if (file_exists(__DIR__ . '/vendor/autoload.php')) {
29
29
  }
30
30
 
31
31
 
32
- // ** Carregar o .env para variáveis de ambiente ** //
33
- $dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
32
+ // ** Load .env into environment variables ** //
33
+ // The .env file lives one level ABOVE the web root when it exists there (on the server, ~/htdocs/.env):
34
+ // nginx serves everything in the web root, and a .env there is public unless a vhost or WAF rule blocks it.
35
+ // Without the file in the parent directory (local environment, or a server not yet migrated), the root one is used.
36
+ $envDir = is_file(dirname(__DIR__) . '/.env') ? dirname(__DIR__) : __DIR__;
37
+ $dotenv = Dotenv\Dotenv::createImmutable($envDir);
34
38
  $dotenv->safeLoad();
35
39
  $requiredEnvs = ['WORDPRESS_DB_NAME', 'WORDPRESS_DB_USER', 'WORDPRESS_DB_PASSWORD', 'WORDPRESS_DB_HOST', 'WORDPRESS_SITE_URL'];
36
40
  $dotenv->required($requiredEnvs);
@@ -40,17 +44,21 @@ if (!function_exists('getenv_docker')) {
40
44
  // https://github.com/docker-library/wordpress/issues/588 (WP-CLI will load this file 2x)
41
45
  function getenv_docker($env, $default)
42
46
  {
47
+ {{#unless enable_kivo_wp}}
43
48
  if (getenv('LANDO_INFO')) {
44
49
  // Lando-specific environment variable
45
50
  return $_ENV[$env] ?? $default;
46
51
  } else if ($fileEnv = getenv($env . '_FILE')) {
52
+ {{else}}
53
+ if ($fileEnv = getenv($env . '_FILE')) {
54
+ {{/unless}}
47
55
  return rtrim(file_get_contents($fileEnv), "\r\n");
48
56
  } else if (($val = getenv($env)) !== false) {
49
57
  return $val;
50
58
  } else if (isset($_ENV[$env])) {
51
59
  // phpdotenv 5.x doesn't populate putenv() — fall back to $_ENV
52
- // so PHP-FPM / WP-CLI / cron all see the .env values outside
53
- // Lando (which sets its own env vars at container start).
60
+ // so PHP-FPM / WP-CLI / cron all see the .env values when the
61
+ // container did not receive them as environment variables.
54
62
  return $_ENV[$env];
55
63
  } else {
56
64
  return $default;
@@ -132,10 +140,11 @@ $table_prefix = getenv_docker('WORDPRESS_TABLE_PREFIX', 'wp_');
132
140
  *
133
141
  * @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
134
142
  */
135
- define('WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', ''));
143
+ define('WP_DEBUG', filter_var(getenv_docker('WORDPRESS_DEBUG', ''), FILTER_VALIDATE_BOOLEAN));
136
144
 
137
145
  /* Add any custom values between this line and the "stop editing" line. */
138
146
 
147
+ {{#unless enable_kivo_wp}}
139
148
  // If we're running in a Docker container, we need to set the HTTP_HOST and SERVER_PORT
140
149
  // to empty strings, otherwise WordPress will try to use the container name as the host.
141
150
  // This is necessary for WordPress to work correctly in a Docker environment.
@@ -146,14 +155,35 @@ if (defined('WP_CLI') && constant('WP_CLI')) {
146
155
  $_SERVER['SERVER_PORT'] = 80;
147
156
  }
148
157
 
158
+ {{/unless}}
159
+ {{#if enable_kivo_wp}}
160
+ // BEGIN kivo-wp forwarded headers
161
+ // X-Forwarded-Proto and X-Forwarded-Host are trusted only from the Caddy proxy service (or the
162
+ // address in KIVO_WP_PROXY_ADDR) and in GitHub Codespaces, whose forwarder terminates TLS.
163
+ // Any other client cannot switch HTTPS on or change the host.
164
+ $kivoWpProxyAddr = getenv('KIVO_WP_PROXY_ADDR') ?: gethostbyname('proxy');
165
+ $kivoWpTrustForwarded = getenv('CODESPACES') === 'true'
166
+ || (isset($_SERVER['REMOTE_ADDR']) && filter_var($kivoWpProxyAddr, FILTER_VALIDATE_IP) && $_SERVER['REMOTE_ADDR'] === $kivoWpProxyAddr);
167
+ if ($kivoWpTrustForwarded) {
168
+ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
169
+ $_SERVER['HTTPS'] = 'on';
170
+ }
171
+ if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
172
+ $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
173
+ }
174
+ }
175
+ unset($kivoWpProxyAddr, $kivoWpTrustForwarded);
176
+ // END kivo-wp forwarded headers
177
+ {{else}}
149
178
  // If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
150
179
  // see also https://wordpress.org/support/article/administration-over-ssl/#using-a-reverse-proxy
151
180
  if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
152
181
  $_SERVER['HTTPS'] = 'on';
153
182
  }
183
+ {{/if}}
154
184
 
155
185
  /** URL routing (Optional, may not be necessary) */
156
- $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
186
+ $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || ($_SERVER['SERVER_PORT'] ?? null) == 443) ? 'https://' : 'http://';
157
187
  $siteUrl = getenv_docker('WORDPRESS_SITE_URL', 'localhost');
158
188
  $siteUrl = (strpos($siteUrl, 'http') === 0) ? $siteUrl : $protocol . $siteUrl;
159
189
  define('WP_HOME', $siteUrl);
@@ -165,19 +195,31 @@ define('WP_SITEURL', $siteUrl . '/wp');
165
195
  // If you want to use a different directory, you can change the path below.
166
196
  // Note: This is not the same as the "wp-content" directory, which is the default location for WordPress content.
167
197
  define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/content' );
198
+ {{#if enable_kivo_wp}}
199
+ // Built from WP_HOME, never from the request Host: WP-CLI has no Host, and forwarded URLs
200
+ // (Codespaces, non-443 ports) do not match it.
201
+ define( 'WP_CONTENT_URL', WP_HOME . '/content' );
202
+ {{else}}
168
203
  define( 'WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/content' );
169
-
170
- // Load all WordPress environment variables from the .env file
171
- $wordpressEnvs = array_filter($_ENV, function ($key) {
172
- return strpos($key, 'WORDPRESS_') === 0;
204
+ {{/if}}
205
+
206
+ // Define a constant for every remaining WORDPRESS_* variable (WORDPRESS_WP_ENVIRONMENT_TYPE ->
207
+ // WP_ENVIRONMENT_TYPE). Process variables come from getenv(): images that run with
208
+ // variables_order=GPCS (serversideup/php) leave $_ENV empty. Values loaded from .env by phpdotenv
209
+ // are only in $_ENV. "true" and "false" become booleans, so WORDPRESS_SCRIPT_DEBUG=false is off.
210
+ $wordpressEnvs = array_filter(getenv() + $_ENV, function ($key) {
211
+ return strpos((string) $key, 'WORDPRESS_') === 0;
173
212
  }, ARRAY_FILTER_USE_KEY);
174
213
 
175
- // Define all remaining WordPress environment variables
176
214
  foreach ($wordpressEnvs as $key => $value) {
177
- $key = str_replace('WORDPRESS_', '', $key);
178
- if (!defined($key))
179
- define($key, $value);
215
+ $key = substr($key, strlen('WORDPRESS_'));
216
+ if (defined($key)) {
217
+ continue;
218
+ }
219
+ $flag = is_string($value) ? strtolower($value) : '';
220
+ define($key, $flag === 'true' ? true : ($flag === 'false' ? false : $value));
180
221
  }
222
+ unset($wordpressEnvs, $key, $value, $flag);
181
223
 
182
224
  // If there's a WORDPRESS_CONFIG_EXTRA environment variable, evaluate it
183
225
  if ($configExtra = getenv_docker('WORDPRESS_CONFIG_EXTRA', '')) {