@codigodoleo/wp-kit 5.2.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",
@@ -283,7 +284,7 @@ export async function runPrompts({ defaults = false } = {}) {
283
284
  return {
284
285
  ...defaultAnswers,
285
286
  ...derived,
286
- phpVersion: "8.4",
287
+ phpVersion: VERSION_REGISTRY.php.latest,
287
288
  nodeVersion: "24",
288
289
  enabledModules,
289
290
  projectDomain: `${defaultAnswers.projectName}.lndo.site`,
@@ -311,7 +312,7 @@ export async function runPrompts({ defaults = false } = {}) {
311
312
  return {
312
313
  ...answers,
313
314
  ...derived,
314
- phpVersion: "8.4",
315
+ phpVersion: VERSION_REGISTRY.php.latest,
315
316
  nodeVersion: "24",
316
317
  enabledModules,
317
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.");
@@ -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}}
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": ["github>hekivo/hekivo-mgmt//renovate-preset.json"]
4
+ }
@@ -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.2.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",
@@ -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