@codigodoleo/wp-kit 6.0.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/utils/git.js +5 -188
- package/modules/docs/templates/docs/Development.md.hbs +35 -4
- package/modules/docs/templates/docs/Troubleshooting.md.hbs +16 -0
- package/modules/git/.husky/kivo-wp/pre-commit +1 -1
- package/modules/git/.lintstagedrc.json +5 -2
- package/modules/kivo-wp/templates/Dockerfile.hbs +2 -0
- package/modules/kivo-wp/templates/bin/_lib.sh.hbs +23 -2
- package/modules/kivo-wp/templates/bin/db-export.hbs +11 -1
- package/modules/kivo-wp/templates/bin/db-import.hbs +8 -2
- package/modules/kivo-wp/templates/bin/db.hbs +1 -4
- package/modules/kivo-wp/templates/bin/e2e.hbs +31 -3
- package/modules/kivo-wp/templates/bin/mago.hbs +3 -1
- package/modules/kivo-wp/templates/bin/seed.hbs +3 -1
- package/modules/kivo-wp/templates/bin/stan.hbs +3 -1
- package/modules/lint/index.js +9 -5
- package/modules/php/index.js +5 -0
- package/modules/php/templates/phpstan.neon.dist.hbs +27 -0
- package/modules/sage/index.js +3 -1
- package/modules/skills/index.js +56 -11
- package/modules/skills/prompts.js +3 -16
- package/modules/test/index.js +1 -0
- package/modules/test/phpunit.xml +18 -0
- package/modules/test/templates/playwright.config.js.hbs +11 -0
- package/modules/test/tests/SmokeTest.php +8 -9
- package/modules/test/tests/e2e/smoke.spec.js +1 -1
- package/package.json +1 -1
- package/templates/.gitignore.hbs +1 -0
- package/templates/CLAUDE.md.hbs +14 -13
- package/templates/README.md.hbs +38 -12
- package/templates/composer.json.hbs +1 -1
- package/templates/wp-config.php.hbs +14 -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/utils/git.js
CHANGED
|
@@ -1,200 +1,17 @@
|
|
|
1
|
-
import { execSync
|
|
2
|
-
import os from 'os';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
|
|
5
|
-
import fs from 'fs-extra';
|
|
6
|
-
|
|
7
|
-
import { log, color } from './logger.js';
|
|
8
|
-
|
|
9
|
-
const CLAUDE_PLUGIN_SUPERPOWERS_SAGE = '.claude/plugins/superpowers-sage';
|
|
10
|
-
const CLAUDE_PLUGIN_SUPERPOWERS = '.claude/plugins/superpowers';
|
|
1
|
+
import { execSync } from "child_process";
|
|
11
2
|
|
|
12
3
|
export function getGitUserDefaults() {
|
|
13
4
|
const exec = (cmd) => {
|
|
14
5
|
try {
|
|
15
6
|
return execSync(cmd).toString().trim();
|
|
16
7
|
} catch {
|
|
17
|
-
return
|
|
8
|
+
return "";
|
|
18
9
|
}
|
|
19
10
|
};
|
|
20
11
|
|
|
21
12
|
return {
|
|
22
|
-
author: exec(
|
|
23
|
-
authorEmail: exec(
|
|
24
|
-
gitRepository: exec(
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Dirs que cada destino copia do repositório superpowers-sage.
|
|
30
|
-
* A subpasta de destino dentro do projeto é TARGET_CONFIG[key].dest.
|
|
31
|
-
*/
|
|
32
|
-
const TARGET_CONFIG = {
|
|
33
|
-
claude: {
|
|
34
|
-
dest: CLAUDE_PLUGIN_SUPERPOWERS_SAGE,
|
|
35
|
-
dirs: ['.claude-plugin', 'skills', 'agents', 'hooks'],
|
|
36
|
-
label: 'Claude Code (.claude/)',
|
|
37
|
-
},
|
|
38
|
-
cursor: {
|
|
39
|
-
dest: '.cursor/plugins/local/superpowers-sage',
|
|
40
|
-
dirs: ['.cursor-plugin', 'skills', 'agents', 'hooks', 'rules'],
|
|
41
|
-
label: 'Cursor (.cursor/)',
|
|
42
|
-
},
|
|
43
|
-
ai: {
|
|
44
|
-
dest: '.ai/superpowers-sage',
|
|
45
|
-
dirs: ['skills', 'agents', 'hooks'],
|
|
46
|
-
label: 'Agnóstico (.ai/)',
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const CLAUDE_SETTINGS_BASELINE = {
|
|
51
|
-
$schema: 'https://json.schemastore.org/claude-code-settings.json',
|
|
52
|
-
permissions: {
|
|
53
|
-
deny: [
|
|
54
|
-
'Read(./.env)',
|
|
55
|
-
'Read(./.env.*)',
|
|
56
|
-
'Read(./secrets/**)',
|
|
57
|
-
'Read(./config/credentials.json)',
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
function mergeUnique(base = [], extra = []) {
|
|
63
|
-
return [...new Set([...(Array.isArray(base) ? base : []), ...extra])];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function mergeClaudeSettings(existing = {}, incoming = {}) {
|
|
67
|
-
const merged = { ...existing, ...incoming };
|
|
68
|
-
|
|
69
|
-
const existingPermissions = existing.permissions ?? {};
|
|
70
|
-
const incomingPermissions = incoming.permissions ?? {};
|
|
71
|
-
|
|
72
|
-
merged.permissions = {
|
|
73
|
-
...existingPermissions,
|
|
74
|
-
...incomingPermissions,
|
|
75
|
-
deny: mergeUnique(existingPermissions.deny, incomingPermissions.deny),
|
|
13
|
+
author: exec("git config --get user.name") || "Developer",
|
|
14
|
+
authorEmail: exec("git config --get user.email") || "developer@example.com",
|
|
15
|
+
gitRepository: exec("git config --get remote.origin.url") || "",
|
|
76
16
|
};
|
|
77
|
-
|
|
78
|
-
merged.enabledPlugins = {
|
|
79
|
-
...(existing.enabledPlugins ?? {}),
|
|
80
|
-
...(incoming.enabledPlugins ?? {}),
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
return merged;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async function updateClaudeProjectSettings(targetDir, enabledPlugins = {}) {
|
|
87
|
-
const claudeDir = path.join(targetDir, '.claude');
|
|
88
|
-
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
89
|
-
|
|
90
|
-
await fs.ensureDir(claudeDir);
|
|
91
|
-
|
|
92
|
-
let existing = {};
|
|
93
|
-
if (await fs.pathExists(settingsPath)) {
|
|
94
|
-
try {
|
|
95
|
-
existing = await fs.readJson(settingsPath);
|
|
96
|
-
} catch {
|
|
97
|
-
log(
|
|
98
|
-
color.orange,
|
|
99
|
-
'[skills] .claude/settings.json invalido. Recriando com baseline seguro + plugins instalados.'
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const nextSettings = mergeClaudeSettings(existing, {
|
|
105
|
-
...CLAUDE_SETTINGS_BASELINE,
|
|
106
|
-
enabledPlugins,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
await fs.writeJson(settingsPath, nextSettings, { spaces: 2 });
|
|
110
|
-
log(
|
|
111
|
-
color.green,
|
|
112
|
-
'✅ .claude/settings.json atualizado com plugins locais e baseline de seguranca.'
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function cloneRepo(repo, tmpDir) {
|
|
117
|
-
return spawnSync('git', ['clone', '--depth=1', repo, tmpDir], {
|
|
118
|
-
stdio: 'inherit',
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Clona codigodoleo/superpowers-sage e copia o conteúdo para os destinos selecionados.
|
|
124
|
-
* Requer git instalado no host.
|
|
125
|
-
*
|
|
126
|
-
* @param {string} targetDir - Caminho absoluto do projeto gerado
|
|
127
|
-
* @param {string[]} targets - Lista de destinos: 'claude' | 'cursor' | 'ai'
|
|
128
|
-
*/
|
|
129
|
-
export async function installSuperpowersSage(targetDir, targets = ['claude']) {
|
|
130
|
-
const sageRepo = 'https://github.com/codigodoleo/superpowers-sage.git';
|
|
131
|
-
const baseRepo = 'https://github.com/obra/superpowers.git';
|
|
132
|
-
const tmpDir = path.join(os.tmpdir(), `superpowers-sage-${Date.now()}`);
|
|
133
|
-
const tmpBaseDir = path.join(os.tmpdir(), `superpowers-base-${Date.now()}`);
|
|
134
|
-
|
|
135
|
-
const validTargets = targets.filter((t) => TARGET_CONFIG[t]);
|
|
136
|
-
if (validTargets.length === 0) {
|
|
137
|
-
log(color.orange, '[skills] Nenhum destino válido informado. Pulando.');
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
log(color.blue, `🔌 Clonando superpowers-sage para: ${validTargets.join(', ')}...`);
|
|
142
|
-
|
|
143
|
-
const result = cloneRepo(sageRepo, tmpDir);
|
|
144
|
-
|
|
145
|
-
if (result.status !== 0) {
|
|
146
|
-
log(
|
|
147
|
-
color.orange,
|
|
148
|
-
'⚠️ Não foi possível clonar superpowers-sage (sem rede ou git indisponível). Pulando.'
|
|
149
|
-
);
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
for (const key of validTargets) {
|
|
154
|
-
const cfg = TARGET_CONFIG[key];
|
|
155
|
-
const destBase = path.join(targetDir, cfg.dest);
|
|
156
|
-
|
|
157
|
-
await fs.ensureDir(destBase);
|
|
158
|
-
|
|
159
|
-
for (const dir of cfg.dirs) {
|
|
160
|
-
const srcDir = path.join(tmpDir, dir);
|
|
161
|
-
if (!(await fs.pathExists(srcDir))) continue;
|
|
162
|
-
|
|
163
|
-
const destDir = path.join(destBase, dir);
|
|
164
|
-
await fs.copy(srcDir, destDir, { overwrite: true });
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
log(color.green, `✅ superpowers-sage instalado em ${cfg.dest}`);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const claudeEnabledPlugins = {
|
|
171
|
-
'superpowers-sage@superpowers-sage-marketplace': true,
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
if (validTargets.includes('claude')) {
|
|
175
|
-
log(color.blue, '🔌 Clonando superpowers (base) para Claude Code...');
|
|
176
|
-
|
|
177
|
-
const baseResult = cloneRepo(baseRepo, tmpBaseDir);
|
|
178
|
-
if (baseResult.status !== 0) {
|
|
179
|
-
log(
|
|
180
|
-
color.orange,
|
|
181
|
-
'⚠️ Nao foi possivel clonar obra/superpowers. O plugin base nao foi instalado localmente.'
|
|
182
|
-
);
|
|
183
|
-
} else {
|
|
184
|
-
const baseDest = path.join(targetDir, CLAUDE_PLUGIN_SUPERPOWERS);
|
|
185
|
-
await fs.ensureDir(baseDest);
|
|
186
|
-
await fs.copy(tmpBaseDir, baseDest, {
|
|
187
|
-
overwrite: true,
|
|
188
|
-
filter: (src) =>
|
|
189
|
-
!src.includes(`${path.sep}.git${path.sep}`) && !src.endsWith(`${path.sep}.git`),
|
|
190
|
-
});
|
|
191
|
-
claudeEnabledPlugins['superpowers@superpowers-dev'] = true;
|
|
192
|
-
log(color.green, `✅ superpowers instalado em ${CLAUDE_PLUGIN_SUPERPOWERS}`);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
await updateClaudeProjectSettings(targetDir, claudeEnabledPlugins);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
await fs.remove(tmpDir);
|
|
199
|
-
await fs.remove(tmpBaseDir);
|
|
200
17
|
}
|
|
@@ -21,8 +21,12 @@ bin/npm <args> # npm (bin/node for Node.js)
|
|
|
21
21
|
bin/build # build the theme assets
|
|
22
22
|
bin/dev # Vite dev server with HMR
|
|
23
23
|
bin/flush # flush WordPress, Acorn and object caches
|
|
24
|
-
bin/
|
|
25
|
-
bin/
|
|
24
|
+
bin/db # MySQL client in the db service (echo 'select 1;' | bin/db)
|
|
25
|
+
bin/db-export [file] # dump the local database (mysqldump in the db service)
|
|
26
|
+
bin/test # PHP tests (Pest, phpunit.xml)
|
|
27
|
+
bin/stan # PHPStan (phpstan.neon.dist)
|
|
28
|
+
bin/mago [command] # Mago: lint by default, bin/mago format to format
|
|
29
|
+
bin/e2e # Playwright smoke tests (HTTP only, no browser)
|
|
26
30
|
bin/xdebug on|off # toggle Xdebug without a rebuild
|
|
27
31
|
bin/shell [service] # shell in a service
|
|
28
32
|
```
|
|
@@ -59,6 +63,11 @@ and cloud agent sessions.
|
|
|
59
63
|
refuses to run when `CI`, `CODESPACES` or `CLAUDE_CODE_REMOTE` is set, and agents must never run it.
|
|
60
64
|
Sanitizing the snapshot (for example `wp db export` without sensitive tables, then an anonymizing
|
|
61
65
|
`wp search-replace`) is the responsibility of whoever produces it.
|
|
66
|
+
|
|
67
|
+
The app image has no MySQL client, so the `bin/wp db` commands that shell out to it (`wp db export`,
|
|
68
|
+
`wp db import`, `wp db query`, `wp db reset`) fail there. `bin/db`, `bin/db-export` and
|
|
69
|
+
`bin/db-import` run the client of the `db` service instead; `bin/seed --reset` recreates the
|
|
70
|
+
database the same way.
|
|
62
71
|
{{else}}
|
|
63
72
|
## Local environment (Lando, deprecated)
|
|
64
73
|
|
|
@@ -187,9 +196,31 @@ checked; CI re-runs the full sweep.
|
|
|
187
196
|
|
|
188
197
|
## Tests
|
|
189
198
|
|
|
199
|
+
{{#if enable_kivo_wp}}
|
|
200
|
+
- **PHP**: Pest tests in `tests/` (every `*Test.php` file, configured by `phpunit.xml`). Run them
|
|
201
|
+
with `bin/test`; arguments pass through (`bin/test --filter=Smoke`).
|
|
202
|
+
- **Static analysis**: `bin/stan` runs PHPStan with `phpstan.neon.dist` (level 5, WordPress
|
|
203
|
+
extension). Add your plugin and MU plugin code to its `paths`.
|
|
204
|
+
- **E2E**: Playwright specs under `tests/e2e/`. `bin/e2e` runs the `smoke` project: HTTP checks of
|
|
205
|
+
the running site that need no browser.
|
|
206
|
+
|
|
207
|
+
### End-to-end tests in a browser
|
|
208
|
+
|
|
209
|
+
The `chromium` project (`tests/e2e/example.spec.js`) needs Chromium, its system libraries and
|
|
210
|
+
`certutil` in the `node` service, which the `node` image does not ship. Install them once per
|
|
211
|
+
container (they are lost when the container is recreated), then select the project:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
bin/e2e --install-chromium # system libraries and certutil (as root), then the browser
|
|
215
|
+
bin/e2e --project=chromium
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
`bin/e2e` adds Caddy's local CA to the browser's certificate store and the Playwright config sends
|
|
219
|
+
the project host names to the `proxy` service, so no TLS error is ignored.
|
|
220
|
+
{{else}}
|
|
190
221
|
- **PHP**: `{{ "{{TODO: Pest suite location and how to invoke it}}" }}`
|
|
191
|
-
- **E2E**: Playwright specs under `tests/e2e/`. Run locally with
|
|
192
|
-
|
|
222
|
+
- **E2E**: Playwright specs under `tests/e2e/`. Run locally with `npm run test:e2e`.
|
|
223
|
+
{{/if}}
|
|
193
224
|
- **Visual regression**: `{{ "{{TODO: define if/how visual regression is captured}}" }}`
|
|
194
225
|
|
|
195
226
|
## Releases
|
|
@@ -33,6 +33,22 @@ set by `HTTPS_PORT` or `HTTP_PORT` in `.env`.
|
|
|
33
33
|
**Why this is the fix**: Caddy publishes the host ports from `.env`; `bin/setup` keeps the site URL in
|
|
34
34
|
step with them and rewrites stored URLs.
|
|
35
35
|
|
|
36
|
+
### WP-CLI prints "PHP Deprecated: Using null as an array offset"
|
|
37
|
+
|
|
38
|
+
**Symptom**: on PHP 8.5, `bin/wp` (and `bin/setup`, which calls it) prints
|
|
39
|
+
`PHP Deprecated: Using null as an array offset is deprecated` from
|
|
40
|
+
`phar:///usr/local/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/Colors.php` before the command output.
|
|
41
|
+
**Likely cause**: WP-CLI 2.12.0, the latest release, bundles a `php-cli-tools` version written
|
|
42
|
+
before PHP 8.5. The notice comes from WP-CLI itself, not from the project code.
|
|
43
|
+
**Fix**:
|
|
44
|
+
|
|
45
|
+
1. Ignore it: the command still runs and its result is correct.
|
|
46
|
+
2. When WP-CLI publishes a release with the fix, update `WP_CLI_VERSION` and `WP_CLI_SHA512` in the
|
|
47
|
+
`Dockerfile` and rebuild with `bin/setup`.
|
|
48
|
+
|
|
49
|
+
**Why this is the fix**: the notice is a deprecation, not an error, and only a new WP-CLI phar
|
|
50
|
+
removes it; hiding deprecations would also hide the project's own.
|
|
51
|
+
|
|
36
52
|
{{else}}
|
|
37
53
|
### `lando start` fails with "port already in use"
|
|
38
54
|
|
|
@@ -17,7 +17,7 @@ php_files="$(git diff --cached --name-only --diff-filter=ACMR -- '*.php')"
|
|
|
17
17
|
if [ -n "$php_files" ] && [ -f vendor/bin/mago ]; then
|
|
18
18
|
echo "🐘 Formatting staged PHP files with Mago..."
|
|
19
19
|
echo "$php_files" | while IFS= read -r file; do
|
|
20
|
-
bin/mago format
|
|
20
|
+
bin/mago format "$file"
|
|
21
21
|
git add -- "$file"
|
|
22
22
|
done
|
|
23
23
|
fi
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"*.{js,mjs,ts,vue,jsx,tsx}": [
|
|
3
|
-
|
|
2
|
+
"*.{js,mjs,ts,vue,jsx,tsx}": [
|
|
3
|
+
"oxfmt --write --no-error-on-unmatched-pattern",
|
|
4
|
+
"oxlint --fix --no-error-on-unmatched-pattern"
|
|
5
|
+
],
|
|
6
|
+
"*.{json,jsonc,html,yml,yaml,md,mdx}": ["oxfmt --write --no-error-on-unmatched-pattern"]
|
|
4
7
|
}
|
|
@@ -9,6 +9,8 @@ FROM serversideup/php:${PHP_VERSION}-fpm-nginx-{{kivoWp.serversidePhpRelease}} A
|
|
|
9
9
|
|
|
10
10
|
USER root
|
|
11
11
|
|
|
12
|
+
# WP-CLI 2.12.0 is the latest release; on PHP 8.5 its bundled php-cli-tools prints a
|
|
13
|
+
# "Using null as an array offset" deprecation (docs/Troubleshooting.md).
|
|
12
14
|
ARG WP_CLI_VERSION={{kivoWp.wpCli.version}}
|
|
13
15
|
ARG WP_CLI_SHA512={{kivoWp.wpCli.sha512}}
|
|
14
16
|
|
|
@@ -53,7 +53,8 @@ kivo_wp_workdir() {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
# Run a command in a service. -T when stdin or stdout is not a terminal, so piped input
|
|
56
|
-
# (agents, MCP stdio, CI) and captured output stay byte-clean.
|
|
56
|
+
# (agents, MCP stdio, CI) and captured output stay byte-clean. Only app and node mount the
|
|
57
|
+
# project, so the other services (db, cache, mail, proxy) keep their image working directory.
|
|
57
58
|
kivo_wp_exec() {
|
|
58
59
|
local service="$1"
|
|
59
60
|
shift
|
|
@@ -62,7 +63,10 @@ kivo_wp_exec() {
|
|
|
62
63
|
if [ ! -t 0 ] || [ ! -t 1 ]; then
|
|
63
64
|
flags+=(-T)
|
|
64
65
|
fi
|
|
65
|
-
|
|
66
|
+
case "${service}" in
|
|
67
|
+
app | node) flags+=(--workdir "$(kivo_wp_workdir)") ;;
|
|
68
|
+
esac
|
|
69
|
+
kivo_wp_compose exec ${flags[@]+"${flags[@]}"} "${service}" "$@"
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
# Same as kivo_wp_exec, from a fixed container directory relative to the project root.
|
|
@@ -77,6 +81,23 @@ kivo_wp_exec_in() {
|
|
|
77
81
|
kivo_wp_compose exec ${flags[@]+"${flags[@]}"} --workdir "${KIVO_WP_CONTAINER_ROOT}/${dir}" "${service}" "$@"
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
# Run a MySQL client tool (mysql, mysqldump) in the db service as the project database user.
|
|
85
|
+
# The app image has no MySQL client; the db image ships the tools matching the server.
|
|
86
|
+
kivo_wp_db_tool() {
|
|
87
|
+
local tool="$1" user password
|
|
88
|
+
shift
|
|
89
|
+
user="$(kivo_wp_env_get WORDPRESS_DB_USER)"
|
|
90
|
+
password="$(kivo_wp_env_get WORDPRESS_DB_PASSWORD)"
|
|
91
|
+
kivo_wp_exec db env MYSQL_PWD="${password:-wordpress}" "${tool}" -u"${user:-wordpress}" "$@"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
# Name of the project database (local default: wordpress).
|
|
95
|
+
kivo_wp_db_name() {
|
|
96
|
+
local name
|
|
97
|
+
name="$(kivo_wp_env_get WORDPRESS_DB_NAME)"
|
|
98
|
+
printf '%s\n' "${name:-wordpress}"
|
|
99
|
+
}
|
|
100
|
+
|
|
80
101
|
# Value of a key in .env without exporting the file (it holds salts; only named keys are read).
|
|
81
102
|
kivo_wp_env_get() {
|
|
82
103
|
local key="$1" file="${KIVO_WP_ROOT}/.env" line
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Export the local database to a SQL file (default: db-export-<timestamp>.sql).
|
|
3
|
+
# mysqldump runs in the db service. The file appears only when the dump succeeds: a failed
|
|
4
|
+
# dump leaves nothing behind.
|
|
3
5
|
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
6
|
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
7
|
|
|
6
8
|
file="${1:-db-export-$(date +%Y%m%d-%H%M%S).sql}"
|
|
7
|
-
|
|
9
|
+
[ ! -d "${file}" ] || kivo_wp_die "${file} is a directory"
|
|
10
|
+
|
|
11
|
+
tmp="$(mktemp "$(dirname "${file}")/.db-export.XXXXXX")"
|
|
12
|
+
trap 'rm -f "${tmp}"' EXIT
|
|
13
|
+
kivo_wp_db_tool mysqldump --single-transaction --quick --no-tablespaces \
|
|
14
|
+
--default-character-set=utf8mb4 "$(kivo_wp_db_name)" >"${tmp}"
|
|
15
|
+
[ -s "${tmp}" ] || kivo_wp_die "mysqldump wrote nothing; ${file} was not created"
|
|
16
|
+
mv "${tmp}" "${file}"
|
|
17
|
+
trap - EXIT
|
|
8
18
|
kivo_wp_err "database exported to ${file}"
|
|
@@ -14,7 +14,13 @@ file="${1:-}"
|
|
|
14
14
|
[ -n "${file}" ] || kivo_wp_die "usage: bin/db-import <dump.sql|dump.sql.gz>"
|
|
15
15
|
[ -f "${file}" ] || kivo_wp_die "file not found: ${file}"
|
|
16
16
|
|
|
17
|
+
# The mysql client runs in the db service.
|
|
18
|
+
import_sql() {
|
|
19
|
+
kivo_wp_db_tool mysql --default-character-set=utf8mb4 "$(kivo_wp_db_name)"
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
case "${file}" in
|
|
18
|
-
*.gz) gzip -dc "${file}" |
|
|
19
|
-
*)
|
|
23
|
+
*.gz) gzip -dc "${file}" | import_sql ;;
|
|
24
|
+
*) import_sql <"${file}" ;;
|
|
20
25
|
esac
|
|
26
|
+
kivo_wp_err "database imported from ${file}"
|
|
@@ -3,7 +3,4 @@
|
|
|
3
3
|
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
4
|
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
user="$(kivo_wp_env_get WORDPRESS_DB_USER)"
|
|
8
|
-
password="$(kivo_wp_env_get WORDPRESS_DB_PASSWORD)"
|
|
9
|
-
kivo_wp_exec db env MYSQL_PWD="${password:-wordpress}" mysql -u"${user:-wordpress}" "${name:-wordpress}" "$@"
|
|
6
|
+
kivo_wp_db_tool mysql "$(kivo_wp_db_name)" "$@"
|
|
@@ -1,20 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Playwright end-to-end tests in the node service
|
|
2
|
+
# Playwright end-to-end tests in the node service. Without --project it runs the smoke project
|
|
3
|
+
# (HTTP checks, no browser), which passes on a fresh project. Browser projects need Chromium in
|
|
4
|
+
# the node service: run `bin/e2e --install-chromium` once per node container, then
|
|
5
|
+
# `bin/e2e --project=chromium` (docs/Development.md, "End-to-end tests in a browser").
|
|
3
6
|
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
7
|
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
8
|
|
|
6
9
|
kivo_wp_require_running node
|
|
7
10
|
kivo_wp_require_running proxy
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
if [ "${1:-}" = "--install-chromium" ]; then
|
|
13
|
+
# System libraries and certutil need root; the browser goes to the node user's cache.
|
|
14
|
+
kivo_wp_compose exec -T -u root --workdir "${KIVO_WP_CONTAINER_ROOT}" node sh -c \
|
|
15
|
+
'npx --yes playwright install-deps chromium && apt-get install -y --no-install-recommends libnss3-tools'
|
|
16
|
+
kivo_wp_exec node npx playwright install chromium
|
|
17
|
+
exit 0
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# Trust Caddy's local CA inside the node service, never by ignoring TLS errors: Node reads
|
|
21
|
+
# NODE_EXTRA_CA_CERTS, Chromium reads the NSS database of the node user (when certutil exists).
|
|
10
22
|
ca_tmp="$(mktemp)"
|
|
11
23
|
KIVO_WP_CERT_OUT="${ca_tmp}" "${KIVO_WP_ROOT}/bin/trust-cert" >/dev/null
|
|
12
24
|
chmod 0644 "${ca_tmp}"
|
|
13
25
|
kivo_wp_compose cp "${ca_tmp}" node:/tmp/kivo-wp-root.crt >/dev/null
|
|
14
26
|
rm -f "${ca_tmp}"
|
|
27
|
+
# shellcheck disable=SC2016 # expanded by the node service shell
|
|
28
|
+
kivo_wp_exec node sh -c 'command -v certutil >/dev/null || exit 0
|
|
29
|
+
db="${HOME}/.pki/nssdb"
|
|
30
|
+
mkdir -p "${db}"
|
|
31
|
+
[ -f "${db}/cert9.db" ] || certutil -d "sql:${db}" -N --empty-password
|
|
32
|
+
certutil -d "sql:${db}" -A -t "C,," -n kivo-wp-local -i /tmp/kivo-wp-root.crt'
|
|
15
33
|
|
|
16
34
|
# The proxy answers the project host names on the same port inside the Compose network.
|
|
17
35
|
site_url="$(kivo_wp_env_get WORDPRESS_SITE_URL)"
|
|
18
36
|
|
|
37
|
+
project_set=0
|
|
38
|
+
for arg in "$@"; do
|
|
39
|
+
case "${arg}" in
|
|
40
|
+
--project | --project=*) project_set=1 ;;
|
|
41
|
+
esac
|
|
42
|
+
done
|
|
43
|
+
[ "${project_set}" -eq 1 ] || set -- --project=smoke "$@"
|
|
44
|
+
|
|
45
|
+
# KIVO_WP_E2E_PROXY: Chromium resolves *.localhost to loopback by itself, so the Playwright
|
|
46
|
+
# config maps the project host names to the proxy service.
|
|
19
47
|
kivo_wp_exec node env NODE_EXTRA_CA_CERTS=/tmp/kivo-wp-root.crt WP_HOME="${site_url}" \
|
|
20
|
-
npx playwright test "$@"
|
|
48
|
+
KIVO_WP_E2E_PROXY=proxy npx playwright test "$@"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Mago (PHP format and lint) in the app service.
|
|
2
|
+
# Mago (PHP format and lint) in the app service. Without arguments it runs `mago lint`, the
|
|
3
|
+
# command agent tooling maps to bin/mago; any arguments pass through (bin/mago format).
|
|
3
4
|
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
5
|
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
6
|
|
|
7
|
+
[ "$#" -gt 0 ] || set -- lint
|
|
6
8
|
kivo_wp_exec app vendor/bin/mago "$@"
|
|
@@ -6,7 +6,9 @@ source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
|
6
6
|
|
|
7
7
|
case "${1:-}" in
|
|
8
8
|
--reset)
|
|
9
|
-
|
|
9
|
+
# The database is recreated with the db service client: the app image has no MySQL client.
|
|
10
|
+
db_name="$(kivo_wp_db_name)"
|
|
11
|
+
kivo_wp_db_tool mysql -e "DROP DATABASE IF EXISTS \`${db_name}\`; CREATE DATABASE \`${db_name}\`;"
|
|
10
12
|
kivo_wp_exec_in app . bash server/cmd/install-wp.sh
|
|
11
13
|
{{#if enable_sage}}
|
|
12
14
|
kivo_wp_exec app wp theme activate "{{projectName}}" --path=wp
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# PHPStan in the app service.
|
|
2
|
+
# PHPStan in the app service, configured by phpstan.neon.dist. Without arguments it runs
|
|
3
|
+
# `phpstan analyse` with room for the WordPress stubs; any arguments pass through.
|
|
3
4
|
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
5
|
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
6
|
|
|
7
|
+
[ "$#" -gt 0 ] || set -- analyse --memory-limit=1G
|
|
6
8
|
kivo_wp_exec app vendor/bin/phpstan "$@"
|
package/modules/lint/index.js
CHANGED
|
@@ -2,6 +2,9 @@ import path from "path";
|
|
|
2
2
|
|
|
3
3
|
import fs from "fs-extra";
|
|
4
4
|
|
|
5
|
+
const OXFMT = "oxfmt --write --no-error-on-unmatched-pattern";
|
|
6
|
+
const OXLINT = "oxlint --fix --no-error-on-unmatched-pattern";
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* Builds the lint-staged entries object from active development modules.
|
|
7
10
|
* Each dev module contributes globs pointing to its own directory.
|
|
@@ -12,11 +15,12 @@ function buildLintStagedEntries(context) {
|
|
|
12
15
|
// formats staged PHP files with bin/mago instead (D-023).
|
|
13
16
|
const phpFormat = context.enable_kivo_wp
|
|
14
17
|
? null
|
|
15
|
-
: ["lando ssh -c 'cd /app && vendor/bin/mago format
|
|
18
|
+
: ["lando ssh -c 'cd /app && vendor/bin/mago format'"];
|
|
16
19
|
|
|
17
|
-
// Infra: YAML, JSON, Markdown at root
|
|
18
|
-
|
|
19
|
-
entries["*.{
|
|
20
|
+
// Infra: YAML, JSON, Markdown at root. Staged files that the ignore files exclude
|
|
21
|
+
// (CHANGELOG.md, lock files) must not fail the commit.
|
|
22
|
+
entries["*.{js,mjs,ts,vue,jsx,tsx}"] = [OXFMT, OXLINT];
|
|
23
|
+
entries["*.{json,jsonc,html,yml,yaml,md,mdx}"] = [OXFMT];
|
|
20
24
|
|
|
21
25
|
// Sage — PHP via mago (format only on pre-commit, lint runs in CI)
|
|
22
26
|
if (context.enable_sage) {
|
|
@@ -42,7 +46,7 @@ function buildLintStagedEntries(context) {
|
|
|
42
46
|
// Blank Theme
|
|
43
47
|
if (context.enable_blank_theme) {
|
|
44
48
|
const dir = `content/themes/${context.blank_theme_name || `${context.projectName}-theme`}`;
|
|
45
|
-
entries[`${dir}/src/**/*.{js,ts}`] = [
|
|
49
|
+
entries[`${dir}/src/**/*.{js,ts}`] = [OXFMT, OXLINT];
|
|
46
50
|
if (context.blank_theme_lint_stylelint !== false) {
|
|
47
51
|
entries[`${dir}/src/**/*.{css,scss}`] = ["stylelint --fix"];
|
|
48
52
|
}
|
package/modules/php/index.js
CHANGED
|
@@ -5,6 +5,11 @@ import fs from "fs-extra";
|
|
|
5
5
|
export async function setupModule(context, generator) {
|
|
6
6
|
await generator.copyDirectory("scripts", "php");
|
|
7
7
|
|
|
8
|
+
// bin/stan and `phpstan analyse` need at least one path to analyse.
|
|
9
|
+
if (context.enable_sage || context.enable_test) {
|
|
10
|
+
await generator.generateFile("phpstan.neon.dist", context, "php");
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
// kivo-wp: the wrappers delegate to bin/php instead of detecting Lando or a host PHP.
|
|
9
14
|
if (context.enable_kivo_wp) {
|
|
10
15
|
for (const name of ["php-wrapper.sh", "pint-wrapper.sh"]) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# PHPStan configuration: bin/stan runs `phpstan analyse` with it.
|
|
2
|
+
# phpstan/extension-installer loads the WordPress extension (szepeviktor/phpstan-wordpress).
|
|
3
|
+
# Add your own code to `paths` (plugins, MU plugins); copy this file to phpstan.neon for local
|
|
4
|
+
# overrides.
|
|
5
|
+
parameters:
|
|
6
|
+
level: 5
|
|
7
|
+
paths:
|
|
8
|
+
{{#if enable_sage}}
|
|
9
|
+
- content/themes/{{projectName}}/app
|
|
10
|
+
{{/if}}
|
|
11
|
+
{{#if enable_test}}
|
|
12
|
+
- tests
|
|
13
|
+
{{/if}}
|
|
14
|
+
{{#if enable_sage}}
|
|
15
|
+
# Acorn and the theme's Composer packages (bin/setup installs them).
|
|
16
|
+
bootstrapFiles:
|
|
17
|
+
- content/themes/{{projectName}}/vendor/autoload.php
|
|
18
|
+
reportUnmatchedIgnoredErrors: false
|
|
19
|
+
ignoreErrors:
|
|
20
|
+
# Upstream Sage code as generated. Remove an entry once you change that code.
|
|
21
|
+
- identifier: return.missing
|
|
22
|
+
path: content/themes/{{projectName}}/app/setup.php
|
|
23
|
+
- identifier: property.phpDocType
|
|
24
|
+
path: content/themes/{{projectName}}/app/View/Composers/*
|
|
25
|
+
- message: '#^Function public_path not found\.$#'
|
|
26
|
+
path: content/themes/{{projectName}}/app/setup.php
|
|
27
|
+
{{/if}}
|
package/modules/sage/index.js
CHANGED
|
@@ -175,7 +175,9 @@ export async function setupModule(context, generator) {
|
|
|
175
175
|
|
|
176
176
|
log(color.green, "[sage] ✅ Advanced Sage setup completed successfully");
|
|
177
177
|
log(color.green, `[sage] ✅ Theme directory: ${relativeThemeDir}`);
|
|
178
|
-
|
|
178
|
+
if (context.dev_environment === "lando") {
|
|
179
|
+
log(color.green, "[sage] ✅ Lando + Devcontainer command parity enabled");
|
|
180
|
+
}
|
|
179
181
|
} catch (error) {
|
|
180
182
|
log(color.red, `[sage] ❌ Installation failed: ${error.message}`);
|
|
181
183
|
throw error;
|
package/modules/skills/index.js
CHANGED
|
@@ -1,18 +1,63 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { log, color } from '../../lib/utils/logger.js';
|
|
1
|
+
import path from "path";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
|
|
5
|
+
import { log, color } from "../../lib/utils/logger.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* kivo-wise: the agent plugins for WordPress on the Roots stack (hekivo/kivo-wise). Claude Code
|
|
9
|
+
* reads the marketplace and the enabled plugin from the project's .claude/settings.json and offers
|
|
10
|
+
* to install them when the project is trusted; nothing is cloned into the project.
|
|
11
|
+
*/
|
|
12
|
+
export const KIVO_WISE_MARKETPLACE = "kivo-wise";
|
|
13
|
+
export const KIVO_WISE_REPO = "hekivo/kivo-wise";
|
|
14
|
+
export const KIVO_WISE_PLUGIN = `kivo-wise@${KIVO_WISE_MARKETPLACE}`;
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
const SETTINGS_BASELINE = {
|
|
17
|
+
$schema: "https://json.schemastore.org/claude-code-settings.json",
|
|
18
|
+
permissions: {
|
|
19
|
+
deny: [
|
|
20
|
+
"Read(./.env)",
|
|
21
|
+
"Read(./.env.*)",
|
|
22
|
+
"Read(./secrets/**)",
|
|
23
|
+
"Read(./config/credentials.json)",
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
11
27
|
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
/** Merge the baseline and the kivo-wise entries into existing settings, keeping what is there. */
|
|
29
|
+
export function mergeClaudeSettings(existing = {}) {
|
|
30
|
+
const permissions = existing.permissions ?? {};
|
|
31
|
+
return {
|
|
32
|
+
...SETTINGS_BASELINE,
|
|
33
|
+
...existing,
|
|
34
|
+
permissions: {
|
|
35
|
+
...permissions,
|
|
36
|
+
deny: [...new Set([...(permissions.deny ?? []), ...SETTINGS_BASELINE.permissions.deny])],
|
|
37
|
+
},
|
|
38
|
+
extraKnownMarketplaces: {
|
|
39
|
+
...existing.extraKnownMarketplaces,
|
|
40
|
+
[KIVO_WISE_MARKETPLACE]: { source: { source: "github", repo: KIVO_WISE_REPO } },
|
|
41
|
+
},
|
|
42
|
+
enabledPlugins: { ...existing.enabledPlugins, [KIVO_WISE_PLUGIN]: true },
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function setupModule(context, generator) {
|
|
47
|
+
if (!context.enable_skills) {
|
|
48
|
+
log(color.orange, "[skills] kivo-wise disabled; skipping.");
|
|
14
49
|
return;
|
|
15
50
|
}
|
|
16
51
|
|
|
17
|
-
|
|
52
|
+
const settingsPath = path.join(generator.cwd, ".claude", "settings.json");
|
|
53
|
+
let existing = {};
|
|
54
|
+
if (await fs.pathExists(settingsPath)) {
|
|
55
|
+
try {
|
|
56
|
+
existing = await fs.readJson(settingsPath);
|
|
57
|
+
} catch {
|
|
58
|
+
log(color.orange, "[skills] .claude/settings.json is not valid JSON; writing a new one.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
await fs.outputJson(settingsPath, mergeClaudeSettings(existing), { spaces: 2 });
|
|
62
|
+
log(color.green, `[skills] ✅ ${KIVO_WISE_PLUGIN} enabled in .claude/settings.json`);
|
|
18
63
|
}
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
export default [
|
|
2
2
|
{
|
|
3
|
-
type:
|
|
4
|
-
name:
|
|
5
|
-
message:
|
|
3
|
+
type: "confirm",
|
|
4
|
+
name: "enable_skills",
|
|
5
|
+
message: "Enable the kivo-wise agent plugin for Claude Code (.claude/settings.json)?",
|
|
6
6
|
default: true,
|
|
7
7
|
},
|
|
8
|
-
{
|
|
9
|
-
type: 'checkbox',
|
|
10
|
-
name: 'skills_targets',
|
|
11
|
-
message: 'Onde instalar as skills?',
|
|
12
|
-
choices: [
|
|
13
|
-
{ name: 'Claude Code → .claude/', value: 'claude' },
|
|
14
|
-
{ name: 'Cursor → .cursor/', value: 'cursor' },
|
|
15
|
-
{ name: 'Agnóstico → .ai/', value: 'ai' },
|
|
16
|
-
],
|
|
17
|
-
default: ['claude'],
|
|
18
|
-
when: (answers) => answers.enable_skills,
|
|
19
|
-
validate: (selected) => (selected.length > 0 ? true : 'Selecione ao menos um destino.'),
|
|
20
|
-
},
|
|
21
8
|
];
|
package/modules/test/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export async function setupModule(context, generator) {
|
|
|
6
6
|
const testsDir = path.join(context.cwd, "tests");
|
|
7
7
|
await fs.ensureDir(path.join(testsDir, "e2e", "helpers"));
|
|
8
8
|
|
|
9
|
+
await generator.copyFile("phpunit.xml", "test", "phpunit.xml");
|
|
9
10
|
await generator.copyFile("tests/Pest.php", "test", "tests/Pest.php");
|
|
10
11
|
await generator.copyFile("tests/SmokeTest.php", "test", "tests/SmokeTest.php");
|
|
11
12
|
await generator.copyFile("tests/e2e/example.spec.js", "test", "tests/e2e/example.spec.js");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!-- Pest and PHPUnit configuration: composer test (bin/test) runs every tests/*Test.php file. -->
|
|
3
|
+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
4
|
+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
|
5
|
+
bootstrap="vendor/autoload.php"
|
|
6
|
+
cacheDirectory=".phpunit.cache"
|
|
7
|
+
colors="true">
|
|
8
|
+
<testsuites>
|
|
9
|
+
<testsuite name="default">
|
|
10
|
+
<directory suffix="Test.php">tests</directory>
|
|
11
|
+
</testsuite>
|
|
12
|
+
</testsuites>
|
|
13
|
+
<source>
|
|
14
|
+
<include>
|
|
15
|
+
<directory>tests</directory>
|
|
16
|
+
</include>
|
|
17
|
+
</source>
|
|
18
|
+
</phpunit>
|
|
@@ -33,6 +33,17 @@ const config = {
|
|
|
33
33
|
testIgnore: /smoke\.spec\.js/,
|
|
34
34
|
use: {
|
|
35
35
|
...devices['Desktop Chrome'],
|
|
36
|
+
{{#if enable_kivo_wp}}
|
|
37
|
+
// bin/e2e sets KIVO_WP_E2E_PROXY: Chromium resolves *.localhost to loopback by itself,
|
|
38
|
+
// so the project host names are sent to the Caddy proxy service instead.
|
|
39
|
+
launchOptions: process.env.KIVO_WP_E2E_PROXY
|
|
40
|
+
? {
|
|
41
|
+
args: [
|
|
42
|
+
`--host-resolver-rules=MAP {{projectName}}.localhost ${process.env.KIVO_WP_E2E_PROXY}, MAP *.{{projectName}}.localhost ${process.env.KIVO_WP_E2E_PROXY}`,
|
|
43
|
+
],
|
|
44
|
+
}
|
|
45
|
+
: {},
|
|
46
|
+
{{/if}}
|
|
36
47
|
},
|
|
37
48
|
},
|
|
38
49
|
],
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
declare(strict_types=1);
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// Runs without the stack (CI included). HTTP checks of the running site live in
|
|
6
|
+
// tests/e2e/smoke.spec.js (bin/e2e).
|
|
6
7
|
|
|
7
|
-
it('
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
]);
|
|
11
|
-
|
|
12
|
-
$response = $client->request('GET', env('WP_HOME'));
|
|
8
|
+
it('installs the Composer dependencies', function () {
|
|
9
|
+
expect(dirname(__DIR__) . '/vendor/autoload.php')->toBeFile();
|
|
10
|
+
});
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
it('installs WordPress core in wp/', function () {
|
|
13
|
+
expect(dirname(__DIR__) . '/wp/wp-settings.php')->toBeFile();
|
|
15
14
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test, expect } from "@playwright/test";
|
|
2
2
|
|
|
3
3
|
// Smoke checks over HTTP only (no browser): the site answers, the login page renders and the
|
|
4
|
-
// synthetic local admin can sign in.
|
|
4
|
+
// synthetic local admin can sign in. `bin/e2e` runs this project by default (kivo-wp).
|
|
5
5
|
const ADMIN_USER = process.env.WORDPRESS_ADMIN_USER || "admin";
|
|
6
6
|
const ADMIN_PASSWORD = process.env.WORDPRESS_ADMIN_PASSWORD || "admin";
|
|
7
7
|
|
package/package.json
CHANGED
package/templates/.gitignore.hbs
CHANGED
package/templates/CLAUDE.md.hbs
CHANGED
|
@@ -32,22 +32,23 @@ lando theme-build # Production build
|
|
|
32
32
|
|
|
33
33
|
## AI Co-Pilot
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
{{#if enable_skills}}
|
|
36
|
+
`.claude/settings.json` enables [kivo-wise](https://github.com/hekivo/kivo-wise), the agent plugin
|
|
37
|
+
for WordPress on the Roots stack (marketplace `hekivo/kivo-wise`, plugin `kivo-wise@kivo-wise`).
|
|
38
|
+
Claude Code offers to install it the first time you trust this folder; to install it by hand:
|
|
37
39
|
|
|
40
|
+
```bash
|
|
41
|
+
claude plugin marketplace add hekivo/kivo-wise
|
|
42
|
+
claude plugin install kivo-wise@kivo-wise
|
|
38
43
|
```
|
|
39
|
-
/sage-onboard
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Available commands:
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
At session start it detects the project and its runner; `/roots-status` prints what it found and the
|
|
46
|
+
`roots-onboarding` skill maps the project. Other assistants (Cursor, Codex, Copilot) are covered in
|
|
47
|
+
the kivo-wise README.
|
|
48
|
+
{{else}}
|
|
49
|
+
No agent plugin is enabled. To add kivo-wise, the plugin for WordPress on the Roots stack, see
|
|
50
|
+
https://github.com/hekivo/kivo-wise.
|
|
51
|
+
{{/if}}
|
|
51
52
|
|
|
52
53
|
## Theme
|
|
53
54
|
|
package/templates/README.md.hbs
CHANGED
|
@@ -2,26 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
Scaffolded by [wp-kit](https://github.com/hekivo/wp-kit).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
{{#if enable_kivo_wp}}
|
|
8
|
+
You need Docker with Compose v2 and Git; PHP, Composer and Node.js run inside the containers.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
bin/setup # build, start, install and seed (idempotent; run it again any time)
|
|
12
|
+
bin/trust-cert # once: trust the local certificate in your browser
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The site answers at `https://{{projectName}}.localhost` (with the port from `HTTPS_PORT` in `.env`
|
|
16
|
+
when it is not 443). `bin/info` prints the URLs; `bin/up` and `bin/down` start and stop the stack.
|
|
17
|
+
{{else}}
|
|
18
|
+
```bash
|
|
19
|
+
lando start
|
|
20
|
+
```
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{#if enable_docs}}
|
|
23
|
+
|
|
24
|
+
Full setup, commands and troubleshooting: [docs/Getting-Started.md](docs/Getting-Started.md),
|
|
25
|
+
[docs/Development.md](docs/Development.md) and [docs/Troubleshooting.md](docs/Troubleshooting.md).
|
|
26
|
+
{{/if}}
|
|
27
|
+
|
|
28
|
+
## Stack
|
|
6
29
|
|
|
7
30
|
- PHP {{phpVersion}}
|
|
8
31
|
- Node.js {{nodeVersion}}
|
|
32
|
+
{{#if useSage}}
|
|
33
|
+
|
|
34
|
+
## Blocks with ACF Composer
|
|
9
35
|
|
|
10
|
-
|
|
36
|
+
The Sage theme builds blocks with ACF Composer:
|
|
11
37
|
|
|
12
|
-
|
|
38
|
+
- Block classes: `content/themes/{{projectName}}/app/Blocks`
|
|
39
|
+
- ACF fields: `content/themes/{{projectName}}/app/Fields`
|
|
40
|
+
- Block Blade views: `content/themes/{{projectName}}/resources/views/blocks`
|
|
13
41
|
|
|
14
|
-
|
|
15
|
-
- Fields do ACF: `content/themes/{{projectName}}/app/Fields`
|
|
16
|
-
- Views Blade dos blocos: `content/themes/{{projectName}}/resources/views/blocks`
|
|
42
|
+
Quick flow:
|
|
17
43
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
3. Renderizar o bloco em `resources/views/blocks`.
|
|
44
|
+
1. Create the block class with {{#if enable_kivo_wp}}`bin/wp acorn acf:block BlockName`{{else}}`lando acorn acf:block BlockName`{{/if}}.
|
|
45
|
+
2. Define its fields in `app/Fields` with ACF Composer.
|
|
46
|
+
3. Render the block in `resources/views/blocks`.
|
|
22
47
|
|
|
23
|
-
|
|
48
|
+
Requirement: the Advanced Custom Fields (ACF) plugin active in WordPress.
|
|
49
|
+
{{/if}}
|
|
24
50
|
|
|
25
|
-
##
|
|
51
|
+
## Author
|
|
26
52
|
|
|
27
53
|
{{author}}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"roots/wordpress": "{{wpCoreVersion}}",
|
|
25
25
|
"roots/bedrock-autoloader": "1.0",
|
|
26
26
|
"inpsyde/wp-translation-downloader": "2.5",
|
|
27
|
-
"vlucas/phpdotenv": "5.
|
|
27
|
+
"vlucas/phpdotenv": "^5.6.2"{{#if enable_acf_pro}},
|
|
28
28
|
"wordpress/mcp-adapter": "0.5.0",
|
|
29
29
|
"wpengine/advanced-custom-fields-pro": "^6.4"{{/if}}
|
|
30
30
|
},
|
|
@@ -140,7 +140,7 @@ $table_prefix = getenv_docker('WORDPRESS_TABLE_PREFIX', 'wp_');
|
|
|
140
140
|
*
|
|
141
141
|
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
|
|
142
142
|
*/
|
|
143
|
-
define('WP_DEBUG',
|
|
143
|
+
define('WP_DEBUG', filter_var(getenv_docker('WORDPRESS_DEBUG', ''), FILTER_VALIDATE_BOOLEAN));
|
|
144
144
|
|
|
145
145
|
/* Add any custom values between this line and the "stop editing" line. */
|
|
146
146
|
|
|
@@ -203,17 +203,23 @@ define( 'WP_CONTENT_URL', WP_HOME . '/content' );
|
|
|
203
203
|
define( 'WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/content' );
|
|
204
204
|
{{/if}}
|
|
205
205
|
|
|
206
|
-
//
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
// Define a constant for every remaining WORDPRESS_* variable (WORDPRESS_WP_ENVIRONMENT_TYPE ->
|
|
207
|
+
// WP_ENVIRONMENT_TYPE). Process variables come from getenv(): images that run with
|
|
208
|
+
// variables_order=GPCS (serversideup/php) leave $_ENV empty. Values loaded from .env by phpdotenv
|
|
209
|
+
// are only in $_ENV. "true" and "false" become booleans, so WORDPRESS_SCRIPT_DEBUG=false is off.
|
|
210
|
+
$wordpressEnvs = array_filter(getenv() + $_ENV, function ($key) {
|
|
211
|
+
return strpos((string) $key, 'WORDPRESS_') === 0;
|
|
209
212
|
}, ARRAY_FILTER_USE_KEY);
|
|
210
213
|
|
|
211
|
-
// Define all remaining WordPress environment variables
|
|
212
214
|
foreach ($wordpressEnvs as $key => $value) {
|
|
213
|
-
$key =
|
|
214
|
-
if (
|
|
215
|
-
|
|
215
|
+
$key = substr($key, strlen('WORDPRESS_'));
|
|
216
|
+
if (defined($key)) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
$flag = is_string($value) ? strtolower($value) : '';
|
|
220
|
+
define($key, $flag === 'true' ? true : ($flag === 'false' ? false : $value));
|
|
216
221
|
}
|
|
222
|
+
unset($wordpressEnvs, $key, $value, $flag);
|
|
217
223
|
|
|
218
224
|
// If there's a WORDPRESS_CONFIG_EXTRA environment variable, evaluate it
|
|
219
225
|
if ($configExtra = getenv_docker('WORDPRESS_CONFIG_EXTRA', '')) {
|