@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/modules/lint/index.js
CHANGED
|
@@ -2,23 +2,30 @@ 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.
|
|
8
11
|
*/
|
|
9
12
|
function buildLintStagedEntries(context) {
|
|
10
13
|
const entries = {};
|
|
14
|
+
// kivo-wp: lint-staged runs in the node service, which has no PHP; the pre-commit hook
|
|
15
|
+
// formats staged PHP files with bin/mago instead (D-023).
|
|
16
|
+
const phpFormat = context.enable_kivo_wp
|
|
17
|
+
? null
|
|
18
|
+
: ["lando ssh -c 'cd /app && vendor/bin/mago format'"];
|
|
11
19
|
|
|
12
|
-
// Infra: YAML, JSON, Markdown at root
|
|
13
|
-
|
|
14
|
-
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];
|
|
15
24
|
|
|
16
25
|
// Sage — PHP via mago (format only on pre-commit, lint runs in CI)
|
|
17
26
|
if (context.enable_sage) {
|
|
18
27
|
const dir = `content/themes/${context.projectName}`;
|
|
19
|
-
entries[`${dir}/{app,routes,config}/**/*.php`] =
|
|
20
|
-
"lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'",
|
|
21
|
-
];
|
|
28
|
+
if (phpFormat) entries[`${dir}/{app,routes,config}/**/*.php`] = phpFormat;
|
|
22
29
|
if (context.sage_lint_stylelint !== false) {
|
|
23
30
|
entries[`${dir}/resources/**/*.{css,scss}`] = ["stylelint --fix"];
|
|
24
31
|
}
|
|
@@ -27,30 +34,26 @@ function buildLintStagedEntries(context) {
|
|
|
27
34
|
// MU-Plugin — PHP via mago
|
|
28
35
|
if (context.enable_mu_plugin) {
|
|
29
36
|
const dir = `content/mu-plugins/${context.mu_plugin_name || `${context.projectName}-core`}`;
|
|
30
|
-
entries[`${dir}/app/**/*.php`] =
|
|
31
|
-
"lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'",
|
|
32
|
-
];
|
|
37
|
+
if (phpFormat) entries[`${dir}/app/**/*.php`] = phpFormat;
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
// Plugin — PHP via mago
|
|
36
41
|
if (context.enable_plugin) {
|
|
37
42
|
const dir = `content/plugins/${context.plugin_name || `${context.projectName}-plugin`}`;
|
|
38
|
-
entries[`${dir}/src/**/*.php`] =
|
|
39
|
-
"lando ssh -c 'cd /app && vendor/bin/mago format --no-progress'",
|
|
40
|
-
];
|
|
43
|
+
if (phpFormat) entries[`${dir}/src/**/*.php`] = phpFormat;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
// Blank Theme
|
|
44
47
|
if (context.enable_blank_theme) {
|
|
45
48
|
const dir = `content/themes/${context.blank_theme_name || `${context.projectName}-theme`}`;
|
|
46
|
-
entries[`${dir}/src/**/*.{js,ts}`] = [
|
|
49
|
+
entries[`${dir}/src/**/*.{js,ts}`] = [OXFMT, OXLINT];
|
|
47
50
|
if (context.blank_theme_lint_stylelint !== false) {
|
|
48
51
|
entries[`${dir}/src/**/*.{css,scss}`] = ["stylelint --fix"];
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
// Tests PHP
|
|
53
|
-
entries["tests/**/*.php"] =
|
|
56
|
+
if (phpFormat) entries["tests/**/*.php"] = phpFormat;
|
|
54
57
|
|
|
55
58
|
return entries;
|
|
56
59
|
}
|
|
@@ -61,6 +64,11 @@ export async function setupModule(context, generator) {
|
|
|
61
64
|
// Root developer tooling
|
|
62
65
|
await generator.copyFile(".commitlintrc.json", "lint");
|
|
63
66
|
await generator.copyFile(".prettierignore", "lint");
|
|
67
|
+
if (context.enable_kivo_wp) {
|
|
68
|
+
const ignoreFile = path.join(generator.cwd, ".prettierignore");
|
|
69
|
+
const lines = (await fs.readFile(ignoreFile, "utf8")).split("\n");
|
|
70
|
+
await fs.outputFile(ignoreFile, lines.filter((line) => line.trim() !== ".lando/").join("\n"));
|
|
71
|
+
}
|
|
64
72
|
await generator.copyFile(".oxlintrc.json", "lint");
|
|
65
73
|
|
|
66
74
|
// mago.toml — generated (paths depend on active modules)
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"scripts": {
|
|
3
|
+
{{#if enable_kivo_wp}}
|
|
4
|
+
"format": "oxfmt && bin/mago format",
|
|
5
|
+
"format:check": "oxfmt --check && bin/mago format --check",
|
|
6
|
+
"lint": "oxlint && bin/mago lint",
|
|
7
|
+
{{else}}
|
|
3
8
|
"format": "oxfmt && lando ssh -c 'cd /app && vendor/bin/mago format'",
|
|
4
9
|
"format:check": "oxfmt --check && lando ssh -c 'cd /app && vendor/bin/mago format --check'",
|
|
5
10
|
"lint": "oxlint && lando ssh -c 'cd /app && vendor/bin/mago lint'",
|
|
11
|
+
{{/if}}
|
|
6
12
|
"lint:fix": "oxlint --fix"
|
|
7
13
|
},
|
|
8
14
|
"devDependencies": {
|
package/modules/php/index.js
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
|
|
1
5
|
export async function setupModule(context, generator) {
|
|
2
|
-
await generator.copyDirectory(
|
|
6
|
+
await generator.copyDirectory("scripts", "php");
|
|
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
|
+
|
|
13
|
+
// kivo-wp: the wrappers delegate to bin/php instead of detecting Lando or a host PHP.
|
|
14
|
+
if (context.enable_kivo_wp) {
|
|
15
|
+
for (const name of ["php-wrapper.sh", "pint-wrapper.sh"]) {
|
|
16
|
+
await generator.copyFile(`kivo-wp/${name}`, "php", `scripts/${name}`);
|
|
17
|
+
await fs.chmod(path.join(generator.cwd, "scripts", name), 0o755);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
3
20
|
}
|
|
@@ -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
|
@@ -16,7 +16,6 @@ import { VERSION_REGISTRY, validateVersionCompatibility } from "../../lib/config
|
|
|
16
16
|
export async function setupModule(context, generator) {
|
|
17
17
|
const themeDir = path.join(context.cwd, "content", "themes", context.projectName);
|
|
18
18
|
const relativeThemeDir = `content/themes/${context.projectName}`;
|
|
19
|
-
const relativeDevcontainerDir = ".devcontainer";
|
|
20
19
|
|
|
21
20
|
try {
|
|
22
21
|
// 1. Validate version compatibility
|
|
@@ -143,21 +142,7 @@ export async function setupModule(context, generator) {
|
|
|
143
142
|
await fs.remove(path.join(context.cwd, relativeThemeDir, stale));
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
|
|
147
|
-
".devcontainer/docker-compose.override.yml",
|
|
148
|
-
context,
|
|
149
|
-
"sage",
|
|
150
|
-
`${relativeDevcontainerDir}/docker-compose.override.yml`,
|
|
151
|
-
);
|
|
152
|
-
await generator.generateFile(
|
|
153
|
-
".devcontainer/post-create.sh",
|
|
154
|
-
context,
|
|
155
|
-
"sage",
|
|
156
|
-
`${relativeDevcontainerDir}/post-create.sh`,
|
|
157
|
-
);
|
|
158
|
-
await fs.chmod(path.join(context.cwd, relativeDevcontainerDir, "post-create.sh"), 0o755);
|
|
159
|
-
|
|
160
|
-
// Unified setup scripts for Sage — shared between Lando, devcontainer and CI/CD
|
|
145
|
+
// Unified setup scripts for Sage — shared between Lando, kivo-wp and CI/CD
|
|
161
146
|
await generator.generateFile(
|
|
162
147
|
"server/cmd/setup-sage-php.sh",
|
|
163
148
|
context,
|
|
@@ -173,15 +158,6 @@ export async function setupModule(context, generator) {
|
|
|
173
158
|
await fs.chmod(path.join(context.cwd, "server/cmd/setup-sage-php.sh"), 0o755);
|
|
174
159
|
await fs.chmod(path.join(context.cwd, "server/cmd/setup-sage-node.sh"), 0o755);
|
|
175
160
|
|
|
176
|
-
await generator.mergeWithExistingFile({
|
|
177
|
-
existingFile: `${relativeDevcontainerDir}/devcontainer.json`,
|
|
178
|
-
moduleTemplatePath: ".devcontainer/devcontainer.json",
|
|
179
|
-
context,
|
|
180
|
-
format: "json",
|
|
181
|
-
moduleName: "sage",
|
|
182
|
-
mergeStrategy: "replace",
|
|
183
|
-
});
|
|
184
|
-
|
|
185
161
|
// 8. Lint configs co-located in theme — always installed (IDE/editor support)
|
|
186
162
|
log(color.blue, "[sage] 🔧 Installing lint configurations...");
|
|
187
163
|
await generator.copyFile(
|
|
@@ -199,7 +175,9 @@ export async function setupModule(context, generator) {
|
|
|
199
175
|
|
|
200
176
|
log(color.green, "[sage] ✅ Advanced Sage setup completed successfully");
|
|
201
177
|
log(color.green, `[sage] ✅ Theme directory: ${relativeThemeDir}`);
|
|
202
|
-
|
|
178
|
+
if (context.dev_environment === "lando") {
|
|
179
|
+
log(color.green, "[sage] ✅ Lando + Devcontainer command parity enabled");
|
|
180
|
+
}
|
|
203
181
|
} catch (error) {
|
|
204
182
|
log(color.red, `[sage] ❌ Installation failed: ${error.message}`);
|
|
205
183
|
throw error;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Lint the Sage theme scripts with oxlint in the node service.
|
|
3
|
+
# shellcheck source=_lib.sh source-path=SCRIPTDIR
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
|
5
|
+
|
|
6
|
+
kivo_wp_exec node npx oxlint --fix "content/themes/{{projectName}}/resources/" "$@"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Installs and builds Sage theme Node.js dependencies.
|
|
3
|
-
# Invoked from:
|
|
3
|
+
{{#if enable_kivo_wp}}# Invoked from: kivo-wp bin/setup and bin/reset-deps (inside the containers), CI/CD.
|
|
4
|
+
{{else}}# Invoked from: Lando (build service build step + post-start), CI/CD.
|
|
5
|
+
{{/if}}
|
|
4
6
|
set -euo pipefail
|
|
5
7
|
|
|
6
8
|
PROJECT_ROOT="${PROJECT_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Installs Sage theme PHP dependencies via Composer.
|
|
3
|
-
# Invoked from:
|
|
3
|
+
{{#if enable_kivo_wp}}# Invoked from: kivo-wp bin/setup and bin/reset-deps (inside the containers), CI/CD.
|
|
4
|
+
{{else}}# Invoked from: Lando (post-start), CI/CD.
|
|
5
|
+
{{/if}}
|
|
4
6
|
set -euo pipefail
|
|
5
7
|
|
|
6
8
|
PROJECT_ROOT="${PROJECT_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { wordpressPlugin, wordpressThemeJson } from '@roots/vite-plugin';
|
|
2
2
|
import tailwindcss from '@tailwindcss/vite';
|
|
3
|
+
{{#unless enable_kivo_wp}}
|
|
3
4
|
import fs from 'fs';
|
|
4
|
-
import laravel from 'laravel-vite-plugin';
|
|
5
|
+
{{/unless}}import laravel from 'laravel-vite-plugin';
|
|
5
6
|
import { defineConfig } from 'vite';
|
|
6
7
|
|
|
7
8
|
export default defineConfig({
|
|
@@ -39,8 +40,24 @@ export default defineConfig({
|
|
|
39
40
|
'@fields': '/app/Fields',
|
|
40
41
|
},
|
|
41
42
|
},
|
|
43
|
+
{{#if enable_kivo_wp}}
|
|
44
|
+
// kivo-wp: Vite runs in the node service behind Caddy, which terminates TLS for
|
|
45
|
+
// https://vite.<project>.localhost on the host HTTPS port (bin/dev).
|
|
42
46
|
server: {
|
|
43
|
-
|
|
47
|
+
host: '0.0.0.0',
|
|
48
|
+
port: 5173,
|
|
49
|
+
strictPort: true,
|
|
50
|
+
origin: `https://${process.env.KIVO_WP_VITE_HOST ?? 'vite.{{projectName}}.localhost'}`,
|
|
51
|
+
cors: true,
|
|
52
|
+
hmr: {
|
|
53
|
+
host: process.env.KIVO_WP_VITE_HOST ?? 'vite.{{projectName}}.localhost',
|
|
54
|
+
protocol: 'wss',
|
|
55
|
+
clientPort: Number(process.env.HTTPS_PORT ?? 443),
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{{else}}
|
|
59
|
+
server: {
|
|
60
|
+
// Lando certificates; outside the container (for example in CI) the build runs without https
|
|
44
61
|
https: fs.existsSync('/certs/cert.key')
|
|
45
62
|
? {
|
|
46
63
|
key: fs.readFileSync('/certs/cert.key'),
|
|
@@ -55,4 +72,5 @@ export default defineConfig({
|
|
|
55
72
|
protocol: 'wss',
|
|
56
73
|
},
|
|
57
74
|
},
|
|
75
|
+
{{/if}}
|
|
58
76
|
});
|
|
@@ -92,63 +92,6 @@
|
|
|
92
92
|
"panel": "shared"
|
|
93
93
|
},
|
|
94
94
|
"problemMatcher": []
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
"label": "🐳 Devcontainer: theme-build",
|
|
98
|
-
"type": "shell",
|
|
99
|
-
"command": "docker",
|
|
100
|
-
"args": ["compose", "-f", ".devcontainer/docker-compose.yml", "-f", ".devcontainer/docker-compose.override.yml", "exec", "wordpress", "bash", "-lc", "cd /workspace/content/themes/{{projectName}} && yarn build"],
|
|
101
|
-
"group": "build",
|
|
102
|
-
"presentation": {
|
|
103
|
-
"echo": true,
|
|
104
|
-
"reveal": "always",
|
|
105
|
-
"focus": false,
|
|
106
|
-
"panel": "shared"
|
|
107
|
-
},
|
|
108
|
-
"problemMatcher": []
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
"label": "🐳 Devcontainer: theme-dev",
|
|
112
|
-
"type": "shell",
|
|
113
|
-
"command": "docker",
|
|
114
|
-
"args": ["compose", "-f", ".devcontainer/docker-compose.yml", "-f", ".devcontainer/docker-compose.override.yml", "exec", "wordpress", "bash", "-lc", "cd /workspace/content/themes/{{projectName}} && yarn dev"],
|
|
115
|
-
"group": "build",
|
|
116
|
-
"isBackground": true,
|
|
117
|
-
"presentation": {
|
|
118
|
-
"echo": true,
|
|
119
|
-
"reveal": "always",
|
|
120
|
-
"focus": false,
|
|
121
|
-
"panel": "shared"
|
|
122
|
-
},
|
|
123
|
-
"problemMatcher": []
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
"label": "🐳 Devcontainer: theme-lint",
|
|
127
|
-
"type": "shell",
|
|
128
|
-
"command": "docker",
|
|
129
|
-
"args": ["compose", "-f", ".devcontainer/docker-compose.yml", "-f", ".devcontainer/docker-compose.override.yml", "exec", "wordpress", "bash", "-lc", "cd /workspace/content/themes/{{projectName}} && yarn lint"],
|
|
130
|
-
"group": "build",
|
|
131
|
-
"presentation": {
|
|
132
|
-
"echo": true,
|
|
133
|
-
"reveal": "always",
|
|
134
|
-
"focus": false,
|
|
135
|
-
"panel": "shared"
|
|
136
|
-
},
|
|
137
|
-
"problemMatcher": []
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"label": "🐳 Devcontainer: acorn",
|
|
141
|
-
"type": "shell",
|
|
142
|
-
"command": "docker",
|
|
143
|
-
"args": ["compose", "-f", ".devcontainer/docker-compose.yml", "-f", ".devcontainer/docker-compose.override.yml", "exec", "wordpress", "bash", "-lc", "cd /workspace/content/themes/{{projectName}} && wp acorn make:component ExampleBlock"],
|
|
144
|
-
"group": "build",
|
|
145
|
-
"presentation": {
|
|
146
|
-
"echo": true,
|
|
147
|
-
"reveal": "always",
|
|
148
|
-
"focus": false,
|
|
149
|
-
"panel": "shared"
|
|
150
|
-
},
|
|
151
|
-
"problemMatcher": []
|
|
152
95
|
}
|
|
153
96
|
]
|
|
154
97
|
}
|
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
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import path from
|
|
1
|
+
import path from "path";
|
|
2
2
|
|
|
3
|
-
import fs from
|
|
3
|
+
import fs from "fs-extra";
|
|
4
4
|
|
|
5
5
|
export async function setupModule(context, generator) {
|
|
6
|
-
const testsDir = path.join(context.cwd,
|
|
7
|
-
await fs.ensureDir(path.join(testsDir,
|
|
6
|
+
const testsDir = path.join(context.cwd, "tests");
|
|
7
|
+
await fs.ensureDir(path.join(testsDir, "e2e", "helpers"));
|
|
8
8
|
|
|
9
|
-
await generator.copyFile(
|
|
10
|
-
await generator.copyFile(
|
|
11
|
-
await generator.copyFile(
|
|
9
|
+
await generator.copyFile("phpunit.xml", "test", "phpunit.xml");
|
|
10
|
+
await generator.copyFile("tests/Pest.php", "test", "tests/Pest.php");
|
|
11
|
+
await generator.copyFile("tests/SmokeTest.php", "test", "tests/SmokeTest.php");
|
|
12
|
+
await generator.copyFile("tests/e2e/example.spec.js", "test", "tests/e2e/example.spec.js");
|
|
13
|
+
await generator.copyFile("tests/e2e/smoke.spec.js", "test", "tests/e2e/smoke.spec.js");
|
|
12
14
|
await generator.copyFile(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
"tests/e2e/helpers/loginHelper.js",
|
|
16
|
+
"test",
|
|
17
|
+
"tests/e2e/helpers/loginHelper.js",
|
|
16
18
|
);
|
|
17
19
|
|
|
18
|
-
await generator.generateFile(
|
|
20
|
+
await generator.generateFile("playwright.config.js", context, "test");
|
|
19
21
|
}
|
|
@@ -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>
|
|
@@ -13,14 +13,37 @@ const config = {
|
|
|
13
13
|
reporter: process.env.CI ? 'github' : 'list',
|
|
14
14
|
use: {
|
|
15
15
|
actionTimeout: 0,
|
|
16
|
+
{{#if enable_kivo_wp}}
|
|
17
|
+
// bin/e2e sets WP_HOME to the site as the node service reaches it through Caddy.
|
|
18
|
+
baseURL:
|
|
19
|
+
process.env.WP_HOME || process.env.WORDPRESS_SITE_URL || 'https://{{projectName}}.localhost',
|
|
20
|
+
{{else}}
|
|
16
21
|
baseURL: process.env.WP_HOME || 'https://{{projectName}}.lndo.site',
|
|
22
|
+
{{/if}}
|
|
17
23
|
trace: 'on-first-retry',
|
|
18
24
|
},
|
|
19
25
|
projects: [
|
|
26
|
+
{
|
|
27
|
+
// HTTP-level checks of the running site; needs no browser (bin/e2e --project=smoke).
|
|
28
|
+
name: 'smoke',
|
|
29
|
+
testMatch: /smoke\.spec\.js/,
|
|
30
|
+
},
|
|
20
31
|
{
|
|
21
32
|
name: 'chromium',
|
|
33
|
+
testIgnore: /smoke\.spec\.js/,
|
|
22
34
|
use: {
|
|
23
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}}
|
|
24
47
|
},
|
|
25
48
|
},
|
|
26
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
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
// Smoke checks over HTTP only (no browser): the site answers, the login page renders and the
|
|
4
|
+
// synthetic local admin can sign in. `bin/e2e` runs this project by default (kivo-wp).
|
|
5
|
+
const ADMIN_USER = process.env.WORDPRESS_ADMIN_USER || "admin";
|
|
6
|
+
const ADMIN_PASSWORD = process.env.WORDPRESS_ADMIN_PASSWORD || "admin";
|
|
7
|
+
|
|
8
|
+
test("the home page answers 200", async ({ request }) => {
|
|
9
|
+
const response = await request.get("/");
|
|
10
|
+
expect(response.status()).toBe(200);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("the login page answers 200", async ({ request }) => {
|
|
14
|
+
const response = await request.get("/wp/wp-login.php");
|
|
15
|
+
expect(response.status()).toBe(200);
|
|
16
|
+
expect(await response.text()).toContain("user_login");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("the synthetic admin can sign in", async ({ request }) => {
|
|
20
|
+
// WordPress checks that cookies work with a test cookie set by the login page.
|
|
21
|
+
await request.get("/wp/wp-login.php");
|
|
22
|
+
const response = await request.post("/wp/wp-login.php", {
|
|
23
|
+
form: { log: ADMIN_USER, pwd: ADMIN_PASSWORD, "wp-submit": "Log In", testcookie: "1" },
|
|
24
|
+
maxRedirects: 0,
|
|
25
|
+
});
|
|
26
|
+
expect(response.status()).toBe(302);
|
|
27
|
+
expect(response.headers().location).toContain("/wp-admin");
|
|
28
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codigodoleo/wp-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "Kit opinativo para padronizar projetos WordPress com CI/CD dinâmico.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codigodoleo",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"modules/",
|
|
23
23
|
"templates/",
|
|
24
24
|
"server/",
|
|
25
|
-
"wp-config.php",
|
|
26
25
|
"index.php",
|
|
27
26
|
".cspell.json",
|
|
28
27
|
".gitkeep"
|
|
@@ -38,6 +37,7 @@
|
|
|
38
37
|
"lint:fix": "oxlint . --fix",
|
|
39
38
|
"format": "oxfmt --write .",
|
|
40
39
|
"commit": "cz",
|
|
40
|
+
"test": "node --test \"__tests__/**/*.test.js\"",
|
|
41
41
|
"test:setup": "npm run test:clean && npm run test:scaffold",
|
|
42
42
|
"test:clean": "rm -rf __test-sandbox__",
|
|
43
43
|
"test:scaffold": "node ./bin/index.js init --output=__test-sandbox__/test-project --defaults",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"@commitlint/prompt": "^18.4.3",
|
|
65
65
|
"@cspell/dict-php": "^4.0.14",
|
|
66
66
|
"@cspell/dict-pt-br": "^2.4.0",
|
|
67
|
+
"ajv": "^8.20.0",
|
|
67
68
|
"commitizen": "^4.3.0",
|
|
68
69
|
"conventional-changelog-cli": "^4.1.0",
|
|
69
70
|
"husky": "^8.0.3",
|