@codigodoleo/wp-kit 5.0.1 → 5.1.0

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.
Files changed (68) hide show
  1. package/lib/commands/init.js +87 -78
  2. package/lib/config/versions.js +45 -45
  3. package/lib/core/infer-ci-capabilities.js +39 -26
  4. package/lib/prompts/index.js +113 -92
  5. package/lib/utils/logger.js +1 -1
  6. package/modules/blank-theme/index.js +49 -41
  7. package/modules/blank-theme/prompts.js +9 -25
  8. package/modules/blank-theme/templates/.lando.yml.hbs +5 -8
  9. package/modules/blank-theme/templates/functions.php.hbs +21 -15
  10. package/modules/blank-theme/templates/package.json.hbs +1 -1
  11. package/modules/deploy/index.js +51 -61
  12. package/modules/deploy/prompts.js +36 -12
  13. package/modules/deploy/templates/.github/workflows/ci.yml.hbs +356 -63
  14. package/modules/deploy/templates/.gitlab/ci/lint-blank-theme.yml.hbs +4 -4
  15. package/modules/deploy/templates/.gitlab/ci/lint-mu-plugin.yml.hbs +3 -2
  16. package/modules/deploy/templates/.gitlab/ci/lint-plugin.yml.hbs +3 -2
  17. package/modules/deploy/templates/.gitlab/ci/lint-sage.yml.hbs +17 -14
  18. package/modules/git/.lintstagedrc.json +2 -5
  19. package/modules/lint/.oxlintrc.json +19 -0
  20. package/modules/lint/.prettierignore +16 -1
  21. package/modules/lint/index.js +32 -40
  22. package/modules/lint/templates/mago.toml.hbs +83 -0
  23. package/modules/lint/templates/package.json.hbs +6 -10
  24. package/modules/lint/templates/workspace.json.hbs +2 -36
  25. package/modules/mu-plugin/index.js +64 -56
  26. package/modules/mu-plugin/prompts.js +21 -23
  27. package/modules/mu-plugin/templates/.lando.yml.hbs +8 -10
  28. package/modules/mu-plugin/templates/acorn/app/Providers/CoreServiceProvider.php.hbs +1 -1
  29. package/modules/mu-plugin/templates/acorn/composer.json.hbs +6 -5
  30. package/modules/mu-plugin/templates/composer.json.hbs +4 -2
  31. package/modules/php/templates/.lando.yml.hbs +13 -8
  32. package/modules/php/templates/composer.json.hbs +15 -7
  33. package/modules/php/templates/workspace.json.hbs +22 -19
  34. package/modules/plugin/index.js +10 -18
  35. package/modules/plugin/prompts.js +5 -19
  36. package/modules/plugin/templates/.lando.yml.hbs +8 -10
  37. package/modules/plugin/templates/composer.json.hbs +4 -2
  38. package/modules/sage/index.js +78 -88
  39. package/modules/sage/prompts.js +10 -24
  40. package/modules/sage/templates/.lando.yml.hbs +17 -7
  41. package/modules/sage/templates/theme/composer.json.hbs +36 -23
  42. package/modules/sage/templates/theme/package.json.hbs +24 -13
  43. package/modules/sage/templates/theme/style.css.hbs +12 -20
  44. package/modules/test/templates/composer.json.hbs +1 -1
  45. package/package.json +30 -35
  46. package/templates/.devcontainer/devcontainer.json.hbs +2 -2
  47. package/templates/.gitignore.hbs +9 -3
  48. package/templates/README.md.hbs +1 -1
  49. package/templates/auth.json.hbs +8 -0
  50. package/templates/composer.json.hbs +13 -5
  51. package/templates/package.json.hbs +2 -4
  52. package/templates/workspace.json.hbs +3 -4
  53. package/wp-config.php +5 -0
  54. package/modules/blank-theme/lint/eslint.config.mjs +0 -30
  55. package/modules/blank-theme/lint/pint.json +0 -11
  56. package/modules/deploy/.github/workflows/deploy-docker.yml +0 -104
  57. package/modules/deploy/.github/workflows/deploy-ssh.yml +0 -128
  58. package/modules/deploy/.github/workflows/release.yml +0 -57
  59. package/modules/mu-plugin/lint/eslint.config.mjs +0 -30
  60. package/modules/mu-plugin/lint/pint.json +0 -11
  61. package/modules/mu-plugin/templates/acorn/resources/.gitkeep +0 -0
  62. package/modules/mu-plugin/templates/acorn/storage/framework/cache/.gitkeep +0 -0
  63. package/modules/mu-plugin/templates/acorn/storage/framework/sessions/.gitkeep +0 -0
  64. package/modules/mu-plugin/templates/acorn/storage/framework/views/.gitkeep +0 -0
  65. package/modules/plugin/lint/eslint.config.mjs +0 -30
  66. package/modules/plugin/lint/pint.json +0 -11
  67. package/modules/sage/lint/eslint.config.mjs +0 -30
  68. package/modules/sage/lint/pint.json +0 -11
