@codigodoleo/wp-kit 5.2.0 → 6.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 (106) hide show
  1. package/lib/commands/init.js +35 -27
  2. package/lib/config/versions.js +32 -5
  3. package/lib/core/cloud-allowlist.js +38 -0
  4. package/lib/core/generator.js +56 -50
  5. package/lib/core/infer-ci-capabilities.js +17 -5
  6. package/lib/prompts/index.js +106 -8
  7. package/lib/utils/auth-template.js +18 -0
  8. package/lib/utils/env-example.js +28 -0
  9. package/modules/blank-theme/index.js +1 -1
  10. package/modules/deploy/index.js +18 -0
  11. package/modules/deploy/scripts/check-exposure.sh +63 -0
  12. package/modules/deploy/templates/.github/workflows/ci.yml.hbs +37 -2
  13. package/modules/deploy/templates/renovate.json.hbs +4 -0
  14. package/modules/docs/index.js +18 -18
  15. package/modules/docs/templates/README.md.hbs +1 -1
  16. package/modules/docs/templates/docs/Arquitetura.md.hbs +2 -2
  17. package/modules/docs/templates/docs/Deploy-Pipeline.md.hbs +21 -1
  18. package/modules/docs/templates/docs/{Desenvolvimento.md.hbs → Development.md.hbs} +80 -2
  19. package/modules/docs/templates/docs/Getting-Started.md.hbs +75 -4
  20. package/modules/docs/templates/docs/Infraestrutura.md.hbs +1 -1
  21. package/modules/docs/templates/docs/Troubleshooting.md.hbs +18 -1
  22. package/modules/git/.husky/kivo-wp/commit-msg +3 -0
  23. package/modules/git/.husky/kivo-wp/pre-commit +25 -0
  24. package/modules/git/.husky/pre-commit +3 -7
  25. package/modules/git/index.js +75 -57
  26. package/modules/git/templates/.lando.yml.hbs +5 -0
  27. package/modules/git/templates/package.json.hbs +1 -1
  28. package/modules/kivo-wp/fixtures/menus.json +11 -0
  29. package/modules/kivo-wp/fixtures/options.json +10 -0
  30. package/modules/kivo-wp/fixtures/posts.json +58 -0
  31. package/modules/kivo-wp/fixtures/seed.php +152 -0
  32. package/modules/kivo-wp/fixtures/terms.json +6 -0
  33. package/modules/kivo-wp/fixtures/users.json +26 -0
  34. package/modules/kivo-wp/index.js +193 -0
  35. package/modules/kivo-wp/prompts.js +1 -0
  36. package/modules/kivo-wp/templates/.devcontainer/devcontainer.json.hbs +40 -0
  37. package/modules/kivo-wp/templates/.dockerignore.hbs +15 -0
  38. package/modules/kivo-wp/templates/Dockerfile.hbs +81 -0
  39. package/modules/kivo-wp/templates/bin/_lib.sh.hbs +116 -0
  40. package/modules/kivo-wp/templates/bin/build.hbs +13 -0
  41. package/modules/kivo-wp/templates/bin/composer.hbs +6 -0
  42. package/modules/kivo-wp/templates/bin/db-export.hbs +8 -0
  43. package/modules/kivo-wp/templates/bin/db-import.hbs +20 -0
  44. package/modules/kivo-wp/templates/bin/db.hbs +9 -0
  45. package/modules/kivo-wp/templates/bin/dev.hbs +7 -0
  46. package/modules/kivo-wp/templates/bin/down.hbs +34 -0
  47. package/modules/kivo-wp/templates/bin/e2e.hbs +20 -0
  48. package/modules/kivo-wp/templates/bin/flush.hbs +11 -0
  49. package/modules/kivo-wp/templates/bin/info.hbs +15 -0
  50. package/modules/kivo-wp/templates/bin/logs.hbs +6 -0
  51. package/modules/kivo-wp/templates/bin/mago.hbs +6 -0
  52. package/modules/kivo-wp/templates/bin/node.hbs +6 -0
  53. package/modules/kivo-wp/templates/bin/npm.hbs +6 -0
  54. package/modules/kivo-wp/templates/bin/php.hbs +6 -0
  55. package/modules/kivo-wp/templates/bin/reset-deps.hbs +11 -0
  56. package/modules/kivo-wp/templates/bin/seed.hbs +19 -0
  57. package/modules/kivo-wp/templates/bin/setup.hbs +283 -0
  58. package/modules/kivo-wp/templates/bin/shell.hbs +14 -0
  59. package/modules/kivo-wp/templates/bin/stan.hbs +6 -0
  60. package/modules/kivo-wp/templates/bin/test.hbs +6 -0
  61. package/modules/kivo-wp/templates/bin/trust-cert.hbs +21 -0
  62. package/modules/kivo-wp/templates/bin/up.hbs +6 -0
  63. package/modules/kivo-wp/templates/bin/wp.hbs +6 -0
  64. package/modules/kivo-wp/templates/bin/xdebug.hbs +22 -0
  65. package/modules/kivo-wp/templates/compose.yaml.hbs +117 -0
  66. package/modules/kivo-wp/templates/content/mu-plugins/kivo-wp-local-mail.php.hbs +29 -0
  67. package/modules/kivo-wp/templates/docs/cloud-sessions.md.hbs +34 -0
  68. package/modules/kivo-wp/templates/server/caddy/Caddyfile.hbs +44 -0
  69. package/modules/kivo-wp/templates/server/nginx/deny.conf.hbs +26 -0
  70. package/modules/lint/.prettierignore +3 -4
  71. package/modules/lint/index.js +14 -10
  72. package/modules/lint/templates/package.json.hbs +6 -0
  73. package/modules/php/index.js +13 -1
  74. package/modules/php/kivo-wp/php-wrapper.sh +3 -0
  75. package/modules/php/kivo-wp/pint-wrapper.sh +3 -0
  76. package/modules/sage/index.js +7 -24
  77. package/modules/sage/templates/bin/theme-lint.hbs +6 -0
  78. package/modules/sage/templates/server/cmd/setup-sage-node.sh.hbs +3 -1
  79. package/modules/sage/templates/server/cmd/setup-sage-php.sh.hbs +3 -1
  80. package/modules/sage/templates/theme/vite.config.js.hbs +25 -4
  81. package/modules/sage/templates/workspace.json.hbs +0 -57
  82. package/modules/test/index.js +12 -11
  83. package/modules/test/templates/playwright.config.js.hbs +12 -0
  84. package/modules/test/tests/e2e/smoke.spec.js +28 -0
  85. package/package.json +3 -2
  86. package/templates/.env.hbs +16 -5
  87. package/templates/.gitignore.hbs +12 -1
  88. package/templates/.lando.yml.hbs +5 -11
  89. package/templates/CLAUDE.md.hbs +19 -2
  90. package/templates/package.json.hbs +8 -1
  91. package/templates/server/cmd/install-wp.sh.hbs +1 -1
  92. package/templates/server/cmd/setup-node.sh.hbs +3 -1
  93. package/templates/server/cmd/setup-php.sh.hbs +63 -9
  94. package/templates/workspace.json.hbs +0 -56
  95. package/{wp-config.php → templates/wp-config.php.hbs} +41 -5
  96. package/modules/lint/templates/.lando.yml.hbs +0 -5
  97. package/modules/sage/templates/.devcontainer/devcontainer.json.hbs +0 -7
  98. package/modules/sage/templates/.devcontainer/docker-compose.override.yml.hbs +0 -4
  99. package/modules/sage/templates/.devcontainer/post-create.sh.hbs +0 -11
  100. package/templates/.devcontainer/Dockerfile.hbs +0 -24
  101. package/templates/.devcontainer/config/nginx.conf +0 -23
  102. package/templates/.devcontainer/config/nginx.conf.hbs +0 -23
  103. package/templates/.devcontainer/devcontainer.json.hbs +0 -29
  104. package/templates/.devcontainer/docker-compose.yml.hbs +0 -76
  105. package/templates/.devcontainer/setup.sh.hbs +0 -17
  106. package/templates/auth.json.hbs +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codigodoleo/wp-kit",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
