@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
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# kivo-wp bin/ library: sourced by every bin/ script, never executed on its own.
|
|
3
|
+
# Every tool runs inside the Compose stack; nothing runs on the host.
|
|
4
|
+
# shellcheck shell=bash
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
KIVO_WP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
9
|
+
# Project path inside the app and node containers (bind mount in compose.yaml).
|
|
10
|
+
KIVO_WP_CONTAINER_ROOT="/var/www/html"
|
|
11
|
+
# Theme directories relative to the root (used by bin/build, bin/dev and bin/flush).
|
|
12
|
+
# shellcheck disable=SC2034
|
|
13
|
+
KIVO_WP_THEME_DIRS=({{#each kivoWp.themeDirs}}"{{this}}"{{#unless @last}} {{/unless}}{{/each}})
|
|
14
|
+
export KIVO_WP_ROOT KIVO_WP_CONTAINER_ROOT
|
|
15
|
+
|
|
16
|
+
kivo_wp_err() {
|
|
17
|
+
printf 'kivo-wp: %s\n' "$*" >&2
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
kivo_wp_die() {
|
|
21
|
+
kivo_wp_err "$@"
|
|
22
|
+
exit 1
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# docker compose for this project. No -f: compose.override.yaml still merges.
|
|
26
|
+
kivo_wp_compose() {
|
|
27
|
+
command -v docker >/dev/null 2>&1 || kivo_wp_die "docker not found; open the project on a host or workspace container with Docker"
|
|
28
|
+
docker compose --project-directory "${KIVO_WP_ROOT}" "$@"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
kivo_wp_is_running() {
|
|
32
|
+
local service="$1" running
|
|
33
|
+
running="$(kivo_wp_compose ps --status running --services 2>/dev/null || true)"
|
|
34
|
+
grep -qx "${service}" <<<"${running}"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
kivo_wp_require_running() {
|
|
38
|
+
local service="${1:-app}"
|
|
39
|
+
kivo_wp_is_running "${service}" || kivo_wp_die "kivo-wp stack is not running (service ${service}); start it with bin/up"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Container working directory: the caller's directory when it is inside the project.
|
|
43
|
+
kivo_wp_workdir() {
|
|
44
|
+
local here
|
|
45
|
+
here="$(pwd -P)"
|
|
46
|
+
case "${here}/" in
|
|
47
|
+
"${KIVO_WP_ROOT}/"*)
|
|
48
|
+
local rel="${here#"${KIVO_WP_ROOT}"}"
|
|
49
|
+
printf '%s%s\n' "${KIVO_WP_CONTAINER_ROOT}" "${rel}"
|
|
50
|
+
;;
|
|
51
|
+
*) printf '%s\n' "${KIVO_WP_CONTAINER_ROOT}" ;;
|
|
52
|
+
esac
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# Run a command in a service. -T when stdin or stdout is not a terminal, so piped input
|
|
56
|
+
# (agents, MCP stdio, CI) and captured output stay byte-clean. Only app and node mount the
|
|
57
|
+
# project, so the other services (db, cache, mail, proxy) keep their image working directory.
|
|
58
|
+
kivo_wp_exec() {
|
|
59
|
+
local service="$1"
|
|
60
|
+
shift
|
|
61
|
+
kivo_wp_require_running "${service}"
|
|
62
|
+
local flags=()
|
|
63
|
+
if [ ! -t 0 ] || [ ! -t 1 ]; then
|
|
64
|
+
flags+=(-T)
|
|
65
|
+
fi
|
|
66
|
+
case "${service}" in
|
|
67
|
+
app | node) flags+=(--workdir "$(kivo_wp_workdir)") ;;
|
|
68
|
+
esac
|
|
69
|
+
kivo_wp_compose exec ${flags[@]+"${flags[@]}"} "${service}" "$@"
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# Same as kivo_wp_exec, from a fixed container directory relative to the project root.
|
|
73
|
+
kivo_wp_exec_in() {
|
|
74
|
+
local service="$1" dir="$2"
|
|
75
|
+
shift 2
|
|
76
|
+
kivo_wp_require_running "${service}"
|
|
77
|
+
local flags=()
|
|
78
|
+
if [ ! -t 0 ] || [ ! -t 1 ]; then
|
|
79
|
+
flags+=(-T)
|
|
80
|
+
fi
|
|
81
|
+
kivo_wp_compose exec ${flags[@]+"${flags[@]}"} --workdir "${KIVO_WP_CONTAINER_ROOT}/${dir}" "${service}" "$@"
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# Run a MySQL client tool (mysql, mysqldump) in the db service as the project database user.
|
|
85
|
+
# The app image has no MySQL client; the db image ships the tools matching the server.
|
|
86
|
+
kivo_wp_db_tool() {
|
|
87
|
+
local tool="$1" user password
|
|
88
|
+
shift
|
|
89
|
+
user="$(kivo_wp_env_get WORDPRESS_DB_USER)"
|
|
90
|
+
password="$(kivo_wp_env_get WORDPRESS_DB_PASSWORD)"
|
|
91
|
+
kivo_wp_exec db env MYSQL_PWD="${password:-wordpress}" "${tool}" -u"${user:-wordpress}" "$@"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
# Name of the project database (local default: wordpress).
|
|
95
|
+
kivo_wp_db_name() {
|
|
96
|
+
local name
|
|
97
|
+
name="$(kivo_wp_env_get WORDPRESS_DB_NAME)"
|
|
98
|
+
printf '%s\n' "${name:-wordpress}"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# Value of a key in .env without exporting the file (it holds salts; only named keys are read).
|
|
102
|
+
kivo_wp_env_get() {
|
|
103
|
+
local key="$1" file="${KIVO_WP_ROOT}/.env" line
|
|
104
|
+
[ -f "${file}" ] || return 0
|
|
105
|
+
line="$(grep -E "^${key}=" "${file}" | tail -n 1 || true)"
|
|
106
|
+
line="${line#*=}"
|
|
107
|
+
line="${line%\"}"
|
|
108
|
+
line="${line#\"}"
|
|
109
|
+
printf '%s\n' "${line}"
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Set KEY=value in .env, adding the line when missing.
|
|
113
|
+
kivo_wp_env_set() {
|
|
114
|
+
local key="$1" value="$2" file="${KIVO_WP_ROOT}/.env" tmp
|
|
115
|
+
[ -f "${file}" ] || kivo_wp_die ".env not found; run bin/setup"
|
|
116
|
+
tmp="$(mktemp)"
|
|
117
|
+
if grep -qE "^${key}=" "${file}"; then
|
|
118
|
+
awk -v k="${key}" -v v="${value}" 'BEGIN { FS = OFS = "=" } $1 == k { print k "=" v; next } { print }' "${file}" >"${tmp}"
|
|
119
|
+
else
|
|
120
|
+
cat "${file}" >"${tmp}"
|
|
121
|
+
# Keep the new line on its own even when the file lacks a final newline.
|
|
122
|
+
[ -z "$(tail -c 1 "${file}")" ] || printf '\n' >>"${tmp}"
|
|
123
|
+
printf '%s=%s\n' "${key}" "${value}" >>"${tmp}"
|
|
124
|
+
fi
|
|
125
|
+
cat "${tmp}" >"${file}"
|
|
126
|
+
rm -f "${tmp}"
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
# Remove KEY from .env when present.
|
|
130
|
+
kivo_wp_env_unset() {
|
|
131
|
+
local key="$1" file="${KIVO_WP_ROOT}/.env" tmp
|
|
132
|
+
[ -f "${file}" ] && grep -qE "^${key}=" "${file}" || return 0
|
|
133
|
+
tmp="$(mktemp)"
|
|
134
|
+
grep -vE "^${key}=" "${file}" >"${tmp}" || true
|
|
135
|
+
cat "${tmp}" >"${file}"
|
|
136
|
+
rm -f "${tmp}"
|
|
137
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Build the theme assets in the node service.
|
|
3
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
|
+
|
|
6
|
+
if [ "${#KIVO_WP_THEME_DIRS[@]}" -eq 0 ]; then
|
|
7
|
+
kivo_wp_err "this project has no theme to build"
|
|
8
|
+
exit 0
|
|
9
|
+
fi
|
|
10
|
+
for dir in "${KIVO_WP_THEME_DIRS[@]}"; do
|
|
11
|
+
kivo_wp_err "building ${dir}"
|
|
12
|
+
kivo_wp_exec_in node "${dir}" npm run build
|
|
13
|
+
done
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Export the local database to a SQL file (default: db-export-<timestamp>.sql).
|
|
3
|
+
# mysqldump runs in the db service. The file appears only when the dump succeeds: a failed
|
|
4
|
+
# dump leaves nothing behind.
|
|
5
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
6
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
7
|
+
|
|
8
|
+
file="${1:-db-export-$(date +%Y%m%d-%H%M%S).sql}"
|
|
9
|
+
[ ! -d "${file}" ] || kivo_wp_die "${file} is a directory"
|
|
10
|
+
|
|
11
|
+
tmp="$(mktemp "$(dirname "${file}")/.db-export.XXXXXX")"
|
|
12
|
+
trap 'rm -f "${tmp}"' EXIT
|
|
13
|
+
kivo_wp_db_tool mysqldump --single-transaction --quick --no-tablespaces \
|
|
14
|
+
--default-character-set=utf8mb4 "$(kivo_wp_db_name)" >"${tmp}"
|
|
15
|
+
[ -s "${tmp}" ] || kivo_wp_die "mysqldump wrote nothing; ${file} was not created"
|
|
16
|
+
mv "${tmp}" "${file}"
|
|
17
|
+
trap - EXIT
|
|
18
|
+
kivo_wp_err "database exported to ${file}"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Import a SQL dump (.sql or .sql.gz) into the local database. Human-only, local only (D-002).
|
|
3
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
|
+
|
|
6
|
+
# Snapshots never reach CI, Codespaces or cloud agent sessions (D-002, D-007).
|
|
7
|
+
for marker in CI CODESPACES CLAUDE_CODE_REMOTE; do
|
|
8
|
+
if [ -n "${!marker:-}" ]; then
|
|
9
|
+
kivo_wp_die "bin/db-import is disabled when ${marker} is set: production data stays on a developer machine; use bin/seed"
|
|
10
|
+
fi
|
|
11
|
+
done
|
|
12
|
+
|
|
13
|
+
file="${1:-}"
|
|
14
|
+
[ -n "${file}" ] || kivo_wp_die "usage: bin/db-import <dump.sql|dump.sql.gz>"
|
|
15
|
+
[ -f "${file}" ] || kivo_wp_die "file not found: ${file}"
|
|
16
|
+
|
|
17
|
+
# The mysql client runs in the db service.
|
|
18
|
+
import_sql() {
|
|
19
|
+
kivo_wp_db_tool mysql --default-character-set=utf8mb4 "$(kivo_wp_db_name)"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
case "${file}" in
|
|
23
|
+
*.gz) gzip -dc "${file}" | import_sql ;;
|
|
24
|
+
*) import_sql <"${file}" ;;
|
|
25
|
+
esac
|
|
26
|
+
kivo_wp_err "database imported from ${file}"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Run the theme Vite dev server in the node service (served at https://vite.<project>.localhost).
|
|
3
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
|
+
|
|
6
|
+
[ "${#KIVO_WP_THEME_DIRS[@]}" -gt 0 ] || kivo_wp_die "this project has no theme with a Vite dev server"
|
|
7
|
+
kivo_wp_exec_in node "${KIVO_WP_THEME_DIRS[0]}" npm run dev -- "$@"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Stop the kivo-wp stack. --volumes also deletes its data (asks first; --yes confirms).
|
|
3
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
|
+
|
|
6
|
+
volumes=false
|
|
7
|
+
confirmed=false
|
|
8
|
+
args=()
|
|
9
|
+
for arg in "$@"; do
|
|
10
|
+
case "${arg}" in
|
|
11
|
+
-v | --volumes)
|
|
12
|
+
volumes=true
|
|
13
|
+
args+=(--volumes)
|
|
14
|
+
;;
|
|
15
|
+
-y | --yes) confirmed=true ;;
|
|
16
|
+
*) args+=("${arg}") ;;
|
|
17
|
+
esac
|
|
18
|
+
done
|
|
19
|
+
|
|
20
|
+
if [ "${volumes}" = true ]; then
|
|
21
|
+
kivo_wp_err "--volumes deletes the named volumes of this project:"
|
|
22
|
+
kivo_wp_err " db-data the local database: content, users and settings (export first with bin/db-export)"
|
|
23
|
+
kivo_wp_err " caddy-data Caddy's local CA and certificates (browsers must trust the new CA again: bin/trust-cert)"
|
|
24
|
+
if [ "${confirmed}" != true ]; then
|
|
25
|
+
[ -t 0 ] || kivo_wp_die "refusing to delete volumes without confirmation; pass --yes to confirm"
|
|
26
|
+
read -r -p "Delete these volumes? [y/N] " answer
|
|
27
|
+
case "${answer}" in
|
|
28
|
+
y | Y | yes | YES) ;;
|
|
29
|
+
*) kivo_wp_die "aborted; nothing was deleted" ;;
|
|
30
|
+
esac
|
|
31
|
+
fi
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
kivo_wp_compose down ${args[@]+"${args[@]}"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Playwright end-to-end tests in the node service. Without --project it runs the smoke project
|
|
3
|
+
# (HTTP checks, no browser), which passes on a fresh project. Browser projects need Chromium in
|
|
4
|
+
# the node service: run `bin/e2e --install-chromium` once per node container, then
|
|
5
|
+
# `bin/e2e --project=chromium` (docs/Development.md, "End-to-end tests in a browser").
|
|
6
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
7
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
8
|
+
|
|
9
|
+
kivo_wp_require_running node
|
|
10
|
+
kivo_wp_require_running proxy
|
|
11
|
+
|
|
12
|
+
if [ "${1:-}" = "--install-chromium" ]; then
|
|
13
|
+
# System libraries and certutil need root; the browser goes to the node user's cache.
|
|
14
|
+
kivo_wp_compose exec -T -u root --workdir "${KIVO_WP_CONTAINER_ROOT}" node sh -c \
|
|
15
|
+
'npx --yes playwright install-deps chromium && apt-get install -y --no-install-recommends libnss3-tools'
|
|
16
|
+
kivo_wp_exec node npx playwright install chromium
|
|
17
|
+
exit 0
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# Trust Caddy's local CA inside the node service, never by ignoring TLS errors: Node reads
|
|
21
|
+
# NODE_EXTRA_CA_CERTS, Chromium reads the NSS database of the node user (when certutil exists).
|
|
22
|
+
ca_tmp="$(mktemp)"
|
|
23
|
+
KIVO_WP_CERT_OUT="${ca_tmp}" "${KIVO_WP_ROOT}/bin/trust-cert" >/dev/null
|
|
24
|
+
chmod 0644 "${ca_tmp}"
|
|
25
|
+
kivo_wp_compose cp "${ca_tmp}" node:/tmp/kivo-wp-root.crt >/dev/null
|
|
26
|
+
rm -f "${ca_tmp}"
|
|
27
|
+
# shellcheck disable=SC2016 # expanded by the node service shell
|
|
28
|
+
kivo_wp_exec node sh -c 'command -v certutil >/dev/null || exit 0
|
|
29
|
+
db="${HOME}/.pki/nssdb"
|
|
30
|
+
mkdir -p "${db}"
|
|
31
|
+
[ -f "${db}/cert9.db" ] || certutil -d "sql:${db}" -N --empty-password
|
|
32
|
+
certutil -d "sql:${db}" -A -t "C,," -n kivo-wp-local -i /tmp/kivo-wp-root.crt'
|
|
33
|
+
|
|
34
|
+
# The proxy answers the project host names on the same port inside the Compose network.
|
|
35
|
+
site_url="$(kivo_wp_env_get WORDPRESS_SITE_URL)"
|
|
36
|
+
|
|
37
|
+
project_set=0
|
|
38
|
+
for arg in "$@"; do
|
|
39
|
+
case "${arg}" in
|
|
40
|
+
--project | --project=*) project_set=1 ;;
|
|
41
|
+
esac
|
|
42
|
+
done
|
|
43
|
+
[ "${project_set}" -eq 1 ] || set -- --project=smoke "$@"
|
|
44
|
+
|
|
45
|
+
# KIVO_WP_E2E_PROXY: Chromium resolves *.localhost to loopback by itself, so the Playwright
|
|
46
|
+
# config maps the project host names to the proxy service.
|
|
47
|
+
kivo_wp_exec node env NODE_EXTRA_CA_CERTS=/tmp/kivo-wp-root.crt WP_HOME="${site_url}" \
|
|
48
|
+
KIVO_WP_E2E_PROXY=proxy npx playwright test "$@"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Flush the WordPress, Acorn and object caches.
|
|
3
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
|
+
|
|
6
|
+
kivo_wp_exec app wp rewrite flush
|
|
7
|
+
kivo_wp_exec app wp cache flush
|
|
8
|
+
{{#if enable_sage}}
|
|
9
|
+
kivo_wp_exec app wp acorn optimize:clear
|
|
10
|
+
{{/if}}
|
|
11
|
+
kivo_wp_exec cache valkey-cli FLUSHDB
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Print the local URLs and the state of the services.
|
|
3
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
|
+
|
|
6
|
+
site_url="$(kivo_wp_env_get WORDPRESS_SITE_URL)"
|
|
7
|
+
host="${site_url#https://}"
|
|
8
|
+
host="${host#http://}"
|
|
9
|
+
|
|
10
|
+
printf 'Site: %s\n' "${site_url}"
|
|
11
|
+
printf 'Admin: %s/wp/wp-admin/\n' "${site_url}"
|
|
12
|
+
printf 'Vite: https://vite.%s\n' "${host}"
|
|
13
|
+
printf 'Mailpit: https://mail.%s\n' "${host}"
|
|
14
|
+
printf '\n'
|
|
15
|
+
kivo_wp_compose ps
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Mago (PHP format and lint) in the app service. Without arguments it runs `mago lint`, the
|
|
3
|
+
# command agent tooling maps to bin/mago; any arguments pass through (bin/mago format).
|
|
4
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
5
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
6
|
+
|
|
7
|
+
[ "$#" -gt 0 ] || set -- lint
|
|
8
|
+
kivo_wp_exec app vendor/bin/mago "$@"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Delete and reinstall the Composer and npm dependencies.
|
|
3
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
|
+
|
|
6
|
+
kivo_wp_exec_in app . bash -c 'rm -rf vendor && bash server/cmd/setup-php.sh'
|
|
7
|
+
kivo_wp_exec_in node . bash -c 'rm -rf node_modules && bash server/cmd/setup-node.sh'
|
|
8
|
+
{{#if enable_sage}}
|
|
9
|
+
kivo_wp_exec_in app . bash server/cmd/setup-sage-php.sh
|
|
10
|
+
kivo_wp_exec_in node . bash server/cmd/setup-sage-node.sh
|
|
11
|
+
{{/if}}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Seed deterministic synthetic fixtures (D-002); --reset empties the database first.
|
|
3
|
+
# Records carry the _kivo_wp_fixture meta, so running it again replaces them.
|
|
4
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
5
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
6
|
+
|
|
7
|
+
case "${1:-}" in
|
|
8
|
+
--reset)
|
|
9
|
+
# The database is recreated with the db service client: the app image has no MySQL client.
|
|
10
|
+
db_name="$(kivo_wp_db_name)"
|
|
11
|
+
kivo_wp_db_tool mysql -e "DROP DATABASE IF EXISTS \`${db_name}\`; CREATE DATABASE \`${db_name}\`;"
|
|
12
|
+
kivo_wp_exec_in app . bash server/cmd/install-wp.sh
|
|
13
|
+
{{#if enable_sage}}
|
|
14
|
+
kivo_wp_exec app wp theme activate "{{projectName}}" --path=wp
|
|
15
|
+
{{/if}}
|
|
16
|
+
;;
|
|
17
|
+
"") ;;
|
|
18
|
+
*) kivo_wp_die "usage: bin/seed [--reset]" ;;
|
|
19
|
+
esac
|
|
20
|
+
|
|
21
|
+
kivo_wp_exec_in app . wp eval-file fixtures/seed.php --path=wp
|