@@ -1,37 +1,37 @@
1
1
  // lib/prompts/index.js
2
- import inquirer from 'inquirer';
2
+ import inquirer from "inquirer";
3
3
 
4
- import { getGitUserDefaults } from '../utils/git.js';
5
- import { Generator } from '../core/generator.js';
4
+ import { getGitUserDefaults } from "../utils/git.js";
5
+ import { Generator } from "../core/generator.js";
6
6
 
7
- import { loadModulePrompts } from './loadModulePrompts.js';
7
+ import { loadModulePrompts } from "./loadModulePrompts.js";
8
8
 
9
9
  function parseBooleanEnv(value) {
10
- if (typeof value !== 'string') return null;
10
+ if (typeof value !== "string") return null;
11
11
  const normalized = value.trim().toLowerCase();
12
- if (['1', 'true', 'yes', 'on'].includes(normalized)) return true;
13
- if (['0', 'false', 'no', 'off'].includes(normalized)) return false;
12
+ if (["1", "true", "yes", "on"].includes(normalized)) return true;
13
+ if (["0", "false", "no", "off"].includes(normalized)) return false;
14
14
  return null;
15
15
  }
16
16
 
17
17
  function capitalizeToken(token) {
18
- if (!token) return '';
18
+ if (!token) return "";
19
19
 
20
20
  const normalized = token.toLowerCase();
21
21
  const dictionary = {
22
- wordpress: 'WordPress',
23
- wp: 'WP',
24
- api: 'API',
25
- ui: 'UI',
26
- ux: 'UX',
27
- cms: 'CMS',
28
- seo: 'SEO',
29
- php: 'PHP',
30
- js: 'JS',
31
- ci: 'CI',
32
- cd: 'CD',
33
- qa: 'QA',
34
- devops: 'DevOps',
22
+ wordpress: "WordPress",
23
+ wp: "WP",
24
+ api: "API",
25
+ ui: "UI",
26
+ ux: "UX",
27
+ cms: "CMS",
28
+ seo: "SEO",
29
+ php: "PHP",
30
+ js: "JS",
31
+ ci: "CI",
32
+ cd: "CD",
33
+ qa: "QA",
34
+ devops: "DevOps",
35
35
  };
36
36
 
37
37
  if (dictionary[normalized]) {
@@ -43,9 +43,9 @@ function capitalizeToken(token) {
43
43
 
44
44
  function parseRepositoryInfo(gitRepository, projectName) {
45
45
  const fallbackPath = `your-group/${projectName}`;
46
- const fallbackHost = 'gitlab.com';
46
+ const fallbackHost = "gitlab.com";
47
47
 
48
- if (!gitRepository || typeof gitRepository !== 'string') {
48
+ if (!gitRepository || typeof gitRepository !== "string") {
49
49
  return {
50
50
  repositoryHost: fallbackHost,
51
51
  repositoryPath: fallbackPath,
@@ -80,10 +80,10 @@ function parseRepositoryInfo(gitRepository, projectName) {
80
80
  }
81
81
 
82
82
  function deriveProjectMetadata({ projectName, gitRepository }) {
83
- const tokens = projectName.split('-').filter(Boolean);
84
- const projectTitle = tokens.map(capitalizeToken).join(' ');
85
- const projectPascal = tokens.map(capitalizeToken).join('');
86
- const projectSnake = projectName.replace(/-/g, '_');
83
+ const tokens = projectName.split("-").filter(Boolean);
84
+ const projectTitle = tokens.map(capitalizeToken).join(" ");
85
+ const projectPascal = tokens.map(capitalizeToken).join("");
86
+ const projectSnake = projectName.replace(/-/g, "_");
87
87
  const projectConstant = projectSnake.toUpperCase();
88
88
  const projectThemeSlug = `${projectName}-theme`;
89
89
  const repository = parseRepositoryInfo(gitRepository, projectName);
@@ -106,80 +106,101 @@ export async function runPrompts({ defaults = false } = {}) {
106
106
 
107
107
  const corePrompts = [
108
108
  {
109
- type: 'input',
110
- name: 'projectName',
111
- message: 'Project name (lowercase, hyphens only):',
112
- default: 'wordpress-dev',
109
+ type: "input",
110
+ name: "projectName",
111
+ message: "Project name (lowercase, hyphens only):",
112
+ default: "wordpress-dev",
113
113
  filter: (val) =>
114
114
  val
115
115
  .trim()
116
116
  .toLowerCase()
117
- .replace(/\s+/g, '-')
118
- .replace(/[^a-z0-9-]/g, ''),
117
+ .replace(/\s+/g, "-")
118
+ .replace(/[^a-z0-9-]/g, ""),
119
119
  validate: (val) =>
120
- /^[a-z0-9][a-z0-9-]*$/.test(val) || 'Use only lowercase letters, numbers and hyphens.',
120
+ /^[a-z0-9][a-z0-9-]*$/.test(val) || "Use only lowercase letters, numbers and hyphens.",
121
121
  },
122
122
  {
123
- type: 'input',
124
- name: 'projectDescription',
125
- message: 'Project description:',
126
- default: 'Generated with wp-devops',
123
+ type: "input",
124
+ name: "projectDescription",
125
+ message: "Project description:",
126
+ default: "Generated with wp-kit",
127
127
  },
128
128
  {
129
- type: 'input',
130
- name: 'projectVersion',
131
- message: 'Project version:',
132
- default: '1.0.0',
129
+ type: "input",
130
+ name: "projectVersion",
131
+ message: "Project version:",
132
+ default: "1.0.0",
133
133
  },
134
134
  {
135
- type: 'input',
136
- name: 'author',
137
- message: 'Author:',
135
+ type: "input",
136
+ name: "author",
137
+ message: "Author:",
138
138
  default: defaultsGit.author,
139
139
  },
140
140
  {
141
- type: 'input',
142
- name: 'authorEmail',
143
- message: 'Author email:',
141
+ type: "input",
142
+ name: "authorEmail",
143
+ message: "Author email:",
144
144
  default: defaultsGit.authorEmail,
145
145
  },
146
146
  {
147
- type: 'input',
148
- name: 'gitRepository',
149
- message: 'Repository URL:',
147
+ type: "input",
148
+ name: "gitRepository",
149
+ message: "Repository URL:",
150
150
  default: defaultsGit.gitRepository,
151
151
  },
152
152
  // phpVersion and nodeVersion are locked to '8.4' / '24' — injected into context, not prompted
153
153
  {
154
- type: 'list',
155
- name: 'wpCoreVersion',
156
- message: 'WordPress core version:',
157
- choices: ['6.9.4', '6.8.1', '6.7', '6.6'],
158
- default: '6.9.4',
154
+ type: "list",
155
+ name: "wpCoreVersion",
156
+ message: "WordPress core version:",
157
+ choices: ["7.0", "6.9.4", "6.8.1", "6.7"],
158
+ default: "7.0",
159
159
  },
160
160
  {
161
- type: 'confirm',
162
- name: 'useRocket',
163
- message: 'Use WP Rocket?',
161
+ type: "confirm",
162
+ name: "useRocket",
163
+ message: "Use WP Rocket?",
164
164
  default: true,
165
165
  },
166
166
  {
167
- type: 'confirm',
168
- name: 'enableDebug',
169
- message: 'Enable debug mode?',
167
+ type: "confirm",
168
+ name: "enableDebug",
169
+ message: "Enable debug mode?",
170
170
  default: false,
171
171
  },
172
172
  {
173
- type: 'checkbox',
174
- name: 'selectedContentModules',
175
- message: 'Selecione os módulos de conteúdo do projeto:',
173
+ type: "checkbox",
174
+ name: "selectedContentModules",
175
+ message: "Selecione os módulos de conteúdo do projeto:",
176
176
  choices: [
177
- { name: 'Sage theme (Roots + Acorn + Vite)', value: 'sage' },
178
- { name: 'Blank theme (Vite + SCSS, sem Sage)', value: 'blank-theme' },
179
- { name: 'MU Plugin scaffold', value: 'mu-plugin' },
180
- { name: 'Plugin scaffold', value: 'plugin' },
177
+ { name: "Sage theme (Roots + Acorn + Vite)", value: "sage" },
178
+ { name: "Blank theme (Vite + SCSS, sem Sage)", value: "blank-theme" },
179
+ { name: "MU Plugin scaffold", value: "mu-plugin" },
180
+ { name: "Plugin scaffold", value: "plugin" },
181
181
  ],
182
- default: ['sage'],
182
+ default: ["sage"],
183
+ },
184
+ {
185
+ type: "confirm",
186
+ name: "enable_acf_pro",
187
+ message: "Install ACF Pro via Composer? (requires license key)",
188
+ default: true,
189
+ },
190
+ {
191
+ type: "input",
192
+ name: "acf_license_key",
193
+ message:
194
+ "ACF Pro license key (from connect.advancedcustomfields.com — leave blank to configure later):",
195
+ default: "",
196
+ when: (answers) => answers.enable_acf_pro,
197
+ },
198
+ {
199
+ type: "input",
200
+ name: "acf_site_url",
201
+ message: "Licensed site URL (must match ACF account):",
202
+ when: (answers) => answers.enable_acf_pro,
203
+ default: (answers) => `https://${answers.projectName || "mysite"}.com`,
183
204
  },
184
205
  ];
185
206
 
@@ -192,14 +213,14 @@ export async function runPrompts({ defaults = false } = {}) {
192
213
  for (const prompt of allPrompts) {
193
214
  if (prompt.when && !prompt.when(defaultAnswers)) continue;
194
215
  const def = prompt.default;
195
- defaultAnswers[prompt.name] = typeof def === 'function' ? def(defaultAnswers) : def;
216
+ defaultAnswers[prompt.name] = typeof def === "function" ? def(defaultAnswers) : def;
196
217
  }
197
218
 
198
219
  const sel = defaultAnswers.selectedContentModules || [];
199
- defaultAnswers.enable_sage = sel.includes('sage');
200
- defaultAnswers.enable_blank_theme = sel.includes('blank-theme');
201
- defaultAnswers.enable_mu_plugin = sel.includes('mu-plugin');
202
- defaultAnswers.enable_plugin = sel.includes('plugin');
220
+ defaultAnswers.enable_sage = sel.includes("sage");
221
+ defaultAnswers.enable_blank_theme = sel.includes("blank-theme");
222
+ defaultAnswers.enable_mu_plugin = sel.includes("mu-plugin");
223
+ defaultAnswers.enable_plugin = sel.includes("plugin");
203
224
 
204
225
  // WP_KIT_ENABLE_SAGE: legacy single-module override. Use WP_KIT_CONTENT_MODULES for full control.
205
226
  const envEnableSage = parseBooleanEnv(process.env.WP_KIT_ENABLE_SAGE);
@@ -208,12 +229,12 @@ export async function runPrompts({ defaults = false } = {}) {
208
229
  // Sync selectedContentModules with env override
209
230
  if (envEnableSage) {
210
231
  defaultAnswers.selectedContentModules = [
211
- ...new Set([...(defaultAnswers.selectedContentModules || []), 'sage']),
232
+ ...new Set([...(defaultAnswers.selectedContentModules || []), "sage"]),
212
233
  ];
213
234
  } else {
214
235
  defaultAnswers.selectedContentModules = (
215
236
  defaultAnswers.selectedContentModules || []
216
- ).filter((m) => m !== 'sage');
237
+ ).filter((m) => m !== "sage");
217
238
  }
218
239
  }
219
240
 
@@ -224,15 +245,15 @@ export async function runPrompts({ defaults = false } = {}) {
224
245
  if (envContentModules !== undefined) {
225
246
  const modules = envContentModules
226
247
  ? envContentModules
227
- .split(',')
248
+ .split(",")
228
249
  .map((m) => m.trim())
229
250
  .filter(Boolean)
230
251
  : [];
231
252
  defaultAnswers.selectedContentModules = modules;
232
- defaultAnswers.enable_sage = modules.includes('sage');
233
- defaultAnswers.enable_blank_theme = modules.includes('blank-theme');
234
- defaultAnswers.enable_mu_plugin = modules.includes('mu-plugin');
235
- defaultAnswers.enable_plugin = modules.includes('plugin');
253
+ defaultAnswers.enable_sage = modules.includes("sage");
254
+ defaultAnswers.enable_blank_theme = modules.includes("blank-theme");
255
+ defaultAnswers.enable_mu_plugin = modules.includes("mu-plugin");
256
+ defaultAnswers.enable_plugin = modules.includes("plugin");
236
257
  }
237
258
 
238
259
  // WP_KIT_PROJECT_NAME: overrides the default project name (used for E2E tests).
@@ -247,7 +268,7 @@ export async function runPrompts({ defaults = false } = {}) {
247
268
  }
248
269
 
249
270
  const enabledModules = Object.keys(modulePromptDefs).filter(
250
- (mod) => defaultAnswers[`enable_${mod.replace(/-/g, '_')}`] === true
271
+ (mod) => defaultAnswers[`enable_${mod.replace(/-/g, "_")}`] === true,
251
272
  );
252
273
  const derived = deriveProjectMetadata({
253
274
  projectName: defaultAnswers.projectName,
@@ -257,8 +278,8 @@ export async function runPrompts({ defaults = false } = {}) {
257
278
  return {
258
279
  ...defaultAnswers,
259
280
  ...derived,
260
- phpVersion: '8.4',
261
- nodeVersion: '24',
281
+ phpVersion: "8.4",
282
+ nodeVersion: "24",
262
283
  enabledModules,
263
284
  projectDomain: `${defaultAnswers.projectName}.lndo.site`,
264
285
  salts: Generator.generateSalts(),
@@ -269,13 +290,13 @@ export async function runPrompts({ defaults = false } = {}) {
269
290
 
270
291
  // Derive enable_* flags from the checkbox selection
271
292
  const sel = answers.selectedContentModules || [];
272
- answers.enable_sage = sel.includes('sage');
273
- answers.enable_blank_theme = sel.includes('blank-theme');
274
- answers.enable_mu_plugin = sel.includes('mu-plugin');
275
- answers.enable_plugin = sel.includes('plugin');
293
+ answers.enable_sage = sel.includes("sage");
294
+ answers.enable_blank_theme = sel.includes("blank-theme");
295
+ answers.enable_mu_plugin = sel.includes("mu-plugin");
296
+ answers.enable_plugin = sel.includes("plugin");
276
297
 
277
298
  const enabledModules = Object.keys(modulePromptDefs).filter(
278
- (mod) => answers[`enable_${mod.replace(/-/g, '_')}`] === true
299
+ (mod) => answers[`enable_${mod.replace(/-/g, "_")}`] === true,
279
300
  );
280
301
  const derived = deriveProjectMetadata({
281
302
  projectName: answers.projectName,
@@ -285,8 +306,8 @@ export async function runPrompts({ defaults = false } = {}) {
285
306
  return {
286
307
  ...answers,
287
308
  ...derived,
288
- phpVersion: '8.4',
289
- nodeVersion: '24',
309
+ phpVersion: "8.4",
310
+ nodeVersion: "24",
290
311
  enabledModules,
291
312
  projectDomain: `${answers.projectName}.lndo.site`,
292
313
  salts: Generator.generateSalts(),
@@ -18,7 +18,7 @@ export const color = {
18
18
  };
19
19
 
20
20
  /**
21
- * Prints a formatted message with prefix [wp-devops] and optional color
21
+ * Prints a formatted message with prefix [leo-wp] and optional color
22
22
  * @param {Function} colorFn - Chalk color function (e.g. color.green)
23
23
  * @param {string} message - The message to print
24
24
  */
@@ -1,69 +1,77 @@
1
- import path from 'path';
1
+ import path from "path";
2
2
 
3
- import fs from 'fs-extra';
3
+ import fs from "fs-extra";
4
4
 
5
- import { log, color } from '../../lib/utils/logger.js';
5
+ import { log, color } from "../../lib/utils/logger.js";
6
+
7
+ /**
8
+ * Derive an UPPER_SNAKE constant prefix from a kebab/snake theme slug
9
+ * so the scaffolded functions.php compiles. PHP `define()` keys can
10
+ * contain hyphens, but bare-name references (`MY_NAME_VERSION`) cannot
11
+ * — those parse as subtraction.
12
+ *
13
+ * acme-theme -> ACME_THEME
14
+ * my-site-theme -> MY_SITE_THEME
15
+ * wp-futrading-theme -> WP_FUTRADING_THEME
16
+ */
17
+ function toConstantPrefix(slug) {
18
+ return slug
19
+ .split(/[-_]/)
20
+ .filter(Boolean)
21
+ .map((segment) => segment.toUpperCase())
22
+ .join("_");
23
+ }
6
24
 
7
25
  export async function setupModule(context, generator) {
8
26
  const themeName = context.blank_theme_name || `${context.projectName}-theme`;
9
27
  const themeDir = `content/themes/${themeName}`;
10
28
  const absoluteThemeDir = path.join(generator.cwd, themeDir);
11
29
 
30
+ const themeContext = {
31
+ ...context,
32
+ blank_theme_name: themeName,
33
+ blank_theme_constant_prefix: toConstantPrefix(themeName),
34
+ };
35
+
12
36
  log(color.blue, `[blank-theme] 📂 Scaffolding blank theme: ${themeDir}`);
13
37
 
14
38
  // 1. Ensure directories exist
15
- await fs.ensureDir(path.join(absoluteThemeDir, 'src', 'js'));
16
- await fs.ensureDir(path.join(absoluteThemeDir, 'src', 'scss'));
17
- await fs.ensureDir(path.join(absoluteThemeDir, 'php'));
39
+ await fs.ensureDir(path.join(absoluteThemeDir, "src", "js"));
40
+ await fs.ensureDir(path.join(absoluteThemeDir, "src", "scss"));
41
+ await fs.ensureDir(path.join(absoluteThemeDir, "php"));
18
42
 
19
43
  // 2. Generate static files
44
+ await generator.generateFile("style.css", themeContext, "blank-theme", `${themeDir}/style.css`);
20
45
  await generator.generateFile(
21
- 'style.css',
22
- { ...context, blank_theme_name: themeName },
23
- 'blank-theme',
24
- `${themeDir}/style.css`
25
- );
26
- await generator.generateFile(
27
- 'functions.php',
28
- { ...context, blank_theme_name: themeName },
29
- 'blank-theme',
30
- `${themeDir}/functions.php`
46
+ "functions.php",
47
+ themeContext,
48
+ "blank-theme",
49
+ `${themeDir}/functions.php`,
31
50
  );
32
51
  await generator.generateFile(
33
- 'vite.config.js',
34
- { ...context, blank_theme_name: themeName },
35
- 'blank-theme',
36
- `${themeDir}/vite.config.js`
52
+ "vite.config.js",
53
+ themeContext,
54
+ "blank-theme",
55
+ `${themeDir}/vite.config.js`,
37
56
  );
38
57
  await generator.generateFile(
39
- 'package.json',
40
- { ...context, blank_theme_name: themeName },
41
- 'blank-theme',
42
- `${themeDir}/package.json`
58
+ "package.json",
59
+ themeContext,
60
+ "blank-theme",
61
+ `${themeDir}/package.json`,
43
62
  );
44
63
 
45
64
  // 3. src/ scaffolds
46
- await fs.ensureFile(path.join(absoluteThemeDir, 'src', 'js', 'app.js'));
47
- await fs.ensureFile(path.join(absoluteThemeDir, 'src', 'scss', 'app.scss'));
65
+ await fs.ensureFile(path.join(absoluteThemeDir, "src", "js", "app.js"));
66
+ await fs.ensureFile(path.join(absoluteThemeDir, "src", "scss", "app.scss"));
48
67
 
49
68
  // 4. Lint configs co-located in theme — always installed (IDE/editor support)
50
- log(color.blue, '[blank-theme] 🔧 Installing lint configurations...');
51
- await generator.copyFile('lint/.prettierrc.json', 'blank-theme', `${themeDir}/.prettierrc.json`);
52
- if (context.blank_theme_lint_eslint !== false) {
53
- await generator.copyFile(
54
- 'lint/eslint.config.mjs',
55
- 'blank-theme',
56
- `${themeDir}/eslint.config.mjs`
57
- );
58
- }
59
- if (context.blank_theme_lint_pint !== false) {
60
- await generator.copyFile('lint/pint.json', 'blank-theme', `${themeDir}/pint.json`);
61
- }
69
+ log(color.blue, "[blank-theme] 🔧 Installing lint configurations...");
62
70
  if (context.blank_theme_lint_stylelint !== false) {
63
71
  await generator.copyFile(
64
- 'lint/.stylelintrc.json',
65
- 'blank-theme',
66
- `${themeDir}/.stylelintrc.json`
72
+ "lint/.stylelintrc.json",
73
+ "blank-theme",
74
+ `${themeDir}/.stylelintrc.json`,
67
75
  );
68
76
  }
69
77
 
@@ -1,33 +1,17 @@
1
1
  export default [
2
2
  {
3
- type: 'input',
4
- name: 'blank_theme_name',
5
- message: 'Blank theme slug (used as directory name):',
6
- default: (answers) => `${answers.projectName || 'wordpress'}-theme`,
7
- when: (answers) => answers.selectedContentModules?.includes('blank-theme'),
3
+ type: "input",
4
+ name: "blank_theme_name",
5
+ message: "Blank theme slug (used as directory name):",
6
+ default: (answers) => `${answers.projectName || "wordpress"}-theme`,
7
+ when: (answers) => answers.selectedContentModules?.includes("blank-theme"),
8
8
  },
9
9
  {
10
- type: 'confirm',
11
- name: 'blank_theme_lint_eslint',
12
- message: 'Blank Theme: enable ESLint for JS/TS?',
10
+ type: "confirm",
11
+ name: "blank_theme_lint_stylelint",
12
+ message: "Blank Theme: enable Stylelint for CSS/SCSS?",
13
13
  default: true,
14
14
  when: (answers) =>
15
- answers.selectedContentModules?.includes('blank-theme') && answers.enable_lint,
16
- },
17
- {
18
- type: 'confirm',
19
- name: 'blank_theme_lint_stylelint',
20
- message: 'Blank Theme: enable Stylelint for CSS/SCSS?',
21
- default: true,
22
- when: (answers) =>
23
- answers.selectedContentModules?.includes('blank-theme') && answers.enable_lint,
24
- },
25
- {
26
- type: 'confirm',
27
- name: 'blank_theme_lint_pint',
28
- message: 'Blank Theme: enable Pint for PHP?',
29
- default: true,
30
- when: (answers) =>
31
- answers.selectedContentModules?.includes('blank-theme') && answers.enable_lint,
15
+ answers.selectedContentModules?.includes("blank-theme") && answers.enable_lint,
32
16
  },
33
17
  ];
@@ -8,19 +8,16 @@ tooling:
8
8
  description: Build blank theme assets
9
9
  cmd: npm run build --prefix /app/content/themes/{{blank_theme_name}}
10
10
  {{#if enable_lint}}
11
- bt-eslint:
11
+ bt-lint:
12
12
  service: build
13
- description: Lint JS/TS in blank theme
14
- cmd: npx eslint --fix src/js/ --config /app/content/themes/{{blank_theme_name}}/eslint.config.mjs
13
+ description: Lint JS/TS in blank theme (oxlint)
14
+ cmd: npx oxlint --fix src/js/
15
15
  dir: /app/content/themes/{{blank_theme_name}}
16
+ {{#if blank_theme_lint_stylelint}}
16
17
  bt-stylelint:
17
18
  service: build
18
19
  description: Lint CSS/SCSS in blank theme
19
20
  cmd: npx stylelint --fix "src/scss/**/*.scss" --config /app/content/themes/{{blank_theme_name}}/.stylelintrc.json
20
21
  dir: /app/content/themes/{{blank_theme_name}}
21
- bt-pint:
22
- service: appserver
23
- description: Lint PHP in blank theme
24
- dir: /app/content/themes/{{blank_theme_name}}
25
- cmd: ./vendor/bin/pint
22
+ {{/if}}
26
23
  {{/if}}
@@ -5,42 +5,48 @@
5
5
  * @package {{blank_theme_name}}
6
6
  */
7
7
 
8
- if (!defined('ABSPATH')) {
8
+ declare(strict_types=1);
9
+
10
+ if (! defined('ABSPATH')) {
9
11
  exit;
10
12
  }
11
13
 
12
- define('{{blank_theme_name}}_VERSION', '{{projectVersion}}');
13
- define('{{blank_theme_name}}_DIR', get_template_directory());
14
- define('{{blank_theme_name}}_URI', get_template_directory_uri());
14
+ define('{{blank_theme_constant_prefix}}_VERSION', '{{projectVersion}}');
15
+ define('{{blank_theme_constant_prefix}}_DIR', get_template_directory());
16
+ define('{{blank_theme_constant_prefix}}_URI', get_template_directory_uri());
15
17
 
16
18
  /**
17
- * Enqueue Vite-compiled assets.
19
+ * Enqueue Vite-compiled assets when the manifest exists.
18
20
  */
19
- add_action('wp_enqueue_scripts', function () {
20
- $manifest = {{blank_theme_name}}_DIR . '/dist/.vite/manifest.json';
21
+ add_action('wp_enqueue_scripts', static function (): void {
22
+ $manifest_path = {{blank_theme_constant_prefix}}_DIR . '/dist/.vite/manifest.json';
21
23
 
22
- if (!file_exists($manifest)) {
24
+ if (! file_exists($manifest_path)) {
23
25
  return;
24
26
  }
25
27
 
26
- $data = json_decode(file_get_contents($manifest), true);
28
+ $manifest = json_decode((string) file_get_contents($manifest_path), true);
29
+
30
+ if (! is_array($manifest)) {
31
+ return;
32
+ }
27
33
 
28
- if (isset($data['src/js/app.js']['file'])) {
34
+ if (isset($manifest['src/js/app.js']['file'])) {
29
35
  wp_enqueue_script(
30
36
  '{{blank_theme_name}}-app',
31
- {{blank_theme_name}}_URI . '/dist/' . $data['src/js/app.js']['file'],
37
+ {{blank_theme_constant_prefix}}_URI . '/dist/' . $manifest['src/js/app.js']['file'],
32
38
  [],
33
- null,
39
+ {{blank_theme_constant_prefix}}_VERSION,
34
40
  true
35
41
  );
36
42
  }
37
43
 
38
- if (isset($data['src/scss/app.scss']['file'])) {
44
+ if (isset($manifest['src/scss/app.scss']['file'])) {
39
45
  wp_enqueue_style(
40
46
  '{{blank_theme_name}}-app',
41
- {{blank_theme_name}}_URI . '/dist/' . $data['src/scss/app.scss']['file'],
47
+ {{blank_theme_constant_prefix}}_URI . '/dist/' . $manifest['src/scss/app.scss']['file'],
42
48
  [],
43
- null
49
+ {{blank_theme_constant_prefix}}_VERSION
44
50
  );
45
51
  }
46
52
  });
@@ -6,7 +6,7 @@
6
6
  "scripts": {
7
7
  "dev": "vite",
8
8
  "build": "vite build",
9
- "lint": "eslint src/js --ext .js,.ts",
9
+ "lint": "oxlint src/js/",
10
10
  "lint:css": "stylelint \"src/scss/**/*.scss\""
11
11
  },
12
12
  "devDependencies": {