4
4
  "description": "Kit opinativo para padronizar projetos WordPress com CI/CD dinâmico.",
5
5
  "keywords": [
6
6
  "codigodoleo",
@@ -22,7 +22,6 @@
22
22
  "modules/",
23
23
  "templates/",
24
24
  "server/",
25
- "wp-config.php",
26
25
  "index.php",
27
26
  ".cspell.json",
28
27
  ".gitkeep"
@@ -38,6 +37,7 @@
38
37
  "lint:fix": "oxlint . --fix",
39
38
  "format": "oxfmt --write .",
40
39
  "commit": "cz",
40
+ "test": "node --test \"__tests__/**/*.test.js\"",
41
41
  "test:setup": "npm run test:clean && npm run test:scaffold",
42
42
  "test:clean": "rm -rf __test-sandbox__",
43
43
  "test:scaffold": "node ./bin/index.js init --output=__test-sandbox__/test-project --defaults",
@@ -64,6 +64,7 @@
64
64
  "@commitlint/prompt": "^18.4.3",
65
65
  "@cspell/dict-php": "^4.0.14",
66
66
  "@cspell/dict-pt-br": "^2.4.0",
67
+ "ajv": "^8.20.0",
67
68
  "commitizen": "^4.3.0",
68
69
  "conventional-changelog-cli": "^4.1.0",
69
70
  "husky": "^8.0.3",
@@ -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,3 +94,8 @@ php_errors.log
88
94
  # Testing
89
95
  coverage/
90
96
  .phpunit.result.cache
97
+
98
+ # Environment (local secrets: WP salts, DB credentials)
99
+ /.env
100
+ /.env.*
101
+ !/.env.example
@@ -8,23 +8,17 @@ excludes:
8
8
  config:
9
9
  webroot: ./
10
10
  via: nginx
11
- php: "8.4"
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:
@@ -44,7 +38,7 @@ services:
44
38
  overrides:
45
39
  platform: linux/amd64
46
40
  ports:
47
- - 5173:5173
41
+ - 5173
48
42
  database:
49
43
  type: mariadb:10.11
50
44
  portforward: true
@@ -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,6 +28,7 @@ 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
 
@@ -44,9 +55,15 @@ Available commands:
44
55
  Theme located at `content/themes/{{themeName}}/`.
45
56
 
46
57
  ```bash
58
+ {{#if enable_kivo_wp}}
59
+ bin/reset-deps # Reinstall theme dependencies
60
+ bin/wp acorn make:component ComponentName
61
+ bin/wp acorn acf:block BlockName
62
+ {{else}}
47
63
  lando theme-bootstrap # Install theme dependencies
48
64
  lando acorn make:component ComponentName
49
65
  lando acorn acf:block BlockName
66
+ {{/if}}
50
67
  ```
51
68
  {{else}}
52
69
  No Sage theme configured.
@@ -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;
@@ -136,6 +144,7 @@ define('WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', ''));
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,7 +195,13 @@ 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' );
204
+ {{/if}}
169
205
 
