@codigodoleo/wp-kit 5.1.0 → 5.3.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.
@@ -7,8 +7,9 @@ import fs from "fs-extra";
7
7
  import { runPrompts } from "../prompts/index.js";
8
8
  import { Generator } from "../core/generator.js";
9
9
  import { log, color } from "../utils/logger.js";
10
+ import { toEnvExample } from "../utils/env-example.js";
10
11
  import { inferCiCapabilities } from "../core/infer-ci-capabilities.js";
11
- import { validateVersionCompatibility } from "../config/versions.js";
12
+ import { VERSION_REGISTRY, validateVersionCompatibility } from "../config/versions.js";
12
13
 
13
14
  const __filename = fileURLToPath(import.meta.url);
14
15
  const __dirname = path.dirname(__filename);
@@ -30,12 +31,12 @@ export const initCommand = new Command("init")
30
31
 
31
32
  // 🔧 Ajustes automáticos para Sage 11
32
33
  if (context.useSage && context.sageVersion === "11") {
33
- context.phpVersion = "8.4";
34
+ context.phpVersion = VERSION_REGISTRY.php.latest;
34
35
  context.nodeVersion = "24";
35
36
  context.wpCoreVersion = "7.0";
36
37
 
37
38
  log(color.orange, "🔧 Sage 11 selected — automatically adjusting versions:");
38
- log(color.orange, " → PHP: 8.4");
39
+ log(color.orange, ` → PHP: ${VERSION_REGISTRY.php.latest}`);
39
40
  log(color.orange, " → Node: 24");
40
41
  log(color.orange, " → WP Core: 7.0");
41
42
  }
@@ -79,6 +80,10 @@ export const initCommand = new Command("init")
79
80
  await generator.generateFile(".gitignore", context);
80
81
  await generator.generateFile("README.md", context);
81
82
  await generator.generateFile(".env", context);
83
+ // Keys-only companion that is safe to commit; the real file stays ignored.
84
+ const envFile = ".env";
85
+ const envContent = await fs.readFile(path.join(target, envFile), "utf8");
86
+ await fs.outputFile(path.join(target, `${envFile}.example`), toEnvExample(envContent));
82
87
  if (context.enable_acf_pro && context.acf_license_key) {
83
88
  await generator.generateFile("auth.json", context);
84
89
  } else if (context.enable_acf_pro) {
@@ -168,12 +173,13 @@ export const initCommand = new Command("init")
168
173
  }
169
174
  }
170
175
 
176
+ // CLAUDE.md must exist before the post-setup hooks run, so the initial
177
+ // commit made by the git module includes it.
178
+ await generator.generateFile("CLAUDE.md", context);
179
+
171
180
  // Executa hooks após todo o setup dos módulos
172
181
  log(color.blue, "🔗 Executing post-setup hooks...");
173
182
  generator.hooks.doAction("after_setup_complete", context, generator);
174
183
 
175
- // Gera CLAUDE.md com overview do projeto e referência ao AI Co-Pilot
176
- await generator.generateFile("CLAUDE.md", context);
177
-
178
184
  log(color.green, "✅ Project initialized with templates.");
179
185
  });
