@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
@@ -3,9 +3,64 @@ import inquirer from "inquirer";
3
3
 
4
4
  import { getGitUserDefaults } from "../utils/git.js";
5
5
  import { Generator } from "../core/generator.js";
6
+ import { VERSION_REGISTRY } from "../config/versions.js";
6
7
 
7
8
  import { loadModulePrompts } from "./loadModulePrompts.js";
8
9
 
10
+ // D-014: licensed Composer credentials are 1Password references, never typed into the generator.
11
+ export const ACF_OP_REFERENCE_PLACEHOLDER = "op://<vault>/<item>";
12
+
13
+ // D-010: 8.4 is the default for every scaffold, Sage 11 included.
14
+ export const DEFAULT_PHP_VERSION = "8.4";
15
+
16
+ export function resolvePhpVersion(value) {
17
+ const version = String(value).trim();
18
+ const { supported } = VERSION_REGISTRY.php;
19
+ if (!supported.includes(version)) {
20
+ throw new Error(
21
+ `Unsupported PHP version "${version}". Supported versions: ${supported.join(", ")}.`,
22
+ );
23
+ }
24
+ return version;
25
+ }
26
+
27
+ // Q-032: Sage 11 requires PHP 8.4+ (roots/acorn-ai); older versions are not offered with Sage.
28
+ export function phpVersionsFor(contentModules = []) {
29
+ const { supported } = VERSION_REGISTRY.php;
30
+ if (!contentModules.includes("sage")) return supported;
31
+ const minPhp = parseFloat(VERSION_REGISTRY.sage[11].minPhp);
32
+ return supported.filter((v) => parseFloat(v) >= minPhp);
33
+ }
34
+
35
+ export function assertPhpForModules(version, contentModules = []) {
36
+ if (!phpVersionsFor(contentModules).includes(version)) {
37
+ throw new Error(
38
+ `Sage requires PHP ${VERSION_REGISTRY.sage[11].minPhp}+ (got ${version}). ` +
39
+ `Choose one of: ${phpVersionsFor(contentModules).join(", ")}, or a scaffold without Sage.`,
40
+ );
41
+ }
42
+ return version;
43
+ }
44
+
45
+ // D-008: kivo-wp is the default environment; Lando stays for 6.x as a deprecated choice.
46
+ export const DEV_ENVIRONMENTS = ["kivo-wp", "lando"];
47
+ export const DEFAULT_DEV_ENVIRONMENT = "kivo-wp";
48
+
49
+ export function resolveDevEnvironment(value) {
50
+ const environment = String(value).trim();
51
+ if (!DEV_ENVIRONMENTS.includes(environment)) {
52
+ throw new Error(
53
+ `Unknown dev environment "${environment}". Supported environments: ${DEV_ENVIRONMENTS.join(", ")}.`,
54
+ );
55
+ }
56
+ return environment;
57
+ }
58
+
59
+ // Hostname of the local site for the chosen environment.
60
+ export function localDomain(projectName, devEnvironment) {
61
+ return devEnvironment === "lando" ? `${projectName}.lndo.site` : `${projectName}.localhost`;
62
+ }
63
+
9
64
  function parseBooleanEnv(value) {
10
65
  if (typeof value !== "string") return null;
11
66
  const normalized = value.trim().toLowerCase();
@@ -149,7 +204,16 @@ export async function runPrompts({ defaults = false } = {}) {
149
204
  message: "Repository URL:",
150
205
  default: defaultsGit.gitRepository,
151
206
  },
152
- // phpVersion and nodeVersion are locked to '8.4' / '24' — injected into context, not prompted
207
+ {
208
+ type: "list",
209
+ name: "dev_environment",
210
+ message: "Local development environment:",
211
+ choices: [
212
+ { name: "kivo-wp (Docker Compose)", value: "kivo-wp" },
213
+ { name: "Lando (deprecated, removed in 7.0.0)", value: "lando" },
214
+ ],
215
+ default: DEFAULT_DEV_ENVIRONMENT,
216
+ },
153
217
  {
154
218
  type: "list",
155
219
  name: "wpCoreVersion",
@@ -181,6 +245,15 @@ export async function runPrompts({ defaults = false } = {}) {
181
245
  ],
182
246
  default: ["sage"],
183
247
  },
248
+ // php_version feeds context.phpVersion for every environment (D-010); nodeVersion ('24') is injected.
249
+ // It follows the content modules so Sage only offers the versions it installs on (Q-032).
250
+ {
251
+ type: "list",
252
+ name: "php_version",
253
+ message: "PHP version:",
254
+ choices: (answers) => phpVersionsFor(answers.selectedContentModules),
255
+ default: DEFAULT_PHP_VERSION,
256
+ },
184
257
  {
185
258
  type: "confirm",
186
259
  name: "enable_acf_pro",
@@ -189,10 +262,10 @@ export async function runPrompts({ defaults = false } = {}) {
189
262
  },
190
263
  {
191
264
  type: "input",
192
- name: "acf_license_key",
265
+ name: "acf_op_reference",
193
266
  message:
194
- "ACF Pro license key (from connect.advancedcustomfields.com — leave blank to configure later):",
195
- default: "",
267
+ "1Password item for the ACF Pro credentials (op://<vault>/<item>; fields license-key and site-url):",
268
+ default: ACF_OP_REFERENCE_PLACEHOLDER,
196
269
  when: (answers) => answers.enable_acf_pro,
197
270
  },
198
271
  {
@@ -267,11 +340,34 @@ export async function runPrompts({ defaults = false } = {}) {
267
340
  defaultAnswers.gitProvider = envGitProvider;
268
341
  }
269
342
 
343
+ // WP_KIT_DEV_ENVIRONMENT: overrides dev_environment (kivo-wp or lando).
344
+ if (process.env.WP_KIT_DEV_ENVIRONMENT) {
345
+ defaultAnswers.dev_environment = resolveDevEnvironment(process.env.WP_KIT_DEV_ENVIRONMENT);
346
+ }
347
+
348
+ // WP_KIT_ACF_PRO: overrides enable_acf_pro (the e2e and image tests run without a licence).
349
+ const envAcfPro = parseBooleanEnv(process.env.WP_KIT_ACF_PRO);
350
+ if (envAcfPro !== null) {
351
+ defaultAnswers.enable_acf_pro = envAcfPro;
352
+ if (!envAcfPro) {
353
+ delete defaultAnswers.acf_op_reference;
354
+ delete defaultAnswers.acf_site_url;
355
+ }
356
+ }
357
+
358
+ // WP_KIT_PHP_VERSION: overrides php_version; only supported versions are accepted.
359
+ if (process.env.WP_KIT_PHP_VERSION) {
360
+ defaultAnswers.php_version = resolvePhpVersion(process.env.WP_KIT_PHP_VERSION);
361
+ }
362
+ assertPhpForModules(defaultAnswers.php_version, defaultAnswers.selectedContentModules);
363
+
270
364
  // WP_KIT_SSH_TRANSPORT: overrides ssh_transport (used for non-interactive E2E generation).
271
365
  if (process.env.WP_KIT_SSH_TRANSPORT) {
272
366
  defaultAnswers.ssh_transport = process.env.WP_KIT_SSH_TRANSPORT;
273
367
  }
274
368
 
369
+ defaultAnswers.enable_kivo_wp = defaultAnswers.dev_environment === "kivo-wp";
370
+
275
371
  const enabledModules = Object.keys(modulePromptDefs).filter(
276
372
  (mod) => defaultAnswers[`enable_${mod.replace(/-/g, "_")}`] === true,
277
373
  );
@@ -283,10 +379,10 @@ export async function runPrompts({ defaults = false } = {}) {
283
379
  return {
284
380
  ...defaultAnswers,
285
381
  ...derived,
286
- phpVersion: "8.4",
382
+ phpVersion: defaultAnswers.php_version,
287
383
  nodeVersion: "24",
288
384
  enabledModules,
289
- projectDomain: `${defaultAnswers.projectName}.lndo.site`,
385
+ projectDomain: localDomain(defaultAnswers.projectName, defaultAnswers.dev_environment),
290
386
  salts: Generator.generateSalts(),
291
387
  };
292
388
  }
@@ -300,6 +396,8 @@ export async function runPrompts({ defaults = false } = {}) {
300
396
  answers.enable_mu_plugin = sel.includes("mu-plugin");
301
397
  answers.enable_plugin = sel.includes("plugin");
302
398
 
399
+ answers.enable_kivo_wp = answers.dev_environment === "kivo-wp";
400
+
303
401
  const enabledModules = Object.keys(modulePromptDefs).filter(
304
402
  (mod) => answers[`enable_${mod.replace(/-/g, "_")}`] === true,
305
403
  );
@@ -311,10 +409,10 @@ export async function runPrompts({ defaults = false } = {}) {
311
409
  return {
312
410
  ...answers,
313
411
  ...derived,
314
- phpVersion: "8.4",
412
+ phpVersion: answers.php_version,
315
413
  nodeVersion: "24",
316
414
  enabledModules,
317
- projectDomain: `${answers.projectName}.lndo.site`,
415
+ projectDomain: localDomain(answers.projectName, answers.dev_environment),
318
416
  salts: Generator.generateSalts(),
319
417
  };
320
418
  }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Composer auth.json template for `op inject` (D-014): only 1Password secret references, never
3
+ * values. `op inject -i auth.json.tpl -o auth.json` replaces each {{ op://... }} with its value.
4
+ * @param {string} reference - op://<vault>/<item> holding the fields license-key and site-url
5
+ * @returns {string} JSON template text
6
+ */
7
+ export function renderAuthTemplate(reference) {
8
+ const base = reference.replace(/\/+$/, "");
9
+ const template = {
10
+ "http-basic": {
11
+ "connect.advancedcustomfields.com": {
12
+ username: `{{ ${base}/license-key }}`,
13
+ password: `{{ ${base}/site-url }}`,
14
+ },
15
+ },
16
+ };
17
+ return `${JSON.stringify(template, null, 2)}\n`;
18
+ }
@@ -0,0 +1,28 @@
1
+ // Matches active and commented-out assignments (`KEY=v`, `export KEY=v`, `# KEY=v`).
2
+ const ASSIGNMENT = /^(\s*(?:#\s*)?(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*))=.*$/;
3
+
4
+ // Keys whose values are never kept, whatever the caller allows (salts, keys, tokens, passwords).
5
+ export const SECRET_KEY_PATTERN = /(KEY|SALT|SECRET|TOKEN|PASSWORD)/;
6
+
7
+ /**
8
+ * Turns dotenv content into an example that is safe to commit. Every assignment, including
9
+ * commented-out ones, keeps its key and loses its value, except active assignments for which
10
+ * `keepValue(key)` returns true and whose key is not secret-like (D-028: non-secret kivo-wp
11
+ * defaults). Other comments and blank lines are preserved as-is.
12
+ * @param {string} content - Rendered dotenv content
13
+ * @param {{ keepValue?: (key: string) => boolean }} [options]
14
+ * @returns {string} Content safe to commit
15
+ */
16
+ export function toEnvExample(content, { keepValue = () => false } = {}) {
17
+ return content
18
+ .split("\n")
19
+ .map((line) => {
20
+ const match = line.match(ASSIGNMENT);
21
+ if (!match) return line;
22
+ const [, prefix, key] = match;
23
+ const commented = /^\s*#/.test(line);
24
+ if (!commented && !SECRET_KEY_PATTERN.test(key) && keepValue(key)) return line;
25
+ return `${prefix}=`;
26
+ })
27
+ .join("\n");
28
+ }
@@ -12,7 +12,7 @@ import { log, color } from "../../lib/utils/logger.js";
12
12
  *
13
13
  * acme-theme -> ACME_THEME
14
14
  * my-site-theme -> MY_SITE_THEME
15
- * wp-futrading-theme -> WP_FUTRADING_THEME
15
+ * wp-myproject-theme -> WP_MYPROJECT_THEME
16
16
  */
17
17
  function toConstantPrefix(slug) {
18
18
  return slug
@@ -1,3 +1,7 @@
1
+ import path from "path";
2
+
3
+ import fs from "fs-extra";
4
+
1
5
  import { log, color } from "../../lib/utils/logger.js";
2
6
 
3
7
  export async function setupModule(context, generator) {
@@ -8,7 +12,21 @@ export async function setupModule(context, generator) {
8
12
 
9
13
  log(color.blue, "[deploy] Gerando pipeline de CI baseado em context.ci");
10
14
 
15
+ // Verificador de exposição: serve ao CI (ci.yml) e a quem faz deploy por conta própria. Confere de fora
16
+ // que .env, CLAUDE.md, composer.lock etc. não respondem 200; ver docs/Deploy-Pipeline.md.
17
+ await generator.copyFile("scripts/check-exposure.sh", "deploy", "scripts/check-exposure.sh");
18
+ if (context.enable_kivo_wp) {
19
+ // The local environment file to probe is compose.yaml instead of the Landofile.
20
+ const script = path.join(generator.cwd, "scripts/check-exposure.sh");
21
+ const text = await fs.readFile(script, "utf8");
22
+ await fs.outputFile(script, text.replace(" .lando.yml ", " compose.yaml "));
23
+ }
24
+ log(color.green, "[deploy] scripts/check-exposure.sh copiado.");
25
+
11
26
  try {
27
+ await generator.generateFile("renovate.json", context, "deploy", "renovate.json");
28
+ log(color.green, "[deploy] renovate.json gerado (frota Hekivo).");
29
+
12
30
  if (context.gitProvider === "gitlab") {
13
31
  await generator.generateFile(".gitlab/gitlab-ci.yml", context, "deploy", ".gitlab-ci.yml");
14
32
  log(color.green, "[deploy] .gitlab-ci.yml gerado com sucesso.");
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env bash
2
+ # Checks from the outside that no secret or development file is public.
3
+ # Usage: check-exposure.sh <base-url> [theme-slug]
4
+ # Exits 1 if a CRITICAL path answers 200 with a body; WARN paths are only listed. Each request carries a
5
+ # unique query: Cloudflare caches static files by URL, and a stale cached copy would hide (or invent) an
6
+ # exposure. Prints status and size only, never content.
7
+ #
8
+ # Where it runs matters. From an IP the WAF lets through (a "Bypass IP" rule, a CI runner on an allow list)
9
+ # the result is the ORIGIN's: the WAF does not act, so it is the strictest reading. To see what the PUBLIC
10
+ # sees, run it from an IP outside any bypass (for example from the server itself over ssh).
11
+ set -uo pipefail
12
+
13
+ BASE="${1:?Usage: $0 <base-url> [theme-slug]}"
14
+ BASE="${BASE%/}"
15
+ THEME="${2:-}"
16
+
17
+ CRITICAL=(
18
+ .env .env.local .env.production .env.staging .env.backup .env.save .env.example '.env~'
19
+ .git/config .git/HEAD .gitignore .htpasswd .npmrc auth.json
20
+ composer.json composer.lock package.json package-lock.json
21
+ CLAUDE.md AGENTS.md README.md DESIGN.md PRODUCT.md
22
+ .mcp.json .claude/settings.json .claude/settings.local.json .cursor/mcp.json .vscode/settings.json
23
+ .devcontainer/devcontainer.json .github/workflows/ci.yml .github/workflows/deploy.yml .lando.yml docker-compose.yml
24
+ wp-config.php.bak 'wp-config.php~' wp-config.old wp-config.txt
25
+ backup.sql dump.sql db.sql backup.zip debug.log content/debug.log error_log phpinfo.php
26
+ )
27
+ WARN=(
28
+ wp-cli.yml vendor/composer/installed.json wp/readme.html wp/license.txt wp/wp-config-sample.php
29
+ wp-json/ wp-json/wp/v2/users
30
+ )
31
+ if [ -n "$THEME" ]; then
32
+ CRITICAL+=("content/themes/$THEME/package.json" "content/themes/$THEME/vite.config.js" "content/themes/$THEME/.env")
33
+ WARN+=("content/themes/$THEME/composer.json" "content/themes/$THEME/resources/views/layouts/app.blade.php")
34
+ fi
35
+
36
+ nonce="$(date +%s)$RANDOM"
37
+ critical=0
38
+
39
+ probe() { # path -> "status size"
40
+ curl -s -o /dev/null -m 20 -w '%{http_code} %{size_download}' "$BASE/$1?_x=$nonce"
41
+ }
42
+
43
+ for path in "${CRITICAL[@]}"; do
44
+ read -r status size < <(probe "$path")
45
+ if [ "$status" = "200" ] && [ "${size:-0}" -gt 0 ]; then
46
+ echo "::error title=Public file::/$path answers 200 (${size}B) on $BASE"
47
+ critical=$((critical + 1))
48
+ fi
49
+ done
50
+
51
+ for path in "${WARN[@]}"; do
52
+ read -r status size < <(probe "$path")
53
+ if [ "$status" = "200" ] && [ "${size:-0}" -gt 0 ]; then
54
+ echo "::warning title=Information disclosure::/$path answers 200 (${size}B) on $BASE"
55
+ fi
56
+ done
57
+
58
+ if [ "$critical" -gt 0 ]; then
59
+ echo "$critical critical path(s) public on $BASE. Block them in nginx/WAF and keep them out of the deploy." >&2
60
+ exit 1
61
+ fi
62
+
63
+ echo "Exposure: no critical path is public on $BASE."
@@ -63,12 +63,19 @@ jobs:
63
63
  theme-path: {{ci.theme.paths.themeRoot}}
64
64
  {{/if}}
65
65
  mago-lint-continue-on-error: false
66
+ {{#if enable_acf_pro}}
67
+ # sem isto o load de credenciais ACF do quality.yml é pulado e o
68
+ # composer morre em 401 no connect (pego no piloto hekivolab)
69
+ enable-acf-pro: true
70
+ {{/if}}
66
71
  secrets:
67
72
  # org-level Connect (ACF no quality) — deploys usam SA-mode
68
73
  OP_CONNECT_TOKEN: $\{{ secrets.OP_CONNECT_TOKEN }}
69
74
  {{#if enable_acf_pro}}
70
- ACF_CONNECT_USERNAME: $\{{ secrets.ACF_CONNECT_USERNAME }}
71
- ACF_CONNECT_PASSWORD: $\{{ secrets.ACF_CONNECT_PASSWORD }}
75
+ # valor = REF op:// literal — o load interno do quality.yml resolve via
76
+ # Connect org-level (o repo não tem secrets ACF próprios; pego no piloto)
77
+ ACF_CONNECT_USERNAME: op://Hekivo-Internal/hekivo-acf-connect/username
78
+ ACF_CONNECT_PASSWORD: op://Hekivo-Internal/hekivo-acf-connect/password
72
79
  {{/if}}
73
80
 
74
81
  {{#if ci.deploy.docker}}
@@ -240,6 +247,9 @@ jobs:
240
247
  with:
241
248
  ssh-target: $\{{ env.SSH_HOST }}
242
249
  remote-root: $\{{ env.SSH_REMOTE_PATH }}
250
+ # .env goes ABOVE the web root (wp-config.php reads it from there): the deploy path is the
251
+ # document root, and anything inside it is public unless a WAF/vhost rule happens to block it.
252
+ env-location: parent
243
253
  {{#if enable_acf_pro}}
244
254
  plugin-slug: advanced-custom-fields-pro
245
255
  {{/if}}
@@ -253,6 +263,17 @@ jobs:
253
263
  zone-id: $\{{ env.CLOUDFLARE_PURGE_ZONE_ID }}
254
264
  api-token: $\{{ env.CLOUDFLARE_PURGE_TOKEN }}
255
265
 
266
+ - name: Check public exposure
267
+ # Fails the deploy if .env, CLAUDE.md, composer.lock... answer 200. Set the STAGING_URL variable
268
+ # (Settings > Environments > staging) to the site's public URL; without it the check is skipped.
269
+ if: vars.STAGING_URL != ''
270
+ uses: hekivo/gha-workflows/actions/check-exposure@v1
271
+ with:
272
+ site-url: $\{{ vars.STAGING_URL }}
273
+ {{#if ci.build.sage}}
274
+ theme-slug: {{projectName}}
275
+ {{/if}}
276
+
256
277
  # ── Deploy Production ─────────────────────────────────────────────────────────
257
278
  deploy-production:
258
279
  needs: quality
@@ -355,6 +376,9 @@ jobs:
355
376
  ssh-target: $\{{ env.SSH_USER }}@$\{{ env.SSH_HOST }}
356
377
  ssh-cmd: ssh -p $\{{ env.SSH_PORT || '22' }}
357
378
  remote-root: $\{{ env.SSH_REMOTE_PATH }}
379
+ # .env goes ABOVE the web root (wp-config.php reads it from there): the deploy path is the
380
+ # document root, and anything inside it is public unless a WAF/vhost rule happens to block it.
381
+ env-location: parent
358
382
  {{#if enable_acf_pro}}
359
383
  plugin-slug: advanced-custom-fields-pro
360
384
  {{/if}}
@@ -367,4 +391,15 @@ jobs:
367
391
  with:
368
392
  zone-id: $\{{ env.CLOUDFLARE_PURGE_ZONE_ID }}
369
393
  api-token: $\{{ env.CLOUDFLARE_PURGE_TOKEN }}
394
+
395
+ - name: Check public exposure
396
+ # Fails the deploy if .env, CLAUDE.md, composer.lock... answer 200. Set the PRODUCTION_URL variable
397
+ # (Settings > Environments > production) to the site's public URL; without it the check is skipped.
398
+ if: vars.PRODUCTION_URL != ''
399
+ uses: hekivo/gha-workflows/actions/check-exposure@v1
400
+ with:
401
+ site-url: $\{{ vars.PRODUCTION_URL }}
402
+ {{#if ci.build.sage}}
403
+ theme-slug: {{projectName}}
404
+ {{/if}}
370
405
  {{/if}}
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": ["github>hekivo/hekivo-mgmt//renovate-preset.json"]
4
+ }
@@ -5,19 +5,19 @@
5
5
  * placeholders inside the generated docs for the team to fill in.
6
6
  */
7
7
  function deriveDocContext(context) {
8
- const isGitHub = context.gitProvider === 'github';
9
- const isGitLab = context.gitProvider === 'gitlab';
10
- const isBitbucket = context.gitProvider === 'bitbucket';
8
+ const isGitHub = context.gitProvider === "github";
9
+ const isGitLab = context.gitProvider === "gitlab";
10
+ const isBitbucket = context.gitProvider === "bitbucket";
11
11
 
12
12
  // Pull request terminology varies by provider; the docs reference it
13
13
  // dozens of times so a single derived string keeps the templates clean.
14
- const prTerm = isGitLab ? 'Merge Request (MR)' : 'Pull Request (PR)';
15
- const prTermShort = isGitLab ? 'MR' : 'PR';
14
+ const prTerm = isGitLab ? "Merge Request (MR)" : "Pull Request (PR)";
15
+ const prTermShort = isGitLab ? "MR" : "PR";
16
16
  const ciSystem = isGitLab
17
- ? 'GitLab CI/CD'
17
+ ? "GitLab CI/CD"
18
18
  : isBitbucket
19
- ? 'Bitbucket Pipelines'
20
- : 'GitHub Actions';
19
+ ? "Bitbucket Pipelines"
20
+ : "GitHub Actions";
21
21
 
22
22
  return {
23
23
  ...context,
@@ -35,17 +35,17 @@ export async function setupModule(context, generator) {
35
35
 
36
36
  // README.md lands at the docs/ entry point (not the project root README,
37
37
  // which is generated by the kit core).
38
- await generator.generateFile('README.md', docContext, 'docs', 'docs/README.md');
38
+ await generator.generateFile("README.md", docContext, "docs", "docs/README.md");
39
39
 
40
40
  const docFiles = [
41
- 'Arquitetura.md',
42
- 'Deploy-Pipeline.md',
43
- 'Desenvolvimento.md',
44
- 'Getting-Started.md',
45
- 'Infraestrutura.md',
46
- 'Monitoramento.md',
47
- 'Sync-the-Production-DB-with-the-Staging-DB.md',
48
- 'Troubleshooting.md',
41
+ "Arquitetura.md",
42
+ "Deploy-Pipeline.md",
43
+ "Development.md",
44
+ "Getting-Started.md",
45
+ "Infraestrutura.md",
46
+ "Monitoramento.md",
47
+ "Sync-the-Production-DB-with-the-Staging-DB.md",
48
+ "Troubleshooting.md",
49
49
  ];
50
50
 
51
51
  // Bug fix: the previous implementation passed `file` as the 4th arg
@@ -53,6 +53,6 @@ export async function setupModule(context, generator) {
53
53
  // inside docs/. Removing that arg restores the template path as the
54
54
  // output path (docs/${file}).
55
55
  for (const file of docFiles) {
56
- await generator.generateFile(`docs/${file}`, docContext, 'docs');
56
+ await generator.generateFile(`docs/${file}`, docContext, "docs");
57
57
  }
58
58
  }
@@ -9,7 +9,7 @@ monitoring tools) as your infrastructure decisions get made.
9
9
  | Document | Purpose |
10
10
  | --- | --- |
11
11
  | [Getting-Started](./Getting-Started.md) | Local environment setup |
12
- | [Desenvolvimento](./Desenvolvimento.md) | Workflow, branching, commit hygiene |
12
+ | [Development](./Development.md) | Workflow, branching, commit hygiene |
13
13
  | [Arquitetura](./Arquitetura.md) | High-level technical architecture |
14
14
  | [Infraestrutura](./Infraestrutura.md) | Cloud / network / runtime topology |
15
15
  | [Deploy-Pipeline](./Deploy-Pipeline.md) | CI/CD flow and environments |
@@ -13,7 +13,7 @@ High-level technical architecture of **{{projectTitle}}**.
13
13
  graph TB
14
14
  subgraph "Developer"
15
15
  DEV[Engineers]
16
- LOCAL[{{projectDomain}}<br/>Lando + Docker]
16
+ LOCAL[{{projectDomain}}<br/>{{#if enable_kivo_wp}}kivo-wp Docker Compose{{else}}Lando + Docker{{/if}}]
17
17
  end
18
18
 
19
19
  subgraph "CI / CD"
@@ -54,7 +54,7 @@ graph TB
54
54
 
55
55
  | Component | Technology | Notes |
56
56
  | --- | --- | --- |
57
- | Database | `{{ "{{TODO: MySQL / MariaDB / managed service}}" }}` | Local dev uses MariaDB via Lando |
57
+ | Database | `{{ "{{TODO: MySQL / MariaDB / managed service}}" }}` | Local dev uses {{#if enable_kivo_wp}}MySQL 8.4 in the kivo-wp `db` service{{else}}MariaDB via Lando{{/if}} |
58
58
  | Object storage | `{{ "{{TODO: S3 / GCS / Azure Blob / NFS}}" }}` | For uploads, backups |
59
59
  | Cache | `{{ "{{TODO: Redis / Memcached / none}}" }}` | Object cache, sessions |
60
60
 
@@ -59,7 +59,27 @@ graph LR
59
59
  - *Docker push + remote pull*: build, push to `{{ "{{TODO: registry}}" }}`, SSH to remote, `docker compose pull && docker compose up -d`.
60
60
  - *Kubernetes*: `kubectl apply -f k8s/<env>/` (or `helm upgrade --install`).
61
61
  - *Cloud-managed (ECS / Cloud Run / App Runner)*: trigger service update with new image tag.
62
- - *SSH rsync*: `rsync -av --delete ./ user@host:/var/www/{{projectName}}/`.
62
+ - *SSH rsync*: sync an **allow list** (`index.php`, `wp-config.php`, `wp-cli.yml`, `vendor/`, `wp/`, `content/`), never `./`. See [Keep files out of the web root](#keep-files-out-of-the-web-root).
63
+
64
+ ## Keep files out of the web root
65
+
66
+ On a VPS/CloudPanel layout the deploy path **is** the document root: nginx serves whatever sits in it. Two
67
+ projects leaked this way (`.env` publicly readable on a production host; `CLAUDE.md`, `AGENTS.md`, `composer.lock`
68
+ and `vendor/composer/installed.json` on a staging host). The rules below are built into the generated project:
69
+
70
+ 1. **`.env` lives one level above the web root** (`<remote-root>/../.env`, mode 600). `wp-config.php` reads it
71
+ from there and falls back to the root when there is no file in the parent ({{#if enable_kivo_wp}}the local kivo-wp environment{{else}}Lando{{/if}}). The generated `ci.yml` passes
72
+ `env-location: parent` to `wp-post-deploy`.
73
+ 2. **Sync an allow list, not the repository.** `deploy-rsync` sends only `wp/`, `vendor/`, `content/*`, `index.php`,
74
+ `wp-config.php`. Anything else at the root (`CLAUDE.md`, `.mcp.json`, `.claude/`, `composer.*`, lint configs,
75
+ `docs/`, `tests/`) is development material. An exclude list fails silently on the first new file; an allow list does not.
76
+ 3. **Check from the outside.** `scripts/check-exposure.sh <url> [theme]` (and the `check-exposure` step in `ci.yml`,
77
+ which needs the `STAGING_URL` / `PRODUCTION_URL` environment variable) fails the deploy if a secret or
78
+ development file answers 200. Run it from an IP **outside** any WAF bypass to see what the public sees; from a
79
+ bypassed IP (your own, a CI runner on an allow list) it shows the origin, the stricter reading.
80
+ 4. **Defence in depth** (a file that slips through still cannot leave the server): deny dotfiles and `vendor/`,
81
+ `composer.*`, `package*.json`, `*.blade.php` in the vhost, and block them with a WAF rule. After deleting a file
82
+ from the origin, purge its URL on the CDN: a cached copy keeps being served.
63
83
 
64
84
  ## Secrets
65
85
 
@@ -1,7 +1,76 @@
1
- # Desenvolvimento
1
+ # Development
2
2
 
3
3
  Workflow and conventions for working on **{{projectTitle}}**.
4
4
 
5
+ {{#if enable_kivo_wp}}
6
+ ## Local environment (kivo-wp)
7
+
8
+ The project runs in a Docker Compose stack named `kivo-wp-{{projectName}}` (services `app`, `db`,
9
+ `cache`, `proxy`, `node`, `mail`). Every tool runs inside it through the scripts in `bin/`; nothing
10
+ needs PHP, Composer or Node.js on your machine.
11
+
12
+ ```bash
13
+ bin/setup # first run and any time after: build, start, install, seed (idempotent)
14
+ bin/up # start the stack
15
+ bin/down # stop it (bin/down --volumes also deletes the database; it asks first)
16
+ bin/info # URLs and service state
17
+ bin/logs # follow the logs
18
+ bin/wp <command> # WP-CLI (bin/wp acorn <command> for Acorn)
19
+ bin/composer <args> # Composer
20
+ bin/npm <args> # npm (bin/node for Node.js)
21
+ bin/build # build the theme assets
22
+ bin/dev # Vite dev server with HMR
23
+ bin/flush # flush WordPress, Acorn and object caches
24
+ bin/test # PHP tests
25
+ bin/e2e # Playwright tests
26
+ bin/xdebug on|off # toggle Xdebug without a rebuild
27
+ bin/shell [service] # shell in a service
28
+ ```
29
+
30
+ ### Ports and certificates
31
+
32
+ The site is served by Caddy at **https://{{projectName}}.localhost** with a local certificate
33
+ authority. `HTTPS_PORT` (default 443) and `HTTP_PORT` (default 80) in `.env` set the host ports;
34
+ when one is busy, `bin/setup` picks a free port and writes it to `.env` together with
35
+ `WORDPRESS_SITE_URL` (for example `https://{{projectName}}.localhost:8443`), then rewrites stored URLs
36
+ with `bin/wp search-replace`. Run `bin/trust-cert` once to export the CA and print the command that
37
+ trusts it on Linux, macOS or Windows (WSL).
38
+
39
+ ### Licensed packages
40
+
41
+ {{#if enable_acf_pro}}
42
+ ACF Pro is installed from `connect.advancedcustomfields.com`. Credentials never live in the
43
+ repository: `auth.json.tpl` holds 1Password references and `bin/setup` renders `auth.json` (mode 600,
44
+ gitignored) with `op inject -i auth.json.tpl -o auth.json`. Install the 1Password CLI (`op`) and sign
45
+ in before the first `bin/setup`.
46
+ {{else}}
47
+ No licensed Composer packages are configured. If one is added, keep its credentials as 1Password
48
+ references in `auth.json.tpl` and let `bin/setup` render `auth.json` with `op inject`.
49
+ {{/if}}
50
+
51
+ ### Data
52
+
53
+ `bin/setup` seeds an empty database with synthetic fixtures from `fixtures/` (users, posts, pages,
54
+ terms, a menu and options; every email is on `example.test`). `bin/seed` reseeds them and
55
+ `bin/seed --reset` empties the database first. Fixtures are the only data allowed in CI, Codespaces
56
+ and cloud agent sessions.
57
+
58
+ `bin/db-import <dump.sql[.gz]>` loads a sanitized snapshot. It is a **human-only, local** command: it
59
+ refuses to run when `CI`, `CODESPACES` or `CLAUDE_CODE_REMOTE` is set, and agents must never run it.
60
+ Sanitizing the snapshot (for example `wp db export` without sensitive tables, then an anonymizing
61
+ `wp search-replace`) is the responsibility of whoever produces it.
62
+ {{else}}
63
+ ## Local environment (Lando, deprecated)
64
+
65
+ Lando remains available for the 6.x line of wp-kit and is removed in 7.0.0. Common commands:
66
+ `lando start`, `lando wp <command>`, `lando composer <args>`, `lando npm <args>`, `lando flush`.
67
+ {{#if enable_acf_pro}}
68
+
69
+ ACF Pro credentials come from 1Password: render `auth.json` once with
70
+ `op inject -i auth.json.tpl -o auth.json` and keep it out of version control.
71
+ {{/if}}
72
+ {{/if}}
73
+
5
74
  ## Git workflow
6
75
 
7
76
  This project follows a **GitFlow-derived workflow** with three long-lived
@@ -96,6 +165,14 @@ chore(deps): bump roots/acorn to 6.2
96
165
 
97
166
  ## Lint and formatting
98
167
 
168
+ {{#if enable_kivo_wp}}
169
+ ```bash
170
+ bin/npm exec -- oxlint . # JavaScript lint
171
+ bin/npm exec -- oxfmt --write . # Format JS, JSON, YAML and Markdown
172
+ bin/mago lint # PHP lint
173
+ bin/mago format # PHP format
174
+ ```
175
+ {{else}}
99
176
  ```bash
100
177
  npm run lint # ESLint + Stylelint
101
178
  npm run lint:fix # Auto-fix where possible
@@ -103,6 +180,7 @@ npm run format # Prettier
103
180
  {{#if useSage}}composer lint --working-dir=content/themes/{{projectName}} # Pint
104
181
  composer lint:fix --working-dir=content/themes/{{projectName}}{{/if}}
105
182
  ```
183
+ {{/if}}
106
184
 
107
185
  Husky runs lint-staged on every commit so only changed files are
108
186
  checked; CI re-runs the full sweep.
@@ -111,7 +189,7 @@ checked; CI re-runs the full sweep.
111
189
 
112
190
  - **PHP**: `{{ "{{TODO: Pest suite location and how to invoke it}}" }}`
113
191
  - **E2E**: Playwright specs under `tests/e2e/`. Run locally with
114
- `npm run test:e2e`.
192
+ {{#if enable_kivo_wp}}`bin/e2e`{{else}}`npm run test:e2e`{{/if}}.
115
193
  - **Visual regression**: `{{ "{{TODO: define if/how visual regression is captured}}" }}`
116
194
 
117
195
  ## Releases