170
206
  // Load all WordPress environment variables from the .env file
171
207
  $wordpressEnvs = array_filter($_ENV, function ($key) {
@@ -1,5 +0,0 @@
1
- tooling:
2
- commitlint:
3
- service: appserver
4
- description: Validate commit message format
5
- cmd: npx commitlint --edit
@@ -1,7 +0,0 @@
1
- {
2
- "dockerComposeFile": [
3
- "docker-compose.yml",
4
- "docker-compose.override.yml"
5
- ],
6
- "postCreateCommand": "bash .devcontainer/setup.sh && bash .devcontainer/post-create.sh"
7
- }
@@ -1,4 +0,0 @@
1
- services:
2
- app:
3
- environment:
4
- SAGE_THEME_DIR: /workspace/content/themes/{{projectName}}
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Sage devcontainer post-create — delegates to unified setup scripts.
3
- # Invoked from: devcontainer.json postCreateCommand.
4
- set -euo pipefail
5
-
6
- PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.."; pwd)"
7
-
8
- bash "${PROJECT_ROOT}/server/cmd/setup-sage-php.sh"
9
- bash "${PROJECT_ROOT}/server/cmd/setup-sage-node.sh"
10
-
11
- echo "Sage post-create bootstrap completed."
@@ -1,24 +0,0 @@
1
- FROM thecodingmachine/php:8.4-v5-fpm-node24
2
-
3
- # Enable PHP extensions needed for WordPress
4
- # (mysqli, mysqlnd, redis, zip already enabled by default in the fat image)
5
- ENV PHP_EXTENSION_BCMATH=1 \
6
- PHP_EXTENSION_GD=1 \
7
- PHP_EXTENSION_PDO_MYSQL=1
8
-
9
- # The base image ends with USER docker — switch to root for installations
10
- USER root
11
-
12
- # Install only what is NOT bundled in the base image.
13
- # Already pre-installed: PHP 8.4, Node 24, npm, yarn (corepack),
14
- # Composer, mysqli, mysqlnd, redis, zip, curl, git, unzip
15
- RUN apt-get update \
16
- && apt-get install -y --no-install-recommends default-mysql-client redis-tools \
17
- && rm -rf /var/lib/apt/lists/*
18
-
19
- # WP-CLI (not included in the base image)
20
- RUN curl -fsSL -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
21
- && chmod +x /usr/local/bin/wp \
22
- && wp --info
23
-
24
- USER docker
@@ -1,23 +0,0 @@
1
- server {
2
- listen 80;
3
- root /workspace/wp;
4
- index index.php;
5
-
6
- client_max_body_size 64M;
7
-
8
- location / {
9
- try_files $uri $uri/ /index.php$is_args$args;
10
- }
11
-
12
- location ~ \.php$ {
13
- fastcgi_pass app:9000;
14
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
15
- include fastcgi_params;
16
- fastcgi_read_timeout 120;
17
- }
18
-
19
- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
20
- expires max;
21
- log_not_found off;
22
- }
23
- }
@@ -1,23 +0,0 @@
1
- server {
2
- listen 80;
3
- root /workspace/wp;
4
- index index.php;
5
-
6
- client_max_body_size 64M;
7
-
8
- location / {
9
- try_files $uri $uri/ /index.php$is_args$args;
10
- }
11
-
12
- location ~ \.php$ {
13
- fastcgi_pass app:9000;
14
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
15
- include fastcgi_params;
16
- fastcgi_read_timeout 120;
17
- }
18
-
19
- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
20
- expires max;
21
- log_not_found off;
22
- }
23
- }
@@ -1,29 +0,0 @@
1
- {
2
- "name": "{{projectName}} Devcontainer",
3
- "dockerComposeFile": [
4
- "docker-compose.yml"
5
- ],
6
- "service": "app",
7
- "workspaceFolder": "/workspace",
8
- "postCreateCommand": "bash .devcontainer/setup.sh",
9
- "customizations": {
10
- "vscode": {
11
- "extensions": [
12
- "bmewburn.vscode-intelephense-client",
13
- "carthage-software.mago",
14
- "oxc.oxc-vscode",
15
- "ms-azuretools.vscode-docker"
16
- ],
17
- "settings": {
18
- "editor.formatOnSave": false,
19
- "terminal.integrated.defaultProfile.linux": "bash"
20
- }
21
- }
22
- },
23
- "forwardPorts": [
24
- 8080,
25
- 3307,
26
- 6380,
27
- 5173
28
- ]
29
- }