@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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"blogname": "Local fixture site",
|
|
3
|
+
"blogdescription": "Synthetic content for development",
|
|
4
|
+
"admin_email": "admin@example.test",
|
|
5
|
+
"timezone_string": "UTC",
|
|
6
|
+
"date_format": "Y-m-d",
|
|
7
|
+
"posts_per_page": 10,
|
|
8
|
+
"show_on_front": "page",
|
|
9
|
+
"page_on_front": { "page": "home" }
|
|
10
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"type": "page",
|
|
4
|
+
"slug": "home",
|
|
5
|
+
"title": "Home",
|
|
6
|
+
"content": "<!-- wp:paragraph --><p>Welcome to the local site. All content here is synthetic.</p><!-- /wp:paragraph -->",
|
|
7
|
+
"author": "editor",
|
|
8
|
+
"date": "2026-01-05 09:00:00"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"type": "page",
|
|
12
|
+
"slug": "about",
|
|
13
|
+
"title": "About",
|
|
14
|
+
"content": "<!-- wp:paragraph --><p>A fictional organization used for local development.</p><!-- /wp:paragraph -->",
|
|
15
|
+
"author": "editor",
|
|
16
|
+
"date": "2026-01-05 09:10:00"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "page",
|
|
20
|
+
"slug": "contact",
|
|
21
|
+
"title": "Contact",
|
|
22
|
+
"content": "<!-- wp:paragraph --><p>Write to hello@example.test.</p><!-- /wp:paragraph -->",
|
|
23
|
+
"author": "editor",
|
|
24
|
+
"date": "2026-01-05 09:20:00"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"type": "post",
|
|
28
|
+
"slug": "first-fixture-post",
|
|
29
|
+
"title": "First fixture post",
|
|
30
|
+
"excerpt": "A short synthetic post.",
|
|
31
|
+
"content": "<!-- wp:paragraph --><p>This post exists to exercise templates, archives and search.</p><!-- /wp:paragraph -->",
|
|
32
|
+
"author": "author",
|
|
33
|
+
"date": "2026-01-10 10:00:00",
|
|
34
|
+
"categories": ["news"],
|
|
35
|
+
"tags": ["sample", "fixture"]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"type": "post",
|
|
39
|
+
"slug": "a-guide-to-the-local-stack",
|
|
40
|
+
"title": "A guide to the local stack",
|
|
41
|
+
"excerpt": "How the fixtures are organized.",
|
|
42
|
+
"content": "<!-- wp:heading --><h2>Fixtures</h2><!-- /wp:heading --><!-- wp:paragraph --><p>Every record carries a fixture marker so a reseed replaces it.</p><!-- /wp:paragraph -->",
|
|
43
|
+
"author": "author",
|
|
44
|
+
"date": "2026-01-12 10:00:00",
|
|
45
|
+
"categories": ["guides"],
|
|
46
|
+
"tags": ["fixture"]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"type": "post",
|
|
50
|
+
"slug": "draft-fixture-post",
|
|
51
|
+
"title": "Draft fixture post",
|
|
52
|
+
"status": "draft",
|
|
53
|
+
"content": "<!-- wp:paragraph --><p>An unpublished post.</p><!-- /wp:paragraph -->",
|
|
54
|
+
"author": "author",
|
|
55
|
+
"date": "2026-01-15 10:00:00",
|
|
56
|
+
"categories": ["news"]
|
|
57
|
+
}
|
|
58
|
+
]
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Synthetic fixtures for the kivo-wp environment (D-002): no real personal data, emails on
|
|
5
|
+
* example.test, fixed dates. Run with `bin/seed` (wp eval-file). Every user, term, post and menu
|
|
6
|
+
* item carries the _kivo_wp_fixture meta, so a second run deletes the previous fixtures first
|
|
7
|
+
* and the result is the same. Fixture user passwords are random and never printed.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
if (! defined('ABSPATH') || ! class_exists('WP_CLI')) {
|
|
11
|
+
exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
require_once ABSPATH . 'wp-admin/includes/user.php';
|
|
15
|
+
|
|
16
|
+
const KIVO_WP_FIXTURE_META = '_kivo_wp_fixture';
|
|
17
|
+
|
|
18
|
+
$kivoWpFixturesDir = __DIR__;
|
|
19
|
+
|
|
20
|
+
$kivoWpLoad = static function (string $name) use ($kivoWpFixturesDir): array {
|
|
21
|
+
$raw = file_get_contents($kivoWpFixturesDir . '/' . $name . '.json');
|
|
22
|
+
|
|
23
|
+
return json_decode((string) $raw, true, 512, JSON_THROW_ON_ERROR);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
$kivoWpCheck = static function ($result, string $what) {
|
|
27
|
+
if (is_wp_error($result)) {
|
|
28
|
+
WP_CLI::error($what . ': ' . $result->get_error_message());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return $result;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// 1. Remove the previous fixtures (menu items are posts too).
|
|
35
|
+
$tagged = get_posts([
|
|
36
|
+
'post_type' => 'any',
|
|
37
|
+
'post_status' => 'any',
|
|
38
|
+
'numberposts' => -1,
|
|
39
|
+
'fields' => 'ids',
|
|
40
|
+
'meta_key' => KIVO_WP_FIXTURE_META,
|
|
41
|
+
]);
|
|
42
|
+
$taggedItems = get_posts([
|
|
43
|
+
'post_type' => 'nav_menu_item',
|
|
44
|
+
'post_status' => 'any',
|
|
45
|
+
'numberposts' => -1,
|
|
46
|
+
'fields' => 'ids',
|
|
47
|
+
'meta_key' => KIVO_WP_FIXTURE_META,
|
|
48
|
+
]);
|
|
49
|
+
foreach (array_unique(array_merge($tagged, $taggedItems)) as $postId) {
|
|
50
|
+
wp_delete_post($postId, true);
|
|
51
|
+
}
|
|
52
|
+
foreach (['category', 'post_tag', 'nav_menu'] as $taxonomy) {
|
|
53
|
+
$terms = get_terms([
|
|
54
|
+
'taxonomy' => $taxonomy,
|
|
55
|
+
'hide_empty' => false,
|
|
56
|
+
'fields' => 'ids',
|
|
57
|
+
'meta_key' => KIVO_WP_FIXTURE_META,
|
|
58
|
+
]);
|
|
59
|
+
foreach (is_array($terms) ? $terms : [] as $termId) {
|
|
60
|
+
wp_delete_term($termId, $taxonomy);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
foreach (get_users(['meta_key' => KIVO_WP_FIXTURE_META, 'fields' => 'ID']) as $userId) {
|
|
64
|
+
wp_delete_user((int) $userId);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 2. Users.
|
|
68
|
+
$users = [];
|
|
69
|
+
foreach ($kivoWpLoad('users') as $user) {
|
|
70
|
+
$userId = $kivoWpCheck(wp_insert_user([
|
|
71
|
+
'user_login' => $user['login'],
|
|
72
|
+
'user_email' => $user['email'],
|
|
73
|
+
'user_pass' => wp_generate_password(32),
|
|
74
|
+
'display_name' => $user['display_name'],
|
|
75
|
+
'first_name' => $user['first_name'],
|
|
76
|
+
'last_name' => $user['last_name'],
|
|
77
|
+
'role' => $user['role'],
|
|
78
|
+
]), 'user ' . $user['login']);
|
|
79
|
+
update_user_meta($userId, KIVO_WP_FIXTURE_META, 1);
|
|
80
|
+
$users[$user['login']] = $userId;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 3. Terms.
|
|
84
|
+
foreach ($kivoWpLoad('terms') as $term) {
|
|
85
|
+
$created = $kivoWpCheck(wp_insert_term($term['name'], $term['taxonomy'], [
|
|
86
|
+
'slug' => $term['slug'],
|
|
87
|
+
'description' => $term['description'] ?? '',
|
|
88
|
+
]), 'term ' . $term['slug']);
|
|
89
|
+
update_term_meta($created['term_id'], KIVO_WP_FIXTURE_META, 1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 4. Posts and pages.
|
|
93
|
+
$pages = [];
|
|
94
|
+
foreach ($kivoWpLoad('posts') as $post) {
|
|
95
|
+
$categoryIds = array_map(
|
|
96
|
+
static fn (string $slug): int => (int) get_term_by('slug', $slug, 'category')->term_id,
|
|
97
|
+
$post['categories'] ?? []
|
|
98
|
+
);
|
|
99
|
+
$postId = $kivoWpCheck(wp_insert_post([
|
|
100
|
+
'post_type' => $post['type'],
|
|
101
|
+
'post_name' => $post['slug'],
|
|
102
|
+
'post_title' => $post['title'],
|
|
103
|
+
'post_content' => $post['content'],
|
|
104
|
+
'post_excerpt' => $post['excerpt'] ?? '',
|
|
105
|
+
'post_status' => $post['status'] ?? 'publish',
|
|
106
|
+
'post_author' => $users[$post['author']] ?? 1,
|
|
107
|
+
'post_date' => $post['date'],
|
|
108
|
+
'post_category' => $categoryIds,
|
|
109
|
+
'tags_input' => $post['tags'] ?? [],
|
|
110
|
+
'meta_input' => [KIVO_WP_FIXTURE_META => 1],
|
|
111
|
+
], true), 'post ' . $post['slug']);
|
|
112
|
+
if ($post['type'] === 'page') {
|
|
113
|
+
$pages[$post['slug']] = $postId;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 5. Menus.
|
|
118
|
+
foreach ($kivoWpLoad('menus') as $menu) {
|
|
119
|
+
$menuId = $kivoWpCheck(wp_create_nav_menu($menu['name']), 'menu ' . $menu['name']);
|
|
120
|
+
update_term_meta($menuId, KIVO_WP_FIXTURE_META, 1);
|
|
121
|
+
foreach ($menu['items'] as $position => $item) {
|
|
122
|
+
$itemId = $kivoWpCheck(wp_update_nav_menu_item($menuId, 0, [
|
|
123
|
+
'menu-item-title' => $item['title'],
|
|
124
|
+
'menu-item-object' => 'page',
|
|
125
|
+
'menu-item-object-id' => $pages[$item['page']],
|
|
126
|
+
'menu-item-type' => 'post_type',
|
|
127
|
+
'menu-item-status' => 'publish',
|
|
128
|
+
'menu-item-position' => $position + 1,
|
|
129
|
+
]), 'menu item ' . $item['title']);
|
|
130
|
+
update_post_meta($itemId, KIVO_WP_FIXTURE_META, 1);
|
|
131
|
+
}
|
|
132
|
+
if (array_key_exists($menu['location'], get_registered_nav_menus())) {
|
|
133
|
+
$locations = get_theme_mod('nav_menu_locations', []);
|
|
134
|
+
$locations[$menu['location']] = $menuId;
|
|
135
|
+
set_theme_mod('nav_menu_locations', $locations);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 6. Options, written by key. {"page": "<slug>"} resolves to that fixture page's id.
|
|
140
|
+
foreach ($kivoWpLoad('options') as $key => $value) {
|
|
141
|
+
if (is_array($value) && isset($value['page'])) {
|
|
142
|
+
$value = $pages[$value['page']];
|
|
143
|
+
}
|
|
144
|
+
update_option($key, $value);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
WP_CLI::success(sprintf(
|
|
148
|
+
'Seeded %d users, %d pages and %d posts of synthetic fixtures.',
|
|
149
|
+
count($users),
|
|
150
|
+
count($pages),
|
|
151
|
+
count($kivoWpLoad('posts')) - count($pages)
|
|
152
|
+
));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
[
|
|
2
|
+
{ "taxonomy": "category", "name": "News", "slug": "news", "description": "Project updates." },
|
|
3
|
+
{ "taxonomy": "category", "name": "Guides", "slug": "guides", "description": "How-to articles." },
|
|
4
|
+
{ "taxonomy": "post_tag", "name": "Sample", "slug": "sample" },
|
|
5
|
+
{ "taxonomy": "post_tag", "name": "Fixture", "slug": "fixture" }
|
|
6
|
+
]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"login": "editor",
|
|
4
|
+
"email": "editor@example.test",
|
|
5
|
+
"display_name": "Erin Editor",
|
|
6
|
+
"first_name": "Erin",
|
|
7
|
+
"last_name": "Editor",
|
|
8
|
+
"role": "editor"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"login": "author",
|
|
12
|
+
"email": "author@example.test",
|
|
13
|
+
"display_name": "Alex Author",
|
|
14
|
+
"first_name": "Alex",
|
|
15
|
+
"last_name": "Author",
|
|
16
|
+
"role": "author"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"login": "subscriber",
|
|
20
|
+
"email": "subscriber@example.test",
|
|
21
|
+
"display_name": "Sam Subscriber",
|
|
22
|
+
"first_name": "Sam",
|
|
23
|
+
"last_name": "Subscriber",
|
|
24
|
+
"role": "subscriber"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
|
|
5
|
+
import { VERSION_REGISTRY, serversidePhpImage } from "../../lib/config/versions.js";
|
|
6
|
+
import { buildCloudAllowlist } from "../../lib/core/cloud-allowlist.js";
|
|
7
|
+
import { log, color } from "../../lib/utils/logger.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Themes built into the production image: each has its own Composer and npm dependencies.
|
|
11
|
+
*/
|
|
12
|
+
function themeDirs(context) {
|
|
13
|
+
const contentDir = context.contentDir || "content";
|
|
14
|
+
const dirs = [];
|
|
15
|
+
if (context.enable_sage) dirs.push(`${contentDir}/themes/${context.projectName}`);
|
|
16
|
+
if (context.enable_blank_theme) {
|
|
17
|
+
dirs.push(`${contentDir}/themes/${context.blank_theme_name || `${context.projectName}-theme`}`);
|
|
18
|
+
}
|
|
19
|
+
return dirs;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* bin/ runner (D-023): script names are the contract kivo-wise reads; renaming one is a
|
|
24
|
+
* contract change. Every script sources bin/_lib.sh within its first 4 KB.
|
|
25
|
+
*/
|
|
26
|
+
export const BIN_SCRIPTS = Object.freeze([
|
|
27
|
+
"up",
|
|
28
|
+
"down",
|
|
29
|
+
"info",
|
|
30
|
+
"logs",
|
|
31
|
+
"shell",
|
|
32
|
+
"wp",
|
|
33
|
+
"php",
|
|
34
|
+
"composer",
|
|
35
|
+
"npm",
|
|
36
|
+
"node",
|
|
37
|
+
"dev",
|
|
38
|
+
"build",
|
|
39
|
+
"flush",
|
|
40
|
+
"reset-deps",
|
|
41
|
+
"db",
|
|
42
|
+
"db-export",
|
|
43
|
+
"db-import",
|
|
44
|
+
"test",
|
|
45
|
+
"stan",
|
|
46
|
+
"mago",
|
|
47
|
+
"e2e",
|
|
48
|
+
"xdebug",
|
|
49
|
+
"trust-cert",
|
|
50
|
+
"setup",
|
|
51
|
+
"seed",
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
// Lando tooling in editor workspace tasks, mapped to the kivo-wp bin/ scripts (D-030).
|
|
55
|
+
const LANDO_TASKS = {
|
|
56
|
+
start: ["bin/up"],
|
|
57
|
+
stop: ["bin/down"],
|
|
58
|
+
info: ["bin/info"],
|
|
59
|
+
yarn: ["bin/npm"],
|
|
60
|
+
composer: ["bin/composer"],
|
|
61
|
+
"redis-cli": ["bin/shell", "cache", "valkey-cli"],
|
|
62
|
+
"git-cz": ["bin/npm", "exec", "--", "git-cz"],
|
|
63
|
+
"commitlint-check": [
|
|
64
|
+
"bin/npm",
|
|
65
|
+
"exec",
|
|
66
|
+
"--",
|
|
67
|
+
"commitlint",
|
|
68
|
+
"--from",
|
|
69
|
+
"HEAD~1",
|
|
70
|
+
"--to",
|
|
71
|
+
"HEAD",
|
|
72
|
+
"--verbose",
|
|
73
|
+
],
|
|
74
|
+
"conventional-changelog": [
|
|
75
|
+
"bin/npm",
|
|
76
|
+
"exec",
|
|
77
|
+
"--",
|
|
78
|
+
"conventional-changelog",
|
|
79
|
+
"-p",
|
|
80
|
+
"angular",
|
|
81
|
+
"-i",
|
|
82
|
+
"CHANGELOG.md",
|
|
83
|
+
"-s",
|
|
84
|
+
],
|
|
85
|
+
mago: ["bin/mago", "format"],
|
|
86
|
+
"mago-check": ["bin/mago", "format", "--check"],
|
|
87
|
+
"mago-lint": ["bin/mago", "lint"],
|
|
88
|
+
"theme-bootstrap": ["bin/reset-deps"],
|
|
89
|
+
"theme-build": ["bin/build"],
|
|
90
|
+
"theme-dev": ["bin/dev"],
|
|
91
|
+
"theme-lint": ["bin/theme-lint"],
|
|
92
|
+
acorn: ["bin/wp", "acorn"],
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/** Rewrite Lando references in the generated editor workspace for kivo-wp. */
|
|
96
|
+
export function toKivoWpWorkspace(workspace) {
|
|
97
|
+
const tasks = workspace.tasks?.tasks ?? [];
|
|
98
|
+
workspace.tasks &&
|
|
99
|
+
(workspace.tasks.tasks = tasks.flatMap((task) => {
|
|
100
|
+
if (task.command !== "lando") return [task];
|
|
101
|
+
const [tool, ...rest] = task.args ?? [];
|
|
102
|
+
const mapped = LANDO_TASKS[tool];
|
|
103
|
+
if (!mapped) return [];
|
|
104
|
+
const [command, ...args] = mapped;
|
|
105
|
+
return [
|
|
106
|
+
{
|
|
107
|
+
...task,
|
|
108
|
+
label: task.label.replace(/Lando/g, "kivo-wp"),
|
|
109
|
+
command,
|
|
110
|
+
args: [...args, ...rest],
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
}));
|
|
114
|
+
|
|
115
|
+
const json = JSON.stringify(workspace)
|
|
116
|
+
.replace(/,?"\*\*\/\.lando(\/\*\*)?":true/g, "")
|
|
117
|
+
.replace(/,?"\*\*\/\.lando\/\*\*"/g, "")
|
|
118
|
+
.replace(/"lando"/g, '"kivo-wp"');
|
|
119
|
+
return JSON.parse(json.replace(/\{,/g, "{").replace(/\[,/g, "["));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* kivo-wp: the Docker Compose development environment (D-004, D-009, D-011, D-012).
|
|
124
|
+
* Renders compose.yaml (other modules may add compose.yaml.hbs fragments), the root
|
|
125
|
+
* Dockerfile, the nginx deny include, the Caddy config and the local mail MU plugin.
|
|
126
|
+
*/
|
|
127
|
+
export async function setupModule(context, generator) {
|
|
128
|
+
if (!context.enable_kivo_wp) return;
|
|
129
|
+
|
|
130
|
+
const contentDir = context.contentDir || "content";
|
|
131
|
+
const kivoWp = {
|
|
132
|
+
...VERSION_REGISTRY.kivoWp,
|
|
133
|
+
appImage: serversidePhpImage(context.phpVersion),
|
|
134
|
+
themeDirs: themeDirs(context),
|
|
135
|
+
};
|
|
136
|
+
const ctx = { ...context, contentDir, kivoWp, cloudAllowlist: buildCloudAllowlist(context) };
|
|
137
|
+
|
|
138
|
+
log(color.blue, "[kivo-wp] Rendering the Docker Compose environment");
|
|
139
|
+
|
|
140
|
+
await generator.generateModularFile({
|
|
141
|
+
baseTemplate: "compose.yaml",
|
|
142
|
+
baseModule: "kivo-wp",
|
|
143
|
+
modules: context.enabledModules || [],
|
|
144
|
+
context: ctx,
|
|
145
|
+
mergeStrategy: "concat",
|
|
146
|
+
header: [
|
|
147
|
+
"# kivo-wp: Docker Compose development environment generated by wp-kit.",
|
|
148
|
+
"# Use the bin/ scripts instead of calling docker compose directly.",
|
|
149
|
+
"# x-kivo-wp.contract is read by agent tooling: service and bin/ names are fixed for that version.",
|
|
150
|
+
"# Keep x-kivo-wp, service names and image keys free of YAML anchors and aliases.",
|
|
151
|
+
].join("\n"),
|
|
152
|
+
});
|
|
153
|
+
await generator.generateFile("Dockerfile", ctx, "kivo-wp");
|
|
154
|
+
await generator.generateFile(".dockerignore", ctx, "kivo-wp");
|
|
155
|
+
await generator.generateFile("server/nginx/deny.conf", ctx, "kivo-wp");
|
|
156
|
+
await generator.generateFile("server/caddy/Caddyfile", ctx, "kivo-wp");
|
|
157
|
+
for (const name of ["_lib.sh", ...BIN_SCRIPTS]) {
|
|
158
|
+
await generator.generateFile(`bin/${name}`, ctx, "kivo-wp");
|
|
159
|
+
await fs.chmod(path.join(generator.cwd, "bin", name), name === "_lib.sh" ? 0o644 : 0o755);
|
|
160
|
+
}
|
|
161
|
+
if (context.enable_sage && context.enable_lint) {
|
|
162
|
+
await generator.generateFile("bin/theme-lint", ctx, "sage");
|
|
163
|
+
await fs.chmod(path.join(generator.cwd, "bin", "theme-lint"), 0o755);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// One workspace container running the root compose.yaml (D-009, D-022); cloud session guide.
|
|
167
|
+
await generator.generateFile(".devcontainer/devcontainer.json", ctx, "kivo-wp");
|
|
168
|
+
await generator.generateFile("docs/cloud-sessions.md", ctx, "kivo-wp");
|
|
169
|
+
|
|
170
|
+
// Synthetic fixtures (D-002) read by bin/seed.
|
|
171
|
+
await generator.copyDirectory("fixtures", "kivo-wp", "fixtures");
|
|
172
|
+
|
|
173
|
+
// The spell-check dictionary of the Lando era lists "lando"; kivo-wp projects do not need it.
|
|
174
|
+
const cspellFile = path.join(generator.cwd, ".cspell.json");
|
|
175
|
+
if (await fs.pathExists(cspellFile)) {
|
|
176
|
+
const cspell = await fs.readJson(cspellFile);
|
|
177
|
+
if (Array.isArray(cspell.words)) cspell.words = cspell.words.filter((word) => word !== "lando");
|
|
178
|
+
await fs.writeJson(cspellFile, cspell, { spaces: 2 });
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const workspaceFile = path.join(generator.cwd, `${context.projectName}.code-workspace`);
|
|
182
|
+
if (await fs.pathExists(workspaceFile)) {
|
|
183
|
+
const workspace = await fs.readJson(workspaceFile);
|
|
184
|
+
await fs.writeJson(workspaceFile, toKivoWpWorkspace(workspace), { spaces: 2 });
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
await generator.generateFile(
|
|
188
|
+
"content/mu-plugins/kivo-wp-local-mail.php",
|
|
189
|
+
ctx,
|
|
190
|
+
"kivo-wp",
|
|
191
|
+
`${contentDir}/mu-plugins/kivo-wp-local-mail.php`,
|
|
192
|
+
);
|
|
193
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default [];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}} (kivo-wp)",
|
|
3
|
+
"image": "mcr.microsoft.com/devcontainers/base:3.0.14-noble",
|
|
4
|
+
"features": {
|
|
5
|
+
"ghcr.io/devcontainers/features/docker-in-docker:4": {},
|
|
6
|
+
"ghcr.io/devcontainers/features/node:2": {
|
|
7
|
+
"version": "lts"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"containerEnv": {
|
|
11
|
+
"KIVO_WP_CONTEXT": "devcontainer"
|
|
12
|
+
},
|
|
13
|
+
"postCreateCommand": "bin/setup",
|
|
14
|
+
"postStartCommand": "bin/up && if [ \"${CODESPACES:-}\" = \"true\" ]; then nohup bash -c 'while sleep 60; do bin/wp cron event run --due-now >/dev/null 2>&1; done' >/dev/null 2>&1 & fi",
|
|
15
|
+
"forwardPorts": [443, 80],
|
|
16
|
+
"portsAttributes": {
|
|
17
|
+
"443": {
|
|
18
|
+
"label": "Site (Caddy, HTTPS)",
|
|
19
|
+
"protocol": "https"
|
|
20
|
+
},
|
|
21
|
+
"80": {
|
|
22
|
+
"label": "Site (Caddy, HTTP; used by Codespaces forwarding)",
|
|
23
|
+
"protocol": "http"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"customizations": {
|
|
27
|
+
"vscode": {
|
|
28
|
+
"extensions": [
|
|
29
|
+
"bmewburn.vscode-intelephense-client",
|
|
30
|
+
"carthage-software.mago",
|
|
31
|
+
"oxc.oxc-vscode",
|
|
32
|
+
"ms-azuretools.vscode-docker"
|
|
33
|
+
],
|
|
34
|
+
"settings": {
|
|
35
|
+
"editor.formatOnSave": false,
|
|
36
|
+
"terminal.integrated.defaultProfile.linux": "bash"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Never sent to the build: secrets, local state and dependencies rebuilt inside the image.
|
|
2
|
+
.env
|
|
3
|
+
.env.*
|
|
4
|
+
!.env.example
|
|
5
|
+
auth.json
|
|
6
|
+
auth.json.tpl
|
|
7
|
+
.git
|
|
8
|
+
.github
|
|
9
|
+
.gitlab
|
|
10
|
+
**/node_modules
|
|
11
|
+
**/vendor
|
|
12
|
+
wp
|
|
13
|
+
{{contentDir}}/uploads
|
|
14
|
+
compose.override.yaml
|
|
15
|
+
.kivo-wise
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1
|
|
2
|
+
# kivo-wp image (D-011). Targets:
|
|
3
|
+
# base serversideup/php fpm-nginx with the extensions, WP-CLI and nginx rules WordPress needs
|
|
4
|
+
# development used by compose.yaml: Xdebug (off by default), host UID/GID, OPcache revalidation
|
|
5
|
+
# production project code with production dependencies and built theme assets
|
|
6
|
+
ARG PHP_VERSION={{phpVersion}}
|
|
7
|
+
|
|
8
|
+
FROM serversideup/php:${PHP_VERSION}-fpm-nginx-{{kivoWp.serversidePhpRelease}} AS base
|
|
9
|
+
|
|
10
|
+
USER root
|
|
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).
|
|
14
|
+
ARG WP_CLI_VERSION={{kivoWp.wpCli.version}}
|
|
15
|
+
ARG WP_CLI_SHA512={{kivoWp.wpCli.sha512}}
|
|
16
|
+
|
|
17
|
+
RUN install-php-extensions mysqli gd intl exif bcmath imagick \
|
|
18
|
+
&& curl -fsSL -o /usr/local/bin/wp \
|
|
19
|
+
"https://github.com/wp-cli/wp-cli/releases/download/v${WP_CLI_VERSION}/wp-cli-${WP_CLI_VERSION}.phar" \
|
|
20
|
+
&& echo "${WP_CLI_SHA512} /usr/local/bin/wp" | sha512sum -c - \
|
|
21
|
+
&& chmod 0755 /usr/local/bin/wp
|
|
22
|
+
|
|
23
|
+
# The project root is the web root (WordPress core lives in wp/).
|
|
24
|
+
ENV NGINX_WEBROOT=/var/www/html
|
|
25
|
+
|
|
26
|
+
# Sorted before the image's own server options so its 404 rules win (see the file).
|
|
27
|
+
COPY server/nginx/deny.conf /etc/nginx/server-opts.d/00-kivo-wp-deny.conf
|
|
28
|
+
{{#if useRocket}}
|
|
29
|
+
COPY server/www/rocket.conf /etc/nginx/server-opts.d/50-rocket.conf
|
|
30
|
+
{{/if}}
|
|
31
|
+
COPY server/php/php.ini /usr/local/etc/php/conf.d/zz-project.ini
|
|
32
|
+
|
|
33
|
+
USER www-data
|
|
34
|
+
|
|
35
|
+
FROM base AS development
|
|
36
|
+
|
|
37
|
+
USER root
|
|
38
|
+
|
|
39
|
+
ARG USER_ID=1000
|
|
40
|
+
ARG GROUP_ID=1000
|
|
41
|
+
|
|
42
|
+
# Bind-mounted files keep the developer's ownership; bin/xdebug toggles XDEBUG_MODE.
|
|
43
|
+
RUN install-php-extensions xdebug \
|
|
44
|
+
&& docker-php-serversideup-set-id www-data "${USER_ID}:${GROUP_ID}" \
|
|
45
|
+
&& docker-php-serversideup-set-file-permissions --owner "${USER_ID}:${GROUP_ID}" --service fpm-nginx
|
|
46
|
+
|
|
47
|
+
ENV XDEBUG_MODE=off \
|
|
48
|
+
PHP_OPCACHE_ENABLE=1 \
|
|
49
|
+
PHP_OPCACHE_VALIDATE_TIMESTAMPS=1 \
|
|
50
|
+
PHP_OPCACHE_REVALIDATE_FREQ=0
|
|
51
|
+
|
|
52
|
+
USER www-data
|
|
53
|
+
{{#if kivoWp.themeDirs.length}}
|
|
54
|
+
|
|
55
|
+
FROM node:{{nodeVersion}}-bookworm AS assets
|
|
56
|
+
|
|
57
|
+
WORKDIR /app
|
|
58
|
+
{{#each kivoWp.themeDirs}}
|
|
59
|
+
COPY {{this}}/ {{this}}/
|
|
60
|
+
RUN cd {{this}} \
|
|
61
|
+
&& if [ -f package-lock.json ]; then npm ci; else npm install; fi \
|
|
62
|
+
&& npm run build \
|
|
63
|
+
&& rm -rf node_modules
|
|
64
|
+
{{/each}}
|
|
65
|
+
{{/if}}
|
|
66
|
+
|
|
67
|
+
FROM base AS production
|
|
68
|
+
|
|
69
|
+
COPY --chown=www-data:www-data . /var/www/html
|
|
70
|
+
{{#each kivoWp.themeDirs}}
|
|
71
|
+
COPY --from=assets --chown=www-data:www-data /app/{{this}}/ /var/www/html/{{this}}/
|
|
72
|
+
{{/each}}
|
|
73
|
+
|
|
74
|
+
# Licensed packages: pass auth.json as a BuildKit secret (--secret id=composer_auth,src=auth.json);
|
|
75
|
+
# it is never written to a layer.
|
|
76
|
+
RUN --mount=type=secret,id=composer_auth,required=false,uid=33 \
|
|
77
|
+
set -eu; \
|
|
78
|
+
if [ -f /run/secrets/composer_auth ]; then COMPOSER_AUTH="$(cat /run/secrets/composer_auth)"; export COMPOSER_AUTH; fi; \
|
|
79
|
+
for dir in /var/www/html{{#each kivoWp.themeDirs}} /var/www/html/{{this}}{{/each}}; do \
|
|
80
|
+
if [ -f "${dir}/composer.json" ]; then \
|
|
81
|
+
composer install --working-dir="${dir}" --no-dev --no-interaction --no-progress --prefer-dist --optimize-autoloader; \
|
|
82
|
+
fi; \
|
|
83
|
+
done
|