@codigodoleo/wp-kit 5.3.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.
- 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/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/{Desenvolvimento.md.hbs → Development.md.hbs} +80 -2
- 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 +18 -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/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 +81 -0
- package/modules/kivo-wp/templates/bin/_lib.sh.hbs +116 -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 +8 -0
- package/modules/kivo-wp/templates/bin/db-import.hbs +20 -0
- package/modules/kivo-wp/templates/bin/db.hbs +9 -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 +20 -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 +6 -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 +19 -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 +6 -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 +14 -10
- package/modules/lint/templates/package.json.hbs +6 -0
- package/modules/php/index.js +13 -1
- package/modules/php/kivo-wp/php-wrapper.sh +3 -0
- package/modules/php/kivo-wp/pint-wrapper.sh +3 -0
- package/modules/sage/index.js +1 -25
- 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/test/index.js +12 -11
- package/modules/test/templates/playwright.config.js.hbs +12 -0
- 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 +7 -1
- package/templates/.lando.yml.hbs +3 -9
- package/templates/CLAUDE.md.hbs +19 -2
- 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} +41 -5
- 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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Export Caddy's local root CA and print the command that trusts it on this OS (never runs it).
|
|
3
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
|
+
|
|
6
|
+
kivo_wp_require_running proxy
|
|
7
|
+
out="${KIVO_WP_CERT_OUT:-${TMPDIR:-/tmp}/kivo-wp-{{projectName}}-root.crt}"
|
|
8
|
+
kivo_wp_compose cp proxy:/data/caddy/pki/authorities/local/root.crt "${out}" >/dev/null
|
|
9
|
+
printf "Caddy root CA exported to %s\n\n" "${out}"
|
|
10
|
+
|
|
11
|
+
printf 'Linux (Debian/Ubuntu):\n'
|
|
12
|
+
printf ' sudo cp "%s" /usr/local/share/ca-certificates/kivo-wp-{{projectName}}.crt && sudo update-ca-certificates\n\n' "${out}"
|
|
13
|
+
printf 'macOS:\n'
|
|
14
|
+
printf ' sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain "%s"\n\n' "${out}"
|
|
15
|
+
|
|
16
|
+
if [ -n "${WSL_DISTRO_NAME:-}" ]; then
|
|
17
|
+
windows_path="\\\\wsl.localhost\\${WSL_DISTRO_NAME}${out//\//\\}"
|
|
18
|
+
printf 'Windows (browsers on the Windows side), from an elevated Command Prompt:\n'
|
|
19
|
+
printf ' certutil.exe -addstore -f ROOT "%s"\n' "${windows_path}"
|
|
20
|
+
printf ' Firefox also needs security.enterprise_roots.enabled = true in about:config.\n'
|
|
21
|
+
fi
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Toggle Xdebug without a rebuild: bin/xdebug on [mode] | off | status
|
|
3
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
|
+
|
|
6
|
+
case "${1:-status}" in
|
|
7
|
+
on)
|
|
8
|
+
mode="${2:-debug,develop}"
|
|
9
|
+
kivo_wp_env_set XDEBUG_MODE "${mode}"
|
|
10
|
+
kivo_wp_compose up -d --no-build app
|
|
11
|
+
kivo_wp_err "Xdebug on (XDEBUG_MODE=${mode})"
|
|
12
|
+
;;
|
|
13
|
+
off)
|
|
14
|
+
kivo_wp_env_set XDEBUG_MODE off
|
|
15
|
+
kivo_wp_compose up -d --no-build app
|
|
16
|
+
kivo_wp_err "Xdebug off"
|
|
17
|
+
;;
|
|
18
|
+
status)
|
|
19
|
+
printf 'XDEBUG_MODE=%s\n' "$(kivo_wp_env_get XDEBUG_MODE)"
|
|
20
|
+
;;
|
|
21
|
+
*) kivo_wp_die "usage: bin/xdebug on [mode] | off | status" ;;
|
|
22
|
+
esac
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
name: kivo-wp-{{projectName}}
|
|
2
|
+
|
|
3
|
+
x-kivo-wp:
|
|
4
|
+
contract: 1
|
|
5
|
+
|
|
6
|
+
services:
|
|
7
|
+
app:
|
|
8
|
+
build:
|
|
9
|
+
context: .
|
|
10
|
+
target: development
|
|
11
|
+
args:
|
|
12
|
+
PHP_VERSION: "{{phpVersion}}"
|
|
13
|
+
USER_ID: "${USER_ID:-1000}"
|
|
14
|
+
GROUP_ID: "${GROUP_ID:-1000}"
|
|
15
|
+
labels:
|
|
16
|
+
dev.hekivo.environment: kivo-wp
|
|
17
|
+
env_file:
|
|
18
|
+
- .env
|
|
19
|
+
environment:
|
|
20
|
+
XDEBUG_MODE: "${XDEBUG_MODE:-off}"
|
|
21
|
+
KIVO_WP_SMTP_HOST: mail
|
|
22
|
+
# Set by GitHub Codespaces in the workspace container; wp-config.php trusts forwarded headers.
|
|
23
|
+
CODESPACES: "${CODESPACES:-}"
|
|
24
|
+
volumes:
|
|
25
|
+
- .:/var/www/html
|
|
26
|
+
extra_hosts:
|
|
27
|
+
- "host.docker.internal:host-gateway"
|
|
28
|
+
depends_on:
|
|
29
|
+
db:
|
|
30
|
+
condition: service_healthy
|
|
31
|
+
cache:
|
|
32
|
+
condition: service_healthy
|
|
33
|
+
healthcheck:
|
|
34
|
+
test: ["CMD", "curl", "-fsS", "http://localhost:8080/healthcheck"]
|
|
35
|
+
interval: 10s
|
|
36
|
+
timeout: 5s
|
|
37
|
+
retries: 12
|
|
38
|
+
start_period: 20s
|
|
39
|
+
|
|
40
|
+
db:
|
|
41
|
+
image: {{kivoWp.images.db}}
|
|
42
|
+
labels:
|
|
43
|
+
dev.hekivo.environment: kivo-wp
|
|
44
|
+
# Local, per-environment database: non-secret defaults (D-006).
|
|
45
|
+
environment:
|
|
46
|
+
MYSQL_DATABASE: "${WORDPRESS_DB_NAME:-wordpress}"
|
|
47
|
+
MYSQL_USER: "${WORDPRESS_DB_USER:-wordpress}"
|
|
48
|
+
MYSQL_PASSWORD: "${WORDPRESS_DB_PASSWORD:-wordpress}"
|
|
49
|
+
MYSQL_ROOT_PASSWORD: root
|
|
50
|
+
volumes:
|
|
51
|
+
- db-data:/var/lib/mysql
|
|
52
|
+
healthcheck:
|
|
53
|
+
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
|
|
54
|
+
interval: 5s
|
|
55
|
+
timeout: 5s
|
|
56
|
+
retries: 30
|
|
57
|
+
start_period: 20s
|
|
58
|
+
|
|
59
|
+
cache:
|
|
60
|
+
image: {{kivoWp.images.cache}}
|
|
61
|
+
labels:
|
|
62
|
+
dev.hekivo.environment: kivo-wp
|
|
63
|
+
healthcheck:
|
|
64
|
+
test: ["CMD", "valkey-cli", "ping"]
|
|
65
|
+
interval: 5s
|
|
66
|
+
timeout: 3s
|
|
67
|
+
retries: 10
|
|
68
|
+
|
|
69
|
+
proxy:
|
|
70
|
+
image: {{kivoWp.images.proxy}}
|
|
71
|
+
labels:
|
|
72
|
+
dev.hekivo.environment: kivo-wp
|
|
73
|
+
# Caddy listens on the same port numbers as the host, so the site URL (with its port) works
|
|
74
|
+
# from the host and from the other services alike.
|
|
75
|
+
environment:
|
|
76
|
+
HTTPS_PORT: "${HTTPS_PORT:-443}"
|
|
77
|
+
HTTP_PORT: "${HTTP_PORT:-80}"
|
|
78
|
+
CODESPACES: "${CODESPACES:-}"
|
|
79
|
+
ports:
|
|
80
|
+
- "${HTTPS_PORT:-443}:${HTTPS_PORT:-443}"
|
|
81
|
+
- "${HTTP_PORT:-80}:${HTTP_PORT:-80}"
|
|
82
|
+
volumes:
|
|
83
|
+
- ./server/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
|
|
84
|
+
- caddy-data:/data
|
|
85
|
+
depends_on:
|
|
86
|
+
- app
|
|
87
|
+
networks:
|
|
88
|
+
default:
|
|
89
|
+
# *.localhost resolves to loopback inside containers; these aliases send it to Caddy.
|
|
90
|
+
aliases:
|
|
91
|
+
- {{projectName}}.localhost
|
|
92
|
+
- vite.{{projectName}}.localhost
|
|
93
|
+
- mail.{{projectName}}.localhost
|
|
94
|
+
|
|
95
|
+
node:
|
|
96
|
+
image: node:{{nodeVersion}}-bookworm
|
|
97
|
+
labels:
|
|
98
|
+
dev.hekivo.environment: kivo-wp
|
|
99
|
+
user: "${USER_ID:-1000}:${GROUP_ID:-1000}"
|
|
100
|
+
working_dir: /var/www/html
|
|
101
|
+
environment:
|
|
102
|
+
npm_config_cache: /tmp/.npm
|
|
103
|
+
# Read by the theme Vite config for the HMR client (served through Caddy).
|
|
104
|
+
HTTPS_PORT: "${HTTPS_PORT:-443}"
|
|
105
|
+
KIVO_WP_VITE_HOST: vite.{{projectName}}.localhost
|
|
106
|
+
command: ["sleep", "infinity"]
|
|
107
|
+
volumes:
|
|
108
|
+
- .:/var/www/html
|
|
109
|
+
|
|
110
|
+
mail:
|
|
111
|
+
image: {{kivoWp.images.mail}}
|
|
112
|
+
labels:
|
|
113
|
+
dev.hekivo.environment: kivo-wp
|
|
114
|
+
|
|
115
|
+
volumes:
|
|
116
|
+
db-data: {}
|
|
117
|
+
caddy-data: {}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Plugin Name: kivo-wp local mail
|
|
5
|
+
* Description: Sends mail to the local Mailpit service. Active only in the local kivo-wp environment.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
defined('ABSPATH') || exit;
|
|
9
|
+
|
|
10
|
+
(function () {
|
|
11
|
+
$environment = function_exists('wp_get_environment_type') ? wp_get_environment_type() : 'production';
|
|
12
|
+
$host = getenv('KIVO_WP_SMTP_HOST');
|
|
13
|
+
if ($host === false || $host === '') {
|
|
14
|
+
$host = $_ENV['KIVO_WP_SMTP_HOST'] ?? '';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if ($environment !== 'local' || $host === '') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
add_action('phpmailer_init', function ($phpmailer) use ($host) {
|
|
22
|
+
$phpmailer->isSMTP();
|
|
23
|
+
$phpmailer->Host = $host;
|
|
24
|
+
$phpmailer->Port = 1025;
|
|
25
|
+
$phpmailer->SMTPAuth = false;
|
|
26
|
+
$phpmailer->SMTPSecure = '';
|
|
27
|
+
$phpmailer->SMTPAutoTLS = false;
|
|
28
|
+
});
|
|
29
|
+
})();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Cloud agent sessions
|
|
2
|
+
|
|
3
|
+
How to run **{{projectName}}** in a Claude Code cloud session (an Ubuntu VM with Docker). The
|
|
4
|
+
session gets the repository and synthetic fixtures only; production data never reaches it.
|
|
5
|
+
|
|
6
|
+
## Environment setup script
|
|
7
|
+
|
|
8
|
+
Configure the cloud environment with this single line as its setup script:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
bin/setup --cloud
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
It starts the kivo-wp stack, serves the site at `https://{{projectName}}.localhost` through Caddy,
|
|
15
|
+
installs Caddy's local root CA in the VM trust store (so `curl`, PHP and Playwright trust it without
|
|
16
|
+
`-k`) and seeds the fixtures. It never creates `auth.json`.
|
|
17
|
+
|
|
18
|
+
## Network access
|
|
19
|
+
|
|
20
|
+
In **Limited** network mode, add these hosts to the allowlist:
|
|
21
|
+
|
|
22
|
+
{{#each cloudAllowlist}}
|
|
23
|
+
- `{{this}}`
|
|
24
|
+
{{/each}}
|
|
25
|
+
|
|
26
|
+
## Secrets
|
|
27
|
+
|
|
28
|
+
No secret is stored in the repository, in `devcontainer.json` or in an environment variable of the
|
|
29
|
+
cloud environment: those variables are visible to everyone who can use the environment.
|
|
30
|
+
{{#if enable_acf_pro}}
|
|
31
|
+
ACF Pro's Composer credential is configured by the project owner as a **network secret** for
|
|
32
|
+
`connect.advancedcustomfields.com`; the session proxy attaches it to those requests and the value
|
|
33
|
+
never enters the VM.
|
|
34
|
+
{{/if}}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# kivo-wp proxy (D-012, D-013): TLS with Caddy's local CA for the project hostnames.
|
|
2
|
+
# The root CA lives in the caddy-data volume (/data/caddy/pki/authorities/local/root.crt);
|
|
3
|
+
# bin/trust-cert exports it. Caddy listens on HTTPS_PORT and HTTP_PORT, the same numbers the host
|
|
4
|
+
# publishes, so the site URL is valid inside the Compose network too.
|
|
5
|
+
{
|
|
6
|
+
https_port {$HTTPS_PORT:443}
|
|
7
|
+
http_port {$HTTP_PORT:80}
|
|
8
|
+
# The automatic redirect would drop a non-443 host port; the http:// block below keeps it.
|
|
9
|
+
auto_https disable_redirects
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
{{projectName}}.localhost {
|
|
13
|
+
tls internal
|
|
14
|
+
reverse_proxy app:8080
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
vite.{{projectName}}.localhost {
|
|
18
|
+
tls internal
|
|
19
|
+
reverse_proxy node:5173
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
mail.{{projectName}}.localhost {
|
|
23
|
+
tls internal
|
|
24
|
+
reverse_proxy mail:8025
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
http://{{projectName}}.localhost, http://vite.{{projectName}}.localhost, http://mail.{{projectName}}.localhost {
|
|
28
|
+
redir https://{host}:{$HTTPS_PORT:443}{uri} permanent
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# GitHub Codespaces: the port forwarder terminates TLS and reaches this port over plain HTTP with
|
|
32
|
+
# its own host name, which Caddy's local certificates cannot serve. Only in Codespaces is that
|
|
33
|
+
# traffic passed to WordPress; anywhere else other hosts get 404.
|
|
34
|
+
:{$HTTP_PORT:80} {
|
|
35
|
+
@codespaces expression `{env.CODESPACES} == "true"`
|
|
36
|
+
handle @codespaces {
|
|
37
|
+
reverse_proxy app:8080 {
|
|
38
|
+
header_up X-Forwarded-Proto https
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
handle {
|
|
42
|
+
respond 404
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# kivo-wp: paths under the project root that are never served (the root is the web root).
|
|
2
|
+
# Included in the server block as /etc/nginx/server-opts.d/00-kivo-wp-deny.conf, before the
|
|
3
|
+
# image's own security.conf, so these rules answer 404 instead of its 403.
|
|
4
|
+
# Directory rules use ^~ so they win over every regex location, including the PHP handler.
|
|
5
|
+
|
|
6
|
+
# Directories at the project root.
|
|
7
|
+
location ^~ /vendor/ { return 404; }
|
|
8
|
+
location ^~ /node_modules/ { return 404; }
|
|
9
|
+
location ^~ /server/ { return 404; }
|
|
10
|
+
location ^~ /fixtures/ { return 404; }
|
|
11
|
+
location ^~ /bin/ { return 404; }
|
|
12
|
+
location ^~ /scripts/ { return 404; }
|
|
13
|
+
|
|
14
|
+
# Files at the project root.
|
|
15
|
+
location = /Dockerfile { return 404; }
|
|
16
|
+
location = /wp-cli.yml { return 404; }
|
|
17
|
+
location = /mago.toml { return 404; }
|
|
18
|
+
location ~ ^/(auth\.json|auth\.json\.tpl)$ { return 404; }
|
|
19
|
+
location ~ ^/composer\.[^/]*$ { return 404; }
|
|
20
|
+
location ~ ^/package[^/]*\.json$ { return 404; }
|
|
21
|
+
location ~ ^/compose[^/]*\.ya?ml$ { return 404; }
|
|
22
|
+
location ~ ^/[^/]+\.md$ { return 404; }
|
|
23
|
+
location ~ \.code-workspace$ { return 404; }
|
|
24
|
+
|
|
25
|
+
# Dotfiles and dot-directories anywhere, except /.well-known/ (RFC 8615).
|
|
26
|
+
location ~ /\.(?!well-known/) { return 404; }
|
package/modules/lint/index.js
CHANGED
|
@@ -8,6 +8,11 @@ import fs from "fs-extra";
|
|
|
8
8
|
*/
|
|
9
9
|
function buildLintStagedEntries(context) {
|
|
10
10
|
const entries = {};
|
|
11
|
+
// kivo-wp: lint-staged runs in the node service, which has no PHP; the pre-commit hook
|
|
12
|
+
// formats staged PHP files with bin/mago instead (D-023).
|
|
13
|
+
const phpFormat = context.enable_kivo_wp
|
|
14
|
+
? null
|
|
15
|
+
: ["lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'"];
|
|
11
16
|
|
|
12
17
|
// Infra: YAML, JSON, Markdown at root
|
|
13
18
|
entries["*.{js,mjs,ts,vue,jsx,tsx}"] = ["oxfmt --write", "oxlint --fix"];
|
|
@@ -16,9 +21,7 @@ function buildLintStagedEntries(context) {
|
|
|
16
21
|
// Sage — PHP via mago (format only on pre-commit, lint runs in CI)
|
|
17
22
|
if (context.enable_sage) {
|
|
18
23
|
const dir = `content/themes/${context.projectName}`;
|
|
19
|
-
entries[`${dir}/{app,routes,config}/**/*.php`] =
|
|
20
|
-
"lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'",
|
|
21
|
-
];
|
|
24
|
+
if (phpFormat) entries[`${dir}/{app,routes,config}/**/*.php`] = phpFormat;
|
|
22
25
|
if (context.sage_lint_stylelint !== false) {
|
|
23
26
|
entries[`${dir}/resources/**/*.{css,scss}`] = ["stylelint --fix"];
|
|
24
27
|
}
|
|
@@ -27,17 +30,13 @@ function buildLintStagedEntries(context) {
|
|
|
27
30
|
// MU-Plugin — PHP via mago
|
|
28
31
|
if (context.enable_mu_plugin) {
|
|
29
32
|
const dir = `content/mu-plugins/${context.mu_plugin_name || `${context.projectName}-core`}`;
|
|
30
|
-
entries[`${dir}/app/**/*.php`] =
|
|
31
|
-
"lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'",
|
|
32
|
-
];
|
|
33
|
+
if (phpFormat) entries[`${dir}/app/**/*.php`] = phpFormat;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
// Plugin — PHP via mago
|
|
36
37
|
if (context.enable_plugin) {
|
|
37
38
|
const dir = `content/plugins/${context.plugin_name || `${context.projectName}-plugin`}`;
|
|
38
|
-
entries[`${dir}/src/**/*.php`] =
|
|
39
|
-
"lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'",
|
|
40
|
-
];
|
|
39
|
+
if (phpFormat) entries[`${dir}/src/**/*.php`] = phpFormat;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
// Blank Theme
|
|
@@ -50,7 +49,7 @@ function buildLintStagedEntries(context) {
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
// Tests PHP
|
|
53
|
-
entries["tests/**/*.php"] =
|
|
52
|
+
if (phpFormat) entries["tests/**/*.php"] = phpFormat;
|
|
54
53
|
|
|
55
54
|
return entries;
|
|
56
55
|
}
|
|
@@ -61,6 +60,11 @@ export async function setupModule(context, generator) {
|
|
|
61
60
|
// Root developer tooling
|
|
62
61
|
await generator.copyFile(".commitlintrc.json", "lint");
|
|
63
62
|
await generator.copyFile(".prettierignore", "lint");
|
|
63
|
+
if (context.enable_kivo_wp) {
|
|
64
|
+
const ignoreFile = path.join(generator.cwd, ".prettierignore");
|
|
65
|
+
const lines = (await fs.readFile(ignoreFile, "utf8")).split("\n");
|
|
66
|
+
await fs.outputFile(ignoreFile, lines.filter((line) => line.trim() !== ".lando/").join("\n"));
|
|
67
|
+
}
|
|
64
68
|
await generator.copyFile(".oxlintrc.json", "lint");
|
|
65
69
|
|
|
66
70
|
// mago.toml — generated (paths depend on active modules)
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"scripts": {
|
|
3
|
+
{{#if enable_kivo_wp}}
|
|
4
|
+
"format": "oxfmt && bin/mago format",
|
|
5
|
+
"format:check": "oxfmt --check && bin/mago format --check",
|
|
6
|
+
"lint": "oxlint && bin/mago lint",
|
|
7
|
+
{{else}}
|
|
3
8
|
"format": "oxfmt && lando ssh -c 'cd /app && vendor/bin/mago format'",
|
|
4
9
|
"format:check": "oxfmt --check && lando ssh -c 'cd /app && vendor/bin/mago format --check'",
|
|
5
10
|
"lint": "oxlint && lando ssh -c 'cd /app && vendor/bin/mago lint'",
|
|
11
|
+
{{/if}}
|
|
6
12
|
"lint:fix": "oxlint --fix"
|
|
7
13
|
},
|
|
8
14
|
"devDependencies": {
|
package/modules/php/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
|
|
1
5
|
export async function setupModule(context, generator) {
|
|
2
|
-
await generator.copyDirectory(
|
|
6
|
+
await generator.copyDirectory("scripts", "php");
|
|
7
|
+
|
|
8
|
+
// kivo-wp: the wrappers delegate to bin/php instead of detecting Lando or a host PHP.
|
|
9
|
+
if (context.enable_kivo_wp) {
|
|
10
|
+
for (const name of ["php-wrapper.sh", "pint-wrapper.sh"]) {
|
|
11
|
+
await generator.copyFile(`kivo-wp/${name}`, "php", `scripts/${name}`);
|
|
12
|
+
await fs.chmod(path.join(generator.cwd, "scripts", name), 0o755);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
3
15
|
}
|
package/modules/sage/index.js
CHANGED
|
@@ -16,7 +16,6 @@ import { VERSION_REGISTRY, validateVersionCompatibility } from "../../lib/config
|
|
|
16
16
|
export async function setupModule(context, generator) {
|
|
17
17
|
const themeDir = path.join(context.cwd, "content", "themes", context.projectName);
|
|
18
18
|
const relativeThemeDir = `content/themes/${context.projectName}`;
|
|
19
|
-
const relativeDevcontainerDir = ".devcontainer";
|
|
20
19
|
|
|
21
20
|
try {
|
|
22
21
|
// 1. Validate version compatibility
|
|
@@ -143,21 +142,7 @@ export async function setupModule(context, generator) {
|
|
|
143
142
|
await fs.remove(path.join(context.cwd, relativeThemeDir, stale));
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
|
|
147
|
-
".devcontainer/docker-compose.override.yml",
|
|
148
|
-
context,
|
|
149
|
-
"sage",
|
|
150
|
-
`${relativeDevcontainerDir}/docker-compose.override.yml`,
|
|
151
|
-
);
|
|
152
|
-
await generator.generateFile(
|
|
153
|
-
".devcontainer/post-create.sh",
|
|
154
|
-
context,
|
|
155
|
-
"sage",
|
|
156
|
-
`${relativeDevcontainerDir}/post-create.sh`,
|
|
157
|
-
);
|
|
158
|
-
await fs.chmod(path.join(context.cwd, relativeDevcontainerDir, "post-create.sh"), 0o755);
|
|
159
|
-
|
|
160
|
-
// Unified setup scripts for Sage — shared between Lando, devcontainer and CI/CD
|
|
145
|
+
// Unified setup scripts for Sage — shared between Lando, kivo-wp and CI/CD
|
|
161
146
|
await generator.generateFile(
|
|
162
147
|
"server/cmd/setup-sage-php.sh",
|
|
163
148
|
context,
|
|
@@ -173,15 +158,6 @@ export async function setupModule(context, generator) {
|
|
|
173
158
|
await fs.chmod(path.join(context.cwd, "server/cmd/setup-sage-php.sh"), 0o755);
|
|
174
159
|
await fs.chmod(path.join(context.cwd, "server/cmd/setup-sage-node.sh"), 0o755);
|
|
175
160
|
|
|
176
|
-
await generator.mergeWithExistingFile({
|
|
177
|
-
existingFile: `${relativeDevcontainerDir}/devcontainer.json`,
|
|
178
|
-
moduleTemplatePath: ".devcontainer/devcontainer.json",
|
|
179
|
-
context,
|
|
180
|
-
format: "json",
|
|
181
|
-
moduleName: "sage",
|
|
182
|
-
mergeStrategy: "replace",
|
|
183
|
-
});
|
|
184
|
-
|
|
185
161
|
// 8. Lint configs co-located in theme — always installed (IDE/editor support)
|
|
186
162
|
log(color.blue, "[sage] 🔧 Installing lint configurations...");
|
|
187
163
|
await generator.copyFile(
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Lint the Sage theme scripts with oxlint in the node service.
|
|
3
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
|
+
|
|
6
|
+
kivo_wp_exec node npx oxlint --fix "content/themes/{{projectName}}/resources/" "$@"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Installs and builds Sage theme Node.js dependencies.
|
|
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 + post-start), CI/CD.
|
|
5
|
+
{{/if}}
|
|
4
6
|
set -euo pipefail
|
|
5
7
|
|
|
6
8
|
PROJECT_ROOT="${PROJECT_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Installs Sage theme PHP dependencies via Composer.
|
|
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 (post-start), CI/CD.
|
|
5
|
+
{{/if}}
|
|
4
6
|
set -euo pipefail
|
|
5
7
|
|
|
6
8
|
PROJECT_ROOT="${PROJECT_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { wordpressPlugin, wordpressThemeJson } from '@roots/vite-plugin';
|
|
2
2
|
import tailwindcss from '@tailwindcss/vite';
|
|
3
|
+
{{#unless enable_kivo_wp}}
|
|
3
4
|
import fs from 'fs';
|
|
4
|
-
import laravel from 'laravel-vite-plugin';
|
|
5
|
+
{{/unless}}import laravel from 'laravel-vite-plugin';
|
|
5
6
|
import { defineConfig } from 'vite';
|
|
6
7
|
|
|
7
8
|
export default defineConfig({
|
|
@@ -39,8 +40,24 @@ export default defineConfig({
|
|
|
39
40
|
'@fields': '/app/Fields',
|
|
40
41
|
},
|
|
41
42
|
},
|
|
43
|
+
{{#if enable_kivo_wp}}
|
|
44
|
+
// kivo-wp: Vite runs in the node service behind Caddy, which terminates TLS for
|
|
45
|
+
// https://vite.<project>.localhost on the host HTTPS port (bin/dev).
|
|
42
46
|
server: {
|
|
43
|
-
|
|
47
|
+
host: '0.0.0.0',
|
|
48
|
+
port: 5173,
|
|
49
|
+
strictPort: true,
|
|
50
|
+
origin: `https://${process.env.KIVO_WP_VITE_HOST ?? 'vite.{{projectName}}.localhost'}`,
|
|
51
|
+
cors: true,
|
|
52
|
+
hmr: {
|
|
53
|
+
host: process.env.KIVO_WP_VITE_HOST ?? 'vite.{{projectName}}.localhost',
|
|
54
|
+
protocol: 'wss',
|
|
55
|
+
clientPort: Number(process.env.HTTPS_PORT ?? 443),
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{{else}}
|
|
59
|
+
server: {
|
|
60
|
+
// Lando certificates; outside the container (for example in CI) the build runs without https
|
|
44
61
|
https: fs.existsSync('/certs/cert.key')
|
|
45
62
|
? {
|
|
46
63
|
key: fs.readFileSync('/certs/cert.key'),
|
|
@@ -55,4 +72,5 @@ export default defineConfig({
|
|
|
55
72
|
protocol: 'wss',
|
|
56
73
|
},
|
|
57
74
|
},
|
|
75
|
+
{{/if}}
|
|
58
76
|
});
|
|
@@ -92,63 +92,6 @@
|
|
|
92
92
|
"panel": "shared"
|
|
93
93
|
},
|
|
94
94
|
"problemMatcher": []
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
"label": "🐳 Devcontainer: theme-build",
|
|
98
|
-
"type": "shell",
|
|
99
|
-
"command": "docker",
|
|
100
|
-
"args": ["compose", "-f", ".devcontainer/docker-compose.yml", "-f", ".devcontainer/docker-compose.override.yml", "exec", "wordpress", "bash", "-lc", "cd /workspace/content/themes/{{projectName}} && yarn build"],
|
|
101
|
-
"group": "build",
|
|
102
|
-
"presentation": {
|
|
103
|
-
"echo": true,
|
|
104
|
-
"reveal": "always",
|
|
105
|
-
"focus": false,
|
|
106
|
-
"panel": "shared"
|
|
107
|
-
},
|
|
108
|
-
"problemMatcher": []
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
"label": "🐳 Devcontainer: theme-dev",
|
|
112
|
-
"type": "shell",
|
|
113
|
-
"command": "docker",
|
|
114
|
-
"args": ["compose", "-f", ".devcontainer/docker-compose.yml", "-f", ".devcontainer/docker-compose.override.yml", "exec", "wordpress", "bash", "-lc", "cd /workspace/content/themes/{{projectName}} && yarn dev"],
|
|
115
|
-
"group": "build",
|
|
116
|
-
"isBackground": true,
|
|
117
|
-
"presentation": {
|
|
118
|
-
"echo": true,
|
|
119
|
-
"reveal": "always",
|
|
120
|
-
"focus": false,
|
|
121
|
-
"panel": "shared"
|
|
122
|
-
},
|
|
123
|
-
"problemMatcher": []
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
"label": "🐳 Devcontainer: theme-lint",
|
|
127
|
-
"type": "shell",
|
|
128
|
-
"command": "docker",
|
|
129
|
-
"args": ["compose", "-f", ".devcontainer/docker-compose.yml", "-f", ".devcontainer/docker-compose.override.yml", "exec", "wordpress", "bash", "-lc", "cd /workspace/content/themes/{{projectName}} && yarn lint"],
|
|
130
|
-
"group": "build",
|
|
131
|
-
"presentation": {
|
|
132
|
-
"echo": true,
|
|
133
|
-
"reveal": "always",
|
|
134
|
-
"focus": false,
|
|
135
|
-
"panel": "shared"
|
|
136
|
-
},
|
|
137
|
-
"problemMatcher": []
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"label": "🐳 Devcontainer: acorn",
|
|
141
|
-
"type": "shell",
|
|
142
|
-
"command": "docker",
|
|
143
|
-
"args": ["compose", "-f", ".devcontainer/docker-compose.yml", "-f", ".devcontainer/docker-compose.override.yml", "exec", "wordpress", "bash", "-lc", "cd /workspace/content/themes/{{projectName}} && wp acorn make:component ExampleBlock"],
|
|
144
|
-
"group": "build",
|
|
145
|
-
"presentation": {
|
|
146
|
-
"echo": true,
|
|
147
|
-
"reveal": "always",
|
|
148
|
-
"focus": false,
|
|
149
|
-
"panel": "shared"
|
|
150
|
-
},
|
|
151
|
-
"problemMatcher": []
|
|
152
95
|
}
|
|
153
96
|
]
|
|
154
97
|
}
|
package/modules/test/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import path from
|
|
1
|
+
import path from "path";
|
|
2
2
|
|
|
3
|
-
import fs from
|
|
3
|
+
import fs from "fs-extra";
|
|
4
4
|
|
|
5
5
|
export async function setupModule(context, generator) {
|
|
6
|
-
const testsDir = path.join(context.cwd,
|
|
7
|
-
await fs.ensureDir(path.join(testsDir,
|
|
6
|
+
const testsDir = path.join(context.cwd, "tests");
|
|
7
|
+
await fs.ensureDir(path.join(testsDir, "e2e", "helpers"));
|
|
8
8
|
|
|
9
|
-
await generator.copyFile(
|
|
10
|
-
await generator.copyFile(
|
|
11
|
-
await generator.copyFile(
|
|
9
|
+
await generator.copyFile("tests/Pest.php", "test", "tests/Pest.php");
|
|
10
|
+
await generator.copyFile("tests/SmokeTest.php", "test", "tests/SmokeTest.php");
|
|
11
|
+
await generator.copyFile("tests/e2e/example.spec.js", "test", "tests/e2e/example.spec.js");
|
|
12
|
+
await generator.copyFile("tests/e2e/smoke.spec.js", "test", "tests/e2e/smoke.spec.js");
|
|
12
13
|
await generator.copyFile(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
"tests/e2e/helpers/loginHelper.js",
|
|
15
|
+
"test",
|
|
16
|
+
"tests/e2e/helpers/loginHelper.js",
|
|
16
17
|
);
|
|
17
18
|
|
|
18
|
-
await generator.generateFile(
|
|
19
|
+
await generator.generateFile("playwright.config.js", context, "test");
|
|
19
20
|
}
|