@@ -53,10 +53,11 @@ export const VERSION_REGISTRY = {
53
53
  * Only actively supported versions per php.net
54
54
  */
55
55
  php: {
56
- latest: "8.4",
57
- supported: ["8.4", "8.3", "8.2"],
58
- eol: ["8.0", "7.4", "7.3", "7.2"], // Deprecated - do not use
59
- description: "Supported PHP versions. PHP 7.4+ reached EOL on 2022-11-28",
56
+ latest: "8.5",
57
+ supported: ["8.5", "8.4", "8.3"],
58
+ eol: ["8.2", "8.1", "8.0", "7.4", "7.3", "7.2"], // Deprecated - do not use
59
+ description:
60
+ "Supported PHP versions (active support per php.net). 8.2 left active support on 2024-12-31.",
60
61
  // PHP version dates: https://www.php.net/supported-versions.php
61
62
  eolDates: {
62
63
  8.1: "2025-11-25",
@@ -3,6 +3,7 @@ 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
 
@@ -149,7 +150,7 @@ export async function runPrompts({ defaults = false } = {}) {
149
150
  message: "Repository URL:",
150
151
  default: defaultsGit.gitRepository,
151
152
  },
152
- // phpVersion and nodeVersion are locked to '8.4' / '24' — injected into context, not prompted
153
+ // phpVersion (VERSION_REGISTRY.php.latest) and nodeVersion ('24') are injected into context, not prompted
153
154
  {
154
155
  type: "list",
155
156
  name: "wpCoreVersion",
@@ -267,6 +268,11 @@ export async function runPrompts({ defaults = false } = {}) {
267
268
  defaultAnswers.gitProvider = envGitProvider;
268
269
  }
269
270
 
271
+ // WP_KIT_SSH_TRANSPORT: overrides ssh_transport (used for non-interactive E2E generation).
272
+ if (process.env.WP_KIT_SSH_TRANSPORT) {
273
+ defaultAnswers.ssh_transport = process.env.WP_KIT_SSH_TRANSPORT;
274
+ }
275
+
270
276
  const enabledModules = Object.keys(modulePromptDefs).filter(
271
277
  (mod) => defaultAnswers[`enable_${mod.replace(/-/g, "_")}`] === true,
272
278
  );
@@ -278,7 +284,7 @@ export async function runPrompts({ defaults = false } = {}) {
278
284
  return {
279
285
  ...defaultAnswers,
280
286
  ...derived,
281
- phpVersion: "8.4",
287
+ phpVersion: VERSION_REGISTRY.php.latest,
282
288
  nodeVersion: "24",
283
289
  enabledModules,
284
290
  projectDomain: `${defaultAnswers.projectName}.lndo.site`,
@@ -306,7 +312,7 @@ export async function runPrompts({ defaults = false } = {}) {
306
312
  return {
307
313
  ...answers,
308
314
  ...derived,
309
- phpVersion: "8.4",
315
+ phpVersion: VERSION_REGISTRY.php.latest,
310
316
  nodeVersion: "24",
311
317
  enabledModules,
312
318
  projectDomain: `${answers.projectName}.lndo.site`,
@@ -0,0 +1,16 @@
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
+ /**
5
+ * Turns dotenv content into a keys-only example: every assignment, including
6
+ * commented-out ones, keeps its key and loses its value; other comments and
7
+ * blank lines are preserved as-is.
8
+ * @param {string} content - Rendered dotenv content
9
+ * @returns {string} Content safe to commit
10
+ */
11
+ export function toEnvExample(content) {
12
+ return content
13
+ .split("\n")
14
+ .map((line) => line.replace(ASSIGNMENT, "$1="))
15
+ .join("\n");
16
+ }
@@ -9,6 +9,9 @@ export async function setupModule(context, generator) {
9
9
  log(color.blue, "[deploy] Gerando pipeline de CI baseado em context.ci");
10
10
 
11
11
  try {
12
+ await generator.generateFile("renovate.json", context, "deploy", "renovate.json");
13
+ log(color.green, "[deploy] renovate.json gerado (frota Hekivo).");
14
+
12
15
  if (context.gitProvider === "gitlab") {
13
16
  await generator.generateFile(".gitlab/gitlab-ci.yml", context, "deploy", ".gitlab-ci.yml");
14
17
  log(color.green, "[deploy] .gitlab-ci.yml gerado com sucesso.");
@@ -1,9 +1,10 @@
1
1
  # CI — {{projectName}}
2
2
  #
3
3
  # Quality gate and deploy pipeline using hekivo/gha-workflows shared actions.
4
- # Secrets are resolved via 1Password Connect (Connect server at vars.OP_CONNECT_HOST,
5
- # authenticated with secrets.OP_CONNECT_TOKEN). Update the op:// paths below to
6
- # match your project's vault items before first run.
4
+ # Deploy jobs resolve secrets via a 1Password Service Account (single repo
5
+ # secret: OP_SERVICE_ACCOUNT_TOKEN). The quality job keeps org-level Connect
6
+ # (org secret OP_CONNECT_TOKEN — contract of quality.yml@v1). Update the
7
+ # op:// paths below to match your project's vault items before first run.
7
8
 
8
9
  name: CI
9
10
 
@@ -37,7 +38,7 @@ permissions:
37
38
  {{/if}}
38
39
 
39
40
  concurrency:
40
- group: ci-${{'{{'}} github.ref {{'}}'}}
41
+ group: ci-$\{{ github.ref }}
41
42
  cancel-in-progress: true
42
43
 
43
44
  env:
@@ -56,17 +57,25 @@ jobs:
56
57
  quality:
57
58
  uses: hekivo/gha-workflows/.github/workflows/quality.yml@v1
58
59
  with:
59
- php-version: ${{'{{'}} env.PHP_VERSION {{'}}'}}
60
- node-version: ${{'{{'}} env.NODE_VERSION {{'}}'}}
60
+ php-version: "{{phpVersion}}"
61
+ node-version: "{{nodeVersion}}"
61
62
  {{#if ci.build.sage}}
62
- theme-path: ${{'{{'}} env.THEME_PATH {{'}}'}}
63
+ theme-path: {{ci.theme.paths.themeRoot}}
63
64
  {{/if}}
64
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}}
65
71
  secrets:
66
- OP_CONNECT_TOKEN: ${{'{{'}} secrets.OP_CONNECT_TOKEN {{'}}'}}
72
+ # org-level Connect (ACF no quality) — deploys usam SA-mode
73
+ OP_CONNECT_TOKEN: $\{{ secrets.OP_CONNECT_TOKEN }}
67
74
  {{#if enable_acf_pro}}
68
- ACF_CONNECT_USERNAME: ${{'{{'}} secrets.ACF_CONNECT_USERNAME {{'}}'}}
69
- 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
70
79
  {{/if}}
71
80
 
72
81
  {{#if ci.deploy.docker}}
@@ -75,7 +84,7 @@ jobs:
75
84
  needs: quality
76
85
  uses: hekivo/gha-workflows/.github/workflows/docker-build.yml@v1
77
86
  with:
78
- image-name: ${{'{{'}} github.repository {{'}}'}}
87
+ image-name: $\{{ github.repository }}
79
88
  platforms: linux/amd64
80
89
  permissions:
81
90
  packages: write
@@ -89,10 +98,10 @@ jobs:
89
98
  (github.event_name == 'workflow_dispatch' && inputs.deploy == true)
90
99
  uses: hekivo/gha-workflows/.github/workflows/docker-publish.yml@v1
91
100
  with:
92
- source-image: ${{'{{'}} needs.docker-build.outputs.image-ref {{'}}'}}
101
+ source-image: $\{{ needs.docker-build.outputs.image-ref }}
93
102
  registry-type: {{docker_registry}}
94
- image-name: ${{'{{'}} github.repository {{'}}'}}
95
- image-tag: ${{'{{'}} github.ref_name {{'}}'}}
103
+ image-name: $\{{ github.repository }}
104
+ image-tag: $\{{ github.ref_name }}
96
105
  {{#if ci.docker.registryEcr}}
97
106
  aws-region: us-east-1 # TODO: update region
98
107
  ecr-registry: "" # TODO: 123456789012.dkr.ecr.us-east-1.amazonaws.com
@@ -105,13 +114,13 @@ jobs:
105
114
  {{/if}}
106
115
  secrets:
107
116
  {{#if ci.docker.registryEcr}}
108
- AWS_ROLE_ARN: ${{'{{'}} secrets.AWS_ROLE_ARN {{'}}'}}
117
+ AWS_ROLE_ARN: $\{{ secrets.AWS_ROLE_ARN }}
109
118
  {{/if}}
110
119
  {{#if ci.docker.registryDockerHub}}
111
- DOCKERHUB_TOKEN: ${{'{{'}} secrets.DOCKERHUB_TOKEN {{'}}'}}
120
+ DOCKERHUB_TOKEN: $\{{ secrets.DOCKERHUB_TOKEN }}
112
121
  {{/if}}
113
122
  {{#if ci.docker.registryGitlab}}
114
- GITLAB_REGISTRY_TOKEN: ${{'{{'}} secrets.GITLAB_REGISTRY_TOKEN {{'}}'}}
123
+ GITLAB_REGISTRY_TOKEN: $\{{ secrets.GITLAB_REGISTRY_TOKEN }}
115
124
  {{/if}}
116
125
  permissions:
117
126
  packages: read
@@ -134,26 +143,25 @@ jobs:
134
143
  uses: actions/checkout@v4
135
144
 
136
145
  - name: Load secrets from 1Password
137
- uses: 1password/load-secrets-action@v2
146
+ uses: 1password/load-secrets-action@v4
138
147
  with:
139
148
  export-env: true
140
149
  env:
141
- OP_CONNECT_HOST: ${{'{{'}} vars.OP_CONNECT_HOST {{'}}'}}
142
- OP_CONNECT_TOKEN: ${{'{{'}} secrets.OP_CONNECT_TOKEN {{'}}'}}
150
+ OP_SERVICE_ACCOUNT_TOKEN: $\{{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
143
151
  {{#if enable_acf_pro}}
144
152
  # ACF Pro Composer auth — item shared across all projects in Hekivo-Internal
145
- ACF_CONNECT_USERNAME: op://Hekivo-Internal/{{projectName}}-acf-connect/username
146
- ACF_CONNECT_PASSWORD: op://Hekivo-Internal/{{projectName}}-acf-connect/password
153
+ ACF_CONNECT_USERNAME: op://Hekivo-Internal/hekivo-acf-connect/username
154
+ ACF_CONNECT_PASSWORD: op://Hekivo-Internal/hekivo-acf-connect/password
147
155
  {{/if}}
148
156
  # SSH transport credentials — update vault/item paths for this project
149
157
  SSH_HOST: op://Client-{{projectName}}/ssh-staging/hostname
150
158
  SSH_USER: op://Client-{{projectName}}/ssh-staging/username
151
159
  SSH_REMOTE_PATH: op://Client-{{projectName}}/ssh-staging/remote-path
152
- SSH_PRIVATE_KEY: op://Client-{{projectName}}/staging-server-ssh-key/private_key?ssh-format=openssh
160
+ SSH_PRIVATE_KEY: op://Client-{{projectName}}/staging-ssh-key/private_key?ssh-format=openssh
153
161
  {{#if ci.ssh.useCloudflare}}
154
- # Cloudflare Access Service Token for SSH tunnel (staging)
155
- TUNNEL_SERVICE_TOKEN_ID: op://Hekivo-Internal/{{projectName}}-cf-access-gha-staging/client-id
156
- TUNNEL_SERVICE_TOKEN_SECRET: op://Hekivo-Internal/{{projectName}}-cf-access-gha-staging/client-secret
162
+ # Cloudflare Access Service Token for SSH tunnel (staging) — shared item in Hekivo-Internal
163
+ TUNNEL_SERVICE_TOKEN_ID: op://Hekivo-Internal/prod-cf-access-gha-deploy-staging/client-id
164
+ TUNNEL_SERVICE_TOKEN_SECRET: op://Hekivo-Internal/prod-cf-access-gha-deploy-staging/client-secret
157
165
  {{/if}}
158
166
  # .env composition (3 layers: template + salts + DB)
159
167
  ENV_TEMPLATE: op://Client-{{projectName}}/staging-env-file/notesPlain
@@ -163,60 +171,60 @@ jobs:
163
171
  WORDPRESS_DB_PASSWORD: op://Client-{{projectName}}/staging-wp-database/password
164
172
  WORDPRESS_DB_HOST: op://Client-{{projectName}}/staging-wp-database/hostname
165
173
  WORDPRESS_DB_PORT: op://Client-{{projectName}}/staging-wp-database/port
166
- # Cloudflare cache purge
167
- CLOUDFLARE_PURGE_ZONE_ID: op://Hekivo-Internal/{{projectName}}-cloudflare-api/zone id
168
- CLOUDFLARE_PURGE_TOKEN: op://Hekivo-Internal/{{projectName}}-cloudflare-api/credential
174
+ # Cloudflare cache purge — shared item in Hekivo-Internal
175
+ CLOUDFLARE_PURGE_ZONE_ID: op://Hekivo-Internal/prod-cloudflare-api/zone id
176
+ CLOUDFLARE_PURGE_TOKEN: op://Hekivo-Internal/prod-cloudflare-api/credential
169
177
 
170
178
  - name: Setup WordPress (production deps)
171
179
  uses: hekivo/gha-workflows/actions/setup-wordpress@v1
172
180
  with:
173
- php-version: ${{'{{'}} env.PHP_VERSION {{'}}'}}
181
+ php-version: $\{{ env.PHP_VERSION }}
174
182
  no-dev: "true"
175
183
  {{#if ci.build.sage}}
176
- working-dir: ${{'{{'}} env.THEME_PATH {{'}}'}}
184
+ working-dir: $\{{ env.THEME_PATH }}
177
185
  {{/if}}
178
186
  {{#if enable_acf_pro}}
179
- acf-username: ${{'{{'}} env.ACF_CONNECT_USERNAME {{'}}'}}
180
- acf-password: ${{'{{'}} env.ACF_CONNECT_PASSWORD {{'}}'}}
187
+ acf-username: $\{{ env.ACF_CONNECT_USERNAME }}
188
+ acf-password: $\{{ env.ACF_CONNECT_PASSWORD }}
181
189
  {{/if}}
182
190
 
183
191
  {{#if ci.build.sage}}
184
192
  - name: Setup Node.js + theme
185
193
  uses: hekivo/gha-workflows/actions/setup-node-theme@v1
186
194
  with:
187
- node-version: ${{'{{'}} env.NODE_VERSION {{'}}'}}
195
+ node-version: $\{{ env.NODE_VERSION }}
188
196
  install-root: "false"
189
- theme-path: ${{'{{'}} env.THEME_PATH {{'}}'}}
197
+ theme-path: $\{{ env.THEME_PATH }}
190
198
 
191
199
  - name: Build theme assets
192
- run: npm run build --prefix "${{'{{'}} env.THEME_PATH {{'}}'}}"
200
+ run: npm run build --prefix "$\{{ env.THEME_PATH }}"
193
201
 
194
202
  {{/if}}
195
203
  - name: Compose .env
196
204
  uses: hekivo/gha-workflows/actions/compose-dotenv@v1
197
205
  with:
198
- env-template: ${{'{{'}} env.ENV_TEMPLATE {{'}}'}}
199
- wp-salts: ${{'{{'}} env.WP_SALTS_BLOCK {{'}}'}}
200
- db-name: ${{'{{'}} env.WORDPRESS_DB_NAME {{'}}'}}
201
- db-user: ${{'{{'}} env.WORDPRESS_DB_USER {{'}}'}}
202
- db-password: ${{'{{'}} env.WORDPRESS_DB_PASSWORD {{'}}'}}
203
- db-host: ${{'{{'}} env.WORDPRESS_DB_HOST {{'}}'}}
204
- db-port: ${{'{{'}} env.WORDPRESS_DB_PORT {{'}}'}}
206
+ env-template: $\{{ env.ENV_TEMPLATE }}
207
+ wp-salts: $\{{ env.WP_SALTS_BLOCK }}
208
+ db-name: $\{{ env.WORDPRESS_DB_NAME }}
209
+ db-user: $\{{ env.WORDPRESS_DB_USER }}
210
+ db-password: $\{{ env.WORDPRESS_DB_PASSWORD }}
211
+ db-host: $\{{ env.WORDPRESS_DB_HOST }}
212
+ db-port: $\{{ env.WORDPRESS_DB_PORT }}
205
213
 
206
214
  {{#if ci.ssh.useCloudflare}}
207
215
  - name: Setup SSH via Cloudflare Tunnel
208
216
  uses: hekivo/gha-workflows/actions/setup-cloudflare-ssh@v1
209
217
  with:
210
- ssh-host: ${{'{{'}} env.SSH_HOST {{'}}'}}
211
- ssh-user: ${{'{{'}} env.SSH_USER {{'}}'}}
212
- ssh-private-key: ${{'{{'}} env.SSH_PRIVATE_KEY {{'}}'}}
213
- tunnel-token-id: ${{'{{'}} env.TUNNEL_SERVICE_TOKEN_ID {{'}}'}}
214
- tunnel-token-secret: ${{'{{'}} env.TUNNEL_SERVICE_TOKEN_SECRET {{'}}'}}
218
+ ssh-host: $\{{ env.SSH_HOST }}
219
+ ssh-user: $\{{ env.SSH_USER }}
220
+ ssh-private-key: $\{{ env.SSH_PRIVATE_KEY }}
221
+ tunnel-token-id: $\{{ env.TUNNEL_SERVICE_TOKEN_ID }}
222
+ tunnel-token-secret: $\{{ env.TUNNEL_SERVICE_TOKEN_SECRET }}
215
223
  {{else}}
216
224
  - name: Configure SSH agent
217
225
  uses: webfactory/ssh-agent@v0.9.0
218
226
  with:
219
- ssh-private-key: ${{'{{'}} env.SSH_PRIVATE_KEY {{'}}'}}
227
+ ssh-private-key: $\{{ env.SSH_PRIVATE_KEY }}
220
228
 
221
229
  - name: Add known hosts
222
230
  run: |
@@ -228,8 +236,8 @@ jobs:
228
236
  - name: Deploy via rsync
229
237
  uses: hekivo/gha-workflows/actions/deploy-rsync@v1
230
238
  with:
231
- ssh-target: ${{'{{'}} env.SSH_HOST {{'}}'}}
232
- remote-root: ${{'{{'}} env.SSH_REMOTE_PATH {{'}}'}}
239
+ ssh-target: $\{{ env.SSH_HOST }}
240
+ remote-root: $\{{ env.SSH_REMOTE_PATH }}
233
241
  {{#if ci.build.sage}}
234
242
  theme-slug: {{projectName}}
235
243
  {{/if}}
@@ -237,8 +245,8 @@ jobs:
237
245
  - name: WordPress post-deploy
238
246
  uses: hekivo/gha-workflows/actions/wp-post-deploy@v1
239
247
  with:
240
- ssh-target: ${{'{{'}} env.SSH_HOST {{'}}'}}
241
- remote-root: ${{'{{'}} env.SSH_REMOTE_PATH {{'}}'}}
248
+ ssh-target: $\{{ env.SSH_HOST }}
249
+ remote-root: $\{{ env.SSH_REMOTE_PATH }}
242
250
  {{#if enable_acf_pro}}
243
251
  plugin-slug: advanced-custom-fields-pro
244
252
  {{/if}}
@@ -249,8 +257,8 @@ jobs:
249
257
  - name: Purge Cloudflare cache
250
258
  uses: hekivo/gha-workflows/actions/cloudflare-purge@v1
251
259
  with:
252
- zone-id: ${{'{{'}} env.CLOUDFLARE_PURGE_ZONE_ID {{'}}'}}
253
- api-token: ${{'{{'}} env.CLOUDFLARE_PURGE_TOKEN {{'}}'}}
260
+ zone-id: $\{{ env.CLOUDFLARE_PURGE_ZONE_ID }}
261
+ api-token: $\{{ env.CLOUDFLARE_PURGE_TOKEN }}
254
262
 
255
263
  # ── Deploy Production ─────────────────────────────────────────────────────────
256
264
  deploy-production:
@@ -266,12 +274,11 @@ jobs:
266
274
  uses: actions/checkout@v4
267
275
 
268
276
  - name: Load secrets from 1Password
269
- uses: 1password/load-secrets-action@v2
277
+ uses: 1password/load-secrets-action@v4
270
278
  with:
271
279
  export-env: true
272
280
  env:
273
- OP_CONNECT_HOST: ${{'{{'}} vars.OP_CONNECT_HOST {{'}}'}}
274
- OP_CONNECT_TOKEN: ${{'{{'}} secrets.OP_CONNECT_TOKEN {{'}}'}}
281
+ OP_SERVICE_ACCOUNT_TOKEN: $\{{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
275
282
  {{#if enable_acf_pro}}
276
283
  ACF_CONNECT_USERNAME: op://Hekivo-Internal/{{projectName}}-acf-connect/username
277
284
  ACF_CONNECT_PASSWORD: op://Hekivo-Internal/{{projectName}}-acf-connect/password
@@ -294,43 +301,43 @@ jobs:
294
301
  - name: Setup WordPress (production deps)
295
302
  uses: hekivo/gha-workflows/actions/setup-wordpress@v1
296
303
  with:
297
- php-version: ${{'{{'}} env.PHP_VERSION {{'}}'}}
304
+ php-version: $\{{ env.PHP_VERSION }}
298
305
  no-dev: "true"
299
306
  {{#if ci.build.sage}}
300
- working-dir: ${{'{{'}} env.THEME_PATH {{'}}'}}
307
+ working-dir: $\{{ env.THEME_PATH }}
301
308
  {{/if}}
302
309
  {{#if enable_acf_pro}}
303
- acf-username: ${{'{{'}} env.ACF_CONNECT_USERNAME {{'}}'}}
304
- acf-password: ${{'{{'}} env.ACF_CONNECT_PASSWORD {{'}}'}}
310
+ acf-username: $\{{ env.ACF_CONNECT_USERNAME }}
311
+ acf-password: $\{{ env.ACF_CONNECT_PASSWORD }}
305
312
  {{/if}}
306
313
 
307
314
  {{#if ci.build.sage}}
308
315
  - name: Setup Node.js + theme
309
316
  uses: hekivo/gha-workflows/actions/setup-node-theme@v1
310
317
  with:
311
- node-version: ${{'{{'}} env.NODE_VERSION {{'}}'}}
318
+ node-version: $\{{ env.NODE_VERSION }}
312
319
  install-root: "false"
313
- theme-path: ${{'{{'}} env.THEME_PATH {{'}}'}}
320
+ theme-path: $\{{ env.THEME_PATH }}
314
321
 
315
322
  - name: Build theme assets
316
- run: npm run build --prefix "${{'{{'}} env.THEME_PATH {{'}}'}}"
323
+ run: npm run build --prefix "$\{{ env.THEME_PATH }}"
317
324
 
318
325
  {{/if}}
319
326
  - name: Compose .env
320
327
  uses: hekivo/gha-workflows/actions/compose-dotenv@v1
321
328
  with:
322
- env-template: ${{'{{'}} env.ENV_TEMPLATE {{'}}'}}
323
- wp-salts: ${{'{{'}} env.WP_SALTS_BLOCK {{'}}'}}
324
- db-name: ${{'{{'}} env.WORDPRESS_DB_NAME {{'}}'}}
325
- db-user: ${{'{{'}} env.WORDPRESS_DB_USER {{'}}'}}
326
- db-password: ${{'{{'}} env.WORDPRESS_DB_PASSWORD {{'}}'}}
327
- db-host: ${{'{{'}} env.WORDPRESS_DB_HOST {{'}}'}}
328
- db-port: ${{'{{'}} env.WORDPRESS_DB_PORT {{'}}'}}
329
+ env-template: $\{{ env.ENV_TEMPLATE }}
330
+ wp-salts: $\{{ env.WP_SALTS_BLOCK }}
331
+ db-name: $\{{ env.WORDPRESS_DB_NAME }}
332
+ db-user: $\{{ env.WORDPRESS_DB_USER }}
333
+ db-password: $\{{ env.WORDPRESS_DB_PASSWORD }}
334
+ db-host: $\{{ env.WORDPRESS_DB_HOST }}
335
+ db-port: $\{{ env.WORDPRESS_DB_PORT }}
329
336
 
330
337
  - name: Configure SSH agent
331
338
  uses: webfactory/ssh-agent@v0.9.0
332
339
  with:
333
- ssh-private-key: ${{'{{'}} env.SSH_PRIVATE_KEY {{'}}'}}
340
+ ssh-private-key: $\{{ env.SSH_PRIVATE_KEY }}
334
341
 
335
342
  - name: Add known hosts
336
343
  run: |
@@ -342,9 +349,9 @@ jobs:
342
349
  - name: Deploy via rsync
343
350
  uses: hekivo/gha-workflows/actions/deploy-rsync@v1
344
351
  with:
345
- ssh-target: ${{'{{'}} env.SSH_USER {{'}}'}}@${{'{{'}} env.SSH_HOST {{'}}'}}
346
- ssh-cmd: ssh -p ${{'{{'}} env.SSH_PORT || '22' {{'}}'}}
347
- remote-root: ${{'{{'}} env.SSH_REMOTE_PATH {{'}}'}}
352
+ ssh-target: $\{{ env.SSH_USER }}@$\{{ env.SSH_HOST }}
353
+ ssh-cmd: ssh -p $\{{ env.SSH_PORT || '22' }}
354
+ remote-root: $\{{ env.SSH_REMOTE_PATH }}
348
355
  {{#if ci.build.sage}}
349
356
  theme-slug: {{projectName}}
350
357
  {{/if}}
@@ -352,9 +359,9 @@ jobs:
352
359
  - name: WordPress post-deploy
353
360
  uses: hekivo/gha-workflows/actions/wp-post-deploy@v1
354
361
  with:
355
- ssh-target: ${{'{{'}} env.SSH_USER {{'}}'}}@${{'{{'}} env.SSH_HOST {{'}}'}}
356
- ssh-cmd: ssh -p ${{'{{'}} env.SSH_PORT || '22' {{'}}'}}
357
- remote-root: ${{'{{'}} env.SSH_REMOTE_PATH {{'}}'}}
362
+ ssh-target: $\{{ env.SSH_USER }}@$\{{ env.SSH_HOST }}
363
+ ssh-cmd: ssh -p $\{{ env.SSH_PORT || '22' }}
364
+ remote-root: $\{{ env.SSH_REMOTE_PATH }}
358
365
  {{#if enable_acf_pro}}
359
366
  plugin-slug: advanced-custom-fields-pro
360
367
  {{/if}}
@@ -365,6 +372,6 @@ jobs:
365
372
  - name: Purge Cloudflare cache
366
373
  uses: hekivo/gha-workflows/actions/cloudflare-purge@v1
367
374
  with:
368
- zone-id: ${{'{{'}} env.CLOUDFLARE_PURGE_ZONE_ID {{'}}'}}
369
- api-token: ${{'{{'}} env.CLOUDFLARE_PURGE_TOKEN {{'}}'}}
375
+ zone-id: $\{{ env.CLOUDFLARE_PURGE_ZONE_ID }}
376
+ api-token: $\{{ env.CLOUDFLARE_PURGE_TOKEN }}
370
377
  {{/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
+ }
@@ -41,6 +41,30 @@ hours during incidents.
41
41
  - **TLS certificate management**: `{{ "{{TODO: ACM / Let's Encrypt / Cloudflare}}" }}`
42
42
  - **WAF**: `{{ "{{TODO}}" }}`
43
43
 
44
+ ## WordPress cron (production)
45
+
46
+ Default WP-Cron fires via an HTTP *loopback* to `/wp/wp-cron.php`. When the site sits
47
+ behind an edge authentication layer (e.g. **Cloudflare Access / Zero Trust**), that
48
+ loopback is redirected to the login page and **never executes** — so no scheduled event
49
+ runs (plugin caches, auto-updates, jobs), silently.
50
+
51
+ In production behind edge auth, provision **both** parts:
52
+
53
+ 1. A system cron (e.g. CloudPanel → Site → Cron Jobs) that runs WP-CLI directly, without
54
+ going through HTTP:
55
+
56
+ ```
57
+ */5 * * * * cd <htdocs> && wp cron event run --due-now --quiet
58
+ ```
59
+
60
+ 2. `WORDPRESS_DISABLE_WP_CRON=true` in the production `.env`, to stop the dead loopback.
61
+ `wp-config.php` maps each `WORDPRESS_*` var to the constant of the same name without the
62
+ prefix, so this defines `DISABLE_WP_CRON`. It must be `WORDPRESS_DISABLE_WP_CRON` — not
63
+ `WORDPRESS_DISABLE_CRON`, which would define `DISABLE_CRON` and be ignored by WordPress.
64
+
65
+ Do not enable this in the local `.env`: under Lando the loopback works and is convenient.
66
+ See [Troubleshooting](./Troubleshooting.md) for the symptom and diagnosis.
67
+
44
68
  ## Secrets and IAM
45
69
 
46
70
  - **Secrets store**: `{{ "{{TODO: cloud secret manager / Vault / env vars}}" }}`
@@ -62,4 +62,21 @@ Each entry follows the same shape:
62
62
 
63
63
  ---
64
64
 
65
+ ### Scheduled tasks never run / a plugin screen stays empty (behind edge auth)
66
+
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.
68
+ **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
+ **Fix**:
70
+
71
+ 1. Add a system cron (CloudPanel → Site → Cron Jobs) running WP-CLI directly (bypasses HTTP/edge auth):
72
+ ```
73
+ */5 * * * * cd <htdocs> && wp cron event run --due-now --quiet
74
+ ```
75
+ 2. Stop the futile loopback: set `WORDPRESS_DISABLE_WP_CRON=true` in the production `.env`.
76
+ 3. One-time unblock / confirm: `wp cron event run --due-now` over SSH — pending jobs run immediately.
77
+
78
+ **Why this is the fix**: `wp cron event run` executes events in the local PHP process, never touching the public HTTP surface, so edge auth can't block it. `DISABLE_WP_CRON` only silences the dead loopback — the system cron is what runs the jobs. Confirm with `curl -I https://<domain>/wp/wp-cron.php` → `302` to the edge auth login.
79
+
80
+ ---
81
+
65
82
  `{{ "{{TODO: add project-specific entries as they come up. The list below is intentionally short — generic entries that apply to every wp-kit project.}}" }}`
@@ -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,72 @@ 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
+ log(color.blue, "[git] Installing Git configuration");
83
84
 
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');
85
+ await generator.copyFile(".commitlintrc.json", "git");
86
+ await generator.copyFile(".lintstagedrc.json", "git");
87
+ await generator.copyFile(".husky/commit-msg", "git");
88
+ await generator.copyFile(".husky/pre-commit", "git");
88
89
 
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');
90
+ await generator.copyFile(".vscode/conventional-commits.code-snippets", "git");
91
+ await generator.copyFile(".vscode/copilot.json", "git");
92
+ await generator.copyFile(".vscode/commit-instructions.md", "git");
93
+ await generator.copyFile("docs/CONVENTIONAL-COMMITS.md", "git");
93
94
 
94
- await fs.chmod(path.join(generator.cwd, '.husky/commit-msg'), 0o755);
95
- await fs.chmod(path.join(generator.cwd, '.husky/pre-commit'), 0o755);
95
+ await fs.chmod(path.join(generator.cwd, ".husky/commit-msg"), 0o755);
96
+ await fs.chmod(path.join(generator.cwd, ".husky/pre-commit"), 0o755);
96
97
 
97
98
  const handler = gitProviderHandlers[context.gitProvider];
98
99
  if (handler) {
@@ -101,38 +102,38 @@ export async function setupModule(context, generator) {
101
102
 
102
103
  // Registra hook para fazer o commit inicial após todo o setup
103
104
  generator.hooks.addAction(
104
- 'after_setup_complete',
105
+ "after_setup_complete",
105
106
  async (context, _generator) => {
106
- const projectGitDir = path.join(context.cwd, '.git');
107
+ const projectGitDir = path.join(context.cwd, ".git");
107
108
  if (!(await fs.pathExists(projectGitDir))) {
108
109
  return; // Repositório não foi inicializado neste setup
109
110
  }
110
111
 
111
112
  try {
112
- log(color.blue, '[git] Making initial commit...');
113
+ log(color.blue, "[git] Making initial commit...");
113
114
 
114
115
  // Adiciona todos os arquivos
115
- runGitCommand(['add', '.'], context.cwd);
116
+ runGitCommand(["add", "."], context.cwd);
116
117
 
117
118
  // Ignora assinatura e hooks neste commit automático para não depender do ambiente local.
118
119
  runGitCommand(
119
120
  [
120
- '-c',
121
- 'commit.gpgsign=false',
122
- 'commit',
123
- '--no-verify',
124
- '-m',
125
- 'chore: initial project setup',
121
+ "-c",
122
+ "commit.gpgsign=false",
123
+ "commit",
124
+ "--no-verify",
125
+ "-m",
126
+ "chore: initial project setup",
126
127
  ],
127
- context.cwd
128
+ context.cwd,
128
129
  );
129
130
 
130
- log(color.green, '[git] ✅ Initial commit created successfully');
131
+ log(color.green, "[git] ✅ Initial commit created successfully");
131
132
  } catch (error) {
132
- log(color.orange, '[git] Warning: Could not create initial commit');
133
+ log(color.orange, "[git] Warning: Could not create initial commit");
133
134
  log(color.yellow, `[git] Error: ${error.message}`);
134
135
  }
135
136
  },
136
- 10
137
+ 10,
137
138
  ); // Prioridade 10 (executa após outros hooks com prioridade menor)
138
139
  }
@@ -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
 
@@ -136,6 +136,13 @@ export async function setupModule(context, generator) {
136
136
  mergeStrategy: "replace",
137
137
  });
138
138
 
139
+ // O create-project gera locks do composer.json/package.json STOCK do Sage;
140
+ // após os merges acima eles ficam defasados e o `composer install`/`npm ci`
141
+ // da CI morre (wp-kit#39). O projeto gera os seus no primeiro install.
142
+ for (const stale of ["composer.lock", "package-lock.json"]) {
143
+ await fs.remove(path.join(context.cwd, relativeThemeDir, stale));
144
+ }
145
+
139
146
  await generator.generateFile(
140
147
  ".devcontainer/docker-compose.override.yml",
141
148
  context,
@@ -40,10 +40,13 @@ export default defineConfig({
40
40
  },
41
41
  },
42
42
  server: {
43
- https: {
44
- key: fs.readFileSync('/certs/cert.key'),
45
- cert: fs.readFileSync('/certs/cert.crt'),
46
- },
43
+ // certs do Lando; fora do container (ex.: CI) o build roda sem https
44
+ https: fs.existsSync('/certs/cert.key')
45
+ ? {
46
+ key: fs.readFileSync('/certs/cert.key'),
47
+ cert: fs.readFileSync('/certs/cert.crt'),
48
+ }
49
+ : false,
47
50
  host: true,
48
51
  port: 5173,
49
52
  strictPort: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codigodoleo/wp-kit",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "description": "Kit opinativo para padronizar projetos WordPress com CI/CD dinâmico.",
5
5
  "keywords": [
6
6
  "codigodoleo",
@@ -48,3 +48,8 @@ WORDPRESS_AUTH_SALT={{{salts.AUTH_SALT}}}
48
48
  WORDPRESS_SECURE_AUTH_SALT={{{salts.SECURE_AUTH_SALT}}}
49
49
  WORDPRESS_LOGGED_IN_SALT={{{salts.LOGGED_IN_SALT}}}
50
50
  WORDPRESS_NONCE_SALT={{{salts.NONCE_SALT}}}
51
+
52
+ # Observability (hekivo-audit-log, fatia #5) — preencher via deploy (op://) ou
53
+ # scripts/push-obs-creds-to-site.sh do hekivo-mgmt:
54
+ # HEKIVO_AUDIT_CW_ACCESS_KEY_ID="op://Client-<Nome>/cloudwatch-observability-push/username"
55
+ # HEKIVO_AUDIT_CW_SECRET_ACCESS_KEY="op://Client-<Nome>/cloudwatch-observability-push/password"
@@ -88,3 +88,8 @@ php_errors.log
88
88
  # Testing
89
89
  coverage/
90
90
  .phpunit.result.cache
91
+
92
+ # Environment (local secrets: WP salts, DB credentials)
93
+ /.env
94
+ /.env.*
95
+ !/.env.example
@@ -8,7 +8,7 @@ excludes:
8
8
  config:
9
9
  webroot: ./
10
10
  via: nginx
11
- php: "8.4"
11
+ php: "{{phpVersion}}"
12
12
  database: mariadb
13
13
  cache: redis
14
14
  xdebug: true
@@ -44,7 +44,7 @@ services:
44
44
  overrides:
45
45
  platform: linux/amd64
46
46
  ports:
47
- - 5173:5173
47
+ - 5173
48
48
  database:
49
49
  type: mariadb:10.11
50
50
  portforward: true