@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
@@ -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; }
@@ -5,10 +5,9 @@
5
5
  node_modules/
6
6
  vendor/
7
7
 
8
- # Theme/plugin/mu-plugin subtrees are formatted by their own
9
- # lint-staged globs targeting specific paths via mago/oxfmt — skip
10
- # the whole subtree here so we never accidentally reformat vendored code.
11
- content/themes/
8
+ # Plugin/mu-plugin subtrees are vendored — skip. content/themes/ NÃO entra
9
+ # aqui: o quality da CI formata o tema (oxfmt), e excluí-lo mascara drift
10
+ # até o primeiro CI vermelho (achado do piloto hekivolab, wp-kit#39).
12
11
  content/mu-plugins/
13
12
  content/plugins/
14
13
 
@@ -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"] = ["lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'"];
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": {
@@ -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('scripts', 'php');
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
  }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+ # PHP wrapper for editors and tools: runs PHP in the kivo-wp app service through bin/php.
3
+ exec "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/bin/php" "$@"
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+ # Pint wrapper for editors and tools: runs the project's Pint in the kivo-wp app service.
3
+ exec "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/bin/php" vendor/bin/pint "$@"
@@ -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
@@ -136,21 +135,14 @@ export async function setupModule(context, generator) {
136
135
  mergeStrategy: "replace",
137
136
  });
138
137
 
139
- await generator.generateFile(
140
- ".devcontainer/docker-compose.override.yml",
141
- context,
142
- "sage",
143
- `${relativeDevcontainerDir}/docker-compose.override.yml`,
144
- );
145
- await generator.generateFile(
146
- ".devcontainer/post-create.sh",
147
- context,
148
- "sage",
149
- `${relativeDevcontainerDir}/post-create.sh`,
150
- );
151
- await fs.chmod(path.join(context.cwd, relativeDevcontainerDir, "post-create.sh"), 0o755);
138
+ // O create-project gera locks do composer.json/package.json STOCK do Sage;
139
+ // após os merges acima eles ficam defasados e o `composer install`/`npm ci`
140
+ // da CI morre (wp-kit#39). O projeto gera os seus no primeiro install.
141
+ for (const stale of ["composer.lock", "package-lock.json"]) {
142
+ await fs.remove(path.join(context.cwd, relativeThemeDir, stale));
143
+ }
152
144
 
