@codigodoleo/wp-kit 2.0.4 → 3.0.1
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.
- package/.cspell.json +5 -25
- package/README.md +127 -2
- package/lib/cli.js +1 -0
- package/lib/commands/init.js +32 -10
- package/lib/config/versions.js +163 -0
- package/lib/core/generator.js +63 -46
- package/lib/core/hook-manager.js +2 -2
- package/lib/core/infer-ci-capabilities.js +13 -24
- package/lib/prompts/index.js +31 -19
- package/lib/prompts/loadModulePrompts.js +4 -2
- package/lib/utils/generate-from-template.js +1 -0
- package/modules/deploy/index.js +34 -7
- package/modules/deploy/prompts.js +5 -5
- package/modules/deploy/templates/.github/workflows/ci.yml.hbs +49 -103
- package/modules/deploy/templates/.gitlab/gitlab-ci.yml.hbs +45 -145
- package/modules/deploy/templates/bitbucket-pipelines.yml.hbs +46 -97
- package/modules/docs/prompts.js +2 -2
- package/modules/docs/templates/README.md.hbs +67 -160
- package/modules/docs/templates/docs/Arquitetura.md +113 -92
- package/modules/docs/templates/docs/Deploy-Pipeline.md +22 -8
- package/modules/docs/templates/docs/Desenvolvimento.md +187 -164
- package/modules/docs/templates/docs/Getting-Started.md +37 -7
- package/modules/docs/templates/docs/Infraestrutura.md +41 -12
- package/modules/docs/templates/docs/Monitoramento.md +83 -45
- package/modules/docs/templates/docs/Sync-the-Production-DB-with-the-Staging-DB.md +6 -7
- package/modules/docs/templates/docs/Troubleshooting.md +1 -1
- package/modules/git/.github/PULL_REQUEST_TEMPLATE.md +1 -0
- package/modules/git/.gitlab/merge_request_templates/default.md +1 -0
- package/modules/git/.vscode/commit-instructions.md +7 -0
- package/modules/git/.vscode/conventional-commits.code-snippets +13 -43
- package/modules/git/docs/CONVENTIONAL-COMMITS.md +14 -14
- package/modules/git/index.js +39 -34
- package/modules/git/prompts.js +4 -4
- package/modules/git/templates/.lando.yml.hbs +5 -13
- package/modules/git/templates/package.json.hbs +4 -15
- package/modules/git/templates/workspace.json.hbs +28 -114
- package/modules/lint/eslint.config.mjs +36 -0
- package/modules/lint/index.js +1 -2
- package/modules/lint/prompts.js +3 -3
- package/modules/lint/templates/.lando.yml.hbs +2 -10
- package/modules/lint/templates/package.json.hbs +4 -16
- package/modules/lint/templates/workspace.json.hbs +15 -56
- package/modules/php/prompts.js +2 -2
- package/modules/php/templates/.lando.yml.hbs +2 -11
- package/modules/php/templates/composer.json.hbs +1 -6
- package/modules/php/templates/workspace.json.hbs +15 -74
- package/modules/redis/prompts.js +2 -2
- package/modules/redis/templates/.lando.yml.hbs +1 -8
- package/modules/sage/index.js +115 -7
- package/modules/sage/prompts.js +3 -3
- package/modules/sage/templates/.lando.yml.hbs +20 -64
- package/modules/sage/templates/theme/composer.json.hbs +3 -18
- package/modules/sage/templates/theme/package.json.hbs +3 -11
- package/modules/sage/templates/theme/style.css.hbs +20 -13
- package/modules/sage/templates/theme/vite.config.js.hbs +13 -53
- package/modules/sage/templates/workspace.json.hbs +12 -67
- package/modules/test-directory/prompts.js +2 -2
- package/package.json +20 -1
- package/templates/.editorconfig.hbs +5 -39
- package/templates/.env.hbs +14 -35
- package/templates/.gitignore.hbs +13 -86
- package/templates/.lando.yml.hbs +11 -44
- package/templates/README.md.hbs +7 -8
- package/templates/composer.json.hbs +12 -60
- package/templates/server/cmd/install-wp.sh.hbs +43 -58
- package/templates/server/www/vhosts.conf.hbs +21 -71
- package/templates/workspace.json.hbs +40 -177
package/.cspell.json
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.2",
|
|
3
3
|
"language": "en,pt_BR",
|
|
4
|
-
"dictionaries": [
|
|
5
|
-
|
|
6
|
-
],
|
|
7
|
-
"import": [
|
|
8
|
-
"@cspell/dict-php/cspell-ext.json",
|
|
9
|
-
"@cspell/dict-pt-br/cspell-ext.json"
|
|
10
|
-
],
|
|
4
|
+
"dictionaries": ["php"],
|
|
5
|
+
"import": ["@cspell/dict-php/cspell-ext.json", "@cspell/dict-pt-br/cspell-ext.json"],
|
|
11
6
|
"words": [
|
|
12
7
|
"ACF",
|
|
13
8
|
"appserver",
|
|
@@ -78,27 +73,12 @@
|
|
|
78
73
|
"yzhang",
|
|
79
74
|
"zhuangtongfa"
|
|
80
75
|
],
|
|
81
|
-
"ignorePaths": [
|
|
82
|
-
|
|
83
|
-
"vendor/**",
|
|
84
|
-
"dist/**",
|
|
85
|
-
"public/**"
|
|
86
|
-
],
|
|
87
|
-
"enableFiletypes": [
|
|
88
|
-
"php",
|
|
89
|
-
"js",
|
|
90
|
-
"ts",
|
|
91
|
-
"json",
|
|
92
|
-
"scss",
|
|
93
|
-
"md",
|
|
94
|
-
"html"
|
|
95
|
-
],
|
|
76
|
+
"ignorePaths": ["node_modules/**", "vendor/**", "dist/**", "public/**"],
|
|
77
|
+
"enableFiletypes": ["php", "js", "ts", "json", "scss", "md", "html"],
|
|
96
78
|
"languageSettings": [
|
|
97
79
|
{
|
|
98
80
|
"languageId": "php",
|
|
99
|
-
"dictionaries": [
|
|
100
|
-
"php"
|
|
101
|
-
]
|
|
81
|
+
"dictionaries": ["php"]
|
|
102
82
|
}
|
|
103
83
|
]
|
|
104
84
|
}
|
package/README.md
CHANGED
|
@@ -3,33 +3,42 @@
|
|
|
3
3
|
Simplifique e padronize seus projetos WordPress em minutos. Este CLI cria um esqueleto moderno, opinativo e pronto para CI/CD, com integração a temas (Sage), qualidade de código e fluxos de deploy — tudo com escolhas inteligentes e mínima fricção.
|
|
4
4
|
|
|
5
5
|
## Por que usar
|
|
6
|
+
|
|
6
7
|
- Padronização entre projetos e equipes
|
|
7
8
|
- Onboarding rápido (menos passos manuais, menos erros)
|
|
8
9
|
- CI/CD dinâmico que se adapta às suas escolhas (GitLab, GitHub ou Bitbucket)
|
|
9
10
|
- Convenções modernas (Conventional Commits, linters, hooks)
|
|
10
11
|
|
|
11
12
|
## Requisitos
|
|
13
|
+
|
|
12
14
|
- Node.js 18+ (recomendado 22+)
|
|
13
15
|
- npm
|
|
14
16
|
- Git
|
|
15
17
|
- PHP 8.2+ e Composer (necessário para tema Sage e ferramentas PHP)
|
|
16
18
|
|
|
17
19
|
## Quickstart (1 minuto)
|
|
20
|
+
|
|
18
21
|
- Criar projeto interativo:
|
|
22
|
+
|
|
19
23
|
```bash
|
|
20
24
|
npx @codigodoleo/wp-kit init --output meu-projeto
|
|
21
25
|
```
|
|
26
|
+
|
|
22
27
|
- Projeto padrão (sem perguntas):
|
|
28
|
+
|
|
23
29
|
```bash
|
|
24
30
|
npx @codigodoleo/wp-kit init --output meu-projeto --defaults
|
|
25
31
|
```
|
|
32
|
+
|
|
26
33
|
- Instalação global (opcional):
|
|
34
|
+
|
|
27
35
|
```bash
|
|
28
36
|
npm install -g @codigodoleo/wp-kit
|
|
29
37
|
leo-wp init --output meu-projeto
|
|
30
38
|
```
|
|
31
39
|
|
|
32
40
|
## O que é gerado
|
|
41
|
+
|
|
33
42
|
- Estrutura WordPress com `content/` (temas, plugins, uploads)
|
|
34
43
|
- Configurações úteis em `server/` e arquivos base (`.env`, `.editorconfig`, etc.)
|
|
35
44
|
- Workspace do VSCode (opcional)
|
|
@@ -41,6 +50,7 @@ leo-wp init --output meu-projeto
|
|
|
41
50
|
- Integração opcional com tema Sage (v10/v11), com build automatizado
|
|
42
51
|
|
|
43
52
|
## Como funciona (visão rápida)
|
|
53
|
+
|
|
44
54
|
1. Você roda `init` e responde às perguntas (ou usa `--defaults`).
|
|
45
55
|
2. O CLI infere capacidades (Composer, Node, Sage, Docker) e monta `context.ci`.
|
|
46
56
|
3. O módulo `deploy` gera o pipeline certo para seu provedor (GitLab/GitHub/Bitbucket) com jobs somente do que faz sentido para o seu projeto.
|
|
@@ -48,36 +58,45 @@ leo-wp init --output meu-projeto
|
|
|
48
58
|
Exemplo: Se você ativar Sage 11, ajustamos versões automaticamente (PHP/Node/WP) e incluímos o job de build do tema no CI.
|
|
49
59
|
|
|
50
60
|
## Fluxo recomendado
|
|
61
|
+
|
|
51
62
|
1. Execute o comando (interativo):
|
|
63
|
+
|
|
52
64
|
```bash
|
|
53
65
|
npx @codigodoleo/wp-kit init --output meu-wp
|
|
54
66
|
```
|
|
67
|
+
|
|
55
68
|
2. Escolha o provedor de Git (ex.: GitLab ou GitHub) no prompt do módulo "git".
|
|
56
69
|
3. Ative o módulo "deploy" (gera a pipeline automática).
|
|
57
70
|
4. Se desejar, habilite o tema Sage (o build entra na pipeline automaticamente).
|
|
58
71
|
5. Faça o primeiro commit e suba o repositório. O CI já estará pronto para rodar.
|
|
59
72
|
|
|
60
73
|
## Comandos disponíveis
|
|
74
|
+
|
|
61
75
|
- `init [options]` — Inicializa um novo projeto WordPress com DevOps
|
|
62
76
|
- `--help` — Ajuda
|
|
63
77
|
- `--version` — Versão
|
|
64
78
|
|
|
65
79
|
### Opções do `init`
|
|
80
|
+
|
|
66
81
|
- `--output <path>` — Diretório de saída do projeto
|
|
67
82
|
- `--defaults` — Usa configurações padrão sem interação
|
|
68
83
|
|
|
69
84
|
## Exemplos práticos
|
|
85
|
+
|
|
70
86
|
- Interativo, escolhendo tudo pelo prompt:
|
|
87
|
+
|
|
71
88
|
```bash
|
|
72
89
|
npx @codigodoleo/wp-kit init --output site-corporativo
|
|
73
90
|
```
|
|
74
91
|
|
|
75
92
|
- Projeto padrão, sem prompts (padrões inteligentes):
|
|
93
|
+
|
|
76
94
|
```bash
|
|
77
95
|
npx @codigodoleo/wp-kit init --output blog-interno --defaults
|
|
78
96
|
```
|
|
79
97
|
|
|
80
98
|
## Estrutura essencial de pastas
|
|
99
|
+
|
|
81
100
|
```
|
|
82
101
|
meu-projeto/
|
|
83
102
|
content/
|
|
@@ -90,25 +109,131 @@ meu-projeto/
|
|
|
90
109
|
```
|
|
91
110
|
|
|
92
111
|
## CI Dinâmico (como decidimos o que rodar)
|
|
112
|
+
|
|
93
113
|
Detectamos automaticamente:
|
|
114
|
+
|
|
94
115
|
- `composer.json` (root/tema) → job de Composer
|
|
95
116
|
- `package.json` (root/tema) → job de Node
|
|
96
117
|
- Tema Sage ativo → job de build do tema
|
|
97
118
|
- Deploy Docker escolhido → job de deploy Docker
|
|
98
119
|
|
|
99
120
|
Provedores suportados:
|
|
121
|
+
|
|
100
122
|
- GitLab CI, GitHub Actions, Bitbucket Pipelines
|
|
101
123
|
|
|
102
124
|
## Convenções e qualidade
|
|
125
|
+
|
|
103
126
|
- Commits: Conventional Commits (ex.: `feat:`, `fix:`, `docs:`)
|
|
104
|
-
- Hooks: Husky + lint-staged
|
|
105
|
-
- Linters: ESLint, Prettier, Stylelint, Pint
|
|
127
|
+
- Hooks: Husky + lint-staged (validação automática ao fazer commit)
|
|
128
|
+
- Linters: ESLint (flat config), Prettier, Stylelint, Pint
|
|
129
|
+
- Commitlint: Validação de mensagens de commit convencionais
|
|
130
|
+
- Interactive commits: Use `npm run commit` para commits interativos
|
|
131
|
+
|
|
132
|
+
## Script de desenvolvimento
|
|
133
|
+
|
|
134
|
+
Comandos disponíveis para desenvolvimento:
|
|
135
|
+
|
|
136
|
+
- `npm run lint` — Validar código com ESLint
|
|
137
|
+
- `npm run lint:fix` — Corrigir automaticamente problemas de linting
|
|
138
|
+
- `npm run format` — Formatar código com Prettier
|
|
139
|
+
- `npm run commit` — Criar commit interativo (cz)
|
|
140
|
+
- `npm run test:setup` — Gerar sandbox de teste
|
|
141
|
+
- `npm run test:scaffold` — Criar novo projeto de teste
|
|
142
|
+
|
|
143
|
+
## Git Workflows
|
|
144
|
+
|
|
145
|
+
O projeto usa Husky para automatizar validações:
|
|
146
|
+
|
|
147
|
+
- **pre-commit**: Executa lint-staged em arquivos modificados
|
|
148
|
+
- **commit-msg**: Valida mensagem com commitlint
|
|
149
|
+
|
|
150
|
+
Se precisar pular hooks (situação de emergência apenas):
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
git commit --no-verify
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## ESLint Flat Config (moderne)
|
|
157
|
+
|
|
158
|
+
O projeto agora usa o novo formato ESLint flat config (`eslint.config.mjs`):
|
|
159
|
+
|
|
160
|
+
- Melhor inicialização de projeto
|
|
161
|
+
- Sem `eslintrc.json` legado
|
|
162
|
+
- Ignores integradas na configuração principal
|
|
163
|
+
- Melhor performance
|
|
164
|
+
|
|
165
|
+
Projetos gerados também usarão este novo formato.
|
|
106
166
|
|
|
107
167
|
## Dicas e solução de problemas
|
|
168
|
+
|
|
108
169
|
- Pipeline não foi gerado? Verifique se habilitou o módulo `deploy` e qual provedor selecionou no módulo `git`.
|
|
109
170
|
- Tema Sage não compilou? Garanta Composer/Node instalados e que o tema existe em `content/themes/<projectName>`.
|
|
110
171
|
|
|
172
|
+
## AI Co-Pilot Support 🤖
|
|
173
|
+
|
|
174
|
+
wp-kit agora inclui suporte integrado para assistência de IA via **Claude Code** (e futuramente Cursor e VSCode).
|
|
175
|
+
|
|
176
|
+
### Funcionalidades
|
|
177
|
+
|
|
178
|
+
Três skills prontos para ajudar no desenvolvimento:
|
|
179
|
+
|
|
180
|
+
1. **Building Sage Themes** — Master Sage 11 & Acorn
|
|
181
|
+
- Service providers e injeção de dependência
|
|
182
|
+
- Componentes Blade e view composers
|
|
183
|
+
- theme.json e configuração WordPress
|
|
184
|
+
- Padrões de desenvolvimento
|
|
185
|
+
|
|
186
|
+
2. **Optimizing Vite Builds** — Performance de assets
|
|
187
|
+
- Configuração Vite e bundling
|
|
188
|
+
- Code splitting e análise de bundle
|
|
189
|
+
- Cache busting e asset versioning
|
|
190
|
+
- Monitoramento de performance
|
|
191
|
+
|
|
192
|
+
3. **Developing ACF Blocks** — Criação de blocos Gutenberg
|
|
193
|
+
- Anatomia de blocos ACF
|
|
194
|
+
- Todos os 20+ tipos de campos ACF
|
|
195
|
+
- Templates com Blade
|
|
196
|
+
- Padrões avançados
|
|
197
|
+
|
|
198
|
+
### Como usar
|
|
199
|
+
|
|
200
|
+
#### Com Claude Code
|
|
201
|
+
|
|
202
|
+
1. Abra seu projeto wp-kit no Claude Code
|
|
203
|
+
2. Use `/` para ver os skills disponíveis
|
|
204
|
+
3. Procure por "sage", "vite" ou "acf"
|
|
205
|
+
4. Clique para acessar o skill
|
|
206
|
+
|
|
207
|
+
#### Busca Direta
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
/building-sage-themes → Desenvolvimento de temas
|
|
211
|
+
/optimizing-vite-builds → Otimização de assets
|
|
212
|
+
/developing-acf-blocks → Blocos Gutenberg
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Estrutura de Skills
|
|
216
|
+
|
|
217
|
+
Cada skill segue um padrão progressivo:
|
|
218
|
+
|
|
219
|
+
- **SKILL.md** — Quick start em 2-3 minutos
|
|
220
|
+
- **Decision Trees** — Guias "qual ferramenta usar?"
|
|
221
|
+
- **Reference Files** — Documentação completa com exemplos
|
|
222
|
+
- **150+ Exemplos** — Código pronto para copiar/colar
|
|
223
|
+
|
|
224
|
+
### Futuro
|
|
225
|
+
|
|
226
|
+
Suporte planejado para:
|
|
227
|
+
|
|
228
|
+
- ✅ Claude Code (atual, disponível)
|
|
229
|
+
- ⏳ Cursor (em desenvolvimento)
|
|
230
|
+
- ⏳ VSCode AI Assistant (em desenvolvimento)
|
|
231
|
+
- ⏳ Plugin customizado (roadmap futuro)
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
111
235
|
## Contribuição
|
|
236
|
+
|
|
112
237
|
Pull Requests são muito bem-vindos! Use commits convencionais, escreva mudanças pequenas e inclua atualizações na documentação quando necessário.
|
|
113
238
|
|
|
114
239
|
—
|
package/lib/cli.js
CHANGED
package/lib/commands/init.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
1
|
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
|
|
4
|
+
import { Command } from 'commander';
|
|
3
5
|
import fs from 'fs-extra';
|
|
6
|
+
|
|
4
7
|
import { runPrompts } from '../prompts/index.js';
|
|
5
8
|
import { Generator } from '../core/generator.js';
|
|
6
9
|
import { log, color } from '../utils/logger.js';
|
|
7
10
|
import { inferCiCapabilities } from '../core/infer-ci-capabilities.js';
|
|
11
|
+
import { validateVersionCompatibility } from '../config/versions.js';
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = path.dirname(__filename);
|
|
8
15
|
|
|
9
16
|
export const initCommand = new Command('init')
|
|
10
17
|
.option('-o, --output <dir>', 'Output directory', '__test-sandbox__/test-project')
|
|
@@ -25,13 +32,28 @@ export const initCommand = new Command('init')
|
|
|
25
32
|
// 🔧 Ajustes automáticos para Sage 11
|
|
26
33
|
if (context.useSage && context.sageVersion === '11') {
|
|
27
34
|
context.phpVersion = '8.3';
|
|
28
|
-
context.nodeVersion = '
|
|
29
|
-
context.wpCoreVersion = '
|
|
35
|
+
context.nodeVersion = '22';
|
|
36
|
+
context.wpCoreVersion = '6.8.1';
|
|
30
37
|
|
|
31
38
|
log(color.orange, '🔧 Sage 11 selected — automatically adjusting versions:');
|
|
32
39
|
log(color.orange, ' → PHP: 8.3');
|
|
33
|
-
log(color.orange, ' → Node:
|
|
34
|
-
log(color.orange, ' → WP Core:
|
|
40
|
+
log(color.orange, ' → Node: 22');
|
|
41
|
+
log(color.orange, ' → WP Core: 6.8.1');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 📋 Validar compatibilidade de versões (se Sage está habilitado)
|
|
45
|
+
if (context.useSage) {
|
|
46
|
+
const validation = validateVersionCompatibility(
|
|
47
|
+
context.sageVersion,
|
|
48
|
+
context.phpVersion,
|
|
49
|
+
context.nodeVersion,
|
|
50
|
+
context.wpCoreVersion
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
if (validation.warnings.length > 0) {
|
|
54
|
+
log(color.orange, '⚠️ Version compatibility warnings:');
|
|
55
|
+
validation.warnings.forEach((warn) => log(color.orange, ` - ${warn}`));
|
|
56
|
+
}
|
|
35
57
|
}
|
|
36
58
|
|
|
37
59
|
context.cwd = target;
|
|
@@ -86,7 +108,7 @@ export const initCommand = new Command('init')
|
|
|
86
108
|
modules: enabledModules,
|
|
87
109
|
context,
|
|
88
110
|
format: 'json',
|
|
89
|
-
mergeStrategy: 'concat'
|
|
111
|
+
mergeStrategy: 'concat',
|
|
90
112
|
});
|
|
91
113
|
|
|
92
114
|
await generator.generateModularFile({
|
|
@@ -94,14 +116,14 @@ export const initCommand = new Command('init')
|
|
|
94
116
|
modules: enabledModules,
|
|
95
117
|
context,
|
|
96
118
|
format: 'json',
|
|
97
|
-
mergeStrategy: 'concat'
|
|
119
|
+
mergeStrategy: 'concat',
|
|
98
120
|
});
|
|
99
121
|
|
|
100
122
|
await generator.generateModularFile({
|
|
101
123
|
baseTemplate: '.lando.yml',
|
|
102
124
|
modules: enabledModules,
|
|
103
125
|
context,
|
|
104
|
-
mergeStrategy: 'concat'
|
|
126
|
+
mergeStrategy: 'concat',
|
|
105
127
|
});
|
|
106
128
|
|
|
107
129
|
await generator.generateModularFile({
|
|
@@ -110,11 +132,11 @@ export const initCommand = new Command('init')
|
|
|
110
132
|
modules: enabledModules,
|
|
111
133
|
context,
|
|
112
134
|
format: 'json',
|
|
113
|
-
mergeStrategy: 'concat'
|
|
135
|
+
mergeStrategy: 'concat',
|
|
114
136
|
});
|
|
115
137
|
|
|
116
138
|
for (const mod of enabledModules) {
|
|
117
|
-
const modIndexPath = path.resolve('modules', mod, 'index.js');
|
|
139
|
+
const modIndexPath = path.resolve(__dirname, '../../modules', mod, 'index.js');
|
|
118
140
|
if (await fs.pathExists(modIndexPath)) {
|
|
119
141
|
const { setupModule } = await import(modIndexPath);
|
|
120
142
|
if (typeof setupModule === 'function') {
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version Registry - Centralized version management for wp-kit
|
|
3
|
+
* This file contains all version information for WordPress, PHP, Node.js, and Sage
|
|
4
|
+
*
|
|
5
|
+
* Benefits of centralized approach:
|
|
6
|
+
* - Single source of truth for all versions
|
|
7
|
+
* - Easy to update versions without searching codebase
|
|
8
|
+
* - Better documentation of version requirements
|
|
9
|
+
* - Compatibility matrix validation
|
|
10
|
+
* - Easy to script version updates
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const VERSION_REGISTRY = {
|
|
14
|
+
/**
|
|
15
|
+
* WordPress Core Versions
|
|
16
|
+
* Maintains LTS and supported versions
|
|
17
|
+
*/
|
|
18
|
+
wordpress: {
|
|
19
|
+
latest: '6.9.4',
|
|
20
|
+
lts: ['6.9.4', '6.8.1', '6.7'],
|
|
21
|
+
all: ['6.9.4', '6.8.1', '6.7', '6.6'],
|
|
22
|
+
eol: ['6.5', '6.0', '5.9'],
|
|
23
|
+
description: 'Available WordPress core versions for new projects',
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Sage Theme Versions
|
|
28
|
+
* Each version specifies minimum PHP requirement and Acorn dependency
|
|
29
|
+
*/
|
|
30
|
+
sage: {
|
|
31
|
+
11: {
|
|
32
|
+
tag: 'v11.0.1', // Update this when new versions are released
|
|
33
|
+
minPhp: '8.1',
|
|
34
|
+
acornVersion: '5.1.0',
|
|
35
|
+
nodeMin: '18',
|
|
36
|
+
status: 'active',
|
|
37
|
+
releaseDate: '2024-09-27',
|
|
38
|
+
url: 'https://github.com/roots/sage/releases/tag/v11.0.1',
|
|
39
|
+
},
|
|
40
|
+
10: {
|
|
41
|
+
tag: 'v10.8.2', // Legacy - consider only for compatibility projects
|
|
42
|
+
minPhp: '8.0',
|
|
43
|
+
acornVersion: '4.x',
|
|
44
|
+
nodeMin: '16',
|
|
45
|
+
status: 'legacy',
|
|
46
|
+
releaseDate: '2023-06-01',
|
|
47
|
+
url: 'https://github.com/roots/sage/releases/tag/v10.8.2',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* PHP Versions
|
|
53
|
+
* Only actively supported versions per php.net
|
|
54
|
+
*/
|
|
55
|
+
php: {
|
|
56
|
+
latest: '8.3',
|
|
57
|
+
supported: ['8.3', '8.2', '8.1'],
|
|
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',
|
|
60
|
+
// PHP version dates: https://www.php.net/supported-versions.php
|
|
61
|
+
eolDates: {
|
|
62
|
+
8.1: '2025-11-25',
|
|
63
|
+
'8.0': '2023-11-26',
|
|
64
|
+
7.4: '2022-11-28',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Node.js Versions
|
|
70
|
+
* Tracks LTS and current stable releases
|
|
71
|
+
*/
|
|
72
|
+
node: {
|
|
73
|
+
latest: '22',
|
|
74
|
+
lts: ['22', '20', '18'],
|
|
75
|
+
all: ['22', '20', '18'],
|
|
76
|
+
deprecated: ['16', '14', '12', '10'],
|
|
77
|
+
description: 'Supported Node.js versions - prefer LTS releases',
|
|
78
|
+
// LTS information: https://nodejs.org/en/about/releases/
|
|
79
|
+
ltsDates: {
|
|
80
|
+
22: { start: '2024-10-29', end: '2027-04-30' },
|
|
81
|
+
20: { start: '2023-10-24', end: '2026-04-30' },
|
|
82
|
+
18: { start: '2022-10-25', end: '2025-04-30' },
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Helper functions for version management
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Get minimum WordPress version for a given Sage version
|
|
93
|
+
*/
|
|
94
|
+
export function getMinWordPresForSage(sageVersion) {
|
|
95
|
+
// Sage 11 requires WordPress 5.9+ due to theme.json requirements
|
|
96
|
+
if (sageVersion === '11') return '6.0'; // Recommend 6.5+
|
|
97
|
+
if (sageVersion === '10') return '5.9';
|
|
98
|
+
return '5.9';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Validate version compatibility
|
|
103
|
+
*/
|
|
104
|
+
export function validateVersionCompatibility(sage, php, node, wp) {
|
|
105
|
+
const errors = [];
|
|
106
|
+
const warnings = [];
|
|
107
|
+
|
|
108
|
+
// Check Sage requirements
|
|
109
|
+
const sageConfig = VERSION_REGISTRY.sage[sage];
|
|
110
|
+
if (!sageConfig) {
|
|
111
|
+
errors.push(`Sage version ${sage} not supported`);
|
|
112
|
+
} else {
|
|
113
|
+
const minPhp = sageConfig.minPhp;
|
|
114
|
+
if (parseFloat(php) < parseFloat(minPhp)) {
|
|
115
|
+
errors.push(`Sage ${sage} requires PHP ${minPhp}+ (got ${php})`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (sageConfig.status === 'legacy') {
|
|
119
|
+
warnings.push(`Sage ${sage} is in legacy status. Consider upgrading.`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Check PHP is supported
|
|
124
|
+
if (!VERSION_REGISTRY.php.supported.includes(php)) {
|
|
125
|
+
warnings.push(`PHP ${php} is out of standard support`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Check Node is supported
|
|
129
|
+
if (!VERSION_REGISTRY.node.all.includes(node)) {
|
|
130
|
+
warnings.push(`Node.js ${node} is not recommended`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Check WordPress is available
|
|
134
|
+
if (!VERSION_REGISTRY.wordpress.all.includes(wp)) {
|
|
135
|
+
warnings.push(`WordPress ${wp} may not be available in the expected repository`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return { errors, warnings, isValid: errors.length === 0 };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Get recommended version combination for a given Sage version
|
|
143
|
+
*/
|
|
144
|
+
export function getRecommendedVersions(sageVersion = '11') {
|
|
145
|
+
return {
|
|
146
|
+
sage: sageVersion,
|
|
147
|
+
php: '8.3',
|
|
148
|
+
node: '22',
|
|
149
|
+
wp: '6.9.4',
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Format version info for display
|
|
155
|
+
*/
|
|
156
|
+
export function formatVersionInfo() {
|
|
157
|
+
return `
|
|
158
|
+
WordPress: ${VERSION_REGISTRY.wordpress.all.join(', ')}
|
|
159
|
+
PHP: ${VERSION_REGISTRY.php.supported.join(', ')}
|
|
160
|
+
Node.js: ${VERSION_REGISTRY.node.lts.join(', ')}
|
|
161
|
+
Sage: 11 (${VERSION_REGISTRY.sage[11].tag}), 10 (${VERSION_REGISTRY.sage[10].tag})
|
|
162
|
+
`;
|
|
163
|
+
}
|