@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.
- package/README.md +83 -96
- package/lib/commands/init.js +28 -26
- package/lib/config/versions.js +27 -1
- package/lib/core/cloud-allowlist.js +38 -0
- package/lib/core/generator.js +56 -50
- package/lib/core/infer-ci-capabilities.js +17 -5
- package/lib/prompts/index.js +105 -8
- package/lib/utils/auth-template.js +18 -0
- package/lib/utils/env-example.js +18 -6
- package/lib/utils/git.js +5 -188
- package/modules/blank-theme/index.js +1 -1
- package/modules/deploy/index.js +15 -0
- package/modules/deploy/scripts/check-exposure.sh +63 -0
- package/modules/deploy/templates/.github/workflows/ci.yml.hbs +28 -0
- package/modules/docs/index.js +18 -18
- package/modules/docs/templates/README.md.hbs +1 -1
- package/modules/docs/templates/docs/Arquitetura.md.hbs +2 -2
- package/modules/docs/templates/docs/Deploy-Pipeline.md.hbs +21 -1
- package/modules/docs/templates/docs/Development.md.hbs +236 -0
- package/modules/docs/templates/docs/Getting-Started.md.hbs +75 -4
- package/modules/docs/templates/docs/Infraestrutura.md.hbs +1 -1
- package/modules/docs/templates/docs/Troubleshooting.md.hbs +34 -1
- package/modules/git/.husky/kivo-wp/commit-msg +3 -0
- package/modules/git/.husky/kivo-wp/pre-commit +25 -0
- package/modules/git/.husky/pre-commit +3 -7
- package/modules/git/.lintstagedrc.json +5 -2
- package/modules/git/index.js +19 -2
- package/modules/git/templates/.lando.yml.hbs +5 -0
- package/modules/git/templates/package.json.hbs +1 -1
- package/modules/kivo-wp/fixtures/menus.json +11 -0
- package/modules/kivo-wp/fixtures/options.json +10 -0
- package/modules/kivo-wp/fixtures/posts.json +58 -0
- package/modules/kivo-wp/fixtures/seed.php +152 -0
- package/modules/kivo-wp/fixtures/terms.json +6 -0
- package/modules/kivo-wp/fixtures/users.json +26 -0
- package/modules/kivo-wp/index.js +193 -0
- package/modules/kivo-wp/prompts.js +1 -0
- package/modules/kivo-wp/templates/.devcontainer/devcontainer.json.hbs +40 -0
- package/modules/kivo-wp/templates/.dockerignore.hbs +15 -0
- package/modules/kivo-wp/templates/Dockerfile.hbs +83 -0
- package/modules/kivo-wp/templates/bin/_lib.sh.hbs +137 -0
- package/modules/kivo-wp/templates/bin/build.hbs +13 -0
- package/modules/kivo-wp/templates/bin/composer.hbs +6 -0
- package/modules/kivo-wp/templates/bin/db-export.hbs +18 -0
- package/modules/kivo-wp/templates/bin/db-import.hbs +26 -0
- package/modules/kivo-wp/templates/bin/db.hbs +6 -0
- package/modules/kivo-wp/templates/bin/dev.hbs +7 -0
- package/modules/kivo-wp/templates/bin/down.hbs +34 -0
- package/modules/kivo-wp/templates/bin/e2e.hbs +48 -0
- package/modules/kivo-wp/templates/bin/flush.hbs +11 -0
- package/modules/kivo-wp/templates/bin/info.hbs +15 -0
- package/modules/kivo-wp/templates/bin/logs.hbs +6 -0
- package/modules/kivo-wp/templates/bin/mago.hbs +8 -0
- package/modules/kivo-wp/templates/bin/node.hbs +6 -0
- package/modules/kivo-wp/templates/bin/npm.hbs +6 -0
- package/modules/kivo-wp/templates/bin/php.hbs +6 -0
- package/modules/kivo-wp/templates/bin/reset-deps.hbs +11 -0
- package/modules/kivo-wp/templates/bin/seed.hbs +21 -0
- package/modules/kivo-wp/templates/bin/setup.hbs +283 -0
- package/modules/kivo-wp/templates/bin/shell.hbs +14 -0
- package/modules/kivo-wp/templates/bin/stan.hbs +8 -0
- package/modules/kivo-wp/templates/bin/test.hbs +6 -0
- package/modules/kivo-wp/templates/bin/trust-cert.hbs +21 -0
- package/modules/kivo-wp/templates/bin/up.hbs +6 -0
- package/modules/kivo-wp/templates/bin/wp.hbs +6 -0
- package/modules/kivo-wp/templates/bin/xdebug.hbs +22 -0
- package/modules/kivo-wp/templates/compose.yaml.hbs +117 -0
- package/modules/kivo-wp/templates/content/mu-plugins/kivo-wp-local-mail.php.hbs +29 -0
- package/modules/kivo-wp/templates/docs/cloud-sessions.md.hbs +34 -0
- package/modules/kivo-wp/templates/server/caddy/Caddyfile.hbs +44 -0
- package/modules/kivo-wp/templates/server/nginx/deny.conf.hbs +26 -0
- package/modules/lint/index.js +22 -14
- package/modules/lint/templates/package.json.hbs +6 -0
- package/modules/php/index.js +18 -1
- package/modules/php/kivo-wp/php-wrapper.sh +3 -0
- package/modules/php/kivo-wp/pint-wrapper.sh +3 -0
- package/modules/php/templates/phpstan.neon.dist.hbs +27 -0
- package/modules/sage/index.js +4 -26
- package/modules/sage/templates/bin/theme-lint.hbs +6 -0
- package/modules/sage/templates/server/cmd/setup-sage-node.sh.hbs +3 -1
- package/modules/sage/templates/server/cmd/setup-sage-php.sh.hbs +3 -1
- package/modules/sage/templates/theme/vite.config.js.hbs +20 -2
- package/modules/sage/templates/workspace.json.hbs +0 -57
- package/modules/skills/index.js +56 -11
- package/modules/skills/prompts.js +3 -16
- package/modules/test/index.js +13 -11
- package/modules/test/phpunit.xml +18 -0
- package/modules/test/templates/playwright.config.js.hbs +23 -0
- package/modules/test/tests/SmokeTest.php +8 -9
- package/modules/test/tests/e2e/smoke.spec.js +28 -0
- package/package.json +3 -2
- package/templates/.env.hbs +16 -5
- package/templates/.gitignore.hbs +8 -1
- package/templates/.lando.yml.hbs +3 -9
- package/templates/CLAUDE.md.hbs +33 -15
- package/templates/README.md.hbs +38 -12
- package/templates/composer.json.hbs +1 -1
- package/templates/package.json.hbs +8 -1
- package/templates/server/cmd/install-wp.sh.hbs +1 -1
- package/templates/server/cmd/setup-node.sh.hbs +3 -1
- package/templates/server/cmd/setup-php.sh.hbs +63 -9
- package/templates/workspace.json.hbs +0 -56
- package/{wp-config.php → templates/wp-config.php.hbs} +56 -14
- package/modules/docs/templates/docs/Desenvolvimento.md.hbs +0 -127
- package/modules/lint/templates/.lando.yml.hbs +0 -5
- package/modules/sage/templates/.devcontainer/devcontainer.json.hbs +0 -7
- package/modules/sage/templates/.devcontainer/docker-compose.override.yml.hbs +0 -4
- package/modules/sage/templates/.devcontainer/post-create.sh.hbs +0 -11
- package/templates/.devcontainer/Dockerfile.hbs +0 -24
- package/templates/.devcontainer/config/nginx.conf +0 -23
- package/templates/.devcontainer/config/nginx.conf.hbs +0 -23
- package/templates/.devcontainer/devcontainer.json.hbs +0 -29
- package/templates/.devcontainer/docker-compose.yml.hbs +0 -76
- package/templates/.devcontainer/setup.sh.hbs +0 -17
- package/templates/auth.json.hbs +0 -8
package/templates/.env.hbs
CHANGED
|
@@ -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=
|
|
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
|
|
53
|
-
# scripts/push-obs-creds-to-site.sh
|
|
54
|
-
# HEKIVO_AUDIT_CW_ACCESS_KEY_ID="op://Client-<
|
|
55
|
-
# HEKIVO_AUDIT_CW_SECRET_ACCESS_KEY="op://Client-<
|
|
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"
|
package/templates/.gitignore.hbs
CHANGED
|
@@ -16,7 +16,8 @@ content/languages/*
|
|
|
16
16
|
!content/languages/.gitkeep
|
|
17
17
|
content/mu-plugins/*
|
|
18
18
|
!content/mu-plugins/.gitkeep
|
|
19
|
-
{{#if
|
|
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
|
package/templates/.lando.yml.hbs
CHANGED
|
@@ -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:
|
package/templates/CLAUDE.md.hbs
CHANGED
|
@@ -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
|
|
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}}-
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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.
|
package/templates/README.md.hbs
CHANGED
|
@@ -2,26 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
Scaffolded by [wp-kit](https://github.com/hekivo/wp-kit).
|
|
4
4
|
|
|
5
|
-
##
|
|
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
|
-
|
|
36
|
+
The Sage theme builds blocks with ACF Composer:
|
|
11
37
|
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
48
|
+
Requirement: the Advanced Custom Fields (ACF) plugin active in WordPress.
|
|
49
|
+
{{/if}}
|
|
24
50
|
|
|
25
|
-
##
|
|
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.
|
|
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.
|
|
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:
|
|
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:
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
// **
|
|
33
|
-
|
|
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
|
|
53
|
-
//
|
|
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',
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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 =
|
|
178
|
-
if (
|
|
179
|
-
|
|
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', '')) {
|