@codigodoleo/wp-kit 5.3.0 → 6.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/README.md +83 -96
- package/lib/commands/init.js +28 -26
- package/lib/config/versions.js +27 -1
- package/lib/core/cloud-allowlist.js +38 -0
- package/lib/core/generator.js +56 -50
- package/lib/core/infer-ci-capabilities.js +17 -5
- package/lib/prompts/index.js +105 -8
- package/lib/utils/auth-template.js +18 -0
- package/lib/utils/env-example.js +18 -6
- package/lib/utils/git.js +5 -188
- package/modules/blank-theme/index.js +1 -1
- package/modules/deploy/index.js +15 -0
- package/modules/deploy/scripts/check-exposure.sh +63 -0
- package/modules/deploy/templates/.github/workflows/ci.yml.hbs +28 -0
- package/modules/docs/index.js +18 -18
- package/modules/docs/templates/README.md.hbs +1 -1
- package/modules/docs/templates/docs/Arquitetura.md.hbs +2 -2
- package/modules/docs/templates/docs/Deploy-Pipeline.md.hbs +21 -1
- package/modules/docs/templates/docs/Development.md.hbs +236 -0
- package/modules/docs/templates/docs/Getting-Started.md.hbs +75 -4
- package/modules/docs/templates/docs/Infraestrutura.md.hbs +1 -1
- package/modules/docs/templates/docs/Troubleshooting.md.hbs +34 -1
- package/modules/git/.husky/kivo-wp/commit-msg +3 -0
- package/modules/git/.husky/kivo-wp/pre-commit +25 -0
- package/modules/git/.husky/pre-commit +3 -7
- package/modules/git/.lintstagedrc.json +5 -2
- package/modules/git/index.js +19 -2
- package/modules/git/templates/.lando.yml.hbs +5 -0
- package/modules/git/templates/package.json.hbs +1 -1
- package/modules/kivo-wp/fixtures/menus.json +11 -0
- package/modules/kivo-wp/fixtures/options.json +10 -0
- package/modules/kivo-wp/fixtures/posts.json +58 -0
- package/modules/kivo-wp/fixtures/seed.php +152 -0
- package/modules/kivo-wp/fixtures/terms.json +6 -0
- package/modules/kivo-wp/fixtures/users.json +26 -0
- package/modules/kivo-wp/index.js +193 -0
- package/modules/kivo-wp/prompts.js +1 -0
- package/modules/kivo-wp/templates/.devcontainer/devcontainer.json.hbs +40 -0
- package/modules/kivo-wp/templates/.dockerignore.hbs +15 -0
- package/modules/kivo-wp/templates/Dockerfile.hbs +83 -0
- package/modules/kivo-wp/templates/bin/_lib.sh.hbs +137 -0
- package/modules/kivo-wp/templates/bin/build.hbs +13 -0
- package/modules/kivo-wp/templates/bin/composer.hbs +6 -0
- package/modules/kivo-wp/templates/bin/db-export.hbs +18 -0
- package/modules/kivo-wp/templates/bin/db-import.hbs +26 -0
- package/modules/kivo-wp/templates/bin/db.hbs +6 -0
- package/modules/kivo-wp/templates/bin/dev.hbs +7 -0
- package/modules/kivo-wp/templates/bin/down.hbs +34 -0
- package/modules/kivo-wp/templates/bin/e2e.hbs +48 -0
- package/modules/kivo-wp/templates/bin/flush.hbs +11 -0
- package/modules/kivo-wp/templates/bin/info.hbs +15 -0
- package/modules/kivo-wp/templates/bin/logs.hbs +6 -0
- package/modules/kivo-wp/templates/bin/mago.hbs +8 -0
- package/modules/kivo-wp/templates/bin/node.hbs +6 -0
- package/modules/kivo-wp/templates/bin/npm.hbs +6 -0
- package/modules/kivo-wp/templates/bin/php.hbs +6 -0
- package/modules/kivo-wp/templates/bin/reset-deps.hbs +11 -0
- package/modules/kivo-wp/templates/bin/seed.hbs +21 -0
- package/modules/kivo-wp/templates/bin/setup.hbs +283 -0
- package/modules/kivo-wp/templates/bin/shell.hbs +14 -0
- package/modules/kivo-wp/templates/bin/stan.hbs +8 -0
- package/modules/kivo-wp/templates/bin/test.hbs +6 -0
- package/modules/kivo-wp/templates/bin/trust-cert.hbs +21 -0
- package/modules/kivo-wp/templates/bin/up.hbs +6 -0
- package/modules/kivo-wp/templates/bin/wp.hbs +6 -0
- package/modules/kivo-wp/templates/bin/xdebug.hbs +22 -0
- package/modules/kivo-wp/templates/compose.yaml.hbs +117 -0
- package/modules/kivo-wp/templates/content/mu-plugins/kivo-wp-local-mail.php.hbs +29 -0
- package/modules/kivo-wp/templates/docs/cloud-sessions.md.hbs +34 -0
- package/modules/kivo-wp/templates/server/caddy/Caddyfile.hbs +44 -0
- package/modules/kivo-wp/templates/server/nginx/deny.conf.hbs +26 -0
- package/modules/lint/index.js +22 -14
- package/modules/lint/templates/package.json.hbs +6 -0
- package/modules/php/index.js +18 -1
- package/modules/php/kivo-wp/php-wrapper.sh +3 -0
- package/modules/php/kivo-wp/pint-wrapper.sh +3 -0
- package/modules/php/templates/phpstan.neon.dist.hbs +27 -0
- package/modules/sage/index.js +4 -26
- package/modules/sage/templates/bin/theme-lint.hbs +6 -0
- package/modules/sage/templates/server/cmd/setup-sage-node.sh.hbs +3 -1
- package/modules/sage/templates/server/cmd/setup-sage-php.sh.hbs +3 -1
- package/modules/sage/templates/theme/vite.config.js.hbs +20 -2
- package/modules/sage/templates/workspace.json.hbs +0 -57
- package/modules/skills/index.js +56 -11
- package/modules/skills/prompts.js +3 -16
- package/modules/test/index.js +13 -11
- package/modules/test/phpunit.xml +18 -0
- package/modules/test/templates/playwright.config.js.hbs +23 -0
- package/modules/test/tests/SmokeTest.php +8 -9
- package/modules/test/tests/e2e/smoke.spec.js +28 -0
- package/package.json +3 -2
- package/templates/.env.hbs +16 -5
- package/templates/.gitignore.hbs +8 -1
- package/templates/.lando.yml.hbs +3 -9
- package/templates/CLAUDE.md.hbs +33 -15
- package/templates/README.md.hbs +38 -12
- package/templates/composer.json.hbs +1 -1
- package/templates/package.json.hbs +8 -1
- package/templates/server/cmd/install-wp.sh.hbs +1 -1
- package/templates/server/cmd/setup-node.sh.hbs +3 -1
- package/templates/server/cmd/setup-php.sh.hbs +63 -9
- package/templates/workspace.json.hbs +0 -56
- package/{wp-config.php → templates/wp-config.php.hbs} +56 -14
- package/modules/docs/templates/docs/Desenvolvimento.md.hbs +0 -127
- package/modules/lint/templates/.lando.yml.hbs +0 -5
- package/modules/sage/templates/.devcontainer/devcontainer.json.hbs +0 -7
- package/modules/sage/templates/.devcontainer/docker-compose.override.yml.hbs +0 -4
- package/modules/sage/templates/.devcontainer/post-create.sh.hbs +0 -11
- package/templates/.devcontainer/Dockerfile.hbs +0 -24
- package/templates/.devcontainer/config/nginx.conf +0 -23
- package/templates/.devcontainer/config/nginx.conf.hbs +0 -23
- package/templates/.devcontainer/devcontainer.json.hbs +0 -29
- package/templates/.devcontainer/docker-compose.yml.hbs +0 -76
- package/templates/.devcontainer/setup.sh.hbs +0 -17
- package/templates/auth.json.hbs +0 -8
package/README.md
CHANGED
|
@@ -3,117 +3,104 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@codigodoleo/wp-kit)
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
|
|
6
|
-
wp-kit
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
| Cenário | Módulos ativos | Quickstart |
|
|
11
|
-
| ----------------------------- | ------------------------- | ----------------------------- |
|
|
12
|
-
| Só lint, git e deploy | `lint` + `git` + `deploy` | [→ Quickstart](#quickstart) |
|
|
13
|
-
| Tema WordPress moderno (Sage) | + `sage` | [→ Sage](#sage) |
|
|
14
|
-
| MU Plugin customizado | + `mu-plugin` | [→ MU Plugin](#mu-plugin) |
|
|
15
|
-
| Plugin WordPress | + `plugin` | [→ Plugin](#plugin) |
|
|
16
|
-
| Tema do zero com Vite | + `blank-theme` | [→ Blank Theme](#blank-theme) |
|
|
17
|
-
|
|
18
|
-
> ⚡ Os módulos são combinantes — você pode ter Sage + mu-plugin + lint no mesmo projeto. E pode adicionar módulos rodando o `init` novamente.
|
|
6
|
+
wp-kit generates a WordPress project with everything you would otherwise rebuild by hand: a Docker
|
|
7
|
+
Compose development environment (kivo-wp), WordPress installed with Composer, optional theme and
|
|
8
|
+
plugin scaffolds, lint, tests, static analysis, CI and project docs.
|
|
19
9
|
|
|
20
10
|
## Quickstart
|
|
21
11
|
|
|
22
12
|
```bash
|
|
23
|
-
npx @codigodoleo/wp-kit init --output
|
|
13
|
+
npx @codigodoleo/wp-kit init --output my-site
|
|
14
|
+
cd my-site
|
|
15
|
+
bin/setup
|
|
24
16
|
```
|
|
25
17
|
|
|
26
|
-
|
|
18
|
+
`bin/setup` builds and starts the stack, installs Composer and npm dependencies, builds the theme,
|
|
19
|
+
installs WordPress, seeds synthetic fixtures and prints the URLs and the local admin login. The site
|
|
20
|
+
answers at `https://my-site.localhost` (with the port from `HTTPS_PORT` in `.env` when 443 is busy);
|
|
21
|
+
run `bin/trust-cert` once so your browser trusts the local certificate. The generated
|
|
22
|
+
`docs/Getting-Started.md` covers the rest.
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
npx @codigodoleo/wp-kit init --output meu-site --defaults
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Instalação global (opcional):
|
|
24
|
+
Without prompts (default answers: kivo-wp, Sage theme, every tooling module):
|
|
33
25
|
|
|
34
26
|
```bash
|
|
35
|
-
|
|
36
|
-
leo-wp init --output meu-site
|
|
27
|
+
npx @codigodoleo/wp-kit init --output my-site --defaults
|
|
37
28
|
```
|
|
38
29
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
| **Diretório** | `content/themes/{name}` | `content/mu-plugins/{name}` | `content/plugins/{name}` | `content/themes/{name}` |
|
|
44
|
-
| **PHP** | Acorn + Blade | PSR-4 | PSR-4 | Mínimo |
|
|
45
|
-
| **JS/CSS** | Vite (Bud) | — | — | Vite + SCSS |
|
|
46
|
-
| **ACF** | ACF Composer | — | — | — |
|
|
47
|
-
| **Lint** | ESLint + Stylelint + Pint | Pint | Pint | ESLint + Stylelint + Pint |
|
|
30
|
+
For scripted runs, environment variables override the defaults, for example
|
|
31
|
+
`WP_KIT_PROJECT_NAME=acme WP_KIT_PHP_VERSION=8.5 WP_KIT_GIT_PROVIDER=github WP_KIT_ACF_PRO=false`
|
|
32
|
+
(see `lib/prompts/index.js` for the full list: `WP_KIT_CONTENT_MODULES`, `WP_KIT_DEV_ENVIRONMENT`,
|
|
33
|
+
...).
|
|
48
34
|
|
|
49
|
-
##
|
|
35
|
+
## Requirements
|
|
50
36
|
|
|
51
|
-
- Node.js
|
|
52
|
-
- npm
|
|
37
|
+
- Node.js 20+ and npm, to run the generator
|
|
53
38
|
- Git
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
| `
|
|
65
|
-
|
|
|
66
|
-
| `
|
|
67
|
-
|
|
|
68
|
-
| `
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
39
|
+
- Docker Engine with Compose v2, to run the generated project
|
|
40
|
+
- Composer on the host only when generating the Sage theme (`composer create-project`)
|
|
41
|
+
|
|
42
|
+
PHP, Composer and Node.js of the project itself run inside the containers. Supported project PHP
|
|
43
|
+
versions: 8.3, 8.4 and 8.5 (the Sage theme needs 8.4 or newer).
|
|
44
|
+
|
|
45
|
+
## The generated project
|
|
46
|
+
|
|
47
|
+
| Area | What you get |
|
|
48
|
+
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
49
|
+
| Environment | kivo-wp: `compose.yaml` with `app` (serversideup/php fpm-nginx), `db` (MySQL 8.4), `cache` (Valkey), `proxy` (Caddy with a local CA), `node` and `mail` (Mailpit); a `Dockerfile` with development and production targets; a devcontainer for Codespaces |
|
|
50
|
+
| Runner | `bin/` scripts: `setup`, `up`, `down`, `wp`, `composer`, `npm`, `build`, `dev`, `db`, `db-export`, `db-import`, `seed`, `test`, `stan`, `mago`, `e2e`, `xdebug`, `trust-cert` and more |
|
|
51
|
+
| WordPress | Core in `wp/` from `roots/wordpress`, content in `content/`, settings from `.env` |
|
|
52
|
+
| Quality | oxlint and oxfmt (JavaScript, JSON, YAML, Markdown), Mago (PHP format and lint), PHPStan with the WordPress extension, commitlint, Husky and lint-staged |
|
|
53
|
+
| Tests | Pest (`bin/test`) and Playwright (`bin/e2e`: HTTP smoke tests by default, Chromium on request) |
|
|
54
|
+
| CI | GitHub Actions, GitLab CI or Bitbucket Pipelines, from the modules you enable |
|
|
55
|
+
| Docs | `docs/` with Getting Started, Development, Troubleshooting and more |
|
|
56
|
+
| Agents | `CLAUDE.md` and the [kivo-wise](https://github.com/hekivo/kivo-wise) plugin enabled in `.claude/settings.json` |
|
|
57
|
+
|
|
58
|
+
Lando is still available as `WP_KIT_DEV_ENVIRONMENT=lando`; it is deprecated and will be removed in
|
|
59
|
+
7.0.0.
|
|
60
|
+
|
|
61
|
+
## Scaffolds
|
|
62
|
+
|
|
63
|
+
| | Sage | MU Plugin | Plugin | Blank Theme |
|
|
64
|
+
| ------------- | ----------------------- | --------------------------- | ------------------------ | ----------------------- |
|
|
65
|
+
| **Directory** | `content/themes/{name}` | `content/mu-plugins/{name}` | `content/plugins/{name}` | `content/themes/{name}` |
|
|
66
|
+
| **PHP** | Acorn + Blade | PSR-4, optional Acorn | PSR-4 | Minimal |
|
|
67
|
+
| **JS/CSS** | Vite | — | — | Vite + SCSS |
|
|
68
|
+
| **ACF** | ACF Composer | — | — | — |
|
|
69
|
+
| **Lint** | Mago, oxlint, Stylelint | Mago | Mago | oxlint, Stylelint |
|
|
70
|
+
|
|
71
|
+
Content modules combine: a project can have Sage, an MU plugin and a plugin at the same time.
|
|
72
|
+
|
|
73
|
+
## Modules
|
|
74
|
+
|
|
75
|
+
| Module | What it does |
|
|
76
|
+
| ------------- | ------------------------------------------------------------------------------------ |
|
|
77
|
+
| `kivo-wp` | Docker Compose environment, `Dockerfile`, `bin/` runner, devcontainer, fixtures |
|
|
78
|
+
| `git` | Repository, Husky, commitlint, lint-staged, pull request template |
|
|
79
|
+
| `deploy` | CI pipeline and deploy (SSH or Docker image) |
|
|
80
|
+
| `lint` | oxlint, oxfmt, Mago, commitlint and the generated `.lintstagedrc.json` |
|
|
81
|
+
| `php` | PHPStan, Mago and Pest dependencies, `phpstan.neon.dist`, PHP wrappers for editors |
|
|
82
|
+
| `test` | Pest (`phpunit.xml`, `tests/`) and Playwright (`playwright.config.js`, `tests/e2e/`) |
|
|
83
|
+
| `sage` | Roots Sage 11 theme in `content/themes/` |
|
|
84
|
+
| `mu-plugin` | MU plugin in `content/mu-plugins/` |
|
|
85
|
+
| `plugin` | Plugin in `content/plugins/` |
|
|
86
|
+
| `blank-theme` | Vite + SCSS theme in `content/themes/` |
|
|
87
|
+
| `docs` | Project docs in `docs/` |
|
|
88
|
+
| `skills` | Enables the kivo-wise agent plugin in `.claude/settings.json` |
|
|
89
|
+
|
|
90
|
+
More detail (in Portuguese): [docs/04-Módulos.md](docs/04-Módulos.md),
|
|
91
|
+
[docs/05-CI-Dinâmico.md](docs/05-CI-Dinâmico.md). Onboarding: [docs/02-Onboarding.md](docs/02-Onboarding.md).
|
|
92
|
+
|
|
93
|
+
## Developing wp-kit
|
|
97
94
|
|
|
98
95
|
```bash
|
|
99
|
-
npm
|
|
100
|
-
npm
|
|
101
|
-
npm run
|
|
102
|
-
npm run
|
|
96
|
+
npm ci
|
|
97
|
+
npm test # generator tests (node --test)
|
|
98
|
+
npm run lint # oxlint
|
|
99
|
+
npm run format # oxfmt
|
|
100
|
+
npm run test:e2e:base # scaffold, bin/setup and smoke-test a kivo-wp stack (needs Docker)
|
|
101
|
+
npm run test:e2e:sage
|
|
103
102
|
```
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
-
|
|
108
|
-
- **Hooks:** Husky + lint-staged validam no pré-commit
|
|
109
|
-
- **Commitlint:** Valida mensagem no commit-msg
|
|
110
|
-
|
|
111
|
-
## Contribuição
|
|
112
|
-
|
|
113
|
-
Pull Requests são bem-vindos. Use commits convencionais, mudanças pequenas e atualize a documentação quando alterar comportamentos.
|
|
114
|
-
|
|
115
|
-
→ Guia completo: [docs/06-Contribuicao.md](docs/06-Contribuicao.md)
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
Para entender a fundo a arquitetura, módulos e CI dinâmico: [docs/](docs/)
|
|
104
|
+
Commits follow Conventional Commits (`feat:`, `fix:`, `docs:`, `refactor:`, `chore:`); Husky runs
|
|
105
|
+
lint-staged and commitlint. Releases are cut by release-please and published to npm by
|
|
106
|
+
`publish-npm.yml`. Contribution guide: [docs/06-Contribuicao.md](docs/06-Contribuicao.md).
|
package/lib/commands/init.js
CHANGED
|
@@ -4,12 +4,13 @@ import { fileURLToPath } from "url";
|
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
import fs from "fs-extra";
|
|
6
6
|
|
|
7
|
-
import { runPrompts } from "../prompts/index.js";
|
|
7
|
+
import { ACF_OP_REFERENCE_PLACEHOLDER, runPrompts } from "../prompts/index.js";
|
|
8
|
+
import { renderAuthTemplate } from "../utils/auth-template.js";
|
|
8
9
|
import { Generator } from "../core/generator.js";
|
|
9
10
|
import { log, color } from "../utils/logger.js";
|
|
10
11
|
import { toEnvExample } from "../utils/env-example.js";
|
|
11
|
-
import { inferCiCapabilities } from "../core/infer-ci-capabilities.js";
|
|
12
|
-
import {
|
|
12
|
+
import { inferCiCapabilities, resolveContentDir } from "../core/infer-ci-capabilities.js";
|
|
13
|
+
import { validateVersionCompatibility } from "../config/versions.js";
|
|
13
14
|
|
|
14
15
|
const __filename = fileURLToPath(import.meta.url);
|
|
15
16
|
const __dirname = path.dirname(__filename);
|
|
@@ -31,12 +32,10 @@ export const initCommand = new Command("init")
|
|
|
31
32
|
|
|
32
33
|
// 🔧 Ajustes automáticos para Sage 11
|
|
33
34
|
if (context.useSage && context.sageVersion === "11") {
|
|
34
|
-
context.phpVersion = VERSION_REGISTRY.php.latest;
|
|
35
35
|
context.nodeVersion = "24";
|
|
36
36
|
context.wpCoreVersion = "7.0";
|
|
37
37
|
|
|
38
38
|
log(color.orange, "🔧 Sage 11 selected — automatically adjusting versions:");
|
|
39
|
-
log(color.orange, ` → PHP: ${VERSION_REGISTRY.php.latest}`);
|
|
40
39
|
log(color.orange, " → Node: 24");
|
|
41
40
|
log(color.orange, " → WP Core: 7.0");
|
|
42
41
|
}
|
|
@@ -57,6 +56,8 @@ export const initCommand = new Command("init")
|
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
context.cwd = target;
|
|
59
|
+
context.contentDir = resolveContentDir(target);
|
|
60
|
+
context.enabledModules = enabledModules;
|
|
60
61
|
|
|
61
62
|
// 🧠 Inferência de capacidades de CI
|
|
62
63
|
context.ci = inferCiCapabilities(context);
|
|
@@ -83,25 +84,24 @@ export const initCommand = new Command("init")
|
|
|
83
84
|
// Keys-only companion that is safe to commit; the real file stays ignored.
|
|
84
85
|
const envFile = ".env";
|
|
85
86
|
const envContent = await fs.readFile(path.join(target, envFile), "utf8");
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
// kivo-wp keeps its non-secret local defaults in the example (D-028); bin/setup copies it and
|
|
88
|
+
// generates the secret values. Lando keeps a keys-only example.
|
|
89
|
+
await fs.outputFile(
|
|
90
|
+
path.join(target, `${envFile}.example`),
|
|
91
|
+
toEnvExample(envContent, { keepValue: () => context.dev_environment === "kivo-wp" }),
|
|
92
|
+
);
|
|
93
|
+
// D-014: no licence key is ever written by the generator; auth.json is rendered from these
|
|
94
|
+
// op:// references by bin/setup (kivo-wp) or by `op inject` (Lando), and stays gitignored.
|
|
95
|
+
if (context.enable_acf_pro) {
|
|
96
|
+
await fs.outputFile(
|
|
97
|
+
path.join(target, "auth.json.tpl"),
|
|
98
|
+
renderAuthTemplate(context.acf_op_reference || ACF_OP_REFERENCE_PLACEHOLDER),
|
|
93
99
|
);
|
|
94
|
-
log(color.orange, " See: https://www.advancedcustomfields.com/my-account/");
|
|
95
100
|
}
|
|
96
101
|
await generator.generateFile(".editorconfig", context);
|
|
97
102
|
await generator.generateFile("server/cmd/install-wp.sh", context);
|
|
98
103
|
await generator.generateFile("server/cmd/setup-php.sh", context);
|
|
99
104
|
await generator.generateFile("server/cmd/setup-node.sh", context);
|
|
100
|
-
await generator.generateFile(".devcontainer/devcontainer.json", context);
|
|
101
|
-
await generator.generateFile(".devcontainer/docker-compose.yml", context);
|
|
102
|
-
await generator.generateFile(".devcontainer/Dockerfile", context);
|
|
103
|
-
await generator.generateFile(".devcontainer/setup.sh", context);
|
|
104
|
-
await generator.generateFile(".devcontainer/config/nginx.conf", context);
|
|
105
105
|
|
|
106
106
|
await generator.copyFile(".cspell.json");
|
|
107
107
|
|
|
@@ -117,14 +117,13 @@ export const initCommand = new Command("init")
|
|
|
117
117
|
await fs.chmod(path.join(target, "server/cmd/install-wp.sh"), 0o755);
|
|
118
118
|
await fs.chmod(path.join(target, "server/cmd/setup-php.sh"), 0o755);
|
|
119
119
|
await fs.chmod(path.join(target, "server/cmd/setup-node.sh"), 0o755);
|
|
120
|
-
await fs.chmod(path.join(target, ".devcontainer/setup.sh"), 0o755);
|
|
121
120
|
|
|
122
121
|
await generator.generateFile("server/www/vhosts.conf", context);
|
|
123
122
|
if (context.useRocket) {
|
|
124
123
|
await generator.copyFile("server/www/rocket.conf");
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
await generator.
|
|
126
|
+
await generator.generateFile("wp-config.php", context);
|
|
128
127
|
await generator.copyFile("index.php");
|
|
129
128
|
await generator.generateFile("wp-cli.yml", context);
|
|
130
129
|
|
|
@@ -146,12 +145,15 @@ export const initCommand = new Command("init")
|
|
|
146
145
|
mergeStrategy: "concat",
|
|
147
146
|
});
|
|
148
147
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
// The Landofile belongs to the deprecated Lando choice only (D-008); kivo-wp renders compose.yaml.
|
|
149
|
+
if (context.dev_environment === "lando") {
|
|
150
|
+
await generator.generateModularFile({
|
|
151
|
+
baseTemplate: ".lando.yml",
|
|
152
|
+
modules: enabledModules,
|
|
153
|
+
context,
|
|
154
|
+
mergeStrategy: "concat",
|
|
155
|
+
});
|
|
156
|
+
}
|
|
155
157
|
|
|
156
158
|
await generator.generateModularFile({
|
|
157
159
|
baseTemplate: "workspace.json",
|
package/lib/config/versions.js
CHANGED
|
@@ -30,7 +30,8 @@ export const VERSION_REGISTRY = {
|
|
|
30
30
|
sage: {
|
|
31
31
|
11: {
|
|
32
32
|
tag: "v11.0.1",
|
|
33
|
-
|
|
33
|
+
// Q-032: the theme requires roots/acorn-ai, which needs PHP 8.4+.
|
|
34
|
+
minPhp: "8.4",
|
|
34
35
|
acornVersion: "6.1.0",
|
|
35
36
|
nodeMin: "20",
|
|
36
37
|
status: "active",
|
|
@@ -83,8 +84,33 @@ export const VERSION_REGISTRY = {
|
|
|
83
84
|
18: { start: "2022-10-25", end: "2025-04-30" },
|
|
84
85
|
},
|
|
85
86
|
},
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* kivo-wp images (Docker Compose environment). Pinned so every project builds the same
|
|
90
|
+
* stack; the scheduled tag check in wp-kit CI catches a removed tag.
|
|
91
|
+
*/
|
|
92
|
+
kivoWp: {
|
|
93
|
+
// serversideup/php release suffix: serversideup/php:<php>-fpm-nginx-<release>
|
|
94
|
+
serversidePhpRelease: "v5.2.1",
|
|
95
|
+
images: {
|
|
96
|
+
db: "mysql:8.4",
|
|
97
|
+
cache: "valkey/valkey:8.1.12-alpine",
|
|
98
|
+
proxy: "caddy:2.11.9-alpine",
|
|
99
|
+
mail: "axllent/mailpit:v1.34.0",
|
|
100
|
+
},
|
|
101
|
+
wpCli: {
|
|
102
|
+
version: "2.12.0",
|
|
103
|
+
sha512:
|
|
104
|
+
"be928f6b8ca1e8dfb9d2f4b75a13aa4aee0896f8a9a0a1c45cd5d2c98605e6172e6d014dda2e27f88c98befc16c040cbb2bd1bfa121510ea5cdf5f6a30fe8832",
|
|
105
|
+
},
|
|
106
|
+
},
|
|
86
107
|
};
|
|
87
108
|
|
|
109
|
+
/** Base image of the kivo-wp app service for a PHP version. */
|
|
110
|
+
export function serversidePhpImage(phpVersion) {
|
|
111
|
+
return `serversideup/php:${phpVersion}-fpm-nginx-${VERSION_REGISTRY.kivoWp.serversidePhpRelease}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
88
114
|
/**
|
|
89
115
|
* Helper functions for version management
|
|
90
116
|
*/
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosts a Claude Code cloud session needs in Limited network mode for a kivo-wp project
|
|
3
|
+
* (spec section 4, kivo-wise spec S-6). Generated from the enabled modules; rendered into
|
|
4
|
+
* docs/cloud-sessions.md.
|
|
5
|
+
*/
|
|
6
|
+
const BASE_HOSTS = [
|
|
7
|
+
// Docker Hub
|
|
8
|
+
"registry-1.docker.io",
|
|
9
|
+
"auth.docker.io",
|
|
10
|
+
"production.cloudflare.docker.com",
|
|
11
|
+
// GitHub container registry and its layer storage
|
|
12
|
+
"ghcr.io",
|
|
13
|
+
"pkg-containers.githubusercontent.com",
|
|
14
|
+
// Composer
|
|
15
|
+
"repo.packagist.org",
|
|
16
|
+
"packagist.org",
|
|
17
|
+
"wpackagist.org",
|
|
18
|
+
// npm
|
|
19
|
+
"registry.npmjs.org",
|
|
20
|
+
// WordPress.org API and downloads (core, translations)
|
|
21
|
+
"api.wordpress.org",
|
|
22
|
+
"downloads.wordpress.org",
|
|
23
|
+
// Documentation hosts used by the kivo-wise skills when no local corpus exists
|
|
24
|
+
"developer.wordpress.org",
|
|
25
|
+
"roots.io",
|
|
26
|
+
"docs.docker.com",
|
|
27
|
+
"containers.dev",
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {{ enable_acf_pro?: boolean }} context - generator context
|
|
32
|
+
* @returns {string[]} sorted, unique host names
|
|
33
|
+
*/
|
|
34
|
+
export function buildCloudAllowlist(context) {
|
|
35
|
+
const hosts = new Set(BASE_HOSTS);
|
|
36
|
+
if (context.enable_acf_pro) hosts.add("connect.advancedcustomfields.com");
|
|
37
|
+
return [...hosts].sort();
|
|
38
|
+
}
|
package/lib/core/generator.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// lib/core/generator.js
|
|
2
|
-
import path from
|
|
3
|
-
import crypto from
|
|
2
|
+
import path from "path";
|
|
3
|
+
import crypto from "crypto";
|
|
4
4
|
|
|
5
|
-
import fs from
|
|
6
|
-
import handlebars from
|
|
7
|
-
import mergeWith from
|
|
8
|
-
import yaml from
|
|
5
|
+
import fs from "fs-extra";
|
|
6
|
+
import handlebars from "handlebars";
|
|
7
|
+
import mergeWith from "lodash.mergewith";
|
|
8
|
+
import yaml from "js-yaml";
|
|
9
9
|
|
|
10
|
-
import { log, color } from
|
|
10
|
+
import { log, color } from "../utils/logger.js";
|
|
11
11
|
import {
|
|
12
12
|
PACKAGE_ROOT,
|
|
13
13
|
MODULES_PATH,
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
getModulePath,
|
|
16
16
|
getModuleTemplatePath,
|
|
17
17
|
getBaseTemplatePath,
|
|
18
|
-
} from
|
|
18
|
+
} from "../utils/paths.js";
|
|
19
19
|
|
|
20
|
-
import { HookManager } from
|
|
20
|
+
import { HookManager } from "./hook-manager.js";
|
|
21
21
|
|
|
22
22
|
export class Generator {
|
|
23
23
|
constructor(baseDir = process.cwd()) {
|
|
@@ -25,7 +25,7 @@ export class Generator {
|
|
|
25
25
|
this.hooks = new HookManager();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async copyFile(sourcePathRelative, moduleName = null, outputName =
|
|
28
|
+
async copyFile(sourcePathRelative, moduleName = null, outputName = "") {
|
|
29
29
|
const baseDir = moduleName ? getModulePath(moduleName) : PACKAGE_ROOT;
|
|
30
30
|
|
|
31
31
|
outputName = outputName ? outputName : sourcePathRelative;
|
|
@@ -44,7 +44,7 @@ export class Generator {
|
|
|
44
44
|
* @param {string} outputName - Nome da pasta de destino (opcional)
|
|
45
45
|
* @param {boolean} overwrite - Se deve sobrescrever arquivos existentes (padrão: true)
|
|
46
46
|
*/
|
|
47
|
-
async copyDirectory(sourcePathRelative, moduleName = null, outputName =
|
|
47
|
+
async copyDirectory(sourcePathRelative, moduleName = null, outputName = "", overwrite = true) {
|
|
48
48
|
const baseDir = moduleName ? getModulePath(moduleName) : PACKAGE_ROOT;
|
|
49
49
|
|
|
50
50
|
outputName = outputName ? outputName : sourcePathRelative;
|
|
@@ -107,15 +107,15 @@ export class Generator {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
async generateFile(templatePathRelative, context, moduleName = null, outputName =
|
|
111
|
-
const baseDir = moduleName ? getModuleTemplatePath(moduleName,
|
|
110
|
+
async generateFile(templatePathRelative, context, moduleName = null, outputName = "") {
|
|
111
|
+
const baseDir = moduleName ? getModuleTemplatePath(moduleName, "") : TEMPLATES_PATH;
|
|
112
112
|
|
|
113
113
|
outputName = outputName ? outputName : templatePathRelative;
|
|
114
114
|
|
|
115
|
-
const templatePath = path.resolve(baseDir, templatePathRelative +
|
|
115
|
+
const templatePath = path.resolve(baseDir, templatePathRelative + ".hbs");
|
|
116
116
|
const outputPath = path.join(this.cwd, outputName);
|
|
117
117
|
|
|
118
|
-
const content = await fs.readFile(templatePath,
|
|
118
|
+
const content = await fs.readFile(templatePath, "utf8");
|
|
119
119
|
const template = handlebars.compile(content);
|
|
120
120
|
const result = template(context);
|
|
121
121
|
|
|
@@ -132,27 +132,33 @@ export class Generator {
|
|
|
132
132
|
* @param {Object} [options.context={}] - Contexto para handlebars
|
|
133
133
|
* @param {'json'|'yaml'} [options.format='yaml'] - Formato do arquivo
|
|
134
134
|
* @param {'concat'|'replace'} [options.mergeStrategy='concat'] - Estratégia de merge de arrays
|
|
135
|
+
* @param {string} [options.baseModule] - Module that owns the base template (default: templates/)
|
|
136
|
+
* @param {string} [options.header] - Comment block written before YAML output (YAML drops comments)
|
|
135
137
|
*/
|
|
136
138
|
async generateModularFile({
|
|
137
139
|
baseTemplate,
|
|
138
|
-
|
|
140
|
+
baseModule = null,
|
|
141
|
+
header = "",
|
|
142
|
+
outputFile = "",
|
|
139
143
|
modules = [],
|
|
140
144
|
context = {},
|
|
141
|
-
format =
|
|
142
|
-
mergeStrategy =
|
|
145
|
+
format = "yaml",
|
|
146
|
+
mergeStrategy = "replace",
|
|
143
147
|
debug = false,
|
|
144
148
|
}) {
|
|
145
|
-
const baseTemplatePath =
|
|
146
|
-
|
|
149
|
+
const baseTemplatePath = baseModule
|
|
150
|
+
? getModuleTemplatePath(baseModule, baseTemplate + ".hbs")
|
|
151
|
+
: getBaseTemplatePath(baseTemplate + ".hbs");
|
|
152
|
+
const baseRaw = await fs.readFile(baseTemplatePath, "utf8");
|
|
147
153
|
const compiledBase = handlebars.compile(baseRaw);
|
|
148
154
|
outputFile = outputFile ? outputFile : baseTemplate;
|
|
149
155
|
let mergedOutput;
|
|
150
156
|
try {
|
|
151
157
|
mergedOutput =
|
|
152
|
-
format ===
|
|
158
|
+
format === "json" ? JSON.parse(compiledBase(context)) : yaml.load(compiledBase(context));
|
|
153
159
|
} catch (err) {
|
|
154
160
|
if (debug) {
|
|
155
|
-
log(color.red,
|
|
161
|
+
log(color.red, "[DEBUG] Erro ao fazer parse do template base:");
|
|
156
162
|
log(color.red, compiledBase(context));
|
|
157
163
|
log(color.red, err);
|
|
158
164
|
}
|
|
@@ -161,20 +167,20 @@ export class Generator {
|
|
|
161
167
|
|
|
162
168
|
function customizer(objValue, srcValue) {
|
|
163
169
|
if (Array.isArray(objValue) && Array.isArray(srcValue)) {
|
|
164
|
-
return mergeStrategy ===
|
|
170
|
+
return mergeStrategy === "concat" ? objValue.concat(srcValue) : srcValue;
|
|
165
171
|
}
|
|
166
172
|
}
|
|
167
173
|
|
|
168
|
-
for (const mod of modules) {
|
|
169
|
-
const modPath = getModuleTemplatePath(mod, path.basename(baseTemplate) +
|
|
174
|
+
for (const mod of modules.filter((name) => name !== baseModule)) {
|
|
175
|
+
const modPath = getModuleTemplatePath(mod, path.basename(baseTemplate) + ".hbs");
|
|
170
176
|
|
|
171
177
|
if (await fs.pathExists(modPath)) {
|
|
172
|
-
const modRaw = await fs.readFile(modPath,
|
|
178
|
+
const modRaw = await fs.readFile(modPath, "utf8");
|
|
173
179
|
const compiledMod = handlebars.compile(modRaw);
|
|
174
180
|
let modParsed;
|
|
175
181
|
try {
|
|
176
182
|
modParsed =
|
|
177
|
-
format ===
|
|
183
|
+
format === "json" ? JSON.parse(compiledMod(context)) : yaml.load(compiledMod(context));
|
|
178
184
|
} catch (err) {
|
|
179
185
|
if (debug) {
|
|
180
186
|
log(color.red, `[DEBUG] Erro ao fazer parse do template do módulo ${mod}:`);
|
|
@@ -188,9 +194,9 @@ export class Generator {
|
|
|
188
194
|
}
|
|
189
195
|
|
|
190
196
|
const finalOutput =
|
|
191
|
-
format ===
|
|
197
|
+
format === "json"
|
|
192
198
|
? JSON.stringify(mergedOutput, null, 2)
|
|
193
|
-
: yaml.dump(mergedOutput, { lineWidth: 120 });
|
|
199
|
+
: (header ? `${header}\n` : "") + yaml.dump(mergedOutput, { lineWidth: 120, noRefs: true });
|
|
194
200
|
|
|
195
201
|
const outputPath = path.join(this.cwd, outputFile);
|
|
196
202
|
await fs.outputFile(outputPath, finalOutput);
|
|
@@ -201,9 +207,9 @@ export class Generator {
|
|
|
201
207
|
existingFile,
|
|
202
208
|
moduleTemplatePath,
|
|
203
209
|
context,
|
|
204
|
-
format =
|
|
210
|
+
format = "json",
|
|
205
211
|
moduleName = null,
|
|
206
|
-
mergeStrategy =
|
|
212
|
+
mergeStrategy = "replace",
|
|
207
213
|
debug = false,
|
|
208
214
|
}) {
|
|
209
215
|
const existingPath = path.isAbsolute(existingFile)
|
|
@@ -215,31 +221,31 @@ export class Generator {
|
|
|
215
221
|
throw new Error(`File to merge not found: ${existingPath}`);
|
|
216
222
|
}
|
|
217
223
|
|
|
218
|
-
const existingRaw = await fs.readFile(existingPath,
|
|
224
|
+
const existingRaw = await fs.readFile(existingPath, "utf8");
|
|
219
225
|
let existingParsed;
|
|
220
226
|
try {
|
|
221
|
-
existingParsed = format ===
|
|
227
|
+
existingParsed = format === "json" ? JSON.parse(existingRaw) : yaml.load(existingRaw);
|
|
222
228
|
} catch (err) {
|
|
223
229
|
if (debug) {
|
|
224
|
-
log(color.red,
|
|
230
|
+
log(color.red, "[DEBUG] Erro ao fazer parse do arquivo existente:");
|
|
225
231
|
log(color.red, existingRaw);
|
|
226
232
|
log(color.red, err);
|
|
227
233
|
}
|
|
228
234
|
throw err;
|
|
229
235
|
}
|
|
230
236
|
|
|
231
|
-
const moduleBase = moduleName ? getModuleTemplatePath(moduleName,
|
|
232
|
-
const templatePath = path.resolve(moduleBase, moduleTemplatePath +
|
|
237
|
+
const moduleBase = moduleName ? getModuleTemplatePath(moduleName, "") : TEMPLATES_PATH;
|
|
238
|
+
const templatePath = path.resolve(moduleBase, moduleTemplatePath + ".hbs");
|
|
233
239
|
|
|
234
|
-
const modRaw = await fs.readFile(templatePath,
|
|
240
|
+
const modRaw = await fs.readFile(templatePath, "utf8");
|
|
235
241
|
const compiledMod = handlebars.compile(modRaw);
|
|
236
242
|
let modParsed;
|
|
237
243
|
try {
|
|
238
244
|
modParsed =
|
|
239
|
-
format ===
|
|
245
|
+
format === "json" ? JSON.parse(compiledMod(context)) : yaml.load(compiledMod(context));
|
|
240
246
|
} catch (err) {
|
|
241
247
|
if (debug) {
|
|
242
|
-
log(color.red,
|
|
248
|
+
log(color.red, "[DEBUG] Erro ao fazer parse do template do módulo:");
|
|
243
249
|
log(color.red, compiledMod(context));
|
|
244
250
|
log(color.red, err);
|
|
245
251
|
}
|
|
@@ -248,14 +254,14 @@ export class Generator {
|
|
|
248
254
|
|
|
249
255
|
function customizer(objValue, srcValue) {
|
|
250
256
|
if (Array.isArray(objValue) && Array.isArray(srcValue)) {
|
|
251
|
-
return mergeStrategy ===
|
|
257
|
+
return mergeStrategy === "concat" ? objValue.concat(srcValue) : srcValue;
|
|
252
258
|
}
|
|
253
259
|
}
|
|
254
260
|
|
|
255
261
|
const merged = mergeWith({}, existingParsed, modParsed, customizer);
|
|
256
262
|
|
|
257
263
|
const output =
|
|
258
|
-
format ===
|
|
264
|
+
format === "json" ? JSON.stringify(merged, null, 2) : yaml.dump(merged, { lineWidth: 120 });
|
|
259
265
|
|
|
260
266
|
await fs.outputFile(existingPath, output);
|
|
261
267
|
log(color.blue, `🔀 Merged into: ${existingPath}`);
|
|
@@ -263,16 +269,16 @@ export class Generator {
|
|
|
263
269
|
|
|
264
270
|
static generateSalts() {
|
|
265
271
|
return [
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
"AUTH_KEY",
|
|
273
|
+
"SECURE_AUTH_KEY",
|
|
274
|
+
"LOGGED_IN_KEY",
|
|
275
|
+
"NONCE_KEY",
|
|
276
|
+
"AUTH_SALT",
|
|
277
|
+
"SECURE_AUTH_SALT",
|
|
278
|
+
"LOGGED_IN_SALT",
|
|
279
|
+
"NONCE_SALT",
|
|
274
280
|
].reduce((acc, key) => {
|
|
275
|
-
acc[key] = crypto.randomBytes(64).toString(
|
|
281
|
+
acc[key] = crypto.randomBytes(64).toString("base64");
|
|
276
282
|
return acc;
|
|
277
283
|
}, {});
|
|
278
284
|
}
|