153
- // 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
154
146
  await generator.generateFile(
155
147
  "server/cmd/setup-sage-php.sh",
156
148
  context,
@@ -166,15 +158,6 @@ export async function setupModule(context, generator) {
166
158
  await fs.chmod(path.join(context.cwd, "server/cmd/setup-sage-php.sh"), 0o755);
167
159
  await fs.chmod(path.join(context.cwd, "server/cmd/setup-sage-node.sh"), 0o755);
168
160
 
169
- await generator.mergeWithExistingFile({
170
- existingFile: `${relativeDevcontainerDir}/devcontainer.json`,
171
- moduleTemplatePath: ".devcontainer/devcontainer.json",
172
- context,
173
- format: "json",
174
- moduleName: "sage",
175
- mergeStrategy: "replace",
176
- });
177
-
178
161
  // 8. Lint configs co-located in theme — always installed (IDE/editor support)
179
162
  log(color.blue, "[sage] 🔧 Installing lint configurations...");
180
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: Lando (build service build step + post-start), Devcontainer (post-create.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 + 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: Lando (post-start), Devcontainer (post-create.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 (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,11 +40,30 @@ 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
- https: {
44
- key: fs.readFileSync('/certs/cert.key'),
45
- cert: fs.readFileSync('/certs/cert.crt'),
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),
46
56
  },
57
+ },
58
+ {{else}}
59
+ server: {
60
+ // Lando certificates; outside the container (for example in CI) the build runs without https
61
+ https: fs.existsSync('/certs/cert.key')
62
+ ? {
63
+ key: fs.readFileSync('/certs/cert.key'),
64
+ cert: fs.readFileSync('/certs/cert.crt'),
65
+ }
66
+ : false,
47
67
  host: true,
48
68
  port: 5173,
49
69
  strictPort: true,
@@ -52,4 +72,5 @@ export default defineConfig({
52
72
  protocol: 'wss',
53
73
  },
54
74
  },
75
+ {{/if}}
55
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
  }
@@ -1,19 +1,20 @@
1
- import path from 'path';
1
+ import path from "path";
2
2
 
3
- import fs from 'fs-extra';
3
+ import fs from "fs-extra";
4
4
 
5
5
  export async function setupModule(context, generator) {
6
- const testsDir = path.join(context.cwd, 'tests');
7
- await fs.ensureDir(path.join(testsDir, 'e2e', 'helpers'));
6
+ const testsDir = path.join(context.cwd, "tests");
7
+ await fs.ensureDir(path.join(testsDir, "e2e", "helpers"));
8
8
 
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');
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
- 'tests/e2e/helpers/loginHelper.js',
14
- 'test',
15
- 'tests/e2e/helpers/loginHelper.js'
14
+ "tests/e2e/helpers/loginHelper.js",
15
+ "test",
16
+ "tests/e2e/helpers/loginHelper.js",
16
17
  );
17
18
 
18
- await generator.generateFile('playwright.config.js', context, 'test');
19
+ await generator.generateFile("playwright.config.js", context, "test");
19
20
  }
@@ -13,12 +13,24 @@ const config = {
13
13
  reporter: process.env.CI ? 'github' : 'list',
14
14
  use: {
15
15
  actionTimeout: 0,
16
+ {{#if enable_kivo_wp}}
17
+ // bin/e2e sets WP_HOME to the site as the node service reaches it through Caddy.
18
+ baseURL:
19
+ process.env.WP_HOME || process.env.WORDPRESS_SITE_URL || 'https://{{projectName}}.localhost',
20
+ {{else}}
16
21
  baseURL: process.env.WP_HOME || 'https://{{projectName}}.lndo.site',
22
+ {{/if}}
17
23
  trace: 'on-first-retry',
18
24
  },
19
25
  projects: [
26
+ {
27
+ // HTTP-level checks of the running site; needs no browser (bin/e2e --project=smoke).
28
+ name: 'smoke',
29
+ testMatch: /smoke\.spec\.js/,
30
+ },
20
31
  {
21
32
  name: 'chromium',
33
+ testIgnore: /smoke\.spec\.js/,
22
34
  use: {
23
35
  ...devices['Desktop Chrome'],
24
36
  },
@@ -0,0 +1,28 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ // Smoke checks over HTTP only (no browser): the site answers, the login page renders and the
4
+ // synthetic local admin can sign in. Run with `bin/e2e --project=smoke` (kivo-wp).
5
+ const ADMIN_USER = process.env.WORDPRESS_ADMIN_USER || "admin";
6
+ const ADMIN_PASSWORD = process.env.WORDPRESS_ADMIN_PASSWORD || "admin";
7
+
8
+ test("the home page answers 200", async ({ request }) => {
9
+ const response = await request.get("/");
10
+ expect(response.status()).toBe(200);
11
+ });
12
+
13
+ test("the login page answers 200", async ({ request }) => {
14
+ const response = await request.get("/wp/wp-login.php");
15
+ expect(response.status()).toBe(200);
16
+ expect(await response.text()).toContain("user_login");
17
+ });
18
+
19
+ test("the synthetic admin can sign in", async ({ request }) => {
20
+ // WordPress checks that cookies work with a test cookie set by the login page.
21
+ await request.get("/wp/wp-login.php");
22
+ const response = await request.post("/wp/wp-login.php", {
23
+ form: { log: ADMIN_USER, pwd: ADMIN_PASSWORD, "wp-submit": "Log In", testcookie: "1" },
24
+ maxRedirects: 0,
25
+ });
26
+ expect(response.status()).toBe(302);
27
+ expect(response.headers().location).toContain("/wp-admin");
28
+ });