@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
@@ -2,11 +2,79 @@
2
2
 
3
3
  Local development setup for **{{projectTitle}}**.
4
4
 
5
+ {{#if enable_kivo_wp}}
5
6
  ## Prerequisites
6
7
 
7
8
  | Tool | Version | Purpose |
8
9
  | --- | --- | --- |
9
- | [Lando](https://lando.dev/) | 3.0+ | Local environment orchestration |
10
+ | [Docker](https://docs.docker.com/get-started/get-docker/) | Engine 24+ with Compose v2 | Runs the kivo-wp stack |
11
+ | [Git](https://git-scm.com/) | any | Version control |
12
+ {{#if enable_acf_pro}}
13
+ | [1Password CLI](https://developer.1password.com/docs/cli/get-started/) | 2.x | Renders `auth.json` for ACF Pro |
14
+ {{/if}}
15
+
16
+ PHP, Composer and Node.js run inside the containers; you do not need them on your machine.
17
+
18
+ ## Clone and bootstrap
19
+
20
+ ```bash
21
+ git clone {{repositoryHttpsUrl}}
22
+ cd {{projectName}}
23
+ bin/setup
24
+ ```
25
+
26
+ `bin/setup` is idempotent and is the only command you need: it creates `.env` from `.env.example`
27
+ when missing, picks free ports, {{#if enable_acf_pro}}renders `auth.json` from 1Password with
28
+ `op inject` (sign in with `op signin` first), {{/if}}builds and starts the stack, installs Composer
29
+ and npm dependencies, builds the theme, installs WordPress ({{wpCoreVersion}}), seeds synthetic
30
+ fixtures into an empty database and prints the URLs and the local admin login. Flags: `--ci`,
31
+ `--quick`, `--fresh` (`bin/setup --help`).
32
+
33
+ Once it finishes, the site is at **https://{{projectName}}.localhost** (with the port from
34
+ `HTTPS_PORT` when it is not 443). Run `bin/trust-cert` once and follow the printed command so your
35
+ browser trusts the local certificate.
36
+
37
+ ## Database
38
+
39
+ The database starts with synthetic fixtures (`bin/seed`, `bin/seed --reset`). To work against a
40
+ sanitized snapshot on your own machine:
41
+
42
+ ```bash
43
+ bin/db-import path/to/sanitized-dump.sql.gz
44
+ bin/wp search-replace 'https://{{projectStagingDomain}}' "$(bin/wp option get home)" --all-tables
45
+ ```
46
+
47
+ `bin/db-import` is a human-only, local command: it refuses to run when `CI`, `CODESPACES` or
48
+ `CLAUDE_CODE_REMOTE` is set, and snapshots never go to CI, Codespaces or cloud agent sessions.
49
+
50
+ {{#if useSage}}
51
+ ## Theme build
52
+
53
+ The Sage theme lives under `content/themes/{{projectName}}`. Vite drives the asset pipeline:
54
+
55
+ ```bash
56
+ bin/dev # HMR dev server through https://vite.{{projectName}}.localhost
57
+ bin/build # Production build
58
+ ```
59
+ {{/if}}
60
+
61
+ ## Common commands
62
+
63
+ ```bash
64
+ bin/up # Start the stack
65
+ bin/down # Stop it
66
+ bin/info # URLs and service state
67
+ bin/logs # Follow container logs
68
+ bin/wp <command> # WP-CLI
69
+ bin/shell # Shell in the app service
70
+ bin/down --volumes # Delete the stack's data (asks first)
71
+ ```
72
+ {{else}}
73
+ ## Prerequisites
74
+
75
+ | Tool | Version | Purpose |
76
+ | --- | --- | --- |
77
+ | [Lando](https://lando.dev/) | 3.0+ | Local environment orchestration (deprecated; removed in wp-kit 7.0.0) |
10
78
  | [Docker](https://docker.com/) | 20.0+ | Container runtime backing Lando |
11
79
  | [Git](https://git-scm.com/) | any | Version control |
12
80
  | [Node.js](https://nodejs.org/) | {{nodeVersion}}+ | Build pipeline (Vite, lint) |
@@ -17,6 +85,9 @@ Local development setup for **{{projectTitle}}**.
17
85
  ```bash
18
86
  git clone {{repositoryHttpsUrl}}
19
87
  cd {{projectName}}
88
+ {{#if enable_acf_pro}}
89
+ op inject -i auth.json.tpl -o auth.json # ACF Pro credentials from 1Password
90
+ {{/if}}
20
91
  lando start
21
92
  ```
22
93
 
@@ -63,6 +134,7 @@ lando wp <command> # Run WP-CLI against the Lando WordPress
63
134
  lando ssh # Shell into the appserver
64
135
  lando destroy # Wipe containers (data is preserved on disk)
65
136
  ```
137
+ {{/if}}
66
138
 
67
139
  ## Editor setup
68
140
 
@@ -73,11 +145,10 @@ open.
73
145
 
74
146
  ## What to read next
75
147
 
76
- - [Desenvolvimento](./Desenvolvimento.md) — git workflow and {{prTermShort}} hygiene
148
+ - [Development](./Development.md) — local environment, git workflow and {{prTermShort}} hygiene
77
149
  - [Arquitetura](./Arquitetura.md) — how the pieces fit together
78
150
 
79
151
  ## Troubleshooting
80
152
 
81
153
  If anything goes wrong during the first boot, check
82
- [Troubleshooting](./Troubleshooting.md) — common Lando/Docker issues
83
- are listed there.
154
+ [Troubleshooting](./Troubleshooting.md).
@@ -62,7 +62,7 @@ In production behind edge auth, provision **both** parts:
62
62
  prefix, so this defines `DISABLE_WP_CRON`. It must be `WORDPRESS_DISABLE_WP_CRON` — not
63
63
  `WORDPRESS_DISABLE_CRON`, which would define `DISABLE_CRON` and be ignored by WordPress.
64
64
 
65
- Do not enable this in the local `.env`: under Lando the loopback works and is convenient.
65
+ Do not enable this in the local `.env`: under {{#if enable_kivo_wp}}kivo-wp{{else}}Lando{{/if}} the loopback works and is convenient{{#if enable_kivo_wp}} (bin/setup sets it only in Codespaces){{/if}}.
66
66
  See [Troubleshooting](./Troubleshooting.md) for the symptom and diagnosis.
67
67
 
68
68
  ## Secrets and IAM
@@ -18,6 +18,22 @@ Each entry follows the same shape:
18
18
 
19
19
  ---
20
20
 
21
+ {{#if enable_kivo_wp}}
22
+ ### `bin/setup` reports "ports are not available"
23
+
24
+ **Symptom**: the stack does not start and Docker reports that a host port is not available.
25
+ **Likely cause**: another local stack, a system service or (on WSL) a Windows service holds the port
26
+ set by `HTTPS_PORT` or `HTTP_PORT` in `.env`.
27
+ **Fix**:
28
+
29
+ 1. Run `bin/setup` again: it moves busy ports to free ones and updates `WORDPRESS_SITE_URL`.
30
+ 2. To choose the ports yourself, set `HTTPS_PORT` and `HTTP_PORT` in `.env` and run `bin/setup`.
31
+ 3. `sudo lsof -i :443` identifies a process holding a port on Linux and macOS.
32
+
33
+ **Why this is the fix**: Caddy publishes the host ports from `.env`; `bin/setup` keeps the site URL in
34
+ step with them and rewrites stored URLs.
35
+
36
+ {{else}}
21
37
  ### `lando start` fails with "port already in use"
22
38
 
23
39
  **Symptom**: Lando fails to start with `Error starting the network: ports are not available`.
@@ -31,6 +47,7 @@ Each entry follows the same shape:
31
47
 
32
48
  **Why this is the fix**: Lando binds host ports; conflicts surface as start failures, not run failures.
33
49
 
50
+ {{/if}}
34
51
  ---
35
52
 
36
53
  ### Composer install hangs or 404s on a wpackagist plugin
@@ -64,7 +81,7 @@ Each entry follows the same shape:
64
81
 
65
82
  ### Scheduled tasks never run / a plugin screen stays empty (behind edge auth)
66
83
 
67
- **Symptom**: A plugin admin screen that loads data via a background refresh never populates (e.g. an items list spins or returns empty forever). More generally: any `wp_schedule_event` / WP-Cron job silently never fires in production, while the same code works under Lando.
84
+ **Symptom**: A plugin admin screen that loads data via a background refresh never populates (e.g. an items list spins or returns empty forever). More generally: any `wp_schedule_event` / WP-Cron job silently never fires in production, while the same code works under {{#if enable_kivo_wp}}kivo-wp{{else}}Lando{{/if}}.
68
85
  **Likely cause**: The site is behind **Cloudflare Access** (or any edge auth fronting the whole domain). Default WP-Cron fires via a loopback HTTP request to `/wp/wp-cron.php`, which the edge `302`-redirects to its login — so `wp-cron.php` never executes and no scheduled event runs. The browser's `admin-ajax` still works (it carries the auth cookie), so the page loads but the background job never completes.
69
86
  **Fix**:
70
87
 
@@ -0,0 +1,3 @@
1
+ # kivo-wp: commitlint runs in the node service through bin/npm.
2
+ echo "🔍 Validating commit message..."
3
+ bin/npm exec -- commitlint --edit "$1"
@@ -0,0 +1,25 @@
1
+ # kivo-wp: every tool runs in the Compose stack through bin/* (start it with bin/up).
2
+ echo "🔍 Running pre-commit checks..."
3
+
4
+ if [ -z "$(git diff --cached --name-only)" ]; then
5
+ echo "ℹ️ No staged files, skipping pre-commit checks"
6
+ exit 0
7
+ fi
8
+
9
+ if [ -f ".lintstagedrc.json" ]; then
10
+ echo "📝 Running lint-staged..."
11
+ bin/npm exec -- lint-staged
12
+ fi
13
+
14
+ # PHP formatting: the node service has no PHP, so staged PHP files are formatted with
15
+ # bin/mago in the app service and staged again.
16
+ php_files="$(git diff --cached --name-only --diff-filter=ACMR -- '*.php')"
17
+ if [ -n "$php_files" ] && [ -f vendor/bin/mago ]; then
18
+ echo "🐘 Formatting staged PHP files with Mago..."
19
+ echo "$php_files" | while IFS= read -r file; do
20
+ bin/mago format --no-progress "$file"
21
+ git add -- "$file"
22
+ done
23
+ fi
24
+
25
+ echo "✅ Pre-commit checks completed!"
@@ -12,13 +12,9 @@ if [ -z "$(git diff --cached --name-only)" ]; then
12
12
  exit 0
13
13
  fi
14
14
 
15
+ # lint-staged runs where git runs (the host); its PHP entries reach the
16
+ # environment through their own commands.
15
17
  echo "📝 Running lint-staged..."
16
- if command -v lando >/dev/null 2>&1 && lando info >/dev/null 2>&1; then
17
- echo "🐳 Using Lando environment..."
18
- lando lint-staged
19
- else
20
- echo "🏠 Using local environment..."
21
- npx lint-staged
22
- fi
18
+ npx --no lint-staged
23
19
 
24
20
  echo "✅ Pre-commit checks completed!"
@@ -1,23 +1,23 @@
1
- import path from 'path';
2
- import { execFileSync } from 'child_process';
1
+ import path from "path";
2
+ import { execFileSync } from "child_process";
3
3
 
4
- import fs from 'fs-extra';
4
+ import fs from "fs-extra";
5
5
 
6
- import { log, color } from '../../lib/utils/logger.js';
6
+ import { log, color } from "../../lib/utils/logger.js";
7
7
 
8
- function runGitCommand(args, cwd, stdio = 'ignore') {
9
- return execFileSync('git', args, { cwd, stdio });
8
+ function runGitCommand(args, cwd, stdio = "ignore") {
9
+ return execFileSync("git", args, { cwd, stdio });
10
10
  }
11
11
 
12
12
  export async function setupModule(context, generator) {
13
- const gitDir = path.join(generator.cwd, '.git');
13
+ const gitDir = path.join(generator.cwd, ".git");
14
14
 
15
15
  const gitProviderHandlers = {
16
16
  github: async () => {
17
- await generator.copyFile('.github/PULL_REQUEST_TEMPLATE.md', 'git');
17
+ await generator.copyFile(".github/PULL_REQUEST_TEMPLATE.md", "git");
18
18
  },
19
19
  gitlab: async () => {
20
- await generator.copyFile('.gitlab/merge_request_templates/default.md', 'git');
20
+ await generator.copyFile(".gitlab/merge_request_templates/default.md", "git");
21
21
  },
22
22
  bitbucket: async () => {
23
23
  // await generator.copyFile('.bitbucket/PULL_REQUEST_TEMPLATE.md', '.bitbucket/PULL_REQUEST_TEMPLATE.md', 'git');
@@ -28,71 +28,89 @@ export async function setupModule(context, generator) {
28
28
  };
29
29
 
30
30
  if (!(await fs.pathExists(gitDir))) {
31
- log(color.orange, '[git] Initializing Git repository');
32
- runGitCommand(['init'], generator.cwd);
33
- await generator.copyFile('.gitmessage', 'git');
34
-
35
- if (context.defaultBranch && context.defaultBranch !== 'main') {
36
- try {
37
- runGitCommand(['branch', '-M', context.defaultBranch], generator.cwd);
38
- log(color.green, `[git] Default branch set to: ${context.defaultBranch}`);
39
- } catch {
40
- log(color.yellow, '[git] Warning: Could not rename default branch');
41
- }
31
+ log(color.orange, "[git] Initializing Git repository");
32
+ const defaultBranch = context.defaultBranch || "main";
33
+ // Create the repository directly on the default branch so the initial
34
+ // commit never lands on the host's init.defaultBranch (often `master`).
35
+ try {
36
+ runGitCommand(["init", "-b", defaultBranch], generator.cwd);
37
+ } catch {
38
+ // git < 2.28 has no `-b`: init, then point the unborn HEAD at the branch.
39
+ runGitCommand(["init"], generator.cwd);
40
+ runGitCommand(["symbolic-ref", "HEAD", `refs/heads/${defaultBranch}`], generator.cwd);
42
41
  }
42
+ log(color.green, `[git] Default branch set to: ${defaultBranch}`);
43
+ await generator.copyFile(".gitmessage", "git");
43
44
 
44
45
  const gitConfigs = [
45
- ['core.autocrlf', 'input'],
46
- ['core.eol', 'lf'],
47
- ['core.filemode', 'false'],
48
- ['pull.rebase', 'false'],
49
- ['init.defaultBranch', context.defaultBranch || 'main'],
46
+ ["core.autocrlf", "input"],
47
+ ["core.eol", "lf"],
48
+ ["core.filemode", "false"],
49
+ ["pull.rebase", "false"],
50
+ ["init.defaultBranch", defaultBranch],
50
51
  ];
51
52
 
52
53
  for (const [key, value] of gitConfigs) {
53
54
  try {
54
- runGitCommand(['config', key, value], generator.cwd);
55
+ runGitCommand(["config", key, value], generator.cwd);
55
56
  } catch {
56
57
  log(color.yellow, `[git] Warning: Could not set ${key}`);
57
58
  }
58
59
  }
59
60
 
60
61
  try {
61
- runGitCommand(['config', 'user.name', context.author], generator.cwd);
62
+ runGitCommand(["config", "user.name", context.author], generator.cwd);
62
63
  } catch {
63
64
  log(color.yellow, `[git] Warning: Could not set user.name`);
64
65
  }
65
66
 
66
67
  try {
67
- runGitCommand(['config', 'user.email', context.authorEmail], generator.cwd);
68
+ runGitCommand(["config", "user.email", context.authorEmail], generator.cwd);
68
69
  } catch {
69
70
  log(color.yellow, `[git] Warning: Could not set user.email`);
70
71
  }
71
72
 
72
73
  try {
73
74
  runGitCommand(
74
- ['config', 'commit.template', path.join(generator.cwd, '.gitmessage')],
75
- generator.cwd
75
+ ["config", "commit.template", path.join(generator.cwd, ".gitmessage")],
76
+ generator.cwd,
76
77
  );
77
78
  } catch {
78
79
  log(color.yellow, `[git] Warning: Could not set commit.template`);
79
80
  }
80
81
  }
81
82
 
82
- log(color.blue, '[git] Installing Git configuration');
83
-
84
- await generator.copyFile('.commitlintrc.json', 'git');
85
- await generator.copyFile('.lintstagedrc.json', 'git');
86
- await generator.copyFile('.husky/commit-msg', 'git');
87
- await generator.copyFile('.husky/pre-commit', 'git');
88
-
89
- await generator.copyFile('.vscode/conventional-commits.code-snippets', 'git');
90
- await generator.copyFile('.vscode/copilot.json', 'git');
91
- await generator.copyFile('.vscode/commit-instructions.md', 'git');
92
- await generator.copyFile('docs/CONVENTIONAL-COMMITS.md', 'git');
83
+ log(color.blue, "[git] Installing Git configuration");
84
+
85
+ await generator.copyFile(".commitlintrc.json", "git");
86
+ await generator.copyFile(".lintstagedrc.json", "git");
87
+ // kivo-wp hooks run every tool through bin/*; the Lando hooks stay for the deprecated choice.
88
+ const hooksDir = context.enable_kivo_wp ? ".husky/kivo-wp" : ".husky";
89
+ await generator.copyFile(`${hooksDir}/commit-msg`, "git", ".husky/commit-msg");
90
+ await generator.copyFile(`${hooksDir}/pre-commit`, "git", ".husky/pre-commit");
91
+
92
+ await generator.copyFile(".vscode/conventional-commits.code-snippets", "git");
93
+ await generator.copyFile(".vscode/copilot.json", "git");
94
+ await generator.copyFile(".vscode/commit-instructions.md", "git");
95
+ await generator.copyFile("docs/CONVENTIONAL-COMMITS.md", "git");
96
+ if (context.enable_kivo_wp) {
97
+ // kivo-wp runs the commit tooling in the node service through bin/npm.
98
+ const doc = path.join(generator.cwd, "docs/CONVENTIONAL-COMMITS.md");
99
+ const text = (await fs.readFile(doc, "utf8"))
100
+ .replaceAll("lando git-cz", "bin/npm exec -- git-cz")
101
+ .replaceAll(
102
+ "lando commitlint-check",
103
+ "bin/npm exec -- commitlint --from HEAD~1 --to HEAD --verbose",
104
+ )
105
+ .replaceAll(
106
+ "lando conventional-changelog",
107
+ "bin/npm exec -- conventional-changelog -p angular -i CHANGELOG.md -s",
108
+ );
109
+ await fs.outputFile(doc, text);
110
+ }
93
111
 
94
- await fs.chmod(path.join(generator.cwd, '.husky/commit-msg'), 0o755);
95
- await fs.chmod(path.join(generator.cwd, '.husky/pre-commit'), 0o755);
112
+ await fs.chmod(path.join(generator.cwd, ".husky/commit-msg"), 0o755);
113
+ await fs.chmod(path.join(generator.cwd, ".husky/pre-commit"), 0o755);
96
114
 
97
115
  const handler = gitProviderHandlers[context.gitProvider];
98
116
  if (handler) {
@@ -101,38 +119,38 @@ export async function setupModule(context, generator) {
101
119
 
102
120
  // Registra hook para fazer o commit inicial após todo o setup
103
121
  generator.hooks.addAction(
104
- 'after_setup_complete',
122
+ "after_setup_complete",
105
123
  async (context, _generator) => {
106
- const projectGitDir = path.join(context.cwd, '.git');
124
+ const projectGitDir = path.join(context.cwd, ".git");
107
125
  if (!(await fs.pathExists(projectGitDir))) {
108
126
  return; // Repositório não foi inicializado neste setup
109
127
  }
110
128
 
111
129
  try {
112
- log(color.blue, '[git] Making initial commit...');
130
+ log(color.blue, "[git] Making initial commit...");
113
131
 
114
132
  // Adiciona todos os arquivos
115
- runGitCommand(['add', '.'], context.cwd);
133
+ runGitCommand(["add", "."], context.cwd);
116
134
 
117
135
  // Ignora assinatura e hooks neste commit automático para não depender do ambiente local.
118
136
  runGitCommand(
119
137
  [
120
- '-c',
121
- 'commit.gpgsign=false',
122
- 'commit',
123
- '--no-verify',
124
- '-m',
125
- 'chore: initial project setup',
138
+ "-c",
139
+ "commit.gpgsign=false",
140
+ "commit",
141
+ "--no-verify",
142
+ "-m",
143
+ "chore: initial project setup",
126
144
  ],
127
- context.cwd
145
+ context.cwd,
128
146
  );
129
147
 
130
- log(color.green, '[git] ✅ Initial commit created successfully');
148
+ log(color.green, "[git] ✅ Initial commit created successfully");
131
149
  } catch (error) {
132
- log(color.orange, '[git] Warning: Could not create initial commit');
150
+ log(color.orange, "[git] Warning: Could not create initial commit");
133
151
  log(color.yellow, `[git] Error: ${error.message}`);
134
152
  }
135
153
  },
136
- 10
154
+ 10,
137
155
  ); // Prioridade 10 (executa após outros hooks com prioridade menor)
138
156
  }
@@ -1,4 +1,9 @@
1
1
  tooling:
2
+ # Used by .husky/commit-msg; it lives here because this module installs the hook.
3
+ commitlint:
4
+ service: build
5
+ description: Validate commit message format
6
+ cmd: npx --no commitlint --edit
2
7
  git-cz:
3
8
  service: appserver
4
9
  description: Make commit using Conventional Commits
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "scripts": {
3
3
  "prepare": "husky",
4
- "commit": "lando git-cz"
4
+ "commit": "{{#if enable_kivo_wp}}bin/npm exec -- git-cz{{else}}lando git-cz{{/if}}"
5
5
  },
6
6
  "devDependencies": {
7
7
  "@commitlint/cli": "^19.7.1",
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "name": "Primary",
4
+ "location": "primary_navigation",
5
+ "items": [
6
+ { "page": "home", "title": "Home" },
7
+ { "page": "about", "title": "About" },
8
+ { "page": "contact", "title": "Contact" }
9
+ ]
10
+ }
11
+ ]
@@ -0,0 +1,10 @@
1
+ {
2
+ "blogname": "Local fixture site",
3
+ "blogdescription": "Synthetic content for development",
4
+ "admin_email": "admin@example.test",
5
+ "timezone_string": "UTC",
6
+ "date_format": "Y-m-d",
7
+ "posts_per_page": 10,
8
+ "show_on_front": "page",
9
+ "page_on_front": { "page": "home" }
10
+ }
@@ -0,0 +1,58 @@
1
+ [
2
+ {
3
+ "type": "page",
4
+ "slug": "home",
5
+ "title": "Home",
6
+ "content": "<!-- wp:paragraph --><p>Welcome to the local site. All content here is synthetic.</p><!-- /wp:paragraph -->",
7
+ "author": "editor",
8
+ "date": "2026-01-05 09:00:00"
9
+ },
10
+ {
11
+ "type": "page",
12
+ "slug": "about",
13
+ "title": "About",
14
+ "content": "<!-- wp:paragraph --><p>A fictional organization used for local development.</p><!-- /wp:paragraph -->",
15
+ "author": "editor",
16
+ "date": "2026-01-05 09:10:00"
17
+ },
18
+ {
19
+ "type": "page",
20
+ "slug": "contact",
21
+ "title": "Contact",
22
+ "content": "<!-- wp:paragraph --><p>Write to hello@example.test.</p><!-- /wp:paragraph -->",
23
+ "author": "editor",
24
+ "date": "2026-01-05 09:20:00"
25
+ },
26
+ {
27
+ "type": "post",
28
+ "slug": "first-fixture-post",
29
+ "title": "First fixture post",
30
+ "excerpt": "A short synthetic post.",
31
+ "content": "<!-- wp:paragraph --><p>This post exists to exercise templates, archives and search.</p><!-- /wp:paragraph -->",
32
+ "author": "author",
33
+ "date": "2026-01-10 10:00:00",
34
+ "categories": ["news"],
35
+ "tags": ["sample", "fixture"]
36
+ },
37
+ {
38
+ "type": "post",
39
+ "slug": "a-guide-to-the-local-stack",
40
+ "title": "A guide to the local stack",
41
+ "excerpt": "How the fixtures are organized.",
42
+ "content": "<!-- wp:heading --><h2>Fixtures</h2><!-- /wp:heading --><!-- wp:paragraph --><p>Every record carries a fixture marker so a reseed replaces it.</p><!-- /wp:paragraph -->",
43
+ "author": "author",
44
+ "date": "2026-01-12 10:00:00",
45
+ "categories": ["guides"],
46
+ "tags": ["fixture"]
47
+ },
48
+ {
49
+ "type": "post",
50
+ "slug": "draft-fixture-post",
51
+ "title": "Draft fixture post",
52
+ "status": "draft",
53
+ "content": "<!-- wp:paragraph --><p>An unpublished post.</p><!-- /wp:paragraph -->",
54
+ "author": "author",
55
+ "date": "2026-01-15 10:00:00",
56
+ "categories": ["news"]
57
+ }
58